From 499180b6ea05b20a6ae77d1177fd7b2410d04df7 Mon Sep 17 00:00:00 2001 From: Zion <62723933+jinzong53@users.noreply.github.com> Date: Fri, 25 Jul 2025 17:06:52 +0800 Subject: [PATCH] Update comick chapter api. (#112) * add new source from comick * fix some code * fix gif load and comic list info(none-type/chapter/volume) * add some comick hidden tags * revise coding error in file * info updata time * fix no-EN error * add new function - Multi-language comic selection support - Added comic recommendations - Fixed empty chapter return bug - Resolved tag click issues - Optimized data processing * Optimize network request Remove redundant requests and prevent async deadlocks * Update comick.js * new small comic source from baihehui * Fixed some bugs and added some sorting methods * Fixed some bugs and added some sorting methods * Add a new resource from ykmh * Remove invalid request * fixed chapter api * Update index.json * Update index.json * Update comick.js --- comick.js | 42 ++++++++++++++++++++++++++++++++++++++---- index.json | 4 ++-- 2 files changed, 40 insertions(+), 6 deletions(-) diff --git a/comick.js b/comick.js index 2199993..bdd3bac 100644 --- a/comick.js +++ b/comick.js @@ -1,7 +1,7 @@ class Comick extends ComicSource { name = "comick" key = "comick" - version = "1.1.0" + version = "1.1.1" minAppVersion = "1.4.0" // update url url = "https://cdn.jsdelivr.net/gh/venera-app/venera-configs@main/comick.js" @@ -340,6 +340,23 @@ class Comick extends ComicSource { '拉脱维亚文': 'lv' } + static getRandomHeaders() { + const userAgents = [ + "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 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36", + "Mozilla/5.0 (iPhone; CPU iPhone OS 14_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Mobile/15E148 Safari/604.1", + "Mozilla/5.0 (Linux; Android 10; SM-G973F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Mobile Safari/537.36", + "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36" + ]; + + return { + "User-Agent": userAgents[Math.floor(Math.random() * userAgents.length)], + "Accept": "application/json, text/plain, */*", + "Accept-Language": "en-US,en;q=0.9", + "Connection": "keep-alive" + }; + } + transReformBookList(bookList, descriptionPrefix = "更新至:") { return bookList.map(book => ({ id: `${book.relates?.slug || 'unknown'}//${book.relates?.title || '未知标题'}`, @@ -482,12 +499,15 @@ class Comick extends ComicSource { buildId: null, loadInfo: async (id) => { + let headers = Comick.getRandomHeaders(); + + const [cId, cTitle] = id.split("//"); if (!cId) { throw "ID error: "; } - let res = await Network.get(`${this.baseUrl}/comic/${cId}`) + let res = await Network.get(`${this.baseUrl}/comic/${cId}`, { headers }); if (res.status !== 200) { throw "Invalid status code: " + res.status } @@ -518,7 +538,13 @@ class Comick extends ComicSource { const result = {}; let updateTime = ""; let i = 1; + + + for (const lang of langs) { + // 随机生成请求头 + let headers = Comick.getRandomHeaders(); + let first = langMap[lang]; if (first.vol == null && first.chap == null) { const chapters = new Map(); @@ -533,9 +559,17 @@ class Comick extends ComicSource { (first.chap != null ? `-chapter-${first.chap}` : `-volume-${first.vol}`) + - `-${lang}.json`; + `-${lang}.json?slug=${id}&` + + (first.chap != null + ? `chapter=${first.hid || 'unknown'}` + : `volume=${first.hid || 'unknown'}`) + + + (first.chap != null + ? `-chapter-${first.chap}` + : `-volume-${first.vol}`) + `-${lang}` + ; - const res = await Network.get(url); + const res = await Network.get(url, { headers }); if (res.status !== 200) { throw `Invalid status code: ${res.status}`; } diff --git a/index.json b/index.json index 71b2174..e168efc 100644 --- a/index.json +++ b/index.json @@ -78,7 +78,7 @@ "name": "comick", "fileName": "comick.js", "key": "comick", - "version": "1.1.0" + "version": "1.1.1" }, { "name": "优酷漫画", @@ -86,4 +86,4 @@ "key": "ykmh", "version": "1.0.0" } -] +] \ No newline at end of file