Skip to content

Commit

Permalink
Merge pull request #1558 from maforn/fix-mtlnovels
Browse files Browse the repository at this point in the history
Added MTLNovels support
  • Loading branch information
dteviot authored Oct 27, 2024
2 parents 4dd7a5e + 37f083d commit b6c82f7
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 25 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@
{ "name": "nozwock"},
{ "name": "Darthagnon"},
{ "name": "LucasFreitaslpf1"},
{ "name": "Jemeni11"}
{ "name": "Jemeni11"},
{ "name": "maforn"}
],
"license": "GPL-3.0-only",
"bugs": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
"use strict";
parserFactory.register("mtlnovel.com", () => new MtlnovelParser());
parserFactory.register("mtlnovels.com", () => new MtlnovelsParser());
parserFactory.register("mtlnovel.com", () => new MtlnovelsParser());
parserFactory.registerUrlRule(
url => (util.extractHostName(url).endsWith(".mtlnovels.com")),
() => new MtlnovelsParser()
);
parserFactory.registerUrlRule(
url => (util.extractHostName(url).endsWith(".mtlnovel.com")),
() => new MtlnovelParser()
() => new MtlnovelsParser()
);

class MtlnovelParser extends Parser{
class MtlnovelsParser extends Parser{
constructor() {
super();
}
Expand All @@ -15,27 +20,18 @@ class MtlnovelParser extends Parser{
document.getElementById("removeOriginalRow").hidden = false;
}

async getChapterUrls(dom, chapterUrlsUI) {
let tocUrls = [...dom.querySelectorAll("#panelchapterlist amp-list")]
.map(e => e.getAttribute("src"));
let chapters = [];
for (let tocUrl of tocUrls) {
let json = (await HttpClient.fetchJson(tocUrl)).json;
let partialList = this.chaptersFromJson(json);
chapterUrlsUI.showTocProgress(partialList);
chapters = chapters.concat(partialList);
}
return chapters;
};
async getChapterUrls(dom) {
const tocUrl = dom.querySelector("#panelchapterlist > a").href

chaptersFromJson(json) {
return json.items.map(
i => ({
title: i.no + " " + i.title,
sourceUrl: i.permalink
})
)
}
const chapterDom = (await HttpClient.fetchHtml(tocUrl)).responseXML;

return [...chapterDom.querySelectorAll(".ch-list > p > a")]
.map(a => ({
title: a.textContent.trim(),
sourceUrl: a.href
}))
.reverse();
};

findContent(dom) {
return dom.querySelector("div.single-page");
Expand Down
2 changes: 1 addition & 1 deletion plugin/popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ <h3>Instructions</h3>
<script src="js/parsers/MtlarchiveParser.js"></script>
<script src="js/parsers/MtledNovelsParser.js"></script>
<script src="js/parsers/MtlnationParser.js"></script>
<script src="js/parsers/MtlnovelParser.js"></script>
<script src="js/parsers/MtlnovelsParser.js"></script>
<script src="js/parsers/MtlreaderParser.js"></script>
<script src="js/parsers/MtnovelParser.js"></script>
<script src="js/parsers/MoonQuillParser.js"></script>
Expand Down
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,7 @@ Don't forget to give the project a star! Thanks again!
<li>Darthagnon</li>
<li>LucasFreitaslpf1</li>
<li>Jemeni11</li>
<li>maforn</li>
</ul>
</details>

Expand Down

0 comments on commit b6c82f7

Please sign in to comment.