feat: Add AkuTranslations to Novel Updates (#1842)

* added AkuTranslations

* sort content into <p> elements

* remove a <br> element when joining

* fix line breaks

* revert test versions
This commit is contained in:
Batorian
2025-10-19 06:44:56 +02:00
committed by GitHub
parent ae405691cf
commit d3313a460e
+24 -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.9.3'; version = '0.9.4';
icon = 'src/en/novelupdates/icon.png'; icon = 'src/en/novelupdates/icon.png';
customCSS = 'src/en/novelupdates/customCSS.css'; customCSS = 'src/en/novelupdates/customCSS.css';
site = 'https://www.novelupdates.com/'; site = 'https://www.novelupdates.com/';
@@ -172,6 +172,29 @@ class NovelUpdates implements Plugin.PluginBase {
const targetDomain = domain.find(d => !unwanted.includes(d)); const targetDomain = domain.find(d => !unwanted.includes(d));
switch (targetDomain) { switch (targetDomain) {
// Last edited in 0.9.4 by Batorian - 15/10/2025
case 'akutranslations': {
try {
const apiUrl = chapterPath.replace('/novel', '/api/novel');
const response = await fetchApi(apiUrl);
const json = await response.json();
if (!json?.content) {
throw new Error('Invalid API response structure.');
}
chapterContent = json.content
.trim()
.split(/\n+/)
.map((p: string) => p.trim())
.filter((p: string) => p.length > 0)
.map((p: string) => `<p>${p}</p>`)
.join('\n');
break;
} catch (error) {
throw new Error(`Failed to parse AkuTranslations chapter: ${error}`);
}
}
// Last edited in 0.9.0 by Batorian - 19/03/2025 // Last edited in 0.9.0 by Batorian - 19/03/2025
case 'anotivereads': { case 'anotivereads': {
chapterTitle = loadedCheerio('#comic-nav-name').first().text(); chapterTitle = loadedCheerio('#comic-nav-name').first().text();
@@ -289,10 +312,6 @@ class NovelUpdates implements Plugin.PluginBase {
const url = `${parts[0]}//${parts[2]}/api/public/chapter-by-slug/${novelSlug}/${chapterSlug}`; const url = `${parts[0]}//${parts[2]}/api/public/chapter-by-slug/${novelSlug}/${chapterSlug}`;
const response = await fetchApi(url); const response = await fetchApi(url);
if (!response.ok) {
throw new Error(`Failed to fetch chapter: ${response.status}`);
}
const json = await response.json(); const json = await response.json();
if (!json?.data?.currentChapter) { if (!json?.data?.currentChapter) {
throw new Error('Invalid API response structure.'); throw new Error('Invalid API response structure.');