Add TopLiba (#1003)
* test * cleanup deleted unused `fetchFile` import replaced fetch with `fetchApi` * eslint * fix * fix multi * Hmm, what to do next. * test URLSearchParams * fix
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import { Parser } from 'htmlparser2';
|
||||
import { fetchApi, fetchFile } from '@libs/fetch';
|
||||
import { FilterTypes, Filters } from '@libs/filterInputs';
|
||||
import { fetchApi } from '@libs/fetch';
|
||||
import { Plugin } from '@typings/plugin';
|
||||
|
||||
class RanobesPlugin implements Plugin.PagePlugin {
|
||||
@@ -8,7 +7,6 @@ class RanobesPlugin implements Plugin.PagePlugin {
|
||||
name = 'Ranobes';
|
||||
icon = 'src/en/ranobes/icon.png';
|
||||
site = 'https://ranobes.top';
|
||||
filters?: Filters | undefined;
|
||||
version = '2.0.0';
|
||||
|
||||
async sleep(ms: number) {
|
||||
@@ -81,14 +79,8 @@ class RanobesPlugin implements Plugin.PagePlugin {
|
||||
return chapter.reverse();
|
||||
}
|
||||
|
||||
async popularNovels(
|
||||
page: number,
|
||||
{
|
||||
showLatestNovels,
|
||||
filters,
|
||||
}: Plugin.PopularNovelsOptions<typeof this.filters>,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
let link = `${this.site}/novels/page/${page}/`;
|
||||
async popularNovels(page: number): Promise<Plugin.NovelItem[]> {
|
||||
const link = `${this.site}/novels/page/${page}/`;
|
||||
const body = await fetchApi(link).then(r => r.text());
|
||||
|
||||
return this.parseNovels(body);
|
||||
@@ -107,7 +99,7 @@ class RanobesPlugin implements Plugin.PagePlugin {
|
||||
chapters: [],
|
||||
totalPages: 1,
|
||||
};
|
||||
let baseUrl = this.site;
|
||||
const baseUrl = this.site;
|
||||
let isCover = false;
|
||||
let isAuthor = false;
|
||||
let isSummary = false;
|
||||
@@ -115,7 +107,7 @@ class RanobesPlugin implements Plugin.PagePlugin {
|
||||
let isStatusText = false;
|
||||
let isGenres = false;
|
||||
let isGenresText = false;
|
||||
let genreArray: string[] = [];
|
||||
const genreArray: string[] = [];
|
||||
let novelId = '';
|
||||
const parser = new Parser({
|
||||
onopentag(name, attribs) {
|
||||
@@ -276,7 +268,7 @@ class RanobesPlugin implements Plugin.PagePlugin {
|
||||
const parser = new Parser({
|
||||
onopentag(name, attribs) {
|
||||
if (isChapter && name === 'div') {
|
||||
let stylediv = attribs['style'];
|
||||
const stylediv = attribs['style'];
|
||||
if (stylediv) {
|
||||
chapterText += `<div style="${stylediv}">`;
|
||||
isStyleText = true;
|
||||
@@ -285,7 +277,7 @@ class RanobesPlugin implements Plugin.PagePlugin {
|
||||
}
|
||||
}
|
||||
if (isChapter && name === 'table') {
|
||||
let w = attribs['width'];
|
||||
const w = attribs['width'];
|
||||
if (w) {
|
||||
chapterText += `<table width="${w}">`;
|
||||
} else {
|
||||
@@ -299,7 +291,7 @@ class RanobesPlugin implements Plugin.PagePlugin {
|
||||
chapterText += `<tr>`;
|
||||
}
|
||||
if (isChapter && name === 'td') {
|
||||
let w1 = attribs['width'];
|
||||
const w1 = attribs['width'];
|
||||
if (w1) {
|
||||
chapterText += `<td width="${w1}">`;
|
||||
} else {
|
||||
@@ -369,7 +361,7 @@ class RanobesPlugin implements Plugin.PagePlugin {
|
||||
searchTerm: string,
|
||||
page: number,
|
||||
): Promise<Plugin.NovelItem[]> {
|
||||
let link = `${this.site}/search/${searchTerm}/page/${page}`;
|
||||
const link = `${this.site}/search/${searchTerm}/page/${page}`;
|
||||
const body = await fetchApi(link).then(r => r.text());
|
||||
|
||||
return this.parseNovels(body);
|
||||
|
||||
Reference in New Issue
Block a user