browser_add_init_script
Register JavaScript that runs BEFORE the page's own code, at document start, on every page opened afterwards in this identity's context. Use when browser.evaluate is too late — most often to hook window.fetch/XMLHttpRequest and capture a SPA's request bodies, which network_requests cannot show. Does NOT affect already-open pages: add the script first, then browser.open. Cannot be removed once added; it lives until the context is evicted or browser.close is called.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"script": "<script>"
},
"name": "browser_add_init_script"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| script | Yes | ||
| in_workspace | No | Run this one call in this workspace id instead of the session's. Nothing is stored; other sessions are not affected. | |
| identity_name | No | _anon |