diff --git a/plugin/js/parsers/DreamyTranslationsParser.js b/plugin/js/parsers/DreamyTranslationsParser.js new file mode 100644 index 00000000..525444a1 --- /dev/null +++ b/plugin/js/parsers/DreamyTranslationsParser.js @@ -0,0 +1,54 @@ +"use strict"; + +parserFactory.register("dreamy-translations.com", () => new DreamyTranslationsParser()); + +class DreamyTranslationsParser extends Parser { + constructor() { + super(); + } + + async getChapterUrls(dom) { + let links = [...dom.querySelectorAll("a")] + .filter(a => a.href && a.href.includes("/chapter/") && a.hasAttribute("data-chapter-index")); + + let chapters = links.map(a => { + let title = ""; + let chNumSpan = a.querySelector("span.font-medium"); + let titleP = a.querySelector("p.truncate"); + + if (chNumSpan && titleP) { + title = chNumSpan.textContent.trim() + " - " + titleP.textContent.trim(); + } else { + title = a.textContent.trim(); + } + + return { + sourceUrl: a.href, + title: title + }; + }); + + return chapters; + } + + findCoverImageUrl(dom) { + let img = dom.querySelector("img[src*='/covers/']"); + if (img) { + return img.src; + } + return super.findCoverImageUrl(dom); + } + + removeUnwantedElementsFromContentElement(element) { + util.removeElements(element.querySelectorAll("sup.tl-note")); + super.removeUnwantedElementsFromContentElement(element); + } + + findContent(dom) { + return dom.querySelector(".chapter-content"); + } + + findChapterTitle(dom) { + return dom.querySelector("button.text-2xl span > span"); + } +} diff --git a/plugin/popup.html b/plugin/popup.html index 0930ebb8..b7ebd89d 100644 --- a/plugin/popup.html +++ b/plugin/popup.html @@ -1,4 +1,4 @@ - + @@ -679,6 +679,7 @@

Instructions

+