evaluate_script
Runs a JavaScript function in the currently selected page and returns the result as JSON. Use it to extract page data or automate browser actions.
Instructions
Evaluate a JavaScript function inside the currently selected page. Returns the response as JSON, so returned values have to be JSON-serializable.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| args | No | An optional list of arguments to pass to the function. | |
| function | Yes | A JavaScript function declaration to be executed by the tool in the currently selected page. Example without arguments: `() => { return document.title }` or `async () => { return await fetch("example.com") }`. Example with arguments: `(el) => { return el.innerText; }` | |
| dialogAction | No | Handle dialogs while execution. "accept", "dismiss", or string for response of window.prompt. Defaults to accept. |