diff --git a/web/src/engine/websites/YuraManga.ts b/web/src/engine/websites/YuraManga.ts index bea46f911..d2e6a1179 100644 --- a/web/src/engine/websites/YuraManga.ts +++ b/web/src/engine/websites/YuraManga.ts @@ -1,13 +1,42 @@ import { Tags } from '../Tags'; import icon from './YuraManga.webp'; -import { DecoratableMangaScraper } from '../providers/MangaPlugin'; -import * as Madara from './decorators/WordPressMadara'; +import { DecoratableMangaScraper, Manga, type MangaPlugin } from '../providers/MangaPlugin'; import * as Common from './decorators/Common'; +import { FetchJSON } from '../platform/FetchProvider'; -@Madara.MangaCSS(/^{origin}\/manga\/[^/]+\/$/, 'meta[property="og:title"]:not([content*="YuraManga"])') -@Madara.MangasMultiPageAJAX() -@Madara.ChaptersSinglePageAJAXv2() -@Madara.PagesSinglePageCSS() +type RSS = { + feed: { + entry: { + title: { + $t: string + }, + link: { + rel: string + title: string, + href: string + }[] + }[] + } +} + +const chapterScript = ` + new Promise ( resolve => + resolve (clwd.arr.filter(chapter => chapter.link != window.location.href) + .map(chapter => { + return { + id: new URL(chapter.link).pathname, + title : chapter.title.trim() + }; + }) + ) + ); +`; + +const pagesScript = `[...document.querySelectorAll('div.isi_chapter div.bx_dl img')].map(img => img.dataset.src ?? img.src);`; + +@Common.MangaCSS(/^{origin}\/\d+\/\d+\/[^/]+\.html$/, 'meta[name="description"]') +@Common.ChaptersSinglePageJS(chapterScript, 500) +@Common.PagesSinglePageJS(pagesScript, 1500) @Common.ImageAjax() export default class extends DecoratableMangaScraper { @@ -18,4 +47,13 @@ export default class extends DecoratableMangaScraper { public override get Icon() { return icon; } -} \ No newline at end of file + + public override async FetchMangas(provider: MangaPlugin): Promise { + const { feed: { entry } } = await FetchJSON(new Request(new URL('/feeds/posts/default/-/Series?orderby=published&alt=json&max-results=999', this.URI))); + return entry.map(manga => { + const goodLink = manga.link.find(link => link.rel === 'alternate'); + return new Manga(this, provider, new URL(goodLink.href).pathname, goodLink.title); + }); + } + +} diff --git a/web/src/engine/websites/YuraManga_e2e.ts b/web/src/engine/websites/YuraManga_e2e.ts index 8d87515d4..8695b1f72 100644 --- a/web/src/engine/websites/YuraManga_e2e.ts +++ b/web/src/engine/websites/YuraManga_e2e.ts @@ -8,7 +8,7 @@ const config: Config = { }, container: { url: 'https://www.yuramanga.my.id/2023/08/district-12.html', - id: JSON.stringify({ post: '2130', slug: '/manga/district-12/' }), + id: '/2023/08/district-12.html', title: 'District 12' }, child: { @@ -17,8 +17,8 @@ const config: Config = { }, entry: { index: 1, - size: 1_637_152, - type: 'image/jpeg' + size: 755_988, + type: 'image/webp' } };