From d88be68c30b8f35a3bc2727302f693e82d69cdc1 Mon Sep 17 00:00:00 2001 From: ooo Date: Fri, 4 Feb 2022 12:21:43 +0800 Subject: [PATCH] yyds --- .../jd_DrawEntrance.js | 0 jd_big_winner.js => activity/jd_big_winner.js | 0 jd_bt_sign.js => activity/jd_bt_sign.js | 0 jd_cfd_loop.js => activity/jd_cfd_loop.js | 0 .../jd_china-joy_card.py | 0 jd_daily_egg.js => activity/jd_daily_egg.js | 0 jd_fcdyj.js => activity/jd_fcdyj.js | 0 jd_fcwb_help.js => activity/jd_fcwb_help.js | 0 activity/jd_festival.js | 1109 +++++++---------- jd_joy_tx.js => activity/jd_joy_tx.js | 0 jd_jxlhb.js => activity/jd_jxlhb.js | 0 jd_jxmc.js => activity/jd_jxmc.js | 0 jd_jxqd_new.js => activity/jd_jxqd_new.js | 0 jd_lxLottery.js => activity/jd_lxLottery.js | 0 jd_mall.js => activity/jd_mall.js | 0 .../jd_mhyyl_sendCard.js | 0 jd_mt.js => activity/jd_mt.js | 0 jd_nh_sign.js => activity/jd_nh_sign.js | 0 .../jd_rankingList.js | 0 jd_small_home.js => activity/jd_small_home.js | 0 .../jd_super_redrain.js | 0 jd_syj.js => activity/jd_syj.js | 0 jd_tiger.js => activity/jd_tiger.js | 0 .../jd_userAwardExpandinfo.py | 0 .../jd_wxCollectionActivity.js | 0 jd_year.js => activity/jd_year.js | 0 jd_zsign.js => activity/jd_zsign.js | 0 jd_festival.js | 446 ------- jd_lzdz1_customized10.js | 580 --------- jd_lzdz1_league.js | 589 --------- jd_mengniu.js | 2 +- jd_mpdzcar.js | 236 ++++ jd_redPacket_help.js | 2 +- 33 files changed, 661 insertions(+), 2303 deletions(-) rename jd_DrawEntrance.js => activity/jd_DrawEntrance.js (100%) rename jd_big_winner.js => activity/jd_big_winner.js (100%) rename jd_bt_sign.js => activity/jd_bt_sign.js (100%) rename jd_cfd_loop.js => activity/jd_cfd_loop.js (100%) rename jd_china-joy_card.py => activity/jd_china-joy_card.py (100%) rename jd_daily_egg.js => activity/jd_daily_egg.js (100%) rename jd_fcdyj.js => activity/jd_fcdyj.js (100%) rename jd_fcwb_help.js => activity/jd_fcwb_help.js (100%) rename jd_joy_tx.js => activity/jd_joy_tx.js (100%) rename jd_jxlhb.js => activity/jd_jxlhb.js (100%) rename jd_jxmc.js => activity/jd_jxmc.js (100%) rename jd_jxqd_new.js => activity/jd_jxqd_new.js (100%) rename jd_lxLottery.js => activity/jd_lxLottery.js (100%) rename jd_mall.js => activity/jd_mall.js (100%) rename jd_mhyyl_sendCard.js => activity/jd_mhyyl_sendCard.js (100%) rename jd_mt.js => activity/jd_mt.js (100%) rename jd_nh_sign.js => activity/jd_nh_sign.js (100%) rename jd_rankingList.js => activity/jd_rankingList.js (100%) rename jd_small_home.js => activity/jd_small_home.js (100%) rename jd_super_redrain.js => activity/jd_super_redrain.js (100%) rename jd_syj.js => activity/jd_syj.js (100%) rename jd_tiger.js => activity/jd_tiger.js (100%) rename jd_userAwardExpandinfo.py => activity/jd_userAwardExpandinfo.py (100%) rename jd_wxCollectionActivity.js => activity/jd_wxCollectionActivity.js (100%) rename jd_year.js => activity/jd_year.js (100%) rename jd_zsign.js => activity/jd_zsign.js (100%) delete mode 100644 jd_festival.js delete mode 100644 jd_lzdz1_customized10.js delete mode 100644 jd_lzdz1_league.js create mode 100755 jd_mpdzcar.js diff --git a/jd_DrawEntrance.js b/activity/jd_DrawEntrance.js similarity index 100% rename from jd_DrawEntrance.js rename to activity/jd_DrawEntrance.js diff --git a/jd_big_winner.js b/activity/jd_big_winner.js similarity index 100% rename from jd_big_winner.js rename to activity/jd_big_winner.js diff --git a/jd_bt_sign.js b/activity/jd_bt_sign.js similarity index 100% rename from jd_bt_sign.js rename to activity/jd_bt_sign.js diff --git a/jd_cfd_loop.js b/activity/jd_cfd_loop.js similarity index 100% rename from jd_cfd_loop.js rename to activity/jd_cfd_loop.js diff --git a/jd_china-joy_card.py b/activity/jd_china-joy_card.py similarity index 100% rename from jd_china-joy_card.py rename to activity/jd_china-joy_card.py diff --git a/jd_daily_egg.js b/activity/jd_daily_egg.js similarity index 100% rename from jd_daily_egg.js rename to activity/jd_daily_egg.js diff --git a/jd_fcdyj.js b/activity/jd_fcdyj.js similarity index 100% rename from jd_fcdyj.js rename to activity/jd_fcdyj.js diff --git a/jd_fcwb_help.js b/activity/jd_fcwb_help.js similarity index 100% rename from jd_fcwb_help.js rename to activity/jd_fcwb_help.js diff --git a/activity/jd_festival.js b/activity/jd_festival.js index 93cbdc8..938bb64 100644 --- a/activity/jd_festival.js +++ b/activity/jd_festival.js @@ -1,709 +1,446 @@ /* -京东手机年终奖 -活动时间:2021年1月26日~2021年2月8日 -更新地址:jd_festival.js -活动入口:https://shopping-festival.m.jd.com -已支持IOS双京东账号, Node.js支持N个京东账号 -脚本兼容: QuantumultX, Surge, Loon, 小火箭,JSBox, Node.js -============Quantumultx=============== -[task_local] -#京东手机年终奖 -15 0 * * * jd_festival.js, tag=京东手机年终奖, img-url=https://raw.githubusercontent.com/yogayyy/Scripts/master/Icon/shylocks/jd_festival2.jpg, enabled=true - -================Loon============== -[Script] -cron "15 0 * * *" script-path=jd_festival.js, tag=京东手机年终奖 - -===============Surge================= -京东手机年终奖 = type=cron,cronexp="15 0 * * *",wake-system=1,timeout=3600,script-path=jd_festival.js - -============小火箭========= -京东手机年终奖 = type=cron,script-path=jd_festival.js, cronexpr="15 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; -const randomCount = $.isNode() ? 20 : 5; - -const inviteCodes = [ - `9b98eb88-80ed-40ac-920c-a63fc769e72b@94c2a4d4-b53b-454b-82a0-0b80828bfd37@e274c80b-82dd-470c-878c-0790f5bf6a5d@aae299fc-6854-4fa7-b3ef-a6dedc3771b7@91ae877b-c98b-484a-9143-22d3a70b4088`, - `9b98eb88-80ed-40ac-920c-a63fc769e72b@94c2a4d4-b53b-454b-82a0-0b80828bfd37@e274c80b-82dd-470c-878c-0790f5bf6a5d@aae299fc-6854-4fa7-b3ef-a6dedc3771b7@91ae877b-c98b-484a-9143-22d3a70b4088` -]; - +tgchannel:https://t.me/Ariszy8028 +github:https://github.com/Ariszy/Private-Script +boxjs:https://raw.githubusercontent.com/Ariszy/Private-Script/master/Ariszy.boxjs.json +*/ +const $ = new Env('点鞭炮赢京豆') +const notify = $.isNode() ?require('./sendNotify') : ''; +cookiesArr = [] +CodeArr = [] +cookie = '' +var taskItemIdArr = [],task1ItemIdArr = [] +let t,num1,num2,num3,num4,num5,num = 0; +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +let tz = ($.getval('tz') || '1');//0关闭通知,1默认开启 +const invite=1;//新用户自动邀请,0关闭,1默认开启 +const logs =0;//0为关闭日志,1为开启 +var hour='' +var minute='' 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); + hour = new Date( new Date().getTime() + 8 * 60 * 60 * 1000 ).getHours(); + minute = new Date( new Date().getTime() + 8 * 60 * 60 * 1000 ).getMinutes(); +}else{ + hour = (new Date()).getHours(); + minute = (new Date()).getMinutes(); } -const JD_API_HOST = 'https://shopping-festival.m.jd.com/sf/'; +//CK运行 +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); +} + !(async () => { if (!cookiesArr[0]) { - $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', {"open-url": "https://bean.m.jd.com/"}); + $.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() - for (let i = 0; i < cookiesArr.length; i++) { - if (cookiesArr[i]) { + 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; + message = '' $.isLogin = true; - $.beans = 0 - $.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/`, {"open-url": "https://bean.m.jd.com/"}); + $.index = i + 1; + 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 getlist() + //await scan() + //await reward() + } - if ($.isNode()) { - await notify.sendNotify(`${$.name}cookie已失效 - ${$.UserName}`, `京东账号${$.index} ${$.UserName}\n请重新登录获取cookie`); - } - continue - } - await shareCodesFormat() - await festival() - await showMsg(); - } - } })() - .catch((e) => { - $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') - }) - .finally(() => { - $.done(); - }) + .catch((e) => $.logErr(e)) + .finally(() => $.done()) + -function showMsg() { - message += `本次运行获得${$.beans}个京豆` - return new Promise(resolve => { - $.msg($.name, '', `【京东账号${$.index}】${$.nickName}\n${message}`); - resolve() - }) +function PostRequest(uri,body) { + const url = `https://api.m.jd.com/api`; + const method = `POST`; + const 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://prodev.m.jd.com", +"User-Agent": "jdapp;iPhone;10.0.6;14.4;0bcbcdb2a68f16cf9c9ad7c9b944fd141646a849;network/4g;model/iPhone12,1;addressid/2377723269;appBuild/167724;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1" +} + return {url: url, method: method, headers: headers, body: body}; } +async function doTask(){ + const body = `appid=china-joy&functionId=festival_floor_prod&body=%7B%22taskId%22%3A%22${taskid}%22%2C%22taskItemId%22%3A%22${taskItemId}%22%2C%22apiMapping%22%3A%22%2Fapi%2Ftask%2FdoTask%22%7D&t=${new Date().getTime()}&loginType=2` + const MyRequest = PostRequest(``,body) + return new Promise((resolve) => { + $.post(MyRequest,async(error, response, data) =>{ + try{ + const result = JSON.parse(data) + if(logs) $.log(data) + if(result.code == 200){ + await $.wait(2000) + t = result.data.timeStamp + }else{ + $.log(result.msg+"\n") + } + }catch(e) { + $.logErr(e, response); + } finally { + resolve(); + } + }) + }) + } +async function DoTask(){ + const body = `appid=china-joy&functionId=festival_floor_prod&body=%7B%22taskId%22:%22${taskid}%22,%22taskItemId%22:%22${taskItemId}%22,%22timestamp%22:${t},%22skuId%22:%22%22,%22taskType%22:null,%22apiMapping%22:%22/api/task/getReward%22%7D&t=1642672924093&loginType=2` + const MyRequest = PostRequest(``,body) + return new Promise((resolve) => { + $.post(MyRequest,async(error, response, data) =>{ + try{ + const result = JSON.parse(data) + if(logs)$.log(data) + if(result.code == 200){ + if(result.data.taskFinish == true){ + console.log(result.msg+"获得"+result.data.jbean+"豆豆\n") + }else{ + console.log("任务继续") + } + } + }catch(e) { + $.logErr(e, response); + } finally { + resolve(); + } + }) + }) + } +async function Lottery(){ + const body = `functionId=interact_template_getLotteryResult&body=%7B%22appId%22:%221FV1VwKc%22%7D&client=wh5&clientVersion=1.0.0` + const MyRequest = PostRequest(``,body) + return new Promise((resolve) => { + $.post(MyRequest,async(error, response, data) =>{ + try{ + const result = JSON.parse(data) + if(logs)$.log(data) + if(result.data.result.userAwardsCacheDto.type == 2){ + console.log("\n获得"+result.data.result.userAwardsCacheDto.jBeanAwardVo.ext+"\n") + await $.wait(4000) + }else{ + $.log("恭喜你获得京豆0个\n") + } + }catch(e) { + $.logErr(e, response); + } finally { + resolve(); + } + }) + }) + } +async function getLottery(){ + const body = `functionId=interact_template_getLotteryResult&body=%7B%22appId%22%3A%221FV1VwKc%22%7D&client=wh5&clientVersion=1.0.0` + const MyRequest = PostRequest(``,body) + return new Promise((resolve) => { + $.post(MyRequest,async(error, response, data) =>{ + try{ + const result = JSON.parse(data) + if(logs)$.log(data) + if(result.data.bizCode == 0 && result.data.result.lotteryReturnCode == 0){ + console.log("\n获得"+result.data.result.userAwardsCacheDto.jBeanAwardVo.prizeName+"\n") + await $.wait(4000) + }else{ + $.log(result.data.bizMsg+" 恭喜你抽中了0豆豆\n") + } + }catch(e) { + $.logErr(e, response); + } finally { + resolve(); + } + }) + }) + } -async function helpFriends() { - for (let code of $.newShareCodes) { - if (!code) continue - console.log(`去助力好友${code}`) - const helpRes = await doSupport(code); - await $.wait(1000) +async function scans(){ + for(let j = 0; j < taskItemIdArr.length; j++){ + taskItemId = task1ItemIdArr[j]; + taskid = taskItemIdArr[j].match(/\d+/) + $.log("TaskId:"+taskid) + $.log("taskItemId:"+taskItemId) + await doTask() + await DoTask() +} +} +async function zy(){ +taskItemIdArr.splice(0,taskItemIdArr.length); +task1ItemIdArr.splice(0,task1ItemIdArr.length); +} + +async function Zy(){ + for(let i = 0; i < num1; i ++){ + await getlist() + } +} +async function control(){ + for(let i = 0; i < list1tokenArr.distinct().length; i++){ + helpcode = list1tokenArr[i] + await dosupport() + await $.wait(4000) +} +} +async function dosupport(){ + const body = `functionId=harmony_collectScore&body=%7B%22appId%22:%221FV1VwKc%22,%22taskToken%22:%22${helpcode}%22,%22taskId%22:6,%22actionType%22:0%7D&client=wh5&clientVersion=1.0.0` + const MyRequest = PostRequest(``,body) + return new Promise((resolve) => { + $.post(MyRequest,async(error, response, data) =>{ + try{ + const result = JSON.parse(data) + if(logs)$.log(data) + if(result.data.bizCode == 0){ + console.log(result.data.bizMsg+"获得"+result.data.result.score+";共有"+result.data.result.userScore+"\n") + await $.wait(4000) + }else{ + console.log(result.data.bizMsg+"\n") + } + }catch(e) { + $.logErr(e, response); + } finally { + resolve(); + } + }) + }) + } +async function getlist(){ + num++ + const MyRequest = PostRequest(``,`appid=china-joy&functionId=festival_floor_prod&body=%7B%22apiMapping%22%3A%22%2Fapi%2Ftask%2FgetTaskList%22%7D&t=1642671545792&loginType=2`) + return new Promise((resolve) => { + $.post(MyRequest,async(error, response, data) =>{ + try{ + const result = JSON.parse(data) + if(logs) $.log(data) + if(result.code == 200){ + + let list1 = result.data.taskList.find(item => item.taskItemType == "VENUE") + num1 = Number(list1.totalNum) - Number(list1.finishNum) + if(num1 > 0){ + + taskid = list1.taskId; + taskItemId = list1.taskItemId + + await doTask() + await $.wait(2000) + await DoTask() + + }else{ + $.log("任务已完成") + } + + let list3 = result.data.taskList.find(item => item.taskItemType == "SHOP") + num3 = Number(list3.totalNum) - Number(list3.finishNum) + if(num3 > 0){ + + taskid = list3.taskId; + taskItemId = list3.taskItemId + + await doTask() + await $.wait(2000) + await DoTask() + + }else{ + $.log("任务已完成") + } + + + let list4 = result.data.taskList.find(item => item.taskItemType == "SKU") + num4 = Number(list4.totalNum) - Number(list4.finishNum) + if(num4 > 0){ + + taskid = list4.taskId; + taskItemId = list4.taskItemId + await $.wait(2000) + await DoTask() + + }else{ + $.log("任务已完成") + } + + let list5 = result.data.taskList.find(item => item.taskItemType == "CHANNEL") + + num5 = Number(list5.totalNum) - Number(list5.finishNum) + if(num5 > 0){ + + taskid = list5.taskId; + taskItemId = list5.taskItemId + await doTask() + await $.wait(2000) + await DoTask() + + }else{ + $.log("任务已完成") + } + }else{ + $.log(result.echo+"错误!\n") + } + if(num1 > 0 || num3 > 0|| num4 > 0 || num5 > 0){ + if(num >= 5){ + console.log("\n⚠️发生错误,脚本自动退出") + return; + } + await getlist() + } + + }catch(e) { + $.logErr(e, response); + } finally { + resolve(); + } + }) + }) + } +async function scan(){ + const MyRequest = PostRequest(``,`functionId=healthyDay_getHomeData&body=%7B%22appId%22:%221FV1VwKc%22,%22taskToken%22:%22%22,%22channelId%22:1%7D&client=wh5&clientVersion=1.0.0`) + return new Promise((resolve) => { + $.post(MyRequest,async(error, response, data) =>{ + try{ + const result = JSON.parse(data) + if(logs)$.log(data) + if(result.code == 0){ + +let list6 = result.data.result.taskVos.find(item => item.taskId == 6) + for(let i = 0; i < list6.productInfoVos.length; i ++){ +list0tokenArr.push(6+list6.productInfoVos[i].taskToken) +list1tokenArr.push(list6.productInfoVos[i].taskToken) +} + + }else{ + $.log(result.data.bizMsg+"\n") + } + }catch(e) { + $.logErr(e, response); + } finally { + resolve(); + } + }) + }) + } +async function gethelpcode(){ + const MyRequest = PostRequest(``,`functionId=healthyDay_getHomeData&body=%7B%22appId%22%3A%221FV1VwKc%22%2C%22taskToken%22%3A%22%22%2C%22channelId%22%3A1%7D&client=wh5&clientVersion=1.0.0`) + return new Promise((resolve) => { + $.post(MyRequest,async(error, response, data) =>{ + try{ + const result = JSON.parse(data) + if(logs)$.log(data) + if(result.code == 0){ + +let list1 = result.data.result.taskVos.find(item => item.taskId == 1) + list0tokenArr.push(1+list1.assistTaskDetailVo.taskToken) +list1tokenArr.push(list1.assistTaskDetailVo.taskToken) + + }else{ + $.log(result.data.bizMsg+"\n") + } + }catch(e) { + $.logErr(e, response); + } finally { + resolve(); + } + }) + }) + } + +async function userScore(){ + const MyRequest = PostRequest(``,`functionId=healthyDay_getHomeData&body={"appId":"1FV1VwKc","taskToken":"","channelId":1}&client=wh5&clientVersion=1.0.0`) + return new Promise((resolve) => { + $.post(MyRequest,async(error, response, data) =>{ + try{ + const result = JSON.parse(data) + if(logs)$.log(data) + if(result.code == 0){ + let userScore = result.data.result.userInfo.userScore + $.log("共有金币:"+userScore+";开始抽奖"+Math.floor(userScore/500)+"次") + for(let i = 0; i < Math.floor(userScore/300); i++){ + await getLottery() + } + }else{ + $.log(result.data.bizMsg+"\n") + } + }catch(e) { + $.logErr(e, response); + } finally { + resolve(); + } + }) + }) + } +//showmsg +//boxjs设置tz=1,在12点<=20和23点>=40时间段通知,其余时间打印日志 + +async function showmsg() { + if (tz == 1) { + if ($.isNode()) { + if ((hour == 12 && minute <= 20) || (hour == 23 && minute >= 40)) { + await notify.sendNotify($.name, message) + } else { + $.log(message) + } + } else { + if ((hour == 12 && minute <= 20) || (hour == 23 && minute >= 40)) { + $.msg(zhiyi, '', message) + } else { + $.log(message) + } + } + } else { + $.log(message) } } - -async function festival() { - $.times = 0 - $.risk = false - await getIndexInfo() - if ($.risk) return - await getSignInfo() - await getTask(true) - for (let i = 0; i < 4; ++i) - await getTask() - for (let i = 0; i < 2; ++i) - await getExtTask() - await helpFriends() -} - -function getIndexInfo() { - return new Promise(resolve => { - $.get(taskUrl('index/indexInfo'), 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 === 200) { - $.risk = data.data.risk - if ($.risk) { - message += `风险用户\n` - console.log(`风险用户`) - return - } - $.times = data.data.remainTimes - console.log(`剩余游戏次数:${$.times}`) - } else { - console.log(`签到信息获取失败!`) - } - } - } - } catch (e) { - $.logErr(e, resp) - } finally { - resolve(); - } - }) - }) -} - -function getSignInfo() { - return new Promise(resolve => { - $.get(taskUrl('signin/listSignIn'), 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 === 200) { - let vo = data.data.signDayList.filter(vo => vo.date === data.data.today)[0] - if (vo.flag === "1") - console.log(`今日已签到`) - else - await signIn() - } else { - console.log(`签到信息获取失败!`) - } - } - } - } catch (e) { - $.logErr(e, resp) - } finally { - resolve(); - } - }) - }) -} - -function signIn() { - return new Promise(resolve => { - $.get(taskUrl('signin/signInPrize'), (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 === 200) { - console.log(`签到成功,获得${data.data.jbean}个京豆`) - $.beans += parseInt(data.data.jbean) - } else { - console.log(`签到失败!`) - } - } - } - } catch (e) { - $.logErr(e, resp) - } finally { - resolve(); - } - }) - }) -} - -function getTask(share = false) { - return new Promise(resolve => { - $.get(taskUrl('task/queryGeneralTasks'), 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 === 200) { - const {shareTask, generalTasks} = data.data - if (share) - console.log(`您的好友助力码为:${shareTask.shareId},当前助力进度:${shareTask.needSupportNum - shareTask.remainSupportNum}/${shareTask.needSupportNum}`) - else - for (let vo of generalTasks) { - console.log(`任务${vo.id}完成进度:${vo.finish}/${vo.total}`) - if (vo.finish < vo.total) { - await doTask(vo.type) - await $.wait(10 * 1000) - } - if (vo.status === "3") { - console.log(`任务已完成,去领奖`) - await doReceive(vo.type) - } else if (vo.status === "4") { - console.log(`任务已领奖`) - } - } - } else { - console.log(`任务获取失败`) - } - } - } - } catch (e) { - $.logErr(e, resp) - } finally { - resolve(); - } - }) - }) -} - -function getExtTask() { - return new Promise(resolve => { - $.get(taskUrl('extTask/extTaskInfo'), 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 === 200) { - let type = ['shop', 'sku', 'venue'] - for (let vo of type) { - for (let item of data.data[`${vo}List`]) { - if (item.status < 2) { - console.log(`去浏览${item.name}`) - await browseTask(item.id, vo) - await $.wait(6 * 1000) - } else if (item.status === 2) { - console.log(`${item.name}浏览完成,去领奖`) - await getPrize(item.id, vo) - } else { - console.log(`${item.name}已浏览过`) - } - } - } - } else { - console.log(`任务获取失败`) - } - } - } - } catch (e) { - $.logErr(e, resp) - } finally { - resolve(); - } - }) - }) -} - -function doTask(type) { - return new Promise(resolve => { - $.get(taskUrl('task/doTask', {type: type}), 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 === 200) { - console.log(`任务完成成功`) - } else { - console.log(`任务完成失败`) - } - } - } - } catch (e) { - $.logErr(e, resp) - } finally { - resolve(); - } - }) - }) -} - -function doReceive(type) { - return new Promise(resolve => { - $.get(taskUrl('task/doReceive', {type: type}), 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 === 200) { - console.log(`任务领奖成功,获得${data.data}次游戏机会`) - } else { - console.log(`任务领奖失败`) - } - } - } - } catch (e) { - $.logErr(e, resp) - } finally { - resolve(); - } - }) - }) -} - -function browseTask(id, type) { - return new Promise(resolve => { - $.get(taskUrl('extTask/browse', {id: id, type: type}), 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 === 200) { - console.log(`任务完成成功`) - } else { - console.log(`任务完成失败`) - } - } - } - } catch (e) { - $.logErr(e, resp) - } finally { - resolve(); - } - }) - }) -} - -function getPrize(id, type) { - return new Promise(resolve => { - $.get(taskUrl('extTask/getPrize', {id: id, type: type}), 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 === 200) { - console.log(`任务领奖成功,获得${data.data}京豆`) - $.beans += data.data - } else { - console.log(`任务领奖失败`) - } - } - } - } catch (e) { - $.logErr(e, resp) - } finally { - resolve(); - } - }) - }) -} - -function getMoney() { - return new Promise(resolve => { - $.get(taskUrl('index/getMoney',), 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 === 200) { - console.log(`游戏开启成功,等待20秒`) - let sum = data.data.moneyList.reduce((a, b) => a + b, 0) - await $.wait(20 * 1000) - await addMoney(sum) - } else { - console.log(`游戏开启失败`) - } - } - } - } catch (e) { - $.logErr(e, resp) - } finally { - resolve(); - } - }) - }) -} - -function addMoney(sum) { - return new Promise(resolve => { - $.post(taskPostUrl('index/addGoldNums', {goldNum: sum}), 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 === 200) { - console.log(`游戏完成成功,获得${data.data.goldTotal}体验金`) - } else { - console.log(`游戏完成失败`) - } - } - } - } catch (e) { - $.logErr(e, resp) - } finally { - resolve(); - } - }) - }) -} - -function doSupport(shareId) { - return new Promise(resolve => { - $.get(taskUrl('task/doSupport', {shareId: shareId}), 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 === 200) { - console.log(`助力好友成功`) - } else { - console.log(`助力好友失败`) - } - } - } - } catch (e) { - $.logErr(e, resp) - } finally { - resolve(); - } - }) - }) -} -function getTs() { - return new Date().getTime() + new Date().getTimezoneOffset() * 60 * 1000 + 8 * 60 * 60 * 1000 -} - -function taskPostUrl(function_id, body = {}) { - const t = getTs() - let n = { - ...body - } - let str = '' - for (let key in body) { - if (str !== "") { - str += "&"; - } - str += key + "=" + encodeURIComponent(body[key]); - } - return { - url: `${JD_API_HOST}${function_id}`, - body: str, - headers: { - "Accept": "*/*", - "Accept-Encoding": "gzip, deflate, br", - "Accept-Language": "zh-cn", - "Connection": "keep-alive", - "Content-Type": "application/x-www-form-urlencoded", - "Host": "shopping-festival.m.jd.com", - "Referer": "https://shopping-festival.m.jd.com/", - "Cookie": cookie, - 'dnt': '1', - 'pragma': 'no-cache', - 'sign': sign(n, `d55b480bed0545839dbd8b78b6cffdb1${t}`, `/sf/${function_id}`), - 'timestamp': ($.isQuanX()||$.isSurge()) ?t.toString():t, - "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('../USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "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.141" - ) - } - } -} - -function taskUrl(function_id, body = {}) { - const t = getTs() - let n = { - t: t, - ...body - } - let str = '' - for (let key in body) { - if (str !== "") { - str += "&"; - } - str += key + "=" + encodeURIComponent(body[key]); - } - return { - url: `${JD_API_HOST}${function_id}?t=${t}&${str}`, - headers: { - "Accept": "*/*", - "Accept-Encoding": "gzip, deflate, br", - "Accept-Language": "zh-cn", - "Connection": "keep-alive", - "Content-Type": "application/x-www-form-urlencoded", - "Host": "shopping-festival.m.jd.com", - "Referer": "https://shopping-festival.m.jd.com/", - "Cookie": cookie, - 'dnt': '1', - 'pragma': 'no-cache', - 'sign': sign(n, `d55b480bed0545839dbd8b78b6cffdb1${t}`, `/sf/${function_id}`), - 'timestamp': ($.isQuanX()||$.isSurge()) ?t.toString():t, - "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.141" - } - } -} - -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 : "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") : ($.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; - } + 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 []; - } + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, "", "不要在BoxJS手动复制粘贴修改cookie"); + return []; + } + } +} +Array.prototype.distinct = function (){ + var arr = this, + result = [], + len = arr.length; + arr.forEach(function(v, i ,arr){ //这里利用map,filter方法也可以实现 + var bool = arr.indexOf(v,i+1); //从传入参数的下一个索引值开始寻找是否存在重复 + if(bool === -1){ + result.push(v); } -} -function sign(t, e, n) { - var a = "" - , i = n.split("?")[1] || ""; - if (t) { - if ("string" == typeof t) - a = t + i; - else if ("object" == typeof (t)) { - var r = []; - for (var s in t) - r.push(s + "=" + t[s]); - a = r.length ? r.join("&") + i : i - } - } else - a = i; - if (a) { - var o = a.split("&").sort().join(""); - return $.md5(o + e) - } - return $.md5(e) -} -function requireConfig() { - return new Promise(resolve => { - console.log(`开始获取${$.name}配置文件\n`); - //Node.js用户请在jdCookie.js处填写京东ck; - let shareCodes = [] - console.log(`共${cookiesArr.length}个京东账号\n`); - if ($.isNode() && process.env.JSMOBILEFESTIVAL_SHARECODES) { - if (process.env.JSMOBILEFESTIVAL_SHARECODES.indexOf('\n') > -1) { - shareCodes = process.env.JSMOBILEFESTIVAL_SHARECODES.split('\n'); - } else { - shareCodes = process.env.JSMOBILEFESTIVAL_SHARECODES.split('&'); - } - } - $.shareCodesArr = []; - if ($.isNode()) { - Object.keys(shareCodes).forEach((item) => { - if (shareCodes[item]) { - $.shareCodesArr.push(shareCodes[item]) - } - }) - } - console.log(`您提供了${$.shareCodesArr.length}个账号的${$.name}PK助力码\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 = null // await readShareCode(); - 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: `http://jd.turinglabs.net/api/v2/jd/festival/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}个PK助力码放到您固定的互助码后面(不影响已有固定互助)`) - data = JSON.parse(data); - } - } - } catch (e) { - $.logErr(e, resp) - } finally { - resolve(data); - } - }) - await $.wait(10000); - resolve() - }) -} -// md5 -!function(n){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); -// 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)} + }) + return result; +}; +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();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){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}}}};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=["","==============\ud83d\udce3\u7cfb\u7edf\u901a\u77e5\ud83d\udce3=============="];t.push(e),s&&t.push(s),i&&t.push(i),console.log(t.join("\n")),this.logs=this.logs.concat(t)}}log(...t){t.length>0&&(this.logs=[...this.logs,...t]),console.log(t.join(this.logSeparator))}logErr(t,e){const s=!this.isSurge()&&!this.isQuanX()&&!this.isLoon();s?this.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t.stack):this.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`\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_joy_tx.js b/activity/jd_joy_tx.js similarity index 100% rename from jd_joy_tx.js rename to activity/jd_joy_tx.js diff --git a/jd_jxlhb.js b/activity/jd_jxlhb.js similarity index 100% rename from jd_jxlhb.js rename to activity/jd_jxlhb.js diff --git a/jd_jxmc.js b/activity/jd_jxmc.js similarity index 100% rename from jd_jxmc.js rename to activity/jd_jxmc.js diff --git a/jd_jxqd_new.js b/activity/jd_jxqd_new.js similarity index 100% rename from jd_jxqd_new.js rename to activity/jd_jxqd_new.js diff --git a/jd_lxLottery.js b/activity/jd_lxLottery.js similarity index 100% rename from jd_lxLottery.js rename to activity/jd_lxLottery.js diff --git a/jd_mall.js b/activity/jd_mall.js similarity index 100% rename from jd_mall.js rename to activity/jd_mall.js diff --git a/jd_mhyyl_sendCard.js b/activity/jd_mhyyl_sendCard.js similarity index 100% rename from jd_mhyyl_sendCard.js rename to activity/jd_mhyyl_sendCard.js diff --git a/jd_mt.js b/activity/jd_mt.js similarity index 100% rename from jd_mt.js rename to activity/jd_mt.js diff --git a/jd_nh_sign.js b/activity/jd_nh_sign.js similarity index 100% rename from jd_nh_sign.js rename to activity/jd_nh_sign.js diff --git a/jd_rankingList.js b/activity/jd_rankingList.js similarity index 100% rename from jd_rankingList.js rename to activity/jd_rankingList.js diff --git a/jd_small_home.js b/activity/jd_small_home.js similarity index 100% rename from jd_small_home.js rename to activity/jd_small_home.js diff --git a/jd_super_redrain.js b/activity/jd_super_redrain.js similarity index 100% rename from jd_super_redrain.js rename to activity/jd_super_redrain.js diff --git a/jd_syj.js b/activity/jd_syj.js similarity index 100% rename from jd_syj.js rename to activity/jd_syj.js diff --git a/jd_tiger.js b/activity/jd_tiger.js similarity index 100% rename from jd_tiger.js rename to activity/jd_tiger.js diff --git a/jd_userAwardExpandinfo.py b/activity/jd_userAwardExpandinfo.py similarity index 100% rename from jd_userAwardExpandinfo.py rename to activity/jd_userAwardExpandinfo.py diff --git a/jd_wxCollectionActivity.js b/activity/jd_wxCollectionActivity.js similarity index 100% rename from jd_wxCollectionActivity.js rename to activity/jd_wxCollectionActivity.js diff --git a/jd_year.js b/activity/jd_year.js similarity index 100% rename from jd_year.js rename to activity/jd_year.js diff --git a/jd_zsign.js b/activity/jd_zsign.js similarity index 100% rename from jd_zsign.js rename to activity/jd_zsign.js diff --git a/jd_festival.js b/jd_festival.js deleted file mode 100644 index 938bb64..0000000 --- a/jd_festival.js +++ /dev/null @@ -1,446 +0,0 @@ -/* -tgchannel:https://t.me/Ariszy8028 -github:https://github.com/Ariszy/Private-Script -boxjs:https://raw.githubusercontent.com/Ariszy/Private-Script/master/Ariszy.boxjs.json -*/ -const $ = new Env('点鞭炮赢京豆') -const notify = $.isNode() ?require('./sendNotify') : ''; -cookiesArr = [] -CodeArr = [] -cookie = '' -var taskItemIdArr = [],task1ItemIdArr = [] -let t,num1,num2,num3,num4,num5,num = 0; -const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; -cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); -let tz = ($.getval('tz') || '1');//0关闭通知,1默认开启 -const invite=1;//新用户自动邀请,0关闭,1默认开启 -const logs =0;//0为关闭日志,1为开启 -var hour='' -var minute='' -if ($.isNode()) { - hour = new Date( new Date().getTime() + 8 * 60 * 60 * 1000 ).getHours(); - minute = new Date( new Date().getTime() + 8 * 60 * 60 * 1000 ).getMinutes(); -}else{ - hour = (new Date()).getHours(); - minute = (new Date()).getMinutes(); -} -//CK运行 -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); -} - -!(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++) { - cookie = cookiesArr[i]; - $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) - message = '' - $.isLogin = true; - $.index = i + 1; - 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 getlist() - //await scan() - //await reward() - } - -})() - .catch((e) => $.logErr(e)) - .finally(() => $.done()) - - -function PostRequest(uri,body) { - const url = `https://api.m.jd.com/api`; - const method = `POST`; - const 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://prodev.m.jd.com", -"User-Agent": "jdapp;iPhone;10.0.6;14.4;0bcbcdb2a68f16cf9c9ad7c9b944fd141646a849;network/4g;model/iPhone12,1;addressid/2377723269;appBuild/167724;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1" -} - return {url: url, method: method, headers: headers, body: body}; -} - -async function doTask(){ - const body = `appid=china-joy&functionId=festival_floor_prod&body=%7B%22taskId%22%3A%22${taskid}%22%2C%22taskItemId%22%3A%22${taskItemId}%22%2C%22apiMapping%22%3A%22%2Fapi%2Ftask%2FdoTask%22%7D&t=${new Date().getTime()}&loginType=2` - const MyRequest = PostRequest(``,body) - return new Promise((resolve) => { - $.post(MyRequest,async(error, response, data) =>{ - try{ - const result = JSON.parse(data) - if(logs) $.log(data) - if(result.code == 200){ - await $.wait(2000) - t = result.data.timeStamp - }else{ - $.log(result.msg+"\n") - } - }catch(e) { - $.logErr(e, response); - } finally { - resolve(); - } - }) - }) - } -async function DoTask(){ - const body = `appid=china-joy&functionId=festival_floor_prod&body=%7B%22taskId%22:%22${taskid}%22,%22taskItemId%22:%22${taskItemId}%22,%22timestamp%22:${t},%22skuId%22:%22%22,%22taskType%22:null,%22apiMapping%22:%22/api/task/getReward%22%7D&t=1642672924093&loginType=2` - const MyRequest = PostRequest(``,body) - return new Promise((resolve) => { - $.post(MyRequest,async(error, response, data) =>{ - try{ - const result = JSON.parse(data) - if(logs)$.log(data) - if(result.code == 200){ - if(result.data.taskFinish == true){ - console.log(result.msg+"获得"+result.data.jbean+"豆豆\n") - }else{ - console.log("任务继续") - } - } - }catch(e) { - $.logErr(e, response); - } finally { - resolve(); - } - }) - }) - } -async function Lottery(){ - const body = `functionId=interact_template_getLotteryResult&body=%7B%22appId%22:%221FV1VwKc%22%7D&client=wh5&clientVersion=1.0.0` - const MyRequest = PostRequest(``,body) - return new Promise((resolve) => { - $.post(MyRequest,async(error, response, data) =>{ - try{ - const result = JSON.parse(data) - if(logs)$.log(data) - if(result.data.result.userAwardsCacheDto.type == 2){ - console.log("\n获得"+result.data.result.userAwardsCacheDto.jBeanAwardVo.ext+"\n") - await $.wait(4000) - }else{ - $.log("恭喜你获得京豆0个\n") - } - }catch(e) { - $.logErr(e, response); - } finally { - resolve(); - } - }) - }) - } -async function getLottery(){ - const body = `functionId=interact_template_getLotteryResult&body=%7B%22appId%22%3A%221FV1VwKc%22%7D&client=wh5&clientVersion=1.0.0` - const MyRequest = PostRequest(``,body) - return new Promise((resolve) => { - $.post(MyRequest,async(error, response, data) =>{ - try{ - const result = JSON.parse(data) - if(logs)$.log(data) - if(result.data.bizCode == 0 && result.data.result.lotteryReturnCode == 0){ - console.log("\n获得"+result.data.result.userAwardsCacheDto.jBeanAwardVo.prizeName+"\n") - await $.wait(4000) - }else{ - $.log(result.data.bizMsg+" 恭喜你抽中了0豆豆\n") - } - }catch(e) { - $.logErr(e, response); - } finally { - resolve(); - } - }) - }) - } - -async function scans(){ - for(let j = 0; j < taskItemIdArr.length; j++){ - taskItemId = task1ItemIdArr[j]; - taskid = taskItemIdArr[j].match(/\d+/) - $.log("TaskId:"+taskid) - $.log("taskItemId:"+taskItemId) - await doTask() - await DoTask() -} -} -async function zy(){ -taskItemIdArr.splice(0,taskItemIdArr.length); -task1ItemIdArr.splice(0,task1ItemIdArr.length); -} - -async function Zy(){ - for(let i = 0; i < num1; i ++){ - await getlist() - } -} -async function control(){ - for(let i = 0; i < list1tokenArr.distinct().length; i++){ - helpcode = list1tokenArr[i] - await dosupport() - await $.wait(4000) -} -} -async function dosupport(){ - const body = `functionId=harmony_collectScore&body=%7B%22appId%22:%221FV1VwKc%22,%22taskToken%22:%22${helpcode}%22,%22taskId%22:6,%22actionType%22:0%7D&client=wh5&clientVersion=1.0.0` - const MyRequest = PostRequest(``,body) - return new Promise((resolve) => { - $.post(MyRequest,async(error, response, data) =>{ - try{ - const result = JSON.parse(data) - if(logs)$.log(data) - if(result.data.bizCode == 0){ - console.log(result.data.bizMsg+"获得"+result.data.result.score+";共有"+result.data.result.userScore+"\n") - await $.wait(4000) - }else{ - console.log(result.data.bizMsg+"\n") - } - }catch(e) { - $.logErr(e, response); - } finally { - resolve(); - } - }) - }) - } -async function getlist(){ - num++ - const MyRequest = PostRequest(``,`appid=china-joy&functionId=festival_floor_prod&body=%7B%22apiMapping%22%3A%22%2Fapi%2Ftask%2FgetTaskList%22%7D&t=1642671545792&loginType=2`) - return new Promise((resolve) => { - $.post(MyRequest,async(error, response, data) =>{ - try{ - const result = JSON.parse(data) - if(logs) $.log(data) - if(result.code == 200){ - - let list1 = result.data.taskList.find(item => item.taskItemType == "VENUE") - num1 = Number(list1.totalNum) - Number(list1.finishNum) - if(num1 > 0){ - - taskid = list1.taskId; - taskItemId = list1.taskItemId - - await doTask() - await $.wait(2000) - await DoTask() - - }else{ - $.log("任务已完成") - } - - let list3 = result.data.taskList.find(item => item.taskItemType == "SHOP") - num3 = Number(list3.totalNum) - Number(list3.finishNum) - if(num3 > 0){ - - taskid = list3.taskId; - taskItemId = list3.taskItemId - - await doTask() - await $.wait(2000) - await DoTask() - - }else{ - $.log("任务已完成") - } - - - let list4 = result.data.taskList.find(item => item.taskItemType == "SKU") - num4 = Number(list4.totalNum) - Number(list4.finishNum) - if(num4 > 0){ - - taskid = list4.taskId; - taskItemId = list4.taskItemId - await $.wait(2000) - await DoTask() - - }else{ - $.log("任务已完成") - } - - let list5 = result.data.taskList.find(item => item.taskItemType == "CHANNEL") - - num5 = Number(list5.totalNum) - Number(list5.finishNum) - if(num5 > 0){ - - taskid = list5.taskId; - taskItemId = list5.taskItemId - await doTask() - await $.wait(2000) - await DoTask() - - }else{ - $.log("任务已完成") - } - }else{ - $.log(result.echo+"错误!\n") - } - if(num1 > 0 || num3 > 0|| num4 > 0 || num5 > 0){ - if(num >= 5){ - console.log("\n⚠️发生错误,脚本自动退出") - return; - } - await getlist() - } - - }catch(e) { - $.logErr(e, response); - } finally { - resolve(); - } - }) - }) - } -async function scan(){ - const MyRequest = PostRequest(``,`functionId=healthyDay_getHomeData&body=%7B%22appId%22:%221FV1VwKc%22,%22taskToken%22:%22%22,%22channelId%22:1%7D&client=wh5&clientVersion=1.0.0`) - return new Promise((resolve) => { - $.post(MyRequest,async(error, response, data) =>{ - try{ - const result = JSON.parse(data) - if(logs)$.log(data) - if(result.code == 0){ - -let list6 = result.data.result.taskVos.find(item => item.taskId == 6) - for(let i = 0; i < list6.productInfoVos.length; i ++){ -list0tokenArr.push(6+list6.productInfoVos[i].taskToken) -list1tokenArr.push(list6.productInfoVos[i].taskToken) -} - - }else{ - $.log(result.data.bizMsg+"\n") - } - }catch(e) { - $.logErr(e, response); - } finally { - resolve(); - } - }) - }) - } -async function gethelpcode(){ - const MyRequest = PostRequest(``,`functionId=healthyDay_getHomeData&body=%7B%22appId%22%3A%221FV1VwKc%22%2C%22taskToken%22%3A%22%22%2C%22channelId%22%3A1%7D&client=wh5&clientVersion=1.0.0`) - return new Promise((resolve) => { - $.post(MyRequest,async(error, response, data) =>{ - try{ - const result = JSON.parse(data) - if(logs)$.log(data) - if(result.code == 0){ - -let list1 = result.data.result.taskVos.find(item => item.taskId == 1) - list0tokenArr.push(1+list1.assistTaskDetailVo.taskToken) -list1tokenArr.push(list1.assistTaskDetailVo.taskToken) - - }else{ - $.log(result.data.bizMsg+"\n") - } - }catch(e) { - $.logErr(e, response); - } finally { - resolve(); - } - }) - }) - } - -async function userScore(){ - const MyRequest = PostRequest(``,`functionId=healthyDay_getHomeData&body={"appId":"1FV1VwKc","taskToken":"","channelId":1}&client=wh5&clientVersion=1.0.0`) - return new Promise((resolve) => { - $.post(MyRequest,async(error, response, data) =>{ - try{ - const result = JSON.parse(data) - if(logs)$.log(data) - if(result.code == 0){ - let userScore = result.data.result.userInfo.userScore - $.log("共有金币:"+userScore+";开始抽奖"+Math.floor(userScore/500)+"次") - for(let i = 0; i < Math.floor(userScore/300); i++){ - await getLottery() - } - }else{ - $.log(result.data.bizMsg+"\n") - } - }catch(e) { - $.logErr(e, response); - } finally { - resolve(); - } - }) - }) - } -//showmsg -//boxjs设置tz=1,在12点<=20和23点>=40时间段通知,其余时间打印日志 - -async function showmsg() { - if (tz == 1) { - if ($.isNode()) { - if ((hour == 12 && minute <= 20) || (hour == 23 && minute >= 40)) { - await notify.sendNotify($.name, message) - } else { - $.log(message) - } - } else { - if ((hour == 12 && minute <= 20) || (hour == 23 && minute >= 40)) { - $.msg(zhiyi, '', message) - } else { - $.log(message) - } - } - } else { - $.log(message) - } -} -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 []; - } - } -} -Array.prototype.distinct = function (){ - var arr = this, - result = [], - len = arr.length; - arr.forEach(function(v, i ,arr){ //这里利用map,filter方法也可以实现 - var bool = arr.indexOf(v,i+1); //从传入参数的下一个索引值开始寻找是否存在重复 - if(bool === -1){ - result.push(v); - } - }) - return result; -}; -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();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){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}}}};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=["","==============\ud83d\udce3\u7cfb\u7edf\u901a\u77e5\ud83d\udce3=============="];t.push(e),s&&t.push(s),i&&t.push(i),console.log(t.join("\n")),this.logs=this.logs.concat(t)}}log(...t){t.length>0&&(this.logs=[...this.logs,...t]),console.log(t.join(this.logSeparator))}logErr(t,e){const s=!this.isSurge()&&!this.isQuanX()&&!this.isLoon();s?this.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t.stack):this.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`\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_lzdz1_customized10.js b/jd_lzdz1_customized10.js deleted file mode 100644 index 75ba759..0000000 --- a/jd_lzdz1_customized10.js +++ /dev/null @@ -1,580 +0,0 @@ -/* -大牌好礼带回家 -TG https://t.me/duckjobs - -https://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity/5063373?activityId=dzlhkkkbblnt20220121&shareUuid=e7c54de96c3b45a398c05ad66ec6c743 -*/ -const $ = new Env("大牌好礼带回家"); -const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; -const notify = $.isNode() ? require('./sendNotify') : ''; -let cookiesArr = [], cookie = '', message = ''; -let ownCode = null; -let authorCodeList = [] -if ($.isNode()) { - Object.keys(jdCookieNode).forEach((item) => { - cookiesArr.push(jdCookieNode[item]) - }) - if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => { }; -} else { - let cookiesData = $.getdata('CookiesJD') || "[]"; - cookiesData = JSON.parse(cookiesData); - cookiesArr = cookiesData.map(item => item.cookie); - cookiesArr.reverse(); - cookiesArr.push(...[$.getdata('CookieJD2'), $.getdata('CookieJD')]); - cookiesArr.reverse(); - cookiesArr = cookiesArr.filter(item => !!item); -} -!(async () => { - $.getAuthorCodeListerr = false - 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; - } - authorCodeList = await getAuthorCodeList('https://gitee.com/fatelight/code/raw/master/lzdz110.json') - if($.getAuthorCodeListerr === false){ - authorCodeList = [ - 'e7c54de96c3b45a398c05ad66ec6c743', - ] - } - for (let i = 0; i < cookiesArr.length; i++) { - if (cookiesArr[i]) { - cookie = cookiesArr[i] - originCookie = cookiesArr[i] - newCookie = '' - $.UserName = decodeURIComponent(cookie.match(/pt_pin=(.+?);/) && cookie.match(/pt_pin=(.+?);/)[1]) - $.index = i + 1; - $.isLogin = true; - $.nickName = ''; - await checkCookie(); - 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 - } - $.bean = 0; - $.ADID = getUUID('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', 1); - $.UUID = getUUID('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'); - $.authorCode = ownCode ? ownCode : authorCodeList[random(0, authorCodeList.length)] - $.authorNum = `${random(1000000, 9999999)}` - $.randomCode = random(1000000, 9999999) - $.activityId = 'dzlhkkkbblnt20220121' - $.activityShopId = '1000040084' - $.activityUrl = `https://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity/${$.authorNum}?activityId=${$.activityId}&shareUuid=${encodeURIComponent($.authorCode)}&adsource=null&shareuserid4minipg=null&shopid=undefined&lng=00.000000&lat=00.000000&sid=&un_area=` - await member(); - await $.wait(5000) - if ($.bean > 0) { - message += `\n【京东账号${$.index}】${$.nickName || $.UserName} \n └ 获得 ${$.bean} 京豆。` - } - } - } - if (message !== '') { - if ($.isNode()) { - await notify.sendNotify($.name, message, '', `\n`); - } else { - $.msg($.name, '有点儿收获', message); - } - } -})() - .catch((e) => { - $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') - }) - .finally(() => { - $.done(); - }) - - -async function member() { - $.token = null; - $.secretPin = null; - $.openCardActivityId = null - await getFirstLZCK() - await getToken(); - await task('dz/common/getSimpleActInfoVo', `activityId=${$.activityId}`, 1) - if ($.token) { - await getMyPing(); - if ($.secretPin) { - console.log("去助力 -> "+$.authorCode) - await task('common/accessLogWithAD', `venderId=${$.activityShopId}&code=99&pin=${encodeURIComponent($.secretPin)}&activityId=${$.activityId}&pageUrl=${$.activityUrl}&subType=app&adSource=null`, 1); - await task('wxActionCommon/getUserInfo', `pin=${encodeURIComponent($.secretPin)}`, 1) - if ($.index === 1) { - await task('linkgame/activity/content', `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}&pinImg=&nick=${encodeURIComponent($.pin)}&cjyxPin=&cjhyPin=&shareUuid=${encodeURIComponent($.authorCode)}`, 0, 1) - } else { - await task('linkgame/activity/content', `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}&pinImg=&nick=${encodeURIComponent($.pin)}&cjyxPin=&cjhyPin=&shareUuid=${encodeURIComponent($.authorCode)}`) - } - $.log("关注店铺") - await task('opencard/follow/shop', `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}`) - await task('taskact/common/drawContent', `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}`) - await task('linkgame/checkOpenCard', `pin=${encodeURIComponent($.secretPin)}&activityId=${$.activityId}`) - $.log("加入店铺会员") - if ($.openCardList) { - $.log(">>> 模拟上报访问记录") - for (let i = 0; i < ($.openCardList.length); i++) { - await task('crm/pageVisit/insertCrmPageVisit', `venderId=1000003005&pageId=llk20211015&elementId=入会跳转&pin=${encodeURIComponent($.secretPin)}`, 1) - await $.wait(2000) - } - - for (const vo of $.openCardList) { - $.log(`>>> 去加入${vo.name} ${vo.venderId}`) - if (vo.status === 0) { - await getShopOpenCardInfo({ "venderId": `${vo.venderId}`, "channel": "401" }, vo.venderId) - await bindWithVender({ "venderId": `${vo.venderId}`, "bindByVerifyCodeFlag": 1, "registerExtend": {}, "writeChildFlag": 0, "activityId": $.openCardActivityId, "channel": 401 }, vo.venderId) - await $.wait(2000) - } else { - $.log(`>>> 已经是会员`) - } - - } - } else { - $.log("没有获取到对应的任务。\n") - } - await task('linkgame/checkOpenCard', `pin=${encodeURIComponent($.secretPin)}&activityId=${$.activityId}`) - if ($.openCardStatus) { - console.log('去助力 -> ' + $.authorCode) - if ($.openCardStatus.allOpenCard) { - await getFirstLZCK() - await getToken(); - await task('linkgame/assist/status', `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}&shareUuid=${$.authorCode}`) - await task('linkgame/assist', `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}&shareUuid=${$.authorCode}`) - - } - } - // await task('linkgame/help/list', `pin=${encodeURIComponent($.secretPin)}&activityId=${$.activityId}`) - - // await task('linkgame/task/info', `pin=${encodeURIComponent($.secretPin)}&activityId=${$.activityId}`) - console.log('任务 -> ') - await $.wait(2000) - await task('opencard/addCart', `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}`); - await $.wait(2000) - await task('linkgame/sendAllCoupon', `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}`); - console.log('抽奖 -> ') - await $.wait(2000) - await task('opencard/draw', `activityId=${$.activityId}&actorUuid=${$.actorUuid}&pin=${encodeURIComponent($.secretPin)}`); - } - } -} - -function task(function_id, body, isCommon = 0, own = 0) { - return new Promise(resolve => { - $.post(taskUrl(function_id, body, isCommon), async (err, resp, data) => { - try { - if (err) { - $.log(err) - } else { - - if (data) { - data = JSON.parse(data); - if (data.result) { - switch (function_id) { - case 'dz/common/getSimpleActInfoVo': - $.jdActivityId = data.data.jdActivityId; - $.venderId = data.data.venderId; - $.activityType = data.data.activityType; - break; - case 'wxActionCommon/getUserInfo': - break; - case 'linkgame/activity/content': - if (!data.data.hasEnd) { - $.log(`开启【${data.data.activity['name']}】活动`) - $.log("-------------------") - if ($.index === 1) { - ownCode = data.data.actor['actorUuid'] - console.log(ownCode) - } - $.actorUuid = data.data.actor['actorUuid']; - } else { - $.log("活动已经结束"); - } - break; - case 'linkgame/checkOpenCard': - $.openCardList = data.data.openCardList; - $.openCardStatus = data.data; - // console.log(data) - break; - case 'opencard/follow/shop': - console.log(data) - break; - case 'linkgame/sign': - console.log(data) - break; - case 'opencard/addCart': - if (data.data) { - console.log(data.data) - } - break; - case 'linkgame/sendAllCoupon': - if (data.data) { - console.log(data.data) - } - - break; - case 'interaction/write/writePersonInfo': - console.log(data) - break; - case 'opencard/draw': - console.log(data) - break; - case 'linkgame/assist/status': - $.log(JSON.stringify(data)) - break; - case 'linkgame/assist': - $.log(JSON.stringify(data)) - break; - case 'linkgame/help/list': - $.log(JSON.stringify(data)) - break; - default: - // $.log(JSON.stringify(data)) - break; - } - } else { - // $.log(JSON.stringify(data)) - } - } else { - // $.log("京东没有返回数据") - } - } - } catch (error) { - $.log(error) - } finally { - resolve(); - } - }) - }) -} -function getShopOpenCardInfo(body, venderId) { - let opt = { - url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body=${encodeURIComponent(JSON.stringify(body))}&client=H5&clientVersion=9.2.0&uuid=88888`, - headers: { - Host: 'api.m.jd.com', - Accept: '*/*', - Connection: 'keep-alive', - Cookie: cookie, - 'User-Agent': `jdapp;iPhone;9.5.4;13.6;${$.UUID};network/wifi;ADID/${$.ADID};model/iPhone10,3;addressid/0;appBuild/167668;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1`, - 'Accept-Language': 'zh-cn', - Referer: `https://shopmember.m.jd.com/shopcard/?venderId=${venderId}}&channel=801&returnUrl=${encodeURIComponent($.activityUrl)}`, - 'Accept-Encoding': 'gzip, deflate, br' - } - } - return new Promise(resolve => { - $.get(opt, (err, resp, data) => { - try { - if (err) { - console.log(err) - } else { - res = JSON.parse(data) - if (res.success) { - if (res.result.interestsRuleList) { - $.openCardActivityId = res.result.interestsRuleList[0].interestsInfo.activityId; - } - } - } - } catch (error) { - console.log(error) - } finally { - resolve(); - } - }) - - }) -} -function bindWithVender(body, venderId) { - let opt = { - url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body=${encodeURIComponent(JSON.stringify(body))}&client=H5&clientVersion=9.2.0&uuid=88888`, - headers: { - Host: 'api.m.jd.com', - Accept: '*/*', - Connection: 'keep-alive', - Cookie: cookie, - 'User-Agent': `jdapp;iPhone;9.5.4;13.6;${$.UUID};network/wifi;ADID/${$.ADID};model/iPhone10,3;addressid/0;appBuild/167668;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1`, - 'Accept-Language': 'zh-cn', - Referer: `https://shopmember.m.jd.com/shopcard/?venderId=${venderId}}&channel=401&returnUrl=${encodeURIComponent($.activityUrl)}`, - 'Accept-Encoding': 'gzip, deflate, br' - } - } - return new Promise(resolve => { - $.get(opt, (err, resp, data) => { - try { - if (err) { - console.log(err) - } else { - res = JSON.parse(data) - if (res.success) { - if (res.result.giftInfo && res.result.giftInfo.giftList) { - for (const vo of res.result.giftInfo.giftList) { - if (vo.prizeType === 4) { - $.log(`==>获得【${vo.quantity}】京豆`) - $.bean += vo.quantity - } - } - } - } - } - } catch (error) { - console.log(error) - } finally { - resolve(); - } - }) - - }) -} - -function getAuthorCodeList(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" - } - }; - $.get(options, async (err, resp, data) => { - try { - if (err) { - // $.log(err) - $.getAuthorCodeListerr = false - } else { - if (data) data = JSON.parse(data) - $.getAuthorCodeListerr = true - } - } catch (e) { - $.logErr(e, resp) - data = null; - } finally { - resolve(data); - } - }) - }) -} - -function taskUrl(function_id, body, isCommon) { - return { - url: isCommon ? `https://lzdz1-isv.isvjcloud.com/${function_id}` : `https://lzdz1-isv.isvjcloud.com/dingzhi/${function_id}`, - headers: { - Host: 'lzdz1-isv.isvjcloud.com', - Accept: 'application/json', - 'X-Requested-With': 'XMLHttpRequest', - 'Accept-Language': 'zh-cn', - 'Accept-Encoding': 'gzip, deflate, br', - 'Content-Type': 'application/x-www-form-urlencoded', - Origin: 'https://lzdz1-isv.isvjcloud.com', - 'User-Agent': `jdapp;iPhone;9.5.4;13.6;${$.UUID};network/wifi;ADID/${$.ADID};model/iPhone10,3;addressid/0;appBuild/167668;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1`, - Connection: 'keep-alive', - Referer: $.activityUrl, - Cookie: cookie - }, - body: body - - } -} - -function getMyPing() { - let opt = { - url: `https://lzdz1-isv.isvjcloud.com/customer/getMyPing`, - headers: { - Host: 'lzdz1-isv.isvjcloud.com', - Accept: 'application/json', - 'X-Requested-With': 'XMLHttpRequest', - 'Accept-Language': 'zh-cn', - 'Accept-Encoding': 'gzip, deflate, br', - 'Content-Type': 'application/x-www-form-urlencoded', - Origin: 'https://lzdz1-isv.isvjcloud.com', - 'User-Agent': `jdapp;iPhone;9.5.4;13.6;${$.UUID};network/wifi;ADID/${$.ADID};model/iPhone10,3;addressid/0;appBuild/167668;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1`, - Connection: 'keep-alive', - Referer: $.activityUrl, - Cookie: cookie, - }, - body: `userId=${$.activityShopId}&token=${$.token}&fromType=APP&riskType=1` - } - return new Promise(resolve => { - $.post(opt, (err, resp, data) => { - try { - if (err) { - $.log(err) - } else { - if (resp['headers']['set-cookie']) { - cookie = `${originCookie}` - if ($.isNode()) { - for (let sk of resp['headers']['set-cookie']) { - cookie = `${cookie}${sk.split(";")[0]};` - } - } else { - for (let ck of resp['headers']['Set-Cookie'].split(',')) { - cookie = `${cookie}${ck.split(";")[0]};` - } - } - } - if (resp['headers']['Set-Cookie']) { - cookie = `${originCookie}` - if ($.isNode()) { - for (let sk of resp['headers']['set-cookie']) { - cookie = `${cookie}${sk.split(";")[0]};` - } - } else { - for (let ck of resp['headers']['Set-Cookie'].split(',')) { - cookie = `${cookie}${ck.split(";")[0]};` - } - } - } - if (data) { - data = JSON.parse(data) - if (data.result) { - $.log(`你好:${data.data.nickname}`) - $.pin = data.data.nickname; - $.secretPin = data.data.secretPin; - cookie = `${cookie};AUTH_C_USER=${data.data.secretPin}` - } else { - $.log(data.errorMessage) - } - } else { - $.log("京东返回了空数据") - } - } - } catch (error) { - $.log(error) - } finally { - resolve(); - } - - }) - }) -} -function getFirstLZCK() { - return new Promise(resolve => { - $.get({ url: $.activityUrl }, (err, resp, data) => { - try { - if (err) { - console.log(err) - } else { - if (resp['headers']['set-cookie']) { - cookie = `${originCookie}` - if ($.isNode()) { - for (let sk of resp['headers']['set-cookie']) { - cookie = `${cookie}${sk.split(";")[0]};` - } - } else { - for (let ck of resp['headers']['Set-Cookie'].split(',')) { - cookie = `${cookie}${ck.split(";")[0]};` - } - } - } - if (resp['headers']['Set-Cookie']) { - cookie = `${originCookie}` - if ($.isNode()) { - for (let sk of resp['headers']['set-cookie']) { - cookie = `${cookie}${sk.split(";")[0]};` - } - } else { - for (let ck of resp['headers']['Set-Cookie'].split(',')) { - cookie = `${cookie}${ck.split(";")[0]};` - } - } - } - } - } catch (error) { - console.log(error) - } finally { - resolve(); - } - }) - }) -} -function getToken() { - let opt = { - url: `https://api.m.jd.com/client.action?functionId=isvObfuscator`, - headers: { - Host: 'api.m.jd.com', - 'Content-Type': 'application/x-www-form-urlencoded', - Accept: '*/*', - Connection: 'keep-alive', - Cookie: cookie, - 'User-Agent': 'JD4iPhone/167650 (iPhone; iOS 13.7; Scale/3.00)', - 'Accept-Language': 'zh-Hans-CN;q=1', - 'Accept-Encoding': 'gzip, deflate, br', - }, - body: `body=%7B%22url%22%3A%20%22https%3A//lzkj-isv.isvjcloud.com%22%2C%20%22id%22%3A%20%22%22%7D&uuid=hjudwgohxzVu96krv&client=apple&clientVersion=9.4.0&st=1620476162000&sv=111&sign=f9d1b7e3b943b6a136d54fe4f892af05` - } - return new Promise(resolve => { - $.post(opt, (err, resp, data) => { - try { - if (err) { - $.log(err) - } else { - if (data) { - data = JSON.parse(data); - if (data.code === "0") { - $.token = data.token - } - } else { - $.log("京东返回了空数据") - } - } - } catch (error) { - $.log(error) - } finally { - resolve(); - } - }) - }) -} -function random(min, max) { - - return Math.floor(Math.random() * (max - min)) + min; - -} -function getUUID(format = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', UpperCase = 0) { - return format.replace(/[xy]/g, function (c) { - var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8); - if (UpperCase) { - uuid = v.toString(36).toUpperCase(); - } else { - uuid = v.toString(36) - } - return uuid; - }); -} -function checkCookie() { - 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": "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", - "Accept-Language": "zh-cn", - "Referer": "https://home.m.jd.com/myJd/newhome.action?sceneval=2&ufc=&", - "Accept-Encoding": "gzip, deflate, br", - } - }; - return new Promise(resolve => { - $.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.hasOwnProperty("userInfo")) { - $.nickName = data.data.userInfo.baseInfo.nickname; - } - } else { - $.log('京东返回了空数据'); - } - } - } catch (e) { - $.logErr(e) - } finally { - resolve(); - } - }) - }) -} -// 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 << 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) } $.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) } diff --git a/jd_lzdz1_league.js b/jd_lzdz1_league.js deleted file mode 100644 index 754844e..0000000 --- a/jd_lzdz1_league.js +++ /dev/null @@ -1,589 +0,0 @@ -/** -瓜分千万京豆 免费抽大奖 - -https://lzdz1-isv.isvjcloud.com/dingzhi/shop/league/activity/6758593?activityId=dz220107100001616201shop&shareUuid=1d0d5fd0a72f4f9cb43f3c0ee722c19e -**/ - -const $ = new Env("瓜分千万京豆 免费抽大奖"); -const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; -const notify = $.isNode() ? require('./sendNotify') : ''; -let cookiesArr = [], cookie = '', message = ''; -let ownCode = null; -if ($.isNode()) { - Object.keys(jdCookieNode).forEach((item) => { - cookiesArr.push(jdCookieNode[item]) - }) - if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => { }; -} else { - let cookiesData = $.getdata('CookiesJD') || "[]"; - cookiesData = JSON.parse(cookiesData); - cookiesArr = cookiesData.map(item => item.cookie); - cookiesArr.reverse(); - cookiesArr.push(...[$.getdata('CookieJD2'), $.getdata('CookieJD')]); - cookiesArr.reverse(); - cookiesArr = cookiesArr.filter(item => !!item); -} -!(async () => { - $.getAuthorCodeListerr = false - 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; - } - - authorCodeList = await getAuthorCodeList('https://gitee.com/fatelight/code/raw/master/lzdz1_league.json') - if($.getAuthorCodeListerr === false){ - authorCodeList = [ - '1d0d5fd0a72f4f9cb43f3c0ee722c19e', - ] - } - for (let i = 0; i < cookiesArr.length; i++) { - if (cookiesArr[i]) { - cookie = cookiesArr[i] - originCookie = cookiesArr[i] - newCookie = '' - $.UserName = decodeURIComponent(cookie.match(/pt_pin=(.+?);/) && cookie.match(/pt_pin=(.+?);/)[1]) - $.index = i + 1; - $.isLogin = true; - $.nickName = ''; - await checkCookie(); - console.log(`\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); - if (!$.isLogin) { - console.log('更新ck'); - continue - } - $.bean = 0; - $.ADID = getUUID('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', 1); - $.UUID = getUUID('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'); - // $.authorCode = authorCodeList[random(0, authorCodeList.length)] - $.authorCode = ownCode ? ownCode : authorCodeList[random(0, authorCodeList.length)] - $.authorNum = `${random(1000000, 9999999)}` - $.activityId = 'dz220107100001616201shop' - $.activityShopId = '1000074823' - $.activityUrl = `https://lzdz1-isv.isvjcloud.com/dingzhi/shop/league/activity?activityId=${$.activityId}&shareUuid=${encodeURIComponent($.authorCode)}&adsource=null&shareuserid4minipg=null&shopid=${$.activityShopId}&lng=00.000000&lat=00.000000&sid=&un_area=` - await superFans(); - - if ($.bean > 0) { - message += `\n【京东账号${$.index}】${$.nickName || $.UserName} \n └ 获得 ${$.bean} 京豆。` - } - } - } - if (message !== '') { - if ($.isNode()) { - await notify.sendNotify($.name, message, '', `\n`); - } else { - $.msg($.name, '有点儿收获', message); - } - } -})() - .catch((e) => { - $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') - }) - .finally(() => { - $.done(); - }) - - -async function superFans() { - $.token = null; - $.secretPin = null; - $.openCardActivityId = null - await getFirstLZCK() - await getToken(); - await task('dz/common/getSimpleActInfoVo', `activityId=${$.activityId}`, 1) - if ($.token) { - await getMyPing(); - if ($.secretPin) { - console.log("去助力 -> "+$.authorCode) - await task("taskact/common/drawContent", `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}`) - await task('common/accessLogWithAD', `venderId=${$.activityShopId}&code=99&pin=${encodeURIComponent($.secretPin)}&activityId=${$.activityId}&pageUrl=${$.activityUrl}&subType=app&adSource=null`, 1); - await task('wxActionCommon/getUserInfo', `pin=${encodeURIComponent($.secretPin)}`, 1) - await task('shop/league/activityContent', `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}&pinImg=${encodeURIComponent($.pinImg)}&nick=${encodeURIComponent($.pin)}&cjyxPin=&cjhyPin=&shareUuid=${encodeURIComponent($.authorCode)}`) - if ($.activityContent) { - await task('shop/league/checkOpenCard', `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}&shareUuid=${encodeURIComponent($.authorCode)}&actorUuid=${$.actorUuid}`) - $.log("\n关注店铺") - if (!$.activityContent['followShop'].allStatus) { - await task('shop/league/saveTask', `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}&actorUuid=${$.actorUuid}&shareUuid=${encodeURIComponent($.authorCode)}&taskType=1&taskValue=1`) - } else { - $.log("已经关注过了\n") - await $.wait(2000); - return - } - $.log("\n加入店铺会员"); - if ($.openCardStatus) { - taskList = $.openCardStatus.cardList.filter((x) => !x.status); - console.log(taskList.length) - for (const vo of taskList) { - $.log(`去加入${vo.name}`); - if (vo.value === vo.value2) { - await bindWithVender( - { - venderId: `${vo.value}`, - bindByVerifyCodeFlag: 1, - registerExtend: {}, - writeChildFlag: 0, - activityId: $.openCardActivityId, - channel: 401, - }, - vo.value - ); - } else { - await bindWithVender( - { - venderId: `${vo.value}`, - shopId: `${vo.value2}`, - bindByVerifyCodeFlag: 1, - registerExtend: {}, - writeChildFlag: 0, - activityId: $.openCardActivityId, - channel: 401, - }, - vo.value - ); - } - await $.wait(1000); - await getFirstLZCK() - await task( - "shop/league/checkOpenCard", - `activityId=${$.activityId}&actorUuid=${$.actorUuid}&shareUuid=${$.authorCode - }&pin=${encodeURIComponent($.secretPin)}` - ); - await $.wait(1000); - } - await getFirstLZCK() - $.log("\n加入购物车") - if (!$.activityContent['addSku'].allStatus) { - await task('shop/league/saveTask', `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}&actorUuid=${$.actorUuid}&shareUuid=${encodeURIComponent($.authorCode)}&taskType=2&taskValue=2`) - } else { - $.log("已经关注过了\n") - } - - $.log("\c抽奖") - await task('shop/league/startDraw', `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}&actorUuid=${$.actorUuid}`) - } else { - $.log("没有获取到对应的任务。\n"); - } - } else { - $.log("无法顺利的获取到活动信息。") - } - } else { - $.log("没有成功获取到用户信息") - } - } else { - $.log("没有成功获取到用户鉴权信息") - } -} - -function task(function_id, body, isCommon = 0) { - return new Promise(resolve => { - $.post(taskUrl(function_id, body, isCommon), async (err, resp, data) => { - try { - if (err) { - $.log(err) - } else { - - if (data) { - data = JSON.parse(data); - if (data.result) { - switch (function_id) { - case 'dz/common/getSimpleActInfoVo': - $.jdActivityId = data.data.jdActivityId; - $.venderId = data.data.venderId; - // console.log($.venderId) - break; - case 'wxActionCommon/getUserInfo': - if (data.data.yunMidImageUrl) { - // if ($.index === 1) { - // ownCode['pinImg'] = data.data.yunMidImageUrl - // ownCode['nickname'] = data.data.nickname - // } - $.pinImg = data.data.yunMidImageUrl - } else { - // if ($.index === 1) { - // ownCode['pinImg'] = 'https://img10.360buyimg.com/imgzone/jfs/t1/7020/27/13511/6142/5c5138d8E4df2e764/5a1216a3a5043c5d.png' - // ownCode['nickname'] = data.data.nickname - // } - $.pinImg = 'https://img10.360buyimg.com/imgzone/jfs/t1/7020/27/13511/6142/5c5138d8E4df2e764/5a1216a3a5043c5d.png' - } - break; - case 'shop/league/activityContent': - if (!data.data.hasEnd) { - $.log(`开启【${data.data.activityName}】活动`) - $.log("-------------------") - if ($.index === 1) { - ownCode = data.data.actorUuid - console.log("你的助力码 -> "+ownCode) - } - $.activityContent = data.data; - $.actorUuid = data.data.actorUuid; - } else { - $.log("活动已经结束"); - } - break; - case 'shop/league/checkOpenCard': - $.openCardStatus = data.data; - break; - case 'shop/league/startDraw': - console.log(data.data) - break; - case 'shop/league/saveTask': - if (data.data) { - if (data.data.addBeanNum) { - $.bean += data.data.addBeanNum; - $.log(`获得【${data.data.addBeanNum}】京豆\n`) - } - if (data.data.addScore) { - $.log(`获得【${data.data.addScore}】积分\n`) - } - } - break; - default: - $.log(JSON.stringify(data)) - break; - } - } else { - $.log(JSON.stringify(data)) - } - } - } - } catch (error) { - $.log(error) - } finally { - resolve(); - } - }) - }) -} -function getShopOpenCardInfo(body, venderId) { - let opt = { - url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body=${encodeURIComponent(JSON.stringify(body))}&client=H5&clientVersion=9.2.0&uuid=88888`, - headers: { - Host: 'api.m.jd.com', - Accept: '*/*', - Connection: 'keep-alive', - Cookie: cookie, - 'User-Agent': `jdapp;iPhone;9.5.4;13.6;${$.UUID};network/wifi;ADID/${$.ADID};model/iPhone10,3;addressid/0;appBuild/167668;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1`, - 'Accept-Language': 'zh-cn', - Referer: `https://shopmember.m.jd.com/shopcard/?venderId=${venderId}}&channel=801&returnUrl=${encodeURIComponent($.activityUrl)}`, - 'Accept-Encoding': 'gzip, deflate, br' - } - } - return new Promise(resolve => { - $.get(opt, (err, resp, data) => { - try { - if (err) { - console.log(err) - } else { - res = JSON.parse(data) - if (res.success) { - if (res.result.interestsRuleList) { - $.openCardActivityId = res.result.interestsRuleList[0].interestsInfo.activityId; - } - } - } - } catch (error) { - console.log(error) - } finally { - resolve(); - } - }) - - }) -} -function bindWithVender(body, venderId) { - let opt = { - url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body=${encodeURIComponent(JSON.stringify(body))}&client=H5&clientVersion=9.2.0&uuid=88888`, - headers: { - Host: 'api.m.jd.com', - Accept: '*/*', - Connection: 'keep-alive', - Cookie: cookie, - 'User-Agent': `jdapp;iPhone;9.5.4;13.6;${$.UUID};network/wifi;ADID/${$.ADID};model/iPhone10,3;addressid/0;appBuild/167668;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1`, - 'Accept-Language': 'zh-cn', - Referer: `https://shopmember.m.jd.com/shopcard/?venderId=${venderId}}&channel=801&returnUrl=${encodeURIComponent($.activityUrl)}`, - 'Accept-Encoding': 'gzip, deflate, br' - } - } - return new Promise(resolve => { - $.get(opt, (err, resp, data) => { - try { - if (err) { - console.log(err) - } else { - res = JSON.parse(data) - if (res.success) { - console.log(res) - // if (res.result.giftInfo && res.result.giftInfo.giftList) { - // for (const vo of res.result.giftInfo.giftList) { - // if (vo.prizeType === 4) { - // $.log(`获得【${vo.quantity}】京豆`) - // $.bean += vo.quantity - // } - // } - // } - } - } - } catch (error) { - console.log(error) - } finally { - resolve(); - } - }) - - }) -} -function taskUrl(function_id, body, isCommon) { - return { - url: isCommon ? `https://lzdz1-isv.isvjcloud.com/${function_id}` : `https://lzdz1-isv.isvjcloud.com/dingzhi/${function_id}`, - headers: { - Host: 'lzdz1-isv.isvjcloud.com', - Accept: 'application/json', - 'X-Requested-With': 'XMLHttpRequest', - 'Accept-Language': 'zh-cn', - 'Accept-Encoding': 'gzip, deflate, br', - 'Content-Type': 'application/x-www-form-urlencoded', - Origin: 'https://lzdz1-isv.isvjcloud.com', - 'User-Agent': `jdapp;iPhone;9.5.4;13.6;${$.UUID};network/wifi;ADID/${$.ADID};model/iPhone10,3;addressid/0;appBuild/167668;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1`, - Connection: 'keep-alive', - Referer: $.activityUrl, - Cookie: cookie - }, - body: body - - } -} - -function getMyPing() { - let opt = { - url: `https://lzdz1-isv.isvjcloud.com/customer/getMyPing`, - headers: { - Host: 'lzdz1-isv.isvjcloud.com', - Accept: 'application/json', - 'X-Requested-With': 'XMLHttpRequest', - 'Accept-Language': 'zh-cn', - 'Accept-Encoding': 'gzip, deflate, br', - 'Content-Type': 'application/x-www-form-urlencoded', - Origin: 'https://lzdz1-isv.isvjcloud.com', - 'User-Agent': `jdapp;iPhone;9.5.4;13.6;${$.UUID};network/wifi;ADID/${$.ADID};model/iPhone10,3;addressid/0;appBuild/167668;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1`, - Connection: 'keep-alive', - Referer: $.activityUrl, - Cookie: cookie, - }, - body: `userId=${$.activityShopId}&token=${$.token}&fromType=APP&riskType=1` - } - return new Promise(resolve => { - $.post(opt, (err, resp, data) => { - try { - if (err) { - $.log(err) - } else { - if (resp['headers']['set-cookie']) { - cookie = `${originCookie}` - if ($.isNode()) { - for (let sk of resp['headers']['set-cookie']) { - cookie = `${cookie}${sk.split(";")[0]};` - } - } else { - for (let ck of resp['headers']['Set-Cookie'].split(',')) { - cookie = `${cookie}${ck.split(";")[0]};` - } - } - } - if (resp['headers']['Set-Cookie']) { - cookie = `${originCookie}` - if ($.isNode()) { - for (let sk of resp['headers']['set-cookie']) { - cookie = `${cookie}${sk.split(";")[0]};` - } - } else { - for (let ck of resp['headers']['Set-Cookie'].split(',')) { - cookie = `${cookie}${ck.split(";")[0]};` - } - } - } - if (data) { - data = JSON.parse(data) - if (data.result) { - $.log(`你好:${data.data.nickname}`) - $.pin = data.data.nickname; - $.secretPin = data.data.secretPin; - cookie = `${cookie};AUTH_C_USER=${data.data.secretPin}` - } else { - $.log(data.errorMessage) - } - } else { - $.log("京东返回了空数据") - } - } - } catch (error) { - $.log(error) - } finally { - resolve(); - } - - }) - }) -} - -function getAuthorCodeList(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" - } - }; - $.get(options, async (err, resp, data) => { - try { - if (err) { - // $.log(err) - $.getAuthorCodeListerr = false - } else { - if (data) data = JSON.parse(data) - $.getAuthorCodeListerr = true - } - } catch (e) { - $.logErr(e, resp) - data = null; - } finally { - resolve(data); - } - }) - }) -} -function getFirstLZCK() { - return new Promise(resolve => { - $.get({ url: $.activityUrl }, (err, resp, data) => { - try { - if (err) { - console.log(err) - } else { - if (resp['headers']['set-cookie']) { - cookie = `${originCookie}` - if ($.isNode()) { - for (let sk of resp['headers']['set-cookie']) { - cookie = `${cookie}${sk.split(";")[0]};` - } - } else { - for (let ck of resp['headers']['Set-Cookie'].split(',')) { - cookie = `${cookie}${ck.split(";")[0]};` - } - } - } - if (resp['headers']['Set-Cookie']) { - cookie = `${originCookie}` - if ($.isNode()) { - for (let sk of resp['headers']['set-cookie']) { - cookie = `${cookie}${sk.split(";")[0]};` - } - } else { - for (let ck of resp['headers']['Set-Cookie'].split(',')) { - cookie = `${cookie}${ck.split(";")[0]};` - } - } - } - } - } catch (error) { - console.log(error) - } finally { - resolve(); - } - }) - }) -} -function getToken() { - let opt = { - url: `https://api.m.jd.com/client.action?functionId=isvObfuscator`, - headers: { - Host: 'api.m.jd.com', - 'Content-Type': 'application/x-www-form-urlencoded', - Accept: '*/*', - Connection: 'keep-alive', - Cookie: cookie, - 'User-Agent': 'JD4iPhone/167650 (iPhone; iOS 13.7; Scale/3.00)', - 'Accept-Language': 'zh-Hans-CN;q=1', - 'Accept-Encoding': 'gzip, deflate, br', - }, - body: `body=%7B%22url%22%3A%20%22https%3A//lzkj-isv.isvjcloud.com%22%2C%20%22id%22%3A%20%22%22%7D&uuid=hjudwgohxzVu96krv&client=apple&clientVersion=9.4.0&st=1620476162000&sv=111&sign=f9d1b7e3b943b6a136d54fe4f892af05` - } - return new Promise(resolve => { - $.post(opt, (err, resp, data) => { - try { - if (err) { - $.log(err) - } else { - if (data) { - data = JSON.parse(data); - if (data.code === "0") { - $.token = data.token - } - } else { - $.log("京东返回了空数据") - } - } - } catch (error) { - $.log(error) - } finally { - resolve(); - } - }) - }) -} -function random(min, max) { - - return Math.floor(Math.random() * (max - min)) + min; - -} -function getUUID(format = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', UpperCase = 0) { - return format.replace(/[xy]/g, function (c) { - var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8); - if (UpperCase) { - uuid = v.toString(36).toUpperCase(); - } else { - uuid = v.toString(36) - } - return uuid; - }); -} -function checkCookie() { - 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": "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", - "Accept-Language": "zh-cn", - "Referer": "https://home.m.jd.com/myJd/newhome.action?sceneval=2&ufc=&", - "Accept-Encoding": "gzip, deflate, br", - } - }; - return new Promise(resolve => { - $.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.hasOwnProperty("userInfo")) { - $.nickName = data.data.userInfo.baseInfo.nickname; - } - } else { - $.log('京东返回了空数据'); - } - } - } catch (e) { - $.logErr(e) - } finally { - resolve(); - } - }) - }) -} -// 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 << 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) } $.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) } diff --git a/jd_mengniu.js b/jd_mengniu.js index 6e06bd6..5573321 100644 --- a/jd_mengniu.js +++ b/jd_mengniu.js @@ -48,7 +48,7 @@ if ($.isNode()) { } continue } - authorCodeList = ['1fc26ba85abe4d7fa8024c9917163442','efa6d50b6d32488ba485f07629ff6c99','8a0d5f341e8440e2aa04a1592cd3f1b3'] + authorCodeList = ['336fe9c225674104bed22b169c820190'] $.bean = 0; $.ADID = getUUID('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', 1); $.UUID = getUUID('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'); diff --git a/jd_mpdzcar.js b/jd_mpdzcar.js new file mode 100755 index 0000000..b9c897b --- /dev/null +++ b/jd_mpdzcar.js @@ -0,0 +1,236 @@ +/* +TG https://t.me/duckjobs + +活动入口:京东汽车 - 右下角 - 领京豆 +先跑积分,不要问为什么分开😂 + +10 8 * * * jd_mpdzcar.js +*/ +const $ = new Env("头文子J"); +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const notify = $.isNode() ? require('./sendNotify') : ''; +let cookiesArr = [], cookie = '' +actId = "1760007"; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => { }; +} else { + let cookiesData = $.getdata('CookiesJD') || "[]"; + cookiesData = JSON.parse(cookiesData); + cookiesArr = cookiesData.map(item => item.cookie); + cookiesArr.reverse(); + cookiesArr.push(...[$.getdata('CookieJD2'), $.getdata('CookieJD')]); + cookiesArr.reverse(); + cookiesArr = cookiesArr.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; + } + console.log("等待初始化任务..."+"\n活动入口:京东汽车 - 右下角 - 领京豆"+"\n请求太快容易繁忙,默认延迟5-10s"); + UUID = getUUID('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'); + for (let i = 0; i < cookiesArr.length; i++) { + UA = `jdapp;iPhone;10.1.6;13.5;${UUID};network/wifi;model/iPhone11,6;addressid/4596882376;appBuild/167841;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1`; + if (cookiesArr[i]) { + cookie = cookiesArr[i]; + $.UserName = decodeURIComponent(cookie.match(/pt_pin=(.+?);/) && cookie.match(/pt_pin=(.+?);/)[1]) + $.index = i + 1; + $.isLogin = true; + $.nickName = ''; + $.hotFlag = false; + 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 main(); + } + } +})().catch((e) => { $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') }).finally(() => { $.done(); }) + +async function main() { + $.token = ''; + await getToken(); + if ($.token) { + await taskPost('getFansInfo', { "data": $.token, "source": "01", "actId": actId }) + if ($.buyerNick) { + await taskPost('loadUnitedCardActivityInfo', { "actId": actId, "buyerNick": $.buyerNick }) + await taskPost('loadSignInState', { "actId": actId, "buyerNick": $.buyerNick }) + await $.wait(5000); + if ($.signInDay) { + $.log('去签到.. 第 '+$.signInDay+ '天') + await taskPost('signGetEnergy', { "actId": actId, "buyerNick": $.buyerNick, "energyValue": 100, "day": $.signInDay }) + + } + for (let i = 0; i < 3; i++) { + await $.wait(5000); + await taskPost('loadShopGroup', { "actId": actId, "buyerNick": $.buyerNick, "shopGroupType": "favouriteShop"}) + if ($.shopId) { + await $.wait(5000); + $.log('关注品牌店铺.. '+$.shopId) + await taskPost('favouriteShopSingle', { "actId": actId, "buyerNick": $.buyerNick, "shopId": $.shopId}) + } + } + $.log('浏览.. ') + await taskPost('participantBehavior', { "actId": actId, "buyerNick": $.buyerNick,"behavior":"browseShop"}) + await $.wait(5000); + await taskPost('participantBehavior', { "actId": actId, "buyerNick": $.buyerNick,"behavior":"carSelection"}) + await $.wait(5000); + await taskPost('participantBehavior', { "actId": actId, "buyerNick": $.buyerNick,"behavior":"refueling"}) + for (let i = 0; i < 3; i++) { + await $.wait(5000); + await taskPost('participantBehavior', { "actId": actId, "buyerNick": $.buyerNick,"behavior":"browseItem"}) + } + for (let i = 0; i < 3; i++) { + await $.wait(5000); + await taskPost('loadItemGroup', { "actId": actId, "buyerNick": $.buyerNick, "itemGroupType": "browseItem"}) + if ($.shopId) { + await $.wait(10000); + $.log('加购车.. '+$.shopId) + await taskPost('addItemSingle', { "actId": actId, "buyerNick": $.buyerNick, "itemId": $.itemId, "shopId": $.shopId}) + } + } + } else { + $.log("没有获取到用户信息") + } + } else { + $.log("没有成功获取到用户鉴权信息"); + } +} +function taskPost(function_id, body = {}) { + return new Promise(async resolve => { + $.post(taskPostUrl(function_id, body), async (err, resp, data) => { + try { + if (data) { + data = JSON.parse(data); + if (data) { + switch (function_id) { + case 'getFansInfo': + if (data.succ) { + $.buyerNick = data.msg; + } + break; + case 'loadUnitedCardActivityInfo': + break; + case 'loadSignInState': + if (data.succ) { + $.signInDay = data.data.signInDay; + break; + } + case 'signGetEnergy': + if (data.succ) { + console.log(data.msg); + } else { + console.log(data.errorMsg); + } + break; + case 'getMarketExchangeData': + if (data.succ) { + $.exchangelist = data.data; + } + break; + case 'loadShopGroup': + if (data.succ) { + $.shopId = data.data.shopId; + } + break; + case 'loadItemGroup': + if (data.succ) { + $.itemId = data.data.itemId; + $.shopId = data.data.shopId; + } + break; + case 'favouriteShopSingle': + if (data.succ) { + $.shopId = data.msg; + } + break; + case 'participantBehavior': + if (data.succ) { + $.shopId = data.msg; + } + break; + default: + $.log(JSON.stringify(data)) + break; + } + } else { + $.log(JSON.stringify(data)) + } + } + } catch (error) { + $.log(error) + } finally { + resolve(); + } + }) + }) +} + +function taskPostUrl(function_id, body) { + return { + url: `https://mpdz-car-dz.isvjcloud.com/ql/front/${function_id}`, + body: JSON.stringify(body), + headers: { + "Host": "mpdz-car-dz.isvjcloud.com", + 'Content-Type': 'application/json; charset=utf-8', + "Origin": "https://mpdz-car-dz.isvjcloud.com", + "Accept-Encoding": "gzip, deflate, br", + "Connection": "keep-alive", + "Accept": "*/*", + "User-Agent": UA, + "Referer": "https://mpdz-car-dz.isvjcloud.com", + "Accept-Language": "zh-cn", + } + } +} + +function getToken() { + let opt = { + url: 'https://api.m.jd.com/client.action?functionId=isvObfuscator', + body: 'body=%7B%22url%22%3A%22https%3A//mpdz-car-dz.isvjcloud.com%22%2C%22id%22%3A%22%22%7D&uuid=dc7b67077d974365b49e479bf85a81c4&client=apple&clientVersion=9.4.0&st=1635355593000&sv=111&sign=8b67f42a305312dc59fe6f8a406e9a07', + headers: { + "Host": "api.m.jd.com", + "Content-Type": "application/x-www-form-urlencoded", + "Accept": "*/*", + "Connection": "keep-alive", + "User-Agent": "JD4iPhone/167541 (iPhone; iOS 13.5; Scale/3.00)", + "Accept-Encoding": "gzip, deflate, br", + "Cookie": cookie, + } + } + return new Promise(resolve => { + $.post(opt, (err, resp, data) => { + try { + if (err) { + console.log(err) + } else { + if (data) { + data = JSON.parse(data); + if (data.code === "0") { + $.token = data.token + } + } else { + $.log("京东返回了空数据") + } + } + } catch (error) { + $.log(error) + } finally { + resolve(); + } + }) + }) +} + +// prettier-ignore +function getUUID(x = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", t = 0) { return x.replace(/[xy]/g, function (x) { var r = 16 * Math.random() | 0, n = "x" == x ? r : 3 & r | 8; return uuid = t ? n.toString(36).toUpperCase() : n.toString(36), uuid }) } +function TotalBean() { return new Promise(async e => { const n = { url: "https://wq.jd.com/user_new/info/GetJDUserInfoUnion?sceneval=2", headers: { Host: "wq.jd.com", Accept: "*/*", Connection: "keep-alive", Cookie: cookie, "User-Agent": UA, "Accept-Language": "zh-cn", Referer: "https://home.m.jd.com/myJd/newhome.action?sceneval=2&ufc=&", "Accept-Encoding": "gzip, deflate, br" } }; $.get(n, (n, o, a) => { try { if (n) $.logErr(n); else if (a) { if (1001 === (a = JSON.parse(a))["retcode"]) return void ($.isLogin = !1); 0 === a["retcode"] && a.data && a.data.hasOwnProperty("userInfo") && ($.nickName = a.data.userInfo.baseInfo.nickname), 0 === a["retcode"] && a.data && a.data["assetInfo"] && ($.beanCount = a.data && a.data["assetInfo"]["beanNum"]) } else console.log("京东服务器返回空数据") } catch (e) { $.logErr(e) } finally { e() } }) }) } +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_redPacket_help.js b/jd_redPacket_help.js index 77b661d..5114e6b 100644 --- a/jd_redPacket_help.js +++ b/jd_redPacket_help.js @@ -14,7 +14,7 @@ const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; //IOS等用户直接用NobyDa的jd cookie let cookiesArr = [], cookie = ''; let isLoginInfo = {} -let helpnum=1 +let helpnum=3 $.redPacketId = []; if ($.isNode()) { Object.keys(jdCookieNode).forEach((item) => {