const http = require('node:http'); const probe = String.raw` (() => { const panel = document.createElement('div'); panel.style.cssText = 'position:fixed;right:8px;top:40px;z-index:99999;background:white;color:black;padding:12px;font:14px monospace;max-width:420px'; panel.innerHTML = '
waiting
'; document.body.appendChild(panel); const findMap = () => { if (!window.cc || !cc.director || !cc.director.getScene()) return null; const node = cc.find('Canvas/Game/GameNode/Map'); return node && node._components.find(c => typeof c.showPropGuideMask === 'function'); }; document.getElementById('test-guide').onclick = () => { const map = findMap(); if (map && cc.fx.GameConfig.GM_INFO.level + 1 === 8) map.showPropGuideMask(8); }; document.getElementById('test-enter').onclick = () => { const config = cc.fx.GameConfig; Object.assign(config.GM_INFO, {level:7,otherLevel:0,first:false,hammerFirst:false,hammerAmount:3}); // 验证页只检查本地交互,不向服务端写入道具消耗或测试埋点。 cc.fx.GameTool.setUserProp = () => {}; cc.fx.GameTool.shushu_Track = () => {}; cc.fx.GameTool.setDailyQuestInfo = () => {}; config.LEVEL_INFO_init(true,0,false); }; setInterval(() => { const map = findMap(); if (!map) return; const mask = map.node.parent.getChildByName('Mask'); const guide = map.propGuideMask; const event = guide && guide.getChildByName('bottom').getChildByName('destroyBtn').getComponent(cc.Button).clickEvents[0]; document.getElementById('guide-state').textContent = JSON.stringify({ level: cc.fx.GameConfig.GM_INFO.level + 1, className: cc.js.getClassName(map), guideVisible: !!guide, guideNodes: map.node.parent.children.filter(n => n.name === 'GuideMask').length, guideHammerPending: map.guideHammerPending, hammer: map.hammer, maskVisible: mask.active, hammerAmount: cc.fx.GameConfig.GM_INFO.hammerAmount, guideEvent: event && {handler:event.handler, data:event.customEventData, component:event.component}, hasCancelGuard: map.cancleHammer.toString().includes('guideHammerPending') }, null, 2); }, 150); })();`; const server = http.createServer((req, res) => { if (req.url === '/__guide_mask_probe.js') { res.writeHead(200, {'Content-Type':'application/javascript'}); res.end(probe); return; } const upstream = http.request({hostname:'localhost',port:7456,path:req.url,method:req.method, headers:{...req.headers, host:'localhost:7456','accept-encoding':'identity'}}, response => { const chunks=[]; response.on('data',chunk=>chunks.push(chunk)); response.on('end',()=>{ let body=Buffer.concat(chunks); const headers={...response.headers}; delete headers['content-length']; delete headers['transfer-encoding']; if ((headers['content-type']||'').includes('text/html') && req.url === '/') { body=Buffer.from(body.toString().replace('','')); } res.writeHead(response.statusCode,headers);res.end(body); }); }); upstream.on('error',error=>{res.writeHead(502);res.end(error.message);});req.pipe(upstream); }); server.listen(7469,'127.0.0.1',()=>console.log('GuideMask browser verification: http://127.0.0.1:7469/'));