From a320658ac8a51855d38d75b18c43107f1e69339b Mon Sep 17 00:00:00 2001 From: personal82555 Date: Tue, 13 Oct 2026 22:25:43 +0800 Subject: [PATCH] =?UTF-8?q?v1.8.0:=20=E6=96=B0=E5=A2=9E=E3=80=8C=E5=8F=91?= =?UTF-8?q?=E9=80=81=E5=86=85=E5=AE=B9=E3=80=8D=E4=B8=89=E9=80=89=E4=B8=80?= =?UTF-8?q?=EF=BC=88=E5=8F=AA=E5=8F=91=E8=AF=84=E8=AE=BA/=E5=8F=AA?= =?UTF-8?q?=E5=8F=91=E7=A7=81=E4=BF=A1=E4=B8=8D=E5=8F=91=E8=AF=84=E8=AE=BA?= =?UTF-8?q?/=E8=AF=84=E8=AE=BA+=E7=A7=81=E4=BF=A1=EF=BC=89=EF=BC=8C?= =?UTF-8?q?=E7=A7=81=E4=BF=A1=E5=AF=B9=E8=B1=A1=E6=98=8E=E7=A1=AE=E4=BB=85?= =?UTF-8?q?=E8=AF=84=E8=AE=BA=E5=8C=BA=E7=94=A8=E6=88=B7=EF=BC=9B=E5=8F=AA?= =?UTF-8?q?=E5=8F=91=E7=A7=81=E4=BF=A1=E6=A8=A1=E5=BC=8F=E4=B8=8B=E6=8C=89?= =?UTF-8?q?=E5=A2=9E=E9=87=8F=E5=88=A4=E6=96=AD=E6=98=AF=E5=90=A6=E8=AE=B0?= =?UTF-8?q?=E4=B8=BA=E5=B7=B2=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- content.js | 38 +++++++++++++++++++++++++++----------- manifest.json | 2 +- sidepanel.html | 19 ++++++++++++++----- sidepanel.js | 15 ++++++++------- 4 files changed, 50 insertions(+), 24 deletions(-) diff --git a/content.js b/content.js index 07ce1a7..3407626 100644 --- a/content.js +++ b/content.js @@ -960,25 +960,41 @@ step("[" + (task.index + 1) + "/" + task.queue.length + "] " + video.title.slice(0, 30)); const text = video.text || pickTemplate(video.title, cfg.keyword); const SRC_LABEL = { custom: "自定义", ai: "AI", tpl: "模板" }; - step("评论[" + (SRC_LABEL[video.src] || "模板") + "]:" + text.slice(0, 30) + (text.length > 30 ? "…" : "")); + // 发送内容三选一:comment=只评论 / dm=只发私信不发评论 / both=评论+私信 + const what = ["comment", "dm", "both"].indexOf(cfg.sendWhat) >= 0 ? cfg.sendWhat : "comment"; + const doComment = (what === "comment" || what === "both"); + const doDm = (what === "dm" || what === "both"); - const r = await sendOne(video, text, cfg.sendMode !== "api"); - if (r.stopped) { finish(task, false, "已手动停止"); return; } - if (r.fatal) { finish(task, false, r.fatal); return; } + if (doComment) { + step("评论[" + (SRC_LABEL[video.src] || "模板") + "]:" + text.slice(0, 30) + (text.length > 30 ? "…" : "")); - if (r.ok) { - step(r.verified ? "✅ 评论成功" : "⚠️ 已发送但未在页面确认,记为已评论", r.verified ? "ok" : "fail"); - await recordOne(task, video, text, true); + const r = await sendOne(video, text, cfg.sendMode !== "api"); + if (r.stopped) { finish(task, false, "已手动停止"); return; } + if (r.fatal) { finish(task, false, r.fatal); return; } + + if (r.ok) { + step(r.verified ? "✅ 评论成功" : "⚠️ 已发送但未在页面确认,记为已评论", r.verified ? "ok" : "fail"); + await recordOne(task, video, text, true); + } else { + step("❌ 失败:" + r.error, "fail"); + await recordOne(task, video, text, false); + } } else { - step("❌ 失败:" + r.error, "fail"); - await recordOne(task, video, text, false); + step("本条不发评论(发送内容=只发私信)"); } - // 私信(可选,评论后对本视频评论区用户发送;风控更严,间隔更长) - if (cfg.dmEnabled && !stopRequested()) { + // 私信:对本视频评论区里发过评论的人发送;风控更严,间隔更长 + let dmBefore = task.dmSent || 0; // 本视频发送前的累计数,用于算增量 + if (doDm && !stopRequested()) { await runDmStep(task, video); } + // 只发私信模式下也要记为「已处理」,否则下次会重复进同一视频 + // 注意按「本视频的增量」判断,不能用累计数(否则前面发过就会误记后面没发的) + if (!doComment && (task.dmSent || 0) > dmBefore) { + await recordOne(task, video, text, true); + } + task.index += 1; if (task.index < task.queue.length && !stopRequested()) { diff --git a/manifest.json b/manifest.json index 6b94030..834d433 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 3, "name": "B站评论助手", - "version": "1.7.1", + "version": "1.8.0", "description": "B站网页版关键词评论助手:按搜索关键词找视频,默认模拟真人(打开视频页、滚到评论区、逐字输入、点发布),也可快速API直发;支持下载当前页视频;带防重复记录、可中断执行与页面实时进度浮层。", "permissions": ["storage", "tabs", "scripting", "sidePanel", "downloads", "declarativeNetRequest"], "host_permissions": [ diff --git a/sidepanel.html b/sidepanel.html index 53f1aa8..e5c455e 100644 --- a/sidepanel.html +++ b/sidepanel.html @@ -237,11 +237,20 @@ 次(0 = 不过滤) -
- -