Auto-approve Run / Accept / Allow buttons in Cursor agent mode — no more clicking through every confirmation dialog.
Uses the Chrome DevTools Protocol (CDP) to connect to Cursor's Electron UI and automatically click approval buttons as they appear.
Cursor (Electron) This Script
┌──────────────────┐ ┌──────────────────┐
│ Agent pops up │ CDP │ Detects button │
│ [Run] [Accept] │◄─────►│ Clicks it │
│ Button vanishes │ 9222 │ Logs the action │
└──────────────────┘ └──────────────────┘
The script polls Cursor's DOM every 500ms (configurable), finds buttons matching a whitelist, and triggers a click. Works with both local and remote (SSH) development — the script only talks to the local Cursor UI.
- macOS or Windows (Linux should also work)
- Node.js >= 18
- Cursor installed at the default path
Quit Cursor completely first (Cmd+Q on Mac, make sure no background processes remain), then:
macOS:
./start-cursor-debug.shOr manually:
/Applications/Cursor.app/Contents/MacOS/Cursor --remote-debugging-port=9222Windows:
Add --remote-debugging-port=9222 to your Cursor shortcut's target field, or run:
& "$env:LOCALAPPDATA\Programs\cursor\Cursor.exe" --remote-debugging-port=9222In a separate terminal window:
npm install
npm startYou should see:
[xx:xx:xx] 🔗 Connected to Cursor via CDP
[xx:xx:xx] Monitoring for Accept / Run buttons...
Done. Every approval popup will now be auto-clicked.
Press Ctrl+C in the script's terminal. Cursor returns to normal manual-approval mode instantly.
| Environment Variable | Default | Description |
|---|---|---|
CDP_PORT |
9222 |
Chrome DevTools Protocol port |
POLL_MS |
300 |
Polling interval in milliseconds |
TELEGRAM_BOT_TOKEN |
— | Telegram Bot API token (from @BotFather) |
TELEGRAM_CHAT_ID |
— | Telegram chat/user ID to send messages to |
WECOM_WEBHOOK_URL |
— | WeCom (企业微信) bot webhook URL |
PUSHPLUS_TOKEN |
— | PushPlus token for WeChat push |
NOTIFY_COOLDOWN_MS |
30000 |
Min interval between notifications (ms) |
Example with custom settings:
CDP_PORT=9333 POLL_MS=200 npm startWhen the script encounters an approval button it doesn't recognize (not in whitelist or blacklist), it sends a push notification so you can manually intervene. This is a safety net for unexpected dialogs.
When configured, Telegram becomes a full remote control for Cursor — not just one-way notifications.
What it does:
- Blocked by unknown button → sends screenshot + inline buttons to TG
- You reply with text → typed into Cursor chat + Enter
- You tap an inline button → clicks that button in Cursor
- You can send commands anytime (even when not blocked)
TG Bot commands:
| Command | Action |
|---|---|
/ss |
Take and send a screenshot |
/status |
Check if script is running |
/click <text> |
Click a button matching the text |
/key <combo> |
Send key combo (e.g. cmd+shift+p, enter, esc) |
/type <text> |
Type text without pressing Enter |
/help |
Show all commands |
| Any other text | Type into Cursor chat + press Enter |
Setup:
- Create a bot via @BotFather, copy the token
- Get your chat ID via @userinfobot
- Send any message to your bot first (so it can reply to you)
- Run:
TELEGRAM_BOT_TOKEN=123456:ABC-DEF TELEGRAM_CHAT_ID=your_id npm start- In your WeCom group, add a bot and copy the webhook URL
- Run:
WECOM_WEBHOOK_URL="https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=xxx" npm start- Sign up at pushplus.plus, copy your token
- Run:
PUSHPLUS_TOKEN=your_token npm startYou can enable multiple channels simultaneously. Notifications are rate-limited (default: once per 30 seconds) to avoid spam.
The script uses seven strategies to catch all approval types in Cursor:
| Approval Type | What's Clicked | How It's Detected |
|---|---|---|
| Terminal commands | "Run" button | button.ui-button inside .ui-shell-tool-call__approval-row |
| Inline code edits | Accept button (⌘Y) | button.partialHoverButton (non-secondary) |
| File changes | "Keep File" / "Keep All" | <span class="truncate"> text match |
| Dialogs | "OK" / "Accept" / "Allow" | .monaco-button text match |
| Unknown buttons | Not clicked — sends notification | Buttons in approval containers not in whitelist |
Full text whitelist (case-insensitive): Run, Keep File, Keep All, Accept, Allow, Approve, Run Command, Save All & Run, Accept All, Continue, Proceed, Yes, Confirm, OK.
To modify, edit the WL set in auto-accept.js.
| Problem | Fix |
|---|---|
| "Cannot reach Cursor on port 9222" | Make sure you fully quit Cursor before relaunching with the debug flag. Use pkill -f Cursor to kill lingering processes. |
| Script connects but nothing gets auto-clicked | Cursor may have updated its button labels/DOM. Open http://localhost:9222 in a browser to inspect the UI and update BUTTON_WHITELIST. |
| "remote-debugging-port is not in the list of known options" | This warning is harmless. The flag is passed through to Chromium and still works. |
- Port 9222 grants full access to Cursor's UI from any local process. Only use this on machines you trust.
- The script does not inspect command content — it will approve
rm -rf /just as happily asecho hello. Use at your own risk. - This is an unofficial hack, not a Cursor feature. It may break after updates.
MIT