|
| 1 | +/* ziye CK导入导出专用 务必下载或者复制到本地使用 |
| 2 | +
|
| 3 | +github地址 https://github.com/ziye12 |
| 4 | +TG频道地址 https://t.me/ziyescript |
| 5 | +TG交流群 https://t.me/joinchat/AAAAAE7XHm-q1-7Np-tF3g |
| 6 | +boxjs链接 https://raw.githubusercontent.com/ziye12/JavaScript/main/Task/ziye.boxjs.json |
| 7 | +
|
| 8 | +
|
| 9 | +转载请备注个名字,谢谢 |
| 10 | +
|
| 11 | +
|
| 12 | +
|
| 13 | +*/ |
| 14 | + |
| 15 | +const $ = Env("CK导入导出"); |
| 16 | + |
| 17 | +//填写账号数, |
| 18 | +const Count=5 |
| 19 | + |
| 20 | +//设置1,导入CK |
| 21 | +const DR=0 |
| 22 | + |
| 23 | +//设置1,导出CK |
| 24 | +const DC=0 |
| 25 | + |
| 26 | +//0可批量导入ck, 1清空ck 2单独导入ck |
| 27 | +const QK=0 |
| 28 | + |
| 29 | + |
| 30 | + |
| 31 | + |
| 32 | + |
| 33 | +//👇👇👇👇👇👇👇👇👇👇👇👇 CK单独导入 👇👇👇👇👇👇👇👇👇👇👇👇👇👇 |
| 34 | + |
| 35 | +//填写你要单独导入的ck名字,去boxjs里看或者ck获取处 如$.setdata(refreshtokenVal, "refreshtoken" + $.idx); 想要导入账号2的ck 则在''中填写refreshtoken2 |
| 36 | +const JSCKNAME='refreshtoken2' |
| 37 | + |
| 38 | +//填写 想要单独导入的ck数据,如token=abc 则在``中填写token=abc |
| 39 | +const JSCK=`token=abc` |
| 40 | + |
| 41 | + |
| 42 | + |
| 43 | + |
| 44 | + |
| 45 | +//👇👇👇👇👇👇👇👇👇👇👇👇 CK批量导入 👇👇👇👇👇👇👇👇👇👇👇👇👇👇 |
| 46 | + |
| 47 | + |
| 48 | +//填写你要导入的ck名字,去boxjs里看或者ck获取处 如$.setdata(refreshtokenVal, "refreshtoken" + $.idx); 则在''中填写refreshtoken |
| 49 | + |
| 50 | +const JSA='refreshtoken' |
| 51 | +const JSB='' |
| 52 | +const JSC='' |
| 53 | +const JSD='' |
| 54 | +const JSE='' |
| 55 | +const JSF='' |
| 56 | +const JSG='' |
| 57 | +const JSH='' |
| 58 | +const JSI='' |
| 59 | +const JSJ='' |
| 60 | +const JSK='' |
| 61 | +const JSL='' |
| 62 | + |
| 63 | +//填写 想要导入的ck数据,多账号换行 如token=abc 则在``中填写token=abc |
| 64 | +const JSAVal=`` |
| 65 | +const JSBVal=`` |
| 66 | +const JSCVal=`` |
| 67 | +const JSDVal=`` |
| 68 | +const JSEVal=`` |
| 69 | +const JSFVal=`` |
| 70 | +const JSGVal=`` |
| 71 | +const JSHVal=`` |
| 72 | +const JSIVal=`` |
| 73 | +const JSJVal=`` |
| 74 | +const JSKVal=`` |
| 75 | +const JSLVal=`` |
| 76 | +//👆👆👆👆👆👆👆👆👆👆👆👆👆👆👆👆👆👆👆👆👆👆👆👆👆👆👆👆 |
| 77 | + |
| 78 | + |
| 79 | + |
| 80 | + |
| 81 | + |
| 82 | + |
| 83 | + |
| 84 | + |
| 85 | + |
| 86 | +//👇👇👇👇👇👇👇👇👇👇👇👇 CK导出 👇👇👇👇👇👇👇👇👇👇👇👇👇👇 |
| 87 | + |
| 88 | +let K = 1;//从哪个账号开始 |
| 89 | +let Z = 5;//到哪个账号结束 |
| 90 | + |
| 91 | +const GG=''//默认为换行,也可以将需要隔开的符号填写在''内 |
| 92 | + |
| 93 | +//填写你要打印的ck名字,去js里获取ck处看 如$.setdata(refreshtokenVal, "refreshtoken" + $.idx); 则在''中填写refreshtoken |
| 94 | + |
| 95 | +const jsA='refreshtoken' |
| 96 | +const jsB='' |
| 97 | +const jsC='' |
| 98 | +const jsD='' |
| 99 | +const jsE='' |
| 100 | +const jsF='' |
| 101 | +const jsG='' |
| 102 | +const jsH='' |
| 103 | +const jsI='' |
| 104 | +const jsJ='' |
| 105 | +const jsK='' |
| 106 | +const jsL='' |
| 107 | + |
| 108 | +//开启打印则设置为1 |
| 109 | +const jsAA=1 |
| 110 | +const jsBB=0 |
| 111 | +const jsCC=0 |
| 112 | +const jsDD=0 |
| 113 | +const jsEE=0 |
| 114 | +const jsFF=0 |
| 115 | +const jsGG=0 |
| 116 | +const jsHH=0 |
| 117 | +const jsII=0 |
| 118 | +const jsJJ=0 |
| 119 | +const jsKK=0 |
| 120 | +const jsLL=0 |
| 121 | + |
| 122 | +//👆👆👆👆👆👆👆👆👆👆👆👆👆👆👆👆👆👆👆👆👆👆👆👆👆👆👆👆 |
| 123 | + |
| 124 | + |
| 125 | + |
| 126 | +//⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️下面内容不要随意改动 |
| 127 | + if (DR==1) { |
| 128 | +if (QK==1) |
| 129 | +{ |
| 130 | +const JSAVal=`` |
| 131 | +const JSBVal=`` |
| 132 | +const JSCVal=`` |
| 133 | +const JSDVal=`` |
| 134 | +const JSEVal=`` |
| 135 | +const JSFVal=`` |
| 136 | +const JSGVal=`` |
| 137 | +const JSHVal=`` |
| 138 | +const JSIVal=`` |
| 139 | +const JSJVal=`` |
| 140 | +const JSKVal=`` |
| 141 | +const JSLVal=`` |
| 142 | +} |
| 143 | + if (QK==2) { |
| 144 | + $.setdata(JSCK, `${JSCKNAME}`); |
| 145 | + console.log($.name+',ck单独导入成功','✅已导入'+JSCKNAME,) |
| 146 | + $.msg($.name+',ck单独导入成功','✅已导入'+JSCKNAME,) |
| 147 | + } |
| 148 | + if ((QK==0&&JSAVal!='')||QK==1) { |
| 149 | + $.setdata(JSAVal.split('\n')[0], `${JSA}`); |
| 150 | + $.setdata(JSBVal.split('\n')[0], `${JSB}`); |
| 151 | + $.setdata(JSCVal.split('\n')[0], `${JSC}`); |
| 152 | + $.setdata(JSDVal.split('\n')[0], `${JSD}`); |
| 153 | + $.setdata(JSEVal.split('\n')[0], `${JSE}`); |
| 154 | + $.setdata(JSFVal.split('\n')[0], `${JSF}`); |
| 155 | + $.setdata(JSGVal.split('\n')[0], `${JSG}`); |
| 156 | + $.setdata(JSHVal.split('\n')[0], `${JSH}`); |
| 157 | + $.setdata(JSIVal.split('\n')[0], `${JSI}`); |
| 158 | + $.setdata(JSJVal.split('\n')[0], `${JSJ}`); |
| 159 | + $.setdata(JSKVal.split('\n')[0], `${JSK}`); |
| 160 | + $.setdata(JSLVal.split('\n')[0], `${JSL}`); |
| 161 | + for (let i =2; i <= Count; i++) { |
| 162 | + $.setdata(JSAVal.split('\n')[i-1], `${JSA+i}`); |
| 163 | + $.setdata(JSBVal.split('\n')[i-1], `${JSB+i}`); |
| 164 | + $.setdata(JSCVal.split('\n')[i-1], `${JSC+i}`); |
| 165 | + $.setdata(JSDVal.split('\n')[i-1], `${JSD+i}`); |
| 166 | + $.setdata(JSEVal.split('\n')[i-1], `${JSE+i}`); |
| 167 | + $.setdata(JSFVal.split('\n')[i-1], `${JSF+i}`); |
| 168 | + $.setdata(JSGVal.split('\n')[i-1], `${JSG+i}`); |
| 169 | + $.setdata(JSHVal.split('\n')[i-1], `${JSH+i}`); |
| 170 | + $.setdata(JSIVal.split('\n')[i-1], `${JSI+i}`); |
| 171 | + $.setdata(JSJVal.split('\n')[i-1], `${JSJ+i}`); |
| 172 | + $.setdata(JSKVal.split('\n')[i-1], `${JSK+i}`); |
| 173 | + $.setdata(JSLVal.split('\n')[i-1], `${JSL+i}`); |
| 174 | + } |
| 175 | + |
| 176 | + if (QK==0&&JSAVal!='') { |
| 177 | + console.log($.name+',ck批量导入成功✅') |
| 178 | + $.msg($.name+',ck批量导入成功✅') |
| 179 | + |
| 180 | + } |
| 181 | + |
| 182 | + if (QK==1) { |
| 183 | + console.log($.name+',ck清除成功✅') |
| 184 | + $.msg($.name+',ck清除成功✅') |
| 185 | + |
| 186 | + } |
| 187 | + } |
| 188 | + |
| 189 | +$.done() |
| 190 | + } |
| 191 | + if (DC==1) { |
| 192 | +let R=K |
| 193 | +const jsAArr = []; |
| 194 | +let jsAVal = ``; |
| 195 | +const jsBArr = []; |
| 196 | +let jsBVal = ``; |
| 197 | +const jsCArr = []; |
| 198 | +let jsCVal = ``; |
| 199 | +const jsDArr = []; |
| 200 | +let jsDVal = ``; |
| 201 | +const jsEArr = []; |
| 202 | +let jsEVal = ``; |
| 203 | +const jsFArr = []; |
| 204 | +let jsFVal = ``; |
| 205 | +const jsGArr = []; |
| 206 | +let jsGVal = ``; |
| 207 | +const jsHArr = []; |
| 208 | +let jsHVal = ``; |
| 209 | +const jsIArr = []; |
| 210 | +let jsIVal = ``; |
| 211 | +const jsJArr = []; |
| 212 | +let jsJVal = ``; |
| 213 | +const jsKArr = []; |
| 214 | +let jsKVal = ``; |
| 215 | +const jsLArr = []; |
| 216 | +let jsLVal = ``; |
| 217 | + jsAArr.push($.getdata(`${jsA}`)); |
| 218 | + jsBArr.push($.getdata(`${jsB}`)); |
| 219 | + jsCArr.push($.getdata(`${jsC}`)); |
| 220 | + jsDArr.push($.getdata(`${jsD}`)); |
| 221 | + jsEArr.push($.getdata(`${jsE}`)); |
| 222 | + jsFArr.push($.getdata(`${jsF}`)); |
| 223 | + jsGArr.push($.getdata(`${jsG}`)); |
| 224 | + jsHArr.push($.getdata(`${jsH}`)); |
| 225 | + jsIArr.push($.getdata(`${jsI}`)); |
| 226 | + jsJArr.push($.getdata(`${jsJ}`)); |
| 227 | + jsKArr.push($.getdata(`${jsK}`)); |
| 228 | + jsLArr.push($.getdata(`${jsL}`)); |
| 229 | + // 根据boxjs中设置的额外账号数,添加存在的账号数据进行任务处理 |
| 230 | + for (let i = 2; i <= Count; i++) { |
| 231 | + if ($.getdata(`${jsA+i}`)) { |
| 232 | + jsAArr.push($.getdata(`${jsA+i}`)); |
| 233 | + jsBArr.push($.getdata(`${jsB+i}`)); |
| 234 | + jsCArr.push($.getdata(`${jsC+i}`)); |
| 235 | + jsDArr.push($.getdata(`${jsD+i}`)); |
| 236 | + jsEArr.push($.getdata(`${jsE+i}`)); |
| 237 | + jsFArr.push($.getdata(`${jsF+i}`)); |
| 238 | + jsGArr.push($.getdata(`${jsG+i}`)); |
| 239 | + jsHArr.push($.getdata(`${jsH+i}`)); |
| 240 | + jsIArr.push($.getdata(`${jsI+i}`)); |
| 241 | + jsJArr.push($.getdata(`${jsJ+i}`)); |
| 242 | + jsKArr.push($.getdata(`${jsK+i}`)); |
| 243 | + jsLArr.push($.getdata(`${jsL+i}`)); |
| 244 | + } |
| 245 | + } |
| 246 | + console.log( |
| 247 | + `============ 脚本执行-北京时间(UTC+8):${new Date( |
| 248 | + new Date().getTime() + 8 * 60 * 60 * 1000 |
| 249 | + ).toLocaleString()} =============\n` |
| 250 | + ); |
| 251 | +if (Z<K){ |
| 252 | + $.msg('⚠️提示:请不要调皮🐶') |
| 253 | + $.done(); |
| 254 | +} |
| 255 | +all(); |
| 256 | +function all() { |
| 257 | +if (!jsAArr[K-1]) { |
| 258 | +if (K>R) |
| 259 | + $.msg($.name+R+'到'+(K-1)+'打印成功'+K+'到'+Z+'打印失败', '⚠️提示:请先获取'+K+'到'+Z+'的ck','并设置好账号数') |
| 260 | +if (K==R&&Z>R) |
| 261 | + $.msg($.name+K+'到'+Z+'打印失败', '⚠️提示:请先获取'+K+'到'+Z+'的ck','并设置好账号数') |
| 262 | +if (Z==R) |
| 263 | + $.msg($.name+K+'打印失败', '⚠️提示:请先获取'+K+'的ck','并设置好账号数') |
| 264 | + $.done(); |
| 265 | + } |
| 266 | + jsAVal = jsAArr[K-1]; |
| 267 | + jsBVal = jsBArr[K-1]; |
| 268 | + jsCVal = jsCArr[K-1]; |
| 269 | + jsDVal = jsDArr[K-1]; |
| 270 | + jsEVal = jsEArr[K-1]; |
| 271 | + jsFVal = jsFArr[K-1]; |
| 272 | + jsGVal = jsGArr[K-1]; |
| 273 | + jsHVal = jsHArr[K-1]; |
| 274 | + jsIVal = jsIArr[K-1]; |
| 275 | + jsJVal = jsJArr[K-1]; |
| 276 | + jsKVal = jsKArr[K-1]; |
| 277 | + jsLVal = jsLArr[K-1]; |
| 278 | +if(jsAA==1)console.log(jsAVal+GG) |
| 279 | +if(jsBB==1)console.log(jsBVal+GG) |
| 280 | +if(jsCC==1)console.log(jsCVal+GG) |
| 281 | +if(jsDD==1)console.log(jsDVal+GG) |
| 282 | +if(jsEE==1)console.log(jsEVal+GG) |
| 283 | +if(jsFF==1)console.log(jsFVal+GG) |
| 284 | +if(jsGG==1)console.log(jsGVal+GG) |
| 285 | +if(jsHH==1)console.log(jsHVal+GG) |
| 286 | +if(jsII==1)console.log(jsIVal+GG) |
| 287 | +if(jsJJ==1)console.log(jsJVal+GG) |
| 288 | +if(jsKK==1)console.log(jsKVal+GG) |
| 289 | +if(jsLL==1)console.log(jsLVal+GG) |
| 290 | + for (let i = 0; i < 1; i++) { |
| 291 | + (function (i) { |
| 292 | + setTimeout( |
| 293 | + function () { |
| 294 | + if (i == 0){ |
| 295 | + if ( K < Z ) { |
| 296 | + K += 1; |
| 297 | + all(); |
| 298 | +} else if (K == Z ) { |
| 299 | + let F=Z-R+1 |
| 300 | + $.msg($.name+R+'到'+Z+',ck打印成功','✅已打印'+F+'个ck',) |
| 301 | + $.done(); |
| 302 | + } |
| 303 | + } |
| 304 | +}, |
| 305 | + (i + 1) * 10 |
| 306 | + ); |
| 307 | + })(i); |
| 308 | + } |
| 309 | +} |
| 310 | +} |
| 311 | + |
| 312 | + |
| 313 | +if(DC==0&&DR==0){ |
| 314 | + |
| 315 | +console.log('😂你玩了个寂寞') |
| 316 | + $.msg('😂你玩了个寂寞') |
| 317 | +$.done(); |
| 318 | + |
| 319 | +} |
| 320 | + |
| 321 | +// prettier-ignore |
| 322 | +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,r)=>{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.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}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 r=this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout");r=r?1*r:20,r=e&&e.timeout?e.timeout:r;const[o,h]=i.split("@"),a={url:`http://${h}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:r},headers:{"X-Key":o,Accept:"*/*"}};this.post(a,(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),r=JSON.stringify(this.data);s?this.fs.writeFileSync(t,r):i?this.fs.writeFileSync(e,r):this.fs.writeFileSync(t,r)}}lodash_get(t,e,s){const i=e.replace(/\[(\d+)\]/g,".$1").split(".");let r=t;for(const t of i)if(r=Object(r)[t],void 0===r)return s;return r}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),r=s?this.getval(s):"";if(r)try{const t=JSON.parse(r);e=t?this.lodash_get(t,i,""):e}catch(t){e=""}}return e}setdata(t,e){let s=!1;if(/^@/.test(e)){const[,i,r]=/^@(.*?)\.(.*?)$/.exec(e),o=this.getval(i),h=i?"null"===o?null:o||"{}":"{}";try{const e=JSON.parse(h);this.lodash_set(e,r,t),s=this.setval(JSON.stringify(e),i)}catch(e){const o={};this.lodash_set(o,r,t),s=this.setval(JSON.stringify(o),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=(()=>{})){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),e(t,s,i)})):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:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t))):this.isNode()&&(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();this.ckjar.setCookieSync(s,null),e.cookieJar=this.ckjar}}catch(t){this.logErr(t)}}).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)}))}post(t,e=(()=>{})){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.post(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)});else if(this.isQuanX())t.method="POST",this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t));else if(this.isNode()){this.initGotEnv(t);const{url:s,...i}=t;this.got.post(s,i).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)})}}time(t){let e={"M+":(new Date).getMonth()+1,"d+":(new Date).getDate(),"H+":(new Date).getHours(),"m+":(new Date).getMinutes(),"s+":(new Date).getSeconds(),"q+":Math.floor(((new Date).getMonth()+3)/3),S:(new Date).getMilliseconds()};/(y+)/.test(t)&&(t=t.replace(RegExp.$1,((new Date).getFullYear()+"").substr(4-RegExp.$1.length)));for(let s in e)new RegExp("("+s+")").test(t)&&(t=t.replace(RegExp.$1,1==RegExp.$1.length?e[s]:("00"+e[s]).substr((""+e[s]).length)));return t}msg(e=t,s="",i="",r){const o=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;return{"open-url":e,"media-url":s}}if(this.isSurge()){let e=t.url||t.openUrl||t["open-url"];return{url:e}}}};this.isMute||(this.isSurge()||this.isLoon()?$notification.post(e,s,i,o(r)):this.isQuanX()&&$notify(e,s,i,o(r)));let h=["","==============\ud83d\udce3\u7cfb\u7edf\u901a\u77e5\ud83d\udce3=============="];h.push(e),s&&h.push(s),i&&h.push(i),console.log(h.join("\n")),this.logs=this.logs.concat(h)}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)}}(t,e)} |
0 commit comments