mirror of
https://github.com/venera-app/venera-configs.git
synced 2025-09-27 08:27:24 +00:00
jm: support domain-updating API (#37)
* jm: support domain-updating API * jm: raise minAppVersion * jm: add refresh domain callback * jm: raise minAppVersion
This commit is contained in:
@@ -45,6 +45,6 @@
|
|||||||
"name": "禁漫天堂",
|
"name": "禁漫天堂",
|
||||||
"fileName": "jm.js",
|
"fileName": "jm.js",
|
||||||
"key": "jm",
|
"key": "jm",
|
||||||
"version": "1.0.2"
|
"version": "1.0.3"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
111
jm.js
111
jm.js
@@ -7,25 +7,25 @@ class JM extends ComicSource {
|
|||||||
// unique id of the source
|
// unique id of the source
|
||||||
key = "jm"
|
key = "jm"
|
||||||
|
|
||||||
version = "1.0.2"
|
version = "1.0.3"
|
||||||
|
|
||||||
minAppVersion = "1.0.2"
|
minAppVersion = "1.2.1"
|
||||||
|
|
||||||
// update url
|
// update url
|
||||||
url = "https://raw.githubusercontent.com/venera-app/venera-configs/refs/heads/main/jm.js"
|
url = "https://raw.githubusercontent.com/venera-app/venera-configs/refs/heads/main/jm.js"
|
||||||
|
|
||||||
static apiDomains = [
|
static apiDomains = [
|
||||||
"https://www.jmapiproxyxxx.vip",
|
"www.jmapiproxyxxx.vip",
|
||||||
"https://www.cdnblackmyth.club",
|
"www.cdnblackmyth.club",
|
||||||
"https://www.cdnmhws.cc",
|
"www.cdnmhws.cc",
|
||||||
"https://www.cdnmhwscc.org"
|
"www.cdnmhwscc.org"
|
||||||
];
|
];
|
||||||
|
|
||||||
static imageUrls = [
|
static imageDomains = [
|
||||||
"https://cdn-msp.jmapiproxy3.cc",
|
"cdn-msp.jmapiproxy3.cc",
|
||||||
"https://cdn-msp3.jmapiproxy3.cc",
|
"cdn-msp3.jmapiproxy3.cc",
|
||||||
"https://cdn-msp2.jmapiproxy1.cc",
|
"cdn-msp2.jmapiproxy1.cc",
|
||||||
"https://cdn-msp3.jmapiproxy3.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"
|
||||||
@@ -34,7 +34,11 @@ class JM extends ComicSource {
|
|||||||
|
|
||||||
get baseUrl() {
|
get baseUrl() {
|
||||||
let index = parseInt(this.loadSetting('apiDomain')) - 1
|
let index = parseInt(this.loadSetting('apiDomain')) - 1
|
||||||
return JM.apiDomains[index]
|
return `https://${JM.apiDomains[index]}`
|
||||||
|
}
|
||||||
|
|
||||||
|
overwriteApiUrls(domains) {
|
||||||
|
if (domains.length != 0) JM.apiDomains = domains
|
||||||
}
|
}
|
||||||
|
|
||||||
isNum(str) {
|
isNum(str) {
|
||||||
@@ -44,7 +48,7 @@ class JM extends ComicSource {
|
|||||||
get imageUrl() {
|
get imageUrl() {
|
||||||
let stream = this.loadSetting('imageStream')
|
let stream = this.loadSetting('imageStream')
|
||||||
let index = parseInt(stream) - 1
|
let index = parseInt(stream) - 1
|
||||||
return JM.imageUrls[index]
|
return `https://${JM.imageDomains[index]}`
|
||||||
}
|
}
|
||||||
|
|
||||||
get apiUa() {
|
get apiUa() {
|
||||||
@@ -67,6 +71,62 @@ class JM extends ComicSource {
|
|||||||
return `${this.imageUrl}/media/users/${imageName}`
|
return `${this.imageUrl}/media/users/${imageName}`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async init() {
|
||||||
|
if (this.loadSetting('refreshDomainsOnStart')) await this.refreshApiDomains(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param showConfirmDialog {boolean}
|
||||||
|
*/
|
||||||
|
async refreshApiDomains(showConfirmDialog) {
|
||||||
|
let today = new Date();
|
||||||
|
let url = "https://jmappc01-1308024008.cos.ap-guangzhou.myqcloud.com/server-2024.txt"
|
||||||
|
let domainSecret = "diosfjckwpqpdfjkvnqQjsik"
|
||||||
|
let title = ""
|
||||||
|
let message = ""
|
||||||
|
let domains = []
|
||||||
|
let res = await fetch(
|
||||||
|
`${url}?time=${today.getFullYear()}${today.getMonth() + 1}${today.getDate()}`,
|
||||||
|
{headers: {"User-Agent": this.imgUa}}
|
||||||
|
)
|
||||||
|
if (res.status == 200) {
|
||||||
|
let data = this.convertData(await res.text(), domainSecret)
|
||||||
|
let json = JSON.parse(data)
|
||||||
|
if (json["Server"]) {
|
||||||
|
title = "Update Success"
|
||||||
|
message = "New domains:\n\n"
|
||||||
|
domains = json["Server"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (domains.length == 0) {
|
||||||
|
title = "Update Failed"
|
||||||
|
message = `Using built-in domains:\n\n`
|
||||||
|
domains = JM.apiDomains
|
||||||
|
}
|
||||||
|
for (let i = 0; i < domains.length; i++) {
|
||||||
|
message = message + `Stream ${i + 1}: ${domains[i]}\n`
|
||||||
|
}
|
||||||
|
if (showConfirmDialog) {
|
||||||
|
UI.showDialog(
|
||||||
|
title,
|
||||||
|
message,
|
||||||
|
[
|
||||||
|
{
|
||||||
|
text: "Cancle",
|
||||||
|
callback: () => {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: "Save",
|
||||||
|
callback: () => this.overwriteApiUrls(domains)
|
||||||
|
}
|
||||||
|
]
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
this.overwriteApiUrls(domains)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param comic {object}
|
* @param comic {object}
|
||||||
@@ -114,9 +174,8 @@ class JM extends ComicSource {
|
|||||||
* @param time {number}
|
* @param time {number}
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
convertData(input, time) {
|
convertData(input, secret) {
|
||||||
let secret = '185Hcomic3PAPP7R'
|
let key = Convert.encodeUtf8(Convert.hexEncode(Convert.md5(Convert.encodeUtf8(secret))))
|
||||||
let key = Convert.encodeUtf8(Convert.hexEncode(Convert.md5(Convert.encodeUtf8(`${time}${secret}`))))
|
|
||||||
let data = Convert.decodeBase64(input)
|
let data = Convert.decodeBase64(input)
|
||||||
let decrypted = Convert.decryptAesEcb(data, key)
|
let decrypted = Convert.decryptAesEcb(data, key)
|
||||||
let res = Convert.decodeUtf8(decrypted)
|
let res = Convert.decodeUtf8(decrypted)
|
||||||
@@ -134,6 +193,7 @@ class JM extends ComicSource {
|
|||||||
*/
|
*/
|
||||||
async get(url) {
|
async get(url) {
|
||||||
let time = Math.floor(Date.now() / 1000)
|
let time = Math.floor(Date.now() / 1000)
|
||||||
|
let kJmSecret = "185Hcomic3PAPP7R"
|
||||||
let res = await Network.get(url, this.getHeaders(time))
|
let res = await Network.get(url, this.getHeaders(time))
|
||||||
if(res.status !== 200) {
|
if(res.status !== 200) {
|
||||||
if(res.status === 401) {
|
if(res.status === 401) {
|
||||||
@@ -151,7 +211,7 @@ class JM extends ComicSource {
|
|||||||
if(typeof data !== 'string') {
|
if(typeof data !== 'string') {
|
||||||
throw 'Invalid Data'
|
throw 'Invalid Data'
|
||||||
}
|
}
|
||||||
return this.convertData(data, time)
|
return this.convertData(data, `${time}${kJmSecret}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
// explore page list
|
// explore page list
|
||||||
@@ -607,6 +667,17 @@ class JM extends ComicSource {
|
|||||||
```
|
```
|
||||||
*/
|
*/
|
||||||
settings = {
|
settings = {
|
||||||
|
refreshDomains: {
|
||||||
|
title: "Refresh Domain List",
|
||||||
|
type: "callback",
|
||||||
|
buttonText: "Refresh",
|
||||||
|
callback: () => this.refreshApiDomains(true)
|
||||||
|
},
|
||||||
|
refreshDomainsOnStart: {
|
||||||
|
title: "Refresh Domain List on Startup",
|
||||||
|
type: "switch",
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
apiDomain: {
|
apiDomain: {
|
||||||
title: "Api Domain",
|
title: "Api Domain",
|
||||||
type: "select",
|
type: "select",
|
||||||
@@ -650,10 +721,16 @@ class JM extends ComicSource {
|
|||||||
// [Optional] translations for the strings in this config
|
// [Optional] translations for the strings in this config
|
||||||
translation = {
|
translation = {
|
||||||
'zh_CN': {
|
'zh_CN': {
|
||||||
|
'Refresh Domain List': '刷新域名列表',
|
||||||
|
'Refresh': '刷新',
|
||||||
|
'Refresh Domain List on Startup': '启动时刷新域名列表',
|
||||||
'Api Domain': 'Api域名',
|
'Api Domain': 'Api域名',
|
||||||
'Image Stream': '图片分流',
|
'Image Stream': '图片分流',
|
||||||
},
|
},
|
||||||
'zh_TW': {
|
'zh_TW': {
|
||||||
|
'Refresh Domain List': '刷新域名列表',
|
||||||
|
'Refresh': '刷新',
|
||||||
|
'Refresh Domain List on Startup': '啟動時刷新域名列表',
|
||||||
'Api Domain': 'Api域名',
|
'Api Domain': 'Api域名',
|
||||||
'Image Stream': '圖片分流',
|
'Image Stream': '圖片分流',
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user