fix jaomix (#2035)

* fix

* o kak

* path

* update

* adblock
This commit is contained in:
Rider21
2026-03-05 13:59:25 +03:00
committed by GitHub
parent 928a47cf12
commit b68a513353
4 changed files with 38 additions and 13 deletions
+38 -13
View File
@@ -2,14 +2,14 @@ import { Plugin } from '@/types/plugin';
import { FilterTypes, Filters } from '@libs/filterInputs';
import { fetchApi } from '@libs/fetch';
import { NovelStatus } from '@libs/novelStatus';
import { load as parseHTML } from 'cheerio';
import { load as parseHTML, CheerioAPI } from 'cheerio';
import dayjs from 'dayjs';
class Jaomix implements Plugin.PluginBase {
class Jaomix implements Plugin.PagePlugin {
id = 'jaomix.ru';
name = 'Jaomix';
site = 'https://jaomix.ru';
version = '1.0.2';
version = '1.0.3';
icon = 'src/ru/jaomix/icon.png';
async popularNovels(
@@ -72,15 +72,18 @@ class Jaomix implements Plugin.PluginBase {
return novels;
}
async parseNovel(novelPath: string): Promise<Plugin.SourceNovel> {
async parseNovel(
novelPath: string,
): Promise<Plugin.SourceNovel & { totalPages: number }> {
const body = await fetchApi(this.site + novelPath).then(res => res.text());
const loadedCheerio = parseHTML(body);
const novel: Plugin.SourceNovel = {
const novel: Plugin.SourceNovel & { totalPages: number } = {
path: novelPath,
name: loadedCheerio('div[class="desc-book"] > h1').text().trim(),
cover: loadedCheerio('div[class="img-book"] > img').attr('src'),
summary: loadedCheerio('div[id="desc-tab"]').text().trim(),
totalPages: loadedCheerio('.sel-toc > option').length,
};
loadedCheerio('#info-book > p').each(function () {
@@ -95,11 +98,36 @@ class Jaomix implements Plugin.PluginBase {
: NovelStatus.Completed;
}
});
novel.chapters = this.parseChapters(loadedCheerio);
return novel;
}
async parsePage(novelPath: string, page: string): Promise<Plugin.SourcePage> {
const body = await fetchApi(`${this.site}/wp-admin/admin-ajax.php`, {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
Referer: this.site + novelPath,
Origin: this.site,
},
body: new URLSearchParams({
action: 'loadpagenavchapstt',
page,
}).toString(),
}).then(data => data.text());
const loadedCheerio = parseHTML(body);
const chapters = this.parseChapters(loadedCheerio);
return {
chapters,
};
}
parseChapters(loadedCheerio: CheerioAPI) {
const chapters: Plugin.ChapterItem[] = [];
const totalChapters = loadedCheerio('div.title').length;
loadedCheerio('div.title').each((chapterIndex, element) => {
loadedCheerio('div.title').each((_, element) => {
const name = loadedCheerio(element).find('a').attr('title');
const url = loadedCheerio(element).find('a').attr('href');
if (!name || !url) return;
@@ -109,12 +137,10 @@ class Jaomix implements Plugin.PluginBase {
name,
path: url.replace(this.site, ''),
releaseTime: this.parseDate(releaseDate),
chapterNumber: totalChapters - chapterIndex,
});
});
novel.chapters = chapters.reverse();
return novel;
return chapters;
}
async parseChapter(chapterPath: string): Promise<string> {
@@ -123,9 +149,8 @@ class Jaomix implements Plugin.PluginBase {
);
const loadedCheerio = parseHTML(body);
loadedCheerio('div[class="adblock-service"]').remove();
const chapterText =
loadedCheerio('div[class="entry-content"]').html() || '';
loadedCheerio('.adblock-service, .lazyblock').remove();
const chapterText = loadedCheerio('.entry-content').html() || '';
return chapterText.replace(/<a[^>]*>(.*?)<\/a>/gi, '$1');
}