faker3/jd_XinFarm_task.js

21 lines
99 KiB
JavaScript
Raw Normal View History

2024-07-15 14:28:01 +08:00
/*
新东东农场任务
种植任务浇水
环境变量
jd_XinFarm_plantSkuId // 需要种植的作物ID详见脚本打印
jd_XinFarm_autoPlant // 种植模式 默认自动种植,自动随机种植等级价值最高的物品
jd_XinFarm_waternum // 浇水次数,默认 10次 自行修改
jd_XinFarm_retainWater // 快速浇水,默认不开启(有水滴门槛,满足要求后开启才会生效)
jd_XinFarm_Notify // 是否推送通知true/false默认不推送
cron:45 2-22/6 * * *
*/
const $ = new Env('新东东农场任务')
const _0x288322=_0x3c3a;(function(_0x23e04f,_0xdb4cee){const _0x2d746e=_0x3c3a,_0x31cd32=_0x23e04f();while(!![]){try{const _0x29d4d3=parseInt(_0x2d746e(0x337,'x28Z'))/0x1+parseInt(_0x2d746e(0x238,'AsSr'))/0x2+parseInt(_0x2d746e(0x40e,'uM4w'))/0x3*(parseInt(_0x2d746e(0x15c,'k%da'))/0x4)+parseInt(_0x2d746e(0x4cc,'l&P('))/0x5+-parseInt(_0x2d746e(0x2a6,'PBEL'))/0x6+-parseInt(_0x2d746e(0x3bf,'PBEL'))/0x7+parseInt(_0x2d746e(0x1a0,'l1#7'))/0x8*(-parseInt(_0x2d746e(0x452,'PBEL'))/0x9);if(_0x29d4d3===_0xdb4cee)break;else _0x31cd32['push'](_0x31cd32['shift']());}catch(_0x3a8ff4){_0x31cd32['push'](_0x31cd32['shift']());}}}(_0x407d,0xd8f17));const jdCookie=require(_0x288322(0x291,')nJ9')),notify=require('./utils/Rebels_sendJDNotify'),common=require(_0x288322(0x23b,'k%da')),{H5st}=require(_0x288322(0x374,'&G7x')),CryptoJS=require(_0x288322(0x367,'AsSr')),querystring=require(_0x288322(0x33d,'kxBi')),autoPlant=!(process[_0x288322(0x27a,'&G7x')][_0x288322(0x4b8,'6ib$')]===_0x288322(0x431,'i0#1')),waternum=process[_0x288322(0x257,'dZ@a')][_0x288322(0x3ff,')nJ9')]||'10',plantSkuId=process['env']['jd_XinFarm_plantSkuId']||'',retainWater=process['env'][_0x288322(0x153,'YJCd')]==='true',isNotify=process[_0x288322(0x523,'R08p')][_0x288322(0x3af,'VMLp')]===_0x288322(0x1d5,'R08p'),sign_linkId=_0x288322(0x2e6,'F536'),draw_linkId=_0x288322(0x396,'l&P('),award_map={0x1:'水滴',0x2:'水滴'};let cookie='';const cookiesArr=Object[_0x288322(0x245,'#7D@')](jdCookie)[_0x288322(0x293,'S*bs')](_0x242a25=>jdCookie[_0x242a25])['filter'](_0x2cdd82=>_0x2cdd82);!cookiesArr[0x0]&&($[_0x288322(0x1d9,'Z8IJ')]($['name'],_0x288322(0x510,'k%da')),process[_0x288322(0x339,'l1#7')](0x1));!(async()=>{const _0x5ec11c=_0x288322;console[_0x5ec11c(0x4f8,'F536')]('=========='+$[_0x5ec11c(0x2bb,'NQBs')]+_0x5ec11c(0x371,'uC@B')),console[_0x5ec11c(0x25c,'Zn4O')](_0x5ec11c(0x34f,'$(p&')),console['log'](_0x5ec11c(0x1da,'pL*Z')+(autoPlant?'自动':'手动')+']'),console['log'](_0x5ec11c(0x182,'r2VN')+waternum+_0x5ec11c(0x42c,'0(uK')+(retainWater?'开启':'关闭')+']'),console[_0x5ec11c(0x46e,'&G7x')](_0x5ec11c(0x26d,'UOyN')+common[_0x5ec11c(0x15f,'PBEL')]()+']'),console[_0x5ec11c(0x408,'pC&c')](_0x5ec11c(0x2d0,'x56c')+(isNotify?'开启':'关闭')+']'),console[_0x5ec11c(0x1d0,'kxBi')]('=========='+$[_0x5ec11c(0x45f,'8W0o')]+_0x5ec11c(0x447,'$(p&')),console[_0x5ec11c(0x565,'YJCd')](''),notify[_0x5ec11c(0x26a,'P1aa')]({'title':$[_0x5ec11c(0x43d,'#7D@')]});for(let _0x2f7e3d=0x0;_0x2f7e3d<cookiesArr['length'];_0x2f7e3d++){$[_0x5ec11c(0x54f,'AsSr')]=_0x2f7e3d+0x1,cookie=cookiesArr[_0x2f7e3d],common[_0x5ec11c(0x1d4,'kxBi')](cookie),$[_0x5ec11c(0x36f,'uC@B')]=decodeURIComponent(common['getCookieValue'](cookie,_0x5ec11c(0x2d4,'Izb9'))),$['UA']=common[_0x5ec11c(0x34a,'$#As')]($[_0x5ec11c(0x20b,'&56n')]),$[_0x5ec11c(0x343,'#7D@')]=common['genUuid'](_0x5ec11c(0x2d8,'NQBs')),$['message']=notify[_0x5ec11c(0x4b5,'p!p1')]($[_0x5ec11c(0x281,'HBZk')],$['UserName']),$['nickName']='',console['log']('\x0a******开始【京东账号'+$['index']+'】'+($['nickName']||$['UserName'])+_0x5ec11c(0x28b,'pC&c')),await Main(),common[_0x5ec11c(0x543,'VMLp')]();if($[_0x5ec11c(0x2b6,'uC@B')])break;await $[_0x5ec11c(0x1f4,'#7D@')](parseInt(Math[_0x5ec11c(0x29d,'HBZk')]()*0x3e8+0x3e8,0xa));}const _0x209121=notify[_0x5ec11c(0x56f,'dZ@a')]();_0x209121&&(console['log']('\x0a📣\x20运行结果\x0a'+_0x209121['replace'](//g,'\x20➜\x20')),isNotify&&(notify[_0x5ec11c(0x4b0,'pC&c')]('\x0a'),await notify[_0x5ec11c(0x36c,'vFO1')]()));})()[_0x288322(0x574,'uC@B')](_0x140eb4=>$[_0x288322(0x498,'tnBq')](_0x140eb4))[_0x288322(0x516,'uC@B')](()=>$[_0x288322(0x16b,'p!p1')]());async function Main(){const _0x5e7d11=_0x288322;$[_0x5e7d11(0x428,'vFO1')]=!![],$[_0x5e7d11(0x49b,'^Zrm')]=![],$['fp']='';try{const _0x5ab75a=await common[_0x5e7d11(0x24f,'l&P(')](cookie);if(!_0x5ab75a&&typeof _0x5ab75a===_0x5e7d11(0x35a,'^Zrm')){console[_0x5e7d11(0x3fc,'6ib$')](_0x5e7d11(0x37c,'&56n')),$[_0x5e7d11(0x3fb,'AsSr')]['fix'](_0x5e7d11(0x522,'HOEs'));return;}$['farm_home']='',await sendRequest(_0x5e7d11(0x2ea,'HOEs')),await $['wait'](par
// 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.d