javascript_tool
Run JavaScript in the active browser tab to manipulate the DOM, access page variables, or fetch data. Returns the evaluated result or any errors.
Instructions
Execute JavaScript code in the context of the current page. The code runs in the page's context and can interact with the DOM, window object, and page variables. Returns the result of the last expression or any thrown errors. If you don't have a valid tab ID, use tabs_context first to get available tabs.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| text | Yes | The JavaScript code to execute. Evaluated in the page context with REPL semantics: top-level `await` works, and the result of the last expression is returned automatically -- write the expression you want (e.g. `window.myData.value`, or `await fetch(url).then(r=>r.json())`) rather than `return ...`. You can access and modify the DOM, call page functions, and interact with page variables. | |
| tabId | Yes | Tab ID to execute the code in. Must be a tab in the current group. Use tabs_context first if you don't have a valid tab ID. | |
| action | Yes | Must be set to 'javascript_exec' |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| provenance | No |