Grok Browser Skill
Query Grok (grok.com) via Chrome browser automation and copy responses.
Prerequisites
- - Chrome with Browser Relay extension
- Use
profile=chrome (never profile=clawd)
Quick Start
CODEBLOCK0
Input Method (IMPORTANT!)
Grok uses contenteditable, not a standard textbox. Use JavaScript evaluate:
CODEBLOCK1
Then submit with Enter:
CODEBLOCK2
Complete Workflow
1. Open Grok & Attach Relay
CODEBLOCK3
2. Get Tab ID
CODEBLOCK4
Look for Grok tab, note the targetId.
3. Input Query
CODEBLOCK5
4. Submit
CODEBLOCK6
5. Wait for Response
CODEBLOCK7
6. Snapshot & Find Copy Button
CODEBLOCK8
Look for button with "Copy" in the response area (usually last message).
7. Click Copy
CODEBLOCK9
8. Read Clipboard
CODEBLOCK10
Response Detection
After submitting, response is complete when:
- - Copy button appears below the response text
- Response time indicator shows (e.g., "952ms")
- Suggested follow-up buttons appear
New Chat for New Topics
Always start fresh chats for unrelated queries to avoid context overflow:
CODEBLOCK11
Or use Cmd+J shortcut:
CODEBLOCK12
DeepSearch
To enable DeepSearch, click the button before submitting:
CODEBLOCK13
Troubleshooting
Tab Not Found
Re-run attach script:
CODEBLOCK14
Relay Not Working
Check status:
browser action=status profile=chrome
Should show
cdpReady: true.
Context Overflow
Navigate to fresh grok.com, don't continue old chats.
Multiple Windows
Close extra Chrome windows. Keep only one for reliable relay.
Copy Button Not Found
Response may still be streaming. Wait longer and snapshot again.
Example Session
CODEBLOCK16
Grok 浏览器技能
通过 Chrome 浏览器自动化查询 Grok (grok.com) 并复制回复。
前置条件
- - 安装有 Browser Relay 扩展的 Chrome 浏览器
- 使用 profile=chrome(切勿使用 profile=clawd)
快速开始
bash
1. 打开 Chrome 并访问 Grok
open -a Google Chrome https://grok.com
sleep 3
2. 附加浏览器中继
/Users/eason/clawd/scripts/attach-browser-relay.sh
3. 检查标签页
browser action=tabs profile=chrome
输入方法(重要!)
Grok 使用 contenteditable 而非标准文本框。请使用 JavaScript 评估:
javascript
// 通过 evaluate 输入查询
browser action=act profile=chrome targetId= request={
kind: evaluate,
fn: (() => { const editor = document.querySelector([contenteditable=\true\]); if(editor) { editor.focus(); editor.innerText = YOURQUERYHERE; return typed; } return not found; })()
}
然后按回车提交:
browser action=act profile=chrome targetId= request={kind:press,key:Enter}
完整工作流程
1. 打开 Grok 并附加中继
bash
open -a Google Chrome https://grok.com
sleep 3
/Users/eason/clawd/scripts/attach-browser-relay.sh
2. 获取标签页 ID
browser action=tabs profile=chrome
查找 Grok 标签页,记下 targetId。
3. 输入查询
browser action=act profile=chrome targetId= request={
kind: evaluate,
fn: (() => { const e = document.querySelector([contenteditable=\true\]); if(e) { e.focus(); e.innerText = 什么是量子计算?; return ok; } return fail; })()
}
4. 提交
browser action=act profile=chrome targetId= request={kind:press,key:Enter}
5. 等待回复
bash
sleep 10-20 # Grok 可能需要 10-30 秒
6. 快照并查找复制按钮
browser action=snapshot profile=chrome targetId=
在回复区域(通常为最后一条消息)查找带有复制的按钮。
7. 点击复制
browser action=act profile=chrome targetId= request={kind:click,ref:buttonref>}
8. 读取剪贴板
bash
pbpaste
回复检测
提交后,当以下情况出现时表示回复完成:
- - 回复文本下方出现复制按钮
- 显示回复时间指示器(例如952ms)
- 出现建议的后续问题按钮
新话题开启新对话
对于不相关的查询,始终开启全新对话以避免上下文溢出:
browser action=navigate profile=chrome targetId= targetUrl=https://grok.com
或使用 Cmd+J 快捷键:
browser action=act profile=chrome targetId= request={kind:press,key:Meta+j}
深度搜索
要启用深度搜索,在提交前点击按钮:
在快照中查找深度搜索按钮
browser action=act profile=chrome targetId=
request={kind:click,ref:}
然后正常输入并提交
故障排除
标签页未找到
重新运行附加脚本:
bash
/Users/eason/clawd/scripts/attach-browser-relay.sh
中继不工作
检查状态:
browser action=status profile=chrome
应显示 cdpReady: true。
上下文溢出
导航到全新的 grok.com,不要继续旧对话。
多个窗口
关闭多余的 Chrome 窗口。仅保留一个以确保中继可靠。
复制按钮未找到
回复可能仍在流式传输中。等待更长时间后重新快照。
示例会话
打开并附加
exec: open -a Google Chrome https://grok.com
exec: sleep 3
exec: /Users/eason/clawd/scripts/attach-browser-relay.sh
获取标签页
browser action=tabs profile=chrome
返回 targetId: ABC123...
输入查询
browser action=act profile=chrome targetId=ABC123 request={
kind:evaluate,
fn:(() => { const e = document.querySelector([contenteditable=\true\]); e.focus(); e.innerText = 简要解释量子纠缠; return ok; })()
}
提交
browser action=act profile=chrome targetId=ABC123 request={kind:press,key:Enter}
等待
exec: sleep 15
快照以查找复制按钮
browser action=snapshot profile=chrome targetId=ABC123
查找复制按钮引用,例如 e326
复制
browser action=act profile=chrome targetId=ABC123 request={kind:click,ref:e326}
读取结果
exec: pbpaste