Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX ManhuaScan : template is Madtheme #6175

Merged
merged 1 commit into from
Aug 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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));
}
}
Loading