From a511c1004b55da1c8b3cd1644b602b03f4b2e2d0 Mon Sep 17 00:00:00 2001 From: gamebeaker Date: Wed, 25 Sep 2024 20:41:38 +0200 Subject: [PATCH] Add NyahFanfictionParser --- package.json | 3 +- plugin/js/parsers/NyahFanfictionParser.js | 35 +++++++++++++++++++++++ plugin/popup.html | 1 + readme.md | 1 + 4 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 plugin/js/parsers/NyahFanfictionParser.js diff --git a/package.json b/package.json index f5e95da4..99883241 100644 --- a/package.json +++ b/package.json @@ -70,7 +70,8 @@ { "name": "ktrin"}, { "name": "Tyderion"}, { "name": "nozwock"}, - { "name": "Darthagnon"} + { "name": "Darthagnon"}, + { "name": "LucasFreitaslpf1"} ], "license": "GPL-3.0-only", "bugs": { diff --git a/plugin/js/parsers/NyahFanfictionParser.js b/plugin/js/parsers/NyahFanfictionParser.js new file mode 100644 index 00000000..d218d38a --- /dev/null +++ b/plugin/js/parsers/NyahFanfictionParser.js @@ -0,0 +1,35 @@ +"use strict"; + +parserFactory.register("fanfiction.com.br", () => new NyahFanfictionParser()); + +class NyahFanfictionParser extends Parser { + constructor() { + super(); + } + + async getChapterUrls(dom) { + let menu = dom.querySelector("div.container_chapter_list"); + return util.hyperlinksToChapterList(menu); + } + + findContent(dom) { + return dom.querySelector("div.historia"); + } + + extractTitleImpl(dom) { + return dom.querySelector("title"); + } + + extractAuthor(dom) { + let authorLabel = dom.querySelector("a.tooltip_userinfo"); + return authorLabel?.textContent ?? super.extractAuthor(dom); + } + + findCoverImageUrl(dom) { + return util.getFirstImgSrc(dom, "div#left_part"); + } + + getInformationEpubItemChildNodes(dom) { + return [...dom.querySelectorAll("p.justify")]; + } +} \ No newline at end of file diff --git a/plugin/popup.html b/plugin/popup.html index 3f557c3e..56e122f1 100644 --- a/plugin/popup.html +++ b/plugin/popup.html @@ -698,6 +698,7 @@

Instructions

+ diff --git a/readme.md b/readme.md index b2c07aa2..0d1686bd 100644 --- a/readme.md +++ b/readme.md @@ -59,6 +59,7 @@ Credits * nozwock * Tyderion * Darthagnon +* LucasFreitaslpf1 ## How to use with Baka-Tsuki: * Browse to a Baka-Tsuki web page that has the full text of a story.