Chrome CDP Skill - 让 AI 控制你的 live Chrome 会话

Chrome CDP Skill - 让 AI 控制你的 live Chrome 会话

项目简介

Chrome CDP Skill 让你的 AI Agent 直接访问和控制你正在运行的 Chrome 浏览器,无需额外安装浏览器、重新登录,直接使用你已经打开的标签页。

核心特性

  • 直接连接:连接到本地 Chrome,不启动新浏览器
  • 保持登录状态:可以读取你已登录的页面(Gmail、GitHub、内部工具等)
  • 实时交互:与你正在工作的标签页交互
  • 稳定可靠:支持 100+ 标签页,比 Puppeteer 方案更稳定

安装方式

作为 pi skill

pi install git:github.com/pasky/chrome-cdp-skill@v1.0.1

其他 Agent(Amp, Claude Code, Cursor 等)

克隆或复制 skills/chrome-cdp/ 目录到 Agent 加载 skills 的位置。唯一依赖是 Node.js 22+,无需 npm install。

启用 Chrome 远程调试

  1. 打开 chrome://inspect/#remote-debugging
  2. 打开开关即可

支持自动检测 macOS 和 Linux 上的 Chrome、Chromium、Brave、Edge 和 Vivaldi。

使用方法

# 列出打开的标签页
scripts/cdp.mjs list

# 截图
scripts/cdp.mjs shot <target>

# 获取页面可访问性树
scripts/cdp.mjs snap <target>

# 获取 HTML(可指定 CSS 选择器)
scripts/cdp.mjs html <target> [".selector"]

# 在页面中执行 JS
scripts/cdp.mjs eval <target> "expression"

# 导航到 URL
scripts/cdp.mjs nav <target> https://...

# 获取网络请求信息
scripts/cdp.mjs net <target>

# 点击元素
scripts/cdp.mjs click <target> "selector"

# 坐标点击
scripts/cdp.mjs clickxy <target> <x> <y>

# 输入文字
scripts/cdp.mjs type <target> "text"

# 循环点击"加载更多"
scripts/cdp.mjs loadall <target> "selector"

# 停止守护进程
scripts/cdp.mjs stop [target]

为什么比 chrome-devtools-mcp 更好?

  • chrome-devtools-mcp 每次命令都重连,导致”允许调试”弹窗反复出现
  • chrome-cdp 为每个标签页保持一个持久守护进程,弹窗只出现一次
  • 能稳定处理 100+ 标签页

工作原理

直接连接到 Chrome 的远程调试 WebSocket,无需 Puppeteer 中介。首次访问标签页时,生成轻量级后台守护进程保持会话。守护进程在 20 分钟无活动后自动退出。


标签:#Chrome #CDP #AI #浏览器自动化

Star:1,257 ⭐ | Fork:64

传送门:https://github.com/pasky/chrome-cdp-skill