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..d6b694f1 --- /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) { + 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 @@