From 1e9f8665c958d10720e4551491d1245b55d16f8c Mon Sep 17 00:00:00 2001 From: MikeZeDev Date: Fri, 25 Oct 2024 16:56:10 +0000 Subject: [PATCH] AllHentai : fix getting chapter links Website append a param to chapter links using JS so people can access it. --- src/web/mjs/connectors/AllHentai.mjs | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/src/web/mjs/connectors/AllHentai.mjs b/src/web/mjs/connectors/AllHentai.mjs index 4803a1a261..683e52adef 100644 --- a/src/web/mjs/connectors/AllHentai.mjs +++ b/src/web/mjs/connectors/AllHentai.mjs @@ -55,15 +55,28 @@ export default class AllHentai extends Connector { } async _getChapters(manga) { + const chapterScript = ` + new Promise( (resolve, reject) => { + try { + setTimeout(() => { + const chapters = [...document.querySelectorAll('div#chapters-list table tr td a[title]')]; + resolve(chapters.map(chapter => { + return { + id: chapter.pathname + chapter.search, + title : chapter.text.trim(), + } + })); + + }, 1500); + } catch (error) { + reject(error); + } + }); + `; + const uri = new URL(manga.id, this.url); const request = new Request(uri, this.requestOptions); - const data = await this.fetchDOM(request, 'div#chapters-list table tr td a[title]'); - return data.map(element => { - return { - id: this.getRootRelativeOrAbsoluteLink(element, this.url), - title : element.text.replace(manga.title, '').trim(), - }; - }); + return Engine.Request.fetchUI(request, chapterScript, 5000); } async _getPages(chapter) {