evaluate_script
Run JavaScript functions in the target page and receive JSON-serializable output to inspect live page data.
Instructions
Evaluate a JavaScript function inside the target 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. | |
| pageId | Yes | Targets a specific page by ID. | |
| filePath | No | The absolute or relative path to a file to save the script output to. If omitted, the output is returned inline. | |
| function | Yes | A JavaScript function declaration to be executed by the tool in the target page. Example without arguments: `() => document.title` or `async () => await fetch("example.com")`. Example with arguments: `(el) => el.innerText` | |
| dialogAction | No | Handle dialogs while execution. "accept", "dismiss", or string for response of window.prompt. Defaults to accept. | |
| waitForStableDom | No | Whether to wait for the DOM to settle. Pass false if the script only reads data. Defaults to true. |