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
+18 -14
View File
@@ -3,9 +3,9 @@ import { FilterTypes, Filters } from '@libs/filterInputs';
import { defaultCover } from '@libs/defaultCover';
import { fetchApi } from '@libs/fetch';
const headers: any = {
const headers: Record<string, string> = {
'Content-Type': 'application/json',
'X-Inertia': true,
'X-Inertia': 'true',
'X-Inertia-Version': '6666cd76f96956469e7be39d750cc7d9',
};
@@ -30,10 +30,12 @@ class freedlit implements Plugin.PluginBase {
url += '&page=' + page;
const novels: Plugin.NovelItem[] = [];
const { books }: { books: Books } = await fetchApi(url).then(res => {
this.getToken(res.headers);
return res.json();
});
const { books }: { books: Books } = await fetchApi(url).then(
(res: Response) => {
this.getToken(res.headers);
return res.json();
},
);
books.data.forEach(novel =>
novels.push({
@@ -57,7 +59,7 @@ class freedlit implements Plugin.PluginBase {
headers,
Referer: this.resolveUrl(novelPath, true),
},
).then(res => {
).then((res: Response) => {
this.getToken(res.headers);
return res.json();
});
@@ -79,7 +81,7 @@ class freedlit implements Plugin.PluginBase {
Referer: this.resolveUrl(novelPath),
body: JSON.stringify({ book_id: novelPath }),
},
).then(res => {
).then((res: Response) => {
this.getToken(res.headers);
return res.json();
});
@@ -103,7 +105,9 @@ class freedlit implements Plugin.PluginBase {
async parseChapter(chapterPath: string): Promise<string> {
const [book_id, chapter_id] = chapterPath.split('/');
if (!headers['X-XSRF-TOKEN']) {
await fetchApi(this.site).then(res => this.getToken(res.headers));
await fetchApi(this.site).then((res: Response) =>
this.getToken(res.headers),
);
}
const { success }: { success: chapterContent } = await fetchApi(
@@ -114,7 +118,7 @@ class freedlit implements Plugin.PluginBase {
Referer: this.resolveUrl(chapterPath),
body: JSON.stringify({ book_id, chapter_id }),
},
).then(res => {
).then((res: Response) => {
this.getToken(res.headers);
return res.json();
});
@@ -126,7 +130,7 @@ class freedlit implements Plugin.PluginBase {
async searchNovels(searchTerm: string): Promise<Plugin.NovelItem[]> {
const { success }: { success: book[] } = await fetchApi(
this.site + '/api/search?query=' + searchTerm,
).then(res => {
).then((res: Response) => {
this.getToken(res.headers);
return res.json();
});
@@ -152,9 +156,9 @@ class freedlit implements Plugin.PluginBase {
resolveUrl = (path: string, isNovel?: boolean) =>
this.site + (isNovel ? '/book/' : '/reader/') + path;
getToken = (header: any) => {
const cookies = header.map['set-cookie'] || '';
for (const cookie of cookies.split('; ') as string[]) {
getToken = (header: Headers) => {
const cookies = header.get('set-cookie') || '';
for (const cookie of cookies.split('; ')) {
const [key, val] = cookie.split('=');
if (key === 'XSRF-TOKEN') {
headers['X-XSRF-TOKEN'] = decodeURIComponent(val);
+3 -2
View File
@@ -11,7 +11,7 @@ class AuthorToday implements Plugin.PluginBase {
name = 'Автор Тудей';
icon = 'src/ru/authortoday/icon.png';
site = 'https://author.today';
version = '1.2.1';
version = '1.2.2';
private userAgent =
'Mozilla/5.0 (Android 15; Mobile; rv:138.0) Gecko/138.0 Firefox/138.0';
@@ -236,7 +236,8 @@ class AuthorToday implements Plugin.PluginBase {
headers: { 'User-Agent': this.userAgent },
}).then(res => res.text());
let [workID, chapterID] = chapterPath.split('/');
const [workID, initialChapterID] = chapterPath.split('/');
let chapterID = initialChapterID;
const userRaw = html.match(/userId:(.*?),/)?.[1]?.trim();
const userId = userRaw === 'null' ? '' : userRaw;
+24 -25
View File
@@ -17,15 +17,13 @@ class Neobook implements Plugin.PluginBase {
name = 'Neobook';
site = 'https://neobook.org';
apiSite = 'https://api.neobook.org/';
version = '1.0.2';
version = '1.0.3';
icon = 'src/ru/neobook/icon.png';
async fetchNovels(
page: number,
{
filters,
showLatestNovels,
}: Plugin.PopularNovelsOptions<typeof this.filters>,
showLatestNovels?: boolean,
filters?: Plugin.PopularNovelsOptions<typeof this.filters>['filters'],
searchTerm?: string,
): Promise<Plugin.NovelItem[]> {
const formData = new FormData();
@@ -70,17 +68,18 @@ class Neobook implements Plugin.PluginBase {
return novels;
}
popularNovels = this.fetchNovels;
async searchNovels(
searchTerm: string,
async popularNovels(
page: number,
): Promise<Plugin.NovelItem[]> {
const defaultOptions: any = {
filters: undefined,
showLatestNovels: false,
};
return this.fetchNovels(page, defaultOptions, searchTerm);
{
showLatestNovels,
filters,
}: Plugin.PopularNovelsOptions<typeof this.filters>,
) {
return this.fetchNovels(page, showLatestNovels, filters);
}
async searchNovels(searchTerm: string, page: number) {
return this.fetchNovels(page, false, undefined, searchTerm);
}
async parseNovel(novelPath: string): Promise<Plugin.SourceNovel> {
@@ -215,8 +214,8 @@ class Neobook implements Plugin.PluginBase {
export default new Neobook();
type BundleBooks = {
categories: any[];
topSection: any[];
// categories: any[];
// topSection: any[];
feed: Novels[];
};
@@ -286,7 +285,7 @@ type Novels = {
readProgress?: ReadProgress;
tags?: string[];
chapters?: Chapter[];
lastComments?: any[];
// lastComments?: any[];
bottomSection?: BottomSection;
carouselItems?: Novels[];
book?: Novels;
@@ -339,7 +338,7 @@ type Data = {
dateEdit: string;
datePublish: string;
attachment: Attachment;
lastComments: any[];
// lastComments: any[];
};
type NovelsCounters = {
@@ -371,12 +370,12 @@ type Login = {
grm: string;
counters: LoginCounters;
user: LoginUser;
pro: any[];
earn: any[];
boost: any[];
deposit: any[];
affiliate: any[];
preferences: any[];
// pro: any[];
// earn: any[];
// boost: any[];
// deposit: any[];
// affiliate: any[];
// preferences: any[];
};
type LoginCounters = {
+8 -4
View File
@@ -24,7 +24,9 @@ class novelOvh implements Plugin.PluginBase {
: filters?.sort?.value || 'averageRating') +
',desc';
const books: BooksEntity[] = await fetchApi(url).then(res => res.json());
const books: BooksEntity[] = await fetchApi(url).then((res: Response) =>
res.json(),
);
const novels: Plugin.NovelItem[] = [];
books.forEach(novel =>
@@ -44,7 +46,7 @@ class novelOvh implements Plugin.PluginBase {
'/content/' +
novelPath +
'?_data=routes/reader/book/$slug/index',
).then(res => res.json());
).then((res: Response) => res.json());
const novel: Plugin.SourceNovel = {
path: novelPath,
@@ -99,7 +101,7 @@ class novelOvh implements Plugin.PluginBase {
async parseChapter(chapterPath: string): Promise<string> {
const book: responseChapter = await fetchApi(
this.apiSite + 'chapters/' + chapterPath.split('/')[1],
).then(res => res.json());
).then((res: Response) => res.json());
const image = Object.fromEntries(
book?.pages?.map(({ id, image }) => [id, image]) || [],
@@ -111,7 +113,9 @@ class novelOvh implements Plugin.PluginBase {
async searchNovels(searchTerm: string): Promise<Plugin.NovelItem[]> {
const url = this.apiSite + 'books?type=NOVEL&search=' + searchTerm;
const books: BooksEntity[] = await fetchApi(url).then(res => res.json());
const books: BooksEntity[] = await fetchApi(url).then((res: Response) =>
res.json(),
);
const novels: Plugin.NovelItem[] = [];
books.forEach(novel =>
+12 -13
View File
@@ -16,12 +16,12 @@ class TL implements Plugin.PluginBase {
id = 'TL';
name = 'NovelTL';
site = 'https://novel.tl';
version = '1.0.1';
version = '1.0.2';
icon = 'src/ru/noveltl/icon.png';
async fetchNovels(
page: number,
{ filters }: Plugin.PopularNovelsOptions<typeof this.filters>,
filters?: Plugin.PopularNovelsOptions<typeof this.filters>['filters'],
searchTerm?: string,
): Promise<Plugin.NovelItem[]> {
const { data }: response = await fetchApi(
@@ -40,10 +40,10 @@ class TL implements Plugin.PluginBase {
variables: {
filter: {
query: searchTerm || undefined,
tags: filters.tags?.value?.length
tags: filters?.tags?.value?.length
? filters.tags.value
: undefined,
genres: filters.genres?.value?.length
genres: filters?.genres?.value?.length
? filters.genres.value
: undefined,
},
@@ -69,16 +69,15 @@ class TL implements Plugin.PluginBase {
return novels;
}
popularNovels = this.fetchNovels;
async searchNovels(
searchTerm: string,
async popularNovels(
page: number,
): Promise<Plugin.NovelItem[]> {
const defaultOptions: any = {
filters: {},
};
return this.fetchNovels(page, defaultOptions, searchTerm);
{ filters }: Plugin.PopularNovelsOptions<typeof this.filters>,
) {
return this.fetchNovels(page, filters);
}
async searchNovels(searchTerm: string, page: number) {
return this.fetchNovels(page, undefined, searchTerm);
}
async parseNovel(novelPath: string): Promise<Plugin.SourceNovel> {
+9 -9
View File
@@ -29,7 +29,7 @@ class RLIB implements Plugin.PluginBase {
name = 'RanobeLib';
site = 'https://ranobelib.me';
apiSite = 'https://api.cdnlibs.org/api/manga/';
version = '2.2.3';
version = '2.2.4';
icon = 'src/ru/ranobelib/icon.png';
webStorageUtilized = true;
imageRequestInit = {
@@ -223,13 +223,11 @@ class RLIB implements Plugin.PluginBase {
volume,
{ headers: this.getHeaders() },
).then(res => res.json());
const content = result?.data?.content;
chapterText =
result?.data?.content?.type == 'doc'
? jsonToHtml(
result.data.content.content,
result.data.attachments || [],
)
: result?.data?.content;
typeof content === 'object' && content?.type === 'doc'
? jsonToHtml(content.content, result.data.attachments || [])
: (content as string) || '';
}
return chapterText;
}
@@ -277,7 +275,9 @@ class RLIB implements Plugin.PluginBase {
};
getUser = () => {
const user = storage.get('user');
const user = storage.get('user') as
| { token: string; id: number }
| undefined;
if (user) {
return { token: { Authorization: 'Bearer ' + user.token }, ui: user.id };
}
@@ -719,7 +719,7 @@ type DataClass = {
created_at?: string;
moderated?: AgeRestriction;
likes_count?: number;
content?: any;
content?: string | { type: string; content: HTML[] };
attachments?: Attachment[];
};
+18 -19
View File
@@ -11,7 +11,7 @@ class ReN implements Plugin.PluginBase {
name = 'Renovels';
icon = 'src/ru/renovels/icon.png';
site = 'https://renovels.org';
version = '1.0.3';
version = '1.0.4';
async popularNovels(
pageNo: number,
@@ -20,26 +20,25 @@ class ReN implements Plugin.PluginBase {
filters,
}: Plugin.PopularNovelsOptions<typeof this.filters>,
): Promise<Plugin.NovelItem[]> {
let url = this.site + '/api/v2/search/catalog/?count=30&ordering=-';
url += showLatestNovels ? 'chapter_date' : filters?.sort?.value || 'rating';
Object.entries(filters || {}).forEach(([type, { value }]: any) => {
if (value instanceof Array && value.length) {
url += '&' + type + '=' + value.join('&' + type + '=');
}
if (value?.include instanceof Array && value.include.length) {
url += '&' + type + '=' + value.include.join('&' + type + '=');
}
if (value?.exclude instanceof Array && value.exclude.length) {
url +=
'&exclude_' +
type +
'=' +
value.exclude.join('&exclude_' + type + '=');
}
const params = new URLSearchParams({
count: '30',
ordering: '-' + (showLatestNovels ? 'chapter_date' : filters.sort.value),
});
url += '&page=' + pageNo;
for (const [type, filter] of Object.entries(filters)) {
const value = filter.value;
if (Array.isArray(value)) {
value.forEach(v => params.append(type, v));
} else if (typeof value === 'object' && value !== null) {
value.include?.forEach((v: string) => params.append(type, v));
value.exclude?.forEach((v: string) =>
params.append(`exclude_${type}`, v),
);
}
}
params.append('page', pageNo.toString());
const url = `${this.site}/api/v2/search/catalog/?${params.toString()}`;
const { results }: { results: responseNovels[] } = await fetchApi(url).then(
res => res.json(),
+16 -13
View File
@@ -15,7 +15,7 @@ class RV implements Plugin.PluginBase {
async fetchNovels(
page: number,
{ filters }: Plugin.PopularNovelsOptions<typeof this.filters>,
filters?: Plugin.PopularNovelsOptions<typeof this.filters>['filters'],
searchTerm?: string,
): Promise<Plugin.NovelItem[]> {
let url = this.site + 'api/books?page=' + page;
@@ -23,8 +23,8 @@ class RV implements Plugin.PluginBase {
if (searchTerm) url += '&search=' + searchTerm;
const { data }: { data: book[] } = await fetchApi(url).then(res =>
res.json(),
const { data }: { data: book[] } = await fetchApi(url).then(
(res: Response) => res.json(),
);
const novels: Plugin.NovelItem[] = [];
@@ -39,18 +39,21 @@ class RV implements Plugin.PluginBase {
return novels;
}
popularNovels = this.fetchNovels;
async searchNovels(
searchTerm: string,
async popularNovels(
page: number,
): Promise<Plugin.NovelItem[]> {
const defaultOptions: any = { filters: {} };
return this.fetchNovels(page, defaultOptions, searchTerm);
{ filters }: Plugin.PopularNovelsOptions<typeof this.filters>,
) {
return this.fetchNovels(page, filters);
}
async searchNovels(searchTerm: string, page: number) {
return this.fetchNovels(page, undefined, searchTerm);
}
async parseNovel(novelPath: string): Promise<Plugin.SourceNovel> {
const body = await fetchApi(this.site + novelPath).then(res => res.text());
const body = await fetchApi(this.site + novelPath).then((res: Response) =>
res.text(),
);
const loadedCheerio = parseHTML(body);
const novel: Plugin.SourceNovel = {
@@ -73,7 +76,7 @@ class RV implements Plugin.PluginBase {
const chaptersJSON: { data: chapters[] } = await fetchApi(
this.site + 'api/books/' + bookId + '/chapters/all',
).then(res => res.json());
).then((res: Response) => res.json());
if (chaptersJSON.data.length) {
const chapters: Plugin.ChapterItem[] = [];
@@ -98,7 +101,7 @@ class RV implements Plugin.PluginBase {
}
async parseChapter(chapterPath: string): Promise<string> {
const body = await fetchApi(this.site + chapterPath).then(res =>
const body = await fetchApi(this.site + chapterPath).then((res: Response) =>
res.text(),
);
const encrypted = body.match(
+19 -18
View File
@@ -7,21 +7,19 @@ class TopLiba implements Plugin.PluginBase {
id = 'TopLiba';
name = 'ТопЛиба';
site = 'https://topliba.com';
version = '1.0.0';
version = '1.0.1';
icon = 'src/ru/topliba/icon.png';
_token = '';
async fetchNovels(
page: number,
{
showLatestNovels,
filters,
}: Plugin.PopularNovelsOptions<typeof this.filters>,
showLatestNovels?: boolean,
filters?: Plugin.PopularNovelsOptions<typeof this.filters>['filters'],
searchTerm?: string,
): Promise<Plugin.NovelItem[]> {
const data = new URLSearchParams({
order_field: showLatestNovels ? 'date' : filters?.sort?.value || 'rating',
p: page,
p: page.toString(),
});
if (searchTerm) data.append('q', searchTerm);
@@ -30,7 +28,9 @@ class TopLiba implements Plugin.PluginBase {
);
const novels: Plugin.NovelItem[] = [];
this._token = body.match(/<meta name="_token" content="(.*?)"/)?.[1];
this._token = body.match(
/<meta name="_token" content="(.*?)"/,
)?.[1] as string;
const elements = body.match(/<img class="cover" data-original=".*>/g) || [];
elements.forEach(element => {
@@ -48,17 +48,18 @@ class TopLiba implements Plugin.PluginBase {
return novels;
}
popularNovels = this.fetchNovels;
async searchNovels(
searchTerm: string,
async popularNovels(
page: number,
): Promise<Plugin.NovelItem[]> {
const defaultOptions: any = {
showLatestNovels: false,
filters: {},
};
return this.fetchNovels(page, defaultOptions, searchTerm);
{
showLatestNovels,
filters,
}: Plugin.PopularNovelsOptions<typeof this.filters>,
) {
return this.fetchNovels(page, showLatestNovels, filters);
}
async searchNovels(searchTerm: string, page: number) {
return this.fetchNovels(page, false, undefined, searchTerm);
}
async parseNovel(novelPath: string): Promise<Plugin.SourceNovel> {
@@ -124,7 +125,7 @@ class TopLiba implements Plugin.PluginBase {
);
this._token = chaptersHTML.match(
/<meta name="_token" content="(.*?)"/,
)?.[1];
)?.[1] as string;
}
const chapterText = await fetchApi(this.resolveUrl(bookID) + '/chapter', {