mini-browser
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesemini-browser (mb) — Browser CLI for Agents
mini-browser (mb) — 面向Agent的浏览器CLI
mbmbSetup (only if not already available)
安装配置(仅当未就绪时需要)
Setup is only needed when is not installed or Chrome is not reachable.
Run these checks first — if both pass, skip straight to the Command Reference.
mb仅当未安装或无法连接到Chrome时,才需要进行配置。先运行以下检查——如果两项都通过,可直接跳至命令参考部分。
mbCheck if ready
检查是否就绪
bash
undefinedbash
undefined1. Is mb installed?
1. Is mb installed?
which mb && echo "mb: ok" || echo "mb: MISSING"
which mb && echo "mb: ok" || echo "mb: MISSING"
2. Is Chrome listening on CDP?
2. Is Chrome listening on CDP?
curl -sf http://127.0.0.1:9222/json/version > /dev/null && echo "chrome: ok" || echo "chrome: NOT RUNNING"
If **both** print "ok", everything is ready — go use `mb` commands directly.curl -sf http://127.0.0.1:9222/json/version > /dev/null && echo "chrome: ok" || echo "chrome: NOT RUNNING"
如果**两项**都输出“ok”,则一切就绪——可直接使用`mb`命令。Install (only if mb
is missing)
mb安装(仅当mb
缺失时)
mbbash
npm install -g @runablehq/mini-browserbash
npm install -g @runablehq/mini-browserStart Chrome (only if not running)
启动Chrome(仅当未运行时)
bash
mb-start-chromeThis launches Chrome with , a fresh profile, and a
1024×768 window. It no-ops if Chrome is already running.
--remote-debugging-port=9222To kill and relaunch:
bash
mb-restart-chromebash
mb-start-chrome该命令会启动Chrome,并启用参数,使用全新配置文件,窗口大小为1024×768。如果Chrome已在运行,该命令不会执行任何操作。
--remote-debugging-port=9222如需重启Chrome:
bash
mb-restart-chromeVerify
验证
bash
mb go "https://example.com" && mb textbash
mb go "https://example.com" && mb textEnvironment Variables
环境变量
| Variable | Default | Description |
|---|---|---|
| | CDP port |
| auto-detected | Path to Chrome/Chromium binary |
| | PID file location |
| | Chrome profile directory |
| 变量名 | 默认值 | 描述 |
|---|---|---|
| | CDP端口 |
| 自动检测 | Chrome/Chromium二进制文件路径 |
| | PID文件位置 |
| | Chrome配置文件目录 |
Command Reference
命令参考
Navigation
导航
| Command | Description |
|---|---|
| Navigate to URL (waits for networkidle) |
| Print current URL |
| Go back |
| Go forward |
| 命令 | 描述 |
|---|---|
| 导航至指定URL(等待网络空闲) |
| 打印当前URL |
| 返回上一页 |
| 前进至下一页 |
Observation
页面观测
| Command | Description |
|---|---|
| Visible text content (default: body) |
| Screenshot to PNG (default: ./shot.png) |
| List interactive elements with coordinates |
| 命令 | 描述 |
|---|---|
| 获取可见文本内容(默认:body元素) |
| 截取屏幕截图保存为PNG(默认:./shot.png) |
| 列出当前视口中的可交互元素及其坐标 |
Interaction
页面交互
| Command | Description |
|---|---|
| Click at coordinates |
| Type text (with coords: selects first) |
| Fill form fields by label/name/placeholder |
| Press keys (Enter, Tab, Meta+a) |
| Hover at coordinates |
| Drag between points |
| Scroll (default: down 500) |
| 命令 | 描述 |
|---|---|
| 在指定坐标位置点击 |
| 输入文本(若指定坐标:先选中第一个匹配元素) |
| 通过标签/名称/占位符填充表单字段 |
| 按下指定按键(Enter、Tab、Meta+a等) |
| 将鼠标悬停在指定坐标位置 |
| 在两点之间拖拽 |
| 滚动页面(默认:向下滚动500像素) |
Recording
录制功能
| Command | Description |
|---|---|
| Start recording (.webm, .mp4, .gif) |
| Stop recording and save |
| Check if recording is active |
| 命令 | 描述 |
|---|---|
| 开始录制(支持.webm、.mp4、.gif格式) |
| 停止录制并保存文件 |
| 检查录制是否处于活跃状态 |
Tabs
标签页管理
| Command | Description |
|---|---|
| List open tabs |
| Open new tab, print index |
| Close tab (default: last) |
| 命令 | 描述 |
|---|---|
| 列出所有打开的标签页 |
| 新建标签页,返回标签页索引 |
| 关闭指定标签页(默认:最后一个标签页) |
Other
其他命令
| Command | Description |
|---|---|
| Run JavaScript in page context |
| Wait for ms / selector / networkidle / url:pattern |
| Design audit (palette, typography, contrast, a11y, SEO) |
| Stream console logs (Ctrl+C to stop) |
| 命令 | 描述 |
|---|---|
| 在页面上下文环境中运行JavaScript代码 |
| 等待指定时长/选择器出现/网络空闲/URL匹配模式 |
| 设计审核(包含调色板、排版、对比度、可访问性、SEO等) |
| 流式输出控制台日志(按Ctrl+C停止) |
Flags
标志位
| Flag | Default | Description |
|---|---|---|
| 30000 | Command timeout |
| 0 | Target tab index |
| false | Structured JSON output |
| false | Right-click |
| false | Double-click |
| 30 | Recording frame rate |
| 1 | Recording scale factor |
| 标志位 | 默认值 | 描述 |
|---|---|---|
| 30000 | 命令超时时间 |
| 0 | 目标标签页索引 |
| false | 输出结构化JSON格式 |
| false | 右键点击 |
| false | 双击 |
| 30 | 录制帧率 |
| 1 | 录制缩放比例 |
Usage Patterns
使用模式
Observe → Act loop
观测→操作循环
The standard agent loop: snapshot the page, pick an element, act on it.
bash
mb snap # list interactive elements with (x, y)
mb click 512 380 # click the button at those coordinates
mb wait networkidle # wait for the page to settle
mb snap # observe again标准Agent工作流:快照页面,选择元素,执行操作。
bash
mb snap # list interactive elements with (x, y)
mb click 512 380 # click the button at those coordinates
mb wait networkidle # wait for the page to settle
mb snap # observe againFill and submit a form
填写并提交表单
bash
mb go "https://example.com/login"
mb fill "Email=user@example.com" "Password=hunter2"
mb key Enter
mb wait url:/dashboardbash
mb go "https://example.com/login"
mb fill "Email=user@example.com" "Password=hunter2"
mb key Enter
mb wait url:/dashboardTake a screenshot
截取屏幕截图
bash
mb shot page.pngbash
mb shot page.pngExtract text
提取文本
bash
mb text "main" # text from <main>
mb text "#content" # text from #content
mb text # full body textbash
mb text "main" # text from <main>
mb text "#content" # text from #content
mb text # full body textRun JavaScript
运行JavaScript代码
bash
mb js 'document.title'
echo 'document.querySelectorAll("a").length' | mb js -bash
mb js 'document.title'
echo 'document.querySelectorAll("a").length' | mb js -Record a screencast
录制屏幕视频
bash
mb record start demo.mp4 --fps 30 --scale 1bash
mb record start demo.mp4 --fps 30 --scale 1... interact with the page ...
... interact with the page ...
mb record stop
undefinedmb record stop
undefinedDesign audit
设计审核
bash
mb audit # human-readable report
mb audit --json # structured JSON outputbash
mb audit # human-readable report
mb audit --json # structured JSON outputDismiss overlays
移除弹窗
Cookie banners and modals block clicks. Remove them with JS:
bash
mb js 'document.querySelector("[class*=cookie]")?.remove()'Cookie提示框和模态框会阻止点击操作。可通过JS移除:
bash
mb js 'document.querySelector("[class*=cookie]")?.remove()'Wait strategies
等待策略
bash
mb wait 2000 # sleep 2 seconds
mb wait ".modal" # wait for selector to appear
mb wait networkidle # wait for no network activity
mb wait url:/dashboard # wait for URL to contain stringbash
mb wait 2000 # sleep 2 seconds
mb wait ".modal" # wait for selector to appear
mb wait networkidle # wait for no network activity
mb wait url:/dashboard # wait for URL to contain stringImportant Notes
重要说明
- Viewport is 1024×768. only returns elements in the current viewport — scroll and snap again to find more.
snap - uses querySelector — returns first match only. Use
textovertext "main"for better results.text "p" - waits for networkidle. For heavy SPAs, follow up with
go.wait ".selector" - with coordinates triple-clicks first to select existing text, then types the replacement.
type - field matching order: aria-label → placeholder → name attr → id → label text → CSS selector (use
fill/#/.prefix).[ - output:
--json→snap,[{role, name, x, y, state}]→tab list,[{index, url, title}]→ JSON lines,logs→ full audit object.audit - Recording state is stored in . Only one recording at a time.
~/.mb-recorder.json - cannot close the last remaining tab.
tab close
- 视口大小为1024×768。命令仅返回当前视口中的元素——如需查找更多元素,可先滚动页面再执行
snap。snap - 命令使用querySelector——仅返回第一个匹配结果。建议使用
text而非text "main"以获得更准确的结果。text "p" - 命令会等待网络空闲。对于复杂的SPA应用,可在之后执行
go等待元素加载完成。wait ".selector" - 指定坐标的命令会先三击选中现有文本,然后输入替换内容。
type - 命令的字段匹配顺序:aria-label → placeholder → name属性 → id → 标签文本 → CSS选择器(使用#/./[前缀)。
fill - 格式输出:
--json→snap,[{role, name, x, y, state}]→tab list,[{index, url, title}]→ JSON行,logs→ 完整的审核对象。audit - 录制状态存储在中。同一时间只能进行一个录制任务。
~/.mb-recorder.json - 命令无法关闭最后一个剩余的标签页。
tab close
Troubleshooting
故障排除
| Problem | Fix |
|---|---|
| "Chrome not found" | Set |
| Connection refused | Run |
| Stale recording state | Delete |
| Chrome window wrong size | |
| Element not in snap output | |
| 问题 | 解决方法 |
|---|---|
| "Chrome not found" | 设置环境变量 |
| 连接被拒绝 | 先运行 |
| 录制状态异常 | 删除文件 |
| Chrome窗口大小异常 | 执行 |
元素未出现在 | 执行 |