diff --git a/jd_fan.js b/jd_fan.js index d4ee74c..882bfa7 100644 --- a/jd_fan.js +++ b/jd_fan.js @@ -1,20 +1,21 @@ -/* - 粉丝互动 - cron 10 1 * * * https://raw.githubusercontent.com/star261/jd/main/scripts/jd_fan.js - 蚊子腿活动,不定时更新 - 环境变量:RUHUI,是否自动入会,开卡算法已失效,默认不开卡了 - 环境变量:RUNCK,执行多少CK,默认全执行,设置RUNCK=10,则脚本只会运行前10个CK -* */ -const $ = new Env('粉丝互动-加密'); -const notify = $.isNode() ? require('./sendNotify') : ''; +/** + 粉丝互动,尽量自己设置定时,在0点和1点抽奖,白天基本没水 + 注意:脚本会加购,脚本会加购,脚本会加购 + cron "10 0 * * *" jd_fan.js + * */ +const $ = new Env('粉丝互动'); const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; -const RUHUI = '888' -const RUNCK = $.isNode() ? (process.env.RUNCK ? process.env.RUNCK : `9999`):`9999`; -let cookiesArr = [],message = ''; +const notify = $.isNode() ? require('./sendNotify') : ''; +let cookiesArr = []; + +const activityList = [ + {'id':'f1c859ad23124013a17cfd8e8791f160','endTime':1656626274000},// +] + 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 = [ @@ -22,710 +23,527 @@ if ($.isNode()) { $.getdata("CookieJD2"), ...$.toObj($.getdata("CookiesJD") || "[]").map((item) => item.cookie)].filter((item) => !!item); } -let activityList = [ - {'id':'cebd38c28cf0468c8082082eebde4c32','endTime':1656626274000},// - {'id':'c88ffa4a17b04cc994a6e66f161471','endTime':1656626274000},// - {'id':'4f49c21967e24e62aa60efc28b015c82','endTime':1656626274000},// - -]; -!(async()=>{ - activityList=getRandomArrayElements(activityList,activityList.length); - $.helpFalg=true; - for(let _0x2e674b=0;_0x2e674b{ - $.log('','❌ '+$.name+', 失败! 原因: '+_0xce13bb+'!',''); -}).finally(()=>{ - $.done(); -}); -async function main(_0x3f7ec5){ - _0x3f7ec5.cookiesArr=cookiesArr; - message=''; - _0x3f7ec5.activityId=getUrlData(_0x3f7ec5.thisActivityUrl,'activityId'); - _0x3f7ec5.runFlag=true; - if(_0x3f7ec5.helpFalg){ - doInfo(); - }for(let _0x42703b=0;_0x42703b<_0x3f7ec5.cookiesArr.length&&(_0x42703b { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); + return; + } + if(!activityList.length){ + console.log(`\n没有活动,退出!!!`); + return; + } + for (let i = 0; i < cookiesArr.length; i++) { + await getUA(); + $.index = i + 1; + $.cookie = cookiesArr[i]; + $.oldcookie = cookiesArr[i]; + $.isLogin = true; + $.nickName = ''; + + $.UserName = decodeURIComponent($.cookie.match(/pt_pin=([^; ]+)(?=;?)/) && $.cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]); + console.log(`\n*****开始【京东账号${$.index}】${$.nickName || $.UserName}*****\n`); + + $.hotFlag = false; + for (let j = 0; j < activityList.length && !$.hotFlag; j++) { + $.activityInfo = activityList[j]; + $.activityID = $.activityInfo.id; + console.log(`互动ID:${JSON.stringify($.activityInfo)}`); + console.log(`活动地址:https://lzkjdz-isv.isvjcloud.com/wxFansInterActionActivity/activity/${$.activityID}?activityId=${$.activityID}`); + if($.activityInfo.endTime && Date.now() > $.activityInfo.endTime){ + console.log(`活动已结束\n`); + continue; + } + await main(); + await $.wait(2500); + console.log('\n') + } + } +})().catch((e) => {$.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '')}).finally(() => {$.done();}); + +async function main() { + $.token = ``; + await getToken(); + await $.wait(1500); + if($.token === ``){ + console.log(`获取token失败`);return; + } + console.log(`token:${$.token}`); + await $.wait(1000); + await getActCk(); + await $.wait(1500); + $.shopId = ``; + await takePostRequest('getSimpleActInfoVo'); + if($.shopid === ``){ + console.log(`获取shopid失败`);return; + } + console.log(`shopid:${$.shopid}`) + await $.wait(1000); + $.pin = ''; + await takePostRequest('getMyPing'); + if($.pin === ``){ + $.hotFlag = true; + console.log(`获取pin失败,该账号可能是黑号`);return; + } + $.cookie=$.cookie + `AUTH_C_USER=${$.pin}`; + await $.wait(1000); + await accessLogWithAD(); + $.cookie=$.cookie + `AUTH_C_USER=${$.pin}`; + await $.wait(1000); + $.activityData = {}; + $.actinfo = '';$.actorInfo='';$.nowUseValue = 0; + await takePostRequest('activityContent'); + if(JSON.stringify($.activityData) === `{}`){ + console.log(`获取活动详情失败`);return; + } + let date = new Date($.activityData.actInfo.endTime) + let endtime = date.getFullYear() + "-" + (date.getMonth() < 10 ? '0' + (date.getMonth() + 1) : (date.getMonth() + 1)) + "-" + (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + console.log(`${$.actinfo.actName},${$.actinfo.shopName},当前积分:${$.nowUseValue},结束时间:${endtime},${$.activityData.actInfo.endTime}`); + let gitList = []; + let gitTypeList = ['One','Two','Three']; + for (let i = 0; i < gitTypeList.length; i++) { + let gitInfo = $.activityData.actInfo['giftLevel'+ gitTypeList[i]] || ''; + if(gitInfo){ + gitInfo = JSON.parse(gitInfo); + gitList.push(gitInfo[0].name); + } + } + console.log(`奖品列表:` + gitList.toString()); + if($.actorInfo.prizeOneStatus && $.actorInfo.prizeTwoStatus && $.actorInfo.prizeThreeStatus){ + console.log(`已抽过所有奖品`);return; + } + await $.wait(1000); + $.memberInfo = {}; + await takePostRequest('getActMemberInfo'); + if($.memberInfo.actMemberStatus === 1 && !$.memberInfo.openCard){ + console.log(`\n====================该活动需要入会,如需执行,请先手动入会====================`);return ; + } + await $.wait(1000); + $.upFlag = false; + await doTask(); + await luckDraw();//抽奖 } -async function doInfo(){ - $.helpFalg=false; - for(let _0x32dca4=0;_0x32dca4= $.activityData.actConfig.prizeScoreOne && $.activityData.actorInfo.prizeOneStatus === false) { + console.log(`开始第一次抽奖`); + $.drawType = '01'; + await takePostRequest('startDraw'); + await $.wait(1000); + } + if (nowUseValue >= $.activityData.actConfig.prizeScoreTwo && $.activityData.actorInfo.prizeTwoStatus === false) { + console.log(`开始第二次抽奖`); + $.drawType = '02'; + await takePostRequest('startDraw'); + await $.wait(1000); + } + if (nowUseValue >= $.activityData.actConfig.prizeScoreThree && $.activityData.actorInfo.prizeThreeStatus === false) { + console.log(`开始第三次抽奖`); + $.drawType = '03'; + await takePostRequest('startDraw'); + await $.wait(1000); + } } -async function invite(_0x8baf4c,_0x3fd6b4){ - let _0x11b30c=Date.now(); - var _0x5156ef={ - 'Host':'api.m.jd.com','accept':'application/json, text/plain, */*','content-type':'application/x-www-form-urlencoded','origin':'https://invite-reward.jd.com','accept-language':'zh-cn','user-agent':$.isNode()?process.env.JS_USER_AGENT?process.env.JS_USER_AGENT:require('./JS_USER_AGENTS').USER_AGENT:$.getdata('JSUA')?$.getdata('JSUA'):'\'jdltapp;iPad;3.1.0;14.4;network/wifi;Mozilla/5.0 (iPad; CPU OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1','referer':'https://invite-reward.jd.com/','Cookie':_0x8baf4c - }; - var _0xd439b2='functionId=InviteFriendApiService&body={"method":"attendInviteActivity","data":{"inviterPin":"'+encodeURIComponent(_0x3fd6b4)+'","channel":1,"token":"","frontendInitStatus":""}}&referer=-1&eid=eidIf3dd8121b7sdmiBLGdxRR46OlWyh62kFAZogTJFnYqqRkwgr63%2BdGmMlcv7EQJ5v0HBic81xHXzXLwKM6fh3i963zIa7Ym2v5ehnwo2B7uDN92Q0&aid=&client=ios&clientVersion=14.4&networkType=wifi&fp=-1&appid=market-task-h5&_t='+_0x11b30c; - var _0x2ef366={'url':'https://api.m.jd.com/?t='+Date.now(),'headers':_0x5156ef,'body':_0xd439b2}; - $.post(_0x2ef366,(_0x2d0d4b,_0x2fae2e,_0x252f14)=>{}); +async function doTask(){ + $.runFalag = true; + if($.activityData.actorInfo && !$.activityData.actorInfo.follow){ + console.log(`关注店铺`); + await takePostRequest('followShop'); + await $.wait(2000); + $.upFlag = true; + }else{ + console.log('已关注') + } + if ($.activityData.task1Sign && $.activityData.task1Sign.finishedCount === 0 && $.runFalag) { + console.log(`执行每日签到`); + await takePostRequest('doSign'); + await $.wait(2000); + $.upFlag = true; + }else{ + console.log(`已签到`) + } + let needFinishNumber = 0; + //浏览货品任务 + if ($.activityData.task2BrowGoods && $.runFalag) { + if($.activityData.task2BrowGoods.finishedCount !== $.activityData.task2BrowGoods.upLimit){ + needFinishNumber = Number($.activityData.task2BrowGoods.upLimit) - Number($.activityData.task2BrowGoods.finishedCount); + console.log(`开始做浏览商品任务`); + $.upFlag = true; + for (let i = 0; i < $.activityData.task2BrowGoods.taskGoodList.length && needFinishNumber > 0 && $.runFalag; i++) { + $.oneGoodInfo = $.activityData.task2BrowGoods.taskGoodList[i]; + if ($.oneGoodInfo.finished === false) { + console.log(`浏览:${$.oneGoodInfo.skuName || ''}`) + await takePostRequest('doBrowGoodsTask'); + await $.wait(2000); + needFinishNumber--; + } + } + }else{ + console.log(`浏览商品任务已完成`) + } + } + //加购商品任务 + if($.activityData.task3AddCart && $.runFalag){ + if($.activityData.task3AddCart.finishedCount !== $.activityData.task3AddCart.upLimit){ + needFinishNumber = Number($.activityData.task3AddCart.upLimit) - Number($.activityData.task3AddCart.finishedCount); + console.log(`开始做加购商品任务`); + $.upFlag = true; + for (let i = 0; i < $.activityData.task3AddCart.taskGoodList.length && needFinishNumber > 0 && $.runFalag; i++) { + $.oneGoodInfo = $.activityData.task3AddCart.taskGoodList[i]; + if ($.oneGoodInfo.finished === false) { + console.log(`加购:${$.oneGoodInfo.skuName || ''}`) + await takePostRequest('doAddGoodsTask'); + await $.wait(5000); + needFinishNumber--; + } + } + }else{ + console.log(`加购商品已完成`) + } + } + //分享任务 + if ($.activityData.task4Share && $.runFalag) { + if($.activityData.task4Share.finishedCount !== $.activityData.task4Share.upLimit){ + needFinishNumber = Number($.activityData.task4Share.upLimit) - Number($.activityData.task4Share.finishedCount); + console.log(`开始做分享任务`); + $.upFlag = true; + for (let i = 0; i < needFinishNumber && $.runFalag; i++) { + console.log(`执行第${i+1}次分享`); + await takePostRequest('doShareTask'); + await $.wait(2000); + } + }else{ + console.log(`分享任务已完成`) + } + } + //设置活动提醒 + if ($.activityData.task5Remind && $.runFalag) { + if($.activityData.task5Remind.finishedCount !== $.activityData.task5Remind.upLimit){ + console.log(`执行设置活动提醒`); + $.upFlag = true; + await takePostRequest('doRemindTask'); + await $.wait(2000); + }else{ + console.log(`设置活动提醒已完成`) + } + } + //领取优惠券 + if ($.activityData.task6GetCoupon && $.runFalag) { + if($.activityData.task6GetCoupon.finishedCount !== $.activityData.task6GetCoupon.upLimit){ + needFinishNumber = Number($.activityData.task6GetCoupon.upLimit) - Number($.activityData.task6GetCoupon.finishedCount); + console.log(`开始做领取优惠券`); + $.upFlag = true; + for (let i = 0; i < $.activityData.task6GetCoupon.taskCouponInfoList.length && needFinishNumber > 0 && $.runFalag; i++) { + $.oneCouponInfo = $.activityData.task6GetCoupon.taskCouponInfoList[i]; + if ($.oneCouponInfo.finished === false) { + await takePostRequest('doGetCouponTask'); + await $.wait(2000); + needFinishNumber--; + } + } + }else{ + console.log(`领取优惠券已完成`) + } + } + //逛会场 + if ($.activityData.task7MeetPlaceVo && $.runFalag) { + if($.activityData.task7MeetPlaceVo.finishedCount !== $.activityData.task7MeetPlaceVo.upLimit){ + console.log(`执行逛会场`); + $.upFlag = true; + await takePostRequest('doMeetingTask'); + await $.wait(2000); + }else{ + console.log(`逛会场已完成`) + } + } + } -async function invite2(_0x36e51c,_0x97b630){ - let _0x577470=Date.now(); - let _0x24b1af={ - 'Host':'api.m.jd.com','accept':'application/json, text/plain, */*','content-type':'application/x-www-form-urlencoded','origin':'https://assignment.jd.com','accept-language':'zh-cn','user-agent':$.isNode()?process.env.JS_USER_AGENT?process.env.JS_USER_AGENT:require('./JS_USER_AGENTS').USER_AGENT:$.getdata('JSUA')?$.getdata('JSUA'):'\'jdltapp;iPad;3.1.0;14.4;network/wifi;Mozilla/5.0 (iPad; CPU OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1','referer':'https://assignment.jd.com/?inviterId='+encodeURIComponent(_0x97b630),'Cookie':_0x36e51c - }; - let _0x33c1bd='functionId=TaskInviteService&body={"method":"participateInviteTask","data":{"channel":"1","encryptionInviterPin":"'+encodeURIComponent(_0x97b630)+'","type":1}}&appid=market-task-h5&uuid=&_t='+_0x577470; - var _0x30d5e1={'url':'https://api.m.jd.com/','headers':_0x24b1af,'body':_0x33c1bd}; - $.post(_0x30d5e1,(_0x36a3f1,_0x5a5a0a,_0x1fe685)=>{}); + +async function takePostRequest(type){ + let url = ''; + let body = ``; + switch (type) { + case 'getSimpleActInfoVo': + url= 'https://lzkjdz-isv.isvjcloud.com/customer/getSimpleActInfoVo'; + body = `activityId=${$.activityID}`; + break; + case 'getMyPing': + url= 'https://lzkjdz-isv.isvjcloud.com/customer/getMyPing'; + body = `userId=${$.shopid}&token=${encodeURIComponent($.token)}&fromType=APP`; + break; + case 'activityContent': + url= 'https://lzkjdz-isv.isvjcloud.com/wxFansInterActionActivity/activityContent'; + body = `activityId=${$.activityID}&pin=${encodeURIComponent($.pin)}`; + break; + case 'getActMemberInfo': + url= 'https://lzkjdz-isv.isvjcloud.com/wxCommonInfo/getActMemberInfo'; + body = `venderId=${$.shopid}&activityId=${$.activityID}&pin=${encodeURIComponent($.pin)}`; + break; + case 'doBrowGoodsTask': + case 'doAddGoodsTask': + url= `https://lzkjdz-isv.isvjcloud.com/wxFansInterActionActivity/${type}`; + body = `activityId=${$.activityID}&uuid=${$.activityData.actorInfo.uuid}&skuId=${$.oneGoodInfo.skuId}`; + break; + case 'doSign': + case 'followShop': + case 'doShareTask': + case 'doRemindTask': + case 'doMeetingTask': + url= `https://lzkjdz-isv.isvjcloud.com/wxFansInterActionActivity/${type}`; + body = `activityId=${$.activityID}&uuid=${$.activityData.actorInfo.uuid}`; + break; + case 'doGetCouponTask': + url= `https://lzkjdz-isv.isvjcloud.com/wxFansInterActionActivity/${type}`; + body= `activityId=${$.activityID}&uuid=${$.activityData.actorInfo.uuid}&couponId=${$.oneCouponInfo.couponInfo.couponId}`; + break; + case 'startDraw': + url= `https://lzkjdz-isv.isvjcloud.com/wxFansInterActionActivity/${type}`; + body= `activityId=${$.activityID}&uuid=${$.activityData.actorInfo.uuid}&drawType=${$.drawType}`; + break; + default: + console.log(`错误${type}`); + } + let myRequest = getPostRequest(url,body); + await $.wait(2500); + return new Promise(async resolve => { + $.post(myRequest, (err, resp, data) => { + try { + dealReturn(type, data); + } catch (e) { + console.log(data); + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) } -function invite3(_0x124be8,_0x95cb67){ - let _0x243f31=+new Date(); - let _0x5e0330={'url':'https://api.m.jd.com/?t='+_0x243f31,'body':'functionId=InviteFriendChangeAssertsService&body='+JSON.stringify({'method':'attendInviteActivity','data':{'inviterPin':encodeURIComponent(_0x95cb67),'channel':1,'token':'','frontendInitStatus':''}})+'&referer=-1&eid=eidI9b2981202fsec83iRW1nTsOVzCocWda3YHPN471AY78%2FQBhYbXeWtdg%2F3TCtVTMrE1JjM8Sqt8f2TqF1Z5P%2FRPGlzA1dERP0Z5bLWdq5N5B2VbBO&aid=&client=ios&clientVersion=14.4.2&networkType=wifi&fp=-1&uuid=ab048084b47df24880613326feffdf7eee471488&osVersion=14.4.2&d_brand=iPhone&d_model=iPhone10,2&agent=-1&pageClickKey=-1&platform=3&lang=zh_CN&appid=market-task-h5&_t='+_0x243f31,'headers':{ - 'Host':'api.m.jd.com','Accept':'application/json, text/plain, */*','Content-type':'application/x-www-form-urlencoded','Origin':'https://invite-reward.jd.com','Accept-Language':'zh-CN,zh-Hans;q=0.9','User-Agent':$.isNode()?process.env.JS_USER_AGENT?process.env.JS_USER_AGENT:require('./JS_USER_AGENTS').USER_AGENT:$.getdata('JSUA')?$.getdata('JSUA'):'\'jdltapp;iPad;3.1.0;14.4;network/wifi;Mozilla/5.0 (iPad; CPU OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1','Referer':'https://invite-reward.jd.com/','Accept-Encoding':'gzip, deflate, br','Cookie':_0x124be8 - }}; - $.post(_0x5e0330,(_0x53cb25,_0x3d3420,_0x345c93)=>{}); + +function dealReturn(type, data) { + try { + if (safeGet(data)) { + data = JSON.parse(data); + }else { + data = ''; + } + }catch (e) { + console.log(`执行任务异常`); + console.log(data); + $.runFalag = false; + } + switch (type) { + case 'getSimpleActInfoVo': + if (data.result) { + $.shopid = data.data.venderId; + } + break; + case 'getMyPing': + if (data.data && data.data.secretPin) { + $.pin = data.data.secretPin + $.nickname = data.data.nickname + }else{ + console.log(JSON.stringify(data)); + } + break; + case 'activityContent': + if (data.data && data.result && data.count === 0) { + $.activityData = data.data; + $.actinfo = $.activityData.actInfo + $.actorInfo = $.activityData.actorInfo + $.nowUseValue = Number($.actorInfo.fansLoveValue) + Number($.actorInfo.energyValue) ; + } else { + console.log(JSON.stringify(data)); + } + break; + case 'getActMemberInfo': + if (data.data && data.result && data.count === 0) { + $.memberInfo = data.data; + } + break; + case 'doSign': + if (data.result === true) { + console.log('签到成功') + } else { + console.log(data.errorMessage) + } + break; + case 'followShop': + case 'doBrowGoodsTask': + case 'doAddGoodsTask': + case 'doShareTask': + case 'doRemindTask': + case 'doGetCouponTask': + case 'doMeetingTask': + if (data.result === true) { + console.log('执行成功'); + } else { + console.log(data.errorMessage) + } + break; + case 'startDraw': + if(data.result && data.data){ + if(data.data.drawInfoType === 6){ + console.log(`抽奖获得:${data.data.name || ''}`); + }else if(data.data.drawInfoType === 0){ + console.log(`未抽中`); + }else{ + console.log(`抽奖结果:${data.data.name || ''}`); + } + } + console.log(JSON.stringify(data)); + break; + default: + console.log(JSON.stringify(data)); + } } -function invite4(_0x4ce7d3,_0x13691e){ - let _0x67f7ab={'url':'https://api.m.jd.com/','body':'functionId=TaskInviteService&body='+JSON.stringify({'method':'participateInviteTask','data':{'channel':'1','encryptionInviterPin':encodeURIComponent(_0x13691e),'type':1}})+'&appid=market-task-h5&uuid=&_t='+Date.now(),'headers':{ - 'Host':'api.m.jd.com','Accept':'application/json, text/plain, */*','Content-Type':'application/x-www-form-urlencoded','Origin':'https://assignment.jd.com','Accept-Language':'zh-CN,zh-Hans;q=0.9','User-Agent':$.isNode()?process.env.JS_USER_AGENT?process.env.JS_USER_AGENT:require('./JS_USER_AGENTS').USER_AGENT:$.getdata('JSUA')?$.getdata('JSUA'):'\'jdltapp;iPad;3.1.0;14.4;network/wifi;Mozilla/5.0 (iPad; CPU OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1','Referer':'https://assignment.jd.com/','Accept-Encoding':'gzip, deflate, br','Cookie':_0x4ce7d3 - }}; - $.post(_0x67f7ab,(_0x29e91a,_0x5baf9c,_0x467f38)=>{}); + +function getPostRequest(url,body) { + let headers = { + 'Host': 'lzkjdz-isv.isvjcloud.com', + 'Accept': 'application/json', + 'X-Requested-With': 'XMLHttpRequest', + 'Referer': 'https://lzkjdz-isv.isvjcloud.com/wxFansInterActionActivity/activity/' + $.activityID + '?activityId=' + $.activityID + '&shareuserid4minipg=jd_4806fb66e0f3e&shopid=undefined', + 'user-agent': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': $.cookie, + } + return {url: url, method: `POST`, headers: headers, body: body}; } -async function runMain(_0x40ebb9){ - _0x40ebb9.UA=_0x40ebb9.isNode()?process.env.JD_USER_AGENT?process.env.JD_USER_AGENT:require('./USER_AGENTS').USER_AGENT:_0x40ebb9.getdata('JDUA')?_0x40ebb9.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',_0x40ebb9.token=''; - _0x40ebb9.LZ_TOKEN_KEY=''; - _0x40ebb9.LZ_TOKEN_VALUE=''; - _0x40ebb9.lz_jdpin_token=''; - _0x40ebb9.pin=''; - _0x40ebb9.nickname=''; - _0x40ebb9.venderId=''; - _0x40ebb9.activityType=''; - _0x40ebb9.attrTouXiang='https://img10.360buyimg.com/imgzone/jfs/t1/7020/27/13511/6142/5c5138d8E4df2e764/5a1216a3a5043c5d.png'; - console.log('活动地址:'+_0x40ebb9.thisActivityUrl); - _0x40ebb9.body='body=%7B%22url%22%3A%22https%3A%2F%2Flzkjdz-isv.isvjcloud.com%22%2C%22id%22%3A%22%22%7D&clientVersion=9.2.2&build=89568&client=android&uuid=b4d0d21978ef8579305f30d52065ffedcc573c2d&st=1643784769190&sign=d6ab868c42dcc3d04c2b95b2aea9014c&sv=111'; - _0x40ebb9.token=await getToken(_0x40ebb9); - if(!_0x40ebb9.token){ - console.log('获取token失败'); - return; - } - await getHtml(_0x40ebb9); - if(!_0x40ebb9.LZ_TOKEN_KEY||!_0x40ebb9.LZ_TOKEN_VALUE){ - console.log('初始化失败1'); - return; - } - let _0x4c9e98=await takePostRequest(_0x40ebb9,'customer/getSimpleActInfoVo'); - _0x40ebb9.venderId=_0x4c9e98.data.venderId||''; - _0x40ebb9.activityType=_0x4c9e98.data.activityType||''; - console.log('venderId:'+_0x40ebb9.venderId); - let _0xfab866=await takePostRequest(_0x40ebb9,'customer/getMyPing'); - _0x40ebb9.pin=_0xfab866.data.secretPin; - _0x40ebb9.nickname=_0xfab866.data.nickname; - if(!_0x40ebb9.pin){ - console.log('获取pin失败,该账号可能是黑号'); - return; - } - await takePostRequest(_0x40ebb9,'common/accessLogWithAD'); - let _0x851536=await takePostRequest(_0x40ebb9,'wxActionCommon/getUserInfo'); - let _0x3343be=await takePostRequest(_0x40ebb9,'wxActionCommon/getShopInfoVO'); - let _0x174237=await takePostRequest(_0x40ebb9,'wxCommonInfo/getActMemberInfo'); - if(_0x851536&&_0x851536.data&&_0x851536.data.yunMidImageUrl){ - _0x40ebb9.attrTouXiang=_0x851536.data.yunMidImageUrl; - } - let _0x11a7bd=await takePostRequest(_0x40ebb9,'wxFansInterActionActivity/activityContent'); - _0x40ebb9.activityData=_0x11a7bd.data||{}; - _0x40ebb9.actinfo=_0x40ebb9.activityData.actInfo; - _0x40ebb9.actorInfo=_0x40ebb9.activityData.actorInfo; - _0x40ebb9.nowUseValue=(Number(_0x40ebb9.actorInfo.fansLoveValue)+Number(_0x40ebb9.actorInfo.energyValue)); - if(JSON.stringify(_0x40ebb9.activityData)==='{}'){ - console.log('获取活动信息失败'); - return; - } - let _0x452779=new Date(_0x40ebb9.activityData.actInfo.endTime); - let _0x3b061a=(_0x452779.getFullYear()+'-'+_0x452779.getMonth()<10?('0'+_0x452779.getMonth()+1):(_0x452779.getMonth()+1)+'-'+_0x452779.getDate()<10?'0'+_0x452779.getDate():_0x452779.getDate()); - _0x452779=new Date(_0x40ebb9.activityData.actInfo.startTime); - let _0x29384a=(_0x452779.getFullYear()+'-'+_0x452779.getMonth()<10?'0'+(_0x452779.getMonth()+1):(_0x452779.getMonth()+1))+'-'+((_0x452779.getDate()<10)?('0'+_0x452779.getDate()):_0x452779.getDate()); - console.log(_0x40ebb9.actinfo.actName+','+_0x3343be.data.shopName+',当前积分:'+_0x40ebb9.nowUseValue+',活动时间:'+_0x29384a+'---'+_0x3b061a+','+_0x40ebb9.activityData.actInfo.endTime); - let _0x14474d=[]; - let _0x3fea64=['One','Two','Three']; - for(let _0x377d67=0;_0x377d67<_0x3fea64.length;_0x377d67++){ - let _0xc7c5a0=_0x40ebb9.activityData.actInfo['giftLevel'+_0x3fea64[_0x377d67]]||''; - if(_0xc7c5a0){ - _0xc7c5a0=JSON.parse(_0xc7c5a0); - _0x14474d.push(_0xc7c5a0[0].name); - } - } - console.log('奖品列表:'+_0x14474d.toString()); - if(_0x40ebb9.actorInfo.prizeOneStatus&&_0x40ebb9.actorInfo.prizeTwoStatus&&_0x40ebb9.actorInfo.prizeThreeStatus){ - console.log('已完成抽奖'); - return; - } - if((_0x174237.data.actMemberStatus===1)&&!_0x174237.data.openCard){ - console.log('活动需要入会后才能参与'); - if(Number(RUHUI)===1){ - console.log('去入会'); - await join(_0x40ebb9); - _0x11a7bd=await takePostRequest(_0x40ebb9,'wxFansInterActionActivity/activityContent'); - _0x40ebb9.activityData=_0x11a7bd.data||{}; - await _0x40ebb9.wait(3000); - }else{ - console.log('不执行入会,跳出'); - return; - } - return; - }else if(_0x174237.data.openCard){ - console.log('已入会'); - } - if(_0x40ebb9.activityData.actorInfo&&!_0x40ebb9.activityData.actorInfo.follow){ - console.log('去关注店铺'); - _0x40ebb9.body='activityId='+_0x40ebb9.activityId+'&uuid='+_0x40ebb9.activityData.actorInfo.uuid; - let _0x477c01=await takePostRequest(_0x40ebb9,'wxFansInterActionActivity/followShop',_0x40ebb9.body); - console.log(JSON.stringify(_0x477c01)); - await _0x40ebb9.wait(3000); - } - _0x40ebb9.upFlag=false; - await doTask(_0x40ebb9); - await luckDraw(_0x40ebb9); +function accessLogWithAD() { + let config = { + url: `https://lzkjdz-isv.isvjcloud.com/common/accessLogWithAD`, + headers: { + 'Host': 'lzkjdz-isv.isvjcloud.com', + 'Accept': 'application/json', + 'X-Requested-With': 'XMLHttpRequest', + 'user-agent': $.UA, + 'Referer': 'https://lzkjdz-isv.isvjcloud.com/wxFansInterActionActivity/activity/' + $.activityID + '?activityId=' + $.activityID + '&shareuserid4minipg=jd_4806fb66e0f3e&shopid=undefined', + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': $.cookie, + }, + body:`venderId=${$.shopid}&code=69&pin=${encodeURIComponent($.pin)}&activityId=${$.activityID}&pageUrl=https://lzkjdz-isv.isvjcloud.com/wxFansInterActionActivity/activity/${$.activityID}?activityId=${$.activityID}&shareuserid4minipg=&shopid=undefined&subType=app&adSource=` + } + return new Promise(resolve => { + $.post(config, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + $.cookie = $.oldcookie; + if ($.isNode()) + for (let ck of resp['headers']['set-cookie']) { + $.cookie = `${$.cookie}${ck.split(";")[0]};` + } + else { + for (let ck of resp['headers']['Set-Cookie'].split(',')) { + $.cookie = `${$.cookie}${ck.split(";")[0]};` + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) } -async function luckDraw(_0x13737e){ - if(_0x13737e.upFlag){ - activityData=await takePostRequest(_0x13737e,'wxFansInterActionActivity/activityContent'); - _0x13737e.activityData=activityData.data||{}; - await _0x13737e.wait(3000); - } - let _0x2b7411=(Number(_0x13737e.activityData.actorInfo.fansLoveValue)+Number(_0x13737e.activityData.actorInfo.energyValue)); - let _0x47ddad=['One','Two','Three']; - let _0x58a1c5={'One':'01','Two':'02','Three':'03'}; - for(let _0x1b895e=0;_0x1b895e<_0x47ddad.length;_0x1b895e++){ - if((_0x2b7411>=_0x13737e.activityData.actConfig['prizeScore'+_0x47ddad[_0x1b895e]])&&_0x13737e.activityData.actorInfo['prize'+_0x47ddad[_0x1b895e]+'Status']===false){ - console.log('\n开始第'+Number(_0x58a1c5[_0x47ddad[_0x1b895e]])+'次抽奖'); - _0x13737e.body='activityId='+_0x13737e.activityId+'&uuid='+_0x13737e.activityData.actorInfo.uuid+'&drawType='+_0x58a1c5[_0x47ddad[_0x1b895e]]; - let _0x55478a=await takePostRequest(_0x13737e,'wxFansInterActionActivity/startDraw',_0x13737e.body); - if(_0x55478a.result&&_0x55478a.count===0){ - let _0x5e600e=_0x55478a.data; - if(!_0x5e600e.drawOk){ - console.log('抽奖获得:空气'); - }else{ - console.log('抽奖获得:'+_0x5e600e.name); - message+=_0x13737e.UserName+',获得:'+(_0x5e600e.name||'未知')+'\n'; - } - }else{ - console.log('抽奖异常'); - } - console.log(JSON.stringify(_0x55478a)); - await _0x13737e.wait(3000); - } - } +function getActCk() { + let config = { + url: `https://lzkjdz-isv.isvjcloud.com/wxFansInterActionActivity/activity/${$.activityID}?activityId=${$.activityID}&shareuserid4minipg=jd_4806fb66e0f3e&shopid=undefined`, + headers: { + 'Host': 'lzkjdz-isv.isvjcloud.com', + 'Accept': 'application/json', + 'X-Requested-With': 'XMLHttpRequest', + 'Referer': 'https://lzkjdz-isv.isvjcloud.com/wxFansInterActionActivity/activity/' + $.activityID + '?activityId=' + $.activityID + '&shareuserid4minipg=jd_4806fb66e0f3e&shopid=undefined', + 'user-agent': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': $.cookie, + } + } + return new Promise(resolve => { + $.get(config, (err, resp, data) => { + try { + if (err) { + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + $.cookie = $.oldcookie; + if ($.isNode()) + for (let ck of resp['headers']['set-cookie']) { + $.cookie = `${$.cookie}${ck.split(";")[0]};` + } + else { + for (let ck of resp['headers']['Set-Cookie'].split(',')) { + $.cookie = `${$.cookie}${ck.split(";")[0]};` + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) } -async function doTask(_0x23c295){ - let _0x90a7c2=0; - if(_0x23c295.activityData.task2BrowGoods){ - if(_0x23c295.activityData.task2BrowGoods.finishedCount!==_0x23c295.activityData.task2BrowGoods.upLimit){ - _0x90a7c2=(Number(_0x23c295.activityData.task2BrowGoods.upLimit)-Number(_0x23c295.activityData.task2BrowGoods.finishedCount)); - console.log('开始做浏览商品任务'); - _0x23c295.upFlag=true; - for(let _0x57ea0c=0;_0x57ea0c<_0x23c295.activityData.task2BrowGoods.taskGoodList.length&&_0x90a7c2>0;_0x57ea0c++){ - _0x23c295.oneGoodInfo=_0x23c295.activityData.task2BrowGoods.taskGoodList[_0x57ea0c]; - if(_0x23c295.oneGoodInfo.finished===false){ - console.log('浏览:'+(_0x23c295.oneGoodInfo.skuName||'')); - _0x23c295.body='activityId='+_0x23c295.activityId+'&uuid='+_0x23c295.activityData.actorInfo.uuid+'&skuId='+_0x23c295.oneGoodInfo.skuId; - let _0x4858b5=await takePostRequest(_0x23c295,'wxFansInterActionActivity/doBrowGoodsTask',_0x23c295.body); - console.log(JSON.stringify(_0x4858b5)); - await _0x23c295.wait(3000); - _0x90a7c2--; - } - } - }else{ - console.log('浏览商品任务已完成'); - } - } - if(_0x23c295.activityData.task3AddCart){ - if(_0x23c295.activityData.task3AddCart.finishedCount!==_0x23c295.activityData.task3AddCart.upLimit){ - _0x90a7c2=(Number(_0x23c295.activityData.task3AddCart.upLimit)-Number(_0x23c295.activityData.task3AddCart.finishedCount)); - console.log('开始做加购商品任务'); - _0x23c295.upFlag=true; - for(let _0x2527f5=0;(_0x2527f5<_0x23c295.activityData.task3AddCart.taskGoodList.length)&&(_0x90a7c2>0);_0x2527f5++){ - _0x23c295.oneGoodInfo=_0x23c295.activityData.task3AddCart.taskGoodList[_0x2527f5]; - if(_0x23c295.oneGoodInfo.finished===false){ - console.log('加购:'+(_0x23c295.oneGoodInfo.skuName||'')); - _0x23c295.body='activityId='+_0x23c295.activityId+'&uuid='+_0x23c295.activityData.actorInfo.uuid+'&skuId='+_0x23c295.oneGoodInfo.skuId; - let _0x4858b5=await takePostRequest(_0x23c295,'wxFansInterActionActivity/doAddGoodsTask',_0x23c295.body); - console.log(JSON.stringify(_0x4858b5)); - await _0x23c295.wait(3000); - _0x90a7c2--; - } - } - }else{ - console.log('加购商品已完成'); - } - } - if(_0x23c295.activityData.task6GetCoupon){ - if(_0x23c295.activityData.task6GetCoupon.finishedCount!==_0x23c295.activityData.task6GetCoupon.upLimit){ - _0x90a7c2=(Number(_0x23c295.activityData.task6GetCoupon.upLimit)-Number(_0x23c295.activityData.task6GetCoupon.finishedCount)); - console.log('开始做领取优惠券'); - _0x23c295.upFlag=true; - for(let _0x48cbc6=0;(_0x48cbc6<_0x23c295.activityData.task6GetCoupon.taskCouponInfoList.length)&&(_0x90a7c2>0);_0x48cbc6++){ - _0x23c295.oneCouponInfo=_0x23c295.activityData.task6GetCoupon.taskCouponInfoList[_0x48cbc6]; - if(_0x23c295.oneCouponInfo.finished===false){ - _0x23c295.body='activityId='+_0x23c295.activityId+'&uuid='+_0x23c295.activityData.actorInfo.uuid+'&couponId='+_0x23c295.oneCouponInfo.couponInfo.couponId; - let _0x4858b5=await takePostRequest(_0x23c295,'wxFansInterActionActivity/doGetCouponTask',_0x23c295.body); - console.log(JSON.stringify(_0x4858b5)); - await _0x23c295.wait(3000); - _0x90a7c2--; - } - } - }else{ - console.log('领取优惠券已完成'); - } - } - _0x23c295.body='activityId='+_0x23c295.activityId+'&uuid='+_0x23c295.activityData.actorInfo.uuid; - if(_0x23c295.activityData.task1Sign&&_0x23c295.activityData.task1Sign.finishedCount===0){ - console.log('执行每日签到'); - let _0x3b44d4=await takePostRequest(_0x23c295,'wxFansInterActionActivity/doSign',_0x23c295.body); - console.log(JSON.stringify(_0x3b44d4)); - await _0x23c295.wait(3000); - _0x23c295.upFlag=true; - }else{ - console.log('已签到'); - }if(_0x23c295.activityData.task4Share){ - if(_0x23c295.activityData.task4Share.finishedCount!==_0x23c295.activityData.task4Share.upLimit){ - _0x90a7c2=Number(_0x23c295.activityData.task4Share.upLimit)-Number(_0x23c295.activityData.task4Share.finishedCount); - console.log('开始做分享任务'); - _0x23c295.upFlag=true; - for(let _0x107268=0;_0x107268<_0x90a7c2;_0x107268++){ - console.log('执行第'+(_0x107268+1)+'次分享'); - let _0x3b44d4=await takePostRequest(_0x23c295,'wxFansInterActionActivity/doShareTask',_0x23c295.body); - console.log(JSON.stringify(_0x3b44d4)); - await _0x23c295.wait(3000); - } - }else{ - console.log('分享任务已完成'); - } - }if(_0x23c295.activityData.task5Remind){ - if(_0x23c295.activityData.task5Remind.finishedCount!==_0x23c295.activityData.task5Remind.upLimit){ - console.log('执行设置活动提醒'); - _0x23c295.upFlag=true; - let _0x204aab=await takePostRequest(_0x23c295,'wxFansInterActionActivity/doRemindTask',_0x23c295.body); - console.log(JSON.stringify(_0x204aab)); - await _0x23c295.wait(3000); - }else{ - console.log('设置活动提醒已完成'); - } - }if(_0x23c295.activityData.task7MeetPlaceVo){ - if(_0x23c295.activityData.task7MeetPlaceVo.finishedCount!==_0x23c295.activityData.task7MeetPlaceVo.upLimit){ - console.log('执行逛会场'); - _0x23c295.upFlag=true; - let _0x84bc88=await takePostRequest(_0x23c295,'wxFansInterActionActivity/doMeetingTask',_0x23c295.body); - console.log(JSON.stringify(_0x84bc88)); - await _0x23c295.wait(3000); - }else{ - console.log('逛会场已完成'); - } - } +function getToken() { + let config = { + url: 'https://api.m.jd.com/client.action?functionId=isvObfuscator&clientVersion=10.0.6&build=88852&client=android&d_brand=Xiaomi&d_model=RedmiK30&osVersion=11&screen=2175*1080&partner=xiaomi001&oaid=b30cf82cacfa8972&openudid=290955c2782e1c44&eid=eidAef5f8122a0sf2tNlFbi9TV+3rtJ+jl5UptrTZo/Aq5MKUEaXcdTZC6RfEBt5Jt3Gtml2hS+ZvrWoDvkVv4HybKpJJVMdRUkzX7rGPOis1TRFRUdU&sdkVersion=30&lang=zh_CN&uuid=290955c2782e1c44&aid=290955c2782e1c44&area=1_2803_2829_0&networkType=wifi&wifiBssid=unknown&uts=0f31TVRjBSsSbxrSGoN9DgdOSm6pBw5mcERcSRBBxns2PPMfI6n6ccc3sDC5tvqojX6KE6uHJtCmbQzfS%2B6T0ggVk1TfVMHdFhgxdB8xiJq%2BUJPVGAaS5duja15lBdKzCeU4J31903%2BQn8mkzlfNoAvZI7hmcbV%2FZBnR1VdoiUChwWlAxuEh75t18FqkjuqQHvhONIbhrfofUoFzbcriHw%3D%3D&uemps=0-0&harmonyOs=0&st=1625157308996&sign=e5ef32369adb2e4b7024cff612395a72&sv=110', + body: 'body=%7B%22id%22%3A%22%22%2C%22url%22%3A%22https%3A%2F%2Flzkjdz-isv.isvjcloud.com%22%7D&', + headers: { + 'Host': 'api.m.jd.com', + 'accept': '*/*', + 'user-agent': 'JD4iPhone/167490 (iPhone; iOS 14.2; Scale/3.00)', + 'accept-language': 'zh-Hans-JP;q=1, en-JP;q=0.9, zh-Hant-TW;q=0.8, ja-JP;q=0.7, en-US;q=0.6', + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': $.cookie + } + } + return new Promise(resolve => { + $.post(config, async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + data = JSON.parse(data); + $.token = data['token'] + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) } -function getUrlData(_0x3c166f,_0x3dcbe9){ - if(typeof URL!=='undefined'){ - let _0xe4e3a4=new URL(_0x3c166f); - let _0x5ddc8d=_0xe4e3a4.searchParams.get(_0x3dcbe9); - return _0x5ddc8d?_0x5ddc8d:''; - }else{ - const _0x114c48=_0x3c166f.match(/\?.*/)[0].substring(1); - const _0x1baacd=_0x114c48.split('&'); - for(let _0x3113d1=0;_0x3113d1<_0x1baacd.length;_0x3113d1++){ - const _0x414733=_0x1baacd[_0x3113d1].split('='); - if(_0x414733[0]===_0x3dcbe9){ - return _0x1baacd[_0x3113d1].substr(_0x1baacd[_0x3113d1].indexOf('=')+1); - } - } - return''; - } + +function safeGet(data) { + try { + if (typeof JSON.parse(data) == "object") { + return true; + } + } catch (e) { + console.log(e); + console.log(`服务器访问数据为空,请检查自身设备网络情况`); + return false; + } } -async function getToken(_0x3c9452){ - let _0x575ad2={'url':'https://api.m.jd.com/client.action?functionId=isvObfuscator','body':_0x3c9452.body,'headers':{'Host':'api.m.jd.com','accept':'*/*','user-agent':'JD4iPhone/167490 (iPhone; iOS 14.2; Scale/3.00)','accept-language':'zh-Hans-JP;q=1, en-JP;q=0.9, zh-Hant-TW;q=0.8, ja-JP;q=0.7, en-US;q=0.6','content-type':'application/x-www-form-urlencoded','Cookie':_0x3c9452.cookie}}; - return new Promise(_0x177e3a=>{ - _0x3c9452.post(_0x575ad2,async(_0x846899,_0x5ddcd4,_0x58ed45)=>{ - try{ - if(_0x846899){ - console.log(''+JSON.stringify(_0x846899)); - console.log(_0x3c9452.name+' API请求失败,请检查网路重试'); - }else{ - _0x58ed45=JSON.parse(_0x58ed45); - } - }catch(_0x537dc9){ - _0x3c9452.logErr(_0x537dc9,_0x5ddcd4); - } - finally{ - _0x177e3a(_0x58ed45.token||''); - } - }); - }); + +async function getUA(){ + $.UA = `jdapp;iPhone;10.0.10;14.3;${randomString(40)};network/wifi;model/iPhone12,1;addressid/3364463029;appBuild/167764;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1` } -async function getHtml(_0x4addca){ - let _0x25eb03={'url':_0x4addca.thisActivityUrl,'headers':{'Host':_0x4addca.host,'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8','Cookie':'IsvToken='+_0x4addca.token+';'+_0x4addca.cookie,'User-Agent':_0x4addca.UA,'Accept-Language':'zh-cn','Accept-Encoding':'gzip, deflate, br','Connection':'keep-alive'}}; - return new Promise(_0x35175a=>{ - _0x4addca.get(_0x25eb03,(_0x53f11b,_0x24beb3,_0x50a1a1)=>{ - try{ - dealCK(_0x4addca,_0x24beb3); - }catch(_0x182b52){ - _0x4addca.logErr(_0x182b52,_0x24beb3); - } - finally{ - _0x35175a(_0x50a1a1); - } - }); - }); +function randomString(e) { + e = e || 32; + let t = "abcdef0123456789", a = t.length, n = ""; + for (i = 0; i < e; i++) + n += t.charAt(Math.floor(Math.random() * a)); + return n } -function dealCK(_0x1ea343,_0x122b40){ - if(_0x122b40===undefined){ - return; - } - let _0x3d9911=_0x122b40.headers['set-cookie']||_0x122b40.headers['Set-Cookie']||''; - if(_0x3d9911){ - let _0x2fabb2=_0x3d9911.filter(_0x942508=>_0x942508.indexOf('lz_jdpin_token')!==-1)[0]; - if(_0x2fabb2&&(_0x2fabb2.indexOf('lz_jdpin_token=')>-1)){ - _0x1ea343.lz_jdpin_token=_0x2fabb2.split(';')&&(_0x2fabb2.split(';')[0]+';')||''; - } - let _0x23a7e9=_0x3d9911.filter(_0x41bf1f=>_0x41bf1f.indexOf('LZ_TOKEN_KEY')!==-1)[0]; - if(_0x23a7e9&&(_0x23a7e9.indexOf('LZ_TOKEN_KEY=')>-1)){ - let _0x22583b=_0x23a7e9.split(';')&&_0x23a7e9.split(';')[0]||''; - _0x1ea343.LZ_TOKEN_KEY=_0x22583b.replace('LZ_TOKEN_KEY=',''); - } - let _0x381ba3=_0x3d9911.filter(_0x29a259=>_0x29a259.indexOf('LZ_TOKEN_VALUE')!==-1)[0]; - if(_0x381ba3&&_0x381ba3.indexOf('LZ_TOKEN_VALUE=')>-1){ - let _0x1f6cc4=_0x381ba3.split(';')&&_0x381ba3.split(';')[0]||''; - _0x1ea343.LZ_TOKEN_VALUE=_0x1f6cc4.replace('LZ_TOKEN_VALUE=',''); - } - } -} -async function takePostRequest(_0x22084a,_0x4d19d2,_0x4cee5b='activityId='+_0x22084a.activityId+'&pin='+encodeURIComponent(_0x22084a.pin)){ - let _0x3e5e9='https://'+_0x22084a.host+'/'+_0x4d19d2; - switch(_0x4d19d2){ - case 'customer/getSimpleActInfoVo': - case 'dz/common/getSimpleActInfoVo': - case 'wxCommonInfo/initActInfo': - case 'wxCollectionActivity/shopInfo': - case 'wxCollectCard/shopInfo': - case 'wxCollectCard/drawContent': - _0x4cee5b='activityId='+_0x22084a.activityId; - break; - case 'customer/getMyPing': - _0x4cee5b='userId='+_0x22084a.venderId+'&token='+encodeURIComponent(_0x22084a.token)+'&fromType=APP'; - break; - case'common/accessLogWithAD': - case 'common/accessLog': - _0x4cee5b='venderId='+_0x22084a.venderId+'&code='+_0x22084a.activityType+'&pin='+encodeURIComponent(_0x22084a.pin)+'&activityId='+_0x22084a.activityId+'&pageUrl='+encodeURIComponent(_0x22084a.thisActivityUrl)+'&subType=app&adSource=null'; - break; - case 'wxActionCommon/getUserInfo': - _0x4cee5b='pin='+encodeURIComponent(_0x22084a.pin); - break; - case'wxCommonInfo/getActMemberInfo': - _0x4cee5b='venderId='+_0x22084a.venderId+'&activityId='+_0x22084a.activityId+'&pin='+encodeURIComponent(_0x22084a.pin); - break; - case 'wxActionCommon/getShopInfoVO': - _0x4cee5b='userId='+_0x22084a.venderId; - break; - case '2222': - _0x4cee5b='222'; - break; - } - const _0x2993f8={'X-Requested-With':'XMLHttpRequest','Connection':'keep-alive','Accept-Encoding':'gzip, deflate, br','Content-Type':'application/x-www-form-urlencoded','Origin':'https://'+_0x22084a.host,'User-Agent':_0x22084a.UA,'Cookie':_0x22084a.cookie+' LZ_TOKEN_KEY='+_0x22084a.LZ_TOKEN_KEY+'; LZ_TOKEN_VALUE='+_0x22084a.LZ_TOKEN_VALUE+'; AUTH_C_USER='+_0x22084a.pin+'; '+_0x22084a.lz_jdpin_token,'Host':_0x22084a.host,'Referer':_0x22084a.thisActivityUrl,'Accept-Language':'zh-cn','Accept':'application/json'}; - let _0x1e0fb8={'url':_0x3e5e9,'method':'POST','headers':_0x2993f8,'body':_0x4cee5b}; - return new Promise(async _0x4afe88=>{ - _0x22084a.post(_0x1e0fb8,(_0xa06eab,_0x445f4b,_0x1ac3a4)=>{ - try{ - dealCK(_0x22084a,_0x445f4b); - if(_0x1ac3a4){ - _0x1ac3a4=JSON.parse(_0x1ac3a4); - } - }catch(_0x174945){ - console.log(_0x1ac3a4); - _0x22084a.logErr(_0x174945,_0x445f4b); - } - finally{ - _0x4afe88(_0x1ac3a4); - } - }); - }); -} -async function join(_0x20b776){ - _0x20b776.shopactivityId=''; - await _0x20b776.wait(1000); - await getshopactivityId(_0x20b776); - let _0x2c5d06=''; - if(_0x20b776.shopactivityId)_0x2c5d06=',"activityId":'+_0x20b776.shopactivityId; - let _0x317371={'url':'https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body={"venderId":"'+_0x20b776.venderId+'","shopId":"'+_0x20b776.venderId+'","bindByVerifyCodeFlag":1,"registerExtend":{},"writeChildFlag":0'+_0x2c5d06+',"channel":401}&client=H5&clientVersion=9.2.0&uuid=88888','headers':{'Content-Type':'text/plain; Charset=UTF-8','Origin':'https://api.m.jd.com','Host':'api.m.jd.com','accept':'*/*','User-Agent':_0x20b776.UA,'content-type':'application/x-www-form-urlencoded','Referer':'https://shopmember.m.jd.com/shopcard/?venderId='+_0x20b776.venderId+'&shopId='+_0x20b776.venderId,'Cookie':_0x20b776.cookie}}; - return new Promise(async _0x373e23=>{ - _0x20b776.get(_0x317371,async(_0x520d30,_0x1d78d3,_0x5a3bf2)=>{ - try{ - _0x5a3bf2=JSON.parse(_0x5a3bf2); - if(_0x5a3bf2.success==true){ - _0x20b776.log(_0x5a3bf2.message); - if(_0x5a3bf2.result&&_0x5a3bf2.result.giftInfo){ - for(let _0x57e5da of _0x5a3bf2.result.giftInfo.giftList){ - console.log('入会获得:'+_0x57e5da.discountString+_0x57e5da.prizeName+_0x57e5da.secondLineDesc); - } - } - }else if(_0x5a3bf2.success==false){ - _0x20b776.log(_0x5a3bf2.message); - } - }catch(_0x470238){ - _0x20b776.logErr(_0x470238,_0x1d78d3); - } - finally{ - _0x373e23(_0x5a3bf2); - } - }); - }); -} -async function getshopactivityId(_0x42e0bc){ - let _0x29a492={'url':'https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body=%7B%22venderId%22%3A%22'+_0x42e0bc.venderId+'%22%2C%22channel%22%3A401%7D&client=H5&clientVersion=9.2.0&uuid=88888','headers':{'Content-Type':'text/plain; Charset=UTF-8','Origin':'https://api.m.jd.com','Host':'api.m.jd.com','accept':'*/*','User-Agent':_0x42e0bc.UA,'content-type':'application/x-www-form-urlencoded','Referer':'https://shopmember.m.jd.com/shopcard/?venderId='+_0x42e0bc.venderId+'&shopId='+_0x42e0bc.venderId,'Cookie':_0x42e0bc.cookie}}; - return new Promise(_0x49664a=>{ - _0x42e0bc.get(_0x29a492,async(_0x5b3807,_0x5d61b1,_0x313fb3)=>{ - try{ - _0x313fb3=JSON.parse(_0x313fb3); - if(_0x313fb3.success==true){ - console.log('入会:'+(_0x313fb3.result.shopMemberCardInfo.venderCardName||'')); - _0x42e0bc.shopactivityId=_0x313fb3.result.interestsRuleList&&_0x313fb3.result.interestsRuleList[0]&&_0x313fb3.result.interestsRuleList[0].interestsInfo&&_0x313fb3.result.interestsRuleList[0].interestsInfo.activityId||''; - } - }catch(_0x254d1e){ - _0x42e0bc.logErr(_0x254d1e,_0x5d61b1); - } - finally{ - _0x49664a(); - } - }); - }); -} -function getRandomArrayElements(_0x424ad7,_0x39bfd1){ - var _0x4063b6=_0x424ad7.slice(0),_0x57a8d=_0x424ad7.length,_0x5dc753=_0x57a8d-_0x39bfd1,_0x3010ad,_0x581bb0; - while(_0x57a8d-->_0x5dc753){ - _0x581bb0=Math.floor((_0x57a8d+1)*Math.random()); - _0x3010ad=_0x4063b6[_0x581bb0]; - _0x4063b6[_0x581bb0]=_0x4063b6[_0x57a8d]; - _0x4063b6[_0x57a8d]=_0x3010ad; - } - return _0x4063b6.slice(_0x5dc753); -}; -function Env(t,e){ - "undefined"!=typeof process&&JSON.stringify(process.env).indexOf("GITHUB")>-1&&process.exit(0); - class s{ - constructor(t){ - this.env=t - }send(t,e="GET"){ - t="string"==typeof t?{url:t}:t; - let s=this.get; - return"POST"===e&&(s=this.post),new Promise((e,i)=>{ - s.call(this,t,(t,s,r)=>{t?i(t):e(s)}) - }) - }get(t){ - return this.send.call(this.env,t) - }post(t){ - return this.send.call(this.env,t,"POST") - } - }return new class{ - constructor(t,e){ - this.name=t,this.http=new s(this),this.data=null,this.dataFile="box.dat",this.logs=[],this.isMute=!1,this.isNeedRewrite=!1,this.logSeparator="\n",this.startTime=(new Date).getTime(),Object.assign(this,e),this.log("",`🔔${this.name}, 开始!`) - }isNode(){ - return"undefined"!=typeof module&&!!module.exports - }isQuanX(){ - return"undefined"!=typeof $task - }isSurge(){ - return"undefined"!=typeof $httpClient&&"undefined"==typeof $loon - }isLoon(){ - return"undefined"!=typeof $loon - }toObj(t,e=null){ - try{ - return JSON.parse(t) - }catch{ - return e - } - }toStr(t,e=null){ - try{ - return JSON.stringify(t) - }catch{ - return e - } - }getjson(t,e){ - let s=e; - const i=this.getdata(t); - if(i)try{ - s=JSON.parse(this.getdata(t)) - }catch{}return s - }setjson(t,e){ - try{ - return this.setdata(JSON.stringify(t),e) - }catch{ - return!1 - } - }getScript(t){ - return new Promise(e=>{ - this.get({url:t},(t,s,i)=>e(i)) - }) - }runScript(t,e){ - return new Promise(s=>{ - let i=this.getdata("@chavy_boxjs_userCfgs.httpapi"); - i=i?i.replace(/\n/g,"").trim():i; - let r=this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout"); - r=r?1*r:20,r=e&&e.timeout?e.timeout:r; - const[o,h]=i.split("@"),n={url:`http://${h}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:r},headers:{"X-Key":o,Accept:"*/*"}}; - this.post(n,(t,e,i)=>s(i)) - }).catch(t=>this.logErr(t)) - }loaddata(){ - if(!this.isNode())return{}; - { - this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path"); - const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),i=!s&&this.fs.existsSync(e); - if(!s&&!i)return{}; - { - const i=s?t:e; - try{ - return JSON.parse(this.fs.readFileSync(i)) - }catch(t){ - return{} - } - } - } - }writedata(){ - if(this.isNode()){ - this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path"); - const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),i=!s&&this.fs.existsSync(e),r=JSON.stringify(this.data); - s?this.fs.writeFileSync(t,r):i?this.fs.writeFileSync(e,r):this.fs.writeFileSync(t,r) - } - }lodash_get(t,e,s){ - const i=e.replace(/\[(\d+)\]/g,".$1").split("."); - let r=t; - for(const t of i)if(r=Object(r)[t],void 0===r)return s; - return r - }lodash_set(t,e,s){return Object(t)!==t?t:(Array.isArray(e)||(e=e.toString().match(/[^.[\]]+/g)||[]),e.slice(0,-1).reduce((t,s,i)=>Object(t[s])===t[s]?t[s]:t[s]=Math.abs(e[i+1])>>0==+e[i+1]?[]:{},t)[e[e.length-1]]=s,t)}getdata(t){ - let e=this.getval(t); - if(/^@/.test(t)){ - const[,s,i]=/^@(.*?)\.(.*?)$/.exec(t),r=s?this.getval(s):""; - if(r)try{ - const t=JSON.parse(r); - e=t?this.lodash_get(t,i,""):e - }catch(t){ - e="" - } - }return e - }setdata(t,e){ - let s=!1; - if(/^@/.test(e)){ - const[,i,r]=/^@(.*?)\.(.*?)$/.exec(e),o=this.getval(i),h=i?"null"===o?null:o||"{}":"{}"; - try{ - const e=JSON.parse(h); - this.lodash_set(e,r,t),s=this.setval(JSON.stringify(e),i) - }catch(e){ - const o={}; - this.lodash_set(o,r,t),s=this.setval(JSON.stringify(o),i) - } - }else s=this.setval(t,e); - return s - }getval(t){ - return this.isSurge()||this.isLoon()?$persistentStore.read(t):this.isQuanX()?$prefs.valueForKey(t):this.isNode()?(this.data=this.loaddata(),this.data[t]):this.data&&this.data[t]||null - }setval(t,e){ - return this.isSurge()||this.isLoon()?$persistentStore.write(t,e):this.isQuanX()?$prefs.setValueForKey(t,e):this.isNode()?(this.data=this.loaddata(),this.data[e]=t,this.writedata(),!0):this.data&&this.data[e]||null - }initGotEnv(t){ - this.got=this.got?this.got:require("got"),this.cktough=this.cktough?this.cktough:require("tough-cookie"),this.ckjar=this.ckjar?this.ckjar:new this.cktough.CookieJar,t&&(t.headers=t.headers?t.headers:{},void 0===t.headers.Cookie&&void 0===t.cookieJar&&(t.cookieJar=this.ckjar)) - }get(t,e=(()=>{})){ - t.headers&&(delete t.headers["Content-Type"],delete t.headers["Content-Length"]),this.isSurge()||this.isLoon()?(this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.get(t,(t,s,i)=>{ - !t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i) - })):this.isQuanX()?(this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{ - const{statusCode:s,statusCode:i,headers:r,body:o}=t; - e(null,{status:s,statusCode:i,headers:r,body:o},o) - },t=>e(t))):this.isNode()&&(this.initGotEnv(t),this.got(t).on("redirect",(t,e)=>{ - try{ - if(t.headers["set-cookie"]){ - const s=t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString(); - s&&this.ckjar.setCookieSync(s,null),e.cookieJar=this.ckjar - } - }catch(t){ - this.logErr(t) - } - }).then(t=>{ - const{statusCode:s,statusCode:i,headers:r,body:o}=t; - e(null,{status:s,statusCode:i,headers:r,body:o},o) - },t=>{ - const{message:s,response:i}=t; - e(s,i,i&&i.body) - })) - }post(t,e=(()=>{})){ - if(t.body&&t.headers&&!t.headers["Content-Type"]&&(t.headers["Content-Type"]="application/x-www-form-urlencoded"),t.headers&&delete t.headers["Content-Length"],this.isSurge()||this.isLoon())this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.post(t,(t,s,i)=>{ - !t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i) - });else if(this.isQuanX())t.method="POST",this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{ - const{statusCode:s,statusCode:i,headers:r,body:o}=t; - e(null,{status:s,statusCode:i,headers:r,body:o},o) - },t=>e(t));else if(this.isNode()){ - this.initGotEnv(t); - const{ - url:s,...i - }=t; - this.got.post(s,i).then(t=>{ - const{statusCode:s,statusCode:i,headers:r,body:o}=t; - e(null,{status:s,statusCode:i,headers:r,body:o},o) - },t=>{ - const{message:s,response:i}=t; - e(s,i,i&&i.body) - }) - } - }time(t,e=null){ - const s=e?new Date(e):new Date; - let i={"M+":s.getMonth()+1,"d+":s.getDate(),"H+":s.getHours(),"m+":s.getMinutes(),"s+":s.getSeconds(),"q+":Math.floor((s.getMonth()+3)/3),S:s.getMilliseconds()}; - /(y+)/.test(t)&&(t=t.replace(RegExp.$1,(s.getFullYear()+"").substr(4-RegExp.$1.length))); - for(let e in i)new RegExp("("+e+")").test(t)&&(t=t.replace(RegExp.$1,1==RegExp.$1.length?i[e]:("00"+i[e]).substr((""+i[e]).length))); - return t - }msg(e=t,s="",i="",r){ - const o=t=>{ - if(!t)return t; - if("string"==typeof t)return this.isLoon()?t:this.isQuanX()?{"open-url":t} - :this.isSurge()?{url:t}:void 0; - if("object"==typeof t){ - if(this.isLoon()){ - let e=t.openUrl||t.url||t["open-url"],s=t.mediaUrl||t["media-url"]; - return{openUrl:e,mediaUrl:s} - } - if(this.isQuanX()){ - let e=t["open-url"]||t.url||t.openUrl,s=t["media-url"]||t.mediaUrl; - return{"open-url":e,"media-url":s} - }if(this.isSurge()){ - let e=t.url||t.openUrl||t["open-url"]; - return{url:e} - } - } - }; - if(this.isMute||(this.isSurge()||this.isLoon()?$notification.post(e,s,i,o(r)):this.isQuanX()&&$notify(e,s,i,o(r))),!this.isMuteLog){ - let t=["","==============📣系统通知📣=============="]; - t.push(e),s&&t.push(s),i&&t.push(i),console.log(t.join("\n")),this.logs=this.logs.concat(t) - } - }log(...t){ - t.length>0&&(this.logs=[...this.logs,...t]),console.log(t.join(this.logSeparator)) - }logErr(t,e){ - const s=!this.isSurge()&&!this.isQuanX()&&!this.isLoon(); - s?this.log("",`❗️${this.name}, 错误!`,t.stack):this.log("",`❗️${this.name}, 错误!`,t) - }wait(t){ - return new Promise(e=>setTimeout(e,t)) - }done(t={}){ - const e=(new Date).getTime(),s=(e-this.startTime)/1e3; - this.log("",`🔔${this.name}, 结束! 🕛 ${s} 秒`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t) - } - }(t,e) -}; \ No newline at end of file + +function Env(t,e){"undefined"!=typeof process&&JSON.stringify(process.env).indexOf("GITHUB")>-1&&process.exit(0);class s{constructor(t){this.env=t}send(t,e="GET"){t="string"==typeof t?{url:t}:t;let s=this.get;return"POST"===e&&(s=this.post),new Promise((e,i)=>{s.call(this,t,(t,s,r)=>{t?i(t):e(s)})})}get(t){return this.send.call(this.env,t)}post(t){return this.send.call(this.env,t,"POST")}}return new class{constructor(t,e){this.name=t,this.http=new s(this),this.data=null,this.dataFile="box.dat",this.logs=[],this.isMute=!1,this.isNeedRewrite=!1,this.logSeparator="\n",this.startTime=(new Date).getTime(),Object.assign(this,e),this.log("",`🔔${this.name}, 开始!`)}isNode(){return"undefined"!=typeof module&&!!module.exports}isQuanX(){return"undefined"!=typeof $task}isSurge(){return"undefined"!=typeof $httpClient&&"undefined"==typeof $loon}isLoon(){return"undefined"!=typeof $loon}toObj(t,e=null){try{return JSON.parse(t)}catch{return e}}toStr(t,e=null){try{return JSON.stringify(t)}catch{return e}}getjson(t,e){let s=e;const i=this.getdata(t);if(i)try{s=JSON.parse(this.getdata(t))}catch{}return s}setjson(t,e){try{return this.setdata(JSON.stringify(t),e)}catch{return!1}}getScript(t){return new Promise(e=>{this.get({url:t},(t,s,i)=>e(i))})}runScript(t,e){return new Promise(s=>{let i=this.getdata("@chavy_boxjs_userCfgs.httpapi");i=i?i.replace(/\n/g,"").trim():i;let r=this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout");r=r?1*r:20,r=e&&e.timeout?e.timeout:r;const[o,h]=i.split("@"),n={url:`http://${h}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:r},headers:{"X-Key":o,Accept:"*/*"}};this.post(n,(t,e,i)=>s(i))}).catch(t=>this.logErr(t))}loaddata(){if(!this.isNode())return{};{this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),i=!s&&this.fs.existsSync(e);if(!s&&!i)return{};{const i=s?t:e;try{return JSON.parse(this.fs.readFileSync(i))}catch(t){return{}}}}}writedata(){if(this.isNode()){this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),i=!s&&this.fs.existsSync(e),r=JSON.stringify(this.data);s?this.fs.writeFileSync(t,r):i?this.fs.writeFileSync(e,r):this.fs.writeFileSync(t,r)}}lodash_get(t,e,s){const i=e.replace(/\[(\d+)\]/g,".$1").split(".");let r=t;for(const t of i)if(r=Object(r)[t],void 0===r)return s;return r}lodash_set(t,e,s){return Object(t)!==t?t:(Array.isArray(e)||(e=e.toString().match(/[^.[\]]+/g)||[]),e.slice(0,-1).reduce((t,s,i)=>Object(t[s])===t[s]?t[s]:t[s]=Math.abs(e[i+1])>>0==+e[i+1]?[]:{},t)[e[e.length-1]]=s,t)}getdata(t){let e=this.getval(t);if(/^@/.test(t)){const[,s,i]=/^@(.*?)\.(.*?)$/.exec(t),r=s?this.getval(s):"";if(r)try{const t=JSON.parse(r);e=t?this.lodash_get(t,i,""):e}catch(t){e=""}}return e}setdata(t,e){let s=!1;if(/^@/.test(e)){const[,i,r]=/^@(.*?)\.(.*?)$/.exec(e),o=this.getval(i),h=i?"null"===o?null:o||"{}":"{}";try{const e=JSON.parse(h);this.lodash_set(e,r,t),s=this.setval(JSON.stringify(e),i)}catch(e){const o={};this.lodash_set(o,r,t),s=this.setval(JSON.stringify(o),i)}}else s=this.setval(t,e);return s}getval(t){return this.isSurge()||this.isLoon()?$persistentStore.read(t):this.isQuanX()?$prefs.valueForKey(t):this.isNode()?(this.data=this.loaddata(),this.data[t]):this.data&&this.data[t]||null}setval(t,e){return this.isSurge()||this.isLoon()?$persistentStore.write(t,e):this.isQuanX()?$prefs.setValueForKey(t,e):this.isNode()?(this.data=this.loaddata(),this.data[e]=t,this.writedata(),!0):this.data&&this.data[e]||null}initGotEnv(t){this.got=this.got?this.got:require("got"),this.cktough=this.cktough?this.cktough:require("tough-cookie"),this.ckjar=this.ckjar?this.ckjar:new this.cktough.CookieJar,t&&(t.headers=t.headers?t.headers:{},void 0===t.headers.Cookie&&void 0===t.cookieJar&&(t.cookieJar=this.ckjar))}get(t,e=(()=>{})){t.headers&&(delete t.headers["Content-Type"],delete t.headers["Content-Length"]),this.isSurge()||this.isLoon()?(this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.get(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)})):this.isQuanX()?(this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t))):this.isNode()&&(this.initGotEnv(t),this.got(t).on("redirect",(t,e)=>{try{if(t.headers["set-cookie"]){const s=t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString();s&&this.ckjar.setCookieSync(s,null),e.cookieJar=this.ckjar}}catch(t){this.logErr(t)}}).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)}))}post(t,e=(()=>{})){if(t.body&&t.headers&&!t.headers["Content-Type"]&&(t.headers["Content-Type"]="application/x-www-form-urlencoded"),t.headers&&delete t.headers["Content-Length"],this.isSurge()||this.isLoon())this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.post(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)});else if(this.isQuanX())t.method="POST",this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t));else if(this.isNode()){this.initGotEnv(t);const{url:s,...i}=t;this.got.post(s,i).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)})}}time(t,e=null){const s=e?new Date(e):new Date;let i={"M+":s.getMonth()+1,"d+":s.getDate(),"H+":s.getHours(),"m+":s.getMinutes(),"s+":s.getSeconds(),"q+":Math.floor((s.getMonth()+3)/3),S:s.getMilliseconds()};/(y+)/.test(t)&&(t=t.replace(RegExp.$1,(s.getFullYear()+"").substr(4-RegExp.$1.length)));for(let e in i)new RegExp("("+e+")").test(t)&&(t=t.replace(RegExp.$1,1==RegExp.$1.length?i[e]:("00"+i[e]).substr((""+i[e]).length)));return t}msg(e=t,s="",i="",r){const o=t=>{if(!t)return t;if("string"==typeof t)return this.isLoon()?t:this.isQuanX()?{"open-url":t}:this.isSurge()?{url:t}:void 0;if("object"==typeof t){if(this.isLoon()){let e=t.openUrl||t.url||t["open-url"],s=t.mediaUrl||t["media-url"];return{openUrl:e,mediaUrl:s}}if(this.isQuanX()){let e=t["open-url"]||t.url||t.openUrl,s=t["media-url"]||t.mediaUrl;return{"open-url":e,"media-url":s}}if(this.isSurge()){let e=t.url||t.openUrl||t["open-url"];return{url:e}}}};if(this.isMute||(this.isSurge()||this.isLoon()?$notification.post(e,s,i,o(r)):this.isQuanX()&&$notify(e,s,i,o(r))),!this.isMuteLog){let t=["","==============📣系统通知📣=============="];t.push(e),s&&t.push(s),i&&t.push(i),console.log(t.join("\n")),this.logs=this.logs.concat(t)}}log(...t){t.length>0&&(this.logs=[...this.logs,...t]),console.log(t.join(this.logSeparator))}logErr(t,e){const s=!this.isSurge()&&!this.isQuanX()&&!this.isLoon();s?this.log("",`❗️${this.name}, 错误!`,t.stack):this.log("",`❗️${this.name}, 错误!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`🔔${this.name}, 结束! 🕛 ${s} 秒`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)} \ No newline at end of file diff --git a/jd_wdz.js b/jd_wdz.js index 40b0cc5..c9bb880 100644 --- a/jd_wdz.js +++ b/jd_wdz.js @@ -1,733 +1,739 @@ /** * 微定制瓜分京豆 - * @param jd_wdz_activityId 活动id - * @param jd_wdz_activityUrl 活动url + * TG: https://t.me/HarbourToulu + * @param activityId 活动id + * @param activityUrl 活动url * @param pin 用户名 * @param num 跑多少ck * @param againUserIndex 需要重新跑的ck * @returns {Promise} - - cron "1 1 1 1 1" jd_wdz.js +1 1 1 1 * jd_wdz.js */ function openCardActivity(activityId, activityUrl, pin, num, againUserIndex) { - return new Promise((resolve) => { - const prefix = activityUrl.includes("cjhydz") ? "cjhydz" : "lzkjdz"; - const $ = new Env("微定制瓜分通用"); - const notify = $.isNode() ? require("./sendNotify") : ""; - const jdCookieNode = $.isNode() ? require("./jdCookie.js") : ""; - let cookiesArr = [], - cookie = "", - message = "", - messageTitle = "", - activityCookie = ""; + return new Promise((resolve) => { + const prefix = activityUrl.includes("cjhydz") ? "cjhydz" : "lzkjdz"; + const $ = new Env("微定制瓜分通用"); + const notify = $.isNode() ? require("./sendNotify") : ""; + const jdCookieNode = $.isNode() ? require("./jdCookie.js") : ""; + let cookiesArr = [], + cookie = "", + message = "", + messageTitle = "", + activityCookie = ""; - if (process.env.jd_wdz_activityId) - activityId = process.env.jd_wdz_activityId; - if (process.env.jd_wdz_activityUrl) - activityUrl = process.env.jd_wdz_activityUrl; - Object.keys(jdCookieNode).forEach((item) => - cookiesArr.push(jdCookieNode[item]) + if (process.env.jd_wdz_activityId) + activityId = process.env.jd_wdz_activityId; + if (process.env.jd_wdz_activityUrl) + activityUrl = process.env.jd_wdz_activityUrl; + Object.keys(jdCookieNode).forEach((item) => + cookiesArr.push(jdCookieNode[item]) + ); + + if(pin) { + const idx = cookiesArr.findIndex((v) => v.includes(pin)); + const currentCookie = cookiesArr.splice(idx, 1); + cookiesArr = [...currentCookie, ...cookiesArr.slice(1, num)]; + } + + + if (againUserIndex.length > 0) { + cookiesArr = cookiesArr.filter((v, idx) => againUserIndex.includes(idx)); + } + + !(async () => { + if (!activityId) { + $.msg($.name, "", "活动id不存在,请设置变量jd_zdjr_activityId"); + $.done(); + return; + } + if (!cookiesArr[0]) { + $.msg( + $.name, + "【提示】请先获取京东账号一cookie\x0a直接使用NobyDa的京东签到获取", + "https://bean.m.jd.com/", + { + "open-url": "https://bean.m.jd.com/", + } ); + return; + } + $.memberCount = 0; + messageTitle += "活动id:\n" + activityId + "\n"; + $.toactivity = []; + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i]; + $.UserName = decodeURIComponent( + cookie.match(/pt_pin=(.+?);/) && cookie.match(/pt_pin=(.+?);/)[1] + ); + $.index = i + 1; + $.isLogin = true; + $.nickName = ""; - if(pin) { - const idx = cookiesArr.findIndex((v) => v.includes(pin)); - const currentCookie = cookiesArr.splice(idx, 1); - cookiesArr = [...currentCookie, ...cookiesArr.slice(1, num)]; + console.log( + "\n******开始【京东账号" + + $.index + + "】" + + ($.nickName || $.UserName) + + "*********\n" + ); + + await jrzd(); + if ($.end) { + break; + } + if (!$.toactivity || $.maxTeam) { + break; + } + } + } + if (againUserIndex.length > 0) { + console.log( + `${againUserIndex.join("、")} 用户需要重新跑!即将开始重新跑~` + ); + await openCardActivity( + activityId, + activityUrl, + pin, + num, + againUserIndex + ); + } + resolve(); + })() + .catch((e) => { + $.log("", `❌ ${$.name}, 失败! 原因: ${e}!`, ""); + }) + .finally(() => { + $.done(); + }); + + async function jrzd() { + getUA(); + $.sid = ""; + $.userId = "599119"; + $.Token = ""; + $.Pin = ""; + $.hisPin = ""; + $.card = []; + + await getCk(); + await $.wait(1000); + await getToken(); + await $.wait(1000); + if ($.Token == "") { + console.log("获取[token]失败!"); + return; + } + await getSimpleActInfoVo(); + await $.wait(1000); + if ($.userId) { + await $.wait(1000); + if ($.Token) await getPin(); + console.log("pin:" + $.Pin); + + await $.wait(1000); + await accessLog(); + if (prefix !== "cjhydz") { + await $.wait(1000); + await getActMemberInfo(); + } + await $.wait(1000); + await getUserInfo(); + await $.wait(1000); + await getOpenCardAllStatuesNew(); + + if ($.index === 1) { + $.his = $.Pin; + $.hisNickName = $.nickName; + $.hisInviterImg = $.attrTouXiang; } + await $.wait(1000); + await joinTeam(); - if (againUserIndex.length > 0) { - cookiesArr = cookiesArr.filter((v, idx) => againUserIndex.includes(idx)); - } - - !(async () => { - if (!activityId) { - $.msg($.name, "", "活动id不存在,请设置变量jd_zdjr_activityId"); - $.done(); - return; - } - if (!cookiesArr[0]) { - $.msg( - $.name, - "【提示】请先获取京东账号一cookie\x0a直接使用NobyDa的京东签到获取", - "https://bean.m.jd.com/", - { - "open-url": "https://bean.m.jd.com/", - } - ); - return; - } - $.memberCount = 0; - messageTitle += "活动id:\n" + activityId + "\n"; - $.toactivity = []; - for (let i = 0; i < cookiesArr.length; i++) { - if (cookiesArr[i]) { - cookie = cookiesArr[i]; - $.UserName = decodeURIComponent( - cookie.match(/pt_pin=(.+?);/) && cookie.match(/pt_pin=(.+?);/)[1] - ); - $.index = i + 1; - $.isLogin = true; - $.nickName = ""; - - console.log( - "\n******开始【京东账号" + - $.index + - "】" + - ($.nickName || $.UserName) + - "*********\n" - ); - - await jrzd(); - if ($.end) { - break; - } - if (!$.toactivity || $.maxTeam) { - break; - } - } - } - if (againUserIndex.length > 0) { - console.log( - `${againUserIndex.join("、")} 用户需要重新跑!即将开始重新跑~` - ); - await openCardActivity( - activityId, - activityUrl, - pin, - num, - againUserIndex - ); - } - resolve(); - })() - .catch((e) => { - $.log("", `❌ ${$.name}, 失败! 原因: ${e}!`, ""); - }) - .finally(() => { - $.done(); - }); - - async function jrzd() { - getUA(); - $.sid = ""; - $.userId = "599119"; - $.Token = ""; - $.Pin = ""; - $.hisPin = ""; - $.card = []; - - await getCk(); + if ($.card.length > 0) { + let i = 0; + do { + await joinShop($.card[i]); await $.wait(1000); - await getToken(); - await $.wait(1000); - if ($.Token == "") { - console.log("获取[token]失败!"); - return; - } - await getSimpleActInfoVo(); - await $.wait(1000); - if ($.userId) { - await $.wait(1000); - if ($.Token) await getPin(); - console.log("pin:" + $.Pin); - - await $.wait(1000); - await accessLog(); - if (prefix !== "cjhydz") { - await $.wait(1000); - await getActMemberInfo(); - } - await $.wait(1000); - await getUserInfo(); - await $.wait(1000); - await getOpenCardAllStatuesNew(); - - if ($.index === 1) { - $.his = $.Pin; - $.hisNickName = $.nickName; - $.hisInviterImg = $.attrTouXiang; - } - - await $.wait(1000); - await joinTeam(); - - if ($.card.length > 0) { - let i = 0; - do { - await joinShop($.card[i]); - await $.wait(1000); - i++; - } while (i < $.card.length); - } - await $.wait(1000); - await getOpenCardAllStatuesNew(); - if ($.maxTeam) { - console.log("队伍已满员"); - return; - } - } else { - console.log("【京东账号" + $.index + "】 未能获取活动信息"); - message += "【京东账号" + $.index + "】 未能获取活动信息\n"; - } + i++; + } while (i < $.card.length); } - - function getUA() { - $.UA = `jdapp;iPhone;10.0.10;14.3;${randomString( - 40 - )};network/wifi;model/iPhone12,1;addressid/4199175193;appBuild/167741;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1`; + await $.wait(1000); + await getOpenCardAllStatuesNew(); + if ($.maxTeam) { + console.log("队伍已满员"); + return; } + } else { + console.log("【京东账号" + $.index + "】 未能获取活动信息"); + message += "【京东账号" + $.index + "】 未能获取活动信息\n"; + } + } - function getSimpleActInfoVo() { - return new Promise((resolve) => { - let body = `activityId=${activityId}`; - $.post( - taskPostUrl("/customer/getSimpleActInfoVo", body), - async (err, resp, data) => { - try { - if (err) { - console.log(`${$.toStr(err)}`); - console.log( - `${$.name} getSimpleActInfoVo API请求失败,请检查网路重试` - ); - } else { - if (resp.status == 200) { - refreshToken(resp); - } - } - } catch (e) { - $.logErr(e, resp); - } finally { - resolve(); - } - } - ); - }); - } + function getUA() { + $.UA = `jdapp;iPhone;10.0.10;14.3;${randomString( + 40 + )};network/wifi;model/iPhone12,1;addressid/4199175193;appBuild/167741;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1`; + } - function randomString(e) { - e = e || 32; - let t = "abcdef0123456789", - a = t.length, - n = ""; - for (i = 0; i < e; i++) n += t.charAt(Math.floor(Math.random() * a)); - return n; - } - - function getCk() { - return new Promise((resolve) => { - let options = { - url: - activityUrl + - "/microDz/invite/activity/wx/view/index?activityId=" + - activityId, - headers: { - Cookie: cookie, - "User-Agent": $.UA, - }, - }; - $.get(options, async (err, resp, data) => { - try { - if (err) { - console.log("" + JSON.stringify(err)); - console.log($.name + " cookie API请求失败,请检查网路重试"); - } else { - if (resp.status == 200) { - refreshToken(resp); - } - } - } catch (e) { - $.logErr(e, resp); - } finally { - resolve(); - } - }); - }); - } - - function getToken() { - return new Promise((resolve) => { - let body = `adid=7B411CD9-D62C-425B-B083-9AFC49B94228&area=16_1332_42932_43102&body=%7B%22url%22%3A%22https%3A%5C/%5C/cjhydz-isv.isvjcloud.com%22%2C%22id%22%3A%22%22%7D&build=167541&client=apple&clientVersion=9.4.0&d_brand=apple&d_model=iPhone8%2C1&eid=eidId10b812191seBCFGmtbeTX2vXF3lbgDAVwQhSA8wKqj6OA9J4foPQm3UzRwrrLdO23B3E2wCUY/bODH01VnxiEnAUvoM6SiEnmP3IPqRuO%2By/%2BZo&isBackground=N&joycious=48&lang=zh_CN&networkType=wifi&networklibtype=JDNetworkBaseAF&openudid=2f7578cb634065f9beae94d013f172e197d62283&osVersion=13.1.2&partner=apple&rfs=0000&scope=11&screen=750%2A1334&sign=60bde51b4b7f7ff6e1bc1f473ecf3d41&st=1613720203903&sv=110&uts=0f31TVRjBStG9NoZJdXLGd939Wv4AlsWNAeL1nxafUsZqiV4NLsVElz6AjC4L7tsnZ1loeT2A8Z5/KfI/YoJAUfJzTd8kCedfnLG522ydI0p40oi8hT2p2sNZiIIRYCfjIr7IAL%2BFkLsrWdSiPZP5QLptc8Cy4Od6/cdYidClR0NwPMd58K5J9narz78y9ocGe8uTfyBIoA9aCd/X3Muxw%3D%3D&uuid=hjudwgohxzVu96krv/T6Hg%3D%3D&wifiBssid=9cf90c586c4468e00678545b16176ed2`; - $.post( - taskUrl("?functionId=isvObfuscator", body), - async (err, resp, data) => { - try { - if (err) { - console.log("" + JSON.stringify(err)); - console.log($.name + " 2 API请求失败,请检查网路重试"); - } else { - if (safeGet(data)) { - data = JSON.parse(data); - if (data.code == 0 && data.token) { - $.Token = data.token; - } else { - console.log("异常2:" + JSON.stringify(data)); - } - } - } - } catch (e) { - $.logErr(e, resp); - } finally { - resolve(); - } - } - ); - }); - } - - function getPin() { - return new Promise((resolve) => { - let body = "userId=" + $.userId + "&token=" + $.Token + "&fromType=APP"; - $.post( - taskPostUrl("/customer/getMyPing", body), - async (err, resp, data) => { - try { - if (err) { - console.log("" + JSON.stringify(err)); - console.log($.name + " 3 API请求失败,请检查网路重试"); - } else { - if (safeGet(data)) { - data = JSON.parse(data); - if (data.result && data.data) { - $.Pin = data.data.secretPin; - $.AUTH_C_USER = $.Pin; - } else { - console.log("异常3:" + JSON.stringify(data)); - } - } - } - } catch (e) { - $.logErr(e, resp); - } finally { - resolve(); - } - } - ); - }); - } - - function joinShop(openCardLink) { - return new Promise(async (resolve) => { - if (prefix == "cjhydz") { - let channel = openCardLink.match(/channel=(\d+)/)[1]; - let venderId = openCardLink.match(/venderId=(\d+)/)[1]; - let shopId = openCardLink.match(/shopId=(\d+)/)[1]; - const body = { - venderId: venderId, - shopId: shopId, - bindByVerifyCodeFlag: 1, - registerExtend: {}, - writeChildFlag: 0, - channel: channel, - }; - let 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=8888&jsonp=jsonp_${Date.now()}_${String( - Math.random() - ).slice(3, 8)}&h5st=20220412164645241%3B3634d1aeada6d9cd11a7526a3a6ac63e%3B169f1%3Btk02wd66f1d7418nXuLjsmO3oJMCxUqKVwIf4q1WRptKRT3nJSrx01oYYBAylbSuyg4sipnEzyEJOZuFjfG2QERcBtzd%3B6b455234e93be4ec963cd7c575d70882b838ba588149a1f54b69c8d0dacf14da%3B3.0%3B1649753205241`; - let referer = `${openCardLink}&returnUrl=${encodeURIComponent( - `https://cjhydz-isv.isvjcloud.com/microDz/invite/activity/wx/view/index?activityId=${activityId}&adsource=cjhdc&isOpenCardBack=iocb` - )}`; - await jiaru(url, referer); - resolve(); - } else { - let url = `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body=${encodeURIComponent( - JSON.stringify({ - venderId: $.userId, - shopId: $.userId, - bindByVerifyCodeFlag: 1, - registerExtend: {}, - writeChildFlag: 0, - channel: $.channel, - }) - )}&client=H5&clientVersion=9.2.0&uuid=88888&jsonp=jsonp_${Date.now()}_${String( - Math.random() - ).slice(3, 8)}&h5st=20220412164645241%3B3634d1aeada6d9cd11a7526a3a6ac63e%3B169f1%3Btk02wd66f1d7418nXuLjsmO3oJMCxUqKVwIf4q1WRptKRT3nJSrx01oYYBAylbSuyg4sipnEzyEJOZuFjfG2QERcBtzd%3B6b455234e93be4ec963cd7c575d70882b838ba588149a1f54b69c8d0dacf14da%3B3.0%3B1649753205241`; - let referer = `https://shopmember.m.jd.com/shopcard/?venderId=${ - $.userId - }&shopId=${$.userId}&channel=${ - $.channel - }&returnUrl=${encodeURIComponent( - "https://lzkjdz-isv.isvjd.com/wxTeam/activity2/${activityId}?activityId=${activityId}c&adsource=cjhdc&isOpenCardBack=iocb" - )}`; - await jiaru(url, referer); - resolve(); - } - }); - } - - function jiaru(url, referer) { - return new Promise((resolve) => { - let options = { - url: url, - headers: { - Accept: "*/*", - "Accept-Encoding": "gzip, deflate, br", - "Accept-Language": "zh-cn", - Connection: "keep-alive", - Host: "api.m.jd.com", - Referer: referer, - Cookie: cookie, - "User-Agent": $.UA, - }, - }; - $.get(options, async (err, resp, data) => { - try { - if (err) { - console.log("" + JSON.stringify(err)); - console.log($.name + "\x20入会\x20API请求失败,请检查网路重试"); - } else { - $.log(data); - } - } catch (e) { - $.logErr(e, resp); - } finally { - resolve(); - } - }); - }); - } - - function getActMemberInfo() { - return new Promise((resolve) => { - let options = { - url: `https://lzkjdz-isv.isvjd.com/wxCommonInfo/getActMemberInfo`, - headers: { - cookie: - activityCookie + ";IsvToken=" + $.Token + ";AUTH_C_USER=" + $.Pin, - Connection: `keep-alive`, - "Accept-Encoding": `gzip, deflate, br`, - "Content-Type": `application/x-www-form-urlencoded; charset=UTF-8`, - Origin: `https://lzkj-isv.isvjd.com`, - "User-Agent": $.UA, - "Accept-Language": `zh-cn`, - Host: `lzkjdz-isv.isvjd.com`, - Referer: `https://lzkjdz-isv.isvjd.com/wxTeam/activity2/${activityId}?activityId=${activityId}&adsource=cjhdc&isOpenCardBack=iocb`, - Accept: `application/json, text/javascript, */*; q=0.01`, - }, - body: `venderId=${ - $.userId - }&activityId=${activityId}&pin=${encodeURIComponent($.Pin)}`, - }; - $.post(options, async (err, resp, data) => { - try { - if (err) { - console.log("" + JSON.stringify(err)); - console.log($.name + " 1 API请求失败,请检查网路重试"); - } else { - if (data && safeGet(data)) { - data = JSON.parse(data); - if (data.data) { - if (data.data.openCard) return; - if (data.data.openCardUrl) { - $.channel = data.data.openCardUrl - .match(/channel=\d+/)[0] - .split("=")[1]; - } else { - console.log("店家不返回开卡地址。活动有问题。。"); - $.end = true; - return; - } - } else { - console.log("异常1:" + JSON.stringify(data)); - } - } - } - } catch (e) { - $.logErr(e, resp); - } finally { - resolve(); - } - }); - }); - } - - function getUserInfo() { - return new Promise((resolve) => { - let body = `pin=${ - prefix === "cjhydz" - ? encodeURIComponent(encodeURIComponent($.Pin)) - : encodeURIComponent($.Pin) - }`; - $.post( - taskPostUrl("/wxActionCommon/getUserInfo", body), - async (err, resp, data) => { - try { - if (err) { - console.log("" + JSON.stringify(err)); - console.log($.name + "\x206-1\x20API请求失败,请检查网路重试"); - } else { - if (safeGet(data)) { - data = JSON.parse(data); - if (data.result && data.data) { - $.attrTouXiang = data.data.yunMidImageUrl - ? data.data.yunMidImageUrl - : "https://img10.360buyimg.com/imgzone/jfs/t1/21383/2/6633/3879/5c5138d8E0967ccf2/91da57c5e2166005.jpg"; - $.nickName = data.data.nickname; - } else { - console.log("异常6-2:" + JSON.stringify(data)); - } - } - } - } catch (e) { - $.logErr(e, resp); - } finally { - resolve(); - } - } - ); - }); - } - - function joinTeam(count = 0x0) { - return new Promise((resolve) => { - let pin = encodeURIComponent($.Pin); - let hisPin = encodeURIComponent(encodeURIComponent($.his)); - if (count == 1) { - pin = encodeURIComponent(encodeURIComponent($.Pin)); - } - let body = `activityId=${activityId}&inviterNick=${encodeURIComponent( - $.hisNickName - )}&inviteeNick=${encodeURIComponent( - $.nickName - )}&inviter=${hisPin}&invitee=${pin}&inviterImg=${encodeURIComponent( - $.hisInviterImg - )}&inviteeImg=${encodeURIComponent($.attrTouXiang)}`; - $.post( - taskPostUrl("/microDz/invite/activity/wx/acceptInvite", body), - async (err, resp, data) => { - try { - if (err) { - console.log("" + JSON.stringify(err)); - console.log($.name + "\x207\x20API请求失败,请检查网路重试"); - } else { - if (safeGet(data)) { - data = JSON.parse(data); - if (data.result && data.data) { - message += "【京东账号" + $.index + "】 加入队伍\n"; - $.log("加入队伍成功"); - } else { - if ( - data.errorMessage.indexOf("店铺会员") > -1 && - count != 3 - ) { - await joinShop(); - await joinTeam(3); - } else if (data.errorMessage.indexOf("队伍已经满员") > -1) { - $.maxTeam = true; - } else if ( - data.errorMessage.indexOf("奖品与您擦肩而过") > -1 && - count == 0 - ) { - await joinTeam(1); - } else { - console.log("异常7:" + JSON.stringify(data)); - if (!data.data.rewardPoint) againUserIndex.push($.index); - if (data.errorMessage.includes("奖品发送完毕")) - process.exit(1); - message += - "【京东账号" + - $.index + - "】\x20" + - data.errorMessage + - "\x0a"; - } - } - } - } - } catch (e) { - $.logErr(e, resp); - } finally { - resolve(); - } - } - ); - }); - } - - function getOpenCardAllStatuesNew() { - return new Promise((resolve) => { - let options = { - url: `https://cjhydz-isv.isvjcloud.com/microDz/invite/activity/wx/getOpenCardAllStatuesNew`, - headers: { - cookie: - activityCookie + ";IsvToken=" + $.Token + ";AUTH_C_USER=" + $.Pin, - Connection: `keep-alive`, - "Accept-Encoding": `gzip, deflate, br`, - "Content-Type": `application/x-www-form-urlencoded; charset=UTF-8`, - "User-Agent": $.UA, - "Accept-Language": `zh-cn`, - Referer: `https://cjhydz-isv.isvjcloud.com/microDz/invite/activity/wx/view/index?activityId=${activityId}`, - Accept: `application/json, text/javascript, */*; q=0.01`, - }, - body: `isInvited=1&activityId=${activityId}&pin=${encodeURIComponent( - encodeURIComponent($.Pin) - )}`, - }; - $.post(options, async (err, resp, data) => { - try { - if (err) { - console.log("" + JSON.stringify(err)); - console.log($.name + " 1 API请求失败,请检查网路重试"); - } else { - if (data && safeGet(data)) { - data = JSON.parse(data); - if (data.data && data.data.isCanJoin) { - // console.log(data.data) - (data.data.list || []).forEach((v) => { - if (v.openCardLink) { - $.card.push(v.openCardLink); - } - }); - // console.log($.card) - } - } - } - } catch (e) { - // $.card = [ - // 'https://shopmember.m.jd.com/shopcard/?venderId=1000006644&shopId=1000006644&channel=8802', - // 'https://shopmember.m.jd.com/shopcard/?venderId=1000000192&shopId=1000000192&channel=8802', - // 'https://shopmember.m.jd.com/shopcard/?venderId=1000099547&shopId=1000099547&channel=8802' - // ] - $.logErr(e, resp); - } finally { - resolve(); - } - }); - }); - } - - function taskPostUrl(url, body) { - return { - url: "" + activityUrl + url, - body: body, - headers: { - Accept: "application/json", - "Accept-Encoding": "gzip, deflate, br", - "Accept-Language": "zh-cn", - Connection: "keep-alive", - Host: `${prefix}-isv.isvjcloud.com`, - Origin: `https://${prefix}-isv.isvjcloud.com`, - "Content-Type": "application/x-www-form-urlencoded", - Referer: - activityUrl + - "/microDz/invite/activity/wx/view/index?activityId=" + - activityId, - Cookie: - cookie + - activityCookie + - ";IsvToken=" + - $.Token + - ";AUTH_C_USER=" + - $.AUTH_C_USER, - "User-Agent": $.UA, - }, - }; - } - - function taskUrl(url, body) { - return { - url: "https://api.m.jd.com/client.action" + url, - body: body, - headers: { - Accept: "*/*", - "Accept-Encoding": "gzip, deflate, br", - "Accept-Language": "zh-cn", - Connection: "keep-alive", - "Content-Type": "application/x-www-form-urlencoded", - Host: "api.m.jd.com", - Cookie: cookie, - "User-Agent": $.UA, - }, - }; - } - - function safeGet(data) { + function getSimpleActInfoVo() { + return new Promise((resolve) => { + let body = `activityId=${activityId}`; + $.post( + taskPostUrl("/customer/getSimpleActInfoVo", body), + async (err, resp, data) => { try { - if (typeof JSON.parse(data) == "object") { - return true; - } + if (err) { + console.log(`${$.toStr(err)}`); + console.log( + `${$.name} getSimpleActInfoVo API请求失败,请检查网路重试` + ); + } else { + // if (resp.status == 200) { + // refreshToken(resp); + // } + } } catch (e) { - console.log(e); - console.log("京东服务器访问数据为空,请检查自身设备网络情况"); - return false; + $.logErr(e, resp); + } finally { + resolve(); } - } + } + ); + }); + } - function accessLog() { - return new Promise(async (resolve) => { - const options = { - url: `https://${prefix}-isv.isvjcloud.com/common/accessLog`, - headers: { - Accept: "application/json", - "Accept-Encoding": "gzip, deflate, br", - "Accept-Language": "zh-cn", - Connection: "keep-alive", - Host: `${prefix}-isv.isvjcloud.com`, - Origin: `https://${prefix}-isv.isvjcloud.com`, - "Content-Type": "application/x-www-form-urlencoded", - Referer: - activityUrl + - "/microDz/invite/activity/wx/view/index?activityId=" + - activityId, - Cookie: - cookie + - activityCookie + - ";IsvToken=" + - $.Token + - ";AUTH_C_USER=" + - $.AUTH_C_USER, - "User-Agent": $.UA, - }, - body: `venderId=1&code=99&pin=${encodeURIComponent( - encodeURIComponent($.Pin) - )}&activityId=${activityId}&pageUrl=https%3A%2F%2F${prefix}-isv.isvjcloud.com%2FmicroDz%2Finvite%2Factivity%2Fwx%2Fview%2Findex%3FactivityId%3D${activityId}&subType=app`, - }; - $.post(options, (err, resp, data) => { - try { - if (err) { - console.log("" + JSON.stringify(err)); - console.log($.name + "\x20API请求失败,请检查网路重试"); - } else { - if (resp.status == 200) { - refreshToken(resp); - } - } - } catch (e) { - $.logErr(e, resp); - } finally { - resolve(); + function randomString(e) { + e = e || 32; + let t = "abcdef0123456789", + a = t.length, + n = ""; + for (i = 0; i < e; i++) n += t.charAt(Math.floor(Math.random() * a)); + return n; + } + + function getCk() { + return new Promise((resolve) => { + let options = { + url: + activityUrl + + "/microDz/invite/activity/wx/view/index?activityId=" + + activityId, + headers: { + Cookie: cookie, + "User-Agent": $.UA, + }, + }; + $.get(options, async (err, resp, data) => { + try { + if (err) { + console.log("" + JSON.stringify(err)); + console.log($.name + " cookie API请求失败,请检查网路重试"); + } else { + if (resp.status == 200) { + refreshToken(resp); + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }); + }); + } + + function getToken() { + return new Promise((resolve) => { + let body = `adid=7B411CD9-D62C-425B-B083-9AFC49B94228&area=16_1332_42932_43102&body=%7B%22url%22%3A%22https%3A%5C/%5C/cjhydz-isv.isvjcloud.com%22%2C%22id%22%3A%22%22%7D&build=167541&client=apple&clientVersion=9.4.0&d_brand=apple&d_model=iPhone8%2C1&eid=eidId10b812191seBCFGmtbeTX2vXF3lbgDAVwQhSA8wKqj6OA9J4foPQm3UzRwrrLdO23B3E2wCUY/bODH01VnxiEnAUvoM6SiEnmP3IPqRuO%2By/%2BZo&isBackground=N&joycious=48&lang=zh_CN&networkType=wifi&networklibtype=JDNetworkBaseAF&openudid=2f7578cb634065f9beae94d013f172e197d62283&osVersion=13.1.2&partner=apple&rfs=0000&scope=11&screen=750%2A1334&sign=60bde51b4b7f7ff6e1bc1f473ecf3d41&st=1613720203903&sv=110&uts=0f31TVRjBStG9NoZJdXLGd939Wv4AlsWNAeL1nxafUsZqiV4NLsVElz6AjC4L7tsnZ1loeT2A8Z5/KfI/YoJAUfJzTd8kCedfnLG522ydI0p40oi8hT2p2sNZiIIRYCfjIr7IAL%2BFkLsrWdSiPZP5QLptc8Cy4Od6/cdYidClR0NwPMd58K5J9narz78y9ocGe8uTfyBIoA9aCd/X3Muxw%3D%3D&uuid=hjudwgohxzVu96krv/T6Hg%3D%3D&wifiBssid=9cf90c586c4468e00678545b16176ed2`; + $.post( + taskUrl("?functionId=isvObfuscator", body), + async (err, resp, data) => { + try { + if (err) { + console.log("" + JSON.stringify(err)); + console.log($.name + " 2 API请求失败,请检查网路重试"); + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.code == 0 && data.token) { + $.Token = data.token; + } else { + console.log("异常2:" + JSON.stringify(data)); + } + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + } + ); + }); + } + + function getPin() { + return new Promise((resolve) => { + let body = "userId=" + $.userId + "&token=" + $.Token + "&fromType=APP"; + $.post( + taskPostUrl("/customer/getMyPing", body), + async (err, resp, data) => { + try { + if (err) { + console.log("" + JSON.stringify(err)); + console.log($.name + " 3 API请求失败,请检查网路重试"); + } else { + if (resp.status == 200) { + refreshToken(resp); + } + if (safeGet(data)) { + data = JSON.parse(data); + if (data.result && data.data) { + $.Pin = data.data.secretPin; + $.AUTH_C_USER = $.Pin; + } else { + console.log("异常3:" + JSON.stringify(data)); + } + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + } + ); + }); + } + + function joinShop(openCardLink) { + return new Promise(async (resolve) => { + if (prefix == "cjhydz") { + let channel = openCardLink.match(/channel=(\d+)/)[1]; + let venderId = openCardLink.match(/venderId=(\d+)/)[1]; + let shopId = openCardLink.match(/shopId=(\d+)/)[1]; + const body = { + venderId: venderId, + shopId: shopId, + bindByVerifyCodeFlag: 1, + registerExtend: {}, + writeChildFlag: 0, + channel: channel, + }; + let 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=8888&jsonp=jsonp_${Date.now()}_${String( + Math.random() + ).slice(3, 8)}&h5st=20220614102046318%3B7327310984571307%3Bef79a%3Btk02wa31b1c7718neoZNHBp75rw4pE%2Fw7fXko2SdFCd1vIeWy005pEHdm0lw2CimWpaw3qc9il8r9xVLHp%2Bhzmo%2B4swg%3Bdd9526fc08234276b392435c8623f4a737e07d4503fab90bf2cd98d2a3a778ac%3B3.0%3B1655173246318`; + let referer = `${openCardLink}&returnUrl=${encodeURIComponent( + `https://cjhydz-isv.isvjcloud.com/microDz/invite/activity/wx/view/index?activityId=${activityId}&adsource=cjhdc&isOpenCardBack=iocb` + )}`; + await jiaru(url, referer); + resolve(); + } else { + let url = `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body=${encodeURIComponent( + JSON.stringify({ + venderId: $.userId, + shopId: $.userId, + bindByVerifyCodeFlag: 1, + registerExtend: {}, + writeChildFlag: 0, + channel: $.channel, + }) + )}&client=H5&clientVersion=9.2.0&uuid=88888&jsonp=jsonp_${Date.now()}_${String( + Math.random() + ).slice(3, 8)}&h5st=20220614102046318%3B7327310984571307%3Bef79a%3Btk02wa31b1c7718neoZNHBp75rw4pE%2Fw7fXko2SdFCd1vIeWy005pEHdm0lw2CimWpaw3qc9il8r9xVLHp%2Bhzmo%2B4swg%3Bdd9526fc08234276b392435c8623f4a737e07d4503fab90bf2cd98d2a3a778ac%3B3.0%3B1655173246318`; + let referer = `https://shopmember.m.jd.com/shopcard/?venderId=${ + $.userId + }&shopId=${$.userId}&channel=${ + $.channel + }&returnUrl=${encodeURIComponent( + "https://lzkjdz-isv.isvjd.com/wxTeam/activity2/${activityId}?activityId=${activityId}c&adsource=cjhdc&isOpenCardBack=iocb" + )}`; + await jiaru(url, referer); + resolve(); + } + }); + } + + function jiaru(url, referer) { + return new Promise((resolve) => { + let options = { + url: url, + headers: { + Accept: "*/*", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + Connection: "keep-alive", + Host: "api.m.jd.com", + Referer: referer, + Cookie: cookie, + "User-Agent": $.UA, + }, + }; + $.get(options, async (err, resp, data) => { + try { + if (err) { + console.log("" + JSON.stringify(err)); + console.log($.name + "\x20入会\x20API请求失败,请检查网路重试"); + } else { + $.log(data); + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }); + }); + } + + function getActMemberInfo() { + return new Promise((resolve) => { + let options = { + url: `https://lzkjdz-isv.isvjd.com/wxCommonInfo/getActMemberInfo`, + headers: { + cookie: + activityCookie + ";IsvToken=" + $.Token + ";AUTH_C_USER=" + $.Pin, + Connection: `keep-alive`, + "Accept-Encoding": `gzip, deflate, br`, + "Content-Type": `application/x-www-form-urlencoded; charset=UTF-8`, + Origin: `https://lzkj-isv.isvjd.com`, + "User-Agent": $.UA, + "Accept-Language": `zh-cn`, + Host: `lzkjdz-isv.isvjd.com`, + Referer: `https://lzkjdz-isv.isvjd.com/wxTeam/activity2/${activityId}?activityId=${activityId}&adsource=cjhdc&isOpenCardBack=iocb`, + Accept: `application/json, text/javascript, */*; q=0.01`, + }, + body: `venderId=${ + $.userId + }&activityId=${activityId}&pin=${encodeURIComponent($.Pin)}`, + }; + $.post(options, async (err, resp, data) => { + try { + if (err) { + console.log("" + JSON.stringify(err)); + console.log($.name + " 1 API请求失败,请检查网路重试"); + } else { + if (data && safeGet(data)) { + data = JSON.parse(data); + if (data.data) { + if (data.data.openCard) return; + if (data.data.openCardUrl) { + $.channel = data.data.openCardUrl + .match(/channel=\d+/)[0] + .split("=")[1]; + } else { + console.log("店家不返回开卡地址。活动有问题。。"); + $.end = true; + return; + } + } else { + console.log("异常1:" + JSON.stringify(data)); + } + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }); + }); + } + + function getUserInfo() { + return new Promise((resolve) => { + let body = `pin=${ + prefix === "cjhydz" + ? encodeURIComponent(encodeURIComponent($.Pin)) + : encodeURIComponent($.Pin) + }`; + $.post( + taskPostUrl("/wxActionCommon/getUserInfo", body), + async (err, resp, data) => { + try { + if (err) { + console.log("" + JSON.stringify(err)); + console.log($.name + "\x206-1\x20API请求失败,请检查网路重试"); + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.result && data.data) { + $.attrTouXiang = data.data.yunMidImageUrl + ? data.data.yunMidImageUrl + : "https://img10.360buyimg.com/imgzone/jfs/t1/21383/2/6633/3879/5c5138d8E0967ccf2/91da57c5e2166005.jpg"; + $.nickName = data.data.nickname; + } else { + console.log("异常6-2:" + JSON.stringify(data)); + } + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + } + ); + }); + } + + function joinTeam(count = 0x0) { + return new Promise((resolve) => { + let pin = encodeURIComponent($.Pin); + let hisPin = encodeURIComponent(encodeURIComponent($.his)); + if (count == 1) { + pin = encodeURIComponent(encodeURIComponent($.Pin)); + } + let body = `activityId=${activityId}&inviterNick=${encodeURIComponent( + $.hisNickName + )}&inviteeNick=${encodeURIComponent( + $.nickName + )}&inviter=${hisPin}&invitee=${pin}&inviterImg=${encodeURIComponent( + $.hisInviterImg + )}&inviteeImg=${encodeURIComponent($.attrTouXiang)}`; + $.post( + taskPostUrl("/microDz/invite/activity/wx/acceptInvite", body), + async (err, resp, data) => { + try { + if (err) { + console.log("" + JSON.stringify(err)); + console.log($.name + "\x207\x20API请求失败,请检查网路重试"); + } else { + if (safeGet(data)) { + data = JSON.parse(data); + if (data.result && data.data) { + message += "【京东账号" + $.index + "】 加入队伍\n"; + $.log("加入队伍成功"); + } else { + if ( + data.errorMessage.indexOf("店铺会员") > -1 && + count != 3 + ) { + await joinShop(); + await joinTeam(3); + } else if (data.errorMessage.indexOf("队伍已经满员") > -1) { + $.maxTeam = true; + } else if ( + data.errorMessage.indexOf("奖品与您擦肩而过") > -1 && + count == 0 + ) { + await joinTeam(1); + } else { + console.log("异常7:" + JSON.stringify(data)); + if (!data.data.rewardPoint) againUserIndex.push($.index); + if (data.errorMessage.includes("奖品发送完毕")) + process.exit(1); + message += + "【京东账号" + + $.index + + "】\x20" + + data.errorMessage + + "\x0a"; } - }); - }); - } - - function refreshToken(resp) { - let cookies = resp.headers["set-cookie"]; - if (cookies) { - activityCookie = cookies - .map((v) => { - return v.split(";")[0]; - }) - .join(";"); + } + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); } + } + ); + }); + } + + function getOpenCardAllStatuesNew() { + return new Promise((resolve) => { + let options = { + url: `https://cjhydz-isv.isvjcloud.com/microDz/invite/activity/wx/getOpenCardAllStatuesNew`, + headers: { + cookie: + activityCookie + ";IsvToken=" + $.Token + ";AUTH_C_USER=" + $.Pin, + Connection: `keep-alive`, + "Accept-Encoding": `gzip, deflate, br`, + "Content-Type": `application/x-www-form-urlencoded; charset=UTF-8`, + "User-Agent": $.UA, + "Accept-Language": `zh-cn`, + Referer: `https://cjhydz-isv.isvjcloud.com/microDz/invite/activity/wx/view/index?activityId=${activityId}`, + Accept: `application/json, text/javascript, */*; q=0.01`, + }, + body: `isInvited=1&activityId=${activityId}&pin=${encodeURIComponent( + encodeURIComponent($.Pin) + )}`, + }; + $.post(options, async (err, resp, data) => { + try { + if (err) { + console.log("" + JSON.stringify(err)); + console.log($.name + " 1 API请求失败,请检查网路重试"); + } else { + if (data && safeGet(data)) { + data = JSON.parse(data); + if (data.data && data.data.isCanJoin) { + // console.log(data.data) + (data.data.list || []).forEach((v) => { + if (v.openCardLink) { + $.card.push(v.openCardLink); + } + }); + // console.log($.card) + } + } + } + } catch (e) { + // $.card = [ + // 'https://shopmember.m.jd.com/shopcard/?venderId=1000006644&shopId=1000006644&channel=8802', + // 'https://shopmember.m.jd.com/shopcard/?venderId=1000000192&shopId=1000000192&channel=8802', + // 'https://shopmember.m.jd.com/shopcard/?venderId=1000099547&shopId=1000099547&channel=8802' + // ] + $.logErr(e, resp); + } finally { + resolve(); + } + }); + }); + } + + function taskPostUrl(url, body) { + return { + url: "" + activityUrl + url, + body: body, + headers: { + Accept: "application/json", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + Connection: "keep-alive", + Host: `${prefix}-isv.isvjcloud.com`, + Origin: `https://${prefix}-isv.isvjcloud.com`, + "Content-Type": "application/x-www-form-urlencoded", + Referer: + activityUrl + + "/microDz/invite/activity/wx/view/index?activityId=" + + activityId, + Cookie: + cookie + + activityCookie + + ";IsvToken=" + + $.Token + + ";AUTH_C_USER=" + + $.AUTH_C_USER, + "User-Agent": $.UA, + }, + }; + } + + function taskUrl(url, body) { + return { + url: "https://api.m.jd.com/client.action" + url, + body: body, + headers: { + Accept: "*/*", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + Connection: "keep-alive", + "Content-Type": "application/x-www-form-urlencoded", + Host: "api.m.jd.com", + Cookie: cookie, + "User-Agent": $.UA, + }, + }; + } + + function safeGet(data) { + try { + if (typeof JSON.parse(data) == "object") { + return true; } - }); + } catch (e) { + console.log(e); + console.log("京东服务器访问数据为空,请检查自身设备网络情况"); + return false; + } + } + + function accessLog() { + return new Promise(async (resolve) => { + const options = { + url: `https://${prefix}-isv.isvjcloud.com/common/accessLog`, + headers: { + Accept: "application/json", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + Connection: "keep-alive", + Host: `${prefix}-isv.isvjcloud.com`, + Origin: `https://${prefix}-isv.isvjcloud.com`, + "Content-Type": "application/x-www-form-urlencoded", + Referer: + activityUrl + + "/microDz/invite/activity/wx/view/index?activityId=" + + activityId, + Cookie: + cookie + + activityCookie + + ";IsvToken=" + + $.Token + + ";AUTH_C_USER=" + + $.AUTH_C_USER, + "User-Agent": $.UA, + }, + body: `venderId=1&code=99&pin=${encodeURIComponent( + encodeURIComponent($.Pin) + )}&activityId=${activityId}&pageUrl=https%3A%2F%2F${prefix}-isv.isvjcloud.com%2FmicroDz%2Finvite%2Factivity%2Fwx%2Fview%2Findex%3FactivityId%3D${activityId}&subType=app`, + }; + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log("" + JSON.stringify(err)); + console.log($.name + "\x20API请求失败,请检查网路重试"); + } else { + // if (resp.status == 200) { + // refreshToken(resp); + // } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }); + }); + } + + function refreshToken(resp) { + // let cookies = resp.headers["set-cookie"]; + let cookies = resp && resp.headers && (resp.headers['set-cookie'] || resp.headers['Set-Cookie'] || '') || ''; + if (cookies) { + activityCookie = cookies + .map((v) => { + return v.split(";")[0]; + }) + .join(";"); + } + } + }); } 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) } -// +// ebe865a541a242d5bdc0c1f912add174 +// 152b6c5ae5b84a88a39a1dec34be2c11 这个还有打水 +// 1dd895c75bda49aeb47481ae404c58da (async () => { - await openCardActivity( - "", - "https://cjhydz-isv.isvjcloud.com", - "", - 160, - [] - ); - console.log("开卡已完成!"); + await openCardActivity( + "", + "https://cjhydz-isv.isvjcloud.com", + "", + 160, + [] + ); + console.log("开卡已完成!"); })(); // module.exports = { joinTeam } \ No newline at end of file diff --git a/jd_wish.js b/jd_wish.js index 2679a15..52b2f07 100644 --- a/jd_wish.js +++ b/jd_wish.js @@ -1,28 +1,13 @@ /* 众筹许愿池 活动入口:京东-京东众筹-众筹许愿池 -脚本兼容: QuantumultX, Surge, Loon, JSBox, Node.js -===============Quantumultx=============== -[task_local] -#众筹许愿池 -40 0,2 * * * https://raw.githubusercontent.com/shufflewzc/faker2/main/jd_wish.js, tag=众筹许愿池, img-url=https://raw.githubusercontent.com/Orz-3/mini/master/Color/jd.png, enabled=true - -================Loon============== -[Script] -cron "40 0,2 * * *" script-path=https://raw.githubusercontent.com/shufflewzc/faker2/main/jd_wish.js,tag=众筹许愿池 - -===============Surge================= -众筹许愿池 = type=cron,cronexp="40 0,2 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/shufflewzc/faker2/main/jd_wish.js - -============小火箭========= -众筹许愿池 = type=cron,script-path=https://raw.githubusercontent.com/shufflewzc/faker2/main/jd_wish.js, cronexpr="40 0,2 * * *", timeout=3600, enable=true +cron "12 0,15 * * *" script-path=jd_wish.js,tag=众筹许愿池 */ + const $ = new Env('众筹许愿池'); const notify = $.isNode() ? require('./sendNotify') : ''; -//Node.js用户请在jdCookie.js处填写京东ck; const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; let message = '', allMessage = ''; -//IOS等用户直接用NobyDa的jd cookie let cookiesArr = [], cookie = ''; const JD_API_HOST = 'https://api.m.jd.com/client.action'; let appIdArr = ['1EFNVyqeH','1FFVQyqw','1EFRWxKuG', '1E1xZy6s']; @@ -50,16 +35,9 @@ if ($.isNode()) { $.isLogin = true; $.nickName = ''; message = ''; - await TotalBean(); - console.log(`\n*******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); - if (!$.isLogin) { - $.msg($.name, `【提示】cookie已失效`, `京东账号${$.index} ${$.nickName || $.UserName}\n请重新登录获取\nhttps://bean.m.jd.com/bean/signIndex.action`, {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); - if ($.isNode()) { - await notify.sendNotify(`${$.name}cookie已失效 - ${$.UserName}`, `京东账号${$.index} ${$.UserName}\n请重新登录获取cookie`); - } - continue - } + console.log(`\n*******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + for (let j = 0; j < appIdArr.length; j++) { appId = appIdArr[j] appName = appNameArr[j] @@ -68,11 +46,7 @@ if ($.isNode()) { } } } - if (allMessage) { - if ($.isNode()) await notify.sendNotify($.name, allMessage); - $.msg($.name, '', allMessage) - } - let res = await getAuthorShareCode('https://gitee.com/KingRan521/JD-Scripts/raw/master/shareCodes/wish.json') + let res = []; $.shareCode = [...$.shareCode, ...(res || [])] for (let i = 0; i < cookiesArr.length; i++) { if (cookiesArr[i]) { @@ -139,8 +113,7 @@ async function jd_wish() { async function healthyDay_getHomeData(type = true) { return new Promise(async resolve => { - // console.log(taskUrl('healthyDay_getHomeData', { "appId": appId, "taskToken": "", "channelId": 1 })); - $.post(taskUrl('healthyDay_getHomeData', { "appId": appId, "taskToken": "", "channelId": 1 }), async (err, resp, data) => { + $.post(taskUrl('healthyDay_getHomeData', {"appId":appId,"taskToken":"","channelId":1}), async (err, resp, data) => { try { if (err) { console.log(`${JSON.stringify(err)}`) @@ -148,53 +121,37 @@ async function healthyDay_getHomeData(type = true) { } else { if (safeGet(data)) { data = JSON.parse(data); - // console.log(data); if (type) { for (let key of Object.keys(data.data.result.hotTaskVos).reverse()) { let vo = data.data.result.hotTaskVos[key] if (vo.status !== 2) { - if (vo.taskType === 13 || vo.taskType === 12) { + if (vo.taskType === 12) { console.log(`点击热区`) - await harmony_collectScore({ "appId": appId, "taskToken": vo.simpleRecordInfoVo.taskToken, "taskId": vo.taskId, "actionType": "0" }, vo.taskType) - } else { + await harmony_collectScore({"appId":appId,"taskToken":vo.simpleRecordInfoVo.taskToken,"taskId":vo.taskId,"actionType":"0"}, vo.taskType) + } + }else { console.log(`【${vo.taskName}】已完成\n`) } - } - } + } for (let key of Object.keys(data.data.result.taskVos).reverse()) { let vo = data.data.result.taskVos[key] - if (vo.status !== 2) { + if (vo.status !== 2 && vo.status !== 0) { if (vo.taskType === 13 || vo.taskType === 12) { console.log(`签到`) - await harmony_collectScore({ "appId": appId, "taskToken": vo.simpleRecordInfoVo.taskToken, "taskId": vo.taskId, "actionType": "0" }, vo.taskType) + await harmony_collectScore({"appId":appId,"taskToken":vo.simpleRecordInfoVo.taskToken,"taskId":vo.taskId,"actionType":"0"}, vo.taskType) } else if (vo.taskType === 1) { for (let key of Object.keys(vo.followShopVo)) { let followShopVo = vo.followShopVo[key] if (followShopVo.status !== 2) { console.log(`【${followShopVo.shopName}】${vo.subTitleName}`) - await harmony_collectScore({ "appId": appId, "taskToken": followShopVo.taskToken, "taskId": vo.taskId, "actionType": "0" }) - } - } - } else if (vo.taskType === 5) { - for (let key of Object.keys(vo.browseShopVo)) { - let browseShopVo = vo.browseShopVo[key] - if (browseShopVo.status !== 2) { - console.log(`【${browseShopVo.skuName}】${vo.subTitleName}`) - await harmony_collectScore({ "appId": appId, "taskToken": browseShopVo.taskToken, "taskId": vo.taskId, "actionType": "0" }) - } - } - } else if (vo.taskType === 15) { - for (let key of Object.keys(vo.productInfoVos)) { - let productInfoVos = vo.productInfoVos[key] - if (productInfoVos.status !== 2) { - console.log(`【${productInfoVos.skuName}】${vo.subTitleName}`) - await harmony_collectScore({ "appId": appId, "taskToken": productInfoVos.taskToken, "taskId": vo.taskId, "actionType": "0" }) + await harmony_collectScore({"appId":appId,"taskToken":followShopVo.taskToken,"taskId":vo.taskId,"actionType":"0"}) } } } else if (vo.taskType === 3) { - for (let key of Object.keys(vo.shoppingActivityVos)) { + for (let key of Object.keys(vo.shoppingActivityVos)) { let shoppingActivityVos = vo.shoppingActivityVos[key] if (shoppingActivityVos.status !== 2) { + // console.log(`【${shoppingActivityVos.skuName}】${vo.subTitleName}`) console.log(`【${vo.subTitleName}】`) await harmony_collectScore({ "appId": appId, "taskToken": shoppingActivityVos.taskToken, "taskId": vo.taskId, "actionType": "0" }) } @@ -204,24 +161,21 @@ async function healthyDay_getHomeData(type = true) { let productInfoVos = vo.productInfoVos[key] if (productInfoVos.status !== 2) { console.log(`【${productInfoVos.skuName}】${vo.subTitleName}`) - await harmony_collectScore({ "appId": appId, "taskToken": productInfoVos.taskToken, "taskId": vo.taskId, "actionType": "1" }) + await harmony_collectScore({"appId":appId,"taskToken":productInfoVos.taskToken,"taskId":vo.taskId,"actionType":"1"}) await $.wait(vo.waitDuration * 1000) - await harmony_collectScore({ "appId": appId, "taskToken": productInfoVos.taskToken, "taskId": vo.taskId, "actionType": "0" }) + await harmony_collectScore({"appId":appId,"taskToken":productInfoVos.taskToken,"taskId":vo.taskId,"actionType":"0"}) } } - } else if (vo.taskType === 27 && vo.taskId === 18) { - console.log(`【${vo.subTitleName}】`) - await harmony_collectScore({ "appId": appId, "taskToken": vo.productInfoVos[0].taskToken, "taskId": vo.taskId, "actionType": "0" }) } else if (vo.taskType === 9 || vo.taskType === 26) { for (let key of Object.keys(vo.shoppingActivityVos)) { let shoppingActivityVos = vo.shoppingActivityVos[key] if (shoppingActivityVos.status !== 2) { console.log(`【${shoppingActivityVos.title}】${vo.subTitleName}`) if (vo.taskType === 9) { - await harmony_collectScore({ "appId": appId, "taskToken": shoppingActivityVos.taskToken, "taskId": vo.taskId, "actionType": "1" }) + await harmony_collectScore({"appId":appId,"taskToken":shoppingActivityVos.taskToken,"taskId":vo.taskId,"actionType":"1"}) await $.wait(vo.waitDuration * 1000) } - await harmony_collectScore({ "appId": appId, "taskToken": shoppingActivityVos.taskToken, "taskId": vo.taskId, "actionType": "0" }) + await harmony_collectScore({"appId":appId,"taskToken":shoppingActivityVos.taskToken,"taskId":vo.taskId,"actionType":"0"}) } } } else if (vo.taskType === 14) { @@ -262,7 +216,7 @@ function harmony_collectScore(body = {}, taskType = '') { if (data && data.data && data.data.bizCode === 0) { if (taskType === 13) { console.log(`签到成功:获得${data.data.result.score}金币\n`) - } else if (body.taskId == 5) { + } else if (body.taskId == 6) { console.log(`助力成功:您的好友获得${data.data.result.score}金币\n`) } else { console.log(`完成任务:获得${data.data.result.score}金币\n`) @@ -270,7 +224,7 @@ function harmony_collectScore(body = {}, taskType = '') { } else { if (taskType === 13) { console.log(`签到失败:${data.data.bizMsg}\n`) - } else if (body.taskId == 5) { + } else if (body.taskId == 6) { console.log(`助力失败:${data.data.bizMsg || data.msg}\n`) if (data.code === -30001 || (data.data && data.data.bizCode === 108)) $.canHelp = false if (data.data.bizCode === 103) $.delcode = true @@ -288,7 +242,6 @@ function harmony_collectScore(body = {}, taskType = '') { }) }) } - function interact_template_getLotteryResult() { return new Promise(resolve => { $.post(taskUrl('interact_template_getLotteryResult', {"appId":appId}), (err, resp, data) => { @@ -299,17 +252,14 @@ function interact_template_getLotteryResult() { } else { if (safeGet(data)) { data = JSON.parse(data); - let userAwardsCacheDto = data && data.data && data.data.result && data.data.result.userAwardsCacheDto; + let userAwardsCacheDto = data && data.data && data.data.result && data.data.result.userAwardsCacheDto if (userAwardsCacheDto) { if (userAwardsCacheDto.type === 2) { - console.log(`抽中:${userAwardsCacheDto.jBeanAwardVo.quantity}${userAwardsCacheDto.jBeanAwardVo.ext || `京豆`}`); + console.log(`抽中:${userAwardsCacheDto.jBeanAwardVo.quantity}${userAwardsCacheDto.jBeanAwardVo.ext || `京豆`}`) } else if (userAwardsCacheDto.type === 0) { console.log(`很遗憾未中奖~`) - } else if (userAwardsCacheDto.type === 1) { - console.log(`抽中:${userAwardsCacheDto.couponVo.prizeName},金额${userAwardsCacheDto.couponVo.usageThreshold}-${userAwardsCacheDto.couponVo.quota},使用时间${userAwardsCacheDto.couponVo.useTimeRange}`); } else { - console.log(`抽中:${JSON.stringify(data)}`); - message += `抽中:${JSON.stringify(data)}\n`; + console.log(JSON.stringify(data)) } } else { $.canLottery = false @@ -377,50 +327,6 @@ function getAuthorShareCode(url) { }) } -function TotalBean() { - return new Promise(async resolve => { - const options = { - "url": `https://wq.jd.com/user/info/QueryJDUserInfo?sceneval=2`, - "headers": { - "Accept": "application/json,text/plain, */*", - "Content-Type": "application/x-www-form-urlencoded", - "Accept-Encoding": "gzip, deflate, br", - "Accept-Language": "zh-cn", - "Connection": "keep-alive", - "Cookie": cookie, - "Referer": "https://wqs.jd.com/my/jingdou/my.shtml?sceneval=2", - "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1") - } - } - $.post(options, (err, resp, data) => { - try { - if (err) { - console.log(`${JSON.stringify(err)}`) - console.log(`${$.name} API请求失败,请检查网路重试`) - } else { - if (data) { - data = JSON.parse(data); - if (data['retcode'] === 13) { - $.isLogin = false; //cookie过期 - return - } - if (data['retcode'] === 0) { - $.nickName = (data['base'] && data['base'].nickname) || $.UserName; - } else { - $.nickName = $.UserName - } - } else { - console.log(`京东服务器返回空数据`) - } - } - } catch (e) { - $.logErr(e, resp) - } finally { - resolve(); - } - }) - }) -} function safeGet(data) { try { if (typeof JSON.parse(data) == "object") { @@ -443,5 +349,6 @@ function jsonParse(str) { } } } + // 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)} +function Env(t,e){"undefined"!=typeof process&&JSON.stringify(process.env).indexOf("GITHUB")>-1&&process.exit(0);class s{constructor(t){this.env=t}send(t,e="GET"){t="string"==typeof t?{url:t}:t;let s=this.get;return"POST"===e&&(s=this.post),new Promise((e,i)=>{s.call(this,t,(t,s,r)=>{t?i(t):e(s)})})}get(t){return this.send.call(this.env,t)}post(t){return this.send.call(this.env,t,"POST")}}return new class{constructor(t,e){this.name=t,this.http=new s(this),this.data=null,this.dataFile="box.dat",this.logs=[],this.isMute=!1,this.isNeedRewrite=!1,this.logSeparator="\n",this.startTime=(new Date).getTime(),Object.assign(this,e),this.log("",`🔔${this.name}, 开始!`)}isNode(){return"undefined"!=typeof module&&!!module.exports}isQuanX(){return"undefined"!=typeof $task}isSurge(){return"undefined"!=typeof $httpClient&&"undefined"==typeof $loon}isLoon(){return"undefined"!=typeof $loon}toObj(t,e=null){try{return JSON.parse(t)}catch{return e}}toStr(t,e=null){try{return JSON.stringify(t)}catch{return e}}getjson(t,e){let s=e;const i=this.getdata(t);if(i)try{s=JSON.parse(this.getdata(t))}catch{}return s}setjson(t,e){try{return this.setdata(JSON.stringify(t),e)}catch{return!1}}getScript(t){return new Promise(e=>{this.get({url:t},(t,s,i)=>e(i))})}runScript(t,e){return new Promise(s=>{let i=this.getdata("@chavy_boxjs_userCfgs.httpapi");i=i?i.replace(/\n/g,"").trim():i;let r=this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout");r=r?1*r:20,r=e&&e.timeout?e.timeout:r;const[o,h]=i.split("@"),n={url:`http://${h}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:r},headers:{"X-Key":o,Accept:"*/*"}};this.post(n,(t,e,i)=>s(i))}).catch(t=>this.logErr(t))}loaddata(){if(!this.isNode())return{};{this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),i=!s&&this.fs.existsSync(e);if(!s&&!i)return{};{const i=s?t:e;try{return JSON.parse(this.fs.readFileSync(i))}catch(t){return{}}}}}writedata(){if(this.isNode()){this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),i=!s&&this.fs.existsSync(e),r=JSON.stringify(this.data);s?this.fs.writeFileSync(t,r):i?this.fs.writeFileSync(e,r):this.fs.writeFileSync(t,r)}}lodash_get(t,e,s){const i=e.replace(/\[(\d+)\]/g,".$1").split(".");let r=t;for(const t of i)if(r=Object(r)[t],void 0===r)return s;return r}lodash_set(t,e,s){return Object(t)!==t?t:(Array.isArray(e)||(e=e.toString().match(/[^.[\]]+/g)||[]),e.slice(0,-1).reduce((t,s,i)=>Object(t[s])===t[s]?t[s]:t[s]=Math.abs(e[i+1])>>0==+e[i+1]?[]:{},t)[e[e.length-1]]=s,t)}getdata(t){let e=this.getval(t);if(/^@/.test(t)){const[,s,i]=/^@(.*?)\.(.*?)$/.exec(t),r=s?this.getval(s):"";if(r)try{const t=JSON.parse(r);e=t?this.lodash_get(t,i,""):e}catch(t){e=""}}return e}setdata(t,e){let s=!1;if(/^@/.test(e)){const[,i,r]=/^@(.*?)\.(.*?)$/.exec(e),o=this.getval(i),h=i?"null"===o?null:o||"{}":"{}";try{const e=JSON.parse(h);this.lodash_set(e,r,t),s=this.setval(JSON.stringify(e),i)}catch(e){const o={};this.lodash_set(o,r,t),s=this.setval(JSON.stringify(o),i)}}else s=this.setval(t,e);return s}getval(t){return this.isSurge()||this.isLoon()?$persistentStore.read(t):this.isQuanX()?$prefs.valueForKey(t):this.isNode()?(this.data=this.loaddata(),this.data[t]):this.data&&this.data[t]||null}setval(t,e){return this.isSurge()||this.isLoon()?$persistentStore.write(t,e):this.isQuanX()?$prefs.setValueForKey(t,e):this.isNode()?(this.data=this.loaddata(),this.data[e]=t,this.writedata(),!0):this.data&&this.data[e]||null}initGotEnv(t){this.got=this.got?this.got:require("got"),this.cktough=this.cktough?this.cktough:require("tough-cookie"),this.ckjar=this.ckjar?this.ckjar:new this.cktough.CookieJar,t&&(t.headers=t.headers?t.headers:{},void 0===t.headers.Cookie&&void 0===t.cookieJar&&(t.cookieJar=this.ckjar))}get(t,e=(()=>{})){t.headers&&(delete t.headers["Content-Type"],delete t.headers["Content-Length"]),this.isSurge()||this.isLoon()?(this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.get(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)})):this.isQuanX()?(this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t))):this.isNode()&&(this.initGotEnv(t),this.got(t).on("redirect",(t,e)=>{try{if(t.headers["set-cookie"]){const s=t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString();s&&this.ckjar.setCookieSync(s,null),e.cookieJar=this.ckjar}}catch(t){this.logErr(t)}}).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)}))}post(t,e=(()=>{})){if(t.body&&t.headers&&!t.headers["Content-Type"]&&(t.headers["Content-Type"]="application/x-www-form-urlencoded"),t.headers&&delete t.headers["Content-Length"],this.isSurge()||this.isLoon())this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.post(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)});else if(this.isQuanX())t.method="POST",this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t));else if(this.isNode()){this.initGotEnv(t);const{url:s,...i}=t;this.got.post(s,i).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)})}}time(t,e=null){const s=e?new Date(e):new Date;let i={"M+":s.getMonth()+1,"d+":s.getDate(),"H+":s.getHours(),"m+":s.getMinutes(),"s+":s.getSeconds(),"q+":Math.floor((s.getMonth()+3)/3),S:s.getMilliseconds()};/(y+)/.test(t)&&(t=t.replace(RegExp.$1,(s.getFullYear()+"").substr(4-RegExp.$1.length)));for(let e in i)new RegExp("("+e+")").test(t)&&(t=t.replace(RegExp.$1,1==RegExp.$1.length?i[e]:("00"+i[e]).substr((""+i[e]).length)));return t}msg(e=t,s="",i="",r){const o=t=>{if(!t)return t;if("string"==typeof t)return this.isLoon()?t:this.isQuanX()?{"open-url":t}:this.isSurge()?{url:t}:void 0;if("object"==typeof t){if(this.isLoon()){let e=t.openUrl||t.url||t["open-url"],s=t.mediaUrl||t["media-url"];return{openUrl:e,mediaUrl:s}}if(this.isQuanX()){let e=t["open-url"]||t.url||t.openUrl,s=t["media-url"]||t.mediaUrl;return{"open-url":e,"media-url":s}}if(this.isSurge()){let e=t.url||t.openUrl||t["open-url"];return{url:e}}}};if(this.isMute||(this.isSurge()||this.isLoon()?$notification.post(e,s,i,o(r)):this.isQuanX()&&$notify(e,s,i,o(r))),!this.isMuteLog){let t=["","==============📣系统通知📣=============="];t.push(e),s&&t.push(s),i&&t.push(i),console.log(t.join("\n")),this.logs=this.logs.concat(t)}}log(...t){t.length>0&&(this.logs=[...this.logs,...t]),console.log(t.join(this.logSeparator))}logErr(t,e){const s=!this.isSurge()&&!this.isQuanX()&&!this.isLoon();s?this.log("",`❗️${this.name}, 错误!`,t.stack):this.log("",`❗️${this.name}, 错误!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`🔔${this.name}, 结束! 🕛 ${s} 秒`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)} \ No newline at end of file