Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
See: #1440
Also, consolidated Noblemtl and Pandamtl parsers
  • Loading branch information
dteviot committed Aug 26, 2024
1 parent 40d89ff commit ad3be3f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 30 deletions.
3 changes: 1 addition & 2 deletions plugin/js/Util.js
Original file line number Diff line number Diff line change
Expand Up @@ -421,8 +421,7 @@ var util = (function () {
}

var getFirstImgSrc = function(dom, selector) {
let img = dom.querySelector(selector + " img");
return (img === null) ? img : img.src;
return dom.querySelector(selector)?.querySelector("img")?.src ?? null;
}

var extractHashFromUri = function(uri) {
Expand Down
56 changes: 28 additions & 28 deletions plugin/js/parsers/NoblemtlParser.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use strict";

parserFactory.register("arcanetranslations.com", () => new PandamtlParser());
parserFactory.register("arcanetranslations.com", () => new NoblemtlParser());
//dead url
parserFactory.register("bookalb.com", () => new NoblemtlParser());
parserFactory.register("ckandawrites.online", () => new KnoxtspaceParser());
Expand All @@ -11,24 +11,25 @@ parserFactory.register("faloomtl.com", () => new NoblemtlParser());
//dead url
parserFactory.register("genesistls.com", () => new NoblemtlParser());
parserFactory.register("hoxionia.com", () => new NoblemtlParser());
parserFactory.register("jobnib.com", () => new PandamtlParser());
parserFactory.register("moonlightnovel.com", () => new PandamtlParser());
parserFactory.register("jobnib.com", () => new NoblemtlParser());
parserFactory.register("moonlightnovel.com", () => new NoblemtlParser());
parserFactory.register("noblemtl.com", () => new NoblemtlParser());
parserFactory.register("novelcranel.org", () => new NoblemtlParser());
//dead url
parserFactory.register("novelsparadise.net", () => new PandamtlParser());
parserFactory.register("novelsparadise.net", () => new NoblemtlParser());
//dead url
parserFactory.register("readfreebooksonline.org", () => new NoblemtlParser());
//dead url
parserFactory.register("tamagotl.com", () => new NoblemtlParser());
parserFactory.register("taonovel.com", () => new NoblemtlParser());
parserFactory.register("knoxt.space", () => new KnoxtspaceParser());
parserFactory.register("lazygirltranslations.com", () => new LazygirltranslationsParser());
//dead url
parserFactory.register("novelsknight.com", () => new NoblemtlParser());
//dead url
parserFactory.register("cyborg-tl.com", () => new NoblemtlParser());

parserFactory.register("pandamtl.com", () => new PandamtlParser());
parserFactory.register("pandamtl.com", () => new NoblemtlParser());
parserFactory.register("universalnovel.com", () => new NoblemtlParser());
parserFactory.register("whitemoonlightnovels.com", () => new WhitemoonlightnovelsParser());

Expand All @@ -49,7 +50,7 @@ class NoblemtlParser extends Parser{

static isNoblemtlTheme(dom) {
return (dom.querySelector("div.eplister a") != null) &&
(dom.querySelector(".thumbook") != null)
(dom.querySelector(".thumbook, .sertothumb") != null);
}

async getChapterUrls(dom) {
Expand Down Expand Up @@ -117,34 +118,18 @@ class NoblemtlParser extends Parser{
}

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

preprocessRawDom(webPageDom) {
util.removeChildElementsMatchingCss(webPageDom, "div.saboxplugin-wrap, div.code-block");
}

getInformationEpubItemChildNodes(dom) {
return [...dom.querySelectorAll("div.synp .entry-content")];
}
}

class PandamtlParser extends NoblemtlParser{
constructor() {
super();
}

static isPandamtlTheme(dom) {
return (dom.querySelector("div.eplister a") != null) &&
(dom.querySelector(".sertothumb") != null)
}

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

getInformationEpubItemChildNodes(dom) {
return [...dom.querySelectorAll("div.sersys.entry-content")];
let info = dom.querySelector("div.synp .entry-content, div.sersys.entry-content");
return info == null
? []
: [info];
}
}

Expand All @@ -158,7 +143,7 @@ class KnoxtspaceParser extends NoblemtlParser{
}
}

class WhitemoonlightnovelsParser extends PandamtlParser{
class WhitemoonlightnovelsParser extends NoblemtlParser{
constructor() {
super();
}
Expand All @@ -176,3 +161,18 @@ class WhitemoonlightnovelsParser extends PandamtlParser{
util.removeChildElementsMatchingCss(node, ".code-block");
}
}

class LazygirltranslationsParser extends KnoxtspaceParser{
constructor() {
super();
}

async getChapterUrls(dom) {
if (dom.querySelector("div.eplister a"))
{
return super.getChapterUrls(dom);
}
let menu = dom.querySelector(".page");
return util.hyperlinksToChapterList(menu);
}
}

0 comments on commit ad3be3f

Please sign in to comment.