Ubuntu/Debian automation for grok.com via Chrome DevTools Protocol (CDP).
GrokAuto is a headless browser automation system that performs configurable chat actions on grok.com using Chrome/Chromium. It validates dependencies, checks your login state, executes tasks, captures responses, and provides comprehensive diagnostic feedback β all from the command line or on a schedule via Cron.
- β Dependency Checking β Validates Chrome, Python, pip packages, Xvfb, cron, and profile health
- β Config Validation β JSON schema validation with colour-coded reports
- β Login Detection β Automatically verifies your grok.com session before running
- β
Headless Execution β Runs without a GUI using Chromium's
--headless=newmode - β
Task Filtering β Run all tasks or filter by
--task-id - β
Cron Integration β One-command scheduling:
--setup-cron "0 9 * * *" - β
Markdown Output β Responses saved as timestamped
.mdfiles with restrictive permissions - β Comprehensive Logging β Colour-coded console output + file logging
git clone https://github.com/yourname/grokauto.git
cd grokauto
bash setup.shchromium --remote-debugging-port=9222
# Navigate to https://grok.com and sign in
# Close the browser β GrokAuto will reuse the saved sessionpython3 main.py --diagnose
python3 main.py --prompt "Say hello and confirm automation works"# Run all tasks from config every 10 minutes
python3 main.py --setup-cron "*/10 * * * *"
# Run only a specific task
python3 main.py --setup-cron "*/10 * * * *" --task-id gmail_check- OS: Ubuntu 22.04+ / Debian 12+
- Python: 3.8+
- Browser: Google Chrome or Chromium
- Packages:
websocket-client,requests - Optional:
xvfb(for virtual display),cron(for scheduling)
bash setup.shThis will:
- Create
~/.config/grokauto/and~/grokauto_outputs/ - Generate a default
config.json - Check all dependencies and offer fixes
- Create a
grokautowrapper in~/.local/bin/
pip3 install websocket-client requests
mkdir -p ~/.config/grokauto ~/grokauto_outputs
cp config.json.template ~/.config/grokauto/config.json
# Edit config.json with your settingsEdit ~/.config/grokauto/config.json:
{
"chrome_profile_path": "/home/YOURUSER/.config/chromium/Default",
"chrome_binary": "/usr/bin/chromium",
"debug_port": 9222,
"headless": true,
"xvfb_display": ":99",
"output_dir": "/home/YOURUSER/grokauto_outputs",
"tasks": [
{
"id": "task_001",
"prompt": "What are the latest developments in AI?",
"wait_for_complete": true,
"timeout_seconds": 120
}
]
}| Field | Type | Description |
|---|---|---|
id |
string | Unique task identifier |
prompt |
string | The message sent to Grok |
wait_for_complete |
boolean | Wait for streaming response to finish |
timeout_seconds |
int | Maximum time to wait for a response |
# Full system diagnostic
python3 main.py --diagnose
# Run all tasks from config
python3 main.py --run
# Run a specific task only
python3 main.py --run --task-id task_001
# Single inline prompt
python3 main.py --prompt "Explain quantum computing"
# Validate config file
python3 main.py --validate-config
# Check dependencies
python3 main.py --check-deps
# List saved outputs
python3 main.py --list-outputs
# Install cron job
python3 main.py --setup-cron "0 9 * * *"
# Remove cron job
python3 main.py --remove-cronAll responses are saved as Markdown in your configured output_dir:
~/grokauto_outputs/
βββ grok_response_task_001_20260523_143022.md
βββ grok_batch_20260523_150000.md
βββ ...
Each file contains:
- Task ID and timestamp
- Execution status (SUCCESS / TIMEOUT / ERROR)
- Duration
- Original prompt
- Grok's response
Cron Scheduler βββΊ main.py (orchestrator)
β
ββββΊ deps_checker.py
ββββΊ config_validator.py
ββββΊ browser_ctl.py (CDP / WebSocket)
ββββΊ login_validator.py
ββββΊ task_executor.py
ββββΊ response_writer.py
See SECURITY.md for the full security review, threat model, and deployment checklist.
Key points:
- Chrome profile credentials are never modified or extracted
- CDP port binds to localhost only (127.0.0.1)
- Output files are created with
chmod 600 - No credentials are stored in config files
| Issue | Solution |
|---|---|
| "Not logged in to grok.com" | Launch Chromium manually, go to grok.com, and sign in |
| "Port 9222 is already in use" | Kill existing Chrome: kill $(lsof -t -i:9222) |
| "No Chrome or Chromium found" | sudo apt install -y chromium-browser |
| Missing pip packages | pip3 install websocket-client requests |
| Headless mode fails | Set "headless": false and run inside a VNC session |
See CONTRIBUTING.md for guidelines.
GrokAuto is an unofficial automation tool. Use it responsibly and in accordance with grok.com Terms of Service. The authors are not responsible for account actions resulting from automated usage.