├── README.md └── Script └── 10010.js /README.md: -------------------------------------------------------------------------------- 1 | # 联通余量(v3) 2 | [源仓库](https://github.com/ChinaTelecomOperators/ChinaUnicom) 3 | > 本库仅供学习交流,如有问题请看源仓库 4 | 5 | ## 使用教程-青龙 6 | > 脚本经由本人简单修改方便小白使用,详细教程和原脚本请看源仓库 7 | 8 | ### 第一步 9 | 青龙拉取脚本 10 | ``` 11 | ql raw https://github.com/liyw0205/ChinaUnicom-v3/releases/download/v1/10010.js 12 | ``` 13 | 14 | 修改定时 15 | > 以下定时为15分钟运行一次 16 | ``` 17 | */15 * * * * 18 | ``` 19 | > 以下定时为上午7点到晚上11点每15分钟运行一次 20 | ``` 21 | */15 7-23 * * * 22 | ``` 23 | > 以下定时为上午7点到晚上11点每30分钟运行一次 24 | ``` 25 | */30 7-23 * * * 26 | ``` 27 | 更多定时请百度 28 | 29 | ### 第二步 30 | 添加账号信息 31 | 脚本管理里找到脚本,在57行添加手机号,59添加服务密码,67行添加APPID 32 | > APPID可以通过抓包及其他方法 33 | 34 | ### 多用户 35 | 把脚本复制并重命名即可,一个脚本一份账号信息 36 | > 如10010_2.js 10010_3.js以此类推 37 | 缺点是会生成同一个10010-box.dat,导致某些信息错误 38 | 解决办法是新建文件夹,一个文件夹放一个脚本 39 | 40 | ### 推送 41 | 在配置文件config.sh里添加或者在脚本管理里sendNotify.js添加,脚本自动获取推送 42 | > 推送怎么注册就不多说了 43 | 44 | 修改完成就可以开始跑了 45 | 46 | ### 访问量 47 | 48 | ![](http://profile-counter.glitch.me/liyw0205/count.svg) 49 | -------------------------------------------------------------------------------- /Script/10010.js: -------------------------------------------------------------------------------- 1 | //#region JSEncrypt 2 | // prettier-ignore 3 | var navigator=navigator||{};var window=window||{};ASN1={};Hex={};Base64S={};var JSEncryptExports={}; (function(exports){var dbits;var canary=0xdeadbeefcafe;var j_lm=(canary&16777215)==15715070;function BigInteger(a,b,c){if(a!=null)if("number"==typeof a)this.fromNumber(a,b,c);else if(b==null&&"string"!=typeof a)this.fromString(a,256);else this.fromString(a,b)}function nbi(){return new BigInteger(null)}function am1(i,x,w,j,c,n){while(--n>=0){var v=x*this[i++]+w[j]+c;c=Math.floor(v/67108864);w[j++]=v&67108863}return c}function am2(i,x,w,j,c,n){var xl=x&32767,xh=x>>15;while(--n>=0){var l=this[i]&32767; var h=this[i++]>>15;var m=xh*l+h*xl;l=xl*l+((m&32767)<<15)+w[j]+(c&1073741823);c=(l>>>30)+(m>>>15)+xh*h+(c>>>30);w[j++]=l&1073741823}return c}function am3(i,x,w,j,c,n){var xl=x&16383,xh=x>>14;while(--n>=0){var l=this[i]&16383;var h=this[i++]>>14;var m=xh*l+h*xl;l=xl*l+((m&16383)<<14)+w[j]+c;c=(l>>28)+(m>>14)+xh*h;w[j++]=l&268435455}return c}if(j_lm&&navigator.appName=="Microsoft Internet Explorer"){BigInteger.prototype.am=am2;dbits=30}else if(j_lm&&navigator.appName!="Netscape"){BigInteger.prototype.am= am1;dbits=26}else{BigInteger.prototype.am=am3;dbits=28}BigInteger.prototype.DB=dbits;BigInteger.prototype.DM=(1<=0;--i)r[i]=this[i];r.t=this.t;r.s=this.s}function bnpFromInt(x){this.t=1;this.s=x<0?-1:0;if(x>0)this[0]=x;else if(x<-1)this[0]=x+this.DV;else this.t=0}function nbv(i){var r=nbi();r.fromInt(i);return r}function bnpFromString(s,b){var k;if(b==16)k=4;else if(b==8)k=3;else if(b==256)k=8;else if(b==2)k=1;else if(b==32)k= 5;else if(b==4)k=2;else{this.fromRadix(s,b);return}this.t=0;this.s=0;var i=s.length,mi=false,sh=0;while(--i>=0){var x=k==8?s[i]&255:intAt(s,i);if(x<0){if(s.charAt(i)=="-")mi=true;continue}mi=false;if(sh==0)this[this.t++]=x;else if(sh+k>this.DB){this[this.t-1]|=(x&(1<>this.DB-sh}else this[this.t-1]|=x<=this.DB)sh-=this.DB}if(k==8&&(s[0]&128)!=0){this.s=-1;if(sh>0)this[this.t-1]|=(1<0&&this[this.t-1]==c)--this.t}function bnToString(b){if(this.s<0)return"-"+this.negate().toString(b);var k;if(b==16)k=4;else if(b==8)k=3;else if(b==2)k=1;else if(b==32)k=5;else if(b==4)k=2;else return this.toRadix(b);var km=(1<0){if(p>p)>0){m=true;r=int2char(d)}while(i>=0){if(p>(p+=this.DB-k)}else{d=this[i]>>(p-= k)&km;if(p<=0){p+=this.DB;--i}}if(d>0)m=true;if(m)r+=int2char(d)}}return m?r:"0"}function bnNegate(){var r=nbi();BigInteger.ZERO.subTo(this,r);return r}function bnAbs(){return this.s<0?this.negate():this}function bnCompareTo(a){var r=this.s-a.s;if(r!=0)return r;var i=this.t;r=i-a.t;if(r!=0)return this.s<0?-r:r;while(--i>=0)if((r=this[i]-a[i])!=0)return r;return 0}function nbits(x){var r=1,t;if((t=x>>>16)!=0){x=t;r+=16}if((t=x>>8)!=0){x=t;r+=8}if((t=x>>4)!=0){x=t;r+=4}if((t=x>>2)!=0){x=t;r+=2}if((t= x>>1)!=0){x=t;r+=1}return r}function bnBitLength(){if(this.t<=0)return 0;return this.DB*(this.t-1)+nbits(this[this.t-1]^this.s&this.DM)}function bnpDLShiftTo(n,r){var i;for(i=this.t-1;i>=0;--i)r[i+n]=this[i];for(i=n-1;i>=0;--i)r[i]=0;r.t=this.t+n;r.s=this.s}function bnpDRShiftTo(n,r){for(var i=n;i=0;--i){r[i+ds+1]=this[i]>>cbs|c;c=(this[i]&bm)<=0;--i)r[i]=0;r[ds]=c;r.t=this.t+ds+1;r.s=this.s;r.clamp()}function bnpRShiftTo(n,r){r.s=this.s;var ds=Math.floor(n/this.DB);if(ds>=this.t){r.t=0;return}var bs=n%this.DB;var cbs=this.DB-bs;var bm=(1<>bs;for(var i=ds+1;i>bs}if(bs>0)r[this.t-ds-1]|=(this.s&bm)<>=this.DB}if(a.t>=this.DB}c+=this.s}else{c+=this.s;while(i>=this.DB}c-=a.s}r.s=c<0?-1:0;if(c<-1)r[i++]=this.DV+c;else if(c>0)r[i++]=c;r.t=i;r.clamp()}function bnpMultiplyTo(a,r){var x=this.abs(),y=a.abs();var i=x.t;r.t=i+y.t;while(--i>=0)r[i]=0;for(i=0;i=0)r[i]=0;for(i=0;i=x.DV){r[i+x.t]-=x.DV;r[i+x.t+1]=1}}if(r.t>0)r[r.t-1]+=x.am(i,x[i],r,2*i,0,1);r.s=0;r.clamp()}function bnpDivRemTo(m,q,r){var pm=m.abs();if(pm.t<=0)return;var pt=this.abs();if(pt.t0){pm.lShiftTo(nsh,y); pt.lShiftTo(nsh,r)}else{pm.copyTo(y);pt.copyTo(r)}var ys=y.t;var y0=y[ys-1];if(y0==0)return;var yt=y0*(1<1?y[ys-2]>>this.F2:0);var d1=this.FV/yt,d2=(1<=0){r[r.t++]=1;r.subTo(t,r)}BigInteger.ONE.dlShiftTo(ys,t);t.subTo(y,y);while(y.t=0){var qd=r[--i]==y0?this.DM:Math.floor(r[i]*d1+(r[i-1]+e)*d2);if((r[i]+=y.am(0,qd,r,j,0,ys))0)r.rShiftTo(nsh,r);if(ts<0)BigInteger.ZERO.subTo(r,r)}function bnMod(a){var r=nbi();this.abs().divRemTo(a,null,r);if(this.s<0&&r.compareTo(BigInteger.ZERO)>0)a.subTo(r,r);return r}function Classic(m){this.m=m}function cConvert(x){if(x.s<0||x.compareTo(this.m)>=0)return x.mod(this.m);else return x}function cRevert(x){return x}function cReduce(x){x.divRemTo(this.m,null,x)}function cMulTo(x, y,r){x.multiplyTo(y,r);this.reduce(r)}function cSqrTo(x,r){x.squareTo(r);this.reduce(r)}Classic.prototype.convert=cConvert;Classic.prototype.revert=cRevert;Classic.prototype.reduce=cReduce;Classic.prototype.mulTo=cMulTo;Classic.prototype.sqrTo=cSqrTo;function bnpInvDigit(){if(this.t<1)return 0;var x=this[0];if((x&1)==0)return 0;var y=x&3;y=y*(2-(x&15)*y)&15;y=y*(2-(x&255)*y)&255;y=y*(2-((x&65535)*y&65535))&65535;y=y*(2-x*y%this.DV)%this.DV;return y>0?this.DV-y:-y}function Montgomery(m){this.m=m;this.mp= m.invDigit();this.mpl=this.mp&32767;this.mph=this.mp>>15;this.um=(1<0)this.m.subTo(r,r);return r}function montRevert(x){var r=nbi();x.copyTo(r);this.reduce(r);return r}function montReduce(x){while(x.t<=this.mt2)x[x.t++]=0;for(var i=0;i>15)*this.mpl&this.um)<<15)&x.DM;j=i+this.m.t; x[j]+=this.m.am(0,u0,x,i,0,this.m.t);while(x[j]>=x.DV){x[j]-=x.DV;x[++j]++}}x.clamp();x.drShiftTo(this.m.t,x);if(x.compareTo(this.m)>=0)x.subTo(this.m,x)}function montSqrTo(x,r){x.squareTo(r);this.reduce(r)}function montMulTo(x,y,r){x.multiplyTo(y,r);this.reduce(r)}Montgomery.prototype.convert=montConvert;Montgomery.prototype.revert=montRevert;Montgomery.prototype.reduce=montReduce;Montgomery.prototype.mulTo=montMulTo;Montgomery.prototype.sqrTo=montSqrTo;function bnpIsEven(){return(this.t>0?this[0]& 1:this.s)==0}function bnpExp(e,z){if(e>4294967295||e<1)return BigInteger.ONE;var r=nbi(),r2=nbi(),g=z.convert(this),i=nbits(e)-1;g.copyTo(r);while(--i>=0){z.sqrTo(r,r2);if((e&1<0)z.mulTo(r2,g,r);else{var t=r;r=r2;r2=t}}return z.revert(r)}function bnModPowInt(e,m){var z;if(e<256||m.isEven())z=new Classic(m);else z=new Montgomery(m);return this.exp(e,z)}BigInteger.prototype.copyTo=bnpCopyTo;BigInteger.prototype.fromInt=bnpFromInt;BigInteger.prototype.fromString=bnpFromString;BigInteger.prototype.clamp= bnpClamp;BigInteger.prototype.dlShiftTo=bnpDLShiftTo;BigInteger.prototype.drShiftTo=bnpDRShiftTo;BigInteger.prototype.lShiftTo=bnpLShiftTo;BigInteger.prototype.rShiftTo=bnpRShiftTo;BigInteger.prototype.subTo=bnpSubTo;BigInteger.prototype.multiplyTo=bnpMultiplyTo;BigInteger.prototype.squareTo=bnpSquareTo;BigInteger.prototype.divRemTo=bnpDivRemTo;BigInteger.prototype.invDigit=bnpInvDigit;BigInteger.prototype.isEven=bnpIsEven;BigInteger.prototype.exp=bnpExp;BigInteger.prototype.toString=bnToString;BigInteger.prototype.negate= bnNegate;BigInteger.prototype.abs=bnAbs;BigInteger.prototype.compareTo=bnCompareTo;BigInteger.prototype.bitLength=bnBitLength;BigInteger.prototype.mod=bnMod;BigInteger.prototype.modPowInt=bnModPowInt;BigInteger.ZERO=nbv(0);BigInteger.ONE=nbv(1);function bnClone(){var r=nbi();this.copyTo(r);return r}function bnIntValue(){if(this.s<0)if(this.t==1)return this[0]-this.DV;else{if(this.t==0)return-1}else if(this.t==1)return this[0];else if(this.t==0)return 0;return(this[1]&(1<<32-this.DB)-1)<>24}function bnShortValue(){return this.t==0?this.s:this[0]<<16>>16}function bnpChunkSize(r){return Math.floor(Math.LN2*this.DB/Math.log(r))}function bnSigNum(){if(this.s<0)return-1;else if(this.t<=0||this.t==1&&this[0]<=0)return 0;else return 1}function bnpToRadix(b){if(b==null)b=10;if(this.signum()==0||b<2||b>36)return"0";var cs=this.chunkSize(b);var a=Math.pow(b,cs);var d=nbv(a),y=nbi(),z=nbi(),r="";this.divRemTo(d,y,z);while(y.signum()> 0){r=(a+z.intValue()).toString(b).substr(1)+r;y.divRemTo(d,y,z)}return z.intValue().toString(b)+r}function bnpFromRadix(s,b){this.fromInt(0);if(b==null)b=10;var cs=this.chunkSize(b);var d=Math.pow(b,cs),mi=false,j=0,w=0;for(var i=0;i=cs){this.dMultiply(d);this.dAddOffset(w,0);j=0;w=0}}if(j>0){this.dMultiply(Math.pow(b,j));this.dAddOffset(w,0)}if(mi)BigInteger.ZERO.subTo(this,this)}function bnpFromNumber(a, b,c){if("number"==typeof b)if(a<2)this.fromInt(1);else{this.fromNumber(a,c);if(!this.testBit(a-1))this.bitwiseTo(BigInteger.ONE.shiftLeft(a-1),op_or,this);if(this.isEven())this.dAddOffset(1,0);while(!this.isProbablePrime(b)){this.dAddOffset(2,0);if(this.bitLength()>a)this.subTo(BigInteger.ONE.shiftLeft(a-1),this)}}else{var x=new Array,t=a&7;x.length=(a>>3)+1;b.nextBytes(x);if(t>0)x[0]&=(1<0){if(p>p)!=(this.s&this.DM)>>p)r[k++]=d|this.s<=0){if(p<8){d=(this[i]&(1<>(p+=this.DB-8)}else{d=this[i]>>(p-=8)&255;if(p<=0){p+=this.DB;--i}}if((d&128)!=0)d|=-256;if(k==0&&(this.s&128)!=(d&128))++k;if(k>0||d!=this.s)r[k++]=d}}return r}function bnEquals(a){return this.compareTo(a)==0}function bnMin(a){return this.compareTo(a)<0?this:a}function bnMax(a){return this.compareTo(a)>0?this:a}function bnpBitwiseTo(a, op,r){var i,f,m=Math.min(a.t,this.t);for(i=0;i>=16;r+=16}if((x&255)==0){x>>=8;r+=8}if((x&15)==0){x>>=4;r+=4}if((x&3)==0){x>>=2;r+=2}if((x&1)==0)++r;return r}function bnGetLowestSetBit(){for(var i=0;i=this.t)return this.s!=0;return(this[j]& 1<>=this.DB}if(a.t>=this.DB}c+=this.s}else{c+=this.s;while(i>=this.DB}c+=a.s}r.s=c<0?-1:0;if(c>0)r[i++]=c;else if(c<-1)r[i++]=this.DV+c;r.t=i;r.clamp()}function bnAdd(a){var r=nbi();this.addTo(a,r);return r}function bnSubtract(a){var r=nbi();this.subTo(a,r);return r}function bnMultiply(a){var r=nbi();this.multiplyTo(a,r);return r}function bnSquare(){var r=nbi();this.squareTo(r);return r}function bnDivide(a){var r=nbi();this.divRemTo(a,r,null);return r}function bnRemainder(a){var r=nbi();this.divRemTo(a,null,r);return r}function bnDivideAndRemainder(a){var q= nbi(),r=nbi();this.divRemTo(a,q,r);return new Array(q,r)}function bnpDMultiply(n){this[this.t]=this.am(0,n-1,this,0,0,this.t);++this.t;this.clamp()}function bnpDAddOffset(n,w){if(n==0)return;while(this.t<=w)this[this.t++]=0;this[w]+=n;while(this[w]>=this.DV){this[w]-=this.DV;if(++w>=this.t)this[this.t++]=0;++this[w]}}function NullExp(){}function nNop(x){return x}function nMulTo(x,y,r){x.multiplyTo(y,r)}function nSqrTo(x,r){x.squareTo(r)}NullExp.prototype.convert=nNop;NullExp.prototype.revert=nNop; NullExp.prototype.mulTo=nMulTo;NullExp.prototype.sqrTo=nSqrTo;function bnPow(e){return this.exp(e,new NullExp)}function bnpMultiplyLowerTo(a,n,r){var i=Math.min(this.t+a.t,n);r.s=0;r.t=i;while(i>0)r[--i]=0;var j;for(j=r.t-this.t;i=0)r[i]=0;for(i=Math.max(n-this.t,0);i2*this.m.t)return x.mod(this.m);else if(x.compareTo(this.m)<0)return x;else{var r=nbi();x.copyTo(r);this.reduce(r);return r}}function barrettRevert(x){return x}function barrettReduce(x){x.drShiftTo(this.m.t-1,this.r2);if(x.t>this.m.t+1){x.t=this.m.t+1;x.clamp()}this.mu.multiplyUpperTo(this.r2, this.m.t+1,this.q3);this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);while(x.compareTo(this.r2)<0)x.dAddOffset(1,this.m.t+1);x.subTo(this.r2,x);while(x.compareTo(this.m)>=0)x.subTo(this.m,x)}function barrettSqrTo(x,r){x.squareTo(r);this.reduce(r)}function barrettMulTo(x,y,r){x.multiplyTo(y,r);this.reduce(r)}Barrett.prototype.convert=barrettConvert;Barrett.prototype.revert=barrettRevert;Barrett.prototype.reduce=barrettReduce;Barrett.prototype.mulTo=barrettMulTo;Barrett.prototype.sqrTo=barrettSqrTo; function bnModPow(e,m){var i=e.bitLength(),k,r=nbv(1),z;if(i<=0)return r;else if(i<18)k=1;else if(i<48)k=3;else if(i<144)k=4;else if(i<768)k=5;else k=6;if(i<8)z=new Classic(m);else if(m.isEven())z=new Barrett(m);else z=new Montgomery(m);var g=new Array,n=3,k1=k-1,km=(1<1){var g2=nbi();z.sqrTo(g[1],g2);while(n<=km){g[n]=nbi();z.mulTo(g2,g[n-2],g[n]);n+=2}}var j=e.t-1,w,is1=true,r2=nbi(),t;i=nbits(e[j])-1;while(j>=0){if(i>=k1)w=e[j]>>i-k1&km;else{w=(e[j]&(1<0)w|=e[j-1]>>this.DB+i-k1}n=k;while((w&1)==0){w>>=1;--n}if((i-=n)<0){i+=this.DB;--j}if(is1){g[w].copyTo(r);is1=false}else{while(n>1){z.sqrTo(r,r2);z.sqrTo(r2,r);n-=2}if(n>0)z.sqrTo(r,r2);else{t=r;r=r2;r2=t}z.mulTo(r2,g[w],r)}while(j>=0&&(e[j]&1<0){x.rShiftTo(g,x);y.rShiftTo(g,y)}while(x.signum()>0){if((i=x.getLowestSetBit())>0)x.rShiftTo(i,x);if((i=y.getLowestSetBit())>0)y.rShiftTo(i,y);if(x.compareTo(y)>=0){x.subTo(y,x);x.rShiftTo(1,x)}else{y.subTo(x,y);y.rShiftTo(1,y)}}if(g>0)y.lShiftTo(g,y);return y}function bnpModInt(n){if(n<=0)return 0;var d=this.DV%n,r=this.s<0?n-1:0;if(this.t>0)if(d==0)r=this[0]%n;else for(var i=this.t-1;i>=0;--i)r=(d*r+this[i])%n;return r}function bnModInverse(m){var ac=m.isEven(); if(this.isEven()&&ac||m.signum()==0)return BigInteger.ZERO;var u=m.clone(),v=this.clone();var a=nbv(1),b=nbv(0),c=nbv(0),d=nbv(1);while(u.signum()!=0){while(u.isEven()){u.rShiftTo(1,u);if(ac){if(!a.isEven()||!b.isEven()){a.addTo(this,a);b.subTo(m,b)}a.rShiftTo(1,a)}else if(!b.isEven())b.subTo(m,b);b.rShiftTo(1,b)}while(v.isEven()){v.rShiftTo(1,v);if(ac){if(!c.isEven()||!d.isEven()){c.addTo(this,c);d.subTo(m,d)}c.rShiftTo(1,c)}else if(!d.isEven())d.subTo(m,d);d.rShiftTo(1,d)}if(u.compareTo(v)>=0){u.subTo(v, u);if(ac)a.subTo(c,a);b.subTo(d,b)}else{v.subTo(u,v);if(ac)c.subTo(a,c);d.subTo(b,d)}}if(v.compareTo(BigInteger.ONE)!=0)return BigInteger.ZERO;if(d.compareTo(m)>=0)return d.subtract(m);if(d.signum()<0)d.addTo(m,d);else return d;if(d.signum()<0)return d.add(m);else return d}var lowprimes=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283, 293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997];var lplim=(1<<26)/lowprimes[lowprimes.length-1];function bnIsProbablePrime(t){var i, x=this.abs();if(x.t==1&&x[0]<=lowprimes[lowprimes.length-1]){for(i=0;i>1; if(t>lowprimes.length)t=lowprimes.length;var a=nbi();for(var i=0;i=256||rng_pptr>=rng_psize){if(window.removeEventListener)window.removeEventListener("mousemove",onMouseMoveListener);else if(window.detachEvent)window.detachEvent("onmousemove",onMouseMoveListener);return}this.count+=1;var mouseCoordinates=ev.x+ev.y;rng_pool[rng_pptr++]=mouseCoordinates&255};if(window.addEventListener)window.addEventListener("mousemove",onMouseMoveListener);else if(window.attachEvent)window.attachEvent("onmousemove", onMouseMoveListener)}function rng_get_byte(){if(rng_state==null){rng_state=prng_newstate();while(rng_pptr=0&&n>0){var c=s.charCodeAt(i--);if(c<128)ba[--n]=c;else if(c>127&&c<2048){ba[--n]=c&63|128;ba[--n]=c>>6|192}else{ba[--n]=c&63|128;ba[--n]=c>>6&63|128; ba[--n]=c>>12|224}}ba[--n]=0;var rng=new SecureRandom;var x=new Array;while(n>2){x[0]=0;while(x[0]==0)rng.nextBytes(x);ba[--n]=x[0]}ba[--n]=2;ba[--n]=0;return new BigInteger(ba)}function RSAKey(){this.n=null;this.e=0;this.d=null;this.p=null;this.q=null;this.dmp1=null;this.dmq1=null;this.coeff=null}function RSASetPublic(N,E){if(N!=null&&E!=null&&N.length>0&&E.length>0){this.n=parseBigInt(N,16);this.e=parseInt(E,16)}else console.log("Invalid RSA public key")}function RSADoPublic(x){return x.modPowInt(this.e, this.n)}function RSAEncrypt(text){var m=pkcs1pad2(text,this.n.bitLength()+7>>3);if(m==null)return null;var c=this.doPublic(m);if(c==null)return null;var h=c.toString(16);if((h.length&1)==0)return h;else return"0"+h}RSAKey.prototype.doPublic=RSADoPublic;RSAKey.prototype.setPublic=RSASetPublic;RSAKey.prototype.encrypt=RSAEncrypt;function pkcs1unpad2(d,n){var b=d.toByteArray();var i=0;while(i=b.length)return null; var ret="";while(++i191&&c<224){ret+=String.fromCharCode((c&31)<<6|b[i+1]&63);++i}else{ret+=String.fromCharCode((c&15)<<12|(b[i+1]&63)<<6|b[i+2]&63);i+=2}}return ret}function RSASetPrivate(N,E,D){if(N!=null&&E!=null&&N.length>0&&E.length>0){this.n=parseBigInt(N,16);this.e=parseInt(E,16);this.d=parseBigInt(D,16)}else console.log("Invalid RSA private key")}function RSASetPrivateEx(N,E,D,P,Q,DP,DQ,C){if(N!=null&&E!=null&&N.length> 0&&E.length>0){this.n=parseBigInt(N,16);this.e=parseInt(E,16);this.d=parseBigInt(D,16);this.p=parseBigInt(P,16);this.q=parseBigInt(Q,16);this.dmp1=parseBigInt(DP,16);this.dmq1=parseBigInt(DQ,16);this.coeff=parseBigInt(C,16)}else console.log("Invalid RSA private key")}function RSAGenerate(B,E){var rng=new SecureRandom;var qs=B>>1;this.e=parseInt(E,16);var ee=new BigInteger(E,16);for(;;){for(;;){this.p=new BigInteger(B-qs,1,rng);if(this.p.subtract(BigInteger.ONE).gcd(ee).compareTo(BigInteger.ONE)== 0&&this.p.isProbablePrime(10))break}for(;;){this.q=new BigInteger(qs,1,rng);if(this.q.subtract(BigInteger.ONE).gcd(ee).compareTo(BigInteger.ONE)==0&&this.q.isProbablePrime(10))break}if(this.p.compareTo(this.q)<=0){var t=this.p;this.p=this.q;this.q=t}var p1=this.p.subtract(BigInteger.ONE);var q1=this.q.subtract(BigInteger.ONE);var phi=p1.multiply(q1);if(phi.gcd(ee).compareTo(BigInteger.ONE)==0){this.n=this.p.multiply(this.q);this.d=ee.modInverse(phi);this.dmp1=this.d.mod(p1);this.dmq1=this.d.mod(q1); this.coeff=this.q.modInverse(this.p);break}}}function RSADoPrivate(x){if(this.p==null||this.q==null)return x.modPow(this.d,this.n);var xp=x.mod(this.p).modPow(this.dmp1,this.p);var xq=x.mod(this.q).modPow(this.dmq1,this.q);while(xp.compareTo(xq)<0)xp=xp.add(this.p);return xp.subtract(xq).multiply(this.coeff).mod(this.p).multiply(this.q).add(xq)}function RSADecrypt(ctext){var c=parseBigInt(ctext,16);var m=this.doPrivate(c);if(m==null)return null;return pkcs1unpad2(m,this.n.bitLength()+7>>3)}RSAKey.prototype.doPrivate= RSADoPrivate;RSAKey.prototype.setPrivate=RSASetPrivate;RSAKey.prototype.setPrivateEx=RSASetPrivateEx;RSAKey.prototype.generate=RSAGenerate;RSAKey.prototype.decrypt=RSADecrypt;(function(){var RSAGenerateAsync=function(B,E,callback){var rng=new SecureRandom;var qs=B>>1;this.e=parseInt(E,16);var ee=new BigInteger(E,16);var rsa=this;var loop1=function(){var loop4=function(){if(rsa.p.compareTo(rsa.q)<=0){var t=rsa.p;rsa.p=rsa.q;rsa.q=t}var p1=rsa.p.subtract(BigInteger.ONE);var q1=rsa.q.subtract(BigInteger.ONE); var phi=p1.multiply(q1);if(phi.gcd(ee).compareTo(BigInteger.ONE)==0){rsa.n=rsa.p.multiply(rsa.q);rsa.d=ee.modInverse(phi);rsa.dmp1=rsa.d.mod(p1);rsa.dmq1=rsa.d.mod(q1);rsa.coeff=rsa.q.modInverse(rsa.p);setTimeout(function(){callback()},0)}else setTimeout(loop1,0)};var loop3=function(){rsa.q=nbi();rsa.q.fromNumberAsync(qs,1,rng,function(){rsa.q.subtract(BigInteger.ONE).gcda(ee,function(r){if(r.compareTo(BigInteger.ONE)==0&&rsa.q.isProbablePrime(10))setTimeout(loop4,0);else setTimeout(loop3,0)})})}; var loop2=function(){rsa.p=nbi();rsa.p.fromNumberAsync(B-qs,1,rng,function(){rsa.p.subtract(BigInteger.ONE).gcda(ee,function(r){if(r.compareTo(BigInteger.ONE)==0&&rsa.p.isProbablePrime(10))setTimeout(loop3,0);else setTimeout(loop2,0)})})};setTimeout(loop2,0)};setTimeout(loop1,0)};RSAKey.prototype.generateAsync=RSAGenerateAsync;var bnGCDAsync=function(a,callback){var x=this.s<0?this.negate():this.clone();var y=a.s<0?a.negate():a.clone();if(x.compareTo(y)<0){var t=x;x=y;y=t}var i=x.getLowestSetBit(), g=y.getLowestSetBit();if(g<0){callback(x);return}if(i0){x.rShiftTo(g,x);y.rShiftTo(g,y)}var gcda1=function(){if((i=x.getLowestSetBit())>0)x.rShiftTo(i,x);if((i=y.getLowestSetBit())>0)y.rShiftTo(i,y);if(x.compareTo(y)>=0){x.subTo(y,x);x.rShiftTo(1,x)}else{y.subTo(x,y);y.rShiftTo(1,y)}if(!(x.signum()>0)){if(g>0)y.lShiftTo(g,y);setTimeout(function(){callback(y)},0)}else setTimeout(gcda1,0)};setTimeout(gcda1,10)};BigInteger.prototype.gcda=bnGCDAsync;var bnpFromNumberAsync=function(a,b,c,callback){if("number"== typeof b)if(a<2)this.fromInt(1);else{this.fromNumber(a,c);if(!this.testBit(a-1))this.bitwiseTo(BigInteger.ONE.shiftLeft(a-1),op_or,this);if(this.isEven())this.dAddOffset(1,0);var bnp=this;var bnpfn1=function(){bnp.dAddOffset(2,0);if(bnp.bitLength()>a)bnp.subTo(BigInteger.ONE.shiftLeft(a-1),bnp);if(bnp.isProbablePrime(b))setTimeout(function(){callback()},0);else setTimeout(bnpfn1,0)};setTimeout(bnpfn1,0)}else{var x=new Array,t=a&7;x.length=(a>>3)+1;b.nextBytes(x);if(t>0)x[0]&=(1<>6)+b64map.charAt(c&63)}if(i+1==h.length){c=parseInt(h.substring(i,i+1),16);ret+=b64map.charAt(c<<2)}else if(i+2==h.length){c=parseInt(h.substring(i,i+2),16);ret+=b64map.charAt(c>>2)+b64map.charAt((c& 3)<<4)}while((ret.length&3)>0)ret+=b64pad;return ret}function b64tohex(s){var ret="";var i;var k=0;var slop;for(i=0;i>2);slop=v&3;k=1}else if(k==1){ret+=int2char(slop<<2|v>>4);slop=v&15;k=2}else if(k==2){ret+=int2char(slop);ret+=int2char(v>>2);slop=v&3;k=3}else{ret+=int2char(slop<<2|v>>4);ret+=int2char(v&15);k=0}}if(k==1)ret+=int2char(slop<<2);return ret}function b64toBA(s){var h=b64tohex(s); var i;var a=new Array;for(i=0;2*i15)throw"ASN.1 length too long to represent by 8x: n = "+n.toString(16);var head=128+hNlen;return head.toString(16)+hN}};this.getEncodedHex=function(){if(this.hTLV==null||this.isModified){this.hV=this.getFreshValueHex();this.hL=this.getLengthHexFromValue();this.hTLV=this.hT+this.hL+this.hV;this.isModified=false}return this.hTLV};this.getValueHex=function(){this.getEncodedHex();return this.hV}; this.getFreshValueHex=function(){return""}};KJUR.asn1.DERAbstractString=function(params){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);var s=null;var hV=null;this.getString=function(){return this.s};this.setString=function(newS){this.hTLV=null;this.isModified=true;this.s=newS;this.hV=stohex(this.s)};this.setStringHex=function(newHexString){this.hTLV=null;this.isModified=true;this.s=null;this.hV=newHexString};this.getFreshValueHex=function(){return this.hV};if(typeof params!="undefined")if(typeof params["str"]!= "undefined")this.setString(params["str"]);else if(typeof params["hex"]!="undefined")this.setStringHex(params["hex"])};JSX.extend(KJUR.asn1.DERAbstractString,KJUR.asn1.ASN1Object);KJUR.asn1.DERAbstractTime=function(params){KJUR.asn1.DERAbstractTime.superclass.constructor.call(this);var s=null;var date=null;this.localDateToUTC=function(d){utc=d.getTime()+d.getTimezoneOffset()*6E4;var utcDate=new Date(utc);return utcDate};this.formatDate=function(dateObject,type){var pad=this.zeroPadding;var d=this.localDateToUTC(dateObject); var year=String(d.getFullYear());if(type=="utc")year=year.substr(2,2);var month=pad(String(d.getMonth()+1),2);var day=pad(String(d.getDate()),2);var hour=pad(String(d.getHours()),2);var min=pad(String(d.getMinutes()),2);var sec=pad(String(d.getSeconds()),2);return year+month+day+hour+min+sec+"Z"};this.zeroPadding=function(s,len){if(s.length>=len)return s;return(new Array(len-s.length+1)).join("0")+s};this.getString=function(){return this.s};this.setString=function(newS){this.hTLV=null;this.isModified= true;this.s=newS;this.hV=stohex(this.s)};this.setByDateValue=function(year,month,day,hour,min,sec){var dateObject=new Date(Date.UTC(year,month-1,day,hour,min,sec,0));this.setByDate(dateObject)};this.getFreshValueHex=function(){return this.hV}};JSX.extend(KJUR.asn1.DERAbstractTime,KJUR.asn1.ASN1Object);KJUR.asn1.DERAbstractStructured=function(params){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);var asn1Array=null;this.setByASN1ObjectArray=function(asn1ObjectArray){this.hTLV=null;this.isModified= true;this.asn1Array=asn1ObjectArray};this.appendASN1Object=function(asn1Object){this.hTLV=null;this.isModified=true;this.asn1Array.push(asn1Object)};this.asn1Array=new Array;if(typeof params!="undefined")if(typeof params["array"]!="undefined")this.asn1Array=params["array"]};JSX.extend(KJUR.asn1.DERAbstractStructured,KJUR.asn1.ASN1Object);KJUR.asn1.DERBoolean=function(){KJUR.asn1.DERBoolean.superclass.constructor.call(this);this.hT="01";this.hTLV="0101ff"};JSX.extend(KJUR.asn1.DERBoolean,KJUR.asn1.ASN1Object); KJUR.asn1.DERInteger=function(params){KJUR.asn1.DERInteger.superclass.constructor.call(this);this.hT="02";this.setByBigInteger=function(bigIntegerValue){this.hTLV=null;this.isModified=true;this.hV=KJUR.asn1.ASN1Util.bigIntToMinTwosComplementsHex(bigIntegerValue)};this.setByInteger=function(intValue){var bi=new BigInteger(String(intValue),10);this.setByBigInteger(bi)};this.setValueHex=function(newHexString){this.hV=newHexString};this.getFreshValueHex=function(){return this.hV};if(typeof params!="undefined")if(typeof params["bigint"]!= "undefined")this.setByBigInteger(params["bigint"]);else if(typeof params["int"]!="undefined")this.setByInteger(params["int"]);else if(typeof params["hex"]!="undefined")this.setValueHex(params["hex"])};JSX.extend(KJUR.asn1.DERInteger,KJUR.asn1.ASN1Object);KJUR.asn1.DERBitString=function(params){KJUR.asn1.DERBitString.superclass.constructor.call(this);this.hT="03";this.setHexValueIncludingUnusedBits=function(newHexStringIncludingUnusedBits){this.hTLV=null;this.isModified=true;this.hV=newHexStringIncludingUnusedBits}; this.setUnusedBitsAndHexValue=function(unusedBits,hValue){if(unusedBits<0||7=2){out[out.length]=bits;bits=0;char_count=0}else bits<<=4}if(char_count)throw"Hex encoding incomplete: 4 bits missing";return out};Hex=Hex1})();(function(undefined){var Base64S1= {},decoder;Base64S1.decode=function(a){var i;if(decoder===undefined){var b64="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",ignore="= \f\n\r\t\u00a0\u2028\u2029";decoder=[];for(i=0;i<64;++i)decoder[b64.charAt(i)]=i;for(i=0;i=4){out[out.length]= bits>>16;out[out.length]=bits>>8&255;out[out.length]=bits&255;bits=0;char_count=0}else bits<<=6}switch(char_count){case 1:throw"Base64S encoding incomplete: at least 2 bits missing";case 2:out[out.length]=bits>>10;break;case 3:out[out.length]=bits>>16;out[out.length]=bits>>8&255;break}return out};Base64S1.re=/-----BEGIN [^-]+-----([A-Za-z0-9+\/=\s]+)-----END [^-]+-----|begin-Base64S[^\n]+\n([A-Za-z0-9+\/=\s]+)====/;Base64S1.unarmor=function(a){var m=Base64S1.re.exec(a);if(m)if(m[1])a=m[1];else if(m[2])a= m[2];else throw"RegExp out of sync";return Base64S1.decode(a)};Base64S=Base64S1})();(function(undefined){var hardLimit=100,ellipsis="\u2026",DOM={tag:function(tagName,className){var t=document.createElement(tagName);t.className=className;return t},text:function(str){return document.createTextNode(str)}};function Stream(enc,pos){if(enc instanceof Stream){this.enc=enc.enc;this.pos=enc.pos}else{this.enc=enc;this.pos=pos}}Stream.prototype.get=function(pos){if(pos===undefined)pos=this.pos++;if(pos>=this.enc.length)throw"Requesting byte offset "+ pos+" on a stream of length "+this.enc.length;return this.enc[pos]};Stream.prototype.hexDigits="0123456789ABCDEF";Stream.prototype.hexByte=function(b){return this.hexDigits.charAt(b>>4&15)+this.hexDigits.charAt(b&15)};Stream.prototype.hexDump=function(start,end,raw){var s="";for(var i=start;i191&&c<224)s+=String.fromCharCode((c&31)<<6|this.get(i++)&63);else s+=String.fromCharCode((c&15)<<12|(this.get(i++)&63)<<6|this.get(i++)&63)}return s};Stream.prototype.parseStringBMP=function(start,end){var str="";for(var i=start;i4){len<<=3;var s=this.get(start);if(s===0)len-=8;else while(s<128){s<<=1;--len}return"("+len+" bit)"}var n=0;for(var i=start;istart;--i){var b=this.get(i); for(var j=skip;j<8;++j)s+=b>>j&1?"1":"0";skip=0}}return s};Stream.prototype.parseOctetString=function(start,end){var len=end-start,s="("+len+" byte) ";if(len>hardLimit)end=start+hardLimit;for(var i=start;ihardLimit)s+=ellipsis;return s};Stream.prototype.parseOID=function(start,end){var s="",n=0,bits=0;for(var i=start;i=31?"bigint": n);n=bits=0}}return s};function ASN11(stream,header,length,tag,sub){this.stream=stream;this.header=header;this.length=length;this.tag=tag;this.sub=sub}ASN11.prototype.typeName=function(){if(this.tag===undefined)return"unknown";var tagClass=this.tag>>6,tagConstructed=this.tag>>5&1,tagNumber=this.tag&31;switch(tagClass){case 0:switch(tagNumber){case 0:return"EOC";case 1:return"BOOLEAN";case 2:return"INTEGER";case 3:return"BIT_STRING";case 4:return"OCTET_STRING";case 5:return"NULL";case 6:return"OBJECT_IDENTIFIER"; case 7:return"ObjectDescriptor";case 8:return"EXTERNAL";case 9:return"REAL";case 10:return"ENUMERATED";case 11:return"EMBEDDED_PDV";case 12:return"UTF8String";case 16:return"SEQUENCE";case 17:return"SET";case 18:return"NumericString";case 19:return"PrintableString";case 20:return"TeletexString";case 21:return"VideotexString";case 22:return"IA5String";case 23:return"UTCTime";case 24:return"GeneralizedTime";case 25:return"GraphicString";case 26:return"VisibleString";case 27:return"GeneralString";case 28:return"UniversalString"; case 30:return"BMPString";default:return"Universal_"+tagNumber.toString(16)}case 1:return"Application_"+tagNumber.toString(16);case 2:return"["+tagNumber+"]";case 3:return"Private_"+tagNumber.toString(16)}};ASN11.prototype.reSeemsASCII=/^[ -~]+$/;ASN11.prototype.content=function(){if(this.tag===undefined)return null;var tagClass=this.tag>>6,tagNumber=this.tag&31,content=this.posContent(),len=Math.abs(this.length);if(tagClass!==0){if(this.sub!==null)return"("+this.sub.length+" elem)";var s=this.stream.parseStringISO(content, content+Math.min(len,hardLimit));if(this.reSeemsASCII.test(s))return s.substring(0,2*hardLimit)+(s.length>2*hardLimit?ellipsis:"");else return this.stream.parseOctetString(content,content+len)}switch(tagNumber){case 1:return this.stream.get(content)===0?"false":"true";case 2:return this.stream.parseInteger(content,content+len);case 3:return this.sub?"("+this.sub.length+" elem)":this.stream.parseBitString(content,content+len);case 4:return this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(content, content+len);case 6:return this.stream.parseOID(content,content+len);case 16:case 17:return"("+this.sub.length+" elem)";case 12:return this.stream.parseStringUTF(content,content+len);case 18:case 19:case 20:case 21:case 22:case 26:return this.stream.parseStringISO(content,content+len);case 30:return this.stream.parseStringBMP(content,content+len);case 23:case 24:return this.stream.parseTime(content,content+len)}return null};ASN11.prototype.toString=function(){return this.typeName()+"@"+this.stream.pos+ "[header:"+this.header+",length:"+this.length+",sub:"+(this.sub===null?"null":this.sub.length)+"]"};ASN11.prototype.print=function(indent){if(indent===undefined)indent="";document.writeln(indent+this);if(this.sub!==null){indent+=" ";for(var i=0,max=this.sub.length;i=0)s+="+";s+=this.length;if(this.tag&32)s+=" (constructed)"; else if((this.tag==3||this.tag==4)&&this.sub!==null)s+=" (encapsulates)";s+="\n";if(this.sub!==null){indent+=" ";for(var i=0,max=this.sub.length;i";s+="Length: "+this.header+"+";if(this.length>=0)s+=this.length;else s+=-this.length+" (undefined)";if(this.tag&32)s+="
(constructed)";else if((this.tag==3||this.tag==4)&&this.sub!==null)s+="
(encapsulates)";if(content!==null){s+="
Value:
"+content+"";if(typeof oids==="object"&&this.tag==6){var oid=oids[content];if(oid){if(oid.d)s+= "
"+oid.d;if(oid.c)s+="
"+oid.c;if(oid.w)s+="
(warning!)"}}}value.innerHTML=s;node.appendChild(value);var sub=DOM.tag("div","sub");if(this.sub!==null)for(var i=0,max=this.sub.length;i=end)return;var sub=DOM.tag("span", className);sub.appendChild(DOM.text(stream.hexDump(start,end)));node.appendChild(sub)};ASN11.prototype.toHexDOM=function(root){var node=DOM.tag("span","hex");if(root===undefined)root=node;this.head.hexNode=node;this.head.onmouseover=function(){this.hexNode.className="hexCurrent"};this.head.onmouseout=function(){this.hexNode.className="hex"};node.asn1=this;node.onmouseover=function(){var current=!root.selected;if(current){root.selected=this.asn1;this.className="hexCurrent"}this.asn1.fakeHover(current)}; node.onmouseout=function(){var current=root.selected==this.asn1;this.asn1.fakeOut(current);if(current){root.selected=null;this.className="hex"}};this.toHexDOM_sub(node,"tag",this.stream,this.posStart(),this.posStart()+1);this.toHexDOM_sub(node,this.length>=0?"dlen":"ulen",this.stream,this.posStart()+1,this.posContent());if(this.sub===null)node.appendChild(DOM.text(this.stream.hexDump(this.posContent(),this.posEnd())));else if(this.sub.length>0){var first=this.sub[0];var last=this.sub[this.sub.length- 1];this.toHexDOM_sub(node,"intro",this.stream,this.posContent(),first.posStart());for(var i=0,max=this.sub.length;i3)throw"Length over 24 bits not supported at position "+ (stream.pos-1);if(len===0)return-1;buf=0;for(var i=0;i4)return false;var p=new Stream(stream);if(tag==3)p.get();var subTag=p.get();if(subTag>>6&1)return false;try{var subLength=ASN11.decodeLength(p);return p.pos-stream.pos+subLength==len}catch(exception){return false}};ASN11.decode=function(stream){if(!(stream instanceof Stream))stream=new Stream(stream,0);var streamStart=new Stream(stream), tag=stream.get(),len=ASN1.decodeLength(stream),header=stream.pos-streamStart.pos,sub=null;if(ASN1.hasContent(tag,len,stream)){var start=stream.pos;if(tag==3)stream.get();sub=[];if(len>=0){var end=start+len;while(stream.pos typeof $request !== 'undefined' 21 | $.isV2p = () => typeof $evui !== 'undefined' 22 | $.isPanel = () => $.isSurge() && typeof $input != 'undefined' && $.lodash_get($input, 'purpose') === 'panel' 23 | $.isTile = () => $.isStash() && typeof $script != 'undefined' && $.lodash_get($script, 'type') === 'tile' 24 | 25 | const KEY_INITED = `@${namespace}.10010.inited` 26 | const KEY_DISABLED = `@${namespace}.10010.disabled` 27 | const KEY_DEBUG = `@${namespace}.10010.debug` 28 | const KEY_COOKIE = `@${namespace}.10010.cookie` 29 | const KEY_APPID = `@${namespace}.10010.appId` 30 | const KEY_MOBILE = `@${namespace}.10010.mobile` 31 | const KEY_PASSWORD = `@${namespace}.10010.password` 32 | const KEY_TITLE = `@${namespace}.10010.title` 33 | const KEY_SUBTITLE = `@${namespace}.10010.subtitle` 34 | const KEY_BODY = `@${namespace}.10010.body` 35 | const KEY_DETAIL = `@${namespace}.10010.detail` 36 | const KEY_DETAIL_TEXT = `@${namespace}.10010.detailText` 37 | const KEY_EXCLUDE_REMAIN_PKG = `@${namespace}.10010.excludeRemainPkg` 38 | const KEY_FREE_PKG = `@${namespace}.10010.freePkg` 39 | const KEY_OTHER_PKG = `@${namespace}.10010.otherPkg` 40 | const KEY_IGNORE_FLOW = `@${namespace}.10010.ignoreFlow` 41 | const KEY_REMAIN_FLOW_ONLY = `@${namespace}.10010.remainFlowOnly` 42 | const KEY_OTHER_PKG_TPL = `@${namespace}.10010.otherPkgTpl` 43 | const KEY_SYSTEM_NOTIFY_DISABLED = `@${namespace}.10010.systemNotifyDisabled` 44 | const KEY_REQUEST_NOTIFY_DISABLED = `@${namespace}.10010.requestNotifyDisabled` 45 | const KEY_PANEL_NOTIFY_DISABLED = `@${namespace}.10010.panelNotifyDisabled` 46 | const KEY_TILE_NOTIFY_DISABLED = `@${namespace}.10010.tileNotifyDisabled` 47 | const KEY_NOTIFY_DISABLED = `@${namespace}.10010.notifyDisabled` 48 | const KEY_BARK = `@${namespace}.10010.bark` 49 | const KEY_TOKEN_ONLINE = `@${namespace}.10010.tokenOnline` 50 | 51 | //配置文件分隔 52 | 53 | $.setdata(new Date().toLocaleString('zh'), KEY_INITED) 54 | 55 | //账号信息 56 | //手机号 57 | $.setdata('手机号', KEY_MOBILE) 58 | //服务密码 59 | $.setdata('服务密码', KEY_PASSWORD) 60 | //APPID 61 | $.setdata('APPID', KEY_APPID) 62 | 63 | //通知正文模板 64 | //已经完美了不用删改了 65 | $.setdata('总用 [总用] 总免 [总免] \n通总 [通总] 通余 [剩]\n[单]\n当前时间 [现]', KEY_BODY); 66 | 67 | //需要单独显示的流量包名正则 68 | //例 设置 (加油包|福利|学习强国), 将显示 剩余 536.98M 加油包 46.12M 福利 490.86M 学习强国 1234.56M 免流 41.66G 69 | //如果想显示公免已用去241行修改,240行有说明 70 | $.setdata('(升级包)', KEY_OTHER_PKG) 71 | 72 | //叠加到免流流量的流量包名正则 73 | //在联通原始值不正确时 进行修正. 例 设置 (定向流量|免流资费|免费流量), 匹配的包叠加到总免流流量 74 | //不需要则加//注释 75 | $.setdata('(定向流量|免流资费|免费流量)', KEY_EXCLUDE_REMAIN_PKG) 76 | 77 | //不计算剩余流量的流量包名正则 78 | //在联通原始值不正确时 进行修正. 例 (定向流量|免流资费|免费流量) , 匹配的包不计算剩余 79 | //不需要则加//注释 80 | //$.setdata('(定向流量|免流资费|免费流量)', KEY_FREE_PKG) 81 | 82 | //流量变化忽略阈值(单位 M) 83 | //小于此数值的流量变化不通知. ⚠️ 就是说大于等于此数值会通知. 如果你要无变化时不通知, 这里可以设为0.01 84 | $.setdata('0.01', KEY_IGNORE_FLOW) 85 | 86 | //配置文件分隔 87 | 88 | let result 89 | const detail = {} 90 | !(async () => { 91 | // if (typeof $request !== 'undefined') { 92 | // $.log('ℹ️ 是 request') 93 | // } else { 94 | // $.log('ℹ️ 不是 request') 95 | 96 | const disabled = $.getdata(KEY_DISABLED) 97 | const debug = String($.getdata(KEY_DEBUG)) === 'true' 98 | if (String(disabled) === 'true') { 99 | $.log('ℹ️ 已禁用') 100 | return 101 | } 102 | let cookie = $.getdata(KEY_COOKIE) 103 | const appId = $.getdata(KEY_APPID) 104 | const mobile = $.getdata(KEY_MOBILE) 105 | const password = $.getdata(KEY_PASSWORD) 106 | let tokenOnline = $.getdata(KEY_TOKEN_ONLINE) 107 | 108 | if (!cookie && (!appId || !mobile || !password)) { 109 | throw new Error('⚠️ 请配置 Cookie 或 appId, 手机号(mobile), 密码(password) 记得保存') 110 | } 111 | let needSign 112 | if (cookie) { 113 | $.log('ℹ️ 有 Cookie 尝试使用 Cookie 进行查询') 114 | try { 115 | await query({ cookie }) 116 | } catch (e) { 117 | if (String(e).indexOf('Cookie 无效') === -1) { 118 | throw e 119 | } 120 | needSign = true 121 | $.log('ℹ️ Cookie 无效, 将尝试自动登录') 122 | if(debug){ 123 | await notify(namespace === 'xream' ? '10010' : `10010(${namespace})`, `❌`, `ℹ️ Cookie 无效, 将尝试自动登录`, {}) 124 | } 125 | } 126 | } else { 127 | needSign = true 128 | } 129 | let needQuery 130 | if (needSign && tokenOnline) { 131 | $.log('ℹ️ 将使用 tokenOnline 自动登录') 132 | if(debug){ 133 | await notify(namespace === 'xream' ? '10010' : `10010(${namespace})`, `ℹ️`, `将使用 tokenOnline 自动登录`, {}) 134 | } 135 | try { 136 | await online({ tokenOnline, appId }) 137 | cookie = $.getdata(KEY_COOKIE) 138 | tokenOnline = $.getdata(KEY_TOKEN_ONLINE) 139 | needSign = false 140 | needQuery = true 141 | if(debug){ 142 | await notify(namespace === 'xream' ? '10010' : `10010(${namespace})`, `✅`, `使用 tokenOnline 自动登录`, {}) 143 | } 144 | } catch (e) { 145 | $.log('❌ 使用 tokenOnline 自动登录失败') 146 | console.log(e) 147 | if(debug){ 148 | await notify(namespace === 'xream' ? '10010' : `10010(${namespace})`, `❌ 使用 tokenOnline 自动登录失败`, `${$.lodash_get(e, 'message') || $.lodash_get(e, 'error') || e}`, {}) 149 | } 150 | } 151 | } 152 | if (needQuery) { 153 | await query({ cookie }) 154 | } 155 | if (needSign) { 156 | $.log('ℹ️ 自动登录') 157 | const signRes = await sign({ mobile, password, appId }) 158 | cookie = $.lodash_get(signRes, 'cookie') 159 | if(debug){ 160 | await notify(namespace === 'xream' ? '10010' : `10010(${namespace})`, `✅`, `自动登录`, {}) 161 | } 162 | await query({ cookie }) 163 | } 164 | 165 | // } 166 | })() 167 | .catch(async e => { 168 | console.log(e) 169 | await notify(namespace === 'xream' ? '10010' : `10010(${namespace})`, `❌`, `${$.lodash_get(e, 'message') || $.lodash_get(e, 'error') || e}`, {}) 170 | }) 171 | .finally(() => { 172 | if ($.isNode()) { 173 | try { 174 | require('fs').writeFileSync(namespace === 'xream' ? '10010.txt' : `10010_${namespace}.txt`, $.getdata(KEY_COOKIE), 'utf-8') 175 | } catch (e) { 176 | console.error(e); 177 | } 178 | } 179 | if ($.isV2p()) { 180 | $.done() 181 | } else if ($.isPanel()) { 182 | let arg 183 | if (typeof $argument != 'undefined') { 184 | arg = Object.fromEntries($argument.split('&').map(item => item.split('='))) 185 | } 186 | $.done({ 187 | title: $.lodash_get(detail, 'msg.title'), 188 | content: `${$.lodash_get(detail, 'msg.subtitle')}\n${$.lodash_get(detail, 'msg.body')}`, 189 | ...arg, 190 | }) 191 | } else if ($.isTile()) { 192 | $.done({ 193 | title: `${$.lodash_get(detail, 'msg.title')}`, 194 | content: `${$.lodash_get(detail, 'msg.subtitle')}\n${$.lodash_get(detail, 'msg.body')}`, 195 | }) 196 | } else { 197 | $.done(result) 198 | } 199 | }) 200 | 201 | async function query({ cookie }) { 202 | $.log('〽️ 开始进行余量查询') 203 | const res = await $.http.post({ 204 | url: 'https://m.client.10010.com/servicequerybusiness/operationservice/queryOcsPackageFlowLeftContentRevisedInJune', 205 | headers: { cookie }, 206 | }) 207 | const status = $.lodash_get(res, 'status') 208 | $.log('↓ res status') 209 | $.log(status) 210 | let body = String($.lodash_get(res, 'body') || $.lodash_get(res, 'rawBody')) 211 | try { 212 | body = JSON.parse(body) 213 | } catch (e) {} 214 | $.log('↓ res body') 215 | console.log($.toStr(body)) 216 | const code = String($.lodash_get(body, 'code')) 217 | const desc = $.lodash_get(body, 'desc') 218 | let errMsg = '未知错误' 219 | if (code !== '0000') { 220 | if (String(body) === '999999' || String(body) === '999998') { 221 | errMsg = 'Cookie 无效' 222 | } else if(code === '4114030182'){ 223 | errMsg = '系统升级' 224 | if (String($.getdata(KEY_SYSTEM_NOTIFY_DISABLED)) === 'true') { 225 | $.log('禁用联通系统升级时的通知') 226 | return 227 | } 228 | } else if(desc){ 229 | errMsg = desc 230 | } 231 | throw new Error(errMsg) 232 | } 233 | 234 | const now = new Date().getTime() 235 | 236 | const titleTpl = $.getdata(KEY_TITLE) || '[套]' 237 | const subtitleTpl = $.getdata(KEY_SUBTITLE) || '时长 [时] 跳 [跳] 免 [免]' 238 | const bodyTpl = $.getdata(KEY_BODY) || '剩余 [剩] [单] 免流 [总免]' 239 | 240 | //把241行绿色' '里的[包] 剩余[剩] 已用[用]\n 替换成 [包] 已用[用]\n 即可 241 | const otherPkgTpl = $.getdata(KEY_OTHER_PKG_TPL) || '[包] 剩余[剩] 已用[用]\n' 242 | 243 | const ignoreFlow = $.getdata(KEY_IGNORE_FLOW) || 0 244 | const remainFlowOnly = String($.getdata(KEY_REMAIN_FLOW_ONLY)) === 'true' 245 | const requestNotifyDisabled = String($.getdata(KEY_REQUEST_NOTIFY_DISABLED)) === 'true' 246 | const panelNotifyDisabled = String($.getdata(KEY_PANEL_NOTIFY_DISABLED)) === 'true' 247 | const tileNotifyDisabled = String($.getdata(KEY_TILE_NOTIFY_DISABLED)) === 'true' 248 | const notifyDisabled = String($.getdata(KEY_NOTIFY_DISABLED)) === 'true' 249 | const time = $.lodash_get(body, 'time') 250 | const packageName = $.lodash_get(body, 'packageName') 251 | const sum = $.lodash_get(body, 'summary.sum') 252 | const freeFlow = $.lodash_get(body, 'summary.freeFlow') 253 | 254 | console.log(`当前套餐: ${packageName}`) 255 | console.log(`当前时间: ${new Date(now).toLocaleString('zh')}`) 256 | console.log(`查询时间(联通): ${time}`) 257 | console.log(`已用流量(联通原始值): ${formatFlow(sum, 2)}`) 258 | console.log(`已免流量(联通原始值): ${formatFlow(freeFlow, 2)}`) 259 | console.log(`流量变化忽略阈值: ${formatFlow(ignoreFlow, 2)}`) 260 | console.log(`当前时间段内有*非免流*才会通知: ${remainFlowOnly}`) 261 | 262 | const excludeRemainPkgRegExpStr = $.getdata(KEY_EXCLUDE_REMAIN_PKG) 263 | let excludeRemainPkgRegExp 264 | if (excludeRemainPkgRegExpStr) { 265 | excludeRemainPkgRegExp = new RegExp(excludeRemainPkgRegExpStr) 266 | console.log(`不计算剩余流量的流量包名正则: ${excludeRemainPkgRegExp}`) 267 | } 268 | const freePkgRegExpStr = $.getdata(KEY_FREE_PKG) 269 | let freePkgRegExp 270 | if (freePkgRegExpStr) { 271 | freePkgRegExp = new RegExp(freePkgRegExpStr) 272 | console.log(`叠加到免流流量的流量包名正则: ${freePkgRegExp}`) 273 | } 274 | const otherPkgRegExpStr = $.getdata(KEY_OTHER_PKG) 275 | let otherPkgRegExp 276 | if (otherPkgRegExpStr) { 277 | otherPkgRegExp = new RegExp(otherPkgRegExpStr) 278 | console.log(`需要单独显示的的流量包名正则: ${otherPkgRegExp}`) 279 | } 280 | 281 | detail.now = now 282 | detail.time = time 283 | detail.packageName = packageName 284 | detail.sum = sum 285 | detail.freeFlow = freeFlow 286 | 287 | const resourcesConfig = { 288 | resources: { name: '套餐内流量&流量包' }, 289 | unshared: { name: '套餐内流量&流量包(非共享)' }, 290 | rzbresources: { name: '日租宝' }, 291 | mlresources: { name: '免流流量' }, 292 | twresources: { name: '套外流量' }, 293 | } 294 | 295 | const pkgs = [] 296 | detail.other = [] 297 | detail.addUpFree = 0 298 | detail.remain = 0 299 | detail.total = 0 300 | detail.tw = 0 301 | detail.resources = {} 302 | for (const key in body) { 303 | const field = String(key).toLowerCase() 304 | if (field.indexOf('resources') !== -1 || field === 'unshared') { 305 | detail.resources[field] = {} 306 | const resources = $.lodash_get(body, key) || [] 307 | resources.map(resource => { 308 | const type = $.lodash_get(resource, 'type') 309 | if (!type || String(type).toLowerCase().indexOf('flow') !== -1) { 310 | const userResource = $.lodash_get(resource, 'userResource') || $.lodash_get(resource, 'rzbAllUse') 311 | const name = $.lodash_get(resourcesConfig, `${field}.name`) || key 312 | console.log(`${name}: 已用 ${formatFlow(userResource, 2)}`) 313 | pkgs.push(`${name}: 已用 ${formatFlow(userResource, 2)}`) 314 | 315 | detail.resources[field].name = name 316 | detail.resources[field].userResource = userResource 317 | detail.resources[field].details = [] 318 | 319 | const details = $.lodash_get(resource, 'details') || [] 320 | details.map((pkg, index) => { 321 | const limited = $.lodash_get(pkg, 'limited') 322 | const feePolicyName = $.lodash_get(pkg, 'feePolicyName') 323 | const addUpItemName = $.lodash_get(pkg, 'addUpItemName') 324 | const pkgFullName = addUpItemName ? `${feePolicyName}(${addUpItemName})` : `${feePolicyName}` 325 | const total = $.lodash_get(pkg, 'total') 326 | const remain = $.lodash_get(pkg, 'remain') 327 | const use = $.lodash_get(pkg, 'use') 328 | console.log(`[${index + 1}] ${pkgFullName}`) 329 | pkgs.push(`[${index + 1}] ${pkgFullName}`) 330 | 331 | let otherPkgName 332 | if (otherPkgRegExp) { 333 | const otherPkgMatchedArray = pkgFullName.match(otherPkgRegExp) 334 | if (otherPkgMatchedArray) { 335 | otherPkgName = otherPkgMatchedArray[1] 336 | } 337 | } 338 | 339 | if (String(limited) === '1') { 340 | console.log(`已用 ${formatFlow(use, 2)}`) 341 | pkgs.push(`已用 ${formatFlow(use, 2)}`) 342 | const item = { feePolicyName, addUpItemName, pkgFullName, limited, use } 343 | detail.resources[field].details.push(item) 344 | if (otherPkgName) { 345 | console.log(`需要单独显示: 匹配 ${otherPkgName}`) 346 | pkgs.push(`需要单独显示: 匹配 ${otherPkgName}`) 347 | item.otherPkgName = otherPkgName 348 | detail.other.push(item) 349 | } else { 350 | // console.log(`不需要单独显示`) 351 | // pkgs.push(`不需要单独显示`) 352 | } 353 | } else { 354 | console.log(`已用 ${formatFlow(use, 2)}, 剩余 ${formatFlow(remain, 2)}/共 ${formatFlow(total, 2)}`) 355 | pkgs.push(`已用 ${formatFlow(use, 2)}, 剩余 ${formatFlow(remain, 2)}/共 ${formatFlow(total, 2)}`) 356 | let excludeRemainPkgName 357 | if (excludeRemainPkgRegExp) { 358 | const excludeRemainPkgMatchedArray = pkgFullName.match(excludeRemainPkgRegExp) 359 | if (excludeRemainPkgMatchedArray) { 360 | excludeRemainPkgName = excludeRemainPkgMatchedArray[1] 361 | } 362 | } 363 | if (excludeRemainPkgName) { 364 | console.log(`不计算剩余: 匹配 ${excludeRemainPkgName}`) 365 | pkgs.push(`不计算剩余: 匹配 ${excludeRemainPkgName}`) 366 | } else { 367 | if (remain >= 0) { 368 | console.log(`计算剩余`) 369 | pkgs.push(`计算剩余`) 370 | detail.remain += parseFloat(remain) 371 | detail.total += parseFloat(total) 372 | } else { 373 | console.log(`不计算剩余: 剩余 ${remain} 应>=0`) 374 | pkgs.push(`不计算剩余: 剩余 ${remain} 应>=0`) 375 | } 376 | } 377 | const item = { feePolicyName, addUpItemName, pkgFullName, limited, use, remain, total } 378 | detail.resources[field].details.push(item) 379 | if (otherPkgName) { 380 | console.log(`需要单独显示: 匹配 ${otherPkgName}`) 381 | pkgs.push(`需要单独显示: 匹配 ${otherPkgName}`) 382 | item.otherPkgName = otherPkgName 383 | detail.other.push(item) 384 | } else { 385 | // console.log(`不需要单独显示`) 386 | // pkgs.push(`不需要单独显示`) 387 | } 388 | } 389 | let freePkgName 390 | if (freePkgRegExp) { 391 | const freePkgMatchedArray = pkgFullName.match(freePkgRegExp) 392 | if (freePkgMatchedArray) { 393 | freePkgName = freePkgMatchedArray[1] 394 | } 395 | } 396 | if (freePkgName) { 397 | if (use >= 0) { 398 | console.log(`计算额外免流: 匹配 ${freePkgName}`) 399 | pkgs.push(`计算额外免流: 匹配 ${freePkgName}`) 400 | detail.addUpFree += parseFloat(use) 401 | } else { 402 | console.log(`不计算额外免流: 已用 ${use} 应>=0`) 403 | pkgs.push(`不计算额外免流: 已用 ${use} 应>=0`) 404 | } 405 | } else { 406 | // console.log(`不计算额外免流`) 407 | // pkgs.push(`不计算额外免流`) 408 | } 409 | }) 410 | } 411 | }) 412 | } 413 | } 414 | detail.free = parseFloat(detail.freeFlow) + parseFloat(detail.addUpFree) 415 | let tw = parseFloat($.lodash_get(detail, 'resources.twresources.userResource')) 416 | if (!isNaN(tw) && tw > 0) { 417 | detail.tw = tw 418 | } 419 | const lastDetail = $.getjson(KEY_DETAIL) 420 | console.log('上次记录:') 421 | console.log(lastDetail) 422 | console.log('本次记录:') 423 | console.log(detail) 424 | const resourcesDetails = $.lodash_get(detail, 'resources.resources.details') 425 | const unsharedDetails = $.lodash_get(detail, 'resources.unshared.details') 426 | const rzbresourcesDetails = $.lodash_get(detail, 'resources.rzbresources.details') 427 | consttwresourcesDetails = $.lodash_get(detail, 'resources.twresources.details') 428 | if ((!Array.isArray(resourcesDetails) || resourcesDetails.length === 0) && (!Array.isArray(unsharedDetails) || unsharedDetails.length === 0) && (!Array.isArray(rzbresourcesDetails) || rzbresourcesDetails.length === 0) && (!Array.isArray(consttwresourcesDetails) || consttwresourcesDetails.length === 0)) { 429 | console.log(`联通未返回包数据 正常情况 习惯就好 🔚`) 430 | return 431 | } 432 | let duration = 0 433 | let durationFree = 0 434 | let durationNotFree = 0 435 | let durationRemain = 0 436 | let durationTw = 0 437 | if (lastDetail) { 438 | duration = (now - parseFloat($.lodash_get(lastDetail, 'now'))) / 1000 / 60 439 | if (!isNaN(duration) && duration > 0) { 440 | durationFree = parseFloat(detail.free) - parseFloat($.lodash_get(lastDetail, 'free')) 441 | durationTw = parseFloat(detail.tw) - parseFloat($.lodash_get(lastDetail, 'tw')) 442 | durationRemain = parseFloat($.lodash_get(lastDetail, 'remain')) - parseFloat(detail.remain) 443 | durationNotFree = durationRemain + durationTw 444 | } else { 445 | duration = 0 446 | } 447 | } 448 | 449 | const otherText = detail.other 450 | .map(i => { 451 | return otherPkgTpl 452 | .replace('[包]', i.otherPkgName) 453 | .replace('[剩]', i.remain == null ? '-' : formatFlow(i.remain, 2)) 454 | .replace('[用]', i.use == null ? '-' : formatFlow(i.use, 2)) 455 | .replace(/ +/g, ' ') 456 | }) 457 | .join(' ') 458 | const msgData = { 459 | ...detail, 460 | duration, 461 | durationNotFree, 462 | durationFree, 463 | otherText, 464 | now: new Date(detail.now).toLocaleString('zh'), 465 | pkgs, 466 | } 467 | const msg = { 468 | title: renderTpl(titleTpl, msgData), 469 | subtitle: renderTpl(subtitleTpl, msgData), 470 | body: renderTpl(bodyTpl, msgData), 471 | } 472 | detail.msg = msg 473 | // 保存 detail 474 | $.setjson(detail, KEY_DETAIL) 475 | // 附加 cookie 476 | detail.cookie = cookie 477 | const detailText = `当前套餐: ${detail.packageName} 478 | 当前时间: ${new Date(detail.now).toLocaleString('zh')} 479 | 查询时间(联通): ${detail.time} 480 | 已用流量(联通原始值): ${formatFlow(detail.sum, 2)} 481 | 已免流量(联通原始值): ${formatFlow(detail.freeFlow, 2)} 482 | ${pkgs.join('\n')} 483 | 总剩余流量: ${formatFlow(detail.remain, 2)} 484 | 总共流量: ${formatFlow(detail.total, 2)} 485 | 额外免流流量: ${formatFlow(detail.addUpFree, 2)} 486 | 修正后总免流: ${formatFlow(detail.free, 2)} 487 | 套外总流量: ${formatFlow(detail.tw, 2)} 488 | 间隔时长: ${formatDuration(duration)} 489 | 期间免流: ${formatFlow(durationFree, 2)} 490 | 期间非免: ${formatFlow(durationNotFree, 2)} 491 | 流量变化忽略阈值: ${formatFlow(ignoreFlow, 2)} 492 | 当前时间段内有*非免流*才会通知: ${remainFlowOnly} 493 | 通知标题模板: ${titleTpl} 494 | 通知副标题模板: ${subtitleTpl} 495 | 通知正文模板: ${bodyTpl} 496 | 通知单独显示的包模板: ${otherPkgTpl} 497 | 单独显示: ${otherText} 498 | 通知标题: ${msg.title} 499 | 通知副标题: ${msg.subtitle} 500 | 通知正文: ${msg.body} 501 | ` 502 | 503 | console.log(detailText) 504 | 505 | const resultBody = JSON.stringify(detail) 506 | const resultHeaders = { 507 | 'Content-Type': 'application/json; charset=utf-8', 508 | 'Access-Control-Allow-Origin': '*', 509 | 'Access-Control-Allow-Methods': 'POST,GET,OPTIONS,PUT,DELETE', 510 | 'Access-Control-Allow-Headers': 'Origin, X-Requested-With, Content-Type, Accept', 511 | } 512 | if ($.isQuanX()) { 513 | result = { status: 'HTTP/1.1 200', headers: resultHeaders, body: resultBody } 514 | } else { 515 | result = { 516 | response: { 517 | status: 200, 518 | body: resultBody, 519 | headers: resultHeaders, 520 | }, 521 | } 522 | } 523 | $.setdata(detailText, KEY_DETAIL_TEXT) 524 | if (durationFree < 0 || durationNotFree < 0) { 525 | console.log(`流量变化 < 0 可能是什么包失效了(比如月初)或者联通接口问题 本次不发送`) 526 | } else { 527 | if (notifyDisabled) { 528 | console.log(`禁用通知`) 529 | } else if ($.isRequest() && requestNotifyDisabled) { 530 | console.log(`禁用作为请求脚本使用时的通知`) 531 | } else if ($.isPanel() && panelNotifyDisabled) { 532 | console.log(`禁用作为 Surge 面板 (Panel) 脚本使用时的通知`) 533 | } else if ($.isTile() && tileNotifyDisabled) { 534 | console.log(`禁用作为 Stash 面板 (Tile) 脚本使用时的通知`) 535 | } else { 536 | if (durationFree >= ignoreFlow || durationNotFree >= ignoreFlow) { 537 | if (!remainFlowOnly || (remainFlowOnly && durationNotFree >= ignoreFlow)) { 538 | console.log(`未设置当前时间段内无*非免流*不通知, 或 设置了且跳>=阈值`) 539 | console.log(`🔔🔔🔔 通知`) 540 | await notify(msg.title, msg.subtitle, msg.body) 541 | } else { 542 | console.log(`当前时间段内无*非免流*, 不通知`) 543 | } 544 | } else { 545 | console.log(`小于流量变化忽略阈值, 不通知`); 546 | } 547 | } 548 | } 549 | } 550 | 551 | 552 | async function notify(title, subtitle, body) { 553 | if ($.isNode()) { 554 | console.log('Node 环境 尝试加载 sendNotify') 555 | try { 556 | console.log(`尝试加载 ./10010_${namespace}_sendNotify`) 557 | notify = require(`./10010_${namespace}_sendNotify`) 558 | } catch (e) { 559 | // console.log(e) 560 | } 561 | if (notify && notify.sendNotify) { 562 | console.log(`./10010_${namespace}_sendNotify 正常`) 563 | } else { 564 | try { 565 | console.log(`尝试加载 ./10010_sendNotify`) 566 | notify = require(`./10010_sendNotify`) 567 | } catch (e) { 568 | // console.log(e) 569 | } 570 | if (notify && notify.sendNotify) { 571 | console.log(`./10010_sendNotify 正常`) 572 | } else { 573 | try { 574 | console.log(`尝试加载 ./sendNotify`) 575 | notify = require('./sendNotify') 576 | if (notify && notify.sendNotify) { 577 | console.log(`./sendNotify 正常`) 578 | } 579 | } catch (e) { 580 | console.log(e) 581 | } 582 | } 583 | } 584 | try { 585 | const { execSync } = require('child_process') 586 | if (process.env.TERMUX_VERSION) { 587 | console.log(execSync(`termux-notification -t "${title}" -c "${subtitle}\n${body}" --sound`,{encoding: 'utf8', timeout: 3 * 1000})) 588 | } 589 | } catch (e) { 590 | console.log(e) 591 | } 592 | } 593 | const bark = $.getdata(KEY_BARK) 594 | 595 | if (bark || (notify && notify.sendNotify)) { 596 | if (bark) { 597 | try { 598 | const url = bark.replace('[推送标题]', encodeURIComponent(title)).replace('[推送内容]', encodeURIComponent(`${subtitle}\n${body}`)) 599 | $.log(`开始 bark 请求: ${url}`) 600 | $.log(`${title}\n\n${subtitle}\n\n${body}`) 601 | const res = await $.http.get({ url }) 602 | // console.log(res) 603 | const status = $.lodash_get(res, 'status') 604 | $.log('↓ res status') 605 | $.log(status) 606 | let resBody = String($.lodash_get(res, 'body') || $.lodash_get(res, 'rawBody')) 607 | try { 608 | resBody = JSON.parse(resBody) 609 | } catch (e) {} 610 | $.log('↓ res body') 611 | console.log($.toStr(resBody)) 612 | if ($.lodash_get(resBody, 'code') !== 200) { 613 | throw new Error($.lodash_get(resBody, 'message') || '未知错误') 614 | } 615 | } catch (e) { 616 | console.log(e) 617 | $.msg(namespace === 'xream' ? '10010' : `10010(${namespace})`, `❌ bark 请求`, `${$.lodash_get(e, 'message') || $.lodash_get(e, 'error') || e}`, {}) 618 | } 619 | } 620 | 621 | if (notify && notify.sendNotify) { 622 | await notify.sendNotify(`${title}`, `${subtitle}\n${body}`) 623 | } 624 | } else if ($.isV2p()) { 625 | $.msg(title, '', `${subtitle}\n${body}`) 626 | } else { 627 | $.msg(title, subtitle, body) 628 | } 629 | } 630 | function renderTpl(tpl, data) { 631 | return tpl 632 | .replace('[套]', data.packageName || '') 633 | .replace('[总免]', formatFlow(data.free, 2)) 634 | .replace('[总用]', formatFlow(data.sum, 2)) 635 | .replace('[通总]', formatFlow(detail.total, 2)) 636 | .replace('[时]', formatDuration(data.duration)) 637 | .replace('[现]', data.now) 638 | .replace('[跳]', formatFlow(data.durationNotFree, 2)) 639 | .replace('[免]', formatFlow(data.durationFree, 2)) 640 | .replace('[剩]', formatFlow(data.remain, 2)) 641 | .replace('[总]', formatFlow(data.total, 2)) 642 | .replace('[套外]', formatFlow(data.tw, 2)) 643 | .replace('[单]', data.otherText) 644 | .replace('[详]', data.pkgs?data.pkgs.join('\n'): '') 645 | .replace(/ +/g, ' ') 646 | } 647 | 648 | async function info({ cookie }) { 649 | $.log('〽️ 开始进行信息查询') 650 | const res = await $.http.post({ 651 | url: 'https://m.client.10010.com//mobileserviceimportant/home/queryUserInfoSeven', 652 | headers: { cookie }, 653 | }) 654 | const status = $.lodash_get(res, 'status') 655 | $.log('↓ res status') 656 | $.log(status) 657 | let body = String($.lodash_get(res, 'body') || $.lodash_get(res, 'rawBody')) 658 | try { 659 | body = JSON.parse(body) 660 | } catch (e) {} 661 | $.log('↓ res body') 662 | console.log($.toStr(body)) 663 | if ($.lodash_get(body, 'code') !== 'Y') { 664 | if (String(body) === '999999' || String(body) === '999998') { 665 | throw new Error('Cookie 无效') 666 | } 667 | throw new Error('未知错误') 668 | } 669 | const title = $.lodash_get(body, 'flush_date_time') 670 | const dataList = $.lodash_get(body, 'data.dataList') || [] 671 | const content = dataList 672 | .map(i => `${$.lodash_get(i, 'remainTitle')} ${$.lodash_get(i, 'number')}${$.lodash_get(i, 'unit')}`) 673 | .join('; ') 674 | console.log(title) 675 | console.log(content) 676 | } 677 | async function sign({ mobile, password, appId }) { 678 | $.log('〽️ 开始进行登录') 679 | const res = await $.http.post({ 680 | url: 'https://m.client.10010.com/mobileService/login.htm', 681 | body: transParams({ 682 | mobile: RSAEncrypt(mobile), 683 | password: RSAEncrypt(password), 684 | appId, 685 | version: 'iphone_c@9.0100', 686 | }), 687 | headers: { 688 | 'Content-Type': 'application/x-www-form-urlencoded', 689 | }, 690 | }) 691 | // console.log(res) 692 | const status = $.lodash_get(res, 'status') 693 | $.log('↓ res status') 694 | $.log(status) 695 | let body = String($.lodash_get(res, 'body') || $.lodash_get(res, 'rawBody')) 696 | try { 697 | body = JSON.parse(body) 698 | } catch (e) {} 699 | $.log('↓ res body') 700 | console.log($.toStr(body)) 701 | if ($.lodash_get(body, 'code') !== '0') { 702 | throw new Error($.lodash_get(body, 'dsc') || '未知错误') 703 | } 704 | const tokenOnline = $.lodash_get(body, 'token_online') 705 | console.log(`token_online`) 706 | console.log(tokenOnline) 707 | $.setdata(tokenOnline, KEY_TOKEN_ONLINE) 708 | const headers = $.lodash_get(res, 'headers') || {} 709 | let cookie = $.lodash_get(headers, 'set-cookie') || $.lodash_get(headers, 'Set-Cookie') 710 | if (Array.isArray(cookie)) { 711 | cookie = cookie.join('; ') 712 | } 713 | console.log(`🍪 登录 Cookie`) 714 | console.log(cookie) 715 | if (!cookie) { 716 | throw new Error(`登录 Cookie 为空`) 717 | } 718 | $.setdata(cookie, KEY_COOKIE) 719 | return { cookie } 720 | 721 | // const title = $.lodash_get(body, 'flush_date_time') 722 | // const dataList = $.lodash_get(body, 'data.dataList') || [] 723 | // const content = dataList 724 | // .map(i => `${$.lodash_get(i, 'remainTitle')} ${$.lodash_get(i, 'number')}${$.lodash_get(i, 'unit')}`) 725 | // .join('; ') 726 | // console.log(title) 727 | // console.log(content) 728 | } 729 | async function online({ tokenOnline, appId }) { 730 | $.log('〽️ 开始进行在线状态维护') 731 | const res = await $.http.post({ 732 | url: 'https://m.client.10010.com/mobileService/onLine.htm', 733 | body: transParams({ 734 | appId, 735 | token_online: tokenOnline, 736 | version: 'iphone_c@9.0100', 737 | }), 738 | headers: { 739 | 'Content-Type': 'application/x-www-form-urlencoded', 740 | }, 741 | }) 742 | // console.log(res) 743 | const status = $.lodash_get(res, 'status') 744 | $.log('↓ res status') 745 | $.log(status) 746 | let body = String($.lodash_get(res, 'body') || $.lodash_get(res, 'rawBody')) 747 | try { 748 | body = JSON.parse(body) 749 | } catch (e) {} 750 | $.log('↓ res body') 751 | console.log($.toStr(body)) 752 | if ($.lodash_get(body, 'code') !== '0') { 753 | throw new Error($.lodash_get(body, 'dsc') || '未知错误') 754 | } 755 | const invalidat = $.lodash_get(body, 'invalidat') 756 | console.log(`有效时间: ${invalidat}`) 757 | const newTokenOnline = $.lodash_get(body, 'token_online') 758 | console.log(`new token_online`) 759 | console.log(newTokenOnline) 760 | $.setdata(newTokenOnline, KEY_TOKEN_ONLINE) 761 | const headers = $.lodash_get(res, 'headers') || {} 762 | let cookie = $.lodash_get(headers, 'set-cookie') || $.lodash_get(headers, 'Set-Cookie') 763 | if (Array.isArray(cookie)) { 764 | cookie = cookie.join('; ') 765 | } 766 | console.log(`🍪 更新登录 Cookie`) 767 | console.log(cookie) 768 | if (!cookie) { 769 | throw new Error(`更新登录 Cookie 为空`) 770 | } 771 | $.setdata(cookie, KEY_COOKIE) 772 | return { cookie } 773 | 774 | // const title = $.lodash_get(body, 'flush_date_time') 775 | // const dataList = $.lodash_get(body, 'data.dataList') || [] 776 | // const content = dataList 777 | // .map(i => `${$.lodash_get(i, 'remainTitle')} ${$.lodash_get(i, 'number')}${$.lodash_get(i, 'unit')}`) 778 | // .join('; ') 779 | // console.log(title) 780 | // console.log(content) 781 | } 782 | 783 | function createRound(methodName) { 784 | const func = Math[methodName] 785 | return (number, precision) => { 786 | precision = precision == null ? 0 : precision >= 0 ? Math.min(precision, 292) : Math.max(precision, -292) 787 | if (precision) { 788 | // Shift with exponential notation to avoid floating-point issues. 789 | // See [MDN](https://mdn.io/round#Examples) for more details. 790 | let pair = `${number}e`.split('e') 791 | const value = func(`${pair[0]}e${+pair[1] + precision}`) 792 | 793 | pair = `${value}e`.split('e') 794 | return +`${pair[0]}e${+pair[1] - precision}` 795 | } 796 | return func(number) 797 | } 798 | } 799 | function round(...args) { 800 | return createRound('round')(...args) 801 | } 802 | function formatFlow(number, precision) { 803 | if (!Number.isFinite(Number.parseFloat(number))) { 804 | return '0M' 805 | } 806 | if (number < 1024) { 807 | return round(number, precision) + 'M' 808 | } 809 | if (number < 1024 * 1024) { 810 | return round(number / 1024, precision) + 'G' 811 | } 812 | return round(number / 1024 / 1024, precision) + 'T' 813 | } 814 | function formatDuration(number, precision) { 815 | if (number < 60) { 816 | return round(number, precision) + '分钟' 817 | } 818 | if (number < 60 * 24) { 819 | return round(number / 60, precision) + '小时' 820 | } 821 | return round(number / 60 / 24, precision) + '天' 822 | } 823 | function transParams(data) { 824 | return Object.keys(data) 825 | .map(k => `${k}=${encodeURIComponent(data[k])}`) 826 | .join('&') 827 | // let params = new URLSearchParams() 828 | // for (let item in data) { 829 | // params.append(item, data['' + item + '']) 830 | // } 831 | // return params 832 | } 833 | 834 | function RSAEncrypt(message) { 835 | var encrypt = new JSEncrypt() 836 | var pKey = 837 | 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDc+CZK9bBA9IU+gZUOc6FUGu7yO9WpTNB0PzmgFBh96Mg1WrovD1oqZ+eIF4LjvxKXGOdI79JRdve9NPhQo07+uqGQgE4imwNnRx7PFtCRryiIEcUoavuNtuRVoBAm6qdB0SrctgaqGfLgKvZHOnwTjyNqjBUxzMeQlEC2czEMSwIDAQAB' 838 | encrypt.setPublicKey(pKey) 839 | var encrypted = encrypt.encrypt(message) 840 | return encrypted 841 | } 842 | 843 | // prettier-ignore 844 | function Env(t,e){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((e,i)=>{s.call(this,t,(t,s,o)=>{t?i(t):e(s)})})}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.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("",`\ud83d\udd14${this.name}, \u5f00\u59cb!`)}isNode(){return"undefined"!=typeof module&&!!module.exports}isQuanX(){return"undefined"!=typeof $task}isSurge(){return"undefined"!=typeof $httpClient&&"undefined"==typeof $loon}isLoon(){return"undefined"!=typeof $loon}isShadowrocket(){return"undefined"!=typeof $rocket}isStash(){return"undefined"!=typeof $environment&&$environment["stash-version"]}toObj(t,e=null){try{return JSON.parse(t)}catch{return e}}toStr(t,e=null){try{return JSON.stringify(t)}catch{return e}}getjson(t,e){let s=e;const i=this.getdata(t);if(i)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(e=>{this.get({url:t},(t,s,i)=>e(i))})}runScript(t,e){return new Promise(s=>{let i=this.getdata("@chavy_boxjs_userCfgs.httpapi");i=i?i.replace(/\n/g,"").trim():i;let o=this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout");o=o?1*o:20,o=e&&e.timeout?e.timeout:o;const[r,a]=i.split("@"),h={url:`http://${a}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:o},headers:{"X-Key":r,Accept:"*/*"}};this.post(h,(t,e,i)=>s(i))}).catch(t=>this.logErr(t))}loaddata(){if(!this.isNode())return{};{this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),i=!s&&this.fs.existsSync(e);if(!s&&!i)return{};{const i=s?t:e;try{return JSON.parse(this.fs.readFileSync(i))}catch(t){return{}}}}}writedata(){if(this.isNode()){this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),i=!s&&this.fs.existsSync(e),o=JSON.stringify(this.data);s?this.fs.writeFileSync(t,o):i?this.fs.writeFileSync(e,o):this.fs.writeFileSync(t,o)}}lodash_get(t,e,s){const i=e.replace(/\[(\d+)\]/g,".$1").split(".");let o=t;for(const t of i)if(o=Object(o)[t],void 0===o)return s;return o}lodash_set(t,e,s){return Object(t)!==t?t:(Array.isArray(e)||(e=e.toString().match(/[^.[\]]+/g)||[]),e.slice(0,-1).reduce((t,s,i)=>Object(t[s])===t[s]?t[s]:t[s]=Math.abs(e[i+1])>>0==+e[i+1]?[]:{},t)[e[e.length-1]]=s,t)}getdata(t){let e=this.getval(t);if(/^@/.test(t)){const[,s,i]=/^@(.*?)\.(.*?)$/.exec(t),o=s?this.getval(s):"";if(o)try{const t=JSON.parse(o);e=t?this.lodash_get(t,i,""):e}catch(t){e=""}}return e}setdata(t,e){let s=!1;if(/^@/.test(e)){const[,i,o]=/^@(.*?)\.(.*?)$/.exec(e),r=this.getval(i),a=i?"null"===r?null:r||"{}":"{}";try{const e=JSON.parse(a);this.lodash_set(e,o,t),s=this.setval(JSON.stringify(e),i)}catch(e){const r={};this.lodash_set(r,o,t),s=this.setval(JSON.stringify(r),i)}}else s=this.setval(t,e);return s}getval(t){return this.isSurge()||this.isLoon()?$persistentStore.read(t):this.isQuanX()?$prefs.valueForKey(t):this.isNode()?(this.data=this.loaddata(),this.data[t]):this.data&&this.data[t]||null}setval(t,e){return this.isSurge()||this.isLoon()?$persistentStore.write(t,e):this.isQuanX()?$prefs.setValueForKey(t,e):this.isNode()?(this.data=this.loaddata(),this.data[e]=t,this.writedata(),!0):this.data&&this.data[e]||null}initGotEnv(t){this.got=this.got?this.got:require("got"),this.cktough=this.cktough?this.cktough:require("tough-cookie"),this.ckjar=this.ckjar?this.ckjar:new this.cktough.CookieJar,t&&(t.headers=t.headers?t.headers:{},void 0===t.headers.Cookie&&void 0===t.cookieJar&&(t.cookieJar=this.ckjar))}get(t,e=(()=>{})){if(t.headers&&(delete t.headers["Content-Type"],delete t.headers["Content-Length"]),this.isSurge()||this.isLoon())this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.get(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status?s.status:s.statusCode,s.status=s.statusCode),e(t,s,i)});else if(this.isQuanX())this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:o,body:r}=t;e(null,{status:s,statusCode:i,headers:o,body:r},r)},t=>e(t));else if(this.isNode()){let s=require("iconv-lite");this.initGotEnv(t),this.got(t).on("redirect",(t,e)=>{try{if(t.headers["set-cookie"]){const s=t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString();s&&this.ckjar.setCookieSync(s,null),e.cookieJar=this.ckjar}}catch(t){this.logErr(t)}}).then(t=>{const{statusCode:i,statusCode:o,headers:r,rawBody:a}=t,h=s.decode(a,this.encoding);e(null,{status:i,statusCode:o,headers:r,rawBody:a,body:h},h)},t=>{const{message:i,response:o}=t;e(i,o,o&&s.decode(o.rawBody,this.encoding))})}}post(t,e=(()=>{})){const s=t.method?t.method.toLocaleLowerCase():"post";if(t.body&&t.headers&&!t.headers["Content-Type"]&&(t.headers["Content-Type"]="application/x-www-form-urlencoded"),t.headers&&delete t.headers["Content-Length"],this.isSurge()||this.isLoon())this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient[s](t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status?s.status:s.statusCode,s.status=s.statusCode),e(t,s,i)});else if(this.isQuanX())t.method=s,this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:o,body:r}=t;e(null,{status:s,statusCode:i,headers:o,body:r},r)},t=>e(t));else if(this.isNode()){let i=require("iconv-lite");this.initGotEnv(t);const{url:o,...r}=t;this.got[s](o,r).then(t=>{const{statusCode:s,statusCode:o,headers:r,rawBody:a}=t,h=i.decode(a,this.encoding);e(null,{status:s,statusCode:o,headers:r,rawBody:a,body:h},h)},t=>{const{message:s,response:o}=t;e(s,o,o&&i.decode(o.rawBody,this.encoding))})}}time(t,e=null){const s=e?new Date(e):new Date;let i={"M+":s.getMonth()+1,"d+":s.getDate(),"H+":s.getHours(),"m+":s.getMinutes(),"s+":s.getSeconds(),"q+":Math.floor((s.getMonth()+3)/3),S:s.getMilliseconds()};/(y+)/.test(t)&&(t=t.replace(RegExp.$1,(s.getFullYear()+"").substr(4-RegExp.$1.length)));for(let e in i)new RegExp("("+e+")").test(t)&&(t=t.replace(RegExp.$1,1==RegExp.$1.length?i[e]:("00"+i[e]).substr((""+i[e]).length)));return t}msg(e=t,s="",i="",o){const r=t=>{if(!t)return t;if("string"==typeof t)return this.isLoon()?t:this.isQuanX()?{"open-url":t}:this.isSurge()?{url:t}:void 0;if("object"==typeof t){if(this.isLoon()){let e=t.openUrl||t.url||t["open-url"],s=t.mediaUrl||t["media-url"];return{openUrl:e,mediaUrl:s}}if(this.isQuanX()){let e=t["open-url"]||t.url||t.openUrl,s=t["media-url"]||t.mediaUrl,i=t["update-pasteboard"]||t.updatePasteboard;return{"open-url":e,"media-url":s,"update-pasteboard":i}}if(this.isSurge()){let e=t.url||t.openUrl||t["open-url"];return{url:e}}}};if(this.isMute||(this.isSurge()||this.isLoon()?$notification.post(e,s,i,r(o)):this.isQuanX()&&$notify(e,s,i,r(o))),!this.isMuteLog){let t=["","==============\ud83d\udce3\u7cfb\u7edf\u901a\u77e5\ud83d\udce3=============="];t.push(e),s&&t.push(s),i&&t.push(i),console.log(t.join("\n")),this.logs=this.logs.concat(t)}}log(...t){t.length>0&&(this.logs=[...this.logs,...t]),console.log(t.join(this.logSeparator))}logErr(t,e){const s=!this.isSurge()&&!this.isQuanX()&&!this.isLoon();s?this.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t.stack):this.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`\ud83d\udd14${this.name}, \u7ed3\u675f! \ud83d\udd5b ${s} \u79d2`),this.log(),this.isSurge()||this.isQuanX()||this.isLoon()?$done(t):this.isNode()&&process.exit(1)}}(t,e)} 845 | --------------------------------------------------------------------------------