Skip to content

Commit

Permalink
Add site https://wfxs.tw/
Browse files Browse the repository at this point in the history
See: #1487
  • Loading branch information
dteviot committed Sep 16, 2024
1 parent ed73b1f commit 6437bb5
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
62 changes: 62 additions & 0 deletions plugin/js/parsers/WfxsParser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
"use strict";

parserFactory.register("wfxs.tw", () => new WfxsParser());

class WfxsParser extends Parser{
constructor() {
super();
}

async getChapterUrls(dom) {
let tocUrl = this.makeTocUrl(dom.baseURI);
let tocHtml = (await HttpClient.wrapFetch(tocUrl)).responseXML;
let menu = [...tocHtml.querySelectorAll("#readerlists")].pop();
return util.hyperlinksToChapterList(menu);
}

makeTocUrl(url) {
return url.substring(0, url.length - 1)
.replace("xiaoshuo", "booklist") + ".html";
}

findContent(dom) {
return Parser.findConstrutedContent(dom);
}

extractTitleImpl(dom) {
return dom.querySelector(".booktitle h1");
}

findCoverImageUrl(dom) {
return util.getFirstImgSrc(dom, "#bookimg");
}

async fetchChapter(url) {
let newDoc = Parser.makeEmptyDocForContent(url);
let dom = (await HttpClient.wrapFetch(url)).responseXML;
newDoc.content.appendChild(this.findRawContent(dom));
let nextPageUrl = this.findNextPageUrl(dom);
while (nextPageUrl != null) {
dom = (await HttpClient.wrapFetch(nextPageUrl)).responseXML;
newDoc.content.appendChild(this.findRawContent(dom));
nextPageUrl = this.findNextPageUrl(dom);
}
return newDoc.dom;
}

findRawContent(dom) {
return dom.querySelector(".chapter-content");
}

findNextPageUrl(dom) {
let link = [...dom.querySelectorAll(".foot-nav a")]
.map(l => l.href)[2];
return ((link != null) && link.endsWith(".html"))
? link
: null;
}

getInformationEpubItemChildNodes(dom) {
return [...dom.querySelectorAll("#intro_win p")];
}
}
1 change: 1 addition & 0 deletions plugin/popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,7 @@ <h3>Instructions</h3>
<script src="js/parsers/UntamedAlleyParser.js"></script>
<script src="js/parsers/VipNovelParser.js"></script>
<script src="js/parsers/Wenku8Parser.js"></script>
<script src="js/parsers/WfxsParser.js"></script>
<script src="js/parsers/WordexcerptParser.js"></script>
<script src="js/parsers/WorldnovelOnlineParser.js"></script>
<script src="js/parsers/XiaoshuoguiParser.js"></script>
Expand Down

0 comments on commit 6437bb5

Please sign in to comment.