Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
See: #1087,
#1059
  • Loading branch information
dteviot committed Oct 10, 2023
1 parent 6850755 commit 2d69f7b
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 1 deletion.
1 change: 0 additions & 1 deletion plugin/js/parsers/NoblemtlParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ parserFactory.register("daotranslate.com", () => new NoblemtlParser());
parserFactory.register("genesistls.com", () => new NoblemtlParser());
parserFactory.register("noblemtl.com", () => new NoblemtlParser());
parserFactory.register("tamagotl.com", () => new NoblemtlParser());
parserFactory.register("novelsemperor.com", () => new NoblemtlParser());
parserFactory.register("knoxt.space", () => new NoblemtlParser());
parserFactory.register("novelsknight.com", () => new NoblemtlParser());

Expand Down
56 changes: 56 additions & 0 deletions plugin/js/parsers/NovelsemperorParser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
"use strict";

parserFactory.register("novelsemperor.com", () => new NovelsemperorParser());

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

async getChapterUrls(dom, chapterUrlsUI) {
return (await this.walkTocPages(dom,
NovelsemperorParser.chaptersFromDom,
NovelsemperorParser.nextTocPageUrl,
chapterUrlsUI
)).reverse();
}

static chaptersFromDom(dom) {
return [...dom.querySelectorAll("#chapters-list a")]
.map(NovelsemperorParser.hyperlinkToChapter);
}

static hyperlinkToChapter(link) {
return {
sourceUrl: link.href,
title: link.querySelector("span").innerText.trim(),
};
}

static nextTocPageUrl(dom) {
let pagination = dom.querySelector("ul.pagination");
return [...pagination.querySelectorAll("li.pagination-link")]?.pop()
?.getAttribute("onclick")
?.split("'")?.[1];
}

findContent(dom) {
return dom.querySelector("div.chap-content");
}

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

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

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

getInformationEpubItemChildNodes(dom) {
return [dom.querySelector("#description").parentElement];
}
}
1 change: 1 addition & 0 deletions plugin/popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,7 @@ <h3>Instructions</h3>
<script src="js/parsers/NovelOnlineFreeParser.js"></script>
<script src="js/parsers/NovelonomiconParser.js"></script>
<script src="js/parsers/NovelpassionParser.js"></script>
<script src="js/parsers/NovelsemperorParser.js"></script>
<script src="js/parsers/NovelsplParser.js"></script>
<script src="js/parsers/NovelSpreadParser.js"></script>
<script src="js/parsers/NovelsRockParser.js"></script>
Expand Down

0 comments on commit 2d69f7b

Please sign in to comment.