Skip to content

Commit

Permalink
FIX ManhuaScan : template is Madtheme (#6175)
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeZeDev authored Aug 30, 2023
1 parent 0f0e95c commit b98eebd
Showing 1 changed file with 7 additions and 46 deletions.
53 changes: 7 additions & 46 deletions src/web/mjs/connectors/ManhuaScan.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import FlatManga from './templates/FlatManga.mjs';
import MadTheme from './templates/MadTheme.mjs';

export default class ManhuaScan extends FlatManga {
export default class ManhuaScan extends MadTheme {

constructor() {
super();
Expand All @@ -9,57 +9,18 @@ export default class ManhuaScan extends FlatManga {
this.tags = ['manga', 'webtoon', 'hentai', 'multi-lingual'];
this.url = 'https://manhuascan.io';
this.requestOptions.headers.set('x-referer', this.url + '/');
this.queryMangaTitle = 'ul.manga-info h3';
this.queryChapters = 'div#tab-chapper div#list-chapters span.title a.chapter';
}

async _getMangas() {
let mangaList = [];
const uri = new URL('/manga-list', this.url);
async _getChapters(manga) {
const mangaid = manga.id.match(/\/manga\/(\d+)-/)[1];
const uri = new URL(`/service/backend/chaplist/?manga_id=${mangaid}`, this.url);
const request = new Request(uri, this.requestOptions);
const data = await this.fetchDOM(request, 'div.pagination-wrap ul.pagination li:nth-last-of-type(2) a');
const pageCount = parseInt(data[0].text);
for (let page = 1; page <= pageCount; page++) {
const mangas = await this._getMangasFromPage(page);
mangaList.push(...mangas);
}
return mangaList;
}

async _getMangasFromPage(page) {
const uri = new URL('/manga-list?page=' + page, this.url);
const request = new Request(uri, this.requestOptions);
const data = await this.fetchDOM(request, 'div.media h3.media-heading a');
const data = await this.fetchDOM(request, 'ul.chapter-list li a');
return data.map(element => {
return {
id: this.getRootRelativeOrAbsoluteLink(element, this.url),
title: element.text.trim()
title: element.querySelector(this.queryChapterTitle).textContent.trim()
};
});
}

// Same decryption as in HeroScan
async _getPages(chapter) {
const script = `
new Promise(async resolve => {
const response = await fetch('/app/manga/controllers/cont.chapterServer1.php', {
method: 'POST',
body: 'id=' + chapter_id,
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
});
const data = await response.text();
const key = CryptoJS.enc.Hex.parse('e11adc3949ba59abbe56e057f20f131e');
const options = {
iv: CryptoJS.enc.Hex.parse('1234567890abcdef1234567890abcdef'),
padding: CryptoJS.pad.ZeroPadding
};
const decrypted = CryptoJS.AES.decrypt(data, key, options).toString(CryptoJS.enc.Utf8).replace(/(^\u0002+)|(\u0003+$)/g, '').trim();
resolve(decrypted.split(','));
});
`;
const uri = new URL(chapter.id, this.url);
const request = new Request(uri, this.requestOptions);
const data = await Engine.Request.fetchUI(request, script);
return data.map(link => this.createConnectorURI(link));
}
}

0 comments on commit b98eebd

Please sign in to comment.