🦀 ClawHub
Bilibili Messager | B站私信助手
by @moroiser
Send Bilibili DMs, reply to messages, read chat history via browser automation. | 通过浏览器自动化发送 B 站私信、回复消息、读私信、看聊天记录。
📋 Tips & Best Practices
找不到编辑器
B站私信页面的编辑器可能出现在不同位置。尝试:
() => {
const selectors = [
'.content-input',
'[contenteditable="true"]',
'[class*="editor"]',
'[class*="input"]'
];
for (const sel of selectors) {
const el = document.querySelector(sel);
if (el) return sel + ' found: ' + el.className;
}
return 'no editor found';
}
找不到发送按钮
发送按钮可能没有稳定的 class 或 ref。查找包含"发送"文字的按钮:
() => {
const btns = document.querySelectorAll('button, [class*="btn"], [class*="send"]');
for (const btn of btns) {
if ((btn.textContent || '').includes('发送')) {
return 'found: ' + btn.className;
}
}
return 'send button not found';
}
页面布局变了(DOM 结构诊断)
如果脚本返回空结果或找不到元素,按以下顺序诊断:
1. 先快照:用 browser action=snapshot 获取当前页面完整 DOM
2. 找消息容器:在快照中搜索 _Msg_ 或 message
3. 找编辑器:搜索 contenteditable、input、editor
4. 找发送按钮:搜索 发送 文字或 button
5. 根据诊断结果:用实际找到的 class/name 重写选择器
诊断脚本:
() => {
return {
msgs: Array.from(document.querySelectorAll('[class*="Msg"]')).slice(0,3).map(el=>el.className),
editor: document.querySelector('[contenteditable="true"]') ? 'found' : 'not found',
btns: Array.from(document.querySelectorAll('button')).map(b=>b.textContent.trim()).filter(t=>t)
};
}
TERMINAL
clawhub install bilibili-messager