From ea9b8c14d74d3d1a80928c62c4909433c97976ac Mon Sep 17 00:00:00 2001 From: nothing0074 <88822838+nothing0074@users.noreply.github.com> Date: Sun, 16 Nov 2025 07:36:26 +0000 Subject: [PATCH 1/3] novelshub.org fetcher --- plugin/js/parsers/Novelshub.js | 67 ++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 plugin/js/parsers/Novelshub.js diff --git a/plugin/js/parsers/Novelshub.js b/plugin/js/parsers/Novelshub.js new file mode 100644 index 00000000..fe29cd60 --- /dev/null +++ b/plugin/js/parsers/Novelshub.js @@ -0,0 +1,67 @@ +"use strict"; +parserFactory.register("novelshub.org", () => new NovelshubParser()); +class NovelshubParser extends Parser { + constructor() { + super(); + } + async getChapterUrls(dom, chapterUrlsUI) { + // Scan for the base URL using the CSS selector + let chaptersUrlElement = dom.querySelector("div.hidden > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > a:nth-child(1)"); + if (!chaptersUrlElement) { + return []; + } + + // Get the max chapter count from the CSS selector + let maxChapterElement = dom.querySelector("div.relative:nth-child(2) > div:nth-child(1)"); + let maxChapters = 1000; // default fallback + if (maxChapterElement) { + let html = maxChapterElement.innerHTML; + // Extract number from pattern like "Chapters ( 97 )" + let match = html.match(/Chapters\s*\(\s*(\d+)\s*\)/i); + if (match && match[1]) { + let parsed = parseInt(match[1]); + if (!isNaN(parsed)) { + maxChapters = parsed; + } + } + } + + let baseUrl = chaptersUrlElement.href; + let chapters = []; + + // Generate URLs incrementing the final number from 1 to maxChapters + for (let i = 1; i <= maxChapters; i++) { + // Replace the final number in the URL with the current iteration number + let url = baseUrl.replace(/(\d+)(?!.*\d)/, i.toString()); + chapters.push({ + sourceUrl: url, + title: `Chapter ${i}` + }); + } + + return chapters; + } + findContent(dom) { + return dom.querySelector("div.p-6"); + } + extractTitleImpl(dom) { + return dom.querySelector("h1.text-2xl"); + } + extractAuthor(dom) { + let authorLabel = dom.querySelector("div.flex:nth-child(3) > div:nth-child(2) > p:nth-child(1)"); + return authorLabel?.textContent ?? super.extractAuthor(dom); + } + extractDescription(dom) { + return dom.querySelector("#react-aria7789978722-_r_1k4_-tabpanel-description > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(2) > div:nth-child(1) > p:nth-child(1)").textContent.trim(); + } + findChapterTitle(dom) { + return dom.querySelector("div.p-6 > p:nth-child(2) > strong:nth-child(1)"); + } + findCoverImageUrl(dom) { + let imgElement = dom.querySelector("img.rounded-lg"); + if (imgElement && imgElement.src) { + return imgElement.src; + } + return super.findCoverImageUrl(dom); + } +} \ No newline at end of file From 5a29060a0d9635f97ce8a5ce0dbb740ddd581e03 Mon Sep 17 00:00:00 2001 From: nothing0074 <88822838+nothing0074@users.noreply.github.com> Date: Sun, 16 Nov 2025 08:05:39 +0000 Subject: [PATCH 2/3] Add NovelshubParser.js script to popup.html --- plugin/popup.html | 1 + 1 file changed, 1 insertion(+) diff --git a/plugin/popup.html b/plugin/popup.html index 1d6cbcdc..b5c983a2 100644 --- a/plugin/popup.html +++ b/plugin/popup.html @@ -794,6 +794,7 @@