dsh-fish-soul 0.12.1 → 0.12.2

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 CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  让一个 QQ 小号背后有"同一个人":固定人格、按人记记忆、有自己的生活节奏、会主动开口;同一个"她"同时出现在 QQ、B站、抖音。
4
4
 
5
- DSH 插件(单角色 `feiyu`)。版本 **0.12.1**。
5
+ DSH 插件(单角色 `feiyu`)。版本 **0.12.2**。
6
6
 
7
7
  ## 能力
8
8
 
@@ -172,9 +172,36 @@ export class DouyinBrowser {
172
172
  }
173
173
 
174
174
  /** 推荐页上看几条(只看、不读详情),返回要细看的视频。 */
175
+ /** 抖音桌面版对导航请求把 /?recommend=1 302 回精选页;得用真实鼠标点左侧「推荐」tab 才进得了推荐流。 */
176
+ async ensureRecommend(b) {
177
+ // 先用真实读一条来判断(测试环境里 mock 会直接喂 ACTIVE_VIDEO_JS)
178
+ if (await this.activeVideo(b) !== null) return true;
179
+ const pos = await b.eval(`(function(){
180
+ const el = document.querySelector('.tab-recommend') || document.querySelector('a[href*="recommend"]');
181
+ if (!el) return null;
182
+ const r = el.getBoundingClientRect();
183
+ if (r.width < 2 || r.height < 2) return null;
184
+ return { x: r.x + r.width / 2, y: r.y + r.height / 2, w: r.width, h: r.height };
185
+ })()`).catch(() => null);
186
+ if (!pos || typeof pos.x !== 'number') return false;
187
+ const m = await b.send('Page.getLayoutMetrics', {}, b.sessionId).catch(() => null);
188
+ const vp = m?.cssVisualViewport ?? m?.cssLayoutViewport ?? {};
189
+ if (pos.x < 0 || pos.y < 0 || pos.x > (vp.clientWidth ?? 0) || pos.y > (vp.clientHeight ?? 0)) return false;
190
+ for (const type of ['mouseMoved', 'mousePressed', 'mouseReleased']) {
191
+ await b.send('Input.dispatchMouseEvent', { type, x: Math.round(pos.x), y: Math.round(pos.y), button: 'left', clickCount: type === 'mouseMoved' ? 0 : 1 }, b.sessionId);
192
+ }
193
+ await sleep(3000);
194
+ return await this.activeVideo(b) !== null;
195
+ }
196
+
175
197
  async scroll(count) {
176
198
  const b = this.host.browser;
177
199
  await b.goto(FEED_URL, { settleMs: this.settleMs });
200
+ // 被 302 弹回精选页时,用真实鼠标点进推荐流;进不去就停下来,别再空刷一轮
201
+ if (!await this.ensureRecommend(b)) {
202
+ this.log('warn', '[fish-soul] 进不了抖音推荐页(精选页抓不到 feed-active-video),这轮不刷');
203
+ return [];
204
+ }
178
205
  const picked = [];
179
206
  let prevId = '';
180
207
  for (let step = 0; step < count + 6 && picked.length < count; step++) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-fish-soul",
3
- "version": "0.12.1",
3
+ "version": "0.12.2",
4
4
  "description": "鱼 · 人格、按人记忆(可纠正、有印象、能导入旧聊天记录)、日程自走与主动开口,直连 SnowLuma 收发 QQ(群里会自己插话),B站 / 抖音小号私信与自己刷视频;按功能选模型并统计用量花费,能听会说 QQ 语音、收藏表情包、学群里的梗,可选上网查;心情影响说话、去 AI 味、每个群的设定、按聊天选模型、每晚写日记(DSH 插件,单角色 feiyu)",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",