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", "id": "kolnovel",
"sourceSite": "https://kolnovel.club/", "sourceSite": "https://kolnovel.club/",
"sourceName": "ملوك الروايات", "sourceName": "Kol Novel",
"options": { "options": {
"lang": "Arabic", "lang": "Arabic",
"reverseChapters": true, "reverseChapters": true,
@@ -57,7 +57,7 @@
{ {
"id": "novelsparadise", "id": "novelsparadise",
"sourceSite": "https://novelsparadise.site/", "sourceSite": "https://novelsparadise.site/",
"sourceName": "جنة الروايات", "sourceName": "Novels Paradise",
"options": { "options": {
"lang": "Arabic", "lang": "Arabic",
"reverseChapters": true "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.icon = `multisrc/lightnovelwp/${metadata.id.toLowerCase()}/icon.png`;
this.site = metadata.sourceSite; this.site = metadata.sourceSite;
const versionIncrements = metadata.options?.versionIncrements || 0; const versionIncrements = metadata.options?.versionIncrements || 0;
this.version = `1.1.${versionIncrements}`; this.version = `1.1.${1 + versionIncrements}`;
this.options = metadata.options ?? ({} as LightNovelWPOptions); this.options = metadata.options ?? ({} as LightNovelWPOptions);
this.filters = metadata.filters satisfies Filters; this.filters = metadata.filters satisfies Filters;
} }
@@ -380,21 +380,23 @@ class LightNovelWPPlugin implements Plugin.PluginBase {
} }
async parseChapter(chapterPath: string): Promise<string> { async parseChapter(chapterPath: string): Promise<string> {
const data = await this.safeFecth(this.site + chapterPath, false); let data = await this.safeFecth(this.site + chapterPath, false);
const chapterText = data.match(
/<div.*class="epcontent ([\s\S]*?)<div.*class="bottomnav"/g,
)?.[0];
if (this.options?.customJs) { if (this.options?.customJs) {
try { try {
const $ = load(chapterText || data); const $ = load(data);
// CustomJS HERE // CustomJS HERE
return $.html(); data = $.html();
} catch (error) { } catch (error) {
console.error('Error executing customJs:', error); console.error('Error executing customJs:', error);
throw 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( async searchNovels(