fix: linter issues

This commit is contained in:
K1ngfish3r
2026-04-23 01:04:42 +05:00
parent 5e195b7f53
commit 2396df38bb
111 changed files with 2738 additions and 2160 deletions
+11 -11
View File
@@ -17,17 +17,17 @@ const parseUrl = (url?: string): URL | undefined => {
const getStandardNovelPath = (url?: string): string | undefined => {
const parsedUrl = parseUrl(url);
if (!parsedUrl) return undefined;
const match = parsedUrl.pathname.match(/^(\/amp)?(\/n\/[^\/]+\/)/);
const match = parsedUrl.pathname.match(/^(\/amp)?(\/n\/[^/]+\/)/);
return match?.[2]?.replace(/^\//, '');
};
const getChapterFileName = (url?: string): string | undefined => {
const parsedUrl = parseUrl(url);
if (!parsedUrl) return undefined;
const fileName = parsedUrl.pathname.split('/').pop();
if (fileName && /^\d+\.html$/.test(fileName)) return fileName;
return undefined;
};
// const getChapterFileName = (url?: string): string | undefined => {
// const parsedUrl = parseUrl(url);
// if (!parsedUrl) return undefined;
// const fileName = parsedUrl.pathname.split('/').pop();
// if (fileName && /^\d+\.html$/.test(fileName)) return fileName;
// return undefined;
// };
const makeAbsolute = (
relativeUrl?: string,
@@ -47,7 +47,7 @@ class QuanbenPlugin implements Plugin.PluginBase {
id = 'quanben';
name = 'Quanben';
site = 'https://www.quanben.io/';
version = '1.1.0';
version = '1.1.1';
icon = 'src/cn/quanben/icon.png';
defaultCover = defaultCover;
@@ -192,7 +192,7 @@ class QuanbenPlugin implements Plugin.PluginBase {
async parseChapterList(novelPath: string): Promise<Plugin.ChapterItem[]> {
if (!novelPath.startsWith('n/') || !novelPath.endsWith('/')) return [];
const novelSlug = novelPath.match(/^n\/([^\/]+)\//)?.[1];
const novelSlug = novelPath.match(/^n\/([^/]+)\//)?.[1];
if (!novelSlug) return [];
const mirrorUrl = `https://quanben5.com/n/${novelSlug}/xiaoshuo.html`;
@@ -230,7 +230,7 @@ class QuanbenPlugin implements Plugin.PluginBase {
// Helper function to extract and clean chapter content from HTML body
private extractChapterContent(body: string): string {
const $ = parseHTML(body);
let $content = $('#contentbody, #content, .content').first();
const $content = $('#contentbody, #content, .content').first();
if (!$content.length) return 'Error: Chapter content not found.';
$content
+23 -10
View File
@@ -29,7 +29,7 @@ class ixdzs8Plugin implements Plugin.PluginBase {
id = 'ixdzs8';
name = '爱下电子书';
site = 'https://ixdzs8.com/';
version = '2.2.8';
version = '2.2.9';
icon = 'src/cn/ixdzs8/favicon.png';
imageRequestInit = {
@@ -49,14 +49,18 @@ class ixdzs8Plugin implements Plugin.PluginBase {
$('ul.u-list > li.burl').each((_i, el) => {
const $el = $(el);
let novelPath: string | undefined;
let novelName: string | undefined;
let novelCover: string | undefined;
const $link = $el.find('.l-info h3 a');
novelPath = $link.attr('href')?.trim();
novelName = ($link.attr('title') || $link.text() || '').trim();
novelCover = $el.find('.l-img img').attr('src')?.trim();
const novelPath: string | undefined = $link.attr('href')?.trim();
const novelName: string | undefined = (
$link.attr('title') ||
$link.text() ||
''
).trim();
const novelCover: string | undefined = $el
.find('.l-img img')
.attr('src')
?.trim();
if (novelPath && novelName) {
novels.push({
@@ -159,14 +163,14 @@ class ixdzs8Plugin implements Plugin.PluginBase {
throw new Error(`Failed to fetch chapters for bid=${bookId}`);
}
const json = await res.json();
const json: ChapterJSON = await res.json();
if (json.rs !== 200 || !Array.isArray(json.data)) {
throw new Error('Invalid response format from chapter list');
}
// Build chapters array
const chapters: Plugin.ChapterItem[] = json.data.map((ch: any) => {
const chapters: Plugin.ChapterItem[] = json.data.map(ch => {
return {
name: ch.title,
path: ch.ctype === '0' ? `read/${bookId}/p${ch.ordernum}.html` : '', // only normal chapters get link
@@ -254,7 +258,7 @@ class ixdzs8Plugin implements Plugin.PluginBase {
async searchNovels(
searchTerm: string,
pageNo: number,
// pageNo: number,
): Promise<Plugin.NovelItem[]> {
const searchUrl = `${this.site}bsearch?q=${encodeURIComponent(searchTerm)}`;
let body = '';
@@ -298,3 +302,12 @@ class ixdzs8Plugin implements Plugin.PluginBase {
}
export default new ixdzs8Plugin();
type ChapterJSON = {
rs: number;
data?: {
ctype: string;
ordernum: string;
title: string;
}[];
};
+8 -9
View File
@@ -9,7 +9,7 @@ class LinovelPlugin implements Plugin.PluginBase {
name = 'linovel';
icon = 'src/cn/linovel/icon.png';
site = 'https://www.linovel.net';
version = '1.0.0';
version = '1.0.1';
filters: Filters | undefined = undefined;
imageRequestInit?: Plugin.ImageRequestInit | undefined = undefined;
@@ -27,13 +27,12 @@ class LinovelPlugin implements Plugin.PluginBase {
return parseHTML(body);
}
async popularNovels(
pageNo: number,
{
showLatestNovels,
filters,
}: Plugin.PopularNovelsOptions<typeof this.filters>,
): Promise<Plugin.NovelItem[]> {
async popularNovels() // pageNo: number,
// {
// showLatestNovels,
// filters,
// }: Plugin.PopularNovelsOptions<typeof this.filters>,
: Promise<Plugin.NovelItem[]> {
const novels: Plugin.NovelItem[] = [];
const loadedCheerio = await this.fetchHTML(this.site);
@@ -139,7 +138,7 @@ class LinovelPlugin implements Plugin.PluginBase {
}
async searchNovels(
searchTerm: string,
pageNo: number,
// pageNo: number,
): Promise<Plugin.NovelItem[]> {
const loadedCheerio = await this.fetchHTML(
this.site + '/search/?kw=' + searchTerm,
+6 -5
View File
@@ -9,7 +9,7 @@ class Linovelib implements Plugin.PluginBase {
name = 'Linovelib';
icon = 'src/cn/linovelib/icon.png';
site = 'https://www.bilinovel.com';
version = '1.2.0';
version = '1.2.1';
imageRequestInit?: Plugin.ImageRequestInit | undefined = {
method: 'GET',
headers: {
@@ -29,7 +29,7 @@ class Linovelib implements Plugin.PluginBase {
type: 'Text',
},
};
serverUrl = storage.get('host') || 'http://localhost:5301';
serverUrl: string = storage.get('host') || 'http://localhost:5301';
async popularNovels(
pageNo: number,
@@ -82,7 +82,7 @@ class Linovelib implements Plugin.PluginBase {
async parseChapter(chapterPath: string): Promise<string> {
// move major logic to LDS
const lastFetchChapterTime =
storage.get('lastFetchChapterTime_' + chapterPath) || 0;
Number(storage.get('lastFetchChapterTime_' + chapterPath)) || 0;
if (Date.now() - lastFetchChapterTime < 10000) {
return storage.get('chapterContent_' + chapterPath) || '';
}
@@ -97,10 +97,11 @@ class Linovelib implements Plugin.PluginBase {
async searchNovels(
searchTerm: string,
pageNo: number,
// pageNo: number,
): Promise<Plugin.NovelItem[]> {
// move major logic to LDS
const lastSearchTime = storage.get('lastSearchTime_' + this.id) || 0;
const lastSearchTime =
Number(storage.get('lastSearchTime_' + this.id)) || 0;
if (Date.now() - lastSearchTime < 5000) {
return [];
}
+3 -3
View File
@@ -9,7 +9,7 @@ class Linovelib_tw implements Plugin.PluginBase {
name = 'Linovelib(繁體)';
icon = 'src/cn/linovelib/icon.png';
site = 'https://tw.linovelib.com/';
version = '1.0.0';
version = '1.0.1';
async popularNovels(
pageNo: number,
@@ -368,7 +368,7 @@ class Linovelib_tw implements Plugin.PluginBase {
pageCheerio('div.cgo, center').remove();
// Load lazyloaded images
pageCheerio('#acontentl img.imagecontent').each((i, el) => {
pageCheerio('[id*=acontent] img.imagecontent').each((i, el) => {
// Sometimes images are either in data-src or src
const imgSrc =
pageCheerio(el).attr('data-src') || pageCheerio(el).attr('src');
@@ -382,7 +382,7 @@ class Linovelib_tw implements Plugin.PluginBase {
});
// Recover the original character
pageText = pageCheerio('#acontentl').html() || '';
pageText = pageCheerio('[id*=acontent]').html() || '';
pageText = pageText.replace(/./g, char => skillgg[char] || char);
return Promise.resolve();