evaluate_script
Runs a JavaScript function in the page and returns the result, enabling targeted reads like text, computed styles, or element existence without a full snapshot.
Instructions
Run a JS function in the page and return its result. Prefer this for targeted reads (a value, text, computed style, whether an element exists) instead of a full take_snapshot. Use the UID interaction tools for clicking, typing, and filling.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| args | No | UIDs to pass as function arguments | |
| saveTo | No | Save the result to a file as JSON instead of returning it inline. Pass a file path, an existing directory (generated file inside), or true (generated file under ~/.firefox-devtools-mcp/output/). Relative paths resolve against the current working directory. | |
| preview | No | Number of characters of the saved result to return inline as a preview when saveTo is used. Omit for no preview. | |
| timeout | No | Timeout in ms (default: 5000) | |
| function | Yes | JS function string, e.g. () => document.title |