mirror of
https://github.com/kodjodevf/mangayomi-extensions.git
synced 2026-02-14 02:41:39 +00:00
feat(manhwaz): make baseUrl configurable via source preferences
This commit is contained in:
@@ -161,7 +161,7 @@ class DefaultExtension extends MProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getPopular(page) {
|
async getPopular(page) {
|
||||||
const url = `${this.source.baseUrl}/genre/manhwa?page=${page}&m_orderby=views`;
|
const url = `${this.getBaseUrl()}/genre/manhwa?page=${page}&m_orderby=views`;
|
||||||
const res = await new Client().get(url, this.getHeaders());
|
const res = await new Client().get(url, this.getHeaders());
|
||||||
return this.mangaListFromPage(res, ".page-item-detail");
|
return this.mangaListFromPage(res, ".page-item-detail");
|
||||||
}
|
}
|
||||||
@@ -171,7 +171,7 @@ class DefaultExtension extends MProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getLatestUpdates(page) {
|
async getLatestUpdates(page) {
|
||||||
const url = `${this.source.baseUrl}/?page=${page}`;
|
const url = `${this.getBaseUrl()}/?page=${page}`;
|
||||||
const res = await new Client().get(url, this.getHeaders());
|
const res = await new Client().get(url, this.getHeaders());
|
||||||
return this.mangaListFromPage(res, ".page-item-detail");
|
return this.mangaListFromPage(res, ".page-item-detail");
|
||||||
}
|
}
|
||||||
@@ -179,13 +179,13 @@ class DefaultExtension extends MProvider {
|
|||||||
async search(query, page, filters) {
|
async search(query, page, filters) {
|
||||||
if (query && query.trim()) {
|
if (query && query.trim()) {
|
||||||
// Search with query
|
// Search with query
|
||||||
const url = `${this.source.baseUrl}/search?s=${encodeURIComponent(query)}&page=${page}`;
|
const url = `${this.getBaseUrl()}/search?s=${encodeURIComponent(query)}&page=${page}`;
|
||||||
const res = await new Client().get(url, this.getHeaders());
|
const res = await new Client().get(url, this.getHeaders());
|
||||||
return this.mangaListFromPage(res, ".page-item-detail");
|
return this.mangaListFromPage(res, ".page-item-detail");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Filter-based search
|
// Filter-based search
|
||||||
let url = this.source.baseUrl;
|
let url = this.getBaseUrl();
|
||||||
let hasGenreFilter = false;
|
let hasGenreFilter = false;
|
||||||
|
|
||||||
// Process filters
|
// Process filters
|
||||||
@@ -227,9 +227,7 @@ class DefaultExtension extends MProvider {
|
|||||||
|
|
||||||
async getDetail(url) {
|
async getDetail(url) {
|
||||||
// Ensure we have the full URL
|
// Ensure we have the full URL
|
||||||
const fullUrl = url.startsWith("http")
|
const fullUrl = url.startsWith("http") ? url : `${this.getBaseUrl()}${url}`;
|
||||||
? url
|
|
||||||
: `${this.source.baseUrl}${url}`;
|
|
||||||
const res = await new Client().get(fullUrl, this.getHeaders());
|
const res = await new Client().get(fullUrl, this.getHeaders());
|
||||||
const doc = new Document(res.body);
|
const doc = new Document(res.body);
|
||||||
|
|
||||||
@@ -302,9 +300,7 @@ class DefaultExtension extends MProvider {
|
|||||||
|
|
||||||
async getPageList(url) {
|
async getPageList(url) {
|
||||||
// Ensure we have the full URL
|
// Ensure we have the full URL
|
||||||
const fullUrl = url.startsWith("http")
|
const fullUrl = url.startsWith("http") ? url : `${this.getBaseUrl()}${url}`;
|
||||||
? url
|
|
||||||
: `${this.source.baseUrl}${url}`;
|
|
||||||
const res = await new Client().get(fullUrl, this.getHeaders());
|
const res = await new Client().get(fullUrl, this.getHeaders());
|
||||||
const doc = new Document(res.body);
|
const doc = new Document(res.body);
|
||||||
|
|
||||||
@@ -322,7 +318,7 @@ class DefaultExtension extends MProvider {
|
|||||||
if (imageUrl.startsWith("//")) {
|
if (imageUrl.startsWith("//")) {
|
||||||
finalUrl = "https:" + imageUrl;
|
finalUrl = "https:" + imageUrl;
|
||||||
} else if (imageUrl.startsWith("/")) {
|
} else if (imageUrl.startsWith("/")) {
|
||||||
finalUrl = this.source.baseUrl + imageUrl;
|
finalUrl = this.getBaseUrl() + imageUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
pages.push(finalUrl);
|
pages.push(finalUrl);
|
||||||
@@ -395,7 +391,30 @@ class DefaultExtension extends MProvider {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getBaseUrl() {
|
||||||
|
const preference = new SharedPreferences();
|
||||||
|
var base_url = preference.get("domain_url");
|
||||||
|
if (base_url.length == 0) {
|
||||||
|
return this.source.baseUrl;
|
||||||
|
}
|
||||||
|
if (base_url.endsWith("/")) {
|
||||||
|
return base_url.slice(0, -1);
|
||||||
|
}
|
||||||
|
return base_url;
|
||||||
|
}
|
||||||
|
|
||||||
getSourcePreferences() {
|
getSourcePreferences() {
|
||||||
return [];
|
return [
|
||||||
|
{
|
||||||
|
key: "domain_url",
|
||||||
|
editTextPreference: {
|
||||||
|
title: "Edit URL",
|
||||||
|
summary: "",
|
||||||
|
value: this.source.baseUrl,
|
||||||
|
dialogTitle: "URL",
|
||||||
|
dialogMessage: "",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user