// ==UserScript== // @name 中兴路由器增强 ZTE-Stat_Max // @name:en ZTE-Stat_Max // @namespace ucxn // @version 5.9.9Ge // @description 哥哥科技 QQ群 680464365 // @description:en https://github.com/ucxn/ZTE-Stat_Max // @author 哥哥科技 space.bilibili.com/501430041 // @noframes // @tag 路由器 中兴 网络 监控 统计 数据 可视化 极客 增强 UI HA 智能 定时 后台 // @icon https://scriptcat.org/api/v2/resource/image/PD6xhxddlUESIwAV // @include /^https?:\/\/10(\.[0-9]{1,3}){3}(:\d+)?\/.*$/ // @include http://192.168.*.* // @match http://zte.home* // @include http://172.16.* // @include https://192.168.*.* // @match https://zte.home* // @include https://172.16.* // @grant unsafeWindow // @grant GM_setValue // @storageName GBNPA_Storage // @license AGPL-3.0-or-later // ==/UserScript== (function() { 'use strict'; console.log("🚀 哥哥科技 V5.9.9 终极引擎已装载..."); function escapeHTML(str) { if (!str) return ''; return String(str).replace(/[&<>'"]/g, function(match) { return { '&': '&', '<': '<', '>': '>', "'": ''', '"': '"' }[match]; }); } // ======== [0] 用户极客环境变量配置区 ======== const CONFIG = { routerIP: "192.168.5.1", // 路由器内网 IP forceMeshMode: 1, // 【Mesh探测模式】0: 官方拓扑驱动 | 1: n秒智能等待(默认) | 2: 强制大包抓取(专治阉割、不出数据) uiLayout: 1, // 【面板拓扑结构】 0: 经典版 | 1: 详细紧凑版(驾驶舱美学) | 2: 详细平铺版(报表流美学) injectMode: 1, // 【UI注入模式】 0: 原生侧边栏(1min)| 1: 优先,10秒悬浮舱(D)| 2: 强制模式(30秒后强制霸屏) calcMode: 1, // 1: 上行/下行倍数模式, 0: 上行占总和比例模式 ratioExtremeUp: 10,// 极端上传判定阈值 (> 1000%) ratioWarnUp: 0.07,// 重度上传警告阈值 (> 7%) ratioExtremeDown: 0.01, // 极端下载判定阈值 (< 1%) ratioThreshold: 7, // (仅calcMode=0时有效) 上传占比报警阈值(%) readSaveData: 1,// 【开关切换】 1: 读档模式(继承本次历史量) | 0: 新局模式(从打开网页此刻归零重新计流) lanRefreshInterval: 5, // 【新增】LAN口刷新时间(秒),用于精准补偿0到唤醒时的瞬时流量 portMap: { "eth1": "网口 1", "eth2": "网口 2", "eth3": "网口 3", "eth4": "网口 4", "wl0": "2.4G", "wl1": "5.2G", "wl2": "5.8G" } }; const S={lt:0,wInstUp:0,wInstDn:0,wTotUp:0,wTotDn:0,cls:{}};let isF=!1,pr=new DOMParser(),lCxt=null;const oOp=unsafeWindow.XMLHttpRequest.prototype.open; unsafeWindow.XMLHttpRequest.prototype.open=function(){this. addEventListener('load',function(){try{if(this.responseType===''|| this.responseType==='text'){let t=this.responseText;if(t&&(t.includes('')||t.includes(''))){ if(t.includes(''))lCxt=t;if(window.startGegePrecisionEngine) {window.startGegePrecisionEngine();}}}}catch(e){console.warn("[哥哥科技] XHR 拦截器异常:",e.message);}}); oOp.apply(this,arguments);};function s2b(s){let m=s?.match(/([\d.]+)\s*(G|M|K)?bps/i);if(!m)return 0;let v=parseFloat(m[1]),u=(m[2]||"").toUpperCase();return u==='G'?v*1e9:u==='M'?v*1e6:u==='K'?v*1e3:v;} function fB(b){return b>=1e9?`${(b/1e9).toFixed(3)} Gbps`:b>=1e6?`${(b/1e6).toFixed(2)} Mbps`:b>=1e3?`${(b/1e3).toFixed(1)} Kbps`:`${Math.round(b)} bps`;}function fBy(b){return b>=8589934592?`${(b/8589934592).toFixed(3)} GiB/s`:b>=8388608?`${(b/8388608).toFixed(2)} MiB/s`:b>=8192?`${(b/8192).toFixed(1)} KiB/s`:`${Math.round(b/8)} B/s`;}function fV(b){return b>=8796093022208?`${(b/8796093022208).toFixed(4)} TiB`:b>=8589934592?`${(b/8589934592).toFixed(3)} GiB`:b>=8388608?`${(b/8388608).toFixed(2)} MiB`:b>=8192?`${(b/8192).toFixed(1)} KiB`:`${Math.round(b/8)} B`;}function fVD(i,o){return i>=8796093022208?`${(o/8796093022208).toFixed(4)} | ${(i/8796093022208).toFixed(4)} TiB`:i>=8589934592?`${(o/8589934592).toFixed(4)} | ${(i/8589934592).toFixed(3)} GiB`:i>=8388608?`${(o/8388608).toFixed(3)} | ${(i/8388608).toFixed(2)} MiB`:i>=8192?`${(o/8192).toFixed(1)} | ${(i/8192).toFixed(2)} KiB`:`${Math.round(o/8)} | ${Math.round(i/8)} B`;} function fSV(b){return(b/=8)>=1073741824?(b/1073741824).toFixed(3)+'G':b>=1048576?(b/1048576).toFixed(2)+'M':b>=1024?(b/1024).toFixed(1)+'K':Math.round(b)+'B';}function fOT(s){if(s<=0)return"";let d=Math.floor(s/86400),h=Math.floor((s%86400)/3600),m=Math.floor((s%3600)/60),sec=Math.floor(s%60);return d>0?`${d}天${h}时${m}分${sec}秒`:`${h}小时${m}分${sec}秒`;}function nM(m){return m?m.toLowerCase().replace(/-/g,':').replace(/\s/g,''):'';}function pI(n){let o=Object.create(null),c=n.children;for(let i=0;i'))return;wX=pr.parseFromString( wT,"text/xml");}let cX=lCxt?pr.parseFromString(lCxt,"text/xml"):null;const bIN=wX.querySelector( "OBJ_HOME_BASICINFO_ID Instance"),wI=bIN?pI(bIN):{},cWU=s2b(wI.WANUpRate),cWD=s2b( wI.WANDownRate),cI=Object.create(null);let cSU=0,cSD=0;(cX?.querySelectorAll("OBJ_CLIENTS_ID Instance")||[]).forEach(nd=>{let d=pI( nd);if(d.MACAddress){let m=nM(d.MACAddress),u=s2b(d.UpRate),dn=s2b(d.DownRate),uT=( parseFloat(d.UpThroughput)||0)*8000,dT=(parseFloat(d.DownThroughput)||0)*8000;let bN= d.AliasName||d.HostName||d.DisplayedPictureName||"";cI[m]={upRate:u,dnRate:dn,iface:d.Interface||"",offUp:uT,offDn:dT,onSec:parseInt(d.OnlineDuration||d.OnlineTime||d.LeaseTime||0),name:bN,ip:d.IPAddress||""};cSU+=u;cSD+=dn;}});let ol=document.getElementById('gege-global-overlay'),cM=Object.keys( cI),iD=window.gegeForceUIRedraw||(cM.length!==window.gegeRenderedMacs.size);if(!iD&&cM.length>0){for(let i=0;i< cM.length;i++){if(!window.gegeRenderedMacs.has(cM[i])){iD=!0;break;}}}let iDW=ol&&ol.style.display==='block'&&!ol.querySelector( '.gege-list-item');if(ol&&ol.style.display==='block'&&(iD||iDW)){bVD(ol,cX);window.gegeRenderedMacs=new Set( cM);window.gegeForceUIRedraw=!1;}let gDt=(S.lt!==0)?(n-S.lt)/1000:0;if(S.wLT===undefined){S.wLT=n;}else if(cWU!==S.wInstUp||cWD!==S.wInstDn){let wDt=n-S.wLT;if(S.wInstUp>0)S.wTotUp+=(S.wInstUp+cWU)*wDt/2000;if(S.wInstDn>0)S.wTotDn+=(S.wInstDn+cWD)*wDt/2000;S.wLT=n;}for(const[m,cC] of Object.entries(cI)){S.cls[m]??={upR:cC.upRate,dnR:cC.dnRate,lUT:n,intUp:0,intDn:0,uB:CONFIG.readSaveData===1?0:cC.offUp,dB:CONFIG.readSaveData===1?0:cC.offDn,lU:cC.offUp,lD:cC.offDn,aR:!1,dpU:0,dpD:0,oU:CONFIG.readSaveData===1?cC.offUp:0,oD:CONFIG.readSaveData===1?cC.offDn:0}; let cS=S.cls[m],dU=cC.offUp-cS.lU,dD=cC.offDn-cS.lD;if(dU<0||dD<0){if(dU<0){cS.uB+=dU;cS.dpU=cS.lU;}if(dD<0){cS.dB+=dD;cS.dpD=cS.lD;}cS.aR=!0;}else if(cS.aR){if(dD>2516582400||dU>671088640||(cS.dpD&&dD>=cS.dpD)||(cS.dpU&&dU>=cS.dpU)){cS.uB+=dU;cS.dB+=dD;cS.aR=!1;cS.dpU=0;cS.dpD=0;}}if(cS.lOS!==cC.onSec){cS.onS=cC.onSec;cS.lOS=cC.onSec;}else{cS.onS=(cS.onS||cC.onSec||0)+gDt;}if(cC.upRate!==cS.upR||cC.dnRate!==cS.dnR){let ms=n-cS.lUT;if(cS.upR>0)cS.intUp+=(cS.upR+cC.upRate)*ms/2000;else if(cC.upRate>0)cS.intUp+=(cC.upRate/2)*CONFIG.lanRefreshInterval;if(cS.dnR>0)cS.intDn+=(cS.dnR+cC.dnRate)*ms/2000;else if(cC.dnRate>0)cS.intDn+=(cC.dnRate/2)*CONFIG.lanRefreshInterval;cS.upR=cC.upRate;cS.dnR=cC.dnRate;cS.lUT=n;}cS.lU=cC.offUp;cS.lD=cC.offDn;}S.lt=n;S.wInstUp=cWU;S.wInstDn=cWD;rUI(cWU,cWD,cSU,cSD,cI);}catch(e){console.error("[哥哥科技] 周期采样中断:",e);}finally{isF=!1;}} function rUI(wU,wD,sU,sD,cI){ let tOD=0,LUp=0,LDn=0,hpU=0,hpD=0,abU=0,abD=0,curHpU=0,curHpD=0,cln={}; for(const[k,s] of Object.entries(S.cls)){ let cC=cI[k],cU=Math.max(0,(s.lU||0)-(s.uB||0)-(s.oU||0)),cD=Math.max(0,(s.lD||0)-(s.dB||0)-(s.oD||0)); LUp+=s.intUp||0;LDn+=s.intDn||0;hpU+=cU;hpD+=cD; if(cC){curHpU+=cU;curHpD+=cD;tOD+=cC.offDn||0;abU+=cC.offUp||0;abD+=cC.offDn||0;} cln[k]={up:cU,down:cD,integral_up:s.intUp||0,integral_down:s.intDn||0,status:s.aR?"off":(CONFIG.portMap[cC?.iface]||cC?.iface||"未知接口"),name:cC?.name||k,ip:cC?.ip||"",raw_up:cC?.offUp||0,raw_down:cC?.offDn||0};} GM_setValue('ha_snapshot',{timestamp:Date.now(),global:{wan_up:S.wTotUp,wan_down:S.wTotDn,lan_integral_up:LUp,lan_integral_down:LDn,lan_high_up:hpU,lan_high_down:hpD,lan_off_up:abU,lan_off_down:abD},devices:cln}); S.rTick=((S.rTick||0)+1)&31;if(S.rTick===1||!S.cRT){const cSR=(W,I,H)=>{if(W===0)return 1.0;let M=Math.max(I,H),m=Math.min(I,H),G=Math.abs(I-H);if(I>=0.84*W&&H>=0.75*W&&(M<=1.5*W||G<=0.6*W))return((I+H)/2)/W;if(m1.5?'#ff4c00':mR>1.15?'#FF9800':'#4CAF50';S.cRT=`${(rU*100).toFixed(2)}%,${(rD*100).toFixed(2)}%`;} let bd=document.getElementById('zte-geek-board'); if(!bd){bd=document.createElement('div');bd.id='zte-geek-board';let lH=''; if(CONFIG.uiLayout===1){lH=`
WAN口速率
|
局域网代数和
实时占比: |
LAN:
WAN: |
在线高精: |
高精流量统计 ->
内外网比:
当前总计: |
`;} else if(CONFIG.uiLayout===2){lH=`
WAN口速率
|
局域网代数和
实时占比: |
LAN:
在线高精: |
高精流量统计 ->
当前总计: |
WAN:
内外网比:
`;} else lH=`
WAN口速率
|
局域网代数和
实时占比: |
LAN:
WAN: |
高精流量统计 ->
当前总计: |
`; bd.innerHTML=lH;} let ol=document.getElementById('gege-global-overlay'),iPO=ol&&ol.style.display==='block',aC=iPO?ol:document; if(iPO){let ac=document.getElementById('gege-board-anchor');if(ac&&bd.parentNode!==ac)ac.appendChild(bd);}else{let mn=document.querySelector('.el-table')||document.querySelector('.config-item')?.closest('div')||document.querySelector('.main-content');if(mn&&bd.parentNode!==mn.parentNode)mn.parentNode.insertBefore(bd,mn);} let oDC=Object.create(null);if(!iPO){const M_RX=/([a-fA-F0-9]{2}[:-]){5}[a-fA-F0-9]{2}/;let aI=aC.querySelectorAll('.config-item');for(let n of aI){let mN=n.querySelector('.dev-number'),mM=mN?mN.textContent.match(M_RX):null;if(mM){oDC[mM[0].toLowerCase().replace(/-/g,':')]=n;}}}else{let gI=aC.querySelectorAll('.gege-list-item');for(let n of gI){let m=n.getAttribute('data-gege-mac');if(m)oDC[m]=n;}} requestAnimationFrame(()=>{ if(bd.parentNode){ bd.querySelector('#gb-wan-up-bytes').textContent=`🔼 ${fBy(wU)}`; bd.querySelector('#gb-wan-down-bytes').textContent=`🔽 ${fBy(wD)}`; bd.querySelector('#gb-wan-up-bps').textContent=`🔼 ${fB(wU)}`; bd.querySelector('#gb-wan-down-bps').textContent=`🔽 ${fB(wD)}`; bd.querySelector('#gb-lan-up-bytes').textContent=`🔼 ${fBy(sU)}`; bd.querySelector('#gb-lan-down-bytes').textContent=`🔽 ${fBy(sD)}`; bd.querySelector('#gb-perc-up').textContent=`🔼 ${wU>0?((sU/wU)*100).toFixed(1):0.0}%`; bd.querySelector('#gb-perc-down').textContent=`🔽 ${wD>0?((sD/wD)*100).toFixed(1):0.0}%`; bd.querySelector('#gb-lan-up-vol').textContent=`🔼 ${fV(LUp)}`; bd.querySelector('#gb-lan-down-vol').textContent=`🔽 ${fV(LDn)}`; bd.querySelector('#gb-wan-up-vol').textContent=`🔼 ${fV(S.wTotUp)}`; bd.querySelector('#gb-wan-down-vol').textContent=`🔽 ${fV(S.wTotDn)}`; bd.querySelector('#gb-int-up-vol').textContent=`🔼 ${fV(hpU)}`; bd.querySelector('#gb-int-down-vol').textContent=`🔽 ${fV(hpD)}`; bd.querySelector('#gb-abs-up-vol').textContent=`🔼 ${fV(abU)}`; bd.querySelector('#gb-abs-down-vol').textContent=`🔽 ${fV(abD)}`; if(bd.querySelector('#gb-ratio-display')){bd.querySelector('#gb-cur-up-vol').textContent=`🔼 ${fV(curHpU)}`;bd.querySelector('#gb-cur-down-vol').textContent=`🔽 ${fV(curHpD)}`;bd.querySelector('#gb-ratio-display').innerHTML=S.cRT;} } for(let m in cI){ let it=oDC[m]; if(!it)continue; const cC=cI[m]||{upRate:0,dnRate:0,iface:"",offUp:0,offDn:0},cS=S.cls[m]||{intUp:0,intDn:0,onS:0}; let tN=it.querySelector('.gege-online-time'); if(tN&&cS.onS>0)tN.textContent=`在线:${fOT(cS.onS)}`; const dI=it.querySelector('.dev-intro'); if(dI){let bx=dI.querySelector('.gege-up-box');if(!bx){bx=document.createElement('div');bx.className='gege-up-box';bx.innerHTML=`
`;dI.appendChild(bx);}let hqU=cln[m]?cln[m].up:0;let p=hpU>0?(hqU/hpU*100).toFixed(1):0.0;bx.querySelector('.v-vol').textContent=fVD(cS.intUp,cC.offUp);bx.querySelector('.v-pct').textContent=p+'%';bx.querySelector('.zte-thin-bar-inner').style.width=Math.min(p,100)+'%';} const inf=it.querySelector('.info'); if(inf){Array.from(inf.querySelectorAll('.dev-ip:not(.gege-box *)')).slice(1).forEach(n=>{n.style.display='none';});inf.querySelectorAll('.dev-number:not(.gege-box *)').forEach(n=>{n.style.display='none';});let rB=inf.querySelector('.gege-ratio-box');if(!rB){rB=document.createElement('div');rB.className='gege-ratio-box';rB.innerHTML=`
`;inf.appendChild(rB);}let hqU=cln[m]?cln[m].up:0,hqD=cln[m]?cln[m].down:0,bR=(hqU+hqD)>0?(hqU/(hqU+hqD)*100):0,tC="",tCol="#0059fa"; if(CONFIG.calcMode===1){let rt=hqD>0?(hqU/hqD):(hqU>0?Infinity:0);if(rt>CONFIG.ratioExtremeUp){tCol='#ff4c00';tC=(rt===Infinity?'∞':rt.toFixed(2))+'⚠️';}else if(rt>CONFIG.ratioWarnUp){tCol='#ff4c00';tC=(rt*100).toFixed(1)+'%';}else if(rt>=CONFIG.ratioExtremeDown){tCol='#0059fa';tC=(rt*100).toFixed(1)+'%';}else{tCol='#0059fa';let rRt=hqU>0?(hqD/hqU):(hqD>0?Infinity:0);tC=(rRt===Infinity?'∞':rRt.toFixed(1))+'x';}}else{tCol=bR>CONFIG.ratioThreshold?'#ff4c00':'#0059fa';tC=bR.toFixed(1)+'%';}rB.querySelector('.v-port').textContent=CONFIG.portMap[cC.iface]||cC.iface||"未知";rB.querySelector('.v-interval .c-up').textContent=''+fSV(hqU);rB.querySelector('.v-interval .c-down').textContent=''+fSV(hqD);let rtP=rB.querySelector('.v-rt-pct');rtP.textContent=tC;rtP.style.color=tCol;rB.querySelector('.gege-ratio-bar-inner').style.width=Math.min(bR,100)+'%';let dBx=inf.querySelector('.gege-down-box');if(!dBx){dBx=document.createElement('div');dBx.className='gege-down-box';dBx.innerHTML=`
`;inf.appendChild(dBx);}let dp=tOD>0?((cC.offDn||0)/tOD*100).toFixed(1):0.0;dBx.querySelector('.v-vol').textContent=fVD(cS.intDn,cC.offDn);dBx.querySelector('.v-pct').textContent=dp+'%';dBx.querySelector('.zte-thin-bar-inner').style.width=Math.min(dp,100)+'%';} const sp=it.querySelector('.speed'); if(sp){ sp.querySelectorAll('.connect-up, .connect-down').forEach(n=>{n.style.display='none';}); let enh=sp.querySelector('.zte-enhance-speed'); if(!enh){enh=document.createElement('div');enh.className='zte-enhance-speed';enh.innerHTML=`
`;sp.appendChild(enh);} let pu=sU>0?(cC.upRate/sU*100):0,pd=sD>0?(cC.dnRate/sD*100):0,bU=enh.querySelector('.zte-bar-up'),bD=enh.querySelector('.zte-bar-down'); bU.style.setProperty('--p-up',Math.min(pu,100)+'%');bU.querySelector('.v-val').textContent=`🔼 ${fBy(cC.upRate)}`;bU.querySelector('.v-pct').textContent=(wU>0?pu.toFixed(1):0.0)+'%';bD.style.setProperty('--p-down',Math.min(pd,100)+'%');bD.querySelector('.v-val').textContent=`🔽 ${fBy(cC.dnRate)}`;bD.querySelector('.v-pct').textContent=(wD>0?pd.toFixed(1):0.0)+'%';}}});}async function bVD(ol,cX){try{ let mB=(window.gegeHiddenDevices&&Object.keys(window.gegeHiddenDevices).length>0)?'(哥哥科技:智能Mesh适配)':'',h2=[],h52=[],h58=[],hW=[];(cX?.querySelectorAll("OBJ_CLIENTS_ID Instance")||[]).forEach(i=>{let d=pI(i);if(!d.MACAddress)return;let m=nM(d.MACAddress),ip=escapeHTML(d.IPAddress||''),nm=escapeHTML(d.AliasName||d.HostName||'未知设备'),ifc=d.Interface||'',oS=parseInt(d.OnlineDuration||d.OnlineTime||d.LeaseTime||0),tS=fOT(oS),tH=`
${tS?'在线:'+tS:''}
`,htm=`
${ip}
MAC:${m}
`;if(['wl0','wlan0','wlan1','wl1'].includes(ifc))h2.push(htm);else if(['wlan5','wl4','wlan4','wl3','wlan3'].includes(ifc))h52.push(htm);else if(ifc==='wl2'||ifc==='wlan2'||ifc==='wl5'||(/w/i.test(ifc)&&!/wan/i.test(ifc)))h58.push(htm);else hW.push(htm);});requestAnimationFrame(()=>{ol.innerHTML=`
无线设备(2.4GHz)
${h2.join('')||'
没有连接设备
'}
无线设备(5.2GHz)
${h52.join('')||'
没有连接设备
'}
无线设备(5.8GHz)
${h58.join('')||'
没有连接设备
'}
有线设备${mB}
${hW.join('')||'
没有连接设备
'}
`;});}catch(e){requestAnimationFrame(()=>{ol.innerHTML=`
数据渲染失败: ${escapeHTML(e.message)}
`;});}}window.createGegeFloatingBtn=function(){if(document.getElementById('gege-floating-btn'))return;let b= document.createElement('div');b.id='gege-floating-btn';b.innerHTML='🛸';b.style.cssText=`position: fixed; `+ `top: 20px; right: 20px; width: 50px; height: 50px; background: `+ `linear-gradient(135deg, #0059fa, #00c6ff); color: white; border-radius: 50%; display: flex; `+ `align-items: center; justify-content: center; font-size: 48px; box-shadow: 0 4px 15px rgba(0,89,250,0.5); `+ `cursor: pointer; z-index: 99999; transition: all 0.3s ease; user-select: none;`;b. onmouseover=()=>{b.style.transform='scale(1.1) rotate(15deg)';};b.onmouseout=()=>{b.style.transform= 'scale(1) rotate(0deg)';};b.onclick=()=>window.gegeTogglePanel();document.body.appendChild(b);};window.gegeTogglePanel=function(fS=null){let o=document.getElementById('gege-global-overlay'),iCO= o&&o.style.display==='block',tS=fS!==null?fS:!iCO,aT=document.querySelector( '#gege-menu-wrapper a'),lT=document.querySelector('#gege-menu-wrapper li');if(!tS){if(lT){lT.classList.remove( 'is-active');lT.style.color='rgb(255, 255, 255)';}if(o)o.style.display='none';return;}if(aT&& lT){aT.classList.add('router-link-exact-active','router-link-active');lT.classList.add('is-active');lT.style.color= 'rgb(61, 163, 247)';}if(!o){o=document.createElement('div');o.id='gege-global-overlay';let pT=document.querySelector('.page-top');if(pT){pT.parentNode.style.position='relative';o.style.cssText=`position: absolute; top: 0; left: 0; width: 100%; min-height: 100%; height: 100%; background: #f3f4f5; z-index: 9999; overflow-y: auto; padding-bottom: 50px;`;pT.parentNode.appendChild(o);}else{o.style.cssText=`position: fixed; top: 60px; left: 240px; right: 0; bottom: 0; background: #f3f4f5; z-index: 9999; overflow-y: auto; padding-bottom: 50px;`;document.body.appendChild(o);}}o.style.display='block';if(!window. gegeBActivated){window.gegeBActivated=!0;clearTimeout(window.gegeMasterTimer);window.gegeMasterTimer=setInterval(eBET,CONFIG.forceMeshMode===2?6000:1000);if(CONFIG.forceMeshMode===1){setTimeout(()=>{if(window.gegeRenderedMacs.size===0){console.log("⏱️ [哥哥科技] 17秒熔断生效:强制切入档位2"); CONFIG.forceMeshMode=2;clearInterval(window.gegeMasterTimer);window.gegeMasterTimer=setInterval(eBET,6000);let ol=document.getElementById('gege-global-overlay');if(ol){let aB=document.createElement('div');aB.id='gege-fallback-alert';aB.style.cssText='background:#fff3cd;color:#856404;padding:12px 15px;margin:15px 30px 5px 30px;border-radius:6px;border:1px solid #ffeeba;border-left:5px solid #ffc107;font-weight:bold;font-size:13px;box-shadow:0 2px 8px rgba(0,0,0,0.05);';aB.innerHTML='⚠️ 17秒熔断机制触发:检测到当前固件常规接口异常(被阉割),已自动为您开启【深度大包抓取模式】。';let ac=document.getElementById('gege-board-anchor'); if(ac&&!document.getElementById('gege-fallback-alert')){ac.parentNode.insertBefore(aB,ac);}}}},4500);}} bVD(o,lCxt?pr.parseFromString(lCxt,"text/xml"):null).then(()=>{if(window.gegeBActivated)eBET();else rSD();});};function iGM(){let mC=document.querySelector('.menu_items');if(!mC)return;let oD=mC.querySelector( 'div');if(!oD)return;let gW=oD.cloneNode(!0);gW.id='gege-menu-wrapper';let aT=gW.querySelector( 'a'),lT=gW.querySelector('li');if(aT){aT.href="javascript:void(0);";aT.classList.remove( 'router-link-exact-active','router-link-active');}if(lT){lT.classList.remove('is-active');let tS= lT.querySelector('span');if(tS){const pT=(t,s)=>{let l=s.length,o=(l===6)?(l+9):15;return decodeURIComponent( escape(window.atob(t.substring(o).split('').reverse().join(''))));};const aM={'ZTE_LEGACY_WIRED':"ZTE_AUTH_TOKEN_/xK9vP2mQ5zL8wJ4nB7cT1fR",'ZTE_NEBULA_MAX':"ZTE_AUTH_TOKEN_/2p5i2Z6Aqo5Re65lOZ5lOZ5",'ZTE_GENERIC_OS':"ZTE_AUTH_TOKEN_/pM4aC7yX9kH3bV2rN6dW8qG"};const gHP=()=>{let m= Object.keys(aM).length,hI=(m<<2)-10;return Object.keys(aM)[hI^3];};tS.textContent=pT(aM[gHP()],tS.textContent);}lT.querySelectorAll( 'img').forEach(i=>i.remove());let eS=document.createElement('span');eS.textContent='🚀';eS.style.cssText=`font-size: `+ `20px; margin-right: 5px; vertical-align: middle; display: inline-block; width: 22px; text-align: center;`;if( tS)lT.insertBefore(eS,tS);lT.style.color='rgb(255, 255, 255)';}mC.appendChild(gW);document. addEventListener('click',function(e){let cW=e.target.closest('.menu_items > div');if(!cW)return;if( cW.id==='gege-menu-wrapper'){e.preventDefault();e.stopPropagation();let fB=document.getElementById( 'gege-floating-btn');if(fB)fB.remove();window.gegeTogglePanel(!0);}else{window. gegeTogglePanel(!1);}},!0);}window.gegeBActivated=!1;window.gegeEngineRunning=!1;window.gegeLastDevCount=-1;window.gegeLastMeshDevCount=-1;window.gegeHiddenDevices={};window.gegeTimerStarted=!1;window.gegeSyncAnchor=0;window.gegeTickCount=0;window.gegeMasterTimer=null; window.triggerGegeMeshSniper=async function(){try{const liR=await fetch(`/?_type=vueData&_tag=localnet_lan_info_lua&_=${Date.now()}`),liX=pr.parseFromString(await liR.text(),"text/xml");let nHD={};liX.querySelectorAll("OBJ_LAN_INFO_ID Instance").forEach(inst=>{let d=pI(inst);if(d.DevMeshType==='3'&&d.Active==='1'&&d.MACAddress){let m=nM(d.MACAddress),bN=d.DevName||d.HostName||d.DisplayedPictureName||d.AliasName||"Mesh设备",bI=d.Interface||"";if(d.IFAliasName==='SSID1')bI='wl0';else if(d.IFAliasName==='SSID5')bI='wl4';nHD[m]={name:bN,iface:bI,origMac:d.MACAddress};}});if(Object.keys(nHD).length>0){window.gegeHiddenDevices=nHD;window.gegeForceUIRedraw=!0;console.log("🎯 [哥哥科技] 破甲弹命中!强制狙击名单:",Object.keys(nHD));}}catch(e){console.warn("[哥哥科技] B2强启拉取失败:",e.message);}}; window.startGegePrecisionEngine=function(){if(window.gegeTimerStarted||window.gegeBActivated)return;window.gegeTimerStarted=!0;window.gegeSyncAnchor=performance.now();window.gegeTickCount=0;window.scheduleNextGegeTick();};window.scheduleNextGegeTick=function(){if(window.gegeBActivated)return;window.gegeTickCount++;let dl=(window.gegeSyncAnchor+window.gegeTickCount*3000)-performance.now();if(dl<0){window.gegeSyncAnchor=performance.now();window.gegeTickCount=0;dl=3000;}window.gegeMasterTimer=setTimeout(()=>{rSD().finally(()=>{window.scheduleNextGegeTick();});},dl);}; async function eBET(){if(window.gegeEngineRunning)return;window.gegeEngineRunning=!0;try{const ts=Date.now(),wR=await fetch(`/?_type=vueData&_tag=vue_home_device_data_no_update_sess&IF_OP=refresh&_=${ts}`); if(!wR.ok)throw new Error();const wT=await wR.text(),wST=performance.now();if(!wT.includes(''))throw new Error();const wX=pr.parseFromString(wT,"text/xml") ;let bIN=wX.querySelector("OBJ_HOME_BASICINFO_ID Instance"),wI=bIN?pI(bIN):{},cDC=parseInt(wI.AccessDevNum);cDC=isNaN(cDC)?-1:cDC;let lT="",lF=""; if(CONFIG.forceMeshMode===2){const liR=await fetch(`/?_type=vueData&_tag=localnet_lan_info_lua&_=${ts}`);if(liR.ok){const liX=pr.parseFromString(await liR.text(),"text/xml");let iI="",nHD={},dC=0;liX.querySelectorAll("OBJ_LAN_INFO_ID Instance").forEach(inst=>{let d=pI(inst);if(d.MACAddress&&d.MACAddress!=="00:00:00:00:00:00"){dC++;let m=nM(d.MACAddress),bN=d.DevName||d.HostName||d.DisplayedPictureName||d.AliasName||"未知设备",bI=d.Interface||"";if(d.IFAliasName==='SSID1')bI='wl0' ;else if(d.IFAliasName==='SSID5')bI='wl4';if(d.DevMeshType==='3')nHD[m]={name:bN,iface:bI,origMac:d.MACAddress}; let uR=`${d.UploadSpeed||0}Kbps`,dR=`${d.DownloadSpeed||0}Kbps`,uT=((parseFloat(d.BytesSend)||0)/1000).toFixed(4),dT=((parseFloat(d.BytesReceived)||0)/1000).toFixed(4),oS=parseInt(d.OnlineTime||d.OnlineTimes||0);iI+=`MACAddress${escapeHTML(m)}IPAddress${d.IPAddress||""}AliasName${escapeHTML(bN)}HostName${escapeHTML(bN)}Interface${escapeHTML(bI)}UpRate${uR}DownRate${dR}UpThroughput${uT}DownThroughput${dT}OnlineDuration${oS}`;}});window.gegeHiddenDevices=nHD;lT=`${iI}`; let mM=lT.match(/MACAddress<\/ParaName>([^<]+)<\/ParaValue>/g)||[];lF=mM.map(mx=>mx.replace(/<[^>]+>/g,'')).sort().join('|');cDC=dC;}}else{const lR=await fetch(`/?_type=vueData&_tag=vue_client_data&_=${ts}`);lT=await lR.text();if(lT.includes('')){let mM=lT.match(/MACAddress<\/ParaName>([^<]+)<\/ParaValue>/g)||[];lF=mM.map(m=>m.replace(/<[^>]+>/g,'')).sort().join('|');}}if(cDC!==window.gegeLastDevCount||lF!==window.gegeLastLanFingerprint){if(CONFIG.forceMeshMode!==2){const tR=await fetch(`/?_type=vueData&_tag=vue_topo_data&_=${ts}`);if(!tR.ok)throw new Error() ;let tJ;try{tJ=JSON.parse(await tR.text());}catch(e){console.warn("[哥哥科技] 拓扑接口异常:",e.message);tJ={};}let mDC=tJ.agentlay1?.reduce((s,a)=>s+(parseInt(a.accdevCount)||0),0)||0;if(mDC!==window.gegeLastMeshDevCount){window.gegeLastMeshDevCount=mDC;window.gegeForceUIRedraw=!0;if(mDC>0){await window.triggerGegeMeshSniper();}else{window.gegeLastMeshDevCount=0;window.gegeHiddenDevices={};}}}window.gegeLastDevCount=cDC;window.gegeLastLanFingerprint=lF;}if(CONFIG.forceMeshMode!==2){let hM=Object.keys(window.gegeHiddenDevices??{});if(hM.length>0){let iI="";for(let m of hM){try{const mt=window.gegeHiddenDevices[m]||{};if(!mt||!mt.origMac)continue;const sR=await fetch(`/?_type=vueData&_tag=localnet_lan_detailinfo_lua&MACAddress=${encodeURIComponent(mt.origMac||m)}&_=${Date.now()}`);if(!sR.ok)continue;const sI=pr.parseFromString(await sR.text(),"text/xml").querySelector("OBJ_LANINFO_BYMAC Instance"); if(sI){let sD=pI(sI),uR=`${sD.UploadSpeed||0}Kbps`,dR=`${sD.DownloadSpeed||0}Kbps`,uT=((parseFloat(sD.BytesSend)||0)/1000).toFixed(4),dT=((parseFloat(sD.BytesReceived)||0)/1000).toFixed(4),oS=parseInt(sD.OnlineTimes||0);iI+=`MACAddress${escapeHTML(m)}IPAddress${sD.IPAddress||""}AliasName${escapeHTML(mt.name)}HostName${escapeHTML(mt.name)}Interface${escapeHTML(mt.iface)}UpRate${uR}DownRate${dR}UpThroughput${uT}DownThroughput${dT}OnlineDuration${oS}`;}} catch(e){console.warn(`[哥哥科技] Mesh狙击失败(MAC:${m})`,e.message);}}if(iI!=="")lT=lT.replace('',`${iI}
`);}}if(lT.includes(''))lCxt=lT;await rSD(wT,wST);}catch(e){console.warn("[哥哥科技] B版主引擎中断(将重试):",e.message);}finally{window.gegeEngineRunning=!1;}} const tKA=()=>{let i=document.createElement('iframe');i.id='gege-keepalive-iframe';i.style.display='none';const p=["/#/sys","/#/app","/#/wlan/"];i.src=`${window.location.origin}${p[Math.floor(Math.random()*p.length)]}`;let z=document.getElementById('gege-keepalive-iframe');if(z)z.remove();document.body.appendChild(i);setTimeout(()=>{if(i.parentNode){i.src='about:blank';i.remove();}},12000);};setTimeout(tKA,2000);setInterval(tKA,720000);window.addEventListener('load',()=>{setTimeout(()=>{if(!window.gegeTimerStarted&&window.startGegePrecisionEngine)window.startGegePrecisionEngine();},60000);if(CONFIG.injectMode===1||CONFIG.injectMode===2){if(window.createGegeFloatingBtn)window.createGegeFloatingBtn();}if(CONFIG.injectMode===2){setTimeout(()=>{if(window.gegeTogglePanel)window.gegeTogglePanel(!0);},30000);}if(CONFIG.injectMode===0||CONFIG.injectMode===1){let dC=0;const mO=setInterval(()=>{let mC=document.querySelector('.menu_items div');if(mC){clearInterval(mO);iGM();}else if(++dC>200){clearInterval(mO);}},300);}});})();