bb-browser 0.4.2 → 0.4.3

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/dist/cli.js CHANGED
@@ -2459,6 +2459,66 @@ async function main() {
2459
2459
  await siteCommand(parsed.args, { json: parsed.flags.json, tabId: globalTabId });
2460
2460
  break;
2461
2461
  }
2462
+ case "guide": {
2463
+ console.log(`How to turn any website into a bb-browser site adapter
2464
+ =======================================================
2465
+
2466
+ 1. REVERSE ENGINEER the API
2467
+ bb-browser network clear --tab <tabId>
2468
+ bb-browser refresh --tab <tabId>
2469
+ bb-browser network requests --filter "api" --with-body --json --tab <tabId>
2470
+
2471
+ 2. TEST if direct fetch works (Tier 1)
2472
+ bb-browser eval "fetch('/api/endpoint',{credentials:'include'}).then(r=>r.json())" --tab <tabId>
2473
+
2474
+ If it works \u2192 Tier 1 (Cookie auth, like Reddit/GitHub/Zhihu/Bilibili)
2475
+ If needs extra headers \u2192 Tier 2 (like Twitter: Bearer + CSRF token)
2476
+ If needs request signing \u2192 Tier 3 (like Xiaohongshu: Pinia store actions)
2477
+
2478
+ 3. WRITE the adapter (one JS file per operation)
2479
+
2480
+ /* @meta
2481
+ {
2482
+ "name": "platform/command",
2483
+ "description": "What it does",
2484
+ "domain": "www.example.com",
2485
+ "args": { "query": {"required": true, "description": "Search query"} },
2486
+ "readOnly": true,
2487
+ "example": "bb-browser site platform/command value"
2488
+ }
2489
+ */
2490
+ async function(args) {
2491
+ if (!args.query) return {error: 'Missing argument: query'};
2492
+ const resp = await fetch('/api/search?q=' + encodeURIComponent(args.query), {credentials: 'include'});
2493
+ if (!resp.ok) return {error: 'HTTP ' + resp.status, hint: 'Not logged in?'};
2494
+ return await resp.json();
2495
+ }
2496
+
2497
+ 4. TEST it
2498
+ Save to ~/.bb-browser/sites/platform/command.js (private, takes priority)
2499
+ bb-browser site platform/command "test query" --json
2500
+
2501
+ 5. CONTRIBUTE
2502
+ Option A (with gh CLI):
2503
+ git clone https://github.com/epiral/bb-sites && cd bb-sites
2504
+ git checkout -b feat-platform
2505
+ # add adapter files
2506
+ git push -u origin feat-platform
2507
+ gh pr create --repo epiral/bb-sites
2508
+
2509
+ Option B (without gh CLI, using bb-browser itself):
2510
+ bb-browser site github/fork epiral/bb-sites
2511
+ git clone https://github.com/YOUR_USER/bb-sites && cd bb-sites
2512
+ git checkout -b feat-platform
2513
+ # add adapter files
2514
+ git push -u origin feat-platform
2515
+ bb-browser site github/pr-create epiral/bb-sites --title "feat(platform): add adapters" --head "YOUR_USER:feat-platform"
2516
+
2517
+ Private adapters: ~/.bb-browser/sites/<platform>/<command>.js
2518
+ Community: ~/.bb-browser/bb-sites/ (via bb-browser site update)
2519
+ Full guide: https://github.com/epiral/bb-sites/blob/main/SKILL.md`);
2520
+ break;
2521
+ }
2462
2522
  default: {
2463
2523
  console.error(`\u9519\u8BEF\uFF1A\u672A\u77E5\u547D\u4EE4 "${parsed.command}"`);
2464
2524
  console.error("\u8FD0\u884C bb-browser --help \u67E5\u770B\u53EF\u7528\u547D\u4EE4");