Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
See: #809
  • Loading branch information
dteviot committed Sep 10, 2022
1 parent 36fff3c commit cc4d3b4
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
67 changes: 67 additions & 0 deletions plugin/js/parsers/888novelParser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
"use strict";

parserFactory.register("888novel.com", () => new _888novelParser());

class _888novelParser extends Parser{
constructor() {
super();
}

async getChapterUrls(dom, chapterUrlsUI) {
return this.getChapterUrlsFromMultipleTocPages(dom,
_888novelParser.extractPartialChapterList,
_888novelParser.getUrlsOfTocPages,
chapterUrlsUI
);
};

static getUrlsOfTocPages(dom) {
let pagination = dom.querySelector("ul.pagination");
let tocUrls = [];
if (pagination != null ) {
let tocLinks = [...pagination.querySelectorAll("a")]
.filter(a => a.textContent !== "»");
if (0 < tocLinks.length) {
let maxPageUrl = tocLinks.pop().href;
let index = maxPageUrl.lastIndexOf("/", maxPageUrl.length - 2);
let base = maxPageUrl.substring(0, index + 1);
let maxPage = parseInt(maxPageUrl.substring(index + 1).replace("#dsc", ""));
if (1 < maxPage) {
for(let i = 2; i <= maxPage; ++i) {
tocUrls.push(`${base}${i}/`);
}
}
}
}
return tocUrls;
}

static extractPartialChapterList(dom) {
let menu = dom.querySelector("#dsc ul.listchap");
return util.hyperlinksToChapterList(menu);
}

findContent(dom) {
return dom.querySelector("div.reading");
}

extractTitleImpl(dom) {
return dom.querySelector("h1");
}

findChapterTitle(dom) {
return dom.querySelector("h2");
}

findCoverImageUrl(dom) {
return util.getFirstImgSrc(dom, ".book3d");
}

getInformationEpubItemChildNodes(dom) {
let nodes = [...dom.querySelectorAll("div.tabs1")];
for(let n of nodes) {
n.setAttribute("style", null);
}
return nodes;
}
}
1 change: 1 addition & 0 deletions plugin/popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@ <h3>Instructions</h3>
<!-- Not used as base -->
<script src="js/parsers/230BookParser.js"></script>
<script src="js/parsers/69shuParser.js"></script>
<script src="js/parsers/888novelParser.js"></script>
<script src="js/parsers/ActiveTranslationsParser.js"></script>
<script src="js/parsers/AerialrainParser.js"></script>
<script src="js/parsers/AlphapolisParser.js"></script>
Expand Down

0 comments on commit cc4d3b4

Please sign in to comment.