Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Interact with a local Chrome browser session via Chrome DevTools Protocol — screenshots, JS eval, clicks, navigation, and accessibility trees.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
SKILL.md
1---2name: chrome-cdp3description: Interact with local Chrome browser session (only on explicit user approval after being asked to inspect, debug, or interact with a page open in Chrome)4---56# Chrome CDP78Lightweight Chrome DevTools Protocol CLI. Connects directly via WebSocket — no Puppeteer, works with 100+ tabs, instant connection.910## Prerequisites1112- Chrome (or Chromium, Brave, Edge, Vivaldi) with remote debugging enabled: open `chrome://inspect/#remote-debugging` and toggle the switch13- Node.js 22+ (uses built-in WebSocket)14- If your browser's `DevToolsActivePort` is in a non-standard location, set `CDP_PORT_FILE` to its full path1516## Commands1718All commands use `scripts/cdp.mjs`. The `<target>` is a **unique** targetId prefix from `list`; copy the full prefix shown in the `list` output (for example `6BE827FA`). The CLI rejects ambiguous prefixes.1920### List open pages2122```bash23scripts/cdp.mjs list24```2526### Take a screenshot2728```bash29scripts/cdp.mjs shot <target> [file] # default: screenshot-<target>.png in runtime dir30```3132Captures the **viewport only**. Scroll first with `eval` if you need content below the fold. Output includes the page's DPR and coordinate conversion hint (see **Coordinates** below).3334### Accessibility tree snapshot3536```bash37scripts/cdp.mjs snap <target>38```3940### Evaluate JavaScript4142```bash43scripts/cdp.mjs eval <target> <expr>44```4546> **Watch out:** avoid index-based selection (`querySelectorAll(...)[i]`) across multiple `eval` calls when the DOM can change between them (e.g. after clicking Ignore, card indices shift). Collect all data in one `eval` or use stable selectors.4748### Other commands4950```bash51scripts/cdp.mjs html <target> [selector] # full page or element HTML52scripts/cdp.mjs nav <target> <url> # navigate and wait for load53scripts/cdp.mjs net <target> # resource timing entries54scripts/cdp.mjs click <target> <selector> # click element by CSS selector55scripts/cdp.mjs clickxy <target> <x> <y> # click at CSS pixel coords56scripts/cdp.mjs type <target> <text> # Input.insertText at current focus; works in cross-origin iframes unlike eval57scripts/cdp.mjs loadall <target> <selector> [ms] # click "load more" until gone (default 1500ms between clicks)58scripts/cdp.mjs evalraw <target> <method> [json] # raw CDP command passthrough59scripts/cdp.mjs open [url] # open new tab (each triggers Allow prompt)60scripts/cdp.mjs stop [target] # stop daemon(s)61```6263## Coordinates6465`shot` saves an image at native resolution: image pixels = CSS pixels × DPR. CDP Input events (`clickxy` etc.) take **CSS pixels**.6667```68CSS px = screenshot image px / DPR69```7071`shot` prints the DPR for the current page. Typical Retina (DPR=2): divide screenshot coords by 2.7273## Tips7475- Prefer `snap --compact` over `html` for page structure.76- Use `type` (not eval) to enter text in cross-origin iframes — `click`/`clickxy` to focus first, then `type`.77- Chrome shows an "Allow debugging" modal once per tab on first access. A background daemon keeps the session alive so subsequent commands need no further approval. Daemons auto-exit after 20 minutes of inactivity.78