Skip to content

Commit 6ebe24a

Browse files
committed
Fetch chapterlist for https://novelarrow.com
If user hasn't fetched the full chapter list, WebToEpub will do it. See: #2698
1 parent 09acc12 commit 6ebe24a

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

plugin/js/parsers/NovelarrowParser.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,27 @@ class NovelarrowParser extends Parser { // eslint-disable-line no-unused-vars
88
}
99

1010
async getChapterUrls(dom) {
11-
return [...dom.querySelectorAll(".jsx-6d23f35167deb67d.space-y-6 a")]
11+
let chapters = [...dom.querySelectorAll(".jsx-6d23f35167deb67d.space-y-6 a")]
1212
.map(a => ({
1313
sourceUrl: a.href,
1414
title: a.querySelector("span.hidden")?.textContent,
1515
}))
1616
.reverse();
17+
18+
if (NovelarrowParser.InitialChapterListMaxLength < chapters.length) {
19+
return chapters;
20+
}
21+
return this.fetchChapterListViaRest(dom);
22+
}
23+
24+
async fetchChapterListViaRest(dom) {
25+
let root = dom.baseURI.replace("/novel/", "/chapter/") + "/";
26+
let restUrl = dom.baseURI.replace("/novel/", "/api-web/novels/") + "/chapters?sort=asc";
27+
let json = (await HttpClient.fetchJson(restUrl)).json;
28+
return json.items.map(i => ({
29+
title: i.chapter_name,
30+
sourceUrl: root + i.chapter_id,
31+
}));
1732
}
1833

1934
findContent(dom) {
@@ -86,3 +101,6 @@ class NovelarrowParser extends Parser { // eslint-disable-line no-unused-vars
86101
return [...dom.querySelectorAll(".site-reading-copy")];
87102
}
88103
}
104+
105+
// When initially open ToC page, is pre-loaded with up to 30 chapters
106+
NovelarrowParser.InitialChapterListMaxLength = 30;

0 commit comments

Comments
 (0)