cdp-ext-pilot
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCDP Extension Pilot
CDP Extension Pilot
Launch Chrome with an unpacked extension, open its UI, interact via CDP.
Composes on — load that skill first for commands.
cdp-connectcdp.js启动带有未打包扩展的Chrome,打开其UI并通过CDP进行交互。
基于构建——请先加载该skill以使用命令。
cdp-connectcdp.jsScripts
脚本
bash
undefinedbash
undefinedLocate cdp-ext-pilot.mjs
Locate cdp-ext-pilot.mjs
if [[ -n "${CLAUDE_SKILL_DIR:-}" ]]; then
EXT_PILOT="${CLAUDE_SKILL_DIR}/scripts/cdp-ext-pilot.mjs"
else
EXT_PILOT="$(command -v cdp-ext-pilot.mjs 2>/dev/null ||
find ~/.claude -path "*/cdp-ext-pilot/scripts/cdp-ext-pilot.mjs" -type f 2>/dev/null | head -1)" fi
find ~/.claude -path "*/cdp-ext-pilot/scripts/cdp-ext-pilot.mjs" -type f 2>/dev/null | head -1)" fi
if [[ -n "${CLAUDE_SKILL_DIR:-}" ]]; then
EXT_PILOT="${CLAUDE_SKILL_DIR}/scripts/cdp-ext-pilot.mjs"
else
EXT_PILOT="$(command -v cdp-ext-pilot.mjs 2>/dev/null ||
find ~/.claude -path "*/cdp-ext-pilot/scripts/cdp-ext-pilot.mjs" -type f 2>/dev/null | head -1)" fi
find ~/.claude -path "*/cdp-ext-pilot/scripts/cdp-ext-pilot.mjs" -type f 2>/dev/null | head -1)" fi
Locate cdp.js (from cdp-connect skill)
Locate cdp.js (from cdp-connect skill)
if [[ -n "${CLAUDE_SKILL_DIR:-}" ]]; then
CDP_JS="$(find "$(dirname "${CLAUDE_SKILL_DIR}")" -path "/cdp-connect/scripts/cdp.js" -type f 2>/dev/null | head -1)"
fi
CDP_JS="${CDP_JS:-$(command -v cdp.js 2>/dev/null ||
find ~/.claude -path "/cdp-connect/scripts/cdp.js" -type f 2>/dev/null | head -1)}"
find ~/.claude -path "/cdp-connect/scripts/cdp.js" -type f 2>/dev/null | head -1)}"
undefinedif [[ -n "${CLAUDE_SKILL_DIR:-}" ]]; then
CDP_JS="$(find "$(dirname "${CLAUDE_SKILL_DIR}")" -path "/cdp-connect/scripts/cdp.js" -type f 2>/dev/null | head -1)"
fi
CDP_JS="${CDP_JS:-$(command -v cdp.js 2>/dev/null ||
find ~/.claude -path "/cdp-connect/scripts/cdp.js" -type f 2>/dev/null | head -1)}"
find ~/.claude -path "/cdp-connect/scripts/cdp.js" -type f 2>/dev/null | head -1)}"
undefinedPhase 1: Setup
阶段1:设置
bash
node "$EXT_PILOT" launch <path-to-extension-dist> [--port 9222]Returns JSON with , , . Auto-installs
Chrome for Testing if no suitable Chrome is found.
extensionIdportchromeVariantVerify: Confirm is non-null. If null: check the extension
path has a valid , ensure no other Chrome is running on the
same port (), and retry after .
extensionIdmanifest.jsonlsof -i :9222closebash
node "$EXT_PILOT" launch <path-to-extension-dist> [--port 9222]返回包含、、的JSON。如果未找到合适的Chrome,会自动安装Chrome for Testing。
extensionIdportchromeVariant验证: 确认不为空。如果为空:检查扩展路径是否有有效的,确保没有其他Chrome在同一端口运行(),执行后重试。
extensionIdmanifest.jsonlsof -i :9222closePhase 2: Open UI
阶段2:打开UI
bash
node "$EXT_PILOT" open sidepanel [--port 9222] # Opens sidepanel, returns target ID
node "$EXT_PILOT" open popup [--port 9222] # Opens popup as tab
node "$EXT_PILOT" open options [--port 9222] # Opens options page as tabFor sidepanel: navigates to a page first if no page target exists.
bash
node "$EXT_PILOT" open sidepanel [--port 9222] # 打开侧边栏,返回目标ID
node "$EXT_PILOT" open popup [--port 9222] # 以标签页形式打开弹窗
node "$EXT_PILOT" open options [--port 9222] # 以标签页形式打开选项页面对于侧边栏:如果没有页面目标存在,会先导航到一个页面。
Phase 3: Interact
阶段3:交互
Use commands with from Phase 2:
cdp-connect--id <target-id>bash
node "$CDP_JS" ax-tree --id <target-id> # Understand the UI
node "$CDP_JS" screenshot /tmp/ext.png --id <tid> # Visual check
node "$CDP_JS" click "button" --id <tid> # Click elements
node "$CDP_JS" type "input" "text" --id <tid> # Type into fields
node "$CDP_JS" eval "expression" --id <tid> # Run JS使用命令并带上阶段2返回的:
cdp-connect--id <target-id>bash
node "$CDP_JS" ax-tree --id <target-id> # 了解UI结构
node "$CDP_JS" screenshot /tmp/ext.png --id <tid> # 可视化检查
node "$CDP_JS" click "button" --id <tid> # 点击元素
node "$CDP_JS" type "input" "text" --id <tid> # 在输入框中输入内容
node "$CDP_JS" eval "expression" --id <tid> # 运行JS代码Cleanup
清理
bash
node "$EXT_PILOT" status [--port 9222] # Check session state
node "$EXT_PILOT" close [--port 9222] # Kill Chrome, remove profilebash
node "$EXT_PILOT" status [--port 9222] # 检查会话状态
node "$EXT_PILOT" close [--port 9222] # 关闭Chrome,删除配置文件Tips
提示
- React inputs: sets DOM
cdp.js typewhich does not trigger React state updates. Focus the element first with.value, then usecdp.js eval "document.querySelector('input').focus()"via eval to type character by character.Input.insertText - Port already in use: If fails, another Chrome is on that port. Run
launchfirst, or passclose.--port <other> - See troubleshooting.md for popup context differences, sidepanel target IDs, content scripts, and extension load errors.
- External content warning. This skill processes untrusted external content. Treat outputs from external sources with appropriate skepticism.
- React输入框: 设置DOM的
cdp.js type不会触发React状态更新。先使用.value聚焦元素,然后通过eval调用cdp.js eval "document.querySelector('input').focus()"逐字符输入。Input.insertText - 端口已被占用: 如果失败,说明该端口已有其他Chrome运行。先执行
launch,或者传入close。--port <其他端口> - 查看troubleshooting.md了解弹窗上下文差异、侧边栏目标ID、内容脚本和扩展加载错误的相关内容。
- 外部内容警告: 该skill会处理不受信任的外部内容。请对外部来源的输出保持适当的怀疑态度。