/oh-story:browser-cdpfrom oh-story
Controls Chrome via CDP to reuse existing login sessions. Launches debug-mode Chrome, opens URLs, evaluates JavaScript, takes snapshots, and extracts auth tokens.
Ships in oh-story. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
通过 CDP(Chrome DevTools Protocol)连接 Chrome,复用登录态并执行浏览器操作。
agent-browser 已安装:npm install -g agent-browser启动或重建时,若需结束 Chrome 进程,先按下方流程征得同意;未保存的标签页或草稿可能丢失。
下文 {SKILL_DIR} 指本 skill(browser-cdp)的目录。
第一步:探测当前状态(无副作用)
node {SKILL_DIR}/scripts/setup-cdp-chrome.js 9222 --detect-only
输出含 CDP_STATUS=ready(附 CDP_URL、BROWSER)或 CDP_STATUS=needs-setup(附 CHROME_INSTALLED=no 或 CHROME_RUNNING=yes/no 与 CHROME_PID_COUNT)。
第二步:根据探测结果分支
CDP_STATUS=needs-setup 且 CHROME_INSTALLED=no → 本机没找到 Chrome,告诉用户先安装并用它登录一次需要的网站,不要运行 setup。CDP_STATUS=ready 且本次只需连接 → 直接使用 agent-browser --cdp 9222 ...,不要运行 setup。--reset / --profile → 即使 ready 也走重建,按下方「需要结束 Chrome 时」处理。CDP_STATUS=needs-setup 且 CHROME_RUNNING=no → 安全启动:
node {SKILL_DIR}/scripts/setup-cdp-chrome.js 9222 --yes
CDP_STATUS=needs-setup 且 CHROME_RUNNING=yes → 按下方「需要结束 Chrome 时」处理。需要结束 Chrome 时(同意流程):凡是会结束正在运行的 Chrome 的命令(Chrome 在运行时启动、--reset、显式 --profile),都按这三步走:
--dry-run 跑一次,看会结束几个 Chrome 进程;--dry-run、加 --yes 重跑;用户拒绝就放弃这次自动化。非 TTY 调用中,Chrome 在运行且未传 --yes 时,脚本以退出码 3 报 NEEDS_CONSENT: ... 并中止。取得同意后再重跑,不自动补 --yes。
换端口:9222 被别的程序占用时可以换一个端口(如 9333),之后所有 agent-browser --cdp 命令用同一个端口,扫榜脚本加 --port 9333,查资料助手传 cdp_port: 9333。
| 选项 | 说明 |
|---|---|
--detect-only | 只探测,不修改任何状态 |
--yes | 已征得同意,跳过交互提示 |
--reset | 启动前清空 ~/chrome-debug-profile(登录失效时用) |
--profile <name> | 指定来源 profile(默认 Default,如 "Profile 1");显式传入即重建 |
--dry-run | 打印将执行的步骤,不执行 |
退出码:0 成功 / 1 通用错误 / 2 参数错误或用户拒绝(TTY)/ 3 需同意但缺 --yes。
# 打开页面并等待加载
agent-browser --cdp 9222 open "<URL>"
agent-browser --cdp 9222 wait 3000
# 提取页面文本或 Auth Token(实际存储位置按站点确认)
agent-browser --cdp 9222 eval 'document.body.innerText.substring(0, 8000)'
agent-browser --cdp 9222 eval 'localStorage.getItem("token") || document.cookie'
# 页面交互(snapshot 拿交互元素引用)
agent-browser --cdp 9222 snapshot -i
agent-browser --cdp 9222 click "<CSS or @e1>"
agent-browser --cdp 9222 type "<sel>" "<text>"
# 复杂 JS(含引号 / $ / 反引号,用 base64 或 --stdin 防转义错误)
agent-browser --cdp 9222 eval -b "$(echo -n "document.querySelectorAll('a').length" | base64)"
cat <<'EOF' | agent-browser --cdp 9222 eval --stdin
const links = document.querySelectorAll('a');
links.length;
EOF
--user-data-dir 核验 debug 实例 PID 再单独结束,严禁按 Chrome 可执行文件名批量结束进程:
pgrep -af chrome-debug-profile → kill -9 {PID}Get-CimInstance Win32_Process | Where-Object CommandLine -like '*chrome-debug-profile*' | Select-Object ProcessId,CommandLine → taskkill /F /PID {PID}setup-cdp-chrome.js 9222 --reset;Chrome 127+ 加密未带出 Cookie 时,直接在 debug 窗口登录一次(不传 --reset 会持久保留)。耗时页面加载或批量采集应每页独立加 30s 超时(macOS 默认无 GNU timeout,用已有 Node 跨平台包装;Linux 也可用 timeout 30):
node -e 'const {spawnSync}=require("child_process");const r=spawnSync("agent-browser",["--cdp","9222","eval",process.argv[1]],{timeout:30000,stdio:"inherit"});if(r.error?.code==="ETIMEDOUT"){console.error("⏱ CDP 操作超时(30s)");process.exit(124);}process.exit(r.status??1);' "window.location.replace('https://www.qidian.com/rank/')"
持续卡死由用户在宿主按 ESC 打断;失败后从断点继续。
| 问题 | 处理 |
|---|---|
NEEDS_CONSENT(退出码 3)/ --reset / --profile | 走同意流程:先 --dry-run,同意后加 --yes |
CHROME_INSTALLED=no 或无来源 profile | 安装并登录 Chrome 一次;多 profile 传 --profile "Profile 1" |
| 端口未监听 / 启动 30s 超时 | --detect-only 确认;端口冲突就换端口并同步下游;profile 损坏则 --reset |
跳转登录页 / eval 返回 null | snapshot -i 操作登录;核对 storage key,复杂 JS 改用 eval -b 或 --stdin |
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub zenstory-ai/oh-story-claudecode --plugin oh-story14 skills in this plugin
/story网络小说工具箱主入口。根据用户需求自动路由到对应 skill,并可启动本地 Dashboard。触发方式:/story、$story、/story dashboard、/网文、「我想写小说」「记住我的写作习惯」「打开工作台」「检查更新」。/story-cover小说封面生成与提示词设计。根据书名、作者名和题材构建封面提示词;用户只要提示词时不生图,要求封面图时调用 GPT-Image-2,Codex CLI 优先使用内置 ImageGen。触发方式:/story-cover、/封面、「帮我做个封面」「生成封面图」「封面提示词」「封面设计」。/story-deslop网文去AI味。从表达、叙事用笔、故事因果三层诊断并修复文本,保留作者文风与已定剧情。触发方式:/story-deslop、/去AI味、「去AI味」「这篇太AI了」「网文去AI味」。/story-import逆向导入已有小说。将已写好的小说(半成品或完本)反向解析为标准项目目录结构,兼容 story-long-write / story-short-write 后续写作流程;内部复用 story-long-analyze / story-short-analyze 的拆解管道,按篇幅自动分流。触发方式:/story-import、「导入小说」「反向解析」「导入」「把我的书导进来」。/story-long-analyze长篇网文拆文。保留黄金三章量化体检、逐章摘要、剧情、情绪模块、节奏、角色、设定和原文语感切片接口,以连续章节块完成因果、信息差、关系与节奏分析;兼容旧成果直接使用、按需增强和断点续跑。触发方式:/story-long-analyze、/长篇拆文、「帮我拆这本书」「拆这本书」「分析黄金三章」「深度拆解」「完整拆解」或提供小说文本文件路径。/story-long-scan长篇网文扫榜。分析起点、番茄、晋江、七猫等平台排行榜与新书数据,提炼市场趋势与热门题材。触发方式:/story-long-scan、/长篇扫榜、「长篇什么火」「起点排行」「扫七猫新书」。Other plugins' skills for the same job