[copy_mange] Use Firefox as UA (#81)

This commit is contained in:
角砂糖
2025-06-04 21:59:48 +08:00
committed by GitHub
parent 1a05d70447
commit fd6fd675a1
2 changed files with 61 additions and 67 deletions

View File

@@ -4,7 +4,7 @@ class CopyManga extends ComicSource {
key = "copy_manga" key = "copy_manga"
version = "1.3.2" version = "1.3.3"
minAppVersion = "1.2.1" minAppVersion = "1.2.1"
@@ -12,26 +12,28 @@ class CopyManga extends ComicSource {
headers = {} headers = {}
static defaultCopyVersion = "2.2.9-dev" // static defaultCopyVersion = "2.2.9-dev"
static defaultCopyPlatform = "2" // static defaultCopyPlatform = "2"
static defaultCopyRegion = "1" static defaultCopyRegion = "0"
static defaultImageQuality = "1500" static defaultImageQuality = "1500"
get copyVersion() { static defaultApiUrl = 'mapi.copy20.com'
return this.loadSetting('version')
} // get copyVersion() {
// return this.loadSetting('version')
// }
// get copyPlatform()
// return this.loadSetting('platform')
// }
get apiUrl() { get apiUrl() {
return `https://${this.loadSetting('base_url')}` return `https://${this.loadSetting('base_url')}`
} }
get copyPlatform() {
return this.loadSetting('platform')
}
get copyRegion() { get copyRegion() {
return this.loadSetting('region') || this.defaultCopyRegion return this.loadSetting('region') || this.defaultCopyRegion
} }
@@ -48,15 +50,12 @@ class CopyManga extends ComicSource {
token = " " + token; token = " " + token;
} }
this.headers = { this.headers = {
"User-Agent": "COPY/" + this.copyVersion, "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/114.0",
"Accept": "*/*", "Accept": "*/*",
"Accept-Encoding": "gzip", "Accept-Encoding": "gzip",
"webp": "1", "webp": "1",
"region": this.copyRegion, "region": this.copyRegion,
"version": this.copyVersion,
"authorization": `Token${token}`, "authorization": `Token${token}`,
"platform": this.copyPlatform,
"umstring": "b4c89ca4104ea9a97750314d791520ac",
} }
// 用于储存 { 作者名 : 英文参数 } // 用于储存 { 作者名 : 英文参数 }
this.author_path_word_dict = {} this.author_path_word_dict = {}
@@ -70,28 +69,24 @@ class CopyManga extends ComicSource {
let salt = randomInt(1000, 9999) let salt = randomInt(1000, 9999)
let base64 = Convert.encodeBase64(Convert.encodeUtf8(`${pwd}-${salt}`)) let base64 = Convert.encodeBase64(Convert.encodeUtf8(`${pwd}-${salt}`))
let res = await Network.post( let res = await Network.post(
`${this.apiUrl}/api/v3/login?platform=3`, `${this.apiUrl}/api/v3/login`,
{ {
...this.headers, ...this.headers,
"Content-Type": "application/x-www-form-urlencoded;charset=utf-8" "Content-Type": "application/x-www-form-urlencoded;charset=utf-8"
}, },
`username=${account}&password=${base64}\n&salt=${salt}&platform=3&authorization=Token+&version=1.4.4&source=copyApp&region=${this.copyRegion}&webp=1` `username=${account}&password=${base64}\n&salt=${salt}&authorization=Token+`
); );
if (res.status === 200) { if (res.status === 200) {
let data = JSON.parse(res.body) let data = JSON.parse(res.body)
let token = data.results.token let token = data.results.token
this.saveData('token', token) this.saveData('token', token)
this.headers = { this.headers = {
"User-Agent": "COPY/" + this.copyVersion, "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/114.0",
"Accept": "*/*", "Accept": "*/*",
"Accept-Encoding": "gzip", "Accept-Encoding": "gzip",
"source": "copyApp",
"webp": "1", "webp": "1",
"region": this.copyRegion, "region": this.copyRegion,
"version": this.copyVersion,
"authorization": `Token${token}`, "authorization": `Token${token}`,
"platform": this.copyPlatform,
"umstring": "b4c89ca4104ea9a97750314d791520ac",
} }
return "ok" return "ok"
} else { } else {
@@ -112,7 +107,7 @@ class CopyManga extends ComicSource {
type: "singlePageWithMultiPart", type: "singlePageWithMultiPart",
load: async () => { load: async () => {
let dataStr = await Network.get( let dataStr = await Network.get(
`${this.apiUrl}/api/v3/h5/homeIndex?platform=3`, `${this.apiUrl}/api/v3/h5/homeIndex`,
this.headers this.headers
) )
@@ -256,7 +251,7 @@ class CopyManga extends ComicSource {
param = CopyManga.category_param_dict[category] || ""; param = CopyManga.category_param_dict[category] || "";
} }
options = options.map(e => e.replace("*", "-")) options = options.map(e => e.replace("*", "-"))
category_url = `${this.apiUrl}/api/v3/comics?limit=30&offset=${(page - 1) * 30}&ordering=${options[1]}&theme=${param}&top=${options[0]}&platform=3` category_url = `${this.apiUrl}/api/v3/comics?limit=30&offset=${(page - 1) * 30}&ordering=${options[1]}&theme=${param}&top=${options[0]}`
} }
@@ -379,7 +374,7 @@ class CopyManga extends ComicSource {
if (author && author in this.author_path_word_dict) { if (author && author in this.author_path_word_dict) {
let path_word = encodeURIComponent(this.author_path_word_dict[author]); let path_word = encodeURIComponent(this.author_path_word_dict[author]);
res = await Network.get( res = await Network.get(
`${this.apiUrl}/api/v3/comics?limit=30&offset=${(page - 1) * 30}&ordering=-datetime_updated&author=${path_word}&platform=3`, `${this.apiUrl}/api/v3/comics?limit=30&offset=${(page - 1) * 30}&ordering=-datetime_updated&author=${path_word}`,
this.headers this.headers
) )
} }
@@ -392,7 +387,7 @@ class CopyManga extends ComicSource {
keyword = encodeURIComponent(keyword) keyword = encodeURIComponent(keyword)
let search_url = this.loadSetting('search_api') === "webAPI" ? `${this.apiUrl}/api/kb/web/searchbd/comics` : `${this.apiUrl}/api/v3/search/comic` let search_url = this.loadSetting('search_api') === "webAPI" ? `${this.apiUrl}/api/kb/web/searchbd/comics` : `${this.apiUrl}/api/v3/search/comic`
res = await Network.get( res = await Network.get(
`${search_url}?limit=30&offset=${(page - 1) * 30}&q=${keyword}&q_type=${q_type}&platform=1`, `${search_url}?limit=30&offset=${(page - 1) * 30}&q=${keyword}&q_type=${q_type}`,
this.headers this.headers
) )
} }
@@ -451,7 +446,7 @@ class CopyManga extends ComicSource {
let is_collect = isAdding ? 1 : 0 let is_collect = isAdding ? 1 : 0
let token = this.loadData("token"); let token = this.loadData("token");
let comicData = await Network.get( let comicData = await Network.get(
`${this.apiUrl}/api/v3/comic2/${comicId}?platform=3`, `${this.apiUrl}/api/v3/comic2/${comicId}`,
this.headers this.headers
) )
if (comicData.status !== 200) { if (comicData.status !== 200) {
@@ -459,7 +454,7 @@ class CopyManga extends ComicSource {
} }
let comic_id = JSON.parse(comicData.body).results.comic.uuid let comic_id = JSON.parse(comicData.body).results.comic.uuid
let res = await Network.post( let res = await Network.post(
`${this.apiUrl}/api/v3/member/collect/comic?platform=3`, `${this.apiUrl}/api/v3/member/collect/comic`,
{ {
...this.headers, ...this.headers,
"Content-Type": "application/x-www-form-urlencoded;charset=utf-8", "Content-Type": "application/x-www-form-urlencoded;charset=utf-8",
@@ -476,7 +471,7 @@ class CopyManga extends ComicSource {
}, },
loadComics: async (page, folder) => { loadComics: async (page, folder) => {
var res = await Network.get( var res = await Network.get(
`${this.apiUrl}/api/v3/member/collect/comics?limit=30&offset=${(page - 1) * 30}&free_type=1&ordering=-datetime_updated&platform=3`, `${this.apiUrl}/api/v3/member/collect/comics?limit=30&offset=${(page - 1) * 30}&free_type=1&ordering=-datetime_updated`,
this.headers this.headers
) )
@@ -526,7 +521,7 @@ class CopyManga extends ComicSource {
let getChapters = async (id, groups) => { let getChapters = async (id, groups) => {
let fetchSingle = async (id, path) => { let fetchSingle = async (id, path) => {
let res = await Network.get( let res = await Network.get(
`${this.apiUrl}/api/v3/comic/${id}/group/${path}/chapters?limit=500&offset=0&platform=3`, `${this.apiUrl}/api/v3/comic/${id}/group/${path}/chapters?limit=500&offset=0`,
this.headers this.headers
); );
if (res.status !== 200) { if (res.status !== 200) {
@@ -544,7 +539,7 @@ class CopyManga extends ComicSource {
let offset = 500; let offset = 500;
while (offset < maxChapter) { while (offset < maxChapter) {
res = await Network.get( res = await Network.get(
`${this.apiUrl}/api/v3/comic/chongjingchengweimofashaonv/group/${path}/chapters?limit=500&offset=${offset}&platform=3`, `${this.apiUrl}/api/v3/comic/${id}/group/${path}/chapters?limit=500&offset=${offset}`,
this.headers this.headers
); );
if (res.status !== 200) { if (res.status !== 200) {
@@ -592,7 +587,7 @@ class CopyManga extends ComicSource {
} }
let getFavoriteStatus = async (id) => { let getFavoriteStatus = async (id) => {
let res = await Network.get(`${this.apiUrl}/api/v3/comic2/${id}/query?platform=3`, this.headers); let res = await Network.get(`${this.apiUrl}/api/v3/comic2/${id}/query`, this.headers);
if (res.status !== 200) { if (res.status !== 200) {
throw `Invalid status code: ${res.status}`; throw `Invalid status code: ${res.status}`;
} }
@@ -601,7 +596,7 @@ class CopyManga extends ComicSource {
let results = await Promise.all([ let results = await Promise.all([
Network.get( Network.get(
`${this.apiUrl}/api/v3/comic2/${id}?platform=3`, `${this.apiUrl}/api/v3/comic2/${id}`,
this.headers this.headers
), ),
getFavoriteStatus.bind(this)(id) getFavoriteStatus.bind(this)(id)
@@ -653,10 +648,9 @@ class CopyManga extends ComicSource {
while (attempt < maxAttempts) { while (attempt < maxAttempts) {
try { try {
res = await Network.get( res = await Network.get(
`${this.apiUrl}/api/v3/comic/${comicId}/chapter2/${epId}?platform=3`, `${this.apiUrl}/api/v3/comic/${comicId}/chapter2/${epId}`,
{ {
...this.headers, ...this.headers
"Region": this.copyRegion
} }
); );
@@ -825,11 +819,20 @@ class CopyManga extends ComicSource {
], ],
default: 'baseAPI' default: 'baseAPI'
}, },
base_url: { region: {
title: "API地址", title: "CDN线路",
type: "input", type: "select",
validator: '^(?!:\\/\\/)(?=.{1,253})([a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\\.)+[a-zA-Z]{2,}$', options: [
default: 'www.copy20.com', {
value: "0",
text: '大陆线路'
},
{
value: "1",
text: '海外线路(丢失登陆状态)'
},
],
default: CopyManga.defaultCopyRegion,
}, },
image_quality: { image_quality: {
title: "图片质量", title: "图片质量",
@@ -850,32 +853,23 @@ class CopyManga extends ComicSource {
], ],
default: CopyManga.defaultImageQuality, default: CopyManga.defaultImageQuality,
}, },
version: { base_url: {
title: "拷贝版本重启APP生效", title: "API地址",
type: "input", type: "input",
default: CopyManga.defaultCopyVersion, validator: '^(?!:\\/\\/)(?=.{1,253})([a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\\.)+[a-zA-Z]{2,}$',
}, default: CopyManga.defaultApiUrl,
platform: {
title: "平台代号重启APP生效",
type: "input",
validator: '^\\d+(?:\\.\\d+)*$',
default: CopyManga.defaultCopyPlatform,
},
region: {
title: "CDN线路",
type: "select",
options: [
{
value: "0",
text: '海外线路'
},
{
value: "1",
text: '大陆线路'
}
],
default: CopyManga.defaultCopyRegion,
} }
// version: {
// title: "拷贝版本重启APP生效",
// type: "input",
// default: CopyManga.defaultCopyVersion,
// },
// platform: {
// title: "平台代号重启APP生效",
// type: "input",
// validator: '^\\d+(?:\\.\\d+)*$',
// default: CopyManga.defaultCopyPlatform,
// },
} }
/** /**

View File

@@ -3,7 +3,7 @@
"name": "拷贝漫画", "name": "拷贝漫画",
"fileName": "copy_manga.js", "fileName": "copy_manga.js",
"key": "copy_manga", "key": "copy_manga",
"version": "1.3.2" "version": "1.3.3"
}, },
{ {
"name": "Komiic", "name": "Komiic",