evaluate_js
Run arbitrary JavaScript in the active browser tab to inspect dynamic state, modify DOM, or trigger interactions. Returns JSON-serialized results, with promises automatically awaited.
Instructions
Executes arbitrary JavaScript code in the page context, returning evaluated results as JSON-serializable values. Side effects: may modify DOM, state, or trigger network requests. Prerequisites: requires an active Chrome tab; script context must allow execution. Returns: JSON-serialized return value (or error if promise rejected). Use this for dynamic inspection, DOM manipulation, complex interactions. Alternatives: 'inspect_dom' for read-only DOM queries, 'click_element' for UI interactions.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tab_id | No | The Tab ID of the target tab. Omit to use the active tab. | |
| expression | Yes | JavaScript code expression to execute. Constraints: valid JavaScript (single expression or IIFE). Interactions: automatically awaits promises; 'returnByValue' returns serialized results. Defaults to: None (required). | |
| instance_id | No | Chrome instance id from open_instance/list_instances. Omit for the default instance. |