首页龙虾技能列表 › Chrome CDP Controller — Chrome CDP 控制器

Chrome CDP Controller — Chrome CDP 控制器

v1.0.0

Chrome CDP 控制器工具。

0· 74·0 当前·0 累计
by @hanxiaolin (xiaoxiaoxi)·MIT-0
下载技能包
License
MIT-0
最后更新
2026/3/30
安全扫描
VirusTotal
可疑
查看报告
OpenClaw
安全
high confidence
The skill is internally consistent with its stated purpose (controlling a local Chrome instance via CDP with Puppeteer); nothing in the files or instructions requests unrelated credentials or installs unexpected remote code.
评估建议
This skill appears to be what it says: a Puppeteer-based controller for a local Chrome instance. Before installing or running it, consider these precautions: - Only connect it to browsers you control. Running Chrome with remote debugging exposes a WebSocket that this tool will use; ensure the debugging port is bound to localhost and not reachable by others. - Audit any commands/JSON files you pass to the script. Commands can (a) upload local files you specify, (b) read and execute JavaScript fil...
详细分析 ▾
用途与能力
Name/description match the implementation: the package depends on puppeteer-core, the SKILL.md explains connecting to a local CDP WebSocket, and scripts/cdp_controller.js implements navigation, interaction, evaluation, uploads, screenshots and network interception as described. No extraneous credentials, binaries, or unrelated services are required.
指令范围
Instructions stay within browser automation scope, but include functionality that can access local files (upload() verifies filesystem paths; the 'evaluate' command supports executing JS from a file by reading it from disk) and capture network responses (start_intercept -> in-memory storage retrievable via get_intercepted). Those capabilities are expected for this tool but can be abused to exfiltrate sensitive data if untrusted command files or commands are executed. SKILL.md also instructs starting Chrome with remote debugging on localhost (expected).
安装机制
No registry install spec in the metadata; the project is instruction-only but includes a package.json and expects the user to run `npm install` which will fetch puppeteer-core from the npm registry. Dependencies resolve to normal npm packages and no ad-hoc download URLs or archive extraction from untrusted hosts are present.
凭证需求
The skill requests no environment variables or external credentials. It connects to a user-provided local CDP WebSocket URL only. Note: the code can read local file paths supplied as command parameters (for upload and evaluate-from-file), so sensitive files on disk could be accessed if commands include them.
持久化与权限
Skill is not always-enabled, does not request persistent platform-level privileges, and does not modify other skills or global agent configuration. It is run on-demand and requires an explicit WebSocket URL to connect to the browser.
scripts/cdp_controller.js:167
Dynamic code execution detected.
scripts/cdp_controller.js:278
File read combined with network send (possible exfiltration).
安全有层次,运行前请审查代码。

License

MIT-0

可自由使用、修改和再分发,无需署名。

运行时依赖

无特殊依赖

版本

latestv1.0.02026/3/30

Initial release: control a running Chrome via CDP using Puppeteer. Includes navigate/click/fill/evaluate/screenshot/network intercept.

● 可疑

安装命令 点击复制

官方npx clawhub@latest install chrome-cdp-controller
镜像加速npx clawhub@latest install chrome-cdp-controller --registry https://cn.clawhub-mirror.com

技能文档

Control and automate a Chrome browser that's already running with CDP enabled, using Puppeteer.

键 Features

  • Non-intrusive: Connects 到 existing Chrome, opens 新的 标签页, operates, 然后 closes 仅 标签页
  • browser stays 打开: Never closes existing tabs 或 browser
  • Clean automation: 每个 task runs 在...中 own 标签页, 哪个 automatically closed 当...时 已完成

1. Chrome 带有 CDP 已启用

Chrome must be running with remote debugging enabled. If not already started:

# macOS
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222 &

# Windows "C:\Program Files\Google\Chrome\Application\chrome.exe" --remote-debugging-port=9222

# Linux google-chrome --remote-debugging-port=9222 &

2. 获取 WebSocket URL

Visit http://localhost:9222/json/version to get the webSocketDebuggerUrl, for example:

ws://127.0.0.1:9222/devtools/browser/FFA7276F8E8E51645BD2AC9BE6B79607

Or use this one-liner:

curl -s http://localhost:9222/json/version | grep -o '"webSocketDebuggerUrl":"[^"]"' | cut -d'"' -f4

3. Install Dependencies

cd chrome-cdp-controller
npm install

This installs puppeteer-core which is lightweight (doesn't download Chromium).

Usage

Command-Based Execution

Create a JSON file with commands:

commands.json:

[
  {"type": "navigate", "url": "https://www.baidu.com"},
  {"type": "wait", "seconds": 2},
  {"type": "screenshot", "path": "/tmp/screenshot.png"},
  {"type": "evaluate", "script": "document.title"}
]

Execute:

node scripts/cdp_controller.js --ws "ws://127.0.0.1:9222/devtools/browser/..." --commands commands.json

节点.js API

const { CDPController } = require('./scripts/cdp_controller.js');

(async () => { const controller = new CDPController('ws://127.0.0.1:9222/devtools/browser/...'); await controller.connect(); // Navigate await controller.navigate('https://www.taobao.com'); // Fill form await controller.fill('#q', 'iPhone'); await controller.press('Enter'); await controller.wait(3); // Extract data const result = await controller.evaluate( Array.from(document.querySelectorAll('.item')) .slice(0, 10) .map(item => ({ title: item.querySelector('.title')?.textContent.trim(), price: item.querySelector('.price')?.textContent.trim() })) ); console.log(result.result); // Intercept network await controller.startIntercept('api'); // ... perform actions ... const responses = controller.getInterceptedResponses(); await controller.close(); })();

可用 Commands

导航

  • navigate - Go 到 URL
- url: Target URL - waitUntil: "加载", "domcontentloaded", 或 "networkidle2" (默认)

Interaction

  • click - Click 元素
- selector: CSS selector - 超时: 超时 在...中 milliseconds (默认: 5000)

  • fill - Fill 表单 字段 (selects 所有, 然后 types)
- selector: CSS selector - text: Text 到 fill - 超时: 超时 在...中 milliseconds (默认: 5000)

  • 类型 - 类型 text character 由 character
- selector: CSS selector - text: Text 到 类型 - 延迟: 延迟 之间 characters 在...中 ms (默认: 50) - 超时: 超时 在...中 milliseconds (默认: 5000)

  • press - Press 键
- : 键 name (Enter, 标签页, 转义, etc.)

Data Extraction

  • get_text - 获取 text content 的 single 元素
- selector: CSS selector

  • get_all_text - 获取 text content 的 所有 matching elements
- selector: CSS selector

  • evaluate - Execute JavaScript 和 return 结果
- script: JavaScript code

Network Interception

  • start_intercept - 开始 intercepting network responses
- url_pattern: URL pattern 到 match (substring match, e.g., "api")

  • get_intercepted - 获取 所有 intercepted responses
  • clear_intercepted - 清除 intercepted responses 列表

Utilities

  • screenshot - Take screenshot
- path: 输出 file path - fullPage: Capture 满 page (默认: 假)

  • wait_for_selector - Wait 对于 元素 到 appear
- selector: CSS selector - 超时: 超时 在...中 milliseconds (默认: 5000)

  • wait - Sleep 对于 持续时间
- seconds: 数字 的 seconds 到 wait

Common Workflows

示例 1: 搜索 Taobao 对于 iPhone Prices

taobao-搜索.json:

[
  {"type": "navigate", "url": "https://www.taobao.com"},
  {"type": "wait", "seconds": 2},
  {"type": "fill", "selector": "#q", "text": "iPhone"},
  {"type": "press", "key": "Enter"},
  {"type": "wait", "seconds": 5},
  {"type": "evaluate", "script": "Array.from(document.querySelectorAll('.item, [class=\"Item\"]')).slice(0, 10).map(item => ({ title: item.querySelector('.title, [class=\"title\"]')?.textContent.trim().substring(0, 80), price: item.querySelector('.price, [class=\"price\"]')?.textContent.trim() }))"}
]

Run:

WS_URL=$(curl -s http://localhost:9222/json/version | grep -o '"webSocketDebuggerUrl":"[^"]*"' | cut -d'"' -f4)
node scripts/cdp_controller.js --ws "$WS_URL" --commands taobao-search.json

Note: Selectors 可能 vary. 使用 browser DevTools (F12) 到 inspect elements.

示例 2: Ask ChatGPT Question

chatgpt-ask.json:

[
  {"type": "navigate", "url": "https://chat.openai.com"},
  {"type": "wait_for_selector", "selector": "textarea", "timeout": 10000},
  {"type": "type", "selector": "textarea", "text": "What is artificial intelligence?"},
  {"type": "press", "key": "Enter"},
  {"type": "wait", "seconds": 10},
  {"type": "get_text", "selector": "[data-message-author-role='assistant']:last-of-type"}
]

示例 3: Intercept API Responses

intercept-api.json:

[
  {"type": "start_intercept", "url_pattern": "graphql"},
  {"type": "navigate", "url": "https://example.com"},
  {"type": "wait", "seconds": 3},
  {"type": "get_intercepted"}
]

For more examples, see references/examples.md.

Workflow

When automating browser tasks:

  • 获取 WebSocket URL:
- 如果 您 已经 有 (e.g., ws://127.0.0.1:9222/devtools/browser/...), 使用 directly - 否则, 获取 从 http://localhost:9222/json/version

  • Determine selectors:
- 对于 known sites (Taobao, ChatGPT, etc.), check references/examples.md - 对于 unknown sites, navigate 第一个 和 使用 evaluate 带有 document.querySelector 到 test selectors - 使用 browser DevTools (F12) 到 inspect elements

  • Build command sequence:
- 开始 带有 navigate - 添加 waitwait_for_selector 之间 steps - 使用 fill 对于 表单 inputs, click 对于 buttons - 使用 evaluate 对于 complex data extraction - 添加 start_intercept 之前 导航 如果 monitoring network traffic

  • Execute:
- 保存 commands 到 JSON file - Run: 节点 scripts/cdp_controller.js --ws "" --commands - 解析 JSON 输出

  • Handle failures:
- 如果 selectors 失败, inspect 带有 DevTools - 如果 timing issues occur, increase wait 乘以 或 使用 wait_for_selector - 如果 连接 fails, 验证 Chrome running 带有 CDP 已启用

Tips

  • Wait 乘以: 使用 wait_for_selector 代替 的 fixed wait 当...时 possible
  • Selectors: Prefer ID (#id) > 类 (.类) > 属性 ([attr='值'])
  • Network interception: 开始 intercepting 之前 navigating
  • JavaScript: 使用 evaluate 对于 complex data extraction
  • Screenshots: Useful 对于 debugging

Troubleshooting

连接 失败

  • Ensure Chrome running 带有 --remote-debugging-port=9222
  • 验证 WebSocket URL 正确
  • Check Chrome version compatibility 带有 puppeteer-core

元素 不 Found

  • 验证 selector 带有 DevTools (F12)
  • 添加 wait_for_selector 之前 interaction
  • Check 如果 元素 在...中 iframe

模块 不 Found

cd chrome-cdp-controller
npm install

数据来源:ClawHub ↗ · 中文优化:龙虾技能库
OpenClaw 技能定制 / 插件定制 / 私有工作流定制

免费技能或插件可能存在安全风险,如需更匹配、更安全的方案,建议联系付费定制

了解定制服务