browser.eval_js
Executes a JavaScript expression in the current page context and returns its JSON result. Requires per-expression operator approval, so use read-only page tools first when possible.
Instructions
Execute a JavaScript expression in the current page context and return the result. Every call needs operator approval for that exact expression: the first call returns status approval_required with an approval_id; retry with approval_id once it is approved. Prefer find_elements, get_html or observe for reading the page — they need no approval.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| expression | Yes | JavaScript expression or function source, evaluated in the page; returns its JSON value. | |
| session_id | No | Target session id, from browser.create_session or browser.list_sessions. Optional when exactly one session is live; observe and act tools create one when none is. | |
| timeout_ms | No | How long to wait for the expression, at most 60000; omitted, 30000. One that times out may still be running in the page. | |
| approval_id | No | ID of the approval granted for exactly this expression. The first call returns status approval_required with an approval_id; call again with it once an operator approves. |