From 3e42af895393d36da2da3124f10d89d638c6402d Mon Sep 17 00:00:00 2001
From: Lukas Richter <53831711+Batorian@users.noreply.github.com>
Date: Wed, 29 May 2024 15:48:42 +0200
Subject: [PATCH] Enhancement(plugin): NU Site Fix and Captcha Checking (#932)
* refactored and updated Novel Updates' parseChapter()
* added `ippotranslations` and `shanghaifantasy` to Novel Updates
* small changes
* removed switch cases and reverted back to `let` and `if`/`else if` structure
* added lots of translation group support
* added more site support and tried cleaning chapter content where possible
* quick fix
* quick fix
* logic overhaul; implementation of switch cases (again)
* small changes to `bloatClasses` and `chapterContent`
* added Anomalously Creative (`anotivereads`) to outliers and added new `bloatClasses` to Wuxia World (`wuxiaworld`)
* edited ElloTL (`ellotl.ts`) to match Novel Updates chapter content and slightly reduced title size in Novel Updates (`novelupdates.ts`) chapters; also added Novel Plex (`novelplex`) as supported site for Novel Updates
* ElloTL fix
* all in all just lots of small changes and fixes
* fix
* reformat chapter names
* fix
* update
* `stabbingwithasyringe` remove advertisements
* update NU `searchNovels`
* added: skydemonorder
* removed log
* update: skydemonorder
* added: skydemonorder
* update: throw captcha error
* fix: skydemonorder
* fix: error message
* fix: chapterContent
* fix: chapterContent
* Enhancement: chapterContent
* Enhancement: potentially missing chapterContent
* Fix: Novel Updates providing old Hel Scans chapter Urls
* Fix: correctly replace faulty chapter urls
* Enhancement: remove Genesis Translations watermark
* Enhancement: remove Genesis Translations footnote content in chapter text
* Fix: Novel World Translations chapterContent fix
* Enhancement: Novel World Translations cleaned chapterContent
* Fix: Novel World Translations cleaned chapterContent
* Enhancement: Novel World Translations cleaned chapterContent
* Enhancement: Novel World Translations cleaned chapterContent
* Enhancement: Novel World Translations cleaned chapterContent
* Fix: remove not needed bloat
---
plugins/english/novelupdates.ts | 91 +++++++++++++++++++++++++++++++--
1 file changed, 86 insertions(+), 5 deletions(-)
diff --git a/plugins/english/novelupdates.ts b/plugins/english/novelupdates.ts
index ce2025e..9270b8a 100644
--- a/plugins/english/novelupdates.ts
+++ b/plugins/english/novelupdates.ts
@@ -6,7 +6,7 @@ import { Plugin } from '@typings/plugin';
class NovelUpdates implements Plugin.PluginBase {
id = 'novelupdates';
name = 'Novel Updates';
- version = '0.5.3';
+ version = '0.5.4';
icon = 'src/en/novelupdates/icon.png';
site = 'https://www.novelupdates.com/';
@@ -180,6 +180,7 @@ class NovelUpdates implements Plugin.PluginBase {
loadedCheerio: CheerioAPI,
domain: string[],
url: string,
+ result: Response,
) {
let bloatClasses = [];
let chapterTitle = '';
@@ -206,6 +207,25 @@ class NovelUpdates implements Plugin.PluginBase {
chapterText = `
${chapterTitle}
${chapterContent}`;
}
break;
+ case 'helscans':
+ chapterTitle = loadedCheerio('.entry-title-main').first().text()!;
+ const chapterStringHelScans =
+ 'Chapter ' + chapterTitle.split('Chapter')[1].trim();
+ loadedCheerio('#readerarea.rdminimal')
+ .children()
+ .each((idx, ele) => {
+ let elementText = loadedCheerio(ele).text();
+ if (elementText.includes(chapterStringHelScans)) {
+ chapterTitle = elementText;
+ loadedCheerio(ele).remove();
+ return false;
+ }
+ });
+ chapterContent = loadedCheerio('#readerarea.rdminimal').html()!;
+ if (chapterTitle && chapterContent) {
+ chapterText = `${chapterTitle}
${chapterContent}`;
+ }
+ break;
case 'hiraethtranslation':
chapterTitle = loadedCheerio('li.active').first().text()!;
chapterContent = loadedCheerio('.text-left').html()!;
@@ -263,10 +283,22 @@ class NovelUpdates implements Plugin.PluginBase {
}
break;
case 'novelworldtranslations':
- bloatClasses = ['.separator', 'p[dir="ltr"]'];
+ bloatClasses = ['.separator img'];
bloatClasses.map(tag => loadedCheerio(tag).remove());
+ loadedCheerio('.entry-content a')
+ .filter((_, el) => {
+ return (
+ loadedCheerio(el)
+ .attr('href')
+ ?.includes('https://novelworldtranslations.blogspot.com') ||
+ false
+ );
+ })
+ .each((_, el) => {
+ loadedCheerio(el).parent().remove();
+ });
chapterTitle = loadedCheerio('.entry-title').first().text()!;
- chapterContent = loadedCheerio('.entry-content p span span')
+ chapterContent = loadedCheerio('.entry-content')
.html()!
.replace(/ /g, '')
.replace(/\n/g, '
');
@@ -334,6 +366,25 @@ class NovelUpdates implements Plugin.PluginBase {
chapterText = `${chapterTitle}
${chapterContent}`;
}
break;
+ case 'skydemonorder':
+ /**
+ * Check for age verification
+ */
+ const ageVerification = loadedCheerio('main').text().toLowerCase()!;
+ if (ageVerification.includes('age verification required')) {
+ throw new Error('Age verification required, please open in webview.');
+ }
+ chapterTitle = `${loadedCheerio('.pl-4 h1').first().text()!} | ${loadedCheerio('.pl-4 div').first().text()!}`;
+ chapterContent = loadedCheerio('#startContainer + * > *')
+ .first()
+ .html()!;
+ if (!chapterContent) {
+ chapterContent = `${loadedCheerio('#chapter-body').html()!}
There could be missing content, please check in webview.`;
+ }
+ if (chapterTitle && chapterContent) {
+ chapterText = `${chapterTitle}
${chapterContent}`;
+ }
+ break;
case 'stabbingwithasyringe':
/**
* Get the chapter link from the main page
@@ -437,6 +488,28 @@ class NovelUpdates implements Plugin.PluginBase {
const loadedCheerio = parseHTML(body);
+ /**
+ * Check for Captcha
+ */
+ const title = loadedCheerio('title').text().toLowerCase().trim();
+ if (
+ title == 'bot verification' ||
+ title == 'just a moment...' ||
+ title == 'redirecting...' ||
+ title == 'un instant...' ||
+ title == 'you are being redirected...'
+ ) {
+ throw new Error('Captcha error, please open in webview.');
+ }
+ if (!result.ok) {
+ /**
+ * Check if the chapter url is wrong or the site is genuinely down
+ */
+ throw new Error(
+ `Could not reach site (${result.status}), try to open in webview.`,
+ );
+ }
+
/**
* Detect if the site is a Blogspot site
*/
@@ -477,6 +550,7 @@ class NovelUpdates implements Plugin.PluginBase {
const outliers = [
'anotivereads',
'asuratls',
+ 'helscans',
'mirilu',
'novelworldtranslations',
'sacredtexttranslations',
@@ -505,7 +579,7 @@ class NovelUpdates implements Plugin.PluginBase {
* - Gem Novels
* - Genesis Translations (Manually added)
* - Goblinslate
- * - Hel Scans
+ * - Hel Scans (Outlier)
* - ippotranslations
* - JATranslations
* - Light Novels Translations
@@ -521,7 +595,12 @@ class NovelUpdates implements Plugin.PluginBase {
* - Zetro Translation (Outlier)
*/
if (!isWordPress && !isBlogspot) {
- chapterText = await this.getChapterBody(loadedCheerio, domain, url);
+ chapterText = await this.getChapterBody(
+ loadedCheerio,
+ domain,
+ url,
+ result,
+ );
} else if (isBlogspot) {
bloatClasses = ['.button-container', '.separator'];
bloatClasses.map(tag => loadedCheerio(tag).remove());
@@ -541,7 +620,9 @@ class NovelUpdates implements Plugin.PluginBase {
'.chapter-warning',
'.entry-meta',
'.ezoic-ad',
+ '.genesistls-watermark',
'.mb-center',
+ '.modern-footnotes-footnote__note',
'.patreon-widget',
'.post-cats',
'.pre-bar',