From 940e61a7636bcbfef2844cd33ec975db3ec36723 Mon Sep 17 00:00:00 2001 From: gamebeaker Date: Tue, 24 Sep 2024 21:54:24 +0200 Subject: [PATCH 1/2] Add Book18Parser --- .gitignore | 3 +-- plugin/js/parsers/Book18Parser.js | 29 +++++++++++++++++++++++++++++ plugin/popup.html | 1 + 3 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 plugin/js/parsers/Book18Parser.js diff --git a/.gitignore b/.gitignore index cdc0f1d8..be19b5bc 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,4 @@ eslint/*.zip eslint/packed.js eslint/index.csv node_modules -plugin/**/*.* -!plugin/jszip/dist/jszip.min.js +plugin/jszip/dist/jszip.min.js diff --git a/plugin/js/parsers/Book18Parser.js b/plugin/js/parsers/Book18Parser.js new file mode 100644 index 00000000..327c384c --- /dev/null +++ b/plugin/js/parsers/Book18Parser.js @@ -0,0 +1,29 @@ +/* + Parses files on www.book18.org +*/ +"use strict"; + +parserFactory.register("book18.org", () => new Book18Parser()); + +class Book18Parser extends Parser{ + constructor() { + super(); + } + + async getChapterUrls(dom, chapterUrlsUI) { + let menu = dom.querySelector(".list-group"); + return util.hyperlinksToChapterList(menu); + } + + findContent(dom) { + return dom.querySelector("div#content"); + } + + extractTitleImpl(dom) { + return dom.querySelector("title"); + } + + removeUnwantedElementsFromContentElement(element) { + util.removeChildElementsMatchingCss(element, "span.d-none"); + } +} diff --git a/plugin/popup.html b/plugin/popup.html index 43b43943..ffde3fba 100644 --- a/plugin/popup.html +++ b/plugin/popup.html @@ -551,6 +551,7 @@

Instructions

+ From 3d646d283010cc2ea6521be35799b396a9dd91a4 Mon Sep 17 00:00:00 2001 From: gamebeaker Date: Tue, 24 Sep 2024 21:56:55 +0200 Subject: [PATCH 2/2] fix eslint Book18Parser --- plugin/js/parsers/Book18Parser.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/js/parsers/Book18Parser.js b/plugin/js/parsers/Book18Parser.js index 327c384c..d6b694f1 100644 --- a/plugin/js/parsers/Book18Parser.js +++ b/plugin/js/parsers/Book18Parser.js @@ -10,7 +10,7 @@ class Book18Parser extends Parser{ super(); } - async getChapterUrls(dom, chapterUrlsUI) { + async getChapterUrls(dom) { let menu = dom.querySelector(".list-group"); return util.hyperlinksToChapterList(menu); }