From d8ac1e0770a0385881eec250607c8a1621ffcca4 Mon Sep 17 00:00:00 2001 From: ktrin-u Date: Tue, 23 Apr 2024 00:02:06 +0800 Subject: [PATCH] Update site https://allnovelnext.com - added alias https://novelfull.com - added alias https://novelfull.net - lint tests ok (reached Wrote Zip to disk) - unit tests passed (Tests completed in 631 milliseconds. 566 assertions of 566 passed, 0 failed.) - added name to package.json and readme.md --- package.json | 3 +- plugin/js/parsers/NovelNextParser.js | 56 ++++++++++++++++++++++++++++ plugin/js/parsers/NovelfullParser.js | 2 + plugin/popup.html | 1 + readme.md | 1 + 5 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 plugin/js/parsers/NovelNextParser.js diff --git a/package.json b/package.json index 6e9c518c..2196c58d 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,8 @@ { "name": "Naheulf"}, { "name": "perishableloc"}, { "name": "praschke"}, - { "name": "ImmortalDreamer"} + { "name": "ImmortalDreamer"}, + { "name": "ktrin"} ], "license": "GPL-3.0-only", "bugs": { diff --git a/plugin/js/parsers/NovelNextParser.js b/plugin/js/parsers/NovelNextParser.js new file mode 100644 index 00000000..28b9ca9c --- /dev/null +++ b/plugin/js/parsers/NovelNextParser.js @@ -0,0 +1,56 @@ +"use strict"; + +parserFactory.register("novelnext.com", () => new NovelNextParser()); + +class NovelNextParser extends Parser{ + constructor() { + super(); + } + + getChapterUrls(dom) { + let chapters = NovelNextParser.extractChapterList(dom) + if (0 < chapters.length) { + return Promise.resolve(chapters); + } + return NovelNextParser.fetchChapterList(dom); + }; + + static fetchChapterList(dom) { + let novelId = dom.querySelector("div#rating").getAttribute("data-novel-id"); + let url = `https://novelnext.com/novelnext/${novelId}`; + return HttpClient.wrapFetch(url).then(function (xhr) { + return NovelNextParser.extractChapterList(xhr.responseXML); + }); + } + + static extractChapterList(dom) { + return [...dom.querySelectorAll("ul.list-chapter a")] + .map(a => util.hyperLinkToChapter(a)); + } + + findContent(dom) { + return dom.querySelector("div#chr-content"); + }; + + extractTitleImpl(dom) { + return dom.querySelector("h3.title"); + }; + + extractAuthor(dom) { + let authorLabel = dom.querySelector("ul.info li:nth-of-type(2) a"); + return (authorLabel === null) ? super.extractAuthor(dom) : authorLabel.textContent; + }; + + findChapterTitle(dom) { + return dom.querySelector("a.chr-title").textContent; + } + + findCoverImageUrl(dom) { + return util.getFirstImgSrc(dom, "div.book"); + } + + getInformationEpubItemChildNodes(dom) { + return [...dom.querySelectorAll("div.desc-text")]; + } + +} diff --git a/plugin/js/parsers/NovelfullParser.js b/plugin/js/parsers/NovelfullParser.js index 9de91dce..4ef5186f 100644 --- a/plugin/js/parsers/NovelfullParser.js +++ b/plugin/js/parsers/NovelfullParser.js @@ -25,6 +25,8 @@ parserFactory.register("novelfull.com", () => new NovelfullParser()); parserFactory.register("novelfull.net", () => new NovelfullParser()); parserFactory.register("novelfullbook.com", () => new NovelfullParser()); parserFactory.register("novelmax.net", () => new NovelfullParser()); +parserFactory.register("novelnext.com", () => new NovelfullParser()); +parserFactory.register("novelnext.net", () => new NovelfullParser()); parserFactory.register("noveltop1.org", () => new NovelfullParser()); parserFactory.register("noveltrust.net", () => new NovelfullParser()); parserFactory.register("novelusb.com", () => new NovelfullParser()); diff --git a/plugin/popup.html b/plugin/popup.html index 771e53b6..bec098cb 100644 --- a/plugin/popup.html +++ b/plugin/popup.html @@ -667,6 +667,7 @@

Instructions

+ diff --git a/readme.md b/readme.md index d3ea63a9..004ebed5 100644 --- a/readme.md +++ b/readme.md @@ -56,6 +56,7 @@ Credits * perishableloc * praschke * ImmortalDreamer +* ktrin ## How to use with Baka-Tsuki: * Browse to a Baka-Tsuki web page that has the full text of a story.