mirror of
https://github.com/kodjodevf/mangayomi-extensions.git
synced 2026-02-19 21:30:29 +00:00
extension(mangafire): Added view manga as volume
This commit is contained in:
@@ -6,13 +6,18 @@ const mangayomiSources = [{
|
||||
"iconUrl": "https://mangafire.to/assets/sites/mangafire/favicon.png?v3",
|
||||
"typeSource": "single",
|
||||
"itemType": 0,
|
||||
"version": "0.1.22",
|
||||
"version": "0.1.23",
|
||||
"dateFormat": "",
|
||||
"dateFormatLocale": "",
|
||||
"pkgPath": "manga/src/all/mangafire.js"
|
||||
}];
|
||||
|
||||
class DefaultExtension extends MProvider {
|
||||
|
||||
getPreference(key) {
|
||||
return new SharedPreferences().get(key);
|
||||
}
|
||||
|
||||
mangaListFromPage(res) {
|
||||
const doc = new Document(res.body);
|
||||
const elements = doc.select("div.unit");
|
||||
@@ -104,7 +109,7 @@ class DefaultExtension extends MProvider {
|
||||
}
|
||||
|
||||
async getDetail(url) {
|
||||
// get urls
|
||||
const viewType = this.getPreference("mangafire_pref_content_view")
|
||||
const id = url.split(".").pop();
|
||||
const detail = {};
|
||||
|
||||
@@ -126,29 +131,38 @@ class DefaultExtension extends MProvider {
|
||||
|
||||
// get chapter
|
||||
// /read/ is needed to get chapter details
|
||||
const chapterUrl = this.source.baseUrl + `/ajax/read/${id}/chapter/${this.source.lang}`;
|
||||
const chapterUrl = this.source.baseUrl + `/ajax/read/${id}/${viewType}/${this.source.lang}`;
|
||||
const idRes = await new Client().get(chapterUrl);
|
||||
const idDoc = new Document(JSON.parse(idRes.body).result.html);
|
||||
const ids = idDoc.select("a");
|
||||
// /manga/ is needed to get chapter dateUpload
|
||||
const chapRes = await new Client().get(this.source.baseUrl + `/ajax/manga/${id}/chapter/${this.source.lang}`);
|
||||
|
||||
var chapElements = null
|
||||
if (viewType == "chapter") { // upload date is not present in volumes
|
||||
// /manga/ is needed to get chapter upload date
|
||||
const chapRes = await new Client().get(this.source.baseUrl + `/ajax/manga/${id}/${viewType}/${this.source.lang}`);
|
||||
const chapDoc = new Document(JSON.parse(chapRes.body).result);
|
||||
const chapElements = chapDoc.selectFirst(".scroll-sm").children;
|
||||
chapElements = chapDoc.selectFirst(".scroll-sm").children;
|
||||
}
|
||||
detail.chapters = [];
|
||||
for (let i = 0; i < ids.length; i++) {
|
||||
const name = ids[i].text;
|
||||
const id = ids[i].attr("data-id");
|
||||
var title = ids[i].attr("title").split(" - ");
|
||||
var scanlator = title.length > 1 ? title[0] : "Vol 1"
|
||||
const id = ids[i]
|
||||
const name = id.text;
|
||||
const mangaId = id.attr("data-id");
|
||||
|
||||
const url = this.source.baseUrl + `/ajax/read/chapter/${id}`;
|
||||
let dateUpload;
|
||||
var scanlator = null
|
||||
var dateUpload = null;
|
||||
if (viewType == "chapter") { // upload date is not present in volumes
|
||||
const chapElement = chapElements[i]
|
||||
var title = chapElement.selectFirst("a").attr("title").split(" - ");
|
||||
scanlator = title.length > 1 ? title[0] : "Vol 1"
|
||||
try {
|
||||
dateUpload = this.parseDate(chapElements[i].selectFirst("span + span").text);
|
||||
dateUpload = this.parseDate(chapElement.selectFirst("span + span").text);
|
||||
} catch (_) {
|
||||
dateUpload = null
|
||||
}
|
||||
}
|
||||
|
||||
const url = this.source.baseUrl + `/ajax/read/${viewType}/${mangaId}`;
|
||||
detail.chapters.push({ name, url, dateUpload, scanlator });
|
||||
}
|
||||
return detail;
|
||||
@@ -268,6 +282,15 @@ class DefaultExtension extends MProvider {
|
||||
}
|
||||
|
||||
getSourcePreferences() {
|
||||
throw new Error("getSourcePreferences not implemented");
|
||||
return [{
|
||||
key: 'mangafire_pref_content_view',
|
||||
listPreference: {
|
||||
title: 'View manga as',
|
||||
summary: '',
|
||||
valueIndex: 0,
|
||||
entries: ["Chapters", "Volumes"],
|
||||
entryValues: ["chapter", "volume"]
|
||||
}
|
||||
}]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user