javascript_tool
Execute JavaScript in page context for custom DOM queries, data extraction, and triggering JS APIs. Supports async code and shadow DOM via __pierce.
Instructions
Execute JavaScript in page context. Supports await, async IIFE, and shadow-DOM helpers via __pierce.
When to use: Custom DOM queries, data extraction, or triggering JS APIs not reachable via other tools. When NOT to use: Use interact or act for UI interactions, or extract_data for structured schema-based extraction.
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": {
"tabId": "<tabId>"
},
"name": "javascript_tool"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | No | JS code. Last expression returned | |
| text | No | Deprecated. Use "code" instead | |
| tabId | Yes | Tab ID to execute code in | |
| timeout | No | Timeout in ms. Default: 30000 |