From 51f65c7cc7edd6d8e9d7e0b8016d84250439c05c Mon Sep 17 00:00:00 2001 From: dteviot Date: Tue, 28 Jan 2025 14:48:48 +1300 Subject: [PATCH] Add site https://www.novel543.com/ See: https://github.com/dteviot/WebToEpub/issues/1654 --- plugin/js/parsers/Novel543Parser.js | 53 +++++++++++++++++++++++++++++ plugin/popup.html | 1 + 2 files changed, 54 insertions(+) create mode 100644 plugin/js/parsers/Novel543Parser.js diff --git a/plugin/js/parsers/Novel543Parser.js b/plugin/js/parsers/Novel543Parser.js new file mode 100644 index 00000000..d04e4238 --- /dev/null +++ b/plugin/js/parsers/Novel543Parser.js @@ -0,0 +1,53 @@ +"use strict"; + +parserFactory.register("novel543.com", () => new Novel543Parser()); + +class Novel543Parser extends Parser{ + constructor() { + super(); + } + + async getChapterUrls(dom) { + let tocUrl = dom.baseURI + "dir"; + let nextDom = (await HttpClient.wrapFetch(tocUrl)).responseXML; + let menu = nextDom.querySelector("div.chaplist ul:nth-of-type(2)"); + return util.hyperlinksToChapterList(menu); + } + + findContent(dom) { + return dom.querySelector("div.chapter-content"); + } + + extractTitleImpl(dom) { + return dom.querySelector("h1.title"); + } + + extractAuthor(dom) { + let authorLabel = dom.querySelector("span.author"); + return authorLabel?.textContent ?? super.extractAuthor(dom); + } + + extractLanguage() { + return "zh"; + } + + findCoverImageUrl(dom) { + return util.getFirstImgSrc(dom, "div.cover"); + } + + async fetchChapter(url) { + return this.walkPagesOfChapter(url, this.moreChapterTextUrl); + } + + moreChapterTextUrl(dom) { + let has2underscores = (s) => ((s.match(/_/g) || []).length === 2); + let nextUrl = [...dom.querySelectorAll(".foot-nav a")].pop(); + return ((nextUrl != null) && has2underscores(nextUrl.href)) + ? nextUrl.href + : null; + } + + getInformationEpubItemChildNodes(dom) { + return [...dom.querySelectorAll("div.intro")]; + } +} diff --git a/plugin/popup.html b/plugin/popup.html index 89f0dc0d..bb5eb812 100644 --- a/plugin/popup.html +++ b/plugin/popup.html @@ -674,6 +674,7 @@

Instructions

+