add_script_on_new_document
Inject JavaScript into every new document before other scripts run, enabling polyfills or hooks to be applied consistently across page loads.
Instructions
Add a script to be evaluated on every new document before any other scripts. Useful for injecting polyfills or hooks.
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": {
"source": "<source>"
},
"name": "add_script_on_new_document"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| source | Yes | JavaScript source code to evaluate | |
| worldName | No | Isolated world name. If specified, script runs in isolated context. | |
| runImmediately | No | Run script immediately on existing documents | |
| includeCommandLineAPI | No | Include command line API (e.g., $, $$, $x) |