diff --git a/plugin/js/parsers/MidnightramblesParser.js b/plugin/js/parsers/MidnightramblesParser.js new file mode 100644 index 00000000..e8ebfcc3 --- /dev/null +++ b/plugin/js/parsers/MidnightramblesParser.js @@ -0,0 +1,30 @@ +"use strict"; + +parserFactory.register("midnightrambles.in", () => new MidnightramblesParser()); + +class MidnightramblesParser extends Parser{ + constructor() { + super(); + } + + async getChapterUrls(dom) { + let menu = dom.querySelector("article"); + return util.hyperlinksToChapterList(menu); + } + + findContent(dom) { + return dom.querySelector(".amp-wp-article-content"); + } + + extractTitleImpl(dom) { + return dom.querySelector(".amp-wp-title"); + } + + findChapterTitle(dom) { + return dom.querySelector(".amp-wp-title"); + } + + findCoverImageUrl(dom) { + return dom.querySelector(".amp-wp-article-content amp-img")?.getAttribute("src") ?? null; + } +} diff --git a/plugin/js/parsers/Template.js b/plugin/js/parsers/Template.js index fcac1982..6facf21e 100644 --- a/plugin/js/parsers/Template.js +++ b/plugin/js/parsers/Template.js @@ -88,8 +88,8 @@ class TemplateParser extends Parser{ // Major points to note // 1. Return the Author's name as a string, not a HTML element // 2. If can't find Author, call the base implementation - let authorLabel = util.getElement(dom, "strong", e => e.textContent === "Author:"); - return (authorLabel === null) ? super.extractAuthor(dom) : authorLabel.nextElementSibling.textContent; + let authorLabel = dom.querySelector(".meta span a"); + return authorLabel?.textContent ?? super.extractAuthor(dom); } */ diff --git a/plugin/popup.html b/plugin/popup.html index 5e979d47..0c43568c 100644 --- a/plugin/popup.html +++ b/plugin/popup.html @@ -638,6 +638,7 @@