diff --git a/52pojie-DailyBonus/52pojie.js b/52pojie-DailyBonus/52pojie.js index 50f6a50d86..52572b8bdc 100644 --- a/52pojie-DailyBonus/52pojie.js +++ b/52pojie-DailyBonus/52pojie.js @@ -1,7 +1,7 @@ /* 吾爱破解签到脚本 -更新时间: 2020.11.11 +更新时间: 2021.09.22 脚本兼容: QuantumultX, Surge, Loon, Node.js 电报频道: @NobyDa 问题反馈: @NobyDa_bot @@ -24,6 +24,9 @@ Node.js说明: const CookieWA = ''; +//Bark APP 通知推送Key +const barkKey = ''; + /*********************** Surge 4.2.0+ 脚本配置: ************************ @@ -66,7 +69,7 @@ http-request https:\/\/www\.52pojie\.cn\/home\.php\? script-path=https://raw.git hostname= www.52pojie.cn */ -var $ = new Env(''); +var $ = new Env('吾爱破解'); var date = new Date() if (typeof $request != "undefined") { GetCookie() @@ -80,23 +83,26 @@ function checkin() { headers: { Cookie: CookieWA || $.getdata("CookieWA"), } - }, function(error, response, data) { + }, async function(error, response, data) { if (error && !data) { - $.log(error); - $.msg("吾爱破解", "签到请求失败 ‼️‼️", error) + $.msgBody = `签到请求失败 ‼️‼️\n${error}` } else { if (data.match(/(ÒÑÍê³É|\u606d\u559c\u60a8|��̳΢�š��ᰮ�ƽ�)/)) { - $.msg("吾爱破解", "", date.getMonth() + 1 + "月" + date.getDate() + "日, 签到成功 🎉") + $.msgBody = date.getMonth() + 1 + "月" + date.getDate() + "日, 签到成功 🎉" } else if (data.match(/(ÄúÒÑ|\u4e0b\u671f\u518d\u6765|>��Ǹ������)/)) { - $.msg("吾爱破解", "", date.getMonth() + 1 + "月" + date.getDate() + "日, 已签过 ⚠️") + $.msgBody = date.getMonth() + 1 + "月" + date.getDate() + "日, 已签过 ⚠️" } else if (data.match(/(ÏȵǼ|\u9700\u8981\u5148\u767b\u5f55|�Ҫ�ȵ�¼���ܼ�)/)) { - $.msg("吾爱破解", "", "签到失败, Cookie失效 ‼️‼️") + $.msgBody = "签到失败, Cookie失效 ‼️‼️" } else if (response.statusCode == 403) { - $.msg("吾爱破解", "", "服务器暂停签到 ⚠️") + $.msgBody = "服务器暂停签到 ⚠️" } else { - $.msg("吾爱破解", "", "脚本待更新 ‼️‼️") + $.msgBody = "脚本待更新 ‼️‼️" } } + if (barkKey) { + await BarkNotify($, barkKey, $.name, $.msgBody); + } + $.msg($.name, ``, $.msgBody); $.done(); }) } @@ -133,5 +139,9 @@ function GetCookie() { } $.done(); } + +//Bark APP notify +async function BarkNotify(c,k,t,b){for(let i=0;i<3;i++){console.log(`🔷Bark notify >> Start push (${i+1})`);const s=await new Promise((n)=>{c.post({url:'https://api.day.app/push',headers:{'Content-Type':'application/json'},body:JSON.stringify({title:t,body:b,device_key:k,ext_params:{group:t}})},(e,r,d)=>r&&r.status==200?n(1):n(d||e))});if(s===1){console.log('✅Push success!');break}else{console.log(`❌Push failed! >> ${s.message||s}`)}}}; + //Compatible code from https://github.com/chavyleung/scripts/blob/master/Env.min.js 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("","")}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{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=["",""];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("",`${s} \u79d2`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)} \ No newline at end of file diff --git a/Bahamut/BahamutDailyBonus.js b/Bahamut/BahamutDailyBonus.js index c4794e1341..42ca42997a 100644 --- a/Bahamut/BahamutDailyBonus.js +++ b/Bahamut/BahamutDailyBonus.js @@ -53,6 +53,9 @@ $.needSignGuild = $.getdata('@ND_BAHA.GUILD') || true; // 是否自动答题动画疯,true/false,默认开启 (不保证100%答题正确) $.needAnswer = $.getdata('@ND_BAHA.ANSWER') || true; +//Bark APP 通知推送Key +$.barkKey = ''; + // 为通知准备的空数组 $.notifyMsg = []; @@ -62,43 +65,55 @@ $.notifyMsg = []; await BahamutSign(); //签到巴哈 await BahamutAnswer(); //动画疯答题 })().catch((e) => $.notifyMsg.push(e.message || e)) //捕获登录函数等抛出的异常, 并把原因添加到全局变量(通知) - .finally(() => { //finally在catch之后无论有无异常都会执行 - $.msg(`巴哈姆特`, ``, $.notifyMsg.join('\n'), { + .finally(async () => { //finally在catch之后无论有无异常都会执行 + if ($.barkKey) { //如果已填写Bark Key + await BarkNotify($, $.barkKey, $.name, $.notifyMsg.join('\n')); //推送Bark通知 + }; + $.msg($.name, ``, $.notifyMsg.join('\n'), { 'open-url': 'crazyanime://', //动画疯url scheme 'media-url': 'https://cdn.jsdelivr.net/gh/NobyDa/mini@master/Color/bahamutClear.png' //通知图片 }); //带上总结推送通知 $.done(); //调用Surge、QX内部特有的函数, 用于退出脚本执行 }); -function BahamutLogin(retry) { //登录函数,拿到Set-Cookie +async function BahamutLogin(retry = 3, interval = 1000) { //登录函数,拿到Set-Cookie //登录成功: {"success":true,"userid":"DGIE","nickname":"coco","gold":152769,"gp":0,"avatar":"https:\/\/avatar2.bahamut.com.tw\/avataruserpic\/dgie.png","avatar_s":"https:\/\/avatar2.bahamut.com.tw\/avataruserpic\/dgie_s.png","lv":6} //账号错误: {"code":0,"message":"查無此人:SDFOUGB"} //密码错误: {"code":0,"message":"帳號、密碼或驗證碼錯誤!"} //验证码错误: {"code":0,"message":"驗證碼錯誤"} - return $.http.post({ //使用post请求查询 (兼容函数实际上返回Promise实例对象,以便后续调用时可以实现顺序执行异步函数) + for (let i = 0; i < retry; i++) { //循环登录(默认三次) + if (i > 0) { + $.log('', `🔶尝试第${i+1}次登录...`); + await $.wait(interval); //延迟一秒 + }; + const reqUrl = { url: 'https://api.gamer.com.tw/mobile_app/user/v3/do_login.php', //登录接口 headers: { //请求头 'Cookie': 'ckAPP_VCODE=6666' //Cookie中的ckAPP_VCODE为必须 }, //请求体放入用户名和密码,并把它uri编码 body: `uid=${encodeURIComponent($.uid)}&passwd=${encodeURIComponent($.pwd)}&vcode=6666${$.totp?`&twoStepAuth=${TOTP($.totp)}`:``}` - }) - .then(async (resp) => { //请求成功的处理 - const body = JSON.parse(resp.body); //解析响应体json为对象 - if (body.userid) { //如果成功返回用户信息 - $.BAHARUNE = JSON.stringify(resp.headers).split(/(BAHARUNE=\w+)/)[1]; - $.log('', `✅巴哈姆特登录成功`); // 打印日志 - } else if (!retry && body.message.includes('驗證碼錯誤')) { //如果首次登陆并且一次性密码失效 - $.log('', `❌登录失败, 3秒后重试`); // 打印日志 - await $.wait(3000); //等待三秒 - await BahamutLogin(true); //重新执行登录函数, 带上参数避免死循环 - } else { //否则登录失败 (例如密码错误) - const failMsg = body.error ? body.error.message : null; //判断签到失败原因 - throw new Error(`❌登录失败\n❌${body.message||failMsg||'未知'}`); //带上原因抛出异常, 脚本结束 - } - }) //未写catch,如果登录失败,例如无法联网、密码错误等, 则被调用该函数时的catch捕获,脚本结束 + }; + const res = await $.http.post(reqUrl) //使用post请求查询 (兼容函数实际上返回Promise实例对象,以便后续调用时可以实现顺序执行异步函数) + .then(async (resp) => { //请求成功的处理 + const body = JSON.parse(resp.body); //解析响应体json为对象 + if (body.userid) { //如果成功返回用户信息 + $.BAHARUNE = JSON.stringify(resp.headers).split(/(BAHARUNE=\w+)/)[1]; + return `✅巴哈姆特登录成功`; + } else { //否则登录失败 (例如密码错误) + const failMsg = body.error ? body.error.message : null; //判断签到失败原因 + throw new Error(`${body.message||failMsg||'原因未知'}`); //带上原因抛出异常 + } + }).catch((err) => `❌登录失败\n❌${err.message || err}`); + $.log('', res.message || res); + if (res === `✅巴哈姆特登录成功`) { + break; //登录成功则跳出循环 + } else if (retry == i + 1) { //如果最后一次重试仍登录失败 + throw new Error(res.message || res); //抛出错误, 被调用该函数时的catch捕获, 脚本结束. + } + } } function BahamutSign() { //查询巴哈姆特签到Token @@ -333,6 +348,9 @@ function StartBahamutAnswer(answer, token) { //动画疯答题 }) } +//Bark APP notify +async function BarkNotify(c,k,t,b){for(let i=0;i<3;i++){console.log(`🔷Bark notify >> Start push (${i+1})`);const s=await new Promise((n)=>{c.post({url:'https://api.day.app/push',headers:{'Content-Type':'application/json'},body:JSON.stringify({title:t,body:b,device_key:k,ext_params:{group:t}})},(e,r,d)=>r&&r.status==200?n(1):n(d||e))});if(s===1){console.log('✅Push success!');break}else{console.log(`❌Push failed! >> ${s.message||s}`)}}}; + //修改自 https://github.com/chavyleung/scripts/blob/master/Env.js 的兼容函数 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.ua="Anime/2.13.9 (tw.com.gamer.anime;build:437;iOS 14.5.0) Alamofire/5.4.1",this.logs=[],this.isMute=!1,this.isNeedRewrite=!0,this.logSeparator="\n",this.startTime=(new Date).getTime(),Object.assign(this,e),this.log("",`\ud83d\udd14${this.name}`)}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}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||/ckAPP_VCODE/.test(t.headers.Cookie))&&void 0===t.cookieJar)&&(t.cookieJar=this.ckjar))}get(t,e=(()=>{})){t.headers&&(t.headers["User-Agent"]=this.ua,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();s&&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=(()=>{})){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&&(t.headers["User-Agent"]=this.ua,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),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: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:i,...r}=t;this.got[s](i,r).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,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="",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}}}};if(this.isMute||(this.isSurge()||this.isLoon()?$notification.post(e,s,i,o(r)):this.isQuanX()&&$notify(e,s,i,o(r))),!this.isMuteLog){let t=["","================================="];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("",`${s}\u79d2`,`=================================`),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)}; diff --git a/Bilibili-DailyBonus/Manga.js b/Bilibili-DailyBonus/Manga.js index 7b0d4a1f29..44afbfc9a8 100644 --- a/Bilibili-DailyBonus/Manga.js +++ b/Bilibili-DailyBonus/Manga.js @@ -17,10 +17,10 @@ Surge 4.2.0+ : [Script] Bili漫画签到 = type=cron,cronexp=0 9 * * *,wake-system=1,script-path=https://raw.githubusercontent.com/NobyDa/Script/master/Bilibili-DailyBonus/Manga.js -Bili漫画Cookie = type=http-request,pattern=^https:\/\/passport\.biligame\.com\/api\/login\/sso.+?version%22%3A%22(3|4|5),script-path=https://raw.githubusercontent.com/NobyDa/Script/master/Bilibili-DailyBonus/Manga.js +Bili漫画Cookie = type=http-request,pattern=^https:\/\/app\.bilibili\.com\/x\/v2\/account\/myinfo,script-path=https://raw.githubusercontent.com/NobyDa/Script/master/Bilibili-DailyBonus/Manga.js [MITM] -hostname = passport.biligame.com +hostname = app.bilibili.com ~~~~~~~~~~~~~~~~ QX 1.0.10+ : @@ -29,17 +29,20 @@ QX 1.0.10+ : [rewrite_local] #获取Bili漫画Cookie -^https:\/\/passport\.biligame\.com\/api\/login\/sso.+?version%22%3A%22(3|4|5) url script-request-header https://raw.githubusercontent.com/NobyDa/Script/master/Bilibili-DailyBonus/Manga.js +^https:\/\/app\.bilibili\.com\/x\/v2\/account\/myinfo url script-request-header https://raw.githubusercontent.com/NobyDa/Script/master/Bilibili-DailyBonus/Manga.js [mitm] -hostname = passport.biligame.com +hostname = app.bilibili.com ~~~~~~~~~~~~~~~~ */ +const $ = new Env(`哔哩哔哩漫画`); -const $nobyda = nobyda(); +const cookie = $.getdata("CookieBM") || ''; // 哔哩哔哩漫画Cookie -if ($nobyda.isRequest) { +const barkKey = ''; //Bark APP 通知推送Key + +if (typeof $request !== 'undefined') { GetCookie() } else { checkin() @@ -49,29 +52,27 @@ function checkin() { const bilibili = { url: 'https://manga.bilibili.com/twirp/activity.v1.Activity/ClockIn', headers: { - Cookie: $nobyda.read("CookieBM"), + Cookie: cookie, }, body: "platform=ios" }; - $nobyda.post(bilibili, function(error, response, data) { - if (!error) { - if (parseInt(response.status) == 200) { - console.log("bilibili success response : \n" + data) - $nobyda.notify("哔哩哔哩漫画 - 签到成功!🎉", "", "") - } else { - console.log("bilibili failed response : \n" + data) - if (data.match(/duplicate/)) { - $nobyda.notify("哔哩哔哩漫画 - 今日已签过 ⚠️", "", "") - } else if (data.match(/uid must/)) { - $nobyda.notify("哔哩哔哩漫画 - Cookie无效 ‼️‼️", "", "") - } else { - $nobyda.notify("哔哩哔哩漫画 - 签到失败 ‼️", "", data) - } - } + $.post(bilibili, async function(error, response, data) { + if (error && !data) { + $.msgBody = `请求失败!\n${error}`; + } else if (parseInt(response.status) == 200) { + $.msgBody = "签到成功!🎉"; + } else if (/duplicate/.test(data)) { + $.msgBody = "今日已签过 ⚠️"; + } else if (/uid must/.test(data)) { + $.msgBody = "Cookie失效 ‼️‼️"; } else { - $nobyda.notify("哔哩哔哩漫画 - 签到接口请求失败", "", error) + $.msgBody = `签到失败 ‼️\n${data}`; + } + if (barkKey) { + await BarkNotify($, barkKey, $.name, $.msgBody); } - $nobyda.end() + $.msg($.name, ``, $.msgBody); + $.done(); }) } @@ -83,62 +84,34 @@ function GetCookie() { var header = $request.headers['Cookie'] ? $request.headers['Cookie'] : ""; if (header.indexOf("SESSDATA=") != -1) { var CookieValue = regex.exec(header)[0]; - if ($nobyda.read(CookieKey)) { - if ($nobyda.read(CookieKey) != CookieValue) { - var cookie = $nobyda.write(CookieValue, CookieKey); + if ($.getdata(CookieKey)) { + if ($.getdata(CookieKey) != CookieValue) { + var cookie = $.setdata(CookieValue, CookieKey); if (!cookie) { - $nobyda.notify("更新" + CookieName + "Cookie失败‼️", "", ""); + $.msg("更新" + CookieName + "Cookie失败‼️", "", ""); } else { - $nobyda.notify("更新" + CookieName + "Cookie成功 🎉", "", ""); + $.msg("更新" + CookieName + "Cookie成功 🎉", "", ""); } } } else { - var cookie = $nobyda.write(CookieValue, CookieKey); + var cookie = $.setdata(CookieValue, CookieKey); if (!cookie) { - $nobyda.notify("首次写入" + CookieName + "Cookie失败‼️", "", ""); + $.msg("首次写入" + CookieName + "Cookie失败‼️", "", ""); } else { - $nobyda.notify("首次写入" + CookieName + "Cookie成功 🎉", "", ""); + $.msg("首次写入" + CookieName + "Cookie成功 🎉", "", ""); } } } else { - $nobyda.notify("写入" + CookieName + "Cookie失败‼️", "", "Cookie关键值缺失"); + $.msg("写入" + CookieName + "Cookie失败‼️", "", "Cookie关键值缺失"); } } else { - $nobyda.notify("写入" + CookieName + "Cookie失败‼️", "", "配置错误, 无法读取请求头,"); + $.msg("写入" + CookieName + "Cookie失败‼️", "", "配置错误, 无法读取请求头,"); } - $nobyda.end() + $.done() } -function nobyda() { - const isRequest = typeof $request != "undefined" - const isSurge = typeof $httpClient != "undefined" - const isQuanX = typeof $task != "undefined" - const notify = (title, subtitle, message) => { - if (isQuanX) $notify(title, subtitle, message) - if (isSurge) $notification.post(title, subtitle, message) - } - const write = (value, key) => { - if (isQuanX) return $prefs.setValueForKey(value, key) - if (isSurge) return $persistentStore.write(value, key) - } - const read = (key) => { - if (isQuanX) return $prefs.valueForKey(key) - if (isSurge) return $persistentStore.read(key) - } - const post = (options, callback) => { - if (isQuanX) { - if (typeof options == "string") options = { url: options } - options["method"] = "POST" - $task.fetch(options).then(response => { - response["status"] = response.statusCode - callback(null, response, response.body) - }, reason => callback(reason.error, null, null)) - } - if (isSurge) $httpClient.post(options, callback) - } - const end = () => { - if (isQuanX) return $done({}) - if (isSurge) isRequest ? $done({}) : $done() - } - return { isRequest, isQuanX, isSurge, notify, write, read, post, end } -}; \ No newline at end of file +//Bark APP notify +async function BarkNotify(c,k,t,b){for(let i=0;i<3;i++){console.log(`🔷Bark notify >> Start push (${i+1})`);const s=await new Promise((n)=>{c.post({url:'https://api.day.app/push',headers:{'Content-Type':'application/json'},body:JSON.stringify({title:t,body:b,device_key:k,ext_params:{group:t}})},(e,r,d)=>r&&r.status==200?n(1):n(d||e))});if(s===1){console.log('✅Push success!');break}else{console.log(`❌Push failed! >> ${s.message||s}`)}}}; + +// https://github.com/chavyleung/scripts/blob/master/Env.min.js +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)} \ No newline at end of file diff --git a/JD-DailyBonus/JD_DailyBonus.js b/JD-DailyBonus/JD_DailyBonus.js index b47a93b63f..05386ea125 100644 --- a/JD-DailyBonus/JD_DailyBonus.js +++ b/JD-DailyBonus/JD_DailyBonus.js @@ -2,7 +2,7 @@ 京东多合一签到脚本 -更新时间: 2021.08.26 21:20 v2.1.2 +更新时间: 2021.09.09 20:20 v2.1.3 有效接口: 20+ 脚本兼容: QuantumultX, Surge, Loon, JSBox, Node.js 电报频道: @NobyDa @@ -167,7 +167,7 @@ async function all(cookie, jrBody) { JDUserSignPre(stop, 'JDStory', '京东失眠-补贴', 'UcyW9Znv3xeyixW1gofhW2DAoz4'), //失眠补贴 JDUserSignPre(stop, 'JDPhone', '京东手机-小时', '4Vh5ybVr98nfJgros5GwvXbmTUpg'), //手机小时达 JDUserSignPre(stop, 'JDEsports', '京东商城-电竞', 'CHdHQhA5AYDXXQN9FLt3QUAPRsB'), //京东电竞 - // JDUserSignPre(stop, 'JDClothing', '京东商城-服饰', '4RBT3H9jmgYg1k2kBnHF8NAHm7m8'), //京东服饰 + JDUserSignPre(stop, 'JDClothing', '京东商城-服饰', '4RBT3H9jmgYg1k2kBnHF8NAHm7m8'), //京东服饰 JDUserSignPre(stop, 'JDSuitcase', '京东商城-箱包', 'ZrH7gGAcEkY2gH8wXqyAPoQgk6t'), //京东箱包馆 JDUserSignPre(stop, 'JDSchool', '京东商城-校园', '2QUxWHx5BSCNtnBDjtt5gZTq7zdZ'), //京东校园 JDUserSignPre(stop, 'JDHealth', '京东商城-健康', 'w2oeK5yLdHqHvwef7SMMy4PL8LF'), //京东健康 @@ -207,7 +207,7 @@ async function all(cookie, jrBody) { await JDUserSignPre(Wait(stop), 'JDEsports', '京东商城-电竞', 'CHdHQhA5AYDXXQN9FLt3QUAPRsB'); //京东电竞 // await JDUserSignPre(Wait(stop), 'JDCustomized', '京东商城-定制', '2BJK5RBdvc3hdddZDS1Svd5Esj3R'); //京东定制 await JDUserSignPre(Wait(stop), 'JDSuitcase', '京东商城-箱包', 'ZrH7gGAcEkY2gH8wXqyAPoQgk6t'); //京东箱包馆 - // await JDUserSignPre(Wait(stop), 'JDClothing', '京东商城-服饰', '4RBT3H9jmgYg1k2kBnHF8NAHm7m8'); //京东服饰 + await JDUserSignPre(Wait(stop), 'JDClothing', '京东商城-服饰', '4RBT3H9jmgYg1k2kBnHF8NAHm7m8'); //京东服饰 await JDUserSignPre(Wait(stop), 'JDSchool', '京东商城-校园', '2QUxWHx5BSCNtnBDjtt5gZTq7zdZ'); //京东校园 await JDUserSignPre(Wait(stop), 'JDHealth', '京东商城-健康', 'w2oeK5yLdHqHvwef7SMMy4PL8LF'); //京东健康 await JDUserSignPre(Wait(stop), 'JDShoes', '京东商城-鞋靴', '4RXyb1W4Y986LJW8ToqMK14BdTD'); //京东鞋靴 @@ -413,54 +413,57 @@ function JingDongBean(s) { }); } -function JingDongTurn(s) { - merge.JDTurn = {}, merge.JDTurn.notify = "", merge.JDTurn.success = 0, merge.JDTurn.bean = 0; - return new Promise((resolve, reject) => { - if (disable("JDTurn")) return reject() - const JDTUrl = { - url: 'https://api.m.jd.com/client.action?functionId=wheelSurfIndex&body=%7B%22actId%22%3A%22jgpqtzjhvaoym%22%2C%22appSource%22%3A%22jdhome%22%7D&appid=ld', - headers: { - Cookie: KEY, - } - }; - $nobyda.get(JDTUrl, async function(error, response, data) { - try { - if (error) { - throw new Error(error) - } else { - const cc = JSON.parse(data).data.lotteryCode - const Details = LogDetails ? "response:\n" + data : ''; - if (cc) { - console.log("\n" + "京东商城-转盘查询成功 " + Details) - return resolve(cc) - } else { - merge.JDTurn.notify = "京东商城-转盘: 失败, 原因: 查询错误 ⚠️" - merge.JDTurn.fail = 1 - console.log("\n" + "京东商城-转盘查询失败 " + Details) - } - } - } catch (eor) { - $nobyda.AnError("京东转盘-查询", "JDTurn", eor, response, data) - } finally { - reject() - } - }) - if (out) setTimeout(reject, out + s) - }).then(data => { - return JingDongTurnSign(s, data); - }, () => {}); -} +// function JingDongTurn(s) { +// merge.JDTurn = {}, merge.JDTurn.notify = "", merge.JDTurn.success = 0, merge.JDTurn.bean = 0; +// return new Promise((resolve, reject) => { +// if (disable("JDTurn")) return reject() +// const JDTUrl = { +// url: 'https://api.m.jd.com/client.action?functionId=wheelSurfIndex&body=%7B%22actId%22%3A%22jgpqtzjhvaoym%22%2C%22appSource%22%3A%22jdhome%22%7D&appid=ld', +// headers: { +// Cookie: KEY, +// } +// }; +// $nobyda.get(JDTUrl, async function(error, response, data) { +// try { +// if (error) { +// throw new Error(error) +// } else { +// const cc = JSON.parse(data) +// const Details = LogDetails ? "response:\n" + data : ''; +// if (cc.data && cc.data.lotteryCode) { +// console.log("\n" + "京东商城-转盘查询成功 " + Details) +// return resolve(cc.data.lotteryCode) +// } else { +// merge.JDTurn.notify = "京东商城-转盘: 失败, 原因: 查询错误 ⚠️" +// merge.JDTurn.fail = 1 +// console.log("\n" + "京东商城-转盘查询失败 " + Details) +// } +// } +// } catch (eor) { +// $nobyda.AnError("京东转盘-查询", "JDTurn", eor, response, data) +// } finally { +// reject() +// } +// }) +// if (out) setTimeout(reject, out + s) +// }).then(data => { +// return JingDongTurnSign(s, data); +// }, () => {}); +// } -function JingDongTurnSign(s, code) { +function JingDongTurn(s) { + if (!merge.JDTurn) merge.JDTurn = {}, merge.JDTurn.notify = "", merge.JDTurn.success = 0, merge.JDTurn.bean = 0; return new Promise(resolve => { + if (disable("JDTurn")) return resolve(); setTimeout(() => { const JDTUrl = { - url: `https://api.m.jd.com/client.action?functionId=lotteryDraw&body=%7B%22actId%22%3A%22jgpqtzjhvaoym%22%2C%22appSource%22%3A%22jdhome%22%2C%22lotteryCode%22%3A%22${code}%22%7D&appid=ld`, + url: `https://api.m.jd.com/client.action?functionId=babelGetLottery`, headers: { - Cookie: KEY, - } + Cookie: KEY + }, + body: 'body=%7B%22enAwardK%22%3A%2295d235f2a09578c6613a1a029b26d12d%22%2C%22riskParam%22%3A%7B%7D%7D&client=wh5' }; - $nobyda.get(JDTUrl, async function(error, response, data) { + $nobyda.post(JDTUrl, async function(error, response, data) { try { if (error) { throw new Error(error) @@ -475,24 +478,24 @@ function JingDongTurnSign(s, code) { } else if (data.match(/(\"T216\"|活动结束)/)) { merge.JDTurn.notify = "京东商城-转盘: 失败, 原因: 活动结束 ⚠️" merge.JDTurn.fail = 1 - } else if (data.match(/(京豆|\"910582\")/)) { + } else if (data.match(/\d+京豆/)) { console.log("\n" + "京东商城-转盘签到成功 " + Details) - merge.JDTurn.bean += Number(cc.data.prizeSendNumber) || 0 - merge.JDTurn.notify += `${also?`\n`:``}京东商城-转盘: ${also?`多次`:`成功`}, 明细: ${cc.data.prizeSendNumber||`无`}京豆 🐶` + merge.JDTurn.bean += (cc.prizeName && cc.prizeName.split(/(\d+)/)[1]) || 0 + merge.JDTurn.notify += `${also?`\n`:``}京东商城-转盘: ${also?`多次`:`成功`}, 明细: ${merge.JDTurn.bean||`无`}京豆 🐶` merge.JDTurn.success += 1 - if (cc.data.chances != "0") { - await JingDongTurnSign(2000, code) + if (cc.chances > 0) { + await JingDongTurnSign(2000) } - } else if (data.match(/未中奖/)) { + } else if (data.match(/未中奖|擦肩而过/)) { merge.JDTurn.notify += `${also?`\n`:``}京东商城-转盘: ${also?`多次`:`成功`}, 状态: 未中奖 🐶` merge.JDTurn.success += 1 - if (cc.data.chances != "0") { - await JingDongTurnSign(2000, code) + if (cc.chances > 0) { + await JingDongTurnSign(2000) } } else { console.log("\n" + "京东商城-转盘签到失败 " + Details) merge.JDTurn.fail = 1 - if (data.match(/(T215|次数为0)/)) { + if (data.match(/(机会已用完|次数为0)/)) { merge.JDTurn.notify = "京东商城-转盘: 失败, 原因: 已转过 ⚠️" } else if (data.match(/(T210|密码)/)) { merge.JDTurn.notify = "京东商城-转盘: 失败, 原因: 无支付密码 ⚠️" @@ -826,6 +829,7 @@ function JDUserSign1(s, key, title, body) { } async function JDUserSign2(s, key, title, tid) { + return console.log(`\n${title} >> 可能需要拼图验证, 跳过签到 ⚠️`); await new Promise(resolve => { $nobyda.get({ url: `https://jdjoy.jd.com/api/turncard/channel/detail?turnTableId=${tid}&invokeKey=ztmFUCxcPMNyUq0P`, @@ -1398,7 +1402,7 @@ function JDSecKilling(s) { //领券中心 if (error) throw new Error(error); const Details = LogDetails ? "response:\n" + data : ''; const cc = JSON.parse(data); - if (cc.msg == 'success' && cc.subCode == 0) { + if (cc.code == 0 && cc.subCode == 0) { console.log(`\n京东秒杀-红包签到成功 ${Details}`); const qt = data.match(/"discount":(\d.*?),/); merge.JDSecKill.success = 1; diff --git a/KuaiKan-DailyBonus/KKMH.js b/KuaiKan-DailyBonus/KKMH.js index 3e5753902a..8b60c637a7 100644 --- a/KuaiKan-DailyBonus/KKMH.js +++ b/KuaiKan-DailyBonus/KKMH.js @@ -1,7 +1,7 @@ /* 快看漫画签到脚本 -更新时间: 2020.9.14 +更新时间: 2021.9.22 脚本兼容: QuantumultX, Surge4, Loon, Node.js 电报频道: @NobyDa 问题反馈: @NobyDa_bot @@ -19,6 +19,8 @@ Node.js用户抓取Cookie说明: var cookie = '' +var barkKey = ''; //Bark APP 通知推送key + /********************* QuantumultX 远程脚本配置: ********************** @@ -104,21 +106,26 @@ function Checkin() { const uid = $.getdata("@KKMH.COOKIE") ? $.getdata("@KKMH.COOKIE").match(/uid=(\d+)/) : '' const rep = $.getdata("@KKMH.DATE") == date.getDate() && (uid ? uid[1] : '') == $.getdata("@KKMH.UID") const gift = await GiftPack(title); - $.msg($.name, rep ? '今天已签过!' : pop, `${rep?``:text+', '}现有${$.score||score}积分, ${$.kkb||kkb}KK币\n${gift||title} 🎉`, imgUrl) + $.subtitle = rep ? '今天已签过!' : pop; + $.msgBody = `${rep?``:text+', '}现有${$.score||score}积分, ${$.kkb||kkb}KK币\n${gift||title} 🎉`; $.setdata(JSON.stringify(date.getDate()), "@KKMH.DATE") $.setdata(uid ? uid[1] : '', "@KKMH.UID") } else { $.log(`${$.name} 失败${Details}`) if (cc.code == 401) { - $.msg($.name, '', 'Cookie失效 ⚠️', imgUrl) + $.msgBody = 'Cookie失效 ⚠️'; } else { - $.msg($.name, '', cc.message || '未知错误 ⚠️', imgUrl) + $.msgBody = cc.message || '未知错误 ⚠️'; } } } catch (err) { $.logErr(err) - $.msg($.name, '', `错误, 已输出日志 ⚠️`, imgUrl) + $.msgBody = `错误, 已输出日志 ⚠️`; } finally { + $.msg($.name, $.subtitle || '', $.msgBody, imgUrl); + if (barkKey) { + await BarkNotify($, barkKey, $.name, $.msgBody); + } resolve() } }) @@ -188,5 +195,9 @@ function GetCookie() { $.log(`${$.name}-请求不含Cookie, 跳过写入 ‼️`) } } + +//Bark APP notify +async function BarkNotify(c,k,t,b){for(let i=0;i<3;i++){console.log(`🔷Bark notify >> Start push (${i+1})`);const s=await new Promise((n)=>{c.post({url:'https://api.day.app/push',headers:{'Content-Type':'application/json'},body:JSON.stringify({title:t,body:b,device_key:k,ext_params:{group:t}})},(e,r,d)=>r&&r.status==200?n(1):n(d||e))});if(s===1){console.log('✅Push success!');break}else{console.log(`❌Push failed! >> ${s.message||s}`)}}} + //Compatible code from https://github.com/chavyleung/scripts/blob/master/Env.min.js 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)} \ No newline at end of file diff --git a/QuantumultX/Js.conf b/QuantumultX/Js.conf index 86cfe2fa7c..31dba53aba 100644 --- a/QuantumultX/Js.conf +++ b/QuantumultX/Js.conf @@ -92,11 +92,11 @@ https://api.bilibili.com/x/v2/reply/main\?access_key url script-response-body ht https://api.live.bilibili.com/xlive/app-room/v1/index/getInfoByRoom\?access_key url script-response-body https://raw.githubusercontent.com/onewayticket255/Surge-Script/master/surge%20bilibili%20live.js # 京东比价 (yichahucha) -^https?://api\.m\.jd\.com/client\.action\?functionId=(wareBusiness|serverConfig|basicConfig) url script-response-body https://raw.githubusercontent.com/yichahucha/surge/master/jd_price.js +^https?://api\.m\.jd\.com/client\.action\?functionId=(wareBusiness|serverConfig|basicConfig) url script-response-body https://service.2ti.st/QuanX/Script/jd_tb_price/main.js # 淘宝比价 (yichahucha) -^http://.+/amdc/mobileDispatch url script-request-body https://raw.githubusercontent.com/yichahucha/surge/master/tb_price.js -^https?://trade-acs\.m\.taobao\.com/gw/mtop\.taobao\.detail\.getdetail url script-response-body https://raw.githubusercontent.com/yichahucha/surge/master/tb_price.js +^http://.+/amdc/mobileDispatch url script-request-body https://service.2ti.st/QuanX/Script/jd_tb_price/main.js +^https?://trade-acs\.m\.taobao\.com/gw/mtop\.taobao\.detail\.getdetail url script-response-body https://service.2ti.st/QuanX/Script/jd_tb_price/main.js # Netflix评分 (yichahucha) ^https?://ios[-\w]*\.prod\.ftl\.netflix\.com/iosui/user/.+path=%5B%22videos%22%2C%\d+%22%2C%22summary%22%5D url script-request-header https://raw.githubusercontent.com/yichahucha/surge/master/nf_rating.js diff --git a/QuantumultX/Rewrite_lhie1.conf b/QuantumultX/Rewrite_lhie1.conf index bb1ea4d105..39c4c993f1 100644 --- a/QuantumultX/Rewrite_lhie1.conf +++ b/QuantumultX/Rewrite_lhie1.conf @@ -426,7 +426,7 @@ hostname = api.cognitive.microsofttranslator.com,offline.microsofttranslator.com ^https?:\/\/api\.zhihu\.com\/commercial_api\/(launch|real_time) url reject-img ^https?:\/\/(api|www)\.zhihu\.com\/.*?(featured-comment-ad|recommendations|community-ad) url reject-img ^https?:\/\/(api|www)\.zhihu\.com\/(fringe|adx|commercial|ad-style-service|banners|mqtt) url reject-img -^https?:\/\/interface3?\.music\.163\.com/eapi/(ad|abtest|sp|hot|store|mlog|search/(specialkeyword|defaultkeyword|hot)) url reject-img +^https?:\/\/interface3?\.music\.163\.com/eapi/(ad|abtest|sp|hot|store|search/(specialkeyword|defaultkeyword|hot)) url reject-img ^https?:\/\/weibointl\.api\.weibo\.cn\/portal\.php\?a=get_coopen_ads url reject-img ^https?:\/\/yxyapi2\.drcuiyutao\.com\/yxy-api-gateway\/api\/json\/advert\/getsAd url reject-dict ^https?:\/\/capis-clb\.didapinche\.com\/ad\/ url reject-dict diff --git a/Surge/JS/Bili_Auto_Regions.js b/Surge/JS/Bili_Auto_Regions.js index 9720fea4cb..8f5e9f2f74 100644 --- a/Surge/JS/Bili_Auto_Regions.js +++ b/Surge/JS/Bili_Auto_Regions.js @@ -5,7 +5,7 @@ 如需禁用豆瓣评分或策略通知, 可前往BoxJs设置. BoxJs订阅地址: https://raw.githubusercontent.com/NobyDa/Script/master/NobyDa_BoxJs.json -Update: 2021.06.17 +Update: 2021.09.26 Author: @NobyDa Use: Surge, QuanX, Loon @@ -144,7 +144,10 @@ async function QueryRating(body, play) { GetRawInfo(play.origin_name) ]); const exYear = body.data.publish.release_date_show.split(/^(\d{4})/)[1]; - const filterInfo = [play.title, play.origin_name, play.staff.info + play.actor.info, exYear]; + const info1 = (play.staff && play.staff.info) || ''; + const info2 = (play.actor && play.actor.info) || ''; + const info3 = (play.celebrity && play.celebrity.map(n => n.name).join('/')) || ''; + const filterInfo = [play.title, play.origin_name, info1 + info2 + info3, exYear]; const [rating, folk, name, id, other] = ExtractMovieInfo([...t1, ...t2], filterInfo); const limit = JSON.stringify(body.data.modules) .replace(/"\u53d7\u9650"/g, `""`).replace(/("area_limit":)1/g, '$10'); diff --git a/Surge/Module/RewriteRules.sgmodule b/Surge/Module/RewriteRules.sgmodule index 779fe92956..007fd72872 100644 --- a/Surge/Module/RewriteRules.sgmodule +++ b/Surge/Module/RewriteRules.sgmodule @@ -717,7 +717,7 @@ ^https?:\/\/(api|www)\.zhihu\.com\/.*?(featured-comment-ad|recommendations|community-ad) - reject ^https?:\/\/(api|www)\.zhihu\.com\/(fringe|adx|commercial|ad-style-service|banners|mqtt) - reject ^https?:\/\/ap(i|p)\.bilibili\.com\/((x\/v2|pgc)\/(search\/defaultword|season\/rank\/cn|splash\/)|(pgc/season/rank/cn|x/v2/(search/(defaultword|hot|recommend|resource)))) - reject -^https?:\/\/interface3?\.music\.163\.com/eapi/(ad|abtest|sp|hot|store|mlog|search/(specialkeyword|defaultkeyword|hot)) - reject +^https?:\/\/interface3?\.music\.163\.com/eapi/(ad|abtest|sp|hot|store|search/(specialkeyword|defaultkeyword|hot)) - reject ^https?:\/\/capis-slb\.didapinche\.com\/ad\/ - reject ^https?:\/\/weibointl\.api\.weibo\.cn\/portal.php\?a=get_coopen_ads - reject ^https?:\/\/yxyapi2\.drcuiyutao\.com\/yxy-api-gateway\/api\/json\/advert\/getsAd - reject diff --git a/Surge/WeChat.list b/Surge/WeChat.list index 21c8e50458..8e5d724833 100644 --- a/Surge/WeChat.list +++ b/Surge/WeChat.list @@ -48,11 +48,14 @@ DOMAIN-KEYWORD,115.231.229. DOMAIN-KEYWORD,115.238.197. DOMAIN-KEYWORD,116.128.133. DOMAIN-KEYWORD,116.128.163. +DOMAIN-KEYWORD,116.253.60. +DOMAIN-KEYWORD,116.253.61. DOMAIN-KEYWORD,117.184.242. DOMAIN-KEYWORD,117.187.243. DOMAIN-KEYWORD,117.41.224. DOMAIN-KEYWORD,119.147.227. DOMAIN-KEYWORD,119.147.83. +DOMAIN-KEYWORD,119.188.155. DOMAIN-KEYWORD,119.39.81. DOMAIN-KEYWORD,120.232.27. DOMAIN-KEYWORD,120.232.33. @@ -147,6 +150,7 @@ DOMAIN-KEYWORD,203.205.254. DOMAIN-KEYWORD,203.209.245. DOMAIN-KEYWORD,211.95.137. DOMAIN-KEYWORD,211.95.138. +DOMAIN-KEYWORD,218.68.90. DOMAIN-KEYWORD,219.135.59. DOMAIN-KEYWORD,220.194.91. DOMAIN-KEYWORD,220.194.93. @@ -156,8 +160,10 @@ DOMAIN-KEYWORD,223.166.152. DOMAIN-KEYWORD,36.152.4. DOMAIN-KEYWORD,36.155.202. DOMAIN-KEYWORD,36.158.242. +DOMAIN-KEYWORD,36.250.230. DOMAIN-KEYWORD,42.187.131. DOMAIN-KEYWORD,42.202.141. +DOMAIN-KEYWORD,58.144.248. DOMAIN-KEYWORD,58.250.136. DOMAIN-KEYWORD,58.251.100. DOMAIN-KEYWORD,58.251.111. @@ -294,4 +300,5 @@ DOMAIN-SUFFIX,lbs.map.qq.com DOMAIN-SUFFIX,ue.indoorloc.map.qq.com DOMAIN-SUFFIX,apis.map.qq.com -USER-AGENT,WeChat* \ No newline at end of file +USER-AGENT,WeChat* +USER-AGENT,MicroMessenger* \ No newline at end of file diff --git a/iQIYI-DailyBonus/iQIYI.js b/iQIYI-DailyBonus/iQIYI.js index 217b0df9cf..014278b32a 100644 --- a/iQIYI-DailyBonus/iQIYI.js +++ b/iQIYI-DailyBonus/iQIYI.js @@ -1,7 +1,7 @@ /* 爱奇艺会员签到脚本 -更新时间: 2020.9.6 +更新时间: 2021.9.22 脚本兼容: QuantumultX, Surge4, Loon, JsBox, Node.js 电报频道: @NobyDa 问题反馈: @NobyDa_bot @@ -20,6 +20,8 @@ JsBox, Node.js用户抓取Cookie说明: var cookie = '' +var barkKey = ''; //Bark APP 通知推送Key + /********************* QuantumultX 远程脚本配置: ********************** @@ -124,8 +126,8 @@ function Checkin() { if (obj.data.signInfo.code == "A00000") { var AwardName = obj.data.signInfo.data.rewards[0].name; var quantity = obj.data.signInfo.data.rewards[0].value; - var continued = obj.data.signInfo.data.continueSignDaysSum; - $nobyda.data = "签到成功: " + AwardName + quantity + ", 已连签" + continued + "天 🎉" + var continued = obj.data.signInfo.data.cumulateSignDaysSum; + $nobyda.data = "签到成功: " + AwardName + quantity + ", 累计签到" + continued + "天 🎉" console.log(`爱奇艺-${$nobyda.data} ${Details}`) } else { $nobyda.data = "签到失败: " + obj.data.signInfo.msg + " ⚠️" @@ -162,7 +164,7 @@ function Lottery(s) { $nobyda.data += !$nobyda.last ? `\n抽奖成功: ${obj.awardName.replace(/《.+》/, "未中奖")} 🎉` : `\n抽奖失败: 今日已抽奖 ⚠️` console.log(`爱奇艺-抽奖明细: ${obj.awardName.replace(/《.+》/, "未中奖")} 🎉 (${$nobyda.times}) ${Details}`) } else if (data.match(/\"errorReason\"/)) { - msg = data.match(/msg=.+?\)/) ? data.match(/msg=(.+?)\)/)[1].replace(/用户(未登录|不存在)/, "Cookie无效") : "" + const msg = data.match(/msg=.+?\)/) ? data.match(/msg=(.+?)\)/)[1].replace(/用户(未登录|不存在)/, "Cookie无效") : "" $nobyda.data += `\n抽奖失败: ${msg || `未知错误`} ⚠️` console.log(`爱奇艺-抽奖失败: ${msg || `未知错误`} ⚠️ (${$nobyda.times}) ${msg ? Details : `response:\n${data}`}`) } else { @@ -174,7 +176,8 @@ function Lottery(s) { await Lottery(s) } else { const expires = $nobyda.expire ? $nobyda.expire.replace(/\u5230\u671f/, "") : "获取失败 ⚠️" - if (!$nobyda.isNode) $nobyda.notify("爱奇艺", "到期时间: " + expires, $nobyda.data) + if (!$nobyda.isNode) $nobyda.notify("爱奇艺", "到期时间: " + expires, $nobyda.data); + if (barkKey) await BarkNotify($nobyda, barkKey, '爱奇艺', `到期时间: ${expires}\n${$nobyda.data}`); } resolve() }) @@ -209,6 +212,8 @@ function GetCookie() { } } +async function BarkNotify(c,k,t,b){for(let i=0;i<3;i++){console.log(`🔷Bark notify >> Start push (${i+1})`);const s=await new Promise((n)=>{c.post({url:'https://api.day.app/push',headers:{'Content-Type':'application/json'},body:JSON.stringify({title:t,body:b,device_key:k,ext_params:{group:t}})},(e,r,d)=>r&&r.status==200?n(1):n(d||e))});if(s===1){console.log('✅Push success!');break}else{console.log(`❌Push failed! >> ${s.message||s}`)}}} + function nobyda() { const times = 0 const start = Date.now() @@ -288,6 +293,42 @@ function nobyda() { $http.get(options); } } + const post = (options, callback) => { + if (isQuanX) { + if (typeof options == "string") options = { + url: options + } + options["method"] = "POST" + $task.fetch(options).then(response => { + callback(null, adapterStatus(response), response.body) + }, reason => callback(reason.error, null, null)) + } + if (isSurge) { + options.headers['X-Surge-Skip-Scripting'] = false + $httpClient.post(options, (error, response, body) => { + callback(error, adapterStatus(response), body) + }) + } + if (isNode) { + node.request.post(options, (error, response, body) => { + callback(error, adapterStatus(response), body) + }) + } + if (isJSBox) { + if (typeof options == "string") options = { + url: options + } + options["header"] = options["headers"] + options["handler"] = function(resp) { + let error = resp.error; + if (error) error = JSON.stringify(resp.error) + let body = resp.data; + if (typeof body == "object") body = JSON.stringify(resp.data) + callback(error, adapterStatus(resp.response), body) + } + $http.post(options); + } + } const log = (message) => console.log(message) const time = () => { @@ -305,6 +346,7 @@ function nobyda() { write, read, get, + post, log, time, times,