feat(mirror): 恢复 /ws_hook.js(页面内旁听抓包,无需 SW,URL 加 #hook 才启用)
- 抓包不再依赖 Service Worker:浏览器仍直连服务器,不改传输、不改模块加载,服务端看不出差别 - index.html(本地,未入库)重新引入 ws_hook;SW 保持移除状态
This commit is contained in:
1 parent
6d229abfb2
commit
f3cd1aae67
1 file changed
+17
@@ -208,6 +208,23 @@ const Server = http.createServer((Req, Res) => {
|
||||
}).end(Sw);
|
||||
return;
|
||||
}
|
||||
// /ws_hook.js:页面内 window.WebSocket 抓包脚本(旁听,不改传输/不改模块加载)。
|
||||
// 由 index.html 在主脚本之前引入;脚本自身默认不启用,URL 加 #hook 才抓。
|
||||
if (UrlPath.split('?')[0] === '/ws_hook.js') {
|
||||
const HookFile = path.join(ROOT, 'sockets', 'ws_hook.js');
|
||||
if (!fs.existsSync(HookFile)) {
|
||||
Res.writeHead(404, { 'Content-Type': 'text/plain; charset=utf-8' }).end('ws_hook.js not found');
|
||||
return;
|
||||
}
|
||||
const Hook = fs.readFileSync(HookFile);
|
||||
Res.writeHead(200, {
|
||||
'Content-Type': 'application/javascript; charset=utf-8',
|
||||
'Content-Length': Hook.length,
|
||||
'Cache-Control': 'no-cache',
|
||||
'X-Hornet-WsHook': 'local',
|
||||
}).end(Hook);
|
||||
return;
|
||||
}
|
||||
// /config.xml 本地覆盖:存在 local/config.xml 时用它,把游戏指向本地 wss_server
|
||||
if (!REAL_CONFIG && UrlPath.split('?')[0] === '/config.xml' && fs.existsSync(LOCAL_CONFIG)) {
|
||||
const Conf = fs.readFileSync(LOCAL_CONFIG);
|
||||
|
||||
Reference in new issue
Block a user