KR/jd_fruit_task.js

43 lines
146 KiB
JavaScript
Raw Normal View History

2023-07-27 16:14:01 +08:00
/*
东东水果:脚本更新地址 jd_fruit_task.js
更新时间2021-5-18
活动入口京东APP我的-更多工具-东东农场
==========================Quantumultx=========================
[task_local]
2023-08-25 03:43:26 +08:00
#东东农场日常任务
2023-07-27 16:14:01 +08:00
5 6-18/6 * * * jd_fruit_task.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_task.js,tag=东东农场日常任务
=========================Surge============================
东东农场日常任务 = type=cron,cronexp="5 6-18/6 * * *",wake-system=1,timeout=3600,script-path=jd_fruit_task.js
=========================小火箭===========================
东东农场日常任务 = type=cron,script-path=jd_fruit_task.js, cronexpr="5 6-18/6 * * *", timeout=3600, enable=true
2023-10-31 01:41:38 +08:00
默认浇水,不浇水设置变量 export jd_fruit_Water="true"
默认在完成每日任务后再次浇水若保留水滴请设置变量 export DO_TEN_WATER_AGAIN="false"
2023-08-25 23:03:50 +08:00
2023-07-27 16:14:01 +08:00
*/
2023-10-31 01:41:38 +08:00
const $ = new Env('东东农场日常任务')
2023-08-25 23:03:50 +08:00
let cookiesArr = [],
cookie = '',
jdFruitShareArr = [],
isBox = false,
notify,
newShareCodes,
2023-10-31 01:41:38 +08:00
allMessage = ''
let shareCodes = []
2023-08-25 23:03:50 +08:00
let message = '',
subTitle = '',
option = {},
2023-10-31 01:41:38 +08:00
isFruitFinished = false
const retainWater = $.isNode() ? (process.env.retainWater ? process.env.retainWater : 100) : $.getdata('retainWater') ? $.getdata('retainWater') : 100 //保留水滴大于多少g,默认100g;
let jdNotify = true //是否关闭通知false打开通知推送true关闭通知推送
let jdFruitBeanCard = false //农场使用水滴换豆卡(如果出现限时活动时100g水换20豆,此时比浇水划算,推荐换豆),true表示换豆(不浇水),false表示不换豆(继续浇水),脚本默认是浇水
let randomCount = $.isNode() ? 20 : 5
2023-10-31 15:06:14 +08:00
var version_='jsjiami.com.v7';const lIiI11=iii1II;(function(iilii1,llilil,il1lii,illi1i,lll1ll,illi1l,l1llI){return iilii1=iilii1>>0x2,illi1l='hs',l1llI='hs',function(llilii,lll1li,l1ii1l,l111ll,l1liIi){const Il1li=iii1II;l111ll='tfi',illi1l=l111ll+illi1l,l1liIi='up',l1llI+=l1liIi,illi1l=l1ii1l(illi1l),l1llI=l1ii1l(l1llI),l1ii1l=0x0;const I11Ii1=llilii();while(!![]&&--illi1i+lll1li){try{l111ll=parseInt(Il1li(0x447,'$4@M'))/0x1+parseInt(Il1li(0x156,'4TSJ'))/0x2*(parseInt(Il1li(0x69d,'66rb'))/0x3)+-parseInt(Il1li(0x66b,'R%W4'))/0x4+parseInt(Il1li(0x4eb,'^Kp9'))/0x5+-parseInt(Il1li(0x62d,'!EVL'))/0x6*(-parseInt(Il1li(0x492,'ym#2'))/0x7)+-parseInt(Il1li(0x505,'FiUh'))/0x8*(parseInt(Il1li(0x2d8,'g9)i'))/0x9)+parseInt(Il1li(0x7b3,'*KOI'))/0xa*(parseInt(Il1li(0x231,'FRiS'))/0xb);}catch(l1liIl){l111ll=l1ii1l;}finally{l1liIi=I11Ii1[illi1l]();if(iilii1<=illi1i)l1ii1l?lll1ll?l111ll=l1liIi:lll1ll=l1liIi:l1ii1l=l1liIi;else{if(l1ii1l==lll1ll['replace'](/[GbVURKepFYAgwhqdLM=]/g,'')){if(l111ll===lll1li){I11Ii1['un'+illi1l](l1liIi);break;}I11Ii1[l1llI](l1liIi);}}}}}(il1lii,llilil,function(l111li,Il1ll,Iilil,Iilii,I1il1,IiIlIl,iiliiI){return Il1ll='\x73\x70\x6c\x69\x74',l111li=arguments[0x0],l111li=l111li[Il1ll](''),Iilil=`\x72\x65\x76\x65\x72\x73\x65`,l111li=l111li[Iilil]('\x76'),Iilii=`\x6a\x6f\x69\x6e`,(0x145390,l111li[Iilii](''));});}(0x31c,0x9c6a0,Iii11l,0xc9),Iii11l)&&(version_=lIiI11(0x17d,'RU[N'));let l1II1=process['env']['jd_fruit_Water']===lIiI11(0x7a3,'R%W4')?!![]:![];const III1i1=lIiI11(0x40c,'K^(R'),IlI1='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',I1IlIl=require(lIiI11(0x4fa,'%nva')),l1I1i1=require(lIiI11(0x277,'QQQ*')),I1IlIi=require(lIiI11(0x787,'FiUh'));let l1ll1i=iiIi(0x28),IiIil1=iiIi(0xa,'123456789'),i111l=iiIi(0x20,lIiI11(0x735,'bO*m')),lIiIlI=iiIi(0x2,lIiI11(0x373,'paTU'))+'-'+iiIi(0x4,lIiI11(0x367,'*KOI'))+'-'+iiIi(0x4,lIiI11(0x437,'K14W'))+'-'+iiIi(0x5,lIiI11(0x224,'66rb')),iilIlI=lIiI11(0x67b,'U$TU')+Math[lIiI11(0x741,'rTPa')](Math['random']()*0x383+0x64),i111i=lIiI11(0x3aa,'K^(R')+Math[lIiI11(0x2d4,'*KOI')](Math[lIiI11(0x160,'4TSJ')]()*0x383+0x64),lIlli1='',llIii1=0x0;!(async()=>{const li111I=lIiI11,Iil1I={'KjCXD':function(illIIl){return illIIl();},'RAnNq':li111I(0x5cf,'ou58'),'STpPC':'https://bean.m.jd.com/bean/signIndex.action','HvhWQ':function(iiiIlI,I1i11){return iiiIlI<I1i11;},'eztMR':function(Ill1ii,IllII){return Ill1ii!==IllII;},'SykmE':li111I(0x6c1,'R%W4'),'MWLnZ':function(Ill1il,IIlI){return Ill1il*IIlI;},'KjerW':function(I1i1l,llIiIi){return I1i1l===llIiIi;},'PmGGb':'LOrUl','hmLrH':'sddzt'};await Iil1I['KjCXD'](l1iill);if(!cookiesArr[0x0]){$[li111I(0x326,'LIaD')]($[li111I(0x526,'1ir9')],Iil1I['RAnNq'],Iil1I[li111I(0x27a,'HToF')],{'open-url':'https://bean.m.jd.com/bean/signIndex.action'});return;}console['log']('该活动检测运行环境较为严格若多次提示403则建议更换IP运行...');for(let IIil=0x0;Iil1I[li111I(0x572,'MXtD')](IIil,cookiesArr['length']);IIil++){if(cookiesArr[IIil]){cookie=cookiesArr[IIil],$['UserName']=decodeURIComponent(cookie['match'](/pt_pin=([^; ]+)(?=;?)/)&&cookie['match'](/pt_pin=([^; ]+)(?=;?)/)[0x1]),$[li111I(0x773,'0LZX')]=IIil+0x1,$[li111I(0x2e8,'bO*m')]=!![],$[li111I(0x378,'ou58')]='',console['log'](li111I(0x1a6,'K^(R')+$['index']+'】'+($[li111I(0x378,'ou58')]||$['UserName'])+'\x0a');if(!$[li111I(0x6b0,'FRiS')]){$[li111I(0x2db,'QQQ*')]($['name'],'【提示】cookie已失效','京东账号'+$[li111I(0x6fb,'L8Lw')]+'\x20'+($[li111I(0x767,'N(T[')]||$[li111I(0x340,'K14W')])+li111I(0x614,'wZSb'),{'open-url':li111I(0x718,'$4@M')});$['isNode']()&&(Iil1I[li111I(0x734,'On5G')](Iil1I[li111I(0x5c6,'LIaD')],'mWhkZ')?lI111i+=I1lIII[liIlll[li111I(0x1cd,'u[PR')](I1iI1I[li111I(0x6f0,'L8Lw')]()*illll1[li111I(0x694,'rTPa')])]:await notify['sendNotify']($[li111I(0x648,'K14W')]+li111I(0x55b,'$4@M')+$['UserName'],li111I(0x761,'!EVL')+$[li111I(0x56d,'QQQ*')]+'\x20'+$[li111I(0x6b4,'ym#2')]+'\x0a请重新登录获取cookie'));continue;}messag
2023-07-27 16:14:01 +08:00
// prettier-ignore
2023-08-25 03:43: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.d