execute_js
Run custom JavaScript in the page's MAIN world when no dedicated tool fits. Await promises up to timeout, return JSON, or save full result to disk.
Instructions
Run JavaScript in the page (MAIN world). Requires the extension's "Allow user scripts" toggle; errors explain setup if disabled. Use it when no dedicated tool fits: extract or extract_table read data, query_dom inspects elements, inject_css restyles, and none of them needs the toggle. A promise is awaited up to timeout. A cut result stays valid JSON and says truncated; save_to writes the whole result to disk.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | JS evaluated in the page; the value of the last expression is returned | |
| tab_id | No | Target tab; omitted = last tab navigated in this session, else the active one | |
| save_to | No | Absolute path: write the result (a string as is, anything else as JSON) there and return the path instead of the content | |
| timeout | No | Max ms to wait for the result (default 30000); raise it for long async work | |
| frame_id | No | Target iframe id from get_frames; omitted = main frame | |
| max_length | No | Max output chars |