- 旧平铺模块(data/data_utils/database_op/image_builder*/get_bf6_data/ gametools_bf6/bf6_data/img_utils)拆分为 handlers(绑定/查询)、 services(fetchers/processing/query)、utils(渲染/参数)分层; 新增 repository.py / config.py / paths.py - 字体/图片/模板资源迁入 res/,新增 BF2042 卡面素材(bg/object_icon 等) - browser_ext/:BF2042 扩展捕获桥(WS 直连兜底通道)源码入库 - 新增 hexi/web/src/plugins/bf_bot 前端管理页 - 新增 tests:test_bf_bot_helpers / repository / tracker_api Co-Authored-By: Claude Code <noreply@anthropic.com>
26 lines
735 B
JavaScript
26 lines
735 B
JavaScript
// 隔离世界桥(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 正在重启等场景,丢弃即可(数据可重查,不值得重试)
|
|
}
|
|
});
|
|
})();
|