browser_execute_script
Runs JavaScript expressions in the current Chrome page context to read or modify page state, await promises, and return results or errors without CSP blocking.
Instructions
Execute JavaScript in the current page, through the Chrome debugger (Runtime.evaluate) in the page's own context: the page's globals are visible and its Content Security Policy does not block it. A returned promise is awaited. If the code throws, the answer is ok:false with error and name, and the code is not run again. The call answers within 29.5 s; if the time runs out before the code is sent, the answer is error call-timeout with sent:false (nothing ran). 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; })() |