jd_scripts/jd_redPacket.js

103 lines
80 KiB
JavaScript
Raw Normal View History

2020-11-10 09:29:58 +08:00
/*
2021-01-16 17:10:19 +08:00
* @Author: LXK9301
2020-11-10 09:29:58 +08:00
* @Date: 2020-11-03 18:12:38
2021-01-16 17:10:19 +08:00
* @Last Modified by: LXK9301
2021-03-30 18:08:53 +08:00
* @Last Modified time: 2021-03-30 18:27:18
2020-11-10 09:29:58 +08:00
*/
/*
京东全民开红包
2021-01-27 18:46:56 +08:00
活动入口京东APP首页-领券-锦鲤红包
2020-11-10 09:29:58 +08:00
已完成功能
①浏览活动
②关注频道
③领取红包
未实现功能
2021-03-30 18:08:53 +08:00
领3张券功能
2020-11-10 09:29:58 +08:00
支持京东双账号
脚本兼容: QuantumultX, Surge, Loon, JSBox, Node.js
2021-01-21 13:58:50 +08:00
================QuantumultX==================
2020-11-10 09:29:58 +08:00
[task_local]
#京东全民开红包
2021-03-30 18:08:53 +08:00
1 1,2,23 * * * https://gitee.com/lxk0301/jd_scripts/raw/master/jd_redPacket.js, tag=京东全民开红包, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jd_redPacket.png, enabled=true
2021-01-21 13:58:50 +08:00
===================Loon==============
2020-11-10 09:29:58 +08:00
[Script]
2021-03-30 18:08:53 +08:00
cron "1 1,2,23 * * *" script-path=https://gitee.com/lxk0301/jd_scripts/raw/master/jd_redPacket.js, tag=京东全民开红包
2021-01-21 13:58:50 +08:00
===============Surge===============
[Script]
2021-03-30 18:08:53 +08:00
京东全民开红包 = type=cron,cronexp=1 1,2,23 * * *,wake-system=1,timeout=3600,script-path=https://gitee.com/lxk0301/jd_scripts/raw/master/jd_redPacket.js
====================================小火箭=============================
京东全民开红包 = type=cron,script-path=https://gitee.com/lxk0301/jd_scripts/raw/master/jd_redPacket.js, cronexpr="1 1,2,23 * * *", timeout=3600, enable=true
2020-11-10 09:29:58 +08:00
*/
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 = '';
2021-03-31 09:52:22 +08:00
$.redPacketId = [];
2020-11-10 09:29:58 +08:00
2021-03-31 09:52:22 +08:00
var _0xodD='jsjiami.com.v6',_0x17e2=[_0xodD,'d8OtwpPCpg==','w7I3fEnChcOwCMOU','bFvDl1zDnA==','BsO8w6fDkcOK','wrd5NTDCvQ==','w6RDaMKcw6I=','fcOzb17DhQ==','w7LDucKELVs=','w5vCl8KlPcOT','Jhhfw5DCrw==','GsKzw7bCsQ==','w6XDp8OEIsKo','w7nCn8KJGsOU','w7Yxw7jCvMOq','I8K0w4M=','w5DDncKVKMKu5pyJ6KyM6Ky75rK95aaM6La9w7jig7nvuLHigLPvu5E=','wpHCrUnDisOdwpNsesK3','P8K6w5bDoHc=','PsO9SWk=','T2HCvy/CpA==','LjjDuWk=','QsOvwr9Wwog=','woHDuDvCj14=','OMKPw63Dsnc=','wpLCuEnDkMOW','wowGRno=','VMOFwpHCshM=','GRTDhWXCkA==','NcOm5YyU6LW85Ym45YuY57mo5YyM776P5oiR5Yqv44O257uO5Y+8Q8KydA==','wp7CiAAmMA==','CV56wqnCng==','LmMJZMKn','J2FjwqDCkQ==','UhwbwrcT','W2DDjVDDtQ==','Jm8lfMKEw4XDusKYYMOIXQ==','XkvClcKu','GELCkRLDlA==','KCFuw6nCiA==','5Y+V6LW45Ym85YuH57mn5Y2lfeWko+i2n+++oA==','wpHDiTrCl2HCrsOTM8On','X8O55Y2V6LW+5Yq05YuX57iw5Y6S776v5ouw5Yur44KZ57uD5Y+7w5RgIQ==','Iydsw63CoQ==','wonDlS83w7k=','fMOWwp04UA==','w6tkwq/DrWM=','w6rCjWFkw4M=','XFnCo8KBcQ==','w6huwoHDsWnCg8Kgw5cEAMOd','O2Zxwow=','dQzDoMOxw5I=','w55SwqbDgEw=','w5zCs2dCw4A=','5Y6D6LS/5YqP5Yi657mo5Y6Zw6Hlp57otK3vvqo=','wpnCicKmEcKJwovCh8KqwoY=','NmDCjhrDrsKo','w4rCt0NYw4I=','wrwpY2N5','wqUoVll7','wrV5NMKrcw==','wqnCtXQ/wr8=','wps25LqE5Yud5p+85b2Z5Y+m','acOtwozCsAc=','KXp4wrvCtWnDtlU=','NilSw4A=','w5zCsVFww6vChg==','wpbCkxIBGB9KwqU=','44CU5o+f56ev44GN6Kyy5YSo6I+q5Y+E5LiW5Lqm6Lan5Y625LmSwqbCqsO8Zx0Sw4vnmazmj5LkvL3nlYfDiMOBwr7ClMKRw4Tnm7fkuofkuYLnrLLli6Pojb/lj7M=','worDiTzCjnzDs8KVesO8w6HCnsO3DsOAwrbChcO/wpLCt3hHcsKrw7ZUEcKwwp4ywrjDuD5mKMOEw6rCssOoGcO5wqjDjRM=','wqUxGMK2wow=','wozDjyHCp0c=','w4zCsnJMw5I=','HkgndsKK','ScOJF8KIAzhO','L8K7YsOAMg==','TsKuwrHDmgg=','KsO9XmMHwrHDlsKDw7s=','O8KGw49MUg==','S8OYRFzDmA==','w6YZw7bCucOiT8Kxw6Qmck7DucO+','TcKJwrR+wrgxwq9Iw6ZyWcKHGMK3f8Kb','w7Q9QlzCnsO3NMOWwoDDv8KXZsK6wofCpMKdw40pwqLDtMKT','wr8SO8K6wrHCjzE3N8KfwoQeHA==','QsO/wqsYw7s=','NcK/w5zDhko=','FcOZwqwgwrM=','bcO1CsKtEw==','PcOwamos','w4N7R8KRw4N5','wqh3Ehk=','IGUSWMKXw4/Dv8Ka','L3pxwofCuXPDvEQ=','w4HCk0Nmw6Nrbw==','JkkDesKH','w5RPXMKYw4o=','w5jCuVFcw4Q=','FcK4GgzDpw==','wrDDniXCtU0=','wosnahVR','EMKUGS/Dow==','KMOff14A','w6jCjnhjw58=','ScOaOcKYFg==','MT9uw4jCog==','wrIDfSht','SmXCkBXCvQ==','LkJKwpLClw==','wojCkRAHFA==','YsO8wr4/w68=','TcKCwrDDoQ0=','wopfFcK7Vg==','AMOYw6nDuMOK','wp02MMKFwp0=','w5NZUsKXw5c=','w7ZuwrLDsVw=','wqYNd1JC','CDPDqm/Cqg==','w4c9w77Cn8Ov','OFgqeMKo','EMKmTcORPg==','w4fDosO9BMKc','wp7DnwQkw68=','w5bDo8KMDHg=','U8OIEcKnIw==','wpHCuw8kFQ==','LcO8wro2wrA=','w4lqTsKpw7E=','wqRZNx/Csw==','GmAEZcKd','w5VAwoLDhUY=','w6QXZ17Ckg==','wpLDkjvCig==','KcKiVcOfKQ==','wo3CpHIDwpc=','DkMWdcKV','ecOIwrUQfw==','wonDmzkAw5o=','SnfClsKVUQ==','BsOaw7HDjcOr','woIefRJm','B8Ogwrktwq8=','McOBw5/DisOw','wrZmw4bClg==','w609w4QIAOaen+isoeiskOaytOWlvei3oUjig77vuKfigK3vu6E=','JjbDqk3Cr8Ox','w4VJT8Kyw7Q=','wqbCr8KlHMKQ','wpoVHcK9wpM=','wrZ3DQ/Csw==','dDAXwps=','w4R7X8Kc','LcOlUGcK','wpTCq2zDssO/','wr7Drjw7w7o=','Y8Oowrcjw48=','wqjCszY7Bw==','w57Dv8OaBcKC','w77DucKBw4rDqw==','woE/JcKHwq8=','GyzDnVvCuQ==','w7lqWcK5w7Q=','dDgQwpk0JCc9','w4PCpsKJHsOe','JGszX8KA','wrnCvXQy','EzJRw4/CmQ==','wod3NcKccQ==','YsOewr8=','5ouI57iT5Y+d6I+I5b6A7766','w7/Dq8O5PMKD','SAXDhsOLw5M=','wp9Pw6/Cv2Q=','6aCc57qp5Y+g5aaQ6LSt77+6','GcKow7fCrAPCkcOJw5F9','w75iwpbDgmfClcKlw4Y=','w5zDvMKCw7nDqMKywqhn','wobClScLDw9A','w4HDp8OEJcKacT4=','YmbCuSjCoBI=','wr3DrQ89w5jCmWVDLGjCjD/CsUo=','FcKQb8OyLMOI','IngWfcKp','wo7CnMKgGQ==','BcKLw7ZZUA==','UMOAwonCijM=','w5HDusKgOWc=','w7rDgcKRKl4=','Uxclwo0y','QlHCgQ==','5oqc57qt5Y+s6I+o5byL77+A','J8KvBRDDqQ==','bW/DqW7DnQ==','ZkHDgVTDvQ==','w75qwpHDgA==','ZsKlYW0G','Sl/CksKn','woh/w5nCo2M=','I8K8VsOMKA==','DsKMbMO6MA==','PMKhS8OZKg==','XFvCgsKWV8OzCxDDucOUYA==','YCQQwpI=','QRnlvZHliqnlvZPmi4DnuLDljLXCimEL','Z8KiwqrDjB8=','wpXDhCXCkWc=','w4MMZXHChQ==','77+B6L2X5buK772M5YSw6YGt','w7TCnXVcw7c=','w61ywojDjmA=','McK0Q8ObAA==','5LiL5aW05Y2O77yU5b63562a','wrkcHcKJwr0=','wqXDrR8Zw43CiEg=','5LmT57mX5YyE44KX5byL5Yut5bWA5oiX57uc5Y+E77+s','J8K6w5fDnGIvwqs=','5LuC772r5Ymb5L2C','YcOlN8KwAQ==','w5nCrU9qw68=','wqhmE8KeVg==','5Lik57iT5Y+d5b+65byXwqoZ','SsODwrAXw7g=','wp3ChMK5F8KP','wpjCiEofwqg=','b3PDr1DDlA==','dcOjwpk=',
2020-11-10 09:29:58 +08:00
2020-11-10 09:29:58 +08:00
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")
2020-11-10 09:29:58 +08:00
}
}
$.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
}
2020-11-10 09:29:58 +08:00
} 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 [];
}
}
}
2020-11-10 09:29:58 +08:00
// prettier-ignore
2021-01-20 11:35:26 +08:00
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"])