execute_js
Run JavaScript code in the browser and retrieve the output. Scripts are automatically wrapped to capture results; avoid using 'return' statements directly.
Instructions
Execute JavaScript code on the page and return the result.
IMPORTANT: Do NOT use 'return' statements directly in your script.
The script is automatically wrapped to capture the result.
Examples:
Good: document.title
Good: (function() { const x = 1 + 1; return x; })()
Bad: return document.title // SyntaxError!
For complex scripts, wrap in an IIFE:
(function() {
const data = [];
// ... your code ...
return data;
})()
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| script | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |