Skip to content

Commit 9fc6e99

Browse files
committed
Code was originally generated by AI and supplied by nothing0074 See: #2313
1 parent cdedd30 commit 9fc6e99

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
"use strict";
2+
parserFactory.register("novelshub.org", () => new NovelshubParser());
3+
class NovelshubParser extends Parser {
4+
constructor() {
5+
super();
6+
}
7+
8+
async getChapterUrls(dom) {
9+
let chapterList = dom.querySelector("article section div[role='tabpanel']");
10+
if (!chapterList) {
11+
return [];
12+
}
13+
14+
// Get the max chapter count from the CSS selector
15+
let maxChapter = chapterList.querySelectorAll("button.w-full")?.length;
16+
let baseUrl = dom.baseURI;
17+
let chapters = [];
18+
19+
// Generate URLs incrementing the final number from 1 to maxChapters
20+
for (let i = 1; i <= maxChapter; i++) {
21+
chapters.push({
22+
sourceUrl: baseUrl + "/Chapter-" + i,
23+
title: `Chapter ${i}`
24+
});
25+
}
26+
27+
return chapters;
28+
}
29+
findContent(dom) {
30+
return dom.querySelector("div.p-6");
31+
}
32+
extractTitleImpl(dom) {
33+
return dom.querySelector("h1.text-2xl");
34+
}
35+
extractAuthor(dom) {
36+
let authorLabel = dom.querySelector("div.flex:nth-child(3) > div:nth-child(2) > p:nth-child(1)");
37+
return authorLabel?.textContent ?? super.extractAuthor(dom);
38+
}
39+
extractDescription(dom) {
40+
var description = dom.querySelector("meta[name='description']")?.getAttribute("content");
41+
return description.trim();
42+
}
43+
findChapterTitle(dom) {
44+
return dom.querySelector("meta[property='og:title']")?.getAttribute("content");
45+
}
46+
findCoverImageUrl(dom) {
47+
return util.getFirstImgSrc(dom, "article section");
48+
}
49+
}

plugin/popup.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,7 @@ <h3>Instructions</h3>
794794
<script src="js/parsers/NovelNaverParser.js"></script>
795795
<script src="js/parsers/NovelOnlineFreeParser.js"></script>
796796
<script src="js/parsers/NovelsfullParser.js"></script>
797+
<script src="js/parsers/NovelshubParser.js"></script>
797798
<script src="js/parsers/NovelsOnlineParser.js"></script>
798799
<script src="js/parsers/NovelonomiconParser.js"></script>
799800
<script src="js/parsers/NovelpassionParser.js"></script>

0 commit comments

Comments
 (0)