2024-12-13 19:58:22 +08:00
|
|
|
|
var JgqiJ5w,q4ip9G,QLfE7R,qWapt_,jdSawTb,gX1fJx,GEU6Hr,cEznFQ,uLSOg7s;const Dtk6Aj=["length",0x1,"b",0x0,0x8,"c",0xda,"i","g",0x5,"f","d",0xff,0x2,0x3,"a",0x4,"undefined",void 0x0,0xf7,0xc,0x3f,0x6,"fromCodePoint",0x7,"push",0x3c,0x5b,0x94,0x1fff,0x58,0xd,0xe,!0x1,0x59,0x5a,0x60,"h",0x9,0x52,0x65,0x67,0x11,0xf5,0xec,0x6d,0xee,"e",0x55,0xdd,0x4a,0x76,0x78,0x64,0x75,0x2e,0xf8,0x7f,0x80,0x50,0x70,0xd8,0xbf,0x38,0x29,0x83,0x8b,0x8c,0x8d,0x7b,0x90,0xa,0xaf,0xb0,0x33,0xd0,0xe9,0xb7,0xad,0xb5,0xb,0x9a,0x82,0xf,0x69,0x3e,0x2c,0xa1,0xa2,0xa0,0xa3,0xa5,0xa4,0x6a,0x87,0x4c," ",0xb9,0xa8,0x6b,0x24,0x68,0x9c,0x3d,0xcc,0x7d,0x45,0x1f4,0x21,0xed,0xa7,0x22,0x7d0,"id",0xd1,0xd2,0x3e8,0x37,0x17,0x62,0x5c,0xc9,0x6e,0x41,!0x0,0xdf,0x49,0x2b,0xab,0xf3,0xdb,0xe5,0xc8,0xef,0xe4,0x81,0x63,0x5d,0xc3,0x89,0x20,0x42,0xeb,0xf0,0x31,0x97,0xf9,0xc1,0x57,0xfa,0xfb,0xd5,0x79,0x46,0xfc,0x4f,"m","UA",0x10d,0x9f,0x115,0x98,0xe0,0xcd,0x126,0x12a,0x128,0x66,0x71,0x109,"ua",0x146,0x25,0xe2,0xbd,0xe6,0xbb,0x43,0xde,0x15e,"\n",0xce,0x12e,0x164,0xe1,0x185,0x16b,0x5e,0x95,0x1d,0x1b2,0x1b3,0x1b5,0x1b6,0x1b9,0x1be,0x92,0x53,0x1c1,0x1c0,0x1cb,0xf6];pGFsE0(kVEx6u(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H","3foC5Yj@|vwKm4tZ1)}8crf4YUfVOhwv","B)q/NDy,E^,|Lx~o4Md&Z{A<vbC4g[0I7DB#cCC]_6O[&%","K^:{3yxEo6J@N","]|(Ff=w*pMm)ToLoV?dGbSF*&^o#+R,H=$g#+sN","R^8Te2L!0qE!E2=9O?IT+L(9e*%8%ajQV$Oy6G@1#El^ir\"I+Gi#q,USME<","s3`}9j#6%g~^:|]Z0fXdHLAk!","lD`t5Sd<<^xVTogUfqXd8]P*kH=","hZ&leWZ1*ET&kxIhB^u:3eO!:qC@)IU,a?B#i*}rl>F4kIbTGN","5M<)Rp_5fUD{Hj|4()j;NRhg>M.(+zbo3^(",";$lGrb:]P|?+ani<afKML:K?%","0zMt>Y;TLH","l$Nw44N","=Z1l*dzE^bhq&u?,)Dj;8*Xg0vw","/h~Cgxy(2;$br(JowMr8+yb4u^lKIuaVX*t85x85#q]d)OB<R`u)LxN","jf){td1EP+h~JE!s=?#MVs(;@bTZ9o*<j#d}d&N","F$XG3KlkKbJn$ucBH,6!+YY4s6`Sh.,o>#x#IYN","eMl7j&4raEG;Pz#s!*%","}M^;atRr$61Z_z[h>fu:Qra~z|cG[|hl@QH:Q","dvbQt?,T+qIF5","j?8)S{sgR6&4Ye~V9G#~K3jEC8mJh(D45G.GJGE@7","w,HdKtiZ#EBjGYnl3x%/5tJ4`bZVAI$U:`k}RoWC/^fz3sM,:=Pl[&F5","vDFh?{?rq*R","S^ZF~YWV6UxL/YXsv)r7","{o~tV&]Z8Em=m4M,o$qt{?TCwMfQH(T4W|O)VWKK^*mezo~o7>M}/Dlkd`h","s%Fk+`#Ffk[vuz(T)*4d&L9T%gkUca>o=fK&w2N","XPIMX=Zgw[zv
|
2024-11-25 10:18:04 +08:00
|
|
|
|
function Env(o,t){class s{constructor(t){this.env=t}send(t,e="GET"){t="string"==typeof t?{url:t}:t;let s=this.get;return"POST"===e&&(s=this.post),new Promise((r,i)=>{s.call(this,t,(t,e,s)=>{t?i(t):r(e)})})}get(t){return this.send.call(this.env,t)}post(t){return this.send.call(this.env,t,"POST")}}return new class{constructor(t,e){this.logLevels={debug:0,info:1,warn:2,error:3},this.logLevelPrefixs={debug:"[DEBUG] ",info:"[INFO] ",warn:"[WARN] ",error:"[ERROR] "},this.logLevel="info",this.name=t,this.http=new s(this),this.data=null,this.dataFile="box.dat",this.logs=[],this.isMute=!1,this.isNeedRewrite=!1,this.logSeparator="\n",this.encoding="utf-8",this.startTime=(new Date).getTime(),Object.assign(this,e),this.log("",`🔔${this.name}, 开始!`)}getEnv(){return"undefined"!=typeof $environment&&$environment["surge-version"]?"Surge":"undefined"!=typeof $environment&&$environment["stash-version"]?"Stash":"undefined"!=typeof module&&module.exports?"Node.js":"undefined"!=typeof $task?"Quantumult X":"undefined"!=typeof $loon?"Loon":"undefined"!=typeof $rocket?"Shadowrocket":void 0}isNode(){return"Node.js"===this.getEnv()}isQuanX(){return"Quantumult X"===this.getEnv()}isSurge(){return"Surge"===this.getEnv()}isLoon(){return"Loon"===this.getEnv()}isShadowrocket(){return"Shadowrocket"===this.getEnv()}isStash(){return"Stash"===this.getEnv()}toObj(t,e=null){try{return JSON.parse(t)}catch{return e}}toStr(t,e=null,...s){try{return JSON.stringify(t,...s)}catch{return e}}getjson(t,e){let s=e;if(this.getdata(t))try{s=JSON.parse(this.getdata(t))}catch{}return s}setjson(t,e){try{return this.setdata(JSON.stringify(t),e)}catch{return!1}}getScript(t){return new Promise(r=>{this.get({url:t},(t,e,s)=>r(s))})}runScript(a,o){return new Promise(r=>{let t=this.getdata("@chavy_boxjs_userCfgs.httpapi");t=t&&t.replace(/\n/g,"").trim();var e=(e=this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout"))?+e:20,[s,i]=(e=o&&o.timeout?o.timeout:e,t.split("@"));this.post({url:`http://${i}/v1/scripting/evaluate`,body:{script_text:a,mock_type:"cron",timeout:e},headers:{"X-Key":s,Accept:"*/*"},timeout:e},(t,e,s)=>r(s))}).catch(t=>this.logErr(t))}loaddata(){if(!this.isNode())return{};this.fs=this.fs||require("fs"),this.path=this.path||require("path");var t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),r=!s&&this.fs.existsSync(e);if(!s&&!r)return{};r=s?t:e;try{return JSON.parse(this.fs.readFileSync(r))}catch(t){return{}}}writedata(){var t,e,s,r,i;this.isNode()&&(this.fs=this.fs||require("fs"),this.path=this.path||require("path"),t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),r=!(s=this.fs.existsSync(t))&&this.fs.existsSync(e),i=JSON.stringify(this.data),!s&&r?this.fs.writeFileSync(e,i):this.fs.writeFileSync(t,i))}lodash_get(t,e,s){let r=t;for(const t of e.replace(/\[(\d+)\]/g,".$1").split("."))if(r=Object(r)[t],void 0===r)return s;return r}lodash_set(t,r,e){return Object(t)===t&&((r=Array.isArray(r)?r:r.toString().match(/[^.[\]]+/g)||[]).slice(0,-1).reduce((t,e,s)=>Object(t[e])===t[e]?t[e]:t[e]=Math.abs(r[s+1])>>0==+r[s+1]?[]:{},t)[r[r.length-1]]=e),t}getdata(t){let e=this.getval(t);if(/^@/.test(t)){var[,s,r]=/^@(.*?)\.(.*?)$/.exec(t);if(s=s?this.getval(s):"")try{const t=JSON.parse(s);e=t?this.lodash_get(t,r,""):e}catch(t){e=""}}return e}setdata(t,e){let s=!1;if(/^@/.test(e)){var[,r,i]=/^@(.*?)\.(.*?)$/.exec(e),a=this.getval(r),a=r?"null"===a?null:a||"{}":"{}";try{const e=JSON.parse(a);this.lodash_set(e,i,t),s=this.setval(JSON.stringify(e),r)}catch(e){this.lodash_set(a={},i,t),s=this.setval(JSON.stringify(a),r)}}else s=this.setval(t,e);return s}getval(t){switch(this.getEnv()){case"Surge":case"Loon":case"Stash":case"Shadowrocket":return $persistentStore.read(t);case"Quantumult X":return $prefs.valueForKey(t);case"Node.js":return this.data=this.loaddata(),this.data[t];default:return this.data&&this.data[t]||null}}setval(t,e){switch(this.getEnv()){case"Surge":case"Loon":case"Stash":case"Shadowrocket":return $persistentStore.write(t,e);case"Quantumult X":return $prefs.setValueF
|