dsh-fish-soul 0.18.18 → 0.18.19
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/douyin-social.js +35 -5
- package/package.json +2 -2
package/README.md
CHANGED
package/lib/douyin-social.js
CHANGED
|
@@ -299,13 +299,17 @@ export const COMMENT_STATE_JS = `(() => {
|
|
|
299
299
|
};
|
|
300
300
|
})()`;
|
|
301
301
|
|
|
302
|
-
/**
|
|
302
|
+
/** 编辑页上的「选择音乐 / 添加音乐」入口(页面有多个同名节点,取最后一个——真正可点的那颗;优先取其按钮容器并避免在视口内时不必要的滚动)。 */
|
|
303
303
|
const MUSIC_ENTRY_JS = String.raw`(() => {
|
|
304
|
-
const els = [...document.querySelectorAll('div, span, button')].filter((x) => x.children.length === 0 &&
|
|
304
|
+
const els = [...document.querySelectorAll('div, span, button')].filter((x) => x.children.length === 0 && /^(选择音乐|添加音乐)$/.test((x.innerText || '').trim()));
|
|
305
305
|
const el = els[els.length - 1];
|
|
306
306
|
if (!el) return null;
|
|
307
|
-
el.
|
|
308
|
-
|
|
307
|
+
const target = el.closest('[class*="preview-button"], button') || el;
|
|
308
|
+
let r = target.getBoundingClientRect();
|
|
309
|
+
if (r.top < 0 || r.bottom > window.innerHeight || r.left < 0 || r.right > window.innerWidth) {
|
|
310
|
+
target.scrollIntoView({ block: 'center', behavior: 'instant' });
|
|
311
|
+
r = target.getBoundingClientRect();
|
|
312
|
+
}
|
|
309
313
|
return r.width && r.height ? { x: Math.round(r.left + r.width / 2), y: Math.round(r.top + r.height / 2) } : null;
|
|
310
314
|
})()`;
|
|
311
315
|
|
|
@@ -555,6 +559,8 @@ export async function ensurePageAlive(br, { timeoutMs = 3000, reload = true } =
|
|
|
555
559
|
async function clickMusicEntry(br, timing) {
|
|
556
560
|
const sel = await br.eval(MUSIC_ENTRY_JS, { timeoutMs: timing.evalTimeoutMs }).catch(() => null);
|
|
557
561
|
if (!sel) return false;
|
|
562
|
+
await br.send('Input.dispatchMouseEvent', { type: 'mouseMoved', x: sel.x, y: sel.y }, br.sessionId).catch(() => {});
|
|
563
|
+
await sleep(150);
|
|
558
564
|
await realClick(br, sel.x, sel.y);
|
|
559
565
|
await sleep(1200);
|
|
560
566
|
return true;
|
|
@@ -645,7 +651,7 @@ async function pickNoteMusic(br, music, { allowDuplicate = false, timing = PAGE_
|
|
|
645
651
|
.find(x => (x.innerText || x.textContent || '').trim() === '使用' && x.children.length <= 1);
|
|
646
652
|
if (!el) return null;
|
|
647
653
|
const r = el.getBoundingClientRect();
|
|
648
|
-
return r.width > 0 && r.height > 0 ? { x: Math.round(r.left + r.width / 2), y: Math.round(r.top + r.height / 2) } :
|
|
654
|
+
return r.width > 0 && r.height > 0 ? { x: Math.round(r.left + r.width / 2), y: Math.round(r.top + r.height / 2) } : { x: card.x, y: card.y };
|
|
649
655
|
})()`, { timeoutMs: timing.evalTimeoutMs }).catch(() => null);
|
|
650
656
|
if (domBtn) btn = domBtn;
|
|
651
657
|
}
|
|
@@ -656,6 +662,24 @@ async function pickNoteMusic(br, music, { allowDuplicate = false, timing = PAGE_
|
|
|
656
662
|
await br.send('Input.dispatchMouseEvent', { type: 'mouseMoved', x: btn.x, y: btn.y }, br.sessionId).catch(() => {});
|
|
657
663
|
await sleep(250);
|
|
658
664
|
await realClick(br, btn.x, btn.y);
|
|
665
|
+
if (btn.backendNodeId) {
|
|
666
|
+
// 真机容错:getBoxModel 偶尔返回的是内层 span 偏移坐标(甚至超出了 400px 卡片右边界),
|
|
667
|
+
// 或者窗口在后台时 mousePressed 没触发 React 合成 onClick —— 仅在抽屉仍开着时用该节点的 DOM click 补一道。
|
|
668
|
+
await sleep(250);
|
|
669
|
+
const stillOpen = await br.eval(MUSIC_OPEN_JS, { timeoutMs: timing.evalTimeoutMs }).catch(() => false);
|
|
670
|
+
if (stillOpen) {
|
|
671
|
+
const resolved = await br.send('DOM.resolveNode', { backendNodeId: btn.backendNodeId }, br.sessionId, timing.evalTimeoutMs).catch(() => null);
|
|
672
|
+
const objectId = resolved?.object?.objectId;
|
|
673
|
+
if (objectId) {
|
|
674
|
+
await br.send('Runtime.callFunctionOn', {
|
|
675
|
+
objectId,
|
|
676
|
+
functionDeclaration: `function () { if (typeof this.click === 'function') this.click(); }`,
|
|
677
|
+
returnByValue: true
|
|
678
|
+
}, br.sessionId, timing.evalTimeoutMs).catch(() => {});
|
|
679
|
+
await br.send('Runtime.releaseObject', { objectId }, br.sessionId, timing.evalTimeoutMs).catch(() => {});
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
}
|
|
659
683
|
const verified = await waitFor(() => br.eval(`(() => {
|
|
660
684
|
const want = ${JSON.stringify(music)}.replace(/\\s+/g, '');
|
|
661
685
|
const visible = el => { const r = el.getBoundingClientRect(); const s = getComputedStyle(el); return r.width > 0 && r.height > 0 && s.visibility !== 'hidden' && s.display !== 'none'; };
|
|
@@ -672,6 +696,12 @@ async function pickNoteMusic(br, music, { allowDuplicate = false, timing = PAGE_
|
|
|
672
696
|
if (text.length <= 250 && text.replace(/\\s+/g, '').includes(want)) return true;
|
|
673
697
|
}
|
|
674
698
|
}
|
|
699
|
+
const binders = [...document.querySelectorAll('[class*="music-binder"], [class*="music-text"]')].filter(visible);
|
|
700
|
+
for (const b of binders) {
|
|
701
|
+
if (b.closest('.semi-sidesheet, [class*="music-collection-container"]')) continue;
|
|
702
|
+
const text = (b.innerText || '').trim();
|
|
703
|
+
if (text.length <= 250 && text.replace(/\\s+/g, '').includes(want)) return true;
|
|
704
|
+
}
|
|
675
705
|
return false;
|
|
676
706
|
})()`, { timeoutMs: timing.evalTimeoutMs }).catch(() => false), { tries: 10, gapMs: 500, budgetMs: timing.waitBudgetMs });
|
|
677
707
|
return verified ? { ok: true } : { ok: false, error: '已点击使用,但编辑页未确认显示歌名' };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-fish-soul",
|
|
3
|
-
"version": "0.18.
|
|
4
|
-
"description": "鱼 · 人格、按人记忆(可纠正、有印象、能导入旧聊天记录)、日程自走与主动开口,直连 SnowLuma 收发 QQ(群里会自己插话),B站 / 抖音小号私信与自己刷视频;按功能选模型并统计用量花费,能听会说 QQ 语音、收藏表情包、学群里的梗,可选上网查;心情影响说话、去 AI 味、每个群的设定、按聊天选模型、每晚写日记、每周记忆存档与可选周记(DSH 插件,单角色 feiyu ,v0.18.
|
|
3
|
+
"version": "0.18.19",
|
|
4
|
+
"description": "鱼 · 人格、按人记忆(可纠正、有印象、能导入旧聊天记录)、日程自走与主动开口,直连 SnowLuma 收发 QQ(群里会自己插话),B站 / 抖音小号私信与自己刷视频;按功能选模型并统计用量花费,能听会说 QQ 语音、收藏表情包、学群里的梗,可选上网查;心情影响说话、去 AI 味、每个群的设定、按聊天选模型、每晚写日记、每周记忆存档与可选周记(DSH 插件,单角色 feiyu ,v0.18.19)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|
|
7
7
|
"files": [
|