mirror of
https://github.com/venera-app/venera-configs.git
synced 2025-09-27 08:27:24 +00:00
jm: fetch img url through setting api (#44)
This commit is contained in:
53
jm.js
53
jm.js
@@ -21,12 +21,7 @@ class JM extends ComicSource {
|
|||||||
"www.cdnmhwscc.org"
|
"www.cdnmhwscc.org"
|
||||||
];
|
];
|
||||||
|
|
||||||
static imageDomains = [
|
static imageUrl = "https://cdn-msp.jmapinodeudzn.net"
|
||||||
"cdn-msp.jmapiproxy3.cc",
|
|
||||||
"cdn-msp3.jmapiproxy3.cc",
|
|
||||||
"cdn-msp2.jmapiproxy1.cc",
|
|
||||||
"cdn-msp3.jmapiproxy3.cc",
|
|
||||||
];
|
|
||||||
|
|
||||||
static apiUa = "Mozilla/5.0 (Linux; Android 10; K; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/130.0.0.0 Mobile Safari/537.36"
|
static apiUa = "Mozilla/5.0 (Linux; Android 10; K; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/130.0.0.0 Mobile Safari/537.36"
|
||||||
|
|
||||||
@@ -37,20 +32,22 @@ class JM extends ComicSource {
|
|||||||
return `https://${JM.apiDomains[index]}`
|
return `https://${JM.apiDomains[index]}`
|
||||||
}
|
}
|
||||||
|
|
||||||
overwriteApiUrls(domains) {
|
get imageUrl() {
|
||||||
if (domains.length !== 0) JM.apiDomains = domains
|
return JM.imageUrl
|
||||||
|
}
|
||||||
|
|
||||||
|
overwriteApiDomains(domains) {
|
||||||
|
if (domains.length != 0) JM.apiDomains = domains
|
||||||
|
}
|
||||||
|
|
||||||
|
overwriteImgUrl(url) {
|
||||||
|
if (url.length != 0) JM.imageUrl = url
|
||||||
}
|
}
|
||||||
|
|
||||||
isNum(str) {
|
isNum(str) {
|
||||||
return /^\d+$/.test(str)
|
return /^\d+$/.test(str)
|
||||||
}
|
}
|
||||||
|
|
||||||
get imageUrl() {
|
|
||||||
let stream = this.loadSetting('imageStream')
|
|
||||||
let index = parseInt(stream) - 1
|
|
||||||
return `https://${JM.imageDomains[index]}`
|
|
||||||
}
|
|
||||||
|
|
||||||
get apiUa() {
|
get apiUa() {
|
||||||
return JM.apiUa;
|
return JM.apiUa;
|
||||||
}
|
}
|
||||||
@@ -73,6 +70,7 @@ class JM extends ComicSource {
|
|||||||
|
|
||||||
async init() {
|
async init() {
|
||||||
if (this.loadSetting('refreshDomainsOnStart')) await this.refreshApiDomains(false)
|
if (this.loadSetting('refreshDomainsOnStart')) await this.refreshApiDomains(false)
|
||||||
|
this.refreshImgUrl(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -117,13 +115,34 @@ class JM extends ComicSource {
|
|||||||
callback: () => {}
|
callback: () => {}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: "Save",
|
text: "Apply",
|
||||||
callback: () => this.overwriteApiUrls(domains)
|
callback: () => {
|
||||||
|
this.overwriteApiDomains(domains)
|
||||||
|
this.refreshImgUrl(true)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
this.overwriteApiUrls(domains)
|
this.overwriteApiDomains(domains)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param showMessage {boolean}
|
||||||
|
*/
|
||||||
|
async refreshImgUrl(showMessage) {
|
||||||
|
let index = this.loadSetting('imageStream')
|
||||||
|
let res = await this.get(
|
||||||
|
`${this.baseUrl}/setting?app_img_shunt=${index}`
|
||||||
|
)
|
||||||
|
let setting = JSON.parse(res)
|
||||||
|
if (setting["img_host"]) {
|
||||||
|
if (showMessage) {
|
||||||
|
UI.showMessage(`Image Stream ${index}:\n${setting["img_host"]}`)
|
||||||
|
}
|
||||||
|
this.overwriteImgUrl(setting["img_host"])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user