chrome-cdp by pasky/chrome-cdp-skill
npx skills add https://github.com/pasky/chrome-cdp-skill --skill chrome-cdp轻量级 Chrome DevTools Protocol 命令行工具。通过 WebSocket 直接连接 —— 无需 Puppeteer,支持 100+ 个标签页,即时连接。
chrome://inspect/#remote-debugging 并切换开关DevToolsActivePort 位于非标准位置,请将 CDP_PORT_FILE 设置为其完整路径所有命令都使用 scripts/cdp.mjs。<target> 是来自 list 命令的唯一 targetId 前缀;请复制 list 输出中显示的完整前缀(例如 6BE827FA)。CLI 会拒绝不明确的前缀。
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
scripts/cdp.mjs list
scripts/cdp.mjs shot <target> [file] # 默认:在运行时目录下生成 screenshot-<target>.png
仅捕获视口。如果需要捕获首屏以下的内容,请先用 eval 滚动页面。输出包含页面的 DPR 和坐标转换提示(见下文坐标部分)。
scripts/cdp.mjs snap <target>
scripts/cdp.mjs eval <target> <expr>
注意: 当 DOM 可能在多次
eval调用之间发生变化时(例如点击“忽略”后,卡片索引会移动),应避免使用基于索引的选择(querySelectorAll(...)[i])。请在一次eval中收集所有数据,或使用稳定的选择器。
scripts/cdp.mjs html <target> [selector] # 获取整个页面或元素的 HTML
scripts/cdp.mjs nav <target> <url> # 导航到 URL 并等待加载完成
scripts/cdp.mjs net <target> # 资源计时条目
scripts/cdp.mjs click <target> <selector> # 通过 CSS 选择器点击元素
scripts/cdp.mjs clickxy <target> <x> <y> # 在 CSS 像素坐标处点击
scripts/cdp.mjs type <target> <text> # 在当前焦点处插入文本;与 eval 不同,可在跨域 iframe 中工作
scripts/cdp.mjs loadall <target> <selector> [ms] # 点击“加载更多”直到消失(默认点击间隔 1500 毫秒)
scripts/cdp.mjs evalraw <target> <method> [json] # 原始 CDP 命令透传
scripts/cdp.mjs open [url] # 打开新标签页(每次都会触发“允许”提示)
scripts/cdp.mjs stop [target] # 停止守护进程
shot 以原生分辨率保存图像:图像像素 = CSS 像素 × DPR。CDP 输入事件(clickxy 等)使用 CSS 像素。
CSS 像素 = 截图图像像素 / DPR
shot 会打印当前页面的 DPR。典型的 Retina 屏幕(DPR=2):将截图坐标除以 2。
snap --compact 而非 html。type(而非 eval)—— 先用 click/clickxy 聚焦,然后使用 type。每周安装量
1.0K
代码仓库
GitHub 星标数
2.6K
首次出现
12 天前
安全审计
安装于
codex988
opencode982
gemini-cli977
cursor976
github-copilot975
cline974
Lightweight Chrome DevTools Protocol CLI. Connects directly via WebSocket — no Puppeteer, works with 100+ tabs, instant connection.
chrome://inspect/#remote-debugging and toggle the switchDevToolsActivePort is in a non-standard location, set CDP_PORT_FILE to its full pathAll commands use scripts/cdp.mjs. The <target> is a unique targetId prefix from list; copy the full prefix shown in the list output (for example 6BE827FA). The CLI rejects ambiguous prefixes.
scripts/cdp.mjs list
scripts/cdp.mjs shot <target> [file] # default: screenshot-<target>.png in runtime dir
Captures the viewport only. Scroll first with eval if you need content below the fold. Output includes the page's DPR and coordinate conversion hint (see Coordinates below).
scripts/cdp.mjs snap <target>
scripts/cdp.mjs eval <target> <expr>
Watch out: avoid index-based selection (
querySelectorAll(...)[i]) across multipleevalcalls when the DOM can change between them (e.g. after clicking Ignore, card indices shift). Collect all data in oneevalor use stable selectors.
scripts/cdp.mjs html <target> [selector] # full page or element HTML
scripts/cdp.mjs nav <target> <url> # navigate and wait for load
scripts/cdp.mjs net <target> # resource timing entries
scripts/cdp.mjs click <target> <selector> # click element by CSS selector
scripts/cdp.mjs clickxy <target> <x> <y> # click at CSS pixel coords
scripts/cdp.mjs type <target> <text> # Input.insertText at current focus; works in cross-origin iframes unlike eval
scripts/cdp.mjs loadall <target> <selector> [ms] # click "load more" until gone (default 1500ms between clicks)
scripts/cdp.mjs evalraw <target> <method> [json] # raw CDP command passthrough
scripts/cdp.mjs open [url] # open new tab (each triggers Allow prompt)
scripts/cdp.mjs stop [target] # stop daemon(s)
shot saves an image at native resolution: image pixels = CSS pixels × DPR. CDP Input events (clickxy etc.) take CSS pixels.
CSS px = screenshot image px / DPR
shot prints the DPR for the current page. Typical Retina (DPR=2): divide screenshot coords by 2.
snap --compact over html for page structure.type (not eval) to enter text in cross-origin iframes — click/clickxy to focus first, then type.Weekly Installs
1.0K
Repository
GitHub Stars
2.6K
First Seen
12 days ago
Security Audits
Gen Agent Trust HubPassSocketPassSnykWarn
Installed on
codex988
opencode982
gemini-cli977
cursor976
github-copilot975
cline974
React 组合模式指南:Vercel 组件架构最佳实践,提升代码可维护性
102,200 周安装