mirror of
https://github.com/kodjodevf/mangayomi-extensions.git
synced 2026-02-14 10:51:17 +00:00
kolnovel: add source preferences for switching between official and free sources
This commit is contained in:
@@ -14,14 +14,16 @@ const mangayomiSources = [{
|
|||||||
|
|
||||||
class DefaultExtension extends MProvider {
|
class DefaultExtension extends MProvider {
|
||||||
headers = {
|
headers = {
|
||||||
Referer: this.source.baseUrl,
|
Referer: this.activeSiteUrl,
|
||||||
Origin: this.source.baseUrl,
|
Origin: this.activeSiteUrl,
|
||||||
"Sec-Fetch-Mode": "cors",
|
"Sec-Fetch-Mode": "cors",
|
||||||
"Accept-Encoding": "gzip, deflate",
|
"Accept-Encoding": "gzip, deflate",
|
||||||
"User-Agent":
|
"User-Agent":
|
||||||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36",
|
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
defaultKolBookUrl = "https://kolbook.xyz";
|
||||||
|
|
||||||
getHeaders(url) {
|
getHeaders(url) {
|
||||||
throw new Error("getHeaders not implemented");
|
throw new Error("getHeaders not implemented");
|
||||||
}
|
}
|
||||||
@@ -50,7 +52,7 @@ class DefaultExtension extends MProvider {
|
|||||||
|
|
||||||
async getPopular(page) {
|
async getPopular(page) {
|
||||||
const res = await new Client().get(
|
const res = await new Client().get(
|
||||||
`${this.source.baseUrl}/series/?page=${page}&order=popular`,
|
`${this.activeSiteUrl}/series/?page=${page}&order=popular`,
|
||||||
this.headers,
|
this.headers,
|
||||||
);
|
);
|
||||||
return this.novelFromElement(res);
|
return this.novelFromElement(res);
|
||||||
@@ -58,7 +60,7 @@ class DefaultExtension extends MProvider {
|
|||||||
|
|
||||||
async getLatestUpdates(page) {
|
async getLatestUpdates(page) {
|
||||||
const res = await new Client().get(
|
const res = await new Client().get(
|
||||||
`${this.source.baseUrl}/series/?page=${page}&order=update`,
|
`${this.activeSiteUrl}/series/?page=${page}&order=update`,
|
||||||
this.headers,
|
this.headers,
|
||||||
);
|
);
|
||||||
return this.novelFromElement(res);
|
return this.novelFromElement(res);
|
||||||
@@ -89,7 +91,60 @@ class DefaultExtension extends MProvider {
|
|||||||
getFilterList() {
|
getFilterList() {
|
||||||
throw new Error("getFilterList not implemented");
|
throw new Error("getFilterList not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getSanitizedUrl(prefKey) {
|
||||||
|
const preference = new SharedPreferences();
|
||||||
|
let url = preference.get(prefKey) || this.source.baseUrl;
|
||||||
|
return url.endsWith("/") ? url.slice(0, -1) : url;
|
||||||
|
}
|
||||||
|
|
||||||
|
get activeSiteUrl() {
|
||||||
|
return this.getSanitizedUrl("selected_site_url");
|
||||||
|
}
|
||||||
|
|
||||||
|
get kolNovelUrl() {
|
||||||
|
return this.getSanitizedUrl("kolnovel_custom_url");
|
||||||
|
}
|
||||||
|
|
||||||
|
get kolBookUrl() {
|
||||||
|
return this.getSanitizedUrl("kolbook_custom_url");
|
||||||
|
}
|
||||||
|
|
||||||
getSourcePreferences() {
|
getSourcePreferences() {
|
||||||
throw new Error("getSourcePreferences not implemented");
|
return [
|
||||||
|
{
|
||||||
|
key: "kolnovel_custom_url",
|
||||||
|
editTextPreference: {
|
||||||
|
title: "المصدر الرئيسي",
|
||||||
|
summary: "يوفر كافة الفصول، لكن بعض المحتوى يتطلب اشتراكًا.",
|
||||||
|
value: this.source.baseUrl,
|
||||||
|
dialogTitle: "URL",
|
||||||
|
dialogMessage: "",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "kolbook_custom_url",
|
||||||
|
editTextPreference: {
|
||||||
|
title: "المصدر المجاني",
|
||||||
|
summary: "لا يتطلب اشتراكًا، ولكن قد لا بحتوي على كافة الفصول.",
|
||||||
|
value: this.defaultKolBookUrl,
|
||||||
|
dialogTitle: "URL",
|
||||||
|
dialogMessage: "",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "selected_site_url",
|
||||||
|
listPreference: {
|
||||||
|
title: "أختر المصدر.",
|
||||||
|
summary: "",
|
||||||
|
valueIndex: 0,
|
||||||
|
entries: [
|
||||||
|
"المصدر الرسمي (قد يتطلب اشتراك)",
|
||||||
|
"المصدر المجانية (بدون اشتراك)",
|
||||||
|
],
|
||||||
|
entryValues: [this.kolNovelUrl, this.kolBookUrl],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user