From 54f84251a6288332ed57802d53a50fa6d5967722 Mon Sep 17 00:00:00 2001 From: Elfing <106489440+elfing44@users.noreply.github.com> Date: Mon, 10 Jun 2024 16:45:02 +0200 Subject: [PATCH] Fix(plugin): novhell (#982) * Fix novhell * fix * fix unnecessary assignment --- plugins/french/novhell.ts | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/plugins/french/novhell.ts b/plugins/french/novhell.ts index f4ebedf..b15a0bf 100644 --- a/plugins/french/novhell.ts +++ b/plugins/french/novhell.ts @@ -10,7 +10,7 @@ class NovhellPlugin implements Plugin.PluginBase { name = 'Novhell'; icon = 'src/fr/novhell/icon.png'; site = 'https://novhell.org'; - version = '1.0.0'; + version = '1.0.1'; filters: Filters | undefined = undefined; async getCheerio(url: string): Promise { @@ -165,10 +165,20 @@ class NovhellPlugin implements Plugin.PluginBase { const sections = $('main article div div section'); if (sections) { const numberOfSection = sections.length; - const title = sections.eq(numberOfSection - 3); - const chapitre = sections.eq(numberOfSection - 2); - if (title && chapitre) { - return (title.html() || '') + (chapitre.html() || ''); + let title; + let positionChapter = 2; + + for (let i = 3; i <= 5; i++) { + title = sections.eq(numberOfSection - i); + if (title.find('h4').length !== 0) { + positionChapter = i - 1; + break; + } + } + const chapter = sections.eq(numberOfSection - positionChapter); + + if (title && chapter) { + return (title.html() || '') + (chapter.html() || ''); } } return '';