Files
TankIC/3dtank.com copy/play/static/js/unpacked/hornet_prehook.js
T
TermiNexus fd0dffe31b feat(bundle): 迁移到新版 main.7cfa4058.js(重做拆分 + 移植 7 处针对性修改)
- 拆分:tools/split.js 重切新版(1347 模块 / 126 代码模块),主文件 main.7cfa4058.js,语法验证通过

- 修复 split.js 内自动刷新拦截的 \\n 转义:它在模板字符串里,必须写 \\\\n,否则生成的主文件字符串断行、语法报错

- 符号映射:map_symbols.js 对齐旧→新(qyr→ryz、w187→c18o、z4t→jtn、vgt→rkt、Bmt→Ezt、Qjt→Fjt、txt→Gjt、k15b→s15n、azi_1→vzr_1…)

- 移植 7 处针对性修改:炮塔摆头不回弹(vSt.ryz)、摆头不过冲(case 0)、精准跟手(case 1/2)、悬浮底盘 raw 两级(Ezt.n36 + Zmt 实际速度)、电磁炮蓄力时长(jtn.c18o)

- 重新打包 unpacked.pack.json(127 文件 / 版本 96833eb2b0cf8909)
2026-10-16 14:20:15 +08:00

72 lines
2.7 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// ===== 3DTank Hornet Pre-hook =====
// 功能:在游戏脚本执行前 hook Function.prototype.call,
// 捕获 webpack 的 __webpack_require__,然后加载 hornet_bundle.js
// 用途:当无法修改 main.xxx.js 时,用此脚本从外部获取 webpack 内部对象
//
// 加载方式(三选一):
// 1. Tampermonkey userscript:@run-at document-start,@match *://3dtank.com/play/*
// 2. 修改 HTML:在游戏 <script src="main.xxx.js"> 之前添加 <script src="hornet_prehook.js"></script>
// 3. 浏览器扩展:content_script 在 document_start 注入
//
// 原理:
// webpack runtime 调用:
// __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__)
// 第四参数 = __webpack_require__
// hook 检测到后捕获,立即恢复原 .call 避免性能影响
(function() {
if (window.__hornetPrehook__) return;
window.__hornetPrehook__ = true;
var origCall = Function.prototype.call;
var captured = false;
// 超时保护:10秒后放弃
var timeout = setTimeout(function() {
if (!captured) {
Function.prototype.call = origCall;
console.error('[Hornet Prehook] 10秒内未捕获 __webpack_require__,可能游戏结构已变化');
}
}, 10000);
Function.prototype.call = function(thisArg) {
if (!captured && arguments.length >= 4) {
var req = arguments[3];
// 检测 __webpack_require__:
// 1. 是函数
// 2. .p === '/play/'(webpack publicPath)
// 3. 有 .n/.d/.o 辅助函数
if (typeof req === 'function' &&
req.p === '/play/' &&
typeof req.n === 'function' &&
typeof req.d === 'function' &&
typeof req.o === 'function') {
window.__wp_require__ = req;
captured = true;
clearTimeout(timeout);
Function.prototype.call = origCall; // 立即恢复,避免性能影响
console.log('[Hornet Prehook] __webpack_require__ 已捕获');
console.log('[Hornet Prehook] window.__wp_require__ 就绪');
// 加载 hornet_bundle.js(如果尚未加载)
if (!window.__hornetTools__) {
var s = document.createElement('script');
s.src = '/play/static/js/unpacked/hornet_bundle.js';
s.onload = function() {
console.log('[Hornet Prehook] hornet_bundle.js 已加载');
};
s.onerror = function() {
console.error('[Hornet Prehook] hornet_bundle.js 加载失败,请检查路径');
};
(document.head || document.documentElement).appendChild(s);
}
}
}
return origCall.apply(this, arguments);
};
console.log('[Hornet Prehook] 已注入,等待 webpack 模块初始化...');
})();