Skip to content
13 changes: 12 additions & 1 deletion plugins/english/dragonholic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Plugin } from '@/types/plugin';
import { fetchApi, FetchInit } from '@libs/fetch';
import { load as loadCheerio } from 'cheerio';
import { NovelStatus } from '@libs/novelStatus';
import { storage } from '@libs/storage';

type LuminaChapter = {
id?: string | number;
Expand Down Expand Up @@ -36,7 +37,15 @@ class Dragonholic implements Plugin.PluginBase {
name = 'Dragonholic';
icon = 'src/en/dragonholic/icon.png';
site = 'https://dragonholictranslations.com';
version = '3.0.1';
version = '3.1.0';

pluginSettings = {
hideLocked: {
value: false,
label: 'Hide locked chapters',
type: 'Switch',
},
};

private decodeEntities(text: string): string {
return text
Expand Down Expand Up @@ -198,8 +207,10 @@ class Dragonholic implements Plugin.PluginBase {
);
const data = (await chaptersRes.json()) as LuminaChaptersResponse;
const list = data?.data?.chapters || data?.chapters || [];
const hideLocked = storage.get('hideLocked');
list.forEach(item => {
if (!item.slug) return;
if (item.is_premium && hideLocked) return;
const order = Number(item.chapter_order);
const title = this.decodeEntities(
[item.heading || item.name, item.subtitle]
Expand Down
16 changes: 14 additions & 2 deletions plugins/english/indraTranslations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { fetchApi } from '@libs/fetch';
import { Filters, FilterTypes } from '@libs/filterInputs';
import { Plugin } from '@/types/plugin';
import { NovelStatus } from '@libs/novelStatus';
import { storage } from '@libs/storage';

type IndraChapter = {
num?: number | string;
Expand All @@ -16,9 +17,17 @@ class IndraTranslations implements Plugin.PluginBase {
id = 'indratranslations';
name = 'Indra Translations';
site = 'https://indratranslations.com';
version = '1.3.1';
version = '1.4.0';
icon = 'src/en/indratranslations/icon.png';

pluginSettings = {
hideLocked: {
value: false,
label: 'Hide locked chapters',
type: 'Switch',
},
};

// Browser-like headers (important for Cloudflare-y sites)
private headers = {
'User-Agent':
Expand Down Expand Up @@ -188,7 +197,10 @@ class IndraTranslations implements Plugin.PluginBase {
summary: summary || this.clean($('#story-synopsis').text()) || undefined,
genres: genres || undefined,
status,
chapters: this.parseChapterList($, html),
chapters: this.parseChapterList($, html).filter(
chapter =>
!(storage.get('hideLocked') && chapter.name.startsWith('🔒')),
),
};
}

Expand Down
50 changes: 33 additions & 17 deletions plugins/english/noveldex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Plugin } from '@/types/plugin';
import { Filters, FilterTypes } from '@libs/filterInputs';
import { load as loadCheerio } from 'cheerio';
import { NovelStatus } from '@libs/novelStatus';
import { storage } from '@libs/storage';

// NovelDex is a Next.js application using app router, rsc ( react server components ), and flight protocol

Expand Down Expand Up @@ -109,7 +110,16 @@ class Noveldex implements Plugin.PluginBase {
name = 'NovelDex';
icon = 'src/en/noveldex/icon.png';
site = 'https://noveldex.io';
version = '1.0.2';
version = '1.1.0';

pluginSettings = {
hideLocked: {
value: false,
label: 'Hide locked chapters',
type: 'Switch',
},
};

// Filter do take a lot of space
filters = {
sort: {
Expand Down Expand Up @@ -537,16 +547,19 @@ class Noveldex implements Plugin.PluginBase {
chapters: NoveldexChapter[],
base: string,
): Plugin.ChapterItem[] {
return chapters.map(chapter => {
const accessible = chapter.hasAccess !== false;
const title = chapter.title || 'Untitled';
return {
name: accessible ? title : `🔒 ${title}`,
path: `${base}/chapter/${chapter.number}`,
releaseTime: chapter.publishedAt,
chapterNumber: chapter.number,
};
});
const hideLocked = storage.get('hideLocked');
return chapters
.filter(chapter => !(hideLocked && chapter.hasAccess === false))
.map(chapter => {
const accessible = chapter.hasAccess !== false;
const title = chapter.title || 'Untitled';
return {
name: accessible ? title : `🔒 ${title}`,
path: `${base}/chapter/${chapter.number}`,
releaseTime: chapter.publishedAt,
chapterNumber: chapter.number,
};
});
}

// Convert NovelDex's raw status strings into the framework's NovelStatus enum.
Expand Down Expand Up @@ -691,13 +704,16 @@ class Noveldex implements Plugin.PluginBase {
});

const clrNovelPath = novelPath.split('?')[0];
const hideLocked = storage.get('hideLocked');

return chapters.map(chapter => ({
name: chapter.title || 'Untitled',
path: `${clrNovelPath}/chapter/${chapter.number}`,
releaseTime: chapter.publishedAt,
chapterNumber: chapter.number,
}));
return chapters
.filter(chapter => !(hideLocked && chapter.hasAccess === false))
.map(chapter => ({
name: chapter.title || 'Untitled',
path: `${clrNovelPath}/chapter/${chapter.number}`,
releaseTime: chapter.publishedAt,
chapterNumber: chapter.number,
}));
}

private async parseNovelFromHtml(
Expand Down
23 changes: 17 additions & 6 deletions plugins/english/wetriedtls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { Plugin } from '@/types/plugin';
import { NovelStatus } from '@libs/novelStatus';
import { Filters, FilterTypes } from '@libs/filterInputs';
import { storage } from '@libs/storage';

const API = 'https://api.wetriedtls.com';

Expand Down Expand Up @@ -205,10 +206,8 @@
* java<TAB>script:-style smuggling are all caught.
*/
function isScriptUrl(url: string): boolean {
const norm = decodeAttrEntities(url).replace(
/[\s\u0000-\u001f\u007f]+/g,
'',
);
// eslint-disable-next-line no-control-regex
const norm = decodeAttrEntities(url).replace(/[\s\u0000-\u001f\u007f]+/g, '');
return /^(javascript|vbscript):/i.test(norm);
}

Expand Down Expand Up @@ -530,7 +529,15 @@
name = 'We Tried TLS';
icon = 'src/en/wetriedtls/icon.png';
site = SITE;
version = '1.0.6';
version = '1.1.0';

pluginSettings = {
hideLocked: {
value: false,
label: 'Hide locked chapters',
type: 'Switch',
},
};

// Novel/chapter titles behind each chapter path, recorded by parseNovel.
// parseChapter passes them to parseChapterContent so the site's repeated
Expand Down Expand Up @@ -589,7 +596,9 @@
// lastPage to 1 and parseNovel would return an incomplete chapter
// list as though it were complete. Fail loudly instead.
if (!json || !json.trim())
throw new Error('Failed to load the chapter list (page ' + pageNo + ')');
throw new Error(
'Failed to load the chapter list (page ' + pageNo + ')',
);
const page = parseChapterList(json);
lastPage = page.lastPage;
for (const c of page.items) all.push(c);
Expand Down Expand Up @@ -623,9 +632,11 @@

const seen: Record<string, boolean> = {};
const chapters: Plugin.ChapterItem[] = [];
const hideLocked = storage.get('hideLocked');
all
.filter(c => {
if (!c.slug || seen[c.slug]) return false;
if (c.locked && hideLocked) return false;
seen[c.slug] = true;
return true;
})
Expand Down Expand Up @@ -704,7 +715,7 @@
}));
}

resolveUrl = (path: string, _isNovel?: boolean): string =>

Check warning on line 718 in plugins/english/wetriedtls.ts

View workflow job for this annotation

GitHub Actions / Lint Check

'_isNovel' is defined but never used
SITE + '/series/' + path;
}

Expand Down
Loading