Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
See: #1593
  • Loading branch information
dteviot committed Jan 7, 2025
1 parent 8244e95 commit 8e0fa18
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 1 deletion.
3 changes: 2 additions & 1 deletion plugin/js/Parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
59 changes: 59 additions & 0 deletions plugin/js/parsers/XiaoshubaoParser.js
Original file line number Diff line number Diff line change
@@ -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")];
}
}
1 change: 1 addition & 0 deletions plugin/popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,7 @@ <h3>Instructions</h3>
<script src="js/parsers/WxscsPaser.js"></script>
<script src="js/parsers/XbiqugeParser.js"></script>
<script src="js/parsers/XenforoBatchParser.js"></script>
<script src="js/parsers/XiaoshubaoParser.js"></script>
<script src="js/parsers/ZenithNovelsParser.js"></script>
<script src="js/parsers/ZeonicrepublicParser.js"></script>
<script src="js/parsers/ZhenhunxiaoshuoParser.js"></script>
Expand Down

0 comments on commit 8e0fa18

Please sign in to comment.