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
This commit is contained in:
Lukas Richter
2024-05-29 15:48:42 +02:00
committed by GitHub
parent 13620a1908
commit 3e42af8953
+86 -5
View File
@@ -6,7 +6,7 @@ import { Plugin } from '@typings/plugin';
class NovelUpdates implements Plugin.PluginBase { class NovelUpdates implements Plugin.PluginBase {
id = 'novelupdates'; id = 'novelupdates';
name = 'Novel Updates'; name = 'Novel Updates';
version = '0.5.3'; version = '0.5.4';
icon = 'src/en/novelupdates/icon.png'; icon = 'src/en/novelupdates/icon.png';
site = 'https://www.novelupdates.com/'; site = 'https://www.novelupdates.com/';
@@ -180,6 +180,7 @@ class NovelUpdates implements Plugin.PluginBase {
loadedCheerio: CheerioAPI, loadedCheerio: CheerioAPI,
domain: string[], domain: string[],
url: string, url: string,
result: Response,
) { ) {
let bloatClasses = []; let bloatClasses = [];
let chapterTitle = ''; let chapterTitle = '';
@@ -206,6 +207,25 @@ class NovelUpdates implements Plugin.PluginBase {
chapterText = `<h2>${chapterTitle}</h2><hr><br>${chapterContent}`; chapterText = `<h2>${chapterTitle}</h2><hr><br>${chapterContent}`;
} }
break; 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 = `<h2>${chapterTitle}</h2><hr><br>${chapterContent}`;
}
break;
case 'hiraethtranslation': case 'hiraethtranslation':
chapterTitle = loadedCheerio('li.active').first().text()!; chapterTitle = loadedCheerio('li.active').first().text()!;
chapterContent = loadedCheerio('.text-left').html()!; chapterContent = loadedCheerio('.text-left').html()!;
@@ -263,10 +283,22 @@ class NovelUpdates implements Plugin.PluginBase {
} }
break; break;
case 'novelworldtranslations': case 'novelworldtranslations':
bloatClasses = ['.separator', 'p[dir="ltr"]']; bloatClasses = ['.separator img'];
bloatClasses.map(tag => loadedCheerio(tag).remove()); 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()!; chapterTitle = loadedCheerio('.entry-title').first().text()!;
chapterContent = loadedCheerio('.entry-content p span span') chapterContent = loadedCheerio('.entry-content')
.html()! .html()!
.replace(/&nbsp;/g, '') .replace(/&nbsp;/g, '')
.replace(/\n/g, '<br>'); .replace(/\n/g, '<br>');
@@ -334,6 +366,25 @@ class NovelUpdates implements Plugin.PluginBase {
chapterText = `<h2>${chapterTitle}</h2><hr><br>${chapterContent}`; chapterText = `<h2>${chapterTitle}</h2><hr><br>${chapterContent}`;
} }
break; 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()!}<hr><br>There could be missing content, please check in webview.`;
}
if (chapterTitle && chapterContent) {
chapterText = `<h2>${chapterTitle}</h2><hr><br>${chapterContent}`;
}
break;
case 'stabbingwithasyringe': case 'stabbingwithasyringe':
/** /**
* Get the chapter link from the main page * Get the chapter link from the main page
@@ -437,6 +488,28 @@ class NovelUpdates implements Plugin.PluginBase {
const loadedCheerio = parseHTML(body); 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 * Detect if the site is a Blogspot site
*/ */
@@ -477,6 +550,7 @@ class NovelUpdates implements Plugin.PluginBase {
const outliers = [ const outliers = [
'anotivereads', 'anotivereads',
'asuratls', 'asuratls',
'helscans',
'mirilu', 'mirilu',
'novelworldtranslations', 'novelworldtranslations',
'sacredtexttranslations', 'sacredtexttranslations',
@@ -505,7 +579,7 @@ class NovelUpdates implements Plugin.PluginBase {
* - Gem Novels * - Gem Novels
* - Genesis Translations (Manually added) * - Genesis Translations (Manually added)
* - Goblinslate * - Goblinslate
* - Hel Scans * - Hel Scans (Outlier)
* - ippotranslations * - ippotranslations
* - JATranslations * - JATranslations
* - Light Novels Translations * - Light Novels Translations
@@ -521,7 +595,12 @@ class NovelUpdates implements Plugin.PluginBase {
* - Zetro Translation (Outlier) * - Zetro Translation (Outlier)
*/ */
if (!isWordPress && !isBlogspot) { if (!isWordPress && !isBlogspot) {
chapterText = await this.getChapterBody(loadedCheerio, domain, url); chapterText = await this.getChapterBody(
loadedCheerio,
domain,
url,
result,
);
} else if (isBlogspot) { } else if (isBlogspot) {
bloatClasses = ['.button-container', '.separator']; bloatClasses = ['.button-container', '.separator'];
bloatClasses.map(tag => loadedCheerio(tag).remove()); bloatClasses.map(tag => loadedCheerio(tag).remove());
@@ -541,7 +620,9 @@ class NovelUpdates implements Plugin.PluginBase {
'.chapter-warning', '.chapter-warning',
'.entry-meta', '.entry-meta',
'.ezoic-ad', '.ezoic-ad',
'.genesistls-watermark',
'.mb-center', '.mb-center',
'.modern-footnotes-footnote__note',
'.patreon-widget', '.patreon-widget',
'.post-cats', '.post-cats',
'.pre-bar', '.pre-bar',