From c9d921489afef9bc3ee04836d10a1c7ce7823e86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A7=92=E7=A0=82=E7=B3=96?= <90336521+lings03@users.noreply.github.com> Date: Sun, 2 Nov 2025 15:59:30 +0800 Subject: [PATCH] [copy_manga] Chapter comment. (#185) --- copy_manga.js | 60 +++++++++++++++++++++++++++++++++++++++++++++++++-- index.json | 2 +- 2 files changed, 59 insertions(+), 3 deletions(-) diff --git a/copy_manga.js b/copy_manga.js index c361156..b183f4d 100644 --- a/copy_manga.js +++ b/copy_manga.js @@ -4,9 +4,9 @@ class CopyManga extends ComicSource { key = "copy_manga" - version = "1.3.8" + version = "1.4.0" - minAppVersion = "1.2.1" + minAppVersion = "1.6.0" url = "https://git.nyne.dev/nyne/venera-configs/raw/branch/main/copy_manga.js" @@ -864,6 +864,62 @@ class CopyManga extends ComicSource { return "ok" } }, + loadChapterComments: async (comicId, epId, page, replyTo) => { + let url = `${this.apiUrl}/api/v3/roasts?chapter_id=${epId}&limit=20&offset=${(page - 1) * 20}`; + let res = await Network.get( + url, + this.headers, + ); + + if (res.status !== 200) { + throw `Invalid status code: ${res.status}`; + } + + let data = JSON.parse(res.body); + + let total = data.results.total; + + return { + comments: data.results.list.map(e => { + return { + userName: e.user_name, + avatar: e.user_avatar, + content: e.comment, + time: e.create_at, + replyCount: null, + id: null, + } + }), + maxPage: (total - (total % 20)) / 20 + 1, + } + }, + sendChapterComment: async (comicId, epId, content, replyTo) => { + let token = this.loadData("token"); + if (!token) { + throw "未登录" + } + let res = await Network.post( + `${this.apiUrl}/api/v3/member/roast`, + { + ...this.headers, + "Content-Type": "application/x-www-form-urlencoded;charset=utf-8", + }, + `chapter_id=${epId}&roast=${encodeURIComponent(content)}`, + ); + + if (res.status === 401) { + throw `Login expired`; + } + + if (res.status !== 200) { + if(res.status === 210) { + throw `210:评论过于频繁或评论内容过短过长`; + } + throw `Invalid status code: ${res.status}`; + } else { + return "ok" + } + }, onClickTag: (namespace, tag) => { if (namespace === "标签") { return { diff --git a/index.json b/index.json index 68e19bb..1257b84 100644 --- a/index.json +++ b/index.json @@ -3,7 +3,7 @@ "name": "拷贝漫画", "fileName": "copy_manga.js", "key": "copy_manga", - "version": "1.3.8" + "version": "1.4.0" }, { "name": "Komiic",