@nntoan/bb-browser 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,249 @@
1
+ <div align="center">
2
+
3
+ # bb-browser
4
+
5
+ ### BadBoy Browser
6
+
7
+ **Your browser is the API. No keys. No bots. No scrapers.**
8
+
9
+ [![npm](https://img.shields.io/npm/v/bb-browser?color=CB3837&logo=npm&logoColor=white)](https://www.npmjs.com/package/bb-browser)
10
+ [![Node.js](https://img.shields.io/badge/Node.js-18+-339933?logo=node.js&logoColor=white)](https://nodejs.org)
11
+ [![License](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
12
+
13
+ [English](README.md) · [中文](README.zh-CN.md)
14
+
15
+ </div>
16
+
17
+ ---
18
+
19
+ You're already logged into Twitter, Reddit, YouTube, Zhihu, Bilibili, LinkedIn, GitHub — bb-browser lets AI agents **use that directly**.
20
+
21
+ ```bash
22
+ bb-browser site twitter/search "AI agent" # search tweets
23
+ bb-browser site zhihu/hot # trending on Zhihu
24
+ bb-browser site arxiv/search "transformer" # search papers
25
+ bb-browser site eastmoney/stock "茅台" # real-time stock quote
26
+ bb-browser site boss/search "AI engineer" # search jobs
27
+ bb-browser site wikipedia/summary "Python" # Wikipedia summary
28
+ bb-browser site youtube/transcript VIDEO_ID # full transcript
29
+ bb-browser site stackoverflow/search "async" # search SO questions
30
+ ```
31
+
32
+ **103 commands across 36 platforms.** All using your real browser's login state. [Full list →](https://github.com/epiral/bb-sites)
33
+
34
+ ## The idea
35
+
36
+ The internet was built for browsers. AI agents have been trying to access it through APIs — but 99% of websites don't offer one.
37
+
38
+ bb-browser flips this: **instead of forcing websites to provide machine interfaces, let machines use the human interface directly.** The adapter runs `eval` inside your browser tab, calls `fetch()` with your cookies, or invokes the page's own webpack modules. The website thinks it's you. Because it **is** you.
39
+
40
+ | | Playwright / Selenium | Scraping libs | bb-browser |
41
+ |---|---|---|---|
42
+ | Browser | Headless, isolated | No browser | Your real Chrome |
43
+ | Login state | None, must re-login | Cookie extraction | Already there |
44
+ | Anti-bot | Detected easily | Cat-and-mouse | Invisible — it IS the user |
45
+ | Complex auth | Can't replicate | Reverse engineer | Page handles it itself |
46
+
47
+ ## Quick Start
48
+
49
+ ### Install
50
+
51
+ ```bash
52
+ npm install -g bb-browser
53
+ ```
54
+
55
+ ### Use
56
+
57
+ ```bash
58
+ bb-browser site update # pull community adapters
59
+ bb-browser site recommend # see which adapters match your browsing habits
60
+ bb-browser site zhihu/hot # go
61
+ ```
62
+
63
+ ### OpenClaw (no extension needed)
64
+
65
+ If you use [OpenClaw](https://openclaw.ai), bb-browser runs directly through OpenClaw's built-in browser — no Chrome extension or daemon required:
66
+
67
+ ```bash
68
+ bb-browser site reddit/hot --openclaw
69
+ bb-browser site xueqiu/hot-stock 5 --openclaw --jq '.items[] | {name, changePercent}'
70
+ ```
71
+
72
+ Skill on ClawHub: [bb-browser-openclaw](https://clawhub.ai/yan5xu/bb-browser)
73
+
74
+ ### Chrome Extension (standalone mode)
75
+
76
+ For use without OpenClaw (Claude Code MCP, standalone CLI):
77
+
78
+ 1. Download from [Releases](https://github.com/epiral/bb-browser/releases/latest)
79
+ 2. Unzip → `chrome://extensions/` → Developer Mode → Load unpacked
80
+
81
+ ### MCP (Claude Code / Cursor)
82
+
83
+ ```json
84
+ {
85
+ "mcpServers": {
86
+ "bb-browser": {
87
+ "command": "npx",
88
+ "args": ["-y", "bb-browser", "--mcp"]
89
+ }
90
+ }
91
+ }
92
+ ```
93
+
94
+ ## 36 platforms, 103 commands
95
+
96
+ Community-driven via [bb-sites](https://github.com/epiral/bb-sites). One JS file per command.
97
+
98
+ | Category | Platforms | Commands |
99
+ |----------|-----------|----------|
100
+ | **Search** | Google, Baidu, Bing, DuckDuckGo, Sogou WeChat | search |
101
+ | **Social** | Twitter/X, Reddit, Weibo, Xiaohongshu, Jike, LinkedIn, Hupu | search, feed, thread, user, notifications, hot |
102
+ | **News** | BBC, Reuters, 36kr, Toutiao, Eastmoney | headlines, search, newsflash, hot |
103
+ | **Dev** | GitHub, StackOverflow, HackerNews, CSDN, cnblogs, V2EX, Dev.to, npm, PyPI, arXiv | search, issues, repo, top, thread, package |
104
+ | **Video** | YouTube, Bilibili | search, video, transcript, popular, comments, feed |
105
+ | **Entertainment** | Douban, IMDb, Genius, Qidian | movie, search, top250 |
106
+ | **Finance** | Xueqiu, Eastmoney, Yahoo Finance | stock, hot stocks, feed, watchlist, search |
107
+ | **Jobs** | BOSS Zhipin, LinkedIn | search, detail, profile |
108
+ | **Knowledge** | Wikipedia, Zhihu, Open Library | search, summary, hot, question |
109
+ | **Shopping** | SMZDM | search deals |
110
+ | **Tools** | Youdao, GSMArena, Product Hunt, Ctrip | translate, phone specs, trending products |
111
+
112
+ ## 10 minutes to add any website
113
+
114
+ ```bash
115
+ bb-browser guide # full tutorial
116
+ ```
117
+
118
+ Tell your AI agent: *"turn XX website into a CLI"*. It reads the guide, reverse-engineers the API with `network --with-body`, writes the adapter, tests it, and submits a PR. All autonomously.
119
+
120
+ Three tiers of adapter complexity:
121
+
122
+ | Tier | Auth method | Example | Time |
123
+ |------|-------------|---------|------|
124
+ | **1** | Cookie (fetch directly) | Reddit, GitHub, V2EX | ~1 min |
125
+ | **2** | Bearer + CSRF token | Twitter, Zhihu | ~3 min |
126
+ | **3** | Webpack injection / Pinia store | Twitter search, Xiaohongshu | ~10 min |
127
+
128
+ We tested this: **20 AI agents ran in parallel, each independently reverse-engineered a website and produced a working adapter.** The marginal cost of adding a new website to the agent-accessible internet is approaching zero.
129
+
130
+ ## What this means for AI agents
131
+
132
+ Without bb-browser, an AI agent's world is: **files + terminal + a few APIs with keys.**
133
+
134
+ With bb-browser: **files + terminal + the entire internet.**
135
+
136
+ An agent can now, in under a minute:
137
+
138
+ ```bash
139
+ # Cross-platform research on any topic
140
+ bb-browser site arxiv/search "retrieval augmented generation"
141
+ bb-browser site twitter/search "RAG"
142
+ bb-browser site github search rag-framework
143
+ bb-browser site stackoverflow/search "RAG implementation"
144
+ bb-browser site zhihu/search "RAG"
145
+ bb-browser site 36kr/newsflash
146
+ ```
147
+
148
+ Six platforms, six dimensions, structured JSON. Faster and broader than any human researcher.
149
+
150
+ ## Also a full browser automation tool
151
+
152
+ ```bash
153
+ bb-browser open https://example.com
154
+ bb-browser snapshot -i # accessibility tree
155
+ bb-browser click @3 # click element
156
+ bb-browser fill @5 "hello" # fill input
157
+ bb-browser eval "document.title" # run JS
158
+ bb-browser fetch URL --json # authenticated fetch
159
+ bb-browser network requests --with-body --json # capture traffic
160
+ bb-browser screenshot # take screenshot
161
+ ```
162
+
163
+ All commands support `--json` output, `--jq <expr>` for inline filtering, and `--tab <id>` for concurrent multi-tab operations.
164
+
165
+ ```bash
166
+ bb-browser site xueqiu/hot-stock 5 --jq '.items[] | {name, changePercent}'
167
+ # {"name":"云天化","changePercent":"2.08%"}
168
+ # {"name":"东芯股份","changePercent":"-7.60%"}
169
+
170
+ bb-browser site info xueqiu/stock # view adapter args, example, domain
171
+ ```
172
+
173
+ ## Daemon configuration
174
+
175
+ The daemon binds to `localhost:19824` by default. You can customize the host with `--host`:
176
+
177
+ ```bash
178
+ bb-browser daemon --host 127.0.0.1 # IPv4 only (fix macOS IPv6 issues)
179
+ bb-browser daemon --host 0.0.0.0 # listen on all interfaces (for Tailscale / ZeroTier remote access)
180
+ ```
181
+
182
+ ## Architecture
183
+
184
+ ```
185
+ AI Agent (Claude Code, Codex, Cursor, etc.)
186
+ │ CLI or MCP (stdio)
187
+
188
+ bb-browser CLI ──HTTP──▶ Daemon ──SSE──▶ Chrome Extension
189
+
190
+ ▼ chrome.debugger (CDP)
191
+ Your Real Browser
192
+ ```
193
+
194
+ ## Fork sync strategy for English-localized forks
195
+
196
+ If your fork keeps English runtime text while upstream still updates Chinese text, avoid direct long-lived manual edits during every sync.
197
+
198
+ This repo includes an overlay-based approach:
199
+
200
+ 1. Merge upstream first.
201
+ 2. Re-apply English string overlay (`pnpm overlay:english`).
202
+ 3. Validate (`pnpm lint && pnpm test`).
203
+ 4. Push sync result.
204
+
205
+ The overlay rules live in:
206
+ - `tools/english-overlay/rules.json`
207
+ - `tools/english-overlay/apply.mjs`
208
+
209
+ For automation, use workflow:
210
+ - `.github/workflows/sync-upstream-overlay.yml`
211
+
212
+ This reduces merge conflicts because your localization is generated after merge, not hand-resolved in every conflicting hunk.
213
+
214
+ Example conflict pattern and resolution:
215
+
216
+ - Upstream changes:
217
+ - `"错误:缺少 URL 参数"` → `"错误:缺少 url 参数(必填)"`
218
+ - Fork direct-edit approach:
219
+ - same line was changed to `"Error: missing URL argument"`
220
+ - next upstream merge can conflict on this hunk.
221
+ - Overlay approach:
222
+ 1. merge upstream Chinese changes first
223
+ 2. run `pnpm overlay:english`
224
+ 3. overlay rewrites to your English form again
225
+
226
+ This keeps sync friction low and avoids repeated manual conflict resolution on translated strings.
227
+
228
+ ## Publish release to your own npm registry (forks)
229
+
230
+ Workflow `.github/workflows/publish.yml` now supports custom registry publish.
231
+
232
+ Manual run (`workflow_dispatch`) inputs:
233
+ - `tag_name` (required)
234
+ - `registry_url` (default: `https://registry.npmjs.org`)
235
+ - `dist_tag` (default: `latest`)
236
+
237
+ Set one of these secrets in your fork:
238
+ - `NPM_TOKEN` (preferred)
239
+ - or `NODE_AUTH_TOKEN`
240
+
241
+ Examples:
242
+ - npmjs: `registry_url=https://registry.npmjs.org`
243
+ - GitHub Packages: `registry_url=https://npm.pkg.github.com`
244
+
245
+ If your registry requires scoped packages, update `name` in `package.json` (for example `@your-scope/bb-browser`) before publishing.
246
+
247
+ ## License
248
+
249
+ [MIT](LICENSE)
@@ -0,0 +1,196 @@
1
+ <div align="center">
2
+
3
+ # bb-browser
4
+
5
+ ### 坏孩子浏览器 BadBoy Browser
6
+
7
+ **你的浏览器就是 API。不需要密钥,不需要爬虫,不需要模拟。**
8
+
9
+ [![npm](https://img.shields.io/npm/v/bb-browser?color=CB3837&logo=npm&logoColor=white)](https://www.npmjs.com/package/bb-browser)
10
+ [![Node.js](https://img.shields.io/badge/Node.js-18+-339933?logo=node.js&logoColor=white)](https://nodejs.org)
11
+ [![License](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
12
+
13
+ [English](README.md) · [中文](README.zh-CN.md)
14
+
15
+ </div>
16
+
17
+ ---
18
+
19
+ 你已经登录了微博、知乎、B站、小红书、Twitter、GitHub、LinkedIn — bb-browser 让 AI Agent **直接用你的登录态**。
20
+
21
+ ```bash
22
+ bb-browser site twitter/search "AI agent" # 搜索推文
23
+ bb-browser site zhihu/hot # 知乎热榜
24
+ bb-browser site arxiv/search "transformer" # 搜论文
25
+ bb-browser site eastmoney/stock "茅台" # 实时股票行情
26
+ bb-browser site boss/search "AI 工程师" # 搜职位
27
+ bb-browser site wikipedia/summary "Python" # 维基百科摘要
28
+ bb-browser site youtube/transcript VIDEO_ID # YouTube 字幕全文
29
+ bb-browser site stackoverflow/search "async" # 搜 StackOverflow
30
+ ```
31
+
32
+ **36 个平台,103 个命令,全部用你真实浏览器的登录态。** [完整列表 →](https://github.com/epiral/bb-sites)
33
+
34
+ ## 核心理念
35
+
36
+ 互联网是为浏览器构建的。AI Agent 一直试图通过 API 访问它 — 但 99% 的网站不提供 API。
37
+
38
+ bb-browser 翻转了这个逻辑:**不是让网站适配机器,而是让机器使用人的界面。** adapter 在你的浏览器 tab 里跑 `eval`,用你的 Cookie 调 `fetch()`,或者直接调用页面的 webpack 模块。网站以为是你在操作。因为**就是你**。
39
+
40
+ | | Playwright / Selenium | 爬虫库 | bb-browser |
41
+ |---|---|---|---|
42
+ | 浏览器 | 无头、隔离环境 | 没有浏览器 | 你的真实 Chrome |
43
+ | 登录态 | 没有,要重新登录 | 偷 Cookie | 已经在了 |
44
+ | 反爬检测 | 容易被识别 | 猫鼠游戏 | 无法检测 — 它就是用户 |
45
+ | 复杂鉴权 | 无法复制 | 需要逆向 | 页面自己处理 |
46
+
47
+ ## 快速开始
48
+
49
+ ### 安装
50
+
51
+ ```bash
52
+ npm install -g bb-browser
53
+ ```
54
+
55
+ ### 使用
56
+
57
+ ```bash
58
+ bb-browser site update # 拉取社区适配器
59
+ bb-browser site recommend # 看看哪些和你的浏览习惯匹配
60
+ bb-browser site zhihu/hot # 开搞
61
+ ```
62
+
63
+ ### OpenClaw(无需安装扩展)
64
+
65
+ 如果你使用 [OpenClaw](https://openclaw.ai),bb-browser 可以直接通过 OpenClaw 内置浏览器运行,不需要额外安装 Chrome 扩展或 daemon:
66
+
67
+ ```bash
68
+ bb-browser site reddit/hot --openclaw
69
+ bb-browser site xueqiu/hot-stock 5 --openclaw --jq '.items[] | {name, changePercent}'
70
+ ```
71
+
72
+ ClawHub Skill: [bb-browser-openclaw](https://clawhub.ai/yan5xu/bb-browser)
73
+
74
+ ### Chrome 扩展(独立模式)
75
+
76
+ 不使用 OpenClaw 时(Claude Code MCP、独立 CLI)需要安装扩展:
77
+
78
+ 1. 从 [Releases](https://github.com/epiral/bb-browser/releases/latest) 下载 zip
79
+ 2. 解压 → `chrome://extensions/` → 开发者模式 → 加载已解压的扩展程序
80
+
81
+ ### MCP 接入(Claude Code / Cursor)
82
+
83
+ ```json
84
+ {
85
+ "mcpServers": {
86
+ "bb-browser": {
87
+ "command": "npx",
88
+ "args": ["-y", "bb-browser", "--mcp"]
89
+ }
90
+ }
91
+ }
92
+ ```
93
+
94
+ ## 36 个平台,103 个命令
95
+
96
+ 社区驱动,通过 [bb-sites](https://github.com/epiral/bb-sites) 维护。每个命令一个 JS 文件。
97
+
98
+ | 类别 | 平台 | 命令 |
99
+ |------|------|------|
100
+ | **搜索引擎** | Google、百度、Bing、DuckDuckGo、搜狗微信 | search |
101
+ | **社交媒体** | Twitter/X、Reddit、微博、小红书、即刻、LinkedIn、虎扑 | search、feed、thread、user、notifications、hot |
102
+ | **新闻资讯** | BBC、Reuters、36氪、今日头条、东方财富 | headlines、search、newsflash、hot |
103
+ | **技术开发** | GitHub、StackOverflow、HackerNews、CSDN、博客园、V2EX、Dev.to、npm、PyPI、arXiv | search、issues、repo、top、thread、package |
104
+ | **视频平台** | YouTube、B站 | search、video、transcript、popular、comments、feed |
105
+ | **影音娱乐** | 豆瓣、IMDb、Genius、起点中文网 | movie、search、top250 |
106
+ | **财经股票** | 雪球、东方财富、Yahoo Finance | stock、hot-stock、feed、watchlist、search |
107
+ | **求职招聘** | BOSS直聘、LinkedIn | search、detail、profile |
108
+ | **知识百科** | Wikipedia、知乎、Open Library | search、summary、hot、question |
109
+ | **消费购物** | 什么值得买 | search |
110
+ | **实用工具** | 有道翻译、GSMArena、Product Hunt、携程 | translate、手机参数、热门产品 |
111
+
112
+ ## 10 分钟,CLI 化任何网站
113
+
114
+ ```bash
115
+ bb-browser guide # 完整教程
116
+ ```
117
+
118
+ 跟你的 AI Agent 说:*「帮我把 XX 网站 CLI 化」*。它会读 guide,用 `network --with-body` 抓包逆向,写 adapter,测试,然后提 PR 到社区仓库。全程自动。
119
+
120
+ 三种 adapter 复杂度:
121
+
122
+ | 层级 | 认证方式 | 代表 | 耗时 |
123
+ |------|----------|------|------|
124
+ | **Tier 1** | Cookie(直接 fetch) | Reddit、GitHub、V2EX | ~1 分钟 |
125
+ | **Tier 2** | Bearer + CSRF token | Twitter、知乎 | ~3 分钟 |
126
+ | **Tier 3** | Webpack 注入 / Pinia store | Twitter 搜索、小红书 | ~10 分钟 |
127
+
128
+ 实测:**20 个 AI Agent 并发运行,每个独立逆向一个网站并产出可用的 adapter。** 将一个新网站纳入 Agent 可访问范围的边际成本趋近于零。
129
+
130
+ ## 对 AI Agent 意味着什么
131
+
132
+ 没有 bb-browser,AI Agent 的世界是:**文件系统 + 终端 + 少数有 API key 的服务。**
133
+
134
+ 有了 bb-browser:**文件系统 + 终端 + 整个互联网。**
135
+
136
+ 一个 Agent 现在可以在一分钟内:
137
+
138
+ ```bash
139
+ # 跨平台调研任何话题
140
+ bb-browser site arxiv/search "retrieval augmented generation"
141
+ bb-browser site twitter/search "RAG"
142
+ bb-browser site github search rag-framework
143
+ bb-browser site stackoverflow/search "RAG implementation"
144
+ bb-browser site zhihu/search "RAG"
145
+ bb-browser site 36kr/newsflash
146
+ ```
147
+
148
+ 六个平台,六个维度,结构化 JSON。比任何人类研究员都快、都广。
149
+
150
+ ## 同时也是完整的浏览器自动化工具
151
+
152
+ ```bash
153
+ bb-browser open https://example.com
154
+ bb-browser snapshot -i # 可访问性树
155
+ bb-browser click @3 # 点击元素
156
+ bb-browser fill @5 "hello" # 填写输入框
157
+ bb-browser eval "document.title" # 执行 JS
158
+ bb-browser fetch URL --json # 带登录态的 fetch
159
+ bb-browser network requests --with-body --json # 抓包
160
+ bb-browser screenshot # 截图
161
+ ```
162
+
163
+ 所有命令支持 `--json` 输出、`--jq <expr>` 内联过滤、和 `--tab <id>` 多标签页并发操作。
164
+
165
+ ```bash
166
+ bb-browser site xueqiu/hot-stock 5 --jq '.items[] | {name, changePercent}'
167
+ # {"name":"云天化","changePercent":"2.08%"}
168
+ # {"name":"东芯股份","changePercent":"-7.60%"}
169
+
170
+ bb-browser site info xueqiu/stock # 查看 adapter 参数、示例、域名
171
+ ```
172
+
173
+ ## Daemon 配置
174
+
175
+ Daemon 默认绑定 `localhost:19824`,可通过 `--host` 自定义监听地址:
176
+
177
+ ```bash
178
+ bb-browser daemon --host 127.0.0.1 # 仅 IPv4(解决 macOS IPv6 问题)
179
+ bb-browser daemon --host 0.0.0.0 # 监听所有网卡(用于 Tailscale / ZeroTier 跨机器访问)
180
+ ```
181
+
182
+ ## 架构
183
+
184
+ ```
185
+ AI Agent (Claude Code, Codex, Cursor 等)
186
+ │ CLI 或 MCP (stdio)
187
+
188
+ bb-browser CLI ──HTTP──▶ Daemon ──SSE──▶ Chrome 扩展
189
+
190
+ ▼ chrome.debugger (CDP)
191
+ 你的真实浏览器
192
+ ```
193
+
194
+ ## 许可证
195
+
196
+ [MIT](LICENSE)