grok-browser

TotalClaw 作者 totalclaw

通过浏览器自动化查询 Grok AI。当您需要询问 Grok 问题、获得 AI 响应或使用 Grok 的 DeepSearch/Think 功能时使用。复制响应文本而不是使用屏幕截图。

安装 / 下载方式

TotalClaw CLI推荐
totalclaw install totalclaw:totalclaw~easonc13-grok-browser
cURL直接下载,无需登录
curl -fsSL https://skills.taituai.com/api/skills/totalclaw%3Atotalclaw~easonc13-grok-browser/file -o easonc13-grok-browser.md
# 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

```bash
# 1. Open Chrome with Grok
open -a "Google Chrome" "https://grok.com"
sleep 3

# 2. Attach browser relay
/Users/eason/clawd/scripts/attach-browser-relay.sh

# 3. Check tabs
browser action=tabs profile=chrome
```

## Input Method (IMPORTANT!)

Grok uses **contenteditable**, not a standard textbox. Use JavaScript evaluate:

```javascript
// Type query via evaluate
browser action=act profile=chrome targetId=<id> request={
  "kind": "evaluate",
  "fn": "(() => { const editor = document.querySelector('[contenteditable=\"true\"]'); if(editor) { editor.focus(); editor.innerText = 'YOUR_QUERY_HERE'; return 'typed'; } return 'not found'; })()"
}
```

Then submit with Enter:
```
browser action=act profile=chrome targetId=<id> request={"kind":"press","key":"Enter"}
```

## Complete Workflow

### 1. Open Grok & Attach Relay

```bash
open -a "Google Chrome" "https://grok.com"
sleep 3
/Users/eason/clawd/scripts/attach-browser-relay.sh
```

### 2. Get Tab ID

```
browser action=tabs profile=chrome
```

Look for Grok tab, note the `targetId`.

### 3. Input Query

```
browser action=act profile=chrome targetId=<id> request={
  "kind": "evaluate",
  "fn": "(() => { const e = document.querySelector('[contenteditable=\"true\"]'); if(e) { e.focus(); e.innerText = 'What is quantum computing?'; return 'ok'; } return 'fail'; })()"
}
```

### 4. Submit

```
browser action=act profile=chrome targetId=<id> request={"kind":"press","key":"Enter"}
```

### 5. Wait for Response

```bash
sleep 10-20  # Grok can take 10-30 seconds
```

### 6. Snapshot & Find Copy Button

```
browser action=snapshot profile=chrome targetId=<id>
```

Look for button with "Copy" in the response area (usually last message).

### 7. Click Copy

```
browser action=act profile=chrome targetId=<id> request={"kind":"click","ref":"<copy_button_ref>"}
```

### 8. Read Clipboard

```bash
pbpaste
```

## 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:

```
browser action=navigate profile=chrome targetId=<id> targetUrl="https://grok.com"
```

Or use Cmd+J shortcut:
```
browser action=act profile=chrome targetId=<id> request={"kind":"press","key":"Meta+j"}
```

## DeepSearch

To enable DeepSearch, click the button before submitting:
```
# In snapshot, find DeepSearch button
browser action=act profile=chrome targetId=<id> request={"kind":"click","ref":"<deepsearch_ref>"}
# Then type and submit as normal
```

## Troubleshooting

### Tab Not Found
Re-run attach script:
```bash
/Users/eason/clawd/scripts/attach-browser-relay.sh
```

### 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

```
# Open and attach
exec: open -a "Google Chrome" "https://grok.com"
exec: sleep 3
exec: /Users/eason/clawd/scripts/attach-browser-relay.sh

# Get tab
browser action=tabs profile=chrome
# Returns targetId: ABC123...

# Type query
browser action=act profile=chrome targetId=ABC123 request={
  "kind":"evaluate",
  "fn":"(() => { const e = document.querySelector('[contenteditable=\"true\"]'); e.focus(); e.innerText = 'Explain quantum entanglement briefly'; return 'ok'; })()"
}

# Submit
browser action=act profile=chrome targetId=ABC123 request={"kind":"press","key":"Enter"}

# Wait
exec: sleep 15

# Snapshot to find Copy button
browser action=snapshot profile=chrome targetId=ABC123
# Find Copy button ref, e.g., e326

# Copy
browser action=act profile=chrome targetId=ABC123 request={"kind":"click","ref":"e326"}

# Read result
exec: pbpaste
```

---

## 中文说明

# Grok Browser Skill

通过 Chrome 浏览器自动化查询 Grok (grok.com) 并复制响应。

## Prerequisites

- 安装了 Browser Relay 扩展的 Chrome
- 使用 `profile=chrome`(切勿使用 `profile=clawd`)

## Quick Start

```bash
# 1. Open Chrome with Grok
open -a "Google Chrome" "https://grok.com"
sleep 3

# 2. Attach browser relay
/Users/eason/clawd/scripts/attach-browser-relay.sh

# 3. Check tabs
browser action=tabs profile=chrome
```

## Input Method (IMPORTANT!)

Grok 使用 **contenteditable**,而非标准文本框。请使用 JavaScript evaluate:

```javascript
// Type query via evaluate
browser action=act profile=chrome targetId=<id> request={
  "kind": "evaluate",
  "fn": "(() => { const editor = document.querySelector('[contenteditable=\"true\"]'); if(editor) { editor.focus(); editor.innerText = 'YOUR_QUERY_HERE'; return 'typed'; } return 'not found'; })()"
}
```

然后按 Enter 提交:
```
browser action=act profile=chrome targetId=<id> request={"kind":"press","key":"Enter"}
```

## Complete Workflow

### 1. Open Grok & Attach Relay

```bash
open -a "Google Chrome" "https://grok.com"
sleep 3
/Users/eason/clawd/scripts/attach-browser-relay.sh
```

### 2. Get Tab ID

```
browser action=tabs profile=chrome
```

找到 Grok 标签页,记下其 `targetId`。

### 3. Input Query

```
browser action=act profile=chrome targetId=<id> request={
  "kind": "evaluate",
  "fn": "(() => { const e = document.querySelector('[contenteditable=\"true\"]'); if(e) { e.focus(); e.innerText = 'What is quantum computing?'; return 'ok'; } return 'fail'; })()"
}
```

### 4. Submit

```
browser action=act profile=chrome targetId=<id> request={"kind":"press","key":"Enter"}
```

### 5. Wait for Response

```bash
sleep 10-20  # Grok can take 10-30 seconds
```

### 6. Snapshot & Find Copy Button

```
browser action=snapshot profile=chrome targetId=<id>
```

在响应区域(通常是最后一条消息)寻找带有 "Copy" 的按钮。

### 7. Click Copy

```
browser action=act profile=chrome targetId=<id> request={"kind":"click","ref":"<copy_button_ref>"}
```

### 8. Read Clipboard

```bash
pbpaste
```

## Response Detection

提交后,当出现以下情况时表示响应已完成:
- 响应文本下方出现 Copy 按钮
- 显示响应时间指示器(例如 "952ms")
- 出现建议的后续追问按钮

## New Chat for New Topics

对于无关的查询,始终开启新的对话,以避免上下文溢出:

```
browser action=navigate profile=chrome targetId=<id> targetUrl="https://grok.com"
```

或使用 Cmd+J 快捷键:
```
browser action=act profile=chrome targetId=<id> request={"kind":"press","key":"Meta+j"}
```

## DeepSearch

要启用 DeepSearch,在提交前点击该按钮:
```
# In snapshot, find DeepSearch button
browser action=act profile=chrome targetId=<id> request={"kind":"click","ref":"<deepsearch_ref>"}
# Then type and submit as normal
```

## Troubleshooting

### Tab Not Found
重新运行 attach 脚本:
```bash
/Users/eason/clawd/scripts/attach-browser-relay.sh
```

### Relay Not Working
检查状态:
```
browser action=status profile=chrome
```
应显示 `cdpReady: true`。

### Context Overflow
导航到新的 grok.com,不要继续旧的对话。

### Multiple Windows
关闭多余的 Chrome 窗口。仅保留一个以确保 relay 可靠运行。

### Copy Button Not Found
响应可能仍在流式输出。再等久一些然后重新 snapshot。

## Example Session

```
# Open and attach
exec: open -a "Google Chrome" "https://grok.com"
exec: sleep 3
exec: /Users/eason/clawd/scripts/attach-browser-relay.sh

# Get tab
browser action=tabs profile=chrome
# Returns targetId: ABC123...

# Type query
browser action=act profile=chrome targetId=ABC123 request={
  "kind":"evaluate",
  "fn":"(() => { const e = document.querySelector('[contenteditable=\"true\"]'); e.focus(); e.innerText = 'Explain quantum entanglement briefly'; return 'ok'; })()"
}

# Submit
browser action=act profile=chrome targetId=ABC123 request={"kind":"press","key":"Enter"}

# Wait
exec: sleep 15

# Snapshot to find Copy button
browser action=snapshot profile=chrome targetId=ABC123
# Find Copy button ref, e.g., e326

# Copy
browser action=act profile=chrome targetId=ABC123 request={"kind":"click","ref":