execute_js
Run JavaScript in the active browser tab to inspect or modify page content. Use a return statement for results, or set preset='dom_tree' to output the DOM structure tree.
Instructions
在当前 tab 执行 JavaScript 代码。⚠️ 必须使用 return 语句返回结果。preset='dom_tree' 时 code 改为传 JSON 参数对象 {"max_depth":5,"include_text":true,"max_text_length":50,"selector":null},直接输出 DOM 结构树。
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | 要执行的 JavaScript 代码(必须用 return 返回结果!),或 preset='dom_tree' 时的 JSON 参数 | |
| preset | No | 预置脚本模板:dom_tree=DOM 结构树(免写模板 JS) | |
| timeout | No | 本次 JS 执行超时(秒,可选)。默认 150 秒。 |