dsh-fish-soul 0.19.23 → 0.19.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/lib/bili-playback.js +114 -30
- package/lib/client.behavior.js +32 -16
- package/lib/client.diag.js +17 -6
- package/lib/client.douyin.js +38 -32
- package/lib/client.js +112 -90
- package/lib/client.models.js +337 -56
- package/lib/client.persona.js +69 -42
- package/lib/client.scheduled-tasks.js +12 -13
- package/lib/client.soul.js +171 -73
- package/lib/config-platforms.js +1 -2
- package/lib/panel.css +290 -32
- package/package.json +2 -2
package/README.md
CHANGED
package/lib/bili-playback.js
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
* 就得让视频在浏览器里放起来——B 站按 heartbeat 记播放进度,历史里就能看到。
|
|
7
7
|
*
|
|
8
8
|
* 三件事:
|
|
9
|
-
* 1. **起浏览器**:用专用 profile 起一个 Edge/Chrome(`--remote-debugging-port
|
|
10
|
-
* 进程 detached
|
|
9
|
+
* 1. **起浏览器**:用专用 profile 起一个 Edge/Chrome(`--remote-debugging-port=0`,端口由它自己挑),
|
|
10
|
+
* 进程 detached,插件重启也不影响它继续活着;下次按 profile 里记的端点复用(须自证归属)。
|
|
11
11
|
* 2. **注 cookie**:Cookie 从 `BiliClient.cookieHeader()` 拿(和接口用的是同一份登录态),
|
|
12
12
|
* 逐个 `Network.setCookie` 写到 `.bilibili.com`。
|
|
13
13
|
* 3. **播**:navigate 到视频页 → 等 `<video>` 出现 → 静音、按倍速播 → 播够目标秒数关标签。
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
* 失败一律只 log,不抛:留痕是加分项,不能因为它把整轮 watch() 拖死。
|
|
20
20
|
*/
|
|
21
21
|
import { spawn } from 'node:child_process';
|
|
22
|
-
import { mkdirSync } from 'node:fs';
|
|
22
|
+
import { mkdirSync, readFileSync, rmSync } from 'node:fs';
|
|
23
23
|
import { join } from 'node:path';
|
|
24
24
|
import { detectBrowsers, pickBrowser } from './browsers.js';
|
|
25
25
|
import { dshHome } from './db.js';
|
|
@@ -27,6 +27,7 @@ import { dshHome } from './db.js';
|
|
|
27
27
|
const CDP_READY_TIMEOUT_MS = 15_000;
|
|
28
28
|
const VIDEO_READY_TIMEOUT_MS = 25_000;
|
|
29
29
|
const POLL_MS = 1000;
|
|
30
|
+
const DEVTOOLS_PORT_FILE = 'DevToolsActivePort';
|
|
30
31
|
|
|
31
32
|
/** 极简 CDP 客户端:连浏览器的 webSocketDebuggerUrl,按 sessionId 收发。 */
|
|
32
33
|
export class Cdp {
|
|
@@ -132,6 +133,40 @@ function cookiePairs(header) {
|
|
|
132
133
|
return out;
|
|
133
134
|
}
|
|
134
135
|
|
|
136
|
+
/**
|
|
137
|
+
* 读本插件 profile 里浏览器自己写的调试端点(只有 `--remote-debugging-port=0` 才会写)。
|
|
138
|
+
* 文件两行:端口、`/devtools/browser/<uuid>`。读不到 ⇒ {port:0, path:''}(没起过,不是错误)。
|
|
139
|
+
*/
|
|
140
|
+
export function readDevToolsRecord(dir) {
|
|
141
|
+
try {
|
|
142
|
+
const [portLine = '', pathLine = ''] = readFileSync(join(dir, DEVTOOLS_PORT_FILE), 'utf8').split(/\r?\n/);
|
|
143
|
+
const port = Number(portLine.trim());
|
|
144
|
+
const path = pathLine.trim();
|
|
145
|
+
if (!Number.isInteger(port) || port <= 0 || port >= 65536 || !path.startsWith('/')) return { port: 0, path: '' };
|
|
146
|
+
return { port, path };
|
|
147
|
+
} catch {
|
|
148
|
+
return { port: 0, path: '' };
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* 自证归属(#258):端口答上来的端点,正好是 profile 里记录的那一个(同端口 + 同 ws 路径)。
|
|
154
|
+
* 同机别的浏览器就算占着这个端口,它的 uuid 也不会等于我们记录里的。
|
|
155
|
+
*
|
|
156
|
+
* ⚠️ 本来想用 Browser.getBrowserCommandLine 直接比 --user-data-dir,真机实测它会回
|
|
157
|
+
* 「Command line not returned because --enable-automation not set」——为它加
|
|
158
|
+
* --enable-automation 会把 navigator.webdriver 打开,反而更容易被 B站判成机器播放。
|
|
159
|
+
*/
|
|
160
|
+
export function recordMatchesEndpoint(record, info) {
|
|
161
|
+
if (!record || record.port <= 0 || !record.path) return false;
|
|
162
|
+
try {
|
|
163
|
+
const url = new URL(String(info?.webSocketDebuggerUrl ?? ''));
|
|
164
|
+
return Number(url.port) === record.port && url.pathname === record.path;
|
|
165
|
+
} catch {
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
135
170
|
export class BiliPlayback {
|
|
136
171
|
constructor({ getConfig, client, log = () => {}, homedirOverride = '', spawnImpl = spawn }) {
|
|
137
172
|
this.getConfig = getConfig;
|
|
@@ -145,11 +180,25 @@ export class BiliPlayback {
|
|
|
145
180
|
this.launching = null;
|
|
146
181
|
// 同时在播的条数:每条占自己的标签,归零才关浏览器(一轮三条可以并行)
|
|
147
182
|
this.active = 0;
|
|
183
|
+
// 等 CDP 就绪的上限;测试把它调小,免得为一条失败路径真等 15 秒
|
|
184
|
+
this.cdpReadyTimeoutMs = CDP_READY_TIMEOUT_MS;
|
|
148
185
|
}
|
|
149
186
|
|
|
187
|
+
/**
|
|
188
|
+
* 配置形状契约:**收的是已切片的 `bili` 配置**(和宿主 `BiliBrowser` 一样)。
|
|
189
|
+
*
|
|
190
|
+
* `{ browse: { playback: {...} } }` —— 不是全量 `{ bili: { browse: ... } }`。
|
|
191
|
+
* 生产入口 `lib/index.js` 给 `BiliBrowser` 和本类的是同一个 `biliCfg`,
|
|
192
|
+
* 所以两者必须同形;`BiliBrowser.cfg()` 读 `.browse`,这里也必须读 `.browse`。
|
|
193
|
+
*
|
|
194
|
+
* ⚠️ 别再写成「两种形状都吃」(`(root.bili ?? root).browse`):
|
|
195
|
+
* 那样会把「传错层级」这件事藏起来 —— 而传错的后果是**静默回退默认值**
|
|
196
|
+
* (#258 的 P0:`rate` / `maxMinutes` / `port` 全变默认且不报错)。
|
|
197
|
+
* 现在形状错了就由 `test/config-shape-contract.mjs` 当场红。
|
|
198
|
+
*/
|
|
150
199
|
cfg() {
|
|
151
|
-
const
|
|
152
|
-
const browse =
|
|
200
|
+
const sliced = this.getConfig?.() ?? {};
|
|
201
|
+
const browse = sliced.browse ?? {};
|
|
153
202
|
return browse.playback ?? {};
|
|
154
203
|
}
|
|
155
204
|
|
|
@@ -177,30 +226,74 @@ export class BiliPlayback {
|
|
|
177
226
|
return res.json();
|
|
178
227
|
}
|
|
179
228
|
|
|
180
|
-
/**
|
|
181
|
-
async
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
229
|
+
/** 连上 CDP 端点,返回带断连清理与超时的客户端。 */
|
|
230
|
+
async openCdp(wsUrl) {
|
|
231
|
+
const ws = new WebSocket(wsUrl);
|
|
232
|
+
await new Promise((resolve, reject) => {
|
|
233
|
+
ws.addEventListener('open', resolve, { once: true });
|
|
234
|
+
ws.addEventListener('error', () => {
|
|
235
|
+
try { ws.close(); } catch { /* 已经关了 */ }
|
|
236
|
+
reject(new Error('CDP 连接失败'));
|
|
237
|
+
}, { once: true });
|
|
238
|
+
});
|
|
239
|
+
return new Cdp(ws);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* 找到(必要时起一个)浏览器;返回 webSocketDebuggerUrl。
|
|
244
|
+
*
|
|
245
|
+
* 🔴 端口上有 CDP 应答 ≠ 那是我们的浏览器(#258)。同机任何程序都可能占着某个调试端口,
|
|
246
|
+
* 直接复用就是把 B站 cookie 注进一个不相干的 profile,还在人家窗口里放片子。
|
|
247
|
+
* ⇒ 一律 `--remote-debugging-port=0` 让浏览器自己挑,端点由它写进 profile 里的
|
|
248
|
+
* DevToolsActivePort;只有「端口 + ws 路径(uuid)都对得上这份记录」才复用。
|
|
249
|
+
* ⇒ 配置里也因此不再接受固定端口:固定端口既没法自证归属,还得跟别人抢。
|
|
250
|
+
*
|
|
251
|
+
* ⚠️ 单实例假设:同一个 userDataDir 只能有一个浏览器(Chrome 自己会锁 profile)。
|
|
252
|
+
* 多个进程共用同一 profile 时,后收尾的那个会关掉前一个正在用的浏览器。
|
|
253
|
+
*/
|
|
254
|
+
async ensureBrowser() {
|
|
255
|
+
// 有人正在起浏览器就直接等它:探端口前先看这一眼,免得第二个调用方在
|
|
256
|
+
// 「记录还没写出来」的窗口里另起一个(同 profile 会被 Chrome 锁住、白失败一次)。
|
|
257
|
+
if (this.launching !== null) return this.launching;
|
|
258
|
+
const dir = this.userDataDir();
|
|
259
|
+
const record = readDevToolsRecord(dir);
|
|
260
|
+
if (record.port > 0) {
|
|
261
|
+
try {
|
|
262
|
+
const info = await this.cdpVersion(record.port);
|
|
263
|
+
if (recordMatchesEndpoint(record, info)) return info.webSocketDebuggerUrl;
|
|
264
|
+
this.log('warn', `[fish-soul] ${record.port} 端口上的实例对不上本插件 profile 的记录(不是本插件起的),不复用`);
|
|
265
|
+
} catch { /* 那个端口上没东西,往下起自己的 */ }
|
|
266
|
+
}
|
|
186
267
|
if (this.launching !== null) return this.launching;
|
|
187
268
|
this.launching = (async () => {
|
|
188
269
|
const exe = await this.resolveBrowser();
|
|
189
|
-
const dir = this.userDataDir();
|
|
190
270
|
mkdirSync(dir, { recursive: true });
|
|
191
|
-
|
|
192
|
-
|
|
271
|
+
// 旧的端点记录会骗到下面的轮询 ⇒ 起之前先清掉
|
|
272
|
+
rmSync(join(dir, DEVTOOLS_PORT_FILE), { force: true });
|
|
273
|
+
const child = this.spawn(exe, playbackBrowserArgs(0, dir), { detached: true, stdio: 'ignore', windowsHide: true });
|
|
193
274
|
child.unref();
|
|
194
|
-
|
|
195
|
-
|
|
275
|
+
// 子进程的 exit 只是**线索**,不能当判决:Edge 158 把「拉起真正的浏览器」交给常驻
|
|
276
|
+
// watchdog,我们 spawn 的那个启动器 ~110ms 就以 code=0 退出,而真端口要 ~800ms 才应答
|
|
277
|
+
// (抖音那条路 2026-11-22 已为同一件事踩过一次,见 test/browser-launch-early-exit.mjs)。
|
|
278
|
+
// ⇒ 先探端口,能自证就用;只有**等到超时**才把 exit 当根因报出来。
|
|
279
|
+
let exited = null;
|
|
280
|
+
child.once?.('exit', (code, signal) => { exited = { code, signal }; });
|
|
281
|
+
this.log('info', `[fish-soul] 起了播放用浏览器:${exe}(端口 自动)`);
|
|
282
|
+
const deadline = Date.now() + this.cdpReadyTimeoutMs;
|
|
196
283
|
while (Date.now() < deadline) {
|
|
197
284
|
await sleep(500);
|
|
285
|
+
const now = readDevToolsRecord(dir);
|
|
286
|
+
if (now.port <= 0) continue;
|
|
198
287
|
try {
|
|
199
|
-
const info = await this.cdpVersion(port);
|
|
200
|
-
|
|
288
|
+
const info = await this.cdpVersion(now.port);
|
|
289
|
+
// 我们那个可能已经死了、端口被抢走 ⇒ 这里同样按记录比一次
|
|
290
|
+
if (recordMatchesEndpoint(now, info)) return info.webSocketDebuggerUrl;
|
|
201
291
|
} catch { /* 还没起来 */ }
|
|
202
292
|
}
|
|
203
|
-
|
|
293
|
+
if (exited !== null) {
|
|
294
|
+
throw new Error(`播放用浏览器启动后立刻退出(code ${exited.code ?? exited.signal}),${this.cdpReadyTimeoutMs / 1000}s 内也没等到 CDP 端口 —— 多半是 profile 正被另一个浏览器占用:${dir}。旧版本(≤0.19.23)固定用 CDP 端口 9222,那时候留下的浏览器如果还在跑,先把它关掉。`);
|
|
295
|
+
}
|
|
296
|
+
throw new Error(`浏览器 ${this.cdpReadyTimeoutMs / 1000}s 内没开 CDP 端口`);
|
|
204
297
|
})();
|
|
205
298
|
try {
|
|
206
299
|
return await this.launching;
|
|
@@ -236,7 +329,6 @@ export class BiliPlayback {
|
|
|
236
329
|
const maxSeconds = Math.max(10, Number(cfg.maxMinutes ?? 60) * 60);
|
|
237
330
|
const fromDuration = Number(duration) > 0 ? Number(duration) / speed : Number(cfg.seconds ?? 30);
|
|
238
331
|
const seconds = Math.round(Math.min(maxSeconds, Math.max(10, fromDuration || 30)));
|
|
239
|
-
const port = Number(cfg.port ?? 9222);
|
|
240
332
|
const state = { aborted: false, targetId: '', sessionId: '', cdp: null, played: 0, closed: false };
|
|
241
333
|
|
|
242
334
|
const closeTarget = async () => {
|
|
@@ -256,16 +348,8 @@ export class BiliPlayback {
|
|
|
256
348
|
const done = (async () => {
|
|
257
349
|
this.active += 1;
|
|
258
350
|
try {
|
|
259
|
-
const wsUrl = await this.ensureBrowser(
|
|
260
|
-
const
|
|
261
|
-
await new Promise((resolve, reject) => {
|
|
262
|
-
ws.addEventListener('open', resolve, { once: true });
|
|
263
|
-
ws.addEventListener('error', () => {
|
|
264
|
-
try { ws.close(); } catch { /* 已经关了 */ }
|
|
265
|
-
reject(new Error('CDP 连接失败'));
|
|
266
|
-
}, { once: true });
|
|
267
|
-
});
|
|
268
|
-
const cdp = new Cdp(ws);
|
|
351
|
+
const wsUrl = await this.ensureBrowser();
|
|
352
|
+
const cdp = await this.openCdp(wsUrl);
|
|
269
353
|
state.cdp = cdp;
|
|
270
354
|
// 每条播放开自己的标签:以前是抢同一张 about:blank,两条并行时
|
|
271
355
|
// 谁先收尾谁把它关掉,另一条的 session 就报 -32001。
|
package/lib/client.behavior.js
CHANGED
|
@@ -148,23 +148,39 @@ window.__ModuleLoader__.load({
|
|
|
148
148
|
if (r?.ok) { notify("写好了"); load(); } else notify(r?.error ?? "没写成");
|
|
149
149
|
}
|
|
150
150
|
const topics = d.topics?.items ?? [];
|
|
151
|
+
const entries = d.entries ?? [];
|
|
151
152
|
const now = Date.now();
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
:
|
|
166
|
-
h("
|
|
167
|
-
|
|
153
|
+
const splitEntry = (text) => {
|
|
154
|
+
const raw = String(text ?? "");
|
|
155
|
+
const m = /^(\d{4}-\d{2}-\d{2}) 的日记:([\s\S]*)$/.exec(raw);
|
|
156
|
+
return m ? { date: m[1], body: m[2] } : { date: null, body: raw };
|
|
157
|
+
};
|
|
158
|
+
return h(react.Fragment, null,
|
|
159
|
+
Group({ title: "每晚记录", aside: Button({ disabled: busy, onClick: writeNow }, busy ? "在写…" : "现在写一篇") },
|
|
160
|
+
Row({ title: "每晚写日记", desc: "记成她自己的私密记忆(群里不会想起),顺便想想明天想跟谁聊什么" },
|
|
161
|
+
h(Switch, { label: "每晚写日记", checked: c.enabled, onChange: (v) => save({ diary: { enabled: v } }) })),
|
|
162
|
+
c.enabled ? Row({ title: "几点写" }, h(NumField, { ui, value: c.hour, min: 18, max: 23, step: 1, label: "几点写", onSave: (n) => save({ diary: { hour: n } }) }), Muted("点以后")) : null,
|
|
163
|
+
Row({ title: "发到 QQ 空间", desc: "默认关;SnowLuma 不支持的话会在动态里记一条失败" },
|
|
164
|
+
h(Switch, { label: "发到 QQ 空间", checked: c.qzone, onChange: (v) => save({ diary: { qzone: v } }) }))),
|
|
165
|
+
topics.length === 0 ? null : Group({ title: "明天想聊的话题", aside: Tag(String(topics.length), "outline") },
|
|
166
|
+
h("div", { className: "fs-list" }, topics.map((x) => h("div", { className: "fs-read-item", key: `${x.who ?? ""}:${x.topic}` },
|
|
167
|
+
h("div", { className: "fs-read-head" },
|
|
168
|
+
Tag("想聊", "info"),
|
|
169
|
+
h("span", { className: "fs-read-text" }, `${x.who ? `${x.who}:` : ""}${x.topic}`),
|
|
170
|
+
h("span", { className: "fs-read-actions" }, IconButton("close", "删除", async () => {
|
|
171
|
+
const r = await api("POST", "/diary/topic-remove", { who: x.who ?? "", topic: x.topic });
|
|
172
|
+
if (r?.ok) { notify("删掉了"); load(); } else notify(r?.error ?? "删除失败");
|
|
173
|
+
}))))))),
|
|
174
|
+
Group({ title: "日记本", aside: entries.length ? Tag(String(entries.length), "outline") : null },
|
|
175
|
+
entries.length === 0 ? Empty("还没写过日记")
|
|
176
|
+
: entries.map((e) => {
|
|
177
|
+
const parsed = splitEntry(e.content);
|
|
178
|
+
return h("div", { className: "fs-diary-card", key: e.id },
|
|
179
|
+
h("div", { className: "fs-diary-head" },
|
|
180
|
+
h("span", { className: "fs-diary-date" }, parsed.date ?? "随笔"),
|
|
181
|
+
h("span", { className: "fs-diary-time" }, relTime(e.at, now))),
|
|
182
|
+
h("div", { className: "fs-diary-body" }, parsed.body));
|
|
183
|
+
})));
|
|
168
184
|
}
|
|
169
185
|
|
|
170
186
|
function BehaviorPane({ api, notify, relTime, ui, section = "habits" }) {
|
package/lib/client.diag.js
CHANGED
|
@@ -43,6 +43,7 @@ window.__ModuleLoader__.load({
|
|
|
43
43
|
function DiagPane({ api, notify, ui }) {
|
|
44
44
|
const { h, Group, Tag, Button, useConfirm = () => [async () => true, null] } = ui;
|
|
45
45
|
const [raw, setRaw] = react.useState(false);
|
|
46
|
+
const [level, setLevel] = react.useState("all");
|
|
46
47
|
const [data, load, err] = usePoll(api, "/diag-log", 15000);
|
|
47
48
|
const [confirm, confirmNode] = useConfirm();
|
|
48
49
|
if (!data) {
|
|
@@ -51,6 +52,9 @@ window.__ModuleLoader__.load({
|
|
|
51
52
|
}
|
|
52
53
|
|
|
53
54
|
const entries = data.entries ?? [];
|
|
55
|
+
const warnCount = entries.filter((e) => e.level === "warn").length;
|
|
56
|
+
const errCount = entries.filter((e) => e.level === "error").length;
|
|
57
|
+
const shownEntries = level === "all" ? entries : entries.filter((e) => e.level === level);
|
|
54
58
|
const pad = (n) => String(n).padStart(2, "0");
|
|
55
59
|
const fmtTime = (ms) => {
|
|
56
60
|
const d = new Date(ms);
|
|
@@ -95,12 +99,19 @@ window.__ModuleLoader__.load({
|
|
|
95
99
|
? h("div", { className: "fs-empty" }, "还没有记录。重启宿主后回来就能看到启动过程。")
|
|
96
100
|
: raw
|
|
97
101
|
? h("pre", { className: "fs-report fs-diag-raw" }, JSON.stringify(entries, null, 2))
|
|
98
|
-
: h(
|
|
99
|
-
|
|
100
|
-
h("
|
|
101
|
-
|
|
102
|
-
h("
|
|
103
|
-
|
|
102
|
+
: h(react.Fragment, null,
|
|
103
|
+
h("div", { className: "fs-pills fs-filter-bar", role: "group", "aria-label": "日志级别筛选" },
|
|
104
|
+
h("button", { type: "button", className: "fs-pill", "aria-pressed": level === "all", onClick: () => setLevel("all") }, `全部 ${entries.length}`),
|
|
105
|
+
h("button", { type: "button", className: "fs-pill", "aria-pressed": level === "warn", onClick: () => setLevel("warn") }, `警告 ${warnCount}`),
|
|
106
|
+
h("button", { type: "button", className: "fs-pill", "aria-pressed": level === "error", onClick: () => setLevel("error") }, `错误 ${errCount}`)),
|
|
107
|
+
shownEntries.length === 0
|
|
108
|
+
? h("div", { className: "fs-empty" }, "这个级别下没有日志。")
|
|
109
|
+
: h("div", { className: "fs-diag-list" },
|
|
110
|
+
shownEntries.map((e, i) => h("div", { key: `${e.at}-${e.key ?? i}`, className: "fs-diag-row", "data-level": e.level },
|
|
111
|
+
h("span", { className: "fs-diag-time" }, fmtTime(e.at)),
|
|
112
|
+
e.level === "error" ? Tag("错误", "danger") : e.level === "warn" ? Tag("警告", "warning") : null,
|
|
113
|
+
h("span", { className: "fs-diag-label", "data-level": e.level }, e.label),
|
|
114
|
+
h("span", { className: "fs-diag-detail" }, describe(e)))))),
|
|
104
115
|
confirmNode);
|
|
105
116
|
}
|
|
106
117
|
|
package/lib/client.douyin.js
CHANGED
|
@@ -225,31 +225,31 @@ window.__ModuleLoader__.load({
|
|
|
225
225
|
`你填的 ${d.channel.identityState.masterUidMismatch.filled} 跟已学到的抖音身份对不上,多半填成了账号短号。留空就行;已学到的身份:${d.channel.identityState.masterUidMismatch.learned.join(" / ")}`,
|
|
226
226
|
undefined, true))
|
|
227
227
|
: null,
|
|
228
|
-
(candidates ?? []).length === 0 ? null : Group({ title: "待确认的抖音身份" },
|
|
229
|
-
Muted("请核对 uid 是不是你自己,确认后点「是我」。"),
|
|
230
|
-
...(candidates ?? []).map((c) => Row({ key: c.name, title: `${c.name} → QQ ${c.qq}`,
|
|
231
|
-
meta: `抖音 uid ${c.uid}${c.at ? ` · ${new Date(c.at).toLocaleString()}` : ""}` },
|
|
232
|
-
Button({ variant: "primary", disabled: busy, onClick: async () => {
|
|
233
|
-
setBusy(true);
|
|
234
|
-
try {
|
|
235
|
-
const r = await api("POST", "/douyin/uin-confirm", { name: c.name });
|
|
236
|
-
if (r?.ok) { notify(`已确认:${c.name}`); await loadCandidates(); refresh(); }
|
|
237
|
-
else notify(r?.error ?? "没确认成");
|
|
238
|
-
} finally { setBusy(false); }
|
|
239
|
-
} }, "是我"),
|
|
240
|
-
Button({ variant: "outline", disabled: busy, onClick: async () => {
|
|
241
|
-
setBusy(true);
|
|
242
|
-
try {
|
|
243
|
-
const r = await api("POST", "/douyin/uin-dismiss", { name: c.name });
|
|
244
|
-
if (r?.ok) { notify(`已忽略:${c.name}`); await loadCandidates(); refresh(); }
|
|
245
|
-
else notify(r?.error ?? "操作失败");
|
|
246
|
-
} finally { setBusy(false); }
|
|
247
|
-
} }, "不是我")))),
|
|
248
228
|
Row({ title: "回所有能私信她的人", desc: d.replyAll ? "建议在抖音隐私设置里把「谁可以私信我」设为互关好友" : null },
|
|
249
229
|
sw("回所有能私信她的人", d.replyAll === true, (v) => save({ top: { replyAll: v } }))),
|
|
250
230
|
Row({ title: "超过多久的消息只记不回", desc: "断线补拉或重启后积压的老消息,超过这个时间就只记进记忆、不回复" },
|
|
251
231
|
Num({ min: 1, max: 1440, value: form.replyWindowMinutes, "aria-label": "分钟", onChange: (e) => patch({ replyWindowMinutes: e.target.value }), onBlur: () => save({ top: { replyWindowMinutes: form.replyWindowMinutes === "" ? 120 : Number(form.replyWindowMinutes) } }) }), Muted("分钟")),
|
|
252
232
|
d.replyAll ? null : Row({ title: "白名单", stack: true }, Area({ ...bind("allowList"), "aria-label": "白名单", placeholder: "对方的抖音数字 uid,每行一个;昵称不参与放行" }))),
|
|
233
|
+
(candidates ?? []).length === 0 ? null : Group({ title: "待确认的抖音身份" },
|
|
234
|
+
Muted("请核对 uid 是不是你自己,确认后点「是我」。"),
|
|
235
|
+
...(candidates ?? []).map((c) => Row({ key: c.name, title: `${c.name} → QQ ${c.qq}`,
|
|
236
|
+
meta: `抖音 uid ${c.uid}${c.at ? ` · ${new Date(c.at).toLocaleString()}` : ""}` },
|
|
237
|
+
Button({ variant: "primary", disabled: busy, onClick: async () => {
|
|
238
|
+
setBusy(true);
|
|
239
|
+
try {
|
|
240
|
+
const r = await api("POST", "/douyin/uin-confirm", { name: c.name });
|
|
241
|
+
if (r?.ok) { notify(`已确认:${c.name}`); await loadCandidates(); refresh(); }
|
|
242
|
+
else notify(r?.error ?? "没确认成");
|
|
243
|
+
} finally { setBusy(false); }
|
|
244
|
+
} }, "是我"),
|
|
245
|
+
Button({ variant: "outline", disabled: busy, onClick: async () => {
|
|
246
|
+
setBusy(true);
|
|
247
|
+
try {
|
|
248
|
+
const r = await api("POST", "/douyin/uin-dismiss", { name: c.name });
|
|
249
|
+
if (r?.ok) { notify(`已忽略:${c.name}`); await loadCandidates(); refresh(); }
|
|
250
|
+
else notify(r?.error ?? "操作失败");
|
|
251
|
+
} finally { setBusy(false); }
|
|
252
|
+
} }, "不是我")))),
|
|
253
253
|
Group({ title: "群聊" },
|
|
254
254
|
Row({ title: "群里被叫到时回", desc: "群聊按说话的人分开认,不会当成一个人;没人 @ 她或叫她名字时只看不说" },
|
|
255
255
|
sw("群里被叫到时回", d.groupReply === true, (v) => save({ top: { groupReply: v } }))),
|
|
@@ -272,9 +272,7 @@ window.__ModuleLoader__.load({
|
|
|
272
272
|
browseOn ? Row({ title: "刷到有意思的发给你", desc: br.shareInDm !== false ? "带链接和感受发到你的抖音私信,没连上就发 QQ;一天最多 2 条" : "带链接和感受发到你的 QQ 私聊;一天最多 2 条" }, sw("刷到有意思的发给你", br.share !== false, (v) => save({ browse: { share: v } }))) : null,
|
|
273
273
|
browseOn && br.share !== false ? Row({ title: "在抖音私信里分享", desc: "要填「主人的名字」、开自动回复" }, sw("在抖音私信里分享", br.shareInDm !== false, (v) => save({ browse: { shareInDm: v } }))) : null,
|
|
274
274
|
browseOn && br.share !== false && br.shareInDm !== false ? Row({ title: "发原生视频卡片", desc: "在抖音私信里发点开就播的原生卡片;需专用浏览器开着,且按收件人身份锁定" }, sw("发原生视频卡片", d.shareCard === true, (v) => save({ top: { shareCard: v } }))) : null),
|
|
275
|
-
Group({ title: "
|
|
276
|
-
post.enabled ? Tag(`今天发了 ${so.post?.todayCount ?? 0} / ${post.perDay ?? 1}`, "outline") : null,
|
|
277
|
-
video.enabled ? Tag(`今天视频 ${so.video?.todayCount ?? 0} / ${video.perDay ?? 1}`, "outline") : null) : null },
|
|
275
|
+
Group({ title: "图文发布", aside: post.enabled ? Tag(`今天发了 ${so.post?.todayCount ?? 0} / ${post.perDay ?? 1}`, "outline") : null },
|
|
278
276
|
Row({ title: "自己发图文", desc: "把想说的话做成文字卡片,在创作者中心发图文;创作者中心可能要单独登录一次" },
|
|
279
277
|
post.enabled ? Button({ disabled: busy || so.post?.running === true || so.video?.running === true || Boolean(so.postPending) || d.enabled !== true || !running, onClick: async () => {
|
|
280
278
|
if (await confirm({ title: "现在发一条图文?", description: "将在抖音创作者中心公开发布一条图文动态。", confirmLabel: "发布" })) await act("/douyin/post-now", { text: noteText.trim() }, "发出去了", "没发成");
|
|
@@ -282,6 +280,10 @@ window.__ModuleLoader__.load({
|
|
|
282
280
|
sw("自己发图文", post.enabled === true, (v) => save({ post: { enabled: v } }))),
|
|
283
281
|
post.enabled ? Row({ title: "指定内容", desc: "留空则按她此刻的心情随机写一条" }, Input({ value: noteText, onChange: (e) => setNoteText(e.target.value), placeholder: "想发什么就写在这里", "aria-label": "图文指定内容" })) : null,
|
|
284
282
|
post.enabled ? Row({ title: "每天最多" }, Num({ min: 0, max: 5, "aria-label": "每天最多几条", ...bind("postPerDay") }), Muted("条")) : null,
|
|
283
|
+
so.postPending && so.postPending.kind !== "video" ? Row({ title: "图文结果待核实", meta: so.postPending.text || "先到创作者中心核实,不会自动重发" },
|
|
284
|
+
Button({ disabled: busy || so.postPending.status !== "unknown", onClick: () => act("/douyin/post-resolve", { jobId: so.postPending.id, outcome: "not_published" }, "已记录为未发布", "记录失败") }, "已核实未发布"),
|
|
285
|
+
Button({ disabled: busy || so.postPending.status !== "unknown", onClick: () => act("/douyin/post-resolve", { jobId: so.postPending.id, outcome: "published" }, "已记录为已发布", "记录失败") }, "已核实已发布")) : null),
|
|
286
|
+
Group({ title: "AI 视频生成", aside: video.enabled ? Tag(`今天视频 ${so.video?.todayCount ?? 0} / ${video.perDay ?? 1}`, "outline") : null },
|
|
285
287
|
// 视频:生成要调付费接口(按条计费)—— 开关旁边必须写清楚这是花钱的操作,点击前也要二次确认。
|
|
286
288
|
Row({ title: "自己发视频", desc: "生成视频要调用付费接口(按条计费),每发一条都真花钱;创作者中心也要先登录过" },
|
|
287
289
|
video.enabled ? Button({ variant: "ghost", disabled: busy || so.video?.running === true || so.post?.running === true || Boolean(so.postPending) || d.enabled !== true || !running, onClick: async () => {
|
|
@@ -304,9 +306,10 @@ window.__ModuleLoader__.load({
|
|
|
304
306
|
Select({ value: form.videoResolution, "aria-label": "分辨率", onChange: (e) => { const v = e.target.value; patch({ videoResolution: v }); save({ video: { resolution: v } }); } },
|
|
305
307
|
...VIDEO_RESOLUTIONS.map((o) => h("option", { key: o.value, value: o.value }, o.label)))) : null,
|
|
306
308
|
video.enabled ? Row({ title: "每天最多" }, Num({ min: 0, max: 5, "aria-label": "每天最多几条视频", ...bind("videoPerDay") }), Muted("条")) : null,
|
|
307
|
-
so.postPending
|
|
309
|
+
so.postPending && so.postPending.kind === "video" ? Row({ title: "视频结果待核实", meta: so.postPending.text || "先到创作者中心核实,不会自动重发" },
|
|
308
310
|
Button({ disabled: busy || so.postPending.status !== "unknown", onClick: () => act("/douyin/post-resolve", { jobId: so.postPending.id, outcome: "not_published" }, "已记录为未发布", "记录失败") }, "已核实未发布"),
|
|
309
|
-
Button({ disabled: busy || so.postPending.status !== "unknown", onClick: () => act("/douyin/post-resolve", { jobId: so.postPending.id, outcome: "published" }, "已记录为已发布", "记录失败") }, "已核实已发布")) : null,
|
|
311
|
+
Button({ disabled: busy || so.postPending.status !== "unknown", onClick: () => act("/douyin/post-resolve", { jobId: so.postPending.id, outcome: "published" }, "已记录为已发布", "记录失败") }, "已核实已发布")) : null),
|
|
312
|
+
Group({ title: "评论互动" },
|
|
310
313
|
Row({ title: "回评论", desc: "每 20 分钟看看最近 3 个作品的评论区;抖音可能要短信验证,碰到会停下来提醒你" },
|
|
311
314
|
cm.enabled ? Button({ disabled: busy || d.enabled !== true || !running, onClick: () => act("/douyin/comments-now", {}, "看完了", "没看成") }, "现在看一眼") : null,
|
|
312
315
|
sw("回评论", cm.enabled === true, (v) => save({ comments: { enabled: v } }))),
|
|
@@ -315,14 +318,17 @@ window.__ModuleLoader__.load({
|
|
|
315
318
|
sw("允许发表情", cm.emoji === true, (v) => save({ comments: { emoji: v } }))) : null,
|
|
316
319
|
so.blockedUntil ? Row({ title: "等验证" }, State("error", `抖音要验证,${Math.max(1, Math.ceil((so.blockedUntil - Date.now()) / 3600000))} 小时内先不试;去浏览器里验证一下`, undefined, true)) : null,
|
|
317
320
|
so.lastError ? Row({ title: "上次出错" }, State("error", so.lastError)) : null,
|
|
318
|
-
socialLog.length === 0 ? null : h("div", { className: "fs-list" }, socialLog.map((x) =>
|
|
321
|
+
socialLog.length === 0 ? null : h("div", { className: "fs-list" }, socialLog.map((x) => h("div", { className: "fs-read-item", key: x.key },
|
|
322
|
+
h("div", { className: "fs-read-head" }, x.tag, h("span", { className: "fs-read-text" }, x.text)),
|
|
323
|
+
h("div", { className: "fs-read-foot" }, h("span", null, relTime(x.at, Date.now()))))))),
|
|
319
324
|
recent.length === 0 ? null : Group({ title: "最近看过" },
|
|
320
|
-
h("div", { className: "fs-list" }, recent.map((v) =>
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
325
|
+
h("div", { className: "fs-list" }, recent.map((v) => h("div", { className: "fs-read-item", key: v.id },
|
|
326
|
+
h("div", { className: "fs-read-head" },
|
|
327
|
+
Tag(v.liked ? "赞" : v.skipped ? "划走" : "推荐", v.liked ? "danger" : undefined),
|
|
328
|
+
h("span", { className: "fs-read-text" }, `${v.title || "没写文案"}${v.impression ? ` · ${v.impression}` : ""}`)),
|
|
329
|
+
h("div", { className: "fs-read-foot" },
|
|
330
|
+
h("a", { href: `https://www.douyin.com/video/${v.id}`, target: "_blank", rel: "noreferrer" }, v.author || "打开"),
|
|
331
|
+
h("span", null, relTime(v.seenAt, Date.now()))))))),
|
|
326
332
|
Group({ title: "页面自检" },
|
|
327
333
|
Row({ title: "能否认出私信页" },
|
|
328
334
|
ch.canary ? State(ch.canary.ok ? "done" : "error", relTime(ch.canary.at, Date.now()), ch.canary.ok ? (ch.canary.recovered?.ok === true ? "上次没通过,刷新后好了" : "上次通过") : "上次没通过") : null,
|