Skip to content

Commit 9d550d1

Browse files
authored
Merge pull request #1518 from gamebeaker/Add-88xiaoshuo.js
Add 88xiaoshuoParser
2 parents f95bf35 + 93eaae0 commit 9d550d1

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed

plugin/js/parsers/88xiaoshuoParser.js

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
"use strict";
2+
3+
parserFactory.register("88xiaoshuo.net", () => new _88xiaoshuoParser());
4+
parserFactory.register("m.88xiaoshuo.net", () => new _88xiaoshuoParser());
5+
6+
class _88xiaoshuoParser extends Parser{
7+
constructor() {
8+
super();
9+
this.infoPageDom = null;
10+
}
11+
12+
async getChapterUrls(dom, chapterUrlsUI) {
13+
return this.getChapterUrlsFromMultipleTocPages(dom,
14+
this.extractPartialChapterList,
15+
this.getUrlsOfTocPages,
16+
chapterUrlsUI
17+
);
18+
}
19+
20+
getUrlsOfTocPages(dom) {
21+
let lastPagespan = [...dom.querySelectorAll(".caption > span > a")];
22+
let lastPage = null;
23+
for (let node of lastPagespan) {
24+
if (node.innerText == "尾页") {
25+
lastPage = node;
26+
}
27+
}
28+
let urls = [];
29+
if (lastPage) {
30+
const lastPageNumber = parseInt(lastPage.href.split("/")[4].split("_")[1]);
31+
const baseUrl = lastPage.baseURI.replace(/\/$/, "");
32+
for (let i = 2; i <= lastPageNumber; i++) {
33+
urls.push(`${baseUrl}_${i}`);
34+
}
35+
}
36+
return urls;
37+
}
38+
39+
extractPartialChapterList(dom) {
40+
let chapterList = dom.querySelector(".read");
41+
return [...chapterList.querySelectorAll("a")].map(a => util.hyperLinkToChapter(a));
42+
}
43+
44+
findContent(dom) {
45+
return dom.querySelector("div.content");
46+
}
47+
48+
extractTitleImpl(dom) {
49+
return dom.querySelector(".name");
50+
}
51+
52+
extractAuthor(dom) {
53+
let element = dom.querySelector(".author > a");
54+
return (element === null) ? null : element.textContent;
55+
}
56+
57+
findChapterTitle(dom) {
58+
let element = dom.querySelector(".headline");
59+
return (element === null) ? null : element.textContent;
60+
}
61+
62+
findCoverImageUrl(dom) {
63+
return dom.querySelector(".detail > img")?.src ?? null;
64+
}
65+
}

plugin/popup.html

+1
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,7 @@ <h3>Instructions</h3>
534534
<script src="js/parsers/230BookParser.js"></script>
535535
<script src="js/parsers/4kswParser.js"></script>
536536
<script src="js/parsers/69shuParser.js"></script>
537+
<script src="js/parsers/88xiaoshuoParser.js"></script>
537538
<script src="js/parsers/888novelParser.js"></script>
538539
<script src="js/parsers/ActiveTranslationsParser.js"></script>
539540
<script src="js/parsers/AdultfanfictionParser.js"></script>

0 commit comments

Comments
 (0)