Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
See: #704
Code provided by nandakishore2009
  • Loading branch information
dteviot committed Mar 12, 2022
1 parent c9bd9d0 commit 373bfc5
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
{ "name": "Miracutor"},
{ "name": "Synteresis"},
{ "name": "Lej77"},
{ "name": "nandakishore2009"},
{ "name": "Dimava"}
],
"license": "GPL-3.0-only",
Expand Down
50 changes: 50 additions & 0 deletions plugin/js/parsers/MadnovelParser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
"use strict";

parserFactory.register("madnovel.com", () => new MadnovelParser());


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

async getChapterUrls(dom) {
let menu = dom.querySelector(".chapter-list");
util.hyperLinkToChapter = function (link, newArc) {
return {
sourceUrl: link.href,
title: link.querySelector("strong").innerText,
newArc: (newArc === undefined) ? null : newArc
};
}
return util.hyperlinksToChapterList(menu).reverse();
}

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

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

extractAuthor(dom) {
let authorLabel = [...dom.querySelectorAll("a[href*='authors'] span")].map(x => x.textContent.trim())
return (authorLabel.length === 0) ? super.extractAuthor(dom) : authorLabel.join(", ");
}

extractSubject(dom) {
let tags = [...dom.querySelectorAll("a[href*='genres'] span")]
return tags.map(e => e.textContent.trim()).join(", ");
}

removeUnwantedElementsFromContentElement(element) {
util.removeChildElementsMatchingCss(element, ".ads-banner, .content-inner > br");
super.removeUnwantedElementsFromContentElement(element);
}

findCoverImageUrl(dom) {
return util.getFirstImgSrc(dom, ".img-cover");
}

}
1 change: 1 addition & 0 deletions plugin/popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,7 @@ <h3>Instructions</h3>
<script src="js/parsers/LiteroticaParser.js"></script>
<script src="js/parsers/LnmtlParser.js"></script>
<script src="js/parsers/MachineTranslationParser.js"></script>
<script src="js/parsers/MadnovelParser.js"></script>
<script src="js/parsers/MangadexParser.js"></script>
<script src="js/parsers/MangakakalotParser.js"></script>
<script src="js/parsers/MangallamaParser.js"></script>
Expand Down
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Credits
* Kiradien
* Synteresis
* Lej77
* nandakishore2009 (Parser for madnovel.com)
* Dimava

## How to use with Baka-Tsuki:
Expand Down

0 comments on commit 373bfc5

Please sign in to comment.