Skip to content

Commit

Permalink
Merge pull request #1523 from gamebeaker/update-88xiaoshuo-and-Shuhaige
Browse files Browse the repository at this point in the history
update 88xiaoshuoParser
  • Loading branch information
gamebeaker authored Sep 28, 2024
2 parents 8bd1188 + 626bf37 commit c58f27f
Showing 1 changed file with 34 additions and 8 deletions.
42 changes: 34 additions & 8 deletions plugin/js/parsers/88xiaoshuoParser.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,32 @@
"use strict";

parserFactory.register("88xiaoshuo.net", () => new _88xiaoshuoParser());
parserFactory.register("m.88xiaoshuo.net", () => new _88xiaoshuoParser());
parserFactory.register("88xiaoshuo.net", () => new _88xiaoshuoParser());
parserFactory.register("m.ilwxs.com", () => new _88xiaoshuoParser());
parserFactory.register("ilwxs.com", () => new _88xiaoshuoParser());
parserFactory.register("m.ttshu8.com", () => new _88xiaoshuoParser());
parserFactory.register("ttshu8.com", () => new _88xiaoshuoParser());
parserFactory.register("m.xpaoshuba.com", () => new _88xiaoshuoParser());
parserFactory.register("xpaoshuba.com", () => new _88xiaoshuoParser());
parserFactory.register("m.shuhaige.net", () => new _88xiaoshuoParser());
parserFactory.register("shuhaige.net", () => new _88xiaoshuoParser());
parserFactory.register("m.qbxsw.com", () => new _88xiaoshuoParser());
parserFactory.register("qbxsw.com", () => new _88xiaoshuoParser());
parserFactory.register("m.38xs.com", () => new _88xiaoshuoParser());

class _88xiaoshuoParser extends Parser{
constructor() {
super();
this.infoPageDom = null;
}

async getChapterUrls(dom, chapterUrlsUI) {
let changedomurl = dom.baseURI;
if (changedomurl.includes("https://www.")) {
changedomurl = changedomurl.replace("https://www.","https://m.");
}
if (changedomurl != dom.baseURI) {
dom = (await HttpClient.fetchHtml(changedomurl)).responseXML;
}
return this.getChapterUrlsFromMultipleTocPages(dom,
this.extractPartialChapterList,
this.getUrlsOfTocPages,
Expand All @@ -21,14 +38,14 @@ class _88xiaoshuoParser extends Parser{
let lastPagespan = [...dom.querySelectorAll(".caption > span > a")];
let lastPage = null;
for (let node of lastPagespan) {
if (node.innerText == "尾页") {
if (node.innerText == "尾页" || node.innerText == "Last page") {
lastPage = node;
}
}
let urls = [];
if (lastPage) {
const lastPageNumber = parseInt(lastPage.href.split("/")[4].split("_")[1]);
const baseUrl = lastPage.baseURI.replace(/\/$/, "");
const lastPageNumber = parseInt(lastPage.href.substring(lastPage.href.search(/_[0-9]+\/?$/)).replace("_", "").replace("/", ""));
const baseUrl = lastPage.baseURI.replace(/_[0-9]+\/$/, "").replace(/\/$/, "");
for (let i = 2; i <= lastPageNumber; i++) {
urls.push(`${baseUrl}_${i}`);
}
Expand All @@ -50,8 +67,8 @@ class _88xiaoshuoParser extends Parser{
}

extractAuthor(dom) {
let element = dom.querySelector(".author > a");
return (element === null) ? null : element.textContent;
let element = dom.querySelector("#maininfo a[href*=\"author\"], .author a");
return (element === null) ? "" : element.textContent;
}

findChapterTitle(dom) {
Expand All @@ -60,6 +77,15 @@ class _88xiaoshuoParser extends Parser{
}

findCoverImageUrl(dom) {
return dom.querySelector(".detail > img")?.src ?? null;
return dom.querySelector(".box_con img, .detail > img")?.src ?? null;
}

getInformationEpubItemChildNodes(dom) {
return [...dom.querySelectorAll("#maininfo, .detail")];
}

extractDescription(dom) {
let element = dom.querySelector("#intro");
return (element === null) ? null : element.textContent;
}
}

0 comments on commit c58f27f

Please sign in to comment.