browser.eval_js
Execute custom JavaScript in the current page context and retrieve the result. Requires explicit approval per expression; use for actions that need dynamic scripting, not for routine reading.
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. | |
| 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. |