diff --git a/plugin/js/Parser.js b/plugin/js/Parser.js index 72f88d80..c797e5c1 100644 --- a/plugin/js/Parser.js +++ b/plugin/js/Parser.js @@ -750,8 +750,9 @@ class Parser { while(nextUrl != null) { let nextDom = (await HttpClient.wrapFetch(nextUrl)).responseXML; let newContent = this.findContent(nextDom); - util.moveChildElements(newContent, oldContent); nextUrl = moreChapterTextUrl(nextDom, url, ++count); + oldContent.appendChild(dom.createElement("br")); + util.moveChildElements(newContent, oldContent); } return dom; } diff --git a/plugin/js/parsers/XiaoshubaoParser.js b/plugin/js/parsers/XiaoshubaoParser.js new file mode 100644 index 00000000..57025fc3 --- /dev/null +++ b/plugin/js/parsers/XiaoshubaoParser.js @@ -0,0 +1,59 @@ +"use strict"; + +parserFactory.register("xiaoshubao.net", () => new XiaoshubaoParser()); + +class XiaoshubaoParser extends Parser{ + constructor() { + super(); + } + + async getChapterUrls(dom) { + return [...dom.querySelectorAll("#list > dl > dd a")] + .map(a => util.hyperLinkToChapter(a)); + } + + findContent(dom) { + return dom.querySelector("#content"); + } + + extractTitleImpl(dom) { + return dom.querySelector(".booktitle h1"); + } + + extractAuthor(dom) { + let authorLabel = dom.querySelector("#info p a"); + return authorLabel?.textContent ?? super.extractAuthor(dom); + } + + extractLanguage() { + return "zh"; + } + + removeUnwantedElementsFromContentElement(element) { + util.removeChildElementsMatchingCss(element, "p.to_nextpage"); + super.removeUnwantedElementsFromContentElement(element); + } + + findChapterTitle(dom) { + return dom.querySelector(".bookname h1"); + } + + findCoverImageUrl(dom) { + return util.getFirstImgSrc(dom, "#fmimg"); + } + + async fetchChapter(url) { + return this.walkPagesOfChapter(url, this.moreChapterTextUrl); + } + + moreChapterTextUrl(dom) { + let nextUrl = dom.querySelector("p.to_nextpage a"); + return (nextUrl != null && nextUrl.href.includes("_")) + ? nextUrl.href + : null; + } + + getInformationEpubItemChildNodes(dom) { + return [...dom.querySelectorAll("#intro")]; + } +} diff --git a/plugin/popup.html b/plugin/popup.html index df3ac1f2..3f2121d5 100644 --- a/plugin/popup.html +++ b/plugin/popup.html @@ -826,6 +826,7 @@