// 隔离世界桥(document_start):把主世界钩子 postMessage 上来的捕获转发给 SW。 // // WS 由 SW 持有 —— 内容脚本直接连 ws://127.0.0.1 会被页面 CSP 的 connect-src 拦掉。 (() => { "use strict"; const MARKER = "__hexi_bf2042_capture__"; window.addEventListener("message", (event) => { if (event.source !== window) return; const data = event.data; if (!data || data[MARKER] !== true) return; try { chrome.runtime.sendMessage({ type: "captured", url: String(data.url || ""), status: data.status, body: data.body, }); } catch (_) { // SW 正在重启等场景,丢弃即可(数据可重查,不值得重试) } }); })();