Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
See: #1081
  • Loading branch information
dteviot committed Sep 24, 2023
1 parent 4ca1bc8 commit 937e0e5
Showing 1 changed file with 27 additions and 6 deletions.
33 changes: 27 additions & 6 deletions plugin/js/parsers/230BookParser.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"use strict";

parserFactory.register("230book.net", () => new _230BookParser() );
parserFactory.register("38xs.com", () => new _38xsParser() );

class _230BookParser extends Parser{
class _230BookBaseParser extends Parser{
constructor() {
super();
}
Expand All @@ -28,11 +29,6 @@ class _230BookParser extends Parser{
return util.getFirstImgSrc(dom, "#fmimg");
}

async fetchChapter(url) {
// site does not tell us gbk is used to encode text
return (await HttpClient.wrapFetch(url, this.makeOptions())).responseXML;
}

makeOptions() {
return ({
makeTextDecoder: () => new TextDecoder("gbk")
Expand All @@ -43,3 +39,28 @@ class _230BookParser extends Parser{
return [...dom.querySelectorAll("div#intro")];
}
}

class _230BookParser extends _230BookBaseParser{
constructor() {
super();
}

async fetchChapter(url) {
// site does not tell us gbk is used to encode text
return (await HttpClient.wrapFetch(url, this.makeOptions())).responseXML;
}
}

class _38xsParser extends _230BookBaseParser{
constructor() {
super();
}

async getChapterUrls(dom) {
let list = await super.getChapterUrls(dom);
// has 12 most recent chapters at start of table
return 25 < list.length
? list.slice(13)
: list;
}
}

0 comments on commit 937e0e5

Please sign in to comment.