Turn SuperGrok into a REST API + CLI tool. No API key needed.
Your Terminal/Script β Safari JS injection β grok.com β Response extracted via DOM
Two modes:
# Start the server on your Mac
python3 scripts/grok_bridge.py --port 19998
# Query from anywhere
curl -X POST http://your-mac:19998/chat \
-H "Content-Type: application/json" \
-d '{"prompt":"What is the mass of the sun?","timeout":60}'
# Health check
curl http://your-mac:19998/health
# Read current conversation
curl http://your-mac:19998/history# Local
bash scripts/grok_chat.sh "Explain quantum tunneling"
# Remote via SSH
MAC_SSH="ssh user@your-mac" bash scripts/grok_chat.sh "Write a haiku" --timeout 90- macOS with Safari
- Logged into grok.com (free or SuperGrok)
- Safari > Settings > Advanced > Show features for web developers β
- Safari > Develop > Allow JavaScript from Apple Events β
- No Accessibility permission needed (v3 uses JS injection, not System Events)
| Method | Path | Description |
|---|---|---|
| POST | /chat |
Send prompt, wait for response |
| POST | /new |
Start new conversation |
| GET | /health |
Health check (Safari URL, grok status) |
| GET | /history |
Read current page conversation |
| v1 | v2 | v3 | |
|---|---|---|---|
| Input | Peekaboo UI | pbcopy + Cmd+V | JS execCommand('insertText') |
| Submit | UI click | System Events Return | JS button.click() |
| Permissions | Peekaboo + Accessibility | Accessibility | None (pure JS injection) |
| Interface | CLI only | CLI only | REST API + CLI |
| Dependencies | Peekaboo (brew) | None | None (stdlib only) |
| Speed | ~30s | ~3s | ~3s |
ββββββββββββββββ βββββββββββββββββββββββββ
β HTTP Client β POST /chat β macOS β
β (anywhere) β βββββββββββββββββββ β β
ββββββββββββββββ β grok_bridge.py β
β β osascript β
β Safari do JavaScript β
β β execCommand β
β grok.com textarea β
β β button.click() β
β Grok responds β
β β DOM poll β
β Response extracted β
βββββββββββββββββββββββββ
React controlled inputs ignore JavaScript value setter, synthetic InputEvent, and even nativeInputValueSetter.
What doesn't work from SSH:
- β
osascript keystrokeβ blocked by macOS Accessibility - β CGEvent (Swift) β HID events don't reach web content
- β JS
InputEvent/nativeInputValueSetterβ React ignores synthetic events
What does work:
- β
document.execCommand('insertText')β triggers real input in the browser - β
JS
button.click()on Send button β no System Events needed
Zero permissions, zero dependencies, pure JavaScript injection via AppleScript.
v3 architecture designed by Claude Opus 4.6 (via Antigravity), System Events bypass by ε°η΅ π¦.
MIT