browser_execute_script
Run custom JavaScript expressions in the current browser page to read data, modify elements, or trigger actions, solving automation limits by returning computed results directly from the live DOM.
Instructions
Execute JavaScript in the current page. IMPORTANT: the parameter is code (NOT script - though that alias is accepted), and it must be an EXPRESSION, not statements: use an IIFE (() => { ...; return x; })(). Top-level return is a syntax error (the handler wraps code in parentheses).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | JavaScript EXPRESSION to evaluate in page context. For multi-statement logic use an IIFE: (() => { ...; return result; })() |