45 lines
1.8 KiB
Markdown
45 lines
1.8 KiB
Markdown
|
|
# 巡樓 Threads Session 同步(Chrome 擴充)
|
|||
|
|
|
|||
|
|
從你已登入的 Chrome Threads 帳號,一鍵把 session 傳到巡樓後端,供**開發模式(爬蟲)測試海巡**使用。
|
|||
|
|
|
|||
|
|
## 安裝
|
|||
|
|
|
|||
|
|
1. 設定頁 → 開啟「開發模式」→ 下載 ZIP 並解壓
|
|||
|
|
2. Chrome 打開 `chrome://extensions` → 開發人員模式 → 載入未封裝項目
|
|||
|
|
3. 選解壓後的 `haixun-threads-sync` 資料夾
|
|||
|
|
4. 擴充**選項**填入巡樓網址(本機 `http://localhost:5173` 或遠端 `https://…`)並儲存
|
|||
|
|
5. **重新整理**巡樓分頁(F5)
|
|||
|
|
|
|||
|
|
## 必要條件
|
|||
|
|
|
|||
|
|
- 後端 gateway 在跑(本機預設 `http://127.0.0.1:8888`)
|
|||
|
|
- 前端在跑(本機 `http://localhost:5173`)
|
|||
|
|
- Chrome 已登入 `threads.com` / `threads.net`
|
|||
|
|
- 巡樓網頁已登入
|
|||
|
|
|
|||
|
|
## 使用
|
|||
|
|
|
|||
|
|
**A. 設定頁(推薦)**
|
|||
|
|
開啟開發模式 → 出現「擴充已偵測」→ 按「從 Chrome 同步 Session」
|
|||
|
|
|
|||
|
|
**B. 擴充圖示**
|
|||
|
|
先開著巡樓分頁 → 點擴充 →「同步到巡樓」
|
|||
|
|
|
|||
|
|
同步成功後,後端會寫入 `POST /api/v1/scout/crawler-session`(Playwright storageState)。
|
|||
|
|
|
|||
|
|
## 常見問題
|
|||
|
|
|
|||
|
|
| 現象 | 處理 |
|
|||
|
|
|------|------|
|
|||
|
|
| 尚未偵測擴充 | 擴充重新載入 + F5;選項網址須與分頁一致(`localhost` ≠ `127.0.0.1`) |
|
|||
|
|
| Cannot access contents of the page… | v1.2.0 起 localStorage 注入失敗會略過,改只靠 cookies;請更新擴充並重新載入 |
|
|||
|
|
| 找不到 cookies | 先開 threads.com 並登入 |
|
|||
|
|
| 找不到登入狀態 | 在設定頁按同步(會帶 JWT);或確認已登入巡樓 |
|
|||
|
|
| 無法連線 :8888 | 確認 gateway 有跑;遠端站請用同源 `/api` |
|
|||
|
|
|
|||
|
|
## 技術
|
|||
|
|
|
|||
|
|
- 網頁 `postMessage` ↔ `content-haixun.js` ↔ service worker
|
|||
|
|
- cookies → Playwright `storageState` → `scout/crawler-session`
|
|||
|
|
- 新版 JWT key:`hb_live_tokens`(舊:`haixun.access_token`)
|