# Claude Browser Bridge Let a local coding agent read and drive **your everyday Chrome profile** — the one already logged into your dashboards, analytics and internal tools. ```bash node server/bridge-cli.mjs nav https://search.google.com/search-console 8000 node server/bridge-cli.mjs rows "table" # -> the report, as JSON ``` No OAuth dance, no scraping cookies out of Chrome's encrypted store, no second browser window. The extension runs inside the profile you already use, so anything you can see, your agent can read. ## Why this exists The obvious approach — launch Chrome with `--remote-debugging-port` and drive it over CDP — does not work on the profile that matters: - `--remote-debugging-port` only applies at launch. You cannot attach to a browser already running. - Since **Chrome 136** the flag is *ignored entirely* for the default profile, so you must point Chrome at a copy. - Copying the profile loses your sessions anyway: cookies are sealed with app-bound encryption and do not survive the move. You end up logged out of everything, which was the whole point. An extension sidesteps all of it. It loads into the real profile and inherits the real sessions. This matters most for the reports that have **no API** — anything behind a login that only ever offers a CSV download or an HTML table. ## Install **1. Load the extension** (one time) 1. Open `chrome://extensions` 2. Enable **Developer mode** (top right) 3. **Load unpacked** → select this repo's `extension/` folder 4. **Click the extension's toolbar icon once** to grant site access (see [Security](#security)) **2. Start the bridge** (each session) ```bash node server/bridge.mjs ``` Requires Node 18+. No dependencies. If your agent starts it, launch it **detached** — a plain background job often gets reaped when the agent harness cleans up, which kills the bridge mid-session: ```powershell # Windows Start-Process node -ArgumentList '"C:\path\to\server\bridge.mjs"' -WindowStyle Hidden ``` ```bash # macOS / Linux nohup node server/bridge.mjs >/tmp/bridge.log 2>&1 & ``` **3. Check it** ```bash node server/bridge-cli.mjs health # { "ok": true, "extensionConnected": true, ... } ``` `extensionConnected: false` means Chrome isn't running, the extension isn't loaded, or it needs a reload after an edit. ## Commands ```bash node server/bridge-cli.mjs health # is the extension connected? node server/bridge-cli.mjs permissions # what sites may it touch? node server/bridge-cli.mjs nav [waitMs] # navigate, wait for load node server/bridge-cli.mjs text # body innerText node server/bridge-cli.mjs html # full outerHTML node server/bridge-cli.mjs query [limit] [attrs] # structured extraction node server/bridge-cli.mjs rows [sel] [limit] # tables -> 2D cell text node server/bridge-cli.mjs eval "" # evaluate in the page node server/bridge-cli.mjs click node server/bridge-cli.mjs clickText [sel] [exact] [nth] node server/bridge-cli.mjs clickNth node server/bridge-cli.mjs waitFor [timeoutMs] node server/bridge-cli.mjs fetch [text|json] # from the page's origin node server/bridge-cli.mjs screenshot [out.png] node server/bridge-cli.mjs waitDownload [timeoutMs] # -> path of finished file node server/bridge-cli.mjs close # dispose of the tab ``` Work happens in **one background tab** the extension creates and reuses. Your other tabs are never touched. `close` disposes of it. ### `fetch` is the useful one It runs from the page's own origin with your cookies, so a site's internal JSON endpoints answer exactly as they do for you: ```bash node server/bridge-cli.mjs nav https://app.example.com/dashboard 5000 node server/bridge-cli.mjs fetch https://app.example.com/api/v2/report json ``` Often far more reliable than scraping the rendered DOM. ### Driving from code The CLI is a thin wrapper over one HTTP endpoint. For anything multi-step, talk to it directly: ```js const cmd = async (action, params = {}) => { const r = await fetch("http://127.0.0.1:8777/cmd", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ action, ...params, timeoutMs: 180000 }), }); const out = await r.json(); if (out.error) throw new Error(`${action}: ${out.error}`); return out.result; }; await cmd("nav", { url: "https://example.com/report", waitMs: 8000 }); const tables = await cmd("rows", { selector: "table", limit: 3000 }); ``` See [`examples/`](examples/) for a complete multi-page collector. ## Security Read this bit. The tool is useful precisely because it is powerful. - **Site access is opt-in.** The extension ships able to talk to `127.0.0.1` and nothing else. Installing it grants access to **no website**. Clicking the toolbar icon requests ``; until you do, every page command fails. - **Narrow it if you prefer.** Replace `optional_host_permissions` in `extension/manifest.json` with an explicit list and it can never touch anything else: ```json "optional_host_permissions": ["https://*.example.com/*"] ``` Check what is actually granted with `bridge-cli.mjs permissions`. - **The server binds to `127.0.0.1` only.** Nothing off your machine can reach it. There is no authentication, so treat it as you would any localhost dev server: **any process on your machine can drive your browser while it runs.** Stop it when you're done. - **Nothing is uploaded.** Results go to your local shell. The extension talks to no remote host. - **Your agent sees whatever you point it at.** If you navigate to a page with sensitive data, that data enters your agent's context — and, for a hosted agent, its provider's. Point it deliberately. - **Stop it any time**: quit the `bridge.mjs` process, or disable the extension. Not affiliated with or endorsed by Anthropic or Google. ## Gotchas Hard-won notes on sites that fight back — see [`docs/gotchas.md`](docs/gotchas.md). Highlights: - **Trusted Types kills `eval`.** Google Search Console blocks string evaluation in *both* the page world and the isolated world. Use `query`, `rows` and `clickText`, which pass real functions. - **Synthetic clicks don't always take.** Material-style tabs accept `el.click()`, flip `aria-selected`, then revert. Prefer URL parameters where the app offers them. - **SPAs keep hidden tables mounted.** "The biggest table on the page" is often the wrong one. Pick by header text. ## Limitations - Chrome / Chromium only (Manifest V3). No Firefox or Safari. - Unpacked extension — reloads after every edit, and Chrome may nag about developer mode. - Single tab, single command at a time. Not built for parallel scraping. - No authentication on the local server (see [Security](#security)). ## License MIT — see [LICENSE](LICENSE).