Fix (template): lighnovelwp customjs (#971)

- customJs fix
 - sources names in latin
This commit is contained in:
Justin COLLON
2024-06-06 04:14:16 +02:00
committed by GitHub
parent c7f6a9b5ee
commit b112e44998
2 changed files with 12 additions and 10 deletions
+2 -2
View File
@@ -11,7 +11,7 @@
{
"id": "kolnovel",
"sourceSite": "https://kolnovel.club/",
"sourceName": "ملوك الروايات",
"sourceName": "Kol Novel",
"options": {
"lang": "Arabic",
"reverseChapters": true,
@@ -57,7 +57,7 @@
{
"id": "novelsparadise",
"sourceSite": "https://novelsparadise.site/",
"sourceName": "جنة الروايات",
"sourceName": "Novels Paradise",
"options": {
"lang": "Arabic",
"reverseChapters": true
+10 -8
View File
@@ -37,7 +37,7 @@ class LightNovelWPPlugin implements Plugin.PluginBase {
this.icon = `multisrc/lightnovelwp/${metadata.id.toLowerCase()}/icon.png`;
this.site = metadata.sourceSite;
const versionIncrements = metadata.options?.versionIncrements || 0;
this.version = `1.1.${versionIncrements}`;
this.version = `1.1.${1 + versionIncrements}`;
this.options = metadata.options ?? ({} as LightNovelWPOptions);
this.filters = metadata.filters satisfies Filters;
}
@@ -380,21 +380,23 @@ class LightNovelWPPlugin implements Plugin.PluginBase {
}
async parseChapter(chapterPath: string): Promise<string> {
const data = await this.safeFecth(this.site + chapterPath, false);
const chapterText = data.match(
/<div.*class="epcontent ([\s\S]*?)<div.*class="bottomnav"/g,
)?.[0];
let data = await this.safeFecth(this.site + chapterPath, false);
if (this.options?.customJs) {
try {
const $ = load(chapterText || data);
const $ = load(data);
// CustomJS HERE
return $.html();
data = $.html();
} catch (error) {
console.error('Error executing customJs:', error);
throw error;
}
}
return chapterText || '';
return (
data
.match(/<div.*class="epcontent ([\s\S]*?)<div.*class="bottomnav"/g)?.[0]
.match(/<p.*>([\s\S]*?)<\/p>/g)
?.join('\n') || ''
);
}
async searchNovels(