execute_javascript
Execute JavaScript in a loaded browser page to extract data, modify content, or automate actions, returning JSON-serializable values and supporting persistent tab reuse.
Instructions
Execute arbitrary JavaScript in the context of a loaded web page. The script runs in the browser and must return a JSON-serializable value. Supports persistent sessions via tab_id — when using a tab_id, the url parameter is optional (executes on the current page).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | No | The URL to load before executing the script (optional if tab_id is provided) | |
| script | Yes | JavaScript code to execute. The last expression is returned, or use 'return' explicitly. | |
| tab_id | No | Reuse a persistent tab (from open_tab) instead of opening a new one | |
| timeout | No | Timeout in ms (default: 30000) |