From 483572ae9d33453f66777554cfd6ed34cc95079e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A0=87=E5=93=A5=E4=B8=B6?= Date: Mon, 21 Feb 2022 15:43:19 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=81=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- activity/jd_opencard1.js | 585 +++++++++++++++++++++++ activity/jd_opencard10.js | 600 ++++++++++++++++++++++++ activity/jd_opencard105.js | 754 ++++++++++++++++++++++++++++++ activity/jd_opencard11.js | 542 +++++++++++++++++++++ activity/jd_opencard12.js | 600 ++++++++++++++++++++++++ activity/jd_opencard2.js | 588 +++++++++++++++++++++++ activity/jd_opencard3.js | 588 +++++++++++++++++++++++ activity/jd_opencard4.js | 587 +++++++++++++++++++++++ activity/jd_opencard5.js | 532 +++++++++++++++++++++ activity/jd_opencard55.js | 620 ++++++++++++++++++++++++ activity/jd_opencard6.js | 585 +++++++++++++++++++++++ activity/jd_opencard64.js | 619 ++++++++++++++++++++++++ activity/jd_opencard7.js | 526 +++++++++++++++++++++ activity/jd_opencard8.js | 17 + activity/jd_opencard9.js | 588 +++++++++++++++++++++++ activity/jd_opencard93.js | 809 ++++++++++++++++++++++++++++++++ activity/jd_opencard96.js | 749 +++++++++++++++++++++++++++++ activity/jd_opencard97.js | 880 ++++++++++++++++++++++++++++++++++ activity/jd_opencard98.js | 881 +++++++++++++++++++++++++++++++++++ activity/jd_opencard99.js | 551 ++++++++++++++++++++++ activity/jd_opencardL34.js | 739 +++++++++++++++++++++++++++++ activity/jd_opencardL35.js | 797 +++++++++++++++++++++++++++++++ activity/jd_opencardL36.js | 829 ++++++++++++++++++++++++++++++++ activity/jd_opencardL37.js | 822 ++++++++++++++++++++++++++++++++ activity/jd_opencardL38.js | 874 ++++++++++++++++++++++++++++++++++ activity/jd_opencardL39.js | 874 ++++++++++++++++++++++++++++++++++ activity/jd_opencardL40.js | 822 ++++++++++++++++++++++++++++++++ activity/jd_opencardL41.js | 880 ++++++++++++++++++++++++++++++++++ activity/jd_opencardL42.js | 796 +++++++++++++++++++++++++++++++ activity/jd_opencardL43.js | 705 ++++++++++++++++++++++++++++ activity/jd_opencardL44.js | 550 ++++++++++++++++++++++ activity/jd_opencardL45.js | 821 ++++++++++++++++++++++++++++++++ activity/jd_opencardL46.js | 799 +++++++++++++++++++++++++++++++ activity/jd_opencardL47.js | 543 +++++++++++++++++++++ activity/jd_opencardL48.js | 543 +++++++++++++++++++++ activity/jd_opencardL49.js | 801 +++++++++++++++++++++++++++++++ activity/jd_opencardL50.js | 554 ++++++++++++++++++++++ activity/jd_opencardL51.js | 821 ++++++++++++++++++++++++++++++++ activity/jd_opencardL53.js | 547 ++++++++++++++++++++++ activity/jd_opencardL54.js | 547 ++++++++++++++++++++++ activity/jd_opencardL55.js | 547 ++++++++++++++++++++++ activity/jd_opencardL56.js | 825 ++++++++++++++++++++++++++++++++ activity/jd_opencardL57.js | 825 ++++++++++++++++++++++++++++++++ activity/jd_opencardL58.js | 611 ++++++++++++++++++++++++ activity/jd_opencardL59.js | 817 ++++++++++++++++++++++++++++++++ activity/jd_opencardL60.js | 742 +++++++++++++++++++++++++++++ activity/jd_opencardL61.js | 547 ++++++++++++++++++++++ activity/jd_opencardL62.js | 544 +++++++++++++++++++++ activity/jd_opencardL63.js | 524 +++++++++++++++++++++ activity/jd_opencardL64.js | 544 +++++++++++++++++++++ activity/jd_opencardL65.js | 544 +++++++++++++++++++++ activity/jd_opencardL66.js | 704 ++++++++++++++++++++++++++++ activity/jd_opencardL67.js | 505 ++++++++++++++++++++ activity/jd_opencardL68.js | 821 ++++++++++++++++++++++++++++++++ activity/jd_opencardL71.js | 544 +++++++++++++++++++++ activity/jd_opencardL72.js | 544 +++++++++++++++++++++ activity/jd_opencardL77.js | 524 +++++++++++++++++++++ activity/jd_opencardLH29.js | 750 +++++++++++++++++++++++++++++ activity/jd_opencardLH30.js | 797 +++++++++++++++++++++++++++++++ activity/jd_opencardLH31.js | 797 +++++++++++++++++++++++++++++++ activity/jd_opencardLH32.js | 797 +++++++++++++++++++++++++++++++ activity/jd_opencardLH34.js | 546 ++++++++++++++++++++++ activity/jd_opencardLH35.js | 546 ++++++++++++++++++++++ activity/jd_opencardLH36.js | 547 ++++++++++++++++++++++ activity/jd_opencardLH37.js | 537 +++++++++++++++++++++ activity/jd_opencardjoyjd.js | 510 ++++++++++++++++++++ 66 files changed, 43404 insertions(+) create mode 100644 activity/jd_opencard1.js create mode 100644 activity/jd_opencard10.js create mode 100644 activity/jd_opencard105.js create mode 100644 activity/jd_opencard11.js create mode 100644 activity/jd_opencard12.js create mode 100644 activity/jd_opencard2.js create mode 100644 activity/jd_opencard3.js create mode 100644 activity/jd_opencard4.js create mode 100644 activity/jd_opencard5.js create mode 100644 activity/jd_opencard55.js create mode 100644 activity/jd_opencard6.js create mode 100644 activity/jd_opencard64.js create mode 100644 activity/jd_opencard7.js create mode 100644 activity/jd_opencard8.js create mode 100644 activity/jd_opencard9.js create mode 100644 activity/jd_opencard93.js create mode 100644 activity/jd_opencard96.js create mode 100644 activity/jd_opencard97.js create mode 100644 activity/jd_opencard98.js create mode 100644 activity/jd_opencard99.js create mode 100644 activity/jd_opencardL34.js create mode 100644 activity/jd_opencardL35.js create mode 100644 activity/jd_opencardL36.js create mode 100644 activity/jd_opencardL37.js create mode 100644 activity/jd_opencardL38.js create mode 100644 activity/jd_opencardL39.js create mode 100644 activity/jd_opencardL40.js create mode 100644 activity/jd_opencardL41.js create mode 100644 activity/jd_opencardL42.js create mode 100644 activity/jd_opencardL43.js create mode 100644 activity/jd_opencardL44.js create mode 100644 activity/jd_opencardL45.js create mode 100644 activity/jd_opencardL46.js create mode 100644 activity/jd_opencardL47.js create mode 100644 activity/jd_opencardL48.js create mode 100644 activity/jd_opencardL49.js create mode 100644 activity/jd_opencardL50.js create mode 100644 activity/jd_opencardL51.js create mode 100644 activity/jd_opencardL53.js create mode 100644 activity/jd_opencardL54.js create mode 100644 activity/jd_opencardL55.js create mode 100644 activity/jd_opencardL56.js create mode 100644 activity/jd_opencardL57.js create mode 100644 activity/jd_opencardL58.js create mode 100644 activity/jd_opencardL59.js create mode 100644 activity/jd_opencardL60.js create mode 100644 activity/jd_opencardL61.js create mode 100644 activity/jd_opencardL62.js create mode 100644 activity/jd_opencardL63.js create mode 100644 activity/jd_opencardL64.js create mode 100644 activity/jd_opencardL65.js create mode 100644 activity/jd_opencardL66.js create mode 100644 activity/jd_opencardL67.js create mode 100644 activity/jd_opencardL68.js create mode 100644 activity/jd_opencardL71.js create mode 100644 activity/jd_opencardL72.js create mode 100644 activity/jd_opencardL77.js create mode 100644 activity/jd_opencardLH29.js create mode 100644 activity/jd_opencardLH30.js create mode 100644 activity/jd_opencardLH31.js create mode 100644 activity/jd_opencardLH32.js create mode 100644 activity/jd_opencardLH34.js create mode 100644 activity/jd_opencardLH35.js create mode 100644 activity/jd_opencardLH36.js create mode 100644 activity/jd_opencardLH37.js create mode 100644 activity/jd_opencardjoyjd.js diff --git a/activity/jd_opencard1.js b/activity/jd_opencard1.js new file mode 100644 index 0000000..fd0325a --- /dev/null +++ b/activity/jd_opencard1.js @@ -0,0 +1,585 @@ +/* +惠聚京东 好物连连 + +https://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity/5063373?activityId=llk20211015&shareUuid=7e4ac784edea4925be06b5ed22802322 +*/ +const $ = new Env("惠聚京东 好物连连"); +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const notify = $.isNode() ? require('./sendNotify') : ''; +let cookiesArr = [], cookie = '', message = ''; +let ownCode = null; +let authorCodeList = [] +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => { }; +} else { + let cookiesData = $.getdata('CookiesJD') || "[]"; + cookiesData = JSON.parse(cookiesData); + cookiesArr = cookiesData.map(item => item.cookie); + cookiesArr.reverse(); + cookiesArr.push(...[$.getdata('CookieJD2'), $.getdata('CookieJD')]); + cookiesArr.reverse(); + cookiesArr = cookiesArr.filter(item => !!item); +} +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', { "open-url": "https://bean.m.jd.com/bean/signIndex.action" }); + return; + } + authorCodeList = await getAuthorCodeList('https://gitee.com/fatelight/dongge/raw/master/dongge/lzdz1_huanju.json') + if(authorCodeList === '404: Not Found'){ + authorCodeList = [ + '7e4ac784edea4925be06b5ed22802322', + ] + } + // console.log(authorCodeList) + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i] + originCookie = cookiesArr[i] + newCookie = '' + $.UserName = decodeURIComponent(cookie.match(/pt_pin=(.+?);/) && cookie.match(/pt_pin=(.+?);/)[1]) + $.index = i + 1; + $.isLogin = true; + $.nickName = ''; + await checkCookie(); + console.log(`\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + if (!$.isLogin) { + $.msg($.name, `【提示】cookie已失效`, `京东账号${$.index} ${$.nickName || $.UserName}\n请重新登录获取\nhttps://bean.m.jd.com/bean/signIndex.action`, { "open-url": "https://bean.m.jd.com/bean/signIndex.action" }); + // if ($.isNode()) { + // await notify.sendNotify(`${$.name}cookie已失效 - ${$.UserName}`, `京东账号${$.index} ${$.UserName}\n请重新登录获取cookie`); + // } + continue + } + $.bean = 0; + $.ADID = getUUID('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', 1); + $.UUID = getUUID('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'); + // $.authorCode = authorCodeList[random(0, authorCodeList.length)] + $.authorCode = ownCode ? ownCode : authorCodeList[random(0, authorCodeList.length)] + $.authorNum = `${random(1000000, 9999999)}` + $.randomCode = random(1000000, 9999999) + $.activityId = 'llk20211015' + $.activityShopId = '1000003005' + $.activityUrl = `https://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity/${$.authorNum}?activityId=${$.activityId}&shareUuid=${encodeURIComponent($.authorCode)}&adsource=null&shareuserid4minipg=null&shopid=undefined&lng=00.000000&lat=00.000000&sid=&un_area=` + await member(); + await $.wait(5000) + if ($.bean > 0) { + message += `\n【京东账号${$.index}】${$.nickName || $.UserName} \n └ 获得 ${$.bean} 京豆。` + } + } + } + if (message !== '') { + if ($.isNode()) { + await notify.sendNotify($.name, message, '', `\n`); + } else { + $.msg($.name, '有点儿收获', message); + } + } +})() + .catch((e) => { + $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') + }) + .finally(() => { + $.done(); + }) + + +async function member() { + $.token = null; + $.secretPin = null; + $.openCardActivityId = null + await getFirstLZCK() + await getToken(); + await task('dz/common/getSimpleActInfoVo', `activityId=${$.activityId}`, 1) + if ($.token) { + await getMyPing(); + if ($.secretPin) { + console.log("去助力 -> "+$.authorCode) + await task('common/accessLogWithAD', `venderId=${$.activityShopId}&code=99&pin=${encodeURIComponent($.secretPin)}&activityId=${$.activityId}&pageUrl=${$.activityUrl}&subType=app&adSource=null`, 1); + await task('wxActionCommon/getUserInfo', `pin=${encodeURIComponent($.secretPin)}`, 1) + if ($.index === 1) { + await task('linkgame/activity/content', `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}&pinImg=&nick=${encodeURIComponent($.pin)}&cjyxPin=&cjhyPin=&shareUuid=${encodeURIComponent($.authorCode)}`, 0, 1) + } else { + await task('linkgame/activity/content', `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}&pinImg=&nick=${encodeURIComponent($.pin)}&cjyxPin=&cjhyPin=&shareUuid=${encodeURIComponent($.authorCode)}`) + } + $.log("关注店铺") + await task('linkgame/follow/shop', `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}`) + await task('taskact/common/drawContent', `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}`) + await task('linkgame/checkOpenCard', `pin=${encodeURIComponent($.secretPin)}&activityId=${$.activityId}`) + $.log("加入店铺会员") + if ($.openCardList) { + for (let i = 0; i < ($.openCardList.length); i++) { + $.log(">>> 模拟上报访问记录") + await task('crm/pageVisit/insertCrmPageVisit', `venderId=1000003005&pageId=llk20211015&elementId=入会跳转&pin=${encodeURIComponent($.secretPin)}`, 1) + await $.wait(2000) + } + + for (const vo of $.openCardList) { + $.log(`>>> 去加入${vo.name} ${vo.venderId}`) + if (vo.status === 0) { + await getShopOpenCardInfo({ "venderId": `${vo.venderId}`, "channel": "401" }, vo.venderId) + await bindWithVender({ "venderId": `${vo.venderId}`, "bindByVerifyCodeFlag": 1, "registerExtend": {}, "writeChildFlag": 0, "activityId": $.openCardActivityId, "channel": 401 }, vo.venderId) + await $.wait(2000) + } else { + $.log(`>>> 已经是会员`) + } + + } + } else { + $.log("没有获取到对应的任务。\n") + } + await task('linkgame/checkOpenCard', `pin=${encodeURIComponent($.secretPin)}&activityId=${$.activityId}`) + if ($.openCardStatus) { + console.log('去助力 -> ' + $.authorCode) + if ($.openCardStatus.allOpenCard) { + await task('linkgame/assist/status', `pin=${encodeURIComponent($.secretPin)}&activityId=${$.activityId}&shareUuid=${$.authorCode}`) + await task('linkgame/assist', `pin=${encodeURIComponent($.secretPin)}&activityId=${$.activityId}&shareUuid=${$.authorCode}`) + + } + } + await task('linkgame/help/list', `pin=${encodeURIComponent($.secretPin)}&activityId=${$.activityId}`) + + await task('linkgame/task/info', `pin=${encodeURIComponent($.secretPin)}&activityId=${$.activityId}`) + if ($.TaskList) { + tasklist = $.TaskList + if (!$.TaskList.sign) { + await task('linkgame/sign', `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}`); + } else { + console.log("已完成签到") + } + if (!$.TaskList.visitSku) { + for (const vo of tasklist.visitSkuList) { + if (vo.status === 0) { + await task('linkgame/browseGoods', `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}&value=${vo.goodsCode}`) + } + } + } else { + console.log("已完成浏览任务"); + } + if (!$.TaskList.addCart) { + await task('linkgame/addCart', `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}`); + } else { + console.log("加购任务已完成") + } + } + } + } +} + +function task(function_id, body, isCommon = 0, own = 0) { + return new Promise(resolve => { + $.post(taskUrl(function_id, body, isCommon), async (err, resp, data) => { + try { + if (err) { + $.log(err) + } else { + + if (data) { + data = JSON.parse(data); + if (data.result) { + switch (function_id) { + case 'dz/common/getSimpleActInfoVo': + $.jdActivityId = data.data.jdActivityId; + $.venderId = data.data.venderId; + $.activityType = data.data.activityType; + break; + case 'wxActionCommon/getUserInfo': + break; + case 'linkgame/activity/content': + if (!data.data.hasEnd) { + $.log(`开启【${data.data.activity['name']}】活动`) + $.log("-------------------") + if ($.index === 1) { + ownCode = data.data.actor['actorUuid'] + console.log(ownCode) + } + $.actorUuid = data.data.actor['actorUuid']; + } else { + $.log("活动已经结束"); + } + break; + case 'linkgame/checkOpenCard': + $.openCardList = data.data.openCardList; + $.openCardStatus = data.data; + // console.log(data) + break; + case 'linkgame/follow/shop': + console.log(data) + break; + case 'linkgame/sign': + console.log(data) + break; + case 'linkgame/addCart': + console.log(data) + break; + case 'linkgame/browseGoods': + console.log(data) + break; + case 'interaction/write/writePersonInfo': + console.log(data) + break; + case 'linkgame/task/info': + console.log(data) + break; + case 'linkgame/assist/status': + $.log(JSON.stringify(data)) + break; + case 'linkgame/assist': + $.log(JSON.stringify(data)) + break; + case 'linkgame/help/list': + $.log(JSON.stringify(data)) + break; + default: + // $.log(JSON.stringify(data)) + break; + } + } else { + // $.log(JSON.stringify(data)) + } + } else { + // $.log("京东没有返回数据") + } + } + } catch (error) { + $.log(error) + } finally { + resolve(); + } + }) + }) +} +function getShopOpenCardInfo(body, venderId) { + let opt = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body=${encodeURIComponent(JSON.stringify(body))}&client=H5&clientVersion=9.2.0&uuid=88888`, + headers: { + Host: 'api.m.jd.com', + Accept: '*/*', + Connection: 'keep-alive', + Cookie: cookie, + 'User-Agent': `jdapp;iPhone;9.5.4;13.6;${$.UUID};network/wifi;ADID/${$.ADID};model/iPhone10,3;addressid/0;appBuild/167668;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1`, + 'Accept-Language': 'zh-cn', + Referer: `https://shopmember.m.jd.com/shopcard/?venderId=${venderId}}&channel=801&returnUrl=${encodeURIComponent($.activityUrl)}`, + 'Accept-Encoding': 'gzip, deflate, br' + } + } + return new Promise(resolve => { + $.get(opt, (err, resp, data) => { + try { + if (err) { + console.log(err) + } else { + res = JSON.parse(data) + if (res.success) { + if (res.result.interestsRuleList) { + $.openCardActivityId = res.result.interestsRuleList[0].interestsInfo.activityId; + } + } + } + } catch (error) { + console.log(error) + } finally { + resolve(); + } + }) + + }) +} +function bindWithVender(body, venderId) { + let opt = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body=${encodeURIComponent(JSON.stringify(body))}&client=H5&clientVersion=9.2.0&uuid=88888`, + headers: { + Host: 'api.m.jd.com', + Accept: '*/*', + Connection: 'keep-alive', + Cookie: cookie, + 'User-Agent': `jdapp;iPhone;9.5.4;13.6;${$.UUID};network/wifi;ADID/${$.ADID};model/iPhone10,3;addressid/0;appBuild/167668;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1`, + 'Accept-Language': 'zh-cn', + Referer: `https://shopmember.m.jd.com/shopcard/?venderId=${venderId}}&channel=401&returnUrl=${encodeURIComponent($.activityUrl)}`, + 'Accept-Encoding': 'gzip, deflate, br' + } + } + return new Promise(resolve => { + $.get(opt, (err, resp, data) => { + try { + if (err) { + console.log(err) + } else { + res = JSON.parse(data) + if (res.success) { + if (res.result.giftInfo && res.result.giftInfo.giftList) { + for (const vo of res.result.giftInfo.giftList) { + if (vo.prizeType === 4) { + $.log(`==>获得【${vo.quantity}】京豆`) + $.bean += vo.quantity + } + } + } + } + } + } catch (error) { + console.log(error) + } finally { + resolve(); + } + }) + + }) +} + +function getAuthorCodeList(url) { + return new Promise(resolve => { + const options = { + url: `${url}?${new Date()}`, "timeout": 10000, headers: { + "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1 Edg/87.0.4280.88" + } + }; + $.get(options, async (err, resp, data) => { + try { + if (err) { + $.log(err) + } else { + if (data) data = JSON.parse(data) + } + } catch (e) { + $.logErr(e, resp) + data = null; + } finally { + resolve(data); + } + }) + }) +} + +function taskUrl(function_id, body, isCommon) { + return { + url: isCommon ? `https://lzdz1-isv.isvjcloud.com/${function_id}` : `https://lzdz1-isv.isvjcloud.com/dingzhi/${function_id}`, + headers: { + Host: 'lzdz1-isv.isvjcloud.com', + Accept: 'application/json', + 'X-Requested-With': 'XMLHttpRequest', + 'Accept-Language': 'zh-cn', + 'Accept-Encoding': 'gzip, deflate, br', + 'Content-Type': 'application/x-www-form-urlencoded', + Origin: 'https://lzdz1-isv.isvjcloud.com', + 'User-Agent': `jdapp;iPhone;9.5.4;13.6;${$.UUID};network/wifi;ADID/${$.ADID};model/iPhone10,3;addressid/0;appBuild/167668;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1`, + Connection: 'keep-alive', + Referer: $.activityUrl, + Cookie: cookie + }, + body: body + + } +} + +function getMyPing() { + let opt = { + url: `https://lzdz1-isv.isvjcloud.com/customer/getMyPing`, + headers: { + Host: 'lzdz1-isv.isvjcloud.com', + Accept: 'application/json', + 'X-Requested-With': 'XMLHttpRequest', + 'Accept-Language': 'zh-cn', + 'Accept-Encoding': 'gzip, deflate, br', + 'Content-Type': 'application/x-www-form-urlencoded', + Origin: 'https://lzdz1-isv.isvjcloud.com', + 'User-Agent': `jdapp;iPhone;9.5.4;13.6;${$.UUID};network/wifi;ADID/${$.ADID};model/iPhone10,3;addressid/0;appBuild/167668;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1`, + Connection: 'keep-alive', + Referer: $.activityUrl, + Cookie: cookie, + }, + body: `userId=${$.activityShopId}&token=${$.token}&fromType=APP&riskType=1` + } + return new Promise(resolve => { + $.post(opt, (err, resp, data) => { + try { + if (err) { + $.log(err) + } else { + if (resp['headers']['set-cookie']) { + cookie = `${originCookie}` + if ($.isNode()) { + for (let sk of resp['headers']['set-cookie']) { + cookie = `${cookie}${sk.split(";")[0]};` + } + } else { + for (let ck of resp['headers']['Set-Cookie'].split(',')) { + cookie = `${cookie}${ck.split(";")[0]};` + } + } + } + if (resp['headers']['Set-Cookie']) { + cookie = `${originCookie}` + if ($.isNode()) { + for (let sk of resp['headers']['set-cookie']) { + cookie = `${cookie}${sk.split(";")[0]};` + } + } else { + for (let ck of resp['headers']['Set-Cookie'].split(',')) { + cookie = `${cookie}${ck.split(";")[0]};` + } + } + } + if (data) { + data = JSON.parse(data) + if (data.result) { + $.log(`你好:${data.data.nickname}`) + $.pin = data.data.nickname; + $.secretPin = data.data.secretPin; + cookie = `${cookie};AUTH_C_USER=${data.data.secretPin}` + } else { + $.log(data.errorMessage) + } + } else { + $.log("京东返回了空数据") + } + } + } catch (error) { + $.log(error) + } finally { + resolve(); + } + + }) + }) +} +function getFirstLZCK() { + return new Promise(resolve => { + $.get({ url: $.activityUrl }, (err, resp, data) => { + try { + if (err) { + console.log(err) + } else { + if (resp['headers']['set-cookie']) { + cookie = `${originCookie}` + if ($.isNode()) { + for (let sk of resp['headers']['set-cookie']) { + cookie = `${cookie}${sk.split(";")[0]};` + } + } else { + for (let ck of resp['headers']['Set-Cookie'].split(',')) { + cookie = `${cookie}${ck.split(";")[0]};` + } + } + } + if (resp['headers']['Set-Cookie']) { + cookie = `${originCookie}` + if ($.isNode()) { + for (let sk of resp['headers']['set-cookie']) { + cookie = `${cookie}${sk.split(";")[0]};` + } + } else { + for (let ck of resp['headers']['Set-Cookie'].split(',')) { + cookie = `${cookie}${ck.split(";")[0]};` + } + } + } + } + } catch (error) { + console.log(error) + } finally { + resolve(); + } + }) + }) +} +function getToken() { + let opt = { + url: `https://api.m.jd.com/client.action?functionId=isvObfuscator`, + headers: { + Host: 'api.m.jd.com', + 'Content-Type': 'application/x-www-form-urlencoded', + Accept: '*/*', + Connection: 'keep-alive', + Cookie: cookie, + 'User-Agent': 'JD4iPhone/167650 (iPhone; iOS 13.7; Scale/3.00)', + 'Accept-Language': 'zh-Hans-CN;q=1', + 'Accept-Encoding': 'gzip, deflate, br', + }, + body: `body=%7B%22url%22%3A%20%22https%3A//lzkj-isv.isvjcloud.com%22%2C%20%22id%22%3A%20%22%22%7D&uuid=hjudwgohxzVu96krv&client=apple&clientVersion=9.4.0&st=1620476162000&sv=111&sign=f9d1b7e3b943b6a136d54fe4f892af05` + } + return new Promise(resolve => { + $.post(opt, (err, resp, data) => { + try { + if (err) { + $.log(err) + } else { + if (data) { + data = JSON.parse(data); + if (data.code === "0") { + $.token = data.token + } + } else { + $.log("京东返回了空数据") + } + } + } catch (error) { + $.log(error) + } finally { + resolve(); + } + }) + }) +} +function random(min, max) { + + return Math.floor(Math.random() * (max - min)) + min; + +} +function getUUID(format = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', UpperCase = 0) { + return format.replace(/[xy]/g, function (c) { + var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8); + if (UpperCase) { + uuid = v.toString(36).toUpperCase(); + } else { + uuid = v.toString(36) + } + return uuid; + }); +} +function checkCookie() { + const options = { + url: "https://me-api.jd.com/user_new/info/GetJDUserInfoUnion", + headers: { + "Host": "me-api.jd.com", + "Accept": "*/*", + "Connection": "keep-alive", + "Cookie": cookie, + "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.2 Mobile/15E148 Safari/604.1", + "Accept-Language": "zh-cn", + "Referer": "https://home.m.jd.com/myJd/newhome.action?sceneval=2&ufc=&", + "Accept-Encoding": "gzip, deflate, br", + } + }; + return new Promise(resolve => { + $.get(options, (err, resp, data) => { + try { + if (err) { + $.logErr(err) + } else { + if (data) { + data = JSON.parse(data); + if (data.retcode === "1001") { + $.isLogin = false; //cookie过期 + return; + } + if (data.retcode === "0" && data.data.hasOwnProperty("userInfo")) { + $.nickName = data.data.userInfo.baseInfo.nickname; + } + } else { + $.log('京东返回了空数据'); + } + } + } catch (e) { + $.logErr(e) + } finally { + resolve(); + } + }) + }) +} +// prettier-ignore +!function (n) { "use strict"; function t(n, t) { var r = (65535 & n) + (65535 & t); return (n >> 16) + (t >> 16) + (r >> 16) << 16 | 65535 & r } function r(n, t) { return n << t | n >>> 32 - t } function e(n, e, o, u, c, f) { return t(r(t(t(e, n), t(u, f)), c), o) } function o(n, t, r, o, u, c, f) { return e(t & r | ~t & o, n, t, u, c, f) } function u(n, t, r, o, u, c, f) { return e(t & o | r & ~o, n, t, u, c, f) } function c(n, t, r, o, u, c, f) { return e(t ^ r ^ o, n, t, u, c, f) } function f(n, t, r, o, u, c, f) { return e(r ^ (t | ~o), n, t, u, c, f) } function i(n, r) { n[r >> 5] |= 128 << r % 32, n[14 + (r + 64 >>> 9 << 4)] = r; var e, i, a, d, h, l = 1732584193, g = -271733879, v = -1732584194, m = 271733878; for (e = 0; e < n.length; e += 16)i = l, a = g, d = v, h = m, g = f(g = f(g = f(g = f(g = c(g = c(g = c(g = c(g = u(g = u(g = u(g = u(g = o(g = o(g = o(g = o(g, v = o(v, m = o(m, l = o(l, g, v, m, n[e], 7, -680876936), g, v, n[e + 1], 12, -389564586), l, g, n[e + 2], 17, 606105819), m, l, n[e + 3], 22, -1044525330), v = o(v, m = o(m, l = o(l, g, v, m, n[e + 4], 7, -176418897), g, v, n[e + 5], 12, 1200080426), l, g, n[e + 6], 17, -1473231341), m, l, n[e + 7], 22, -45705983), v = o(v, m = o(m, l = o(l, g, v, m, n[e + 8], 7, 1770035416), g, v, n[e + 9], 12, -1958414417), l, g, n[e + 10], 17, -42063), m, l, n[e + 11], 22, -1990404162), v = o(v, m = o(m, l = o(l, g, v, m, n[e + 12], 7, 1804603682), g, v, n[e + 13], 12, -40341101), l, g, n[e + 14], 17, -1502002290), m, l, n[e + 15], 22, 1236535329), v = u(v, m = u(m, l = u(l, g, v, m, n[e + 1], 5, -165796510), g, v, n[e + 6], 9, -1069501632), l, g, n[e + 11], 14, 643717713), m, l, n[e], 20, -373897302), v = u(v, m = u(m, l = u(l, g, v, m, n[e + 5], 5, -701558691), g, v, n[e + 10], 9, 38016083), l, g, n[e + 15], 14, -660478335), m, l, n[e + 4], 20, -405537848), v = u(v, m = u(m, l = u(l, g, v, m, n[e + 9], 5, 568446438), g, v, n[e + 14], 9, -1019803690), l, g, n[e + 3], 14, -187363961), m, l, n[e + 8], 20, 1163531501), v = u(v, m = u(m, l = u(l, g, v, m, n[e + 13], 5, -1444681467), g, v, n[e + 2], 9, -51403784), l, g, n[e + 7], 14, 1735328473), m, l, n[e + 12], 20, -1926607734), v = c(v, m = c(m, l = c(l, g, v, m, n[e + 5], 4, -378558), g, v, n[e + 8], 11, -2022574463), l, g, n[e + 11], 16, 1839030562), m, l, n[e + 14], 23, -35309556), v = c(v, m = c(m, l = c(l, g, v, m, n[e + 1], 4, -1530992060), g, v, n[e + 4], 11, 1272893353), l, g, n[e + 7], 16, -155497632), m, l, n[e + 10], 23, -1094730640), v = c(v, m = c(m, l = c(l, g, v, m, n[e + 13], 4, 681279174), g, v, n[e], 11, -358537222), l, g, n[e + 3], 16, -722521979), m, l, n[e + 6], 23, 76029189), v = c(v, m = c(m, l = c(l, g, v, m, n[e + 9], 4, -640364487), g, v, n[e + 12], 11, -421815835), l, g, n[e + 15], 16, 530742520), m, l, n[e + 2], 23, -995338651), v = f(v, m = f(m, l = f(l, g, v, m, n[e], 6, -198630844), g, v, n[e + 7], 10, 1126891415), l, g, n[e + 14], 15, -1416354905), m, l, n[e + 5], 21, -57434055), v = f(v, m = f(m, l = f(l, g, v, m, n[e + 12], 6, 1700485571), g, v, n[e + 3], 10, -1894986606), l, g, n[e + 10], 15, -1051523), m, l, n[e + 1], 21, -2054922799), v = f(v, m = f(m, l = f(l, g, v, m, n[e + 8], 6, 1873313359), g, v, n[e + 15], 10, -30611744), l, g, n[e + 6], 15, -1560198380), m, l, n[e + 13], 21, 1309151649), v = f(v, m = f(m, l = f(l, g, v, m, n[e + 4], 6, -145523070), g, v, n[e + 11], 10, -1120210379), l, g, n[e + 2], 15, 718787259), m, l, n[e + 9], 21, -343485551), l = t(l, i), g = t(g, a), v = t(v, d), m = t(m, h); return [l, g, v, m] } function a(n) { var t, r = "", e = 32 * n.length; for (t = 0; t < e; t += 8)r += String.fromCharCode(n[t >> 5] >>> t % 32 & 255); return r } function d(n) { var t, r = []; for (r[(n.length >> 2) - 1] = void 0, t = 0; t < r.length; t += 1)r[t] = 0; var e = 8 * n.length; for (t = 0; t < e; t += 8)r[t >> 5] |= (255 & n.charCodeAt(t / 8)) << t % 32; return r } function h(n) { return a(i(d(n), 8 * n.length)) } function l(n, t) { var r, e, o = d(n), u = [], c = []; for (u[15] = c[15] = void 0, o.length > 16 && (o = i(o, 8 * n.length)), r = 0; r < 16; r += 1)u[r] = 909522486 ^ o[r], c[r] = 1549556828 ^ o[r]; return e = i(u.concat(d(t)), 512 + 8 * t.length), a(i(c.concat(e), 640)) } function g(n) { var t, r, e = ""; for (r = 0; r < n.length; r += 1)t = n.charCodeAt(r), e += "0123456789abcdef".charAt(t >>> 4 & 15) + "0123456789abcdef".charAt(15 & t); return e } function v(n) { return unescape(encodeURIComponent(n)) } function m(n) { return h(v(n)) } function p(n) { return g(m(n)) } function s(n, t) { return l(v(n), v(t)) } function C(n, t) { return g(s(n, t)) } function A(n, t, r) { return t ? r ? s(t, n) : C(t, n) : r ? m(n) : p(n) } $.md5 = A }(this); +function Env(t, e) { "undefined" != typeof process && JSON.stringify(process.env).indexOf("GITHUB") > -1 && process.exit(0); class s { constructor(t) { this.env = t } send(t, e = "GET") { t = "string" == typeof t ? { url: t } : t; let s = this.get; return "POST" === e && (s = this.post), new Promise((e, i) => { s.call(this, t, (t, s, r) => { t ? i(t) : e(s) }) }) } get(t) { return this.send.call(this.env, t) } post(t) { return this.send.call(this.env, t, "POST") } } return new class { constructor(t, e) { this.name = t, this.http = new s(this), this.data = null, this.dataFile = "box.dat", this.logs = [], this.isMute = !1, this.isNeedRewrite = !1, this.logSeparator = "\n", this.startTime = (new Date).getTime(), Object.assign(this, e), this.log("", `🔔${this.name}, 开始!`) } isNode() { return "undefined" != typeof module && !!module.exports } isQuanX() { return "undefined" != typeof $task } isSurge() { return "undefined" != typeof $httpClient && "undefined" == typeof $loon } isLoon() { return "undefined" != typeof $loon } toObj(t, e = null) { try { return JSON.parse(t) } catch { return e } } toStr(t, e = null) { try { return JSON.stringify(t) } catch { return e } } getjson(t, e) { let s = e; const i = this.getdata(t); if (i) try { s = JSON.parse(this.getdata(t)) } catch { } return s } setjson(t, e) { try { return this.setdata(JSON.stringify(t), e) } catch { return !1 } } getScript(t) { return new Promise(e => { this.get({ url: t }, (t, s, i) => e(i)) }) } runScript(t, e) { return new Promise(s => { let i = this.getdata("@chavy_boxjs_userCfgs.httpapi"); i = i ? i.replace(/\n/g, "").trim() : i; let r = this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout"); r = r ? 1 * r : 20, r = e && e.timeout ? e.timeout : r; const [o, h] = i.split("@"), n = { url: `http://${h}/v1/scripting/evaluate`, body: { script_text: t, mock_type: "cron", timeout: r }, headers: { "X-Key": o, Accept: "*/*" } }; this.post(n, (t, e, i) => s(i)) }).catch(t => this.logErr(t)) } loaddata() { if (!this.isNode()) return {}; { this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path"); const t = this.path.resolve(this.dataFile), e = this.path.resolve(process.cwd(), this.dataFile), s = this.fs.existsSync(t), i = !s && this.fs.existsSync(e); if (!s && !i) return {}; { const i = s ? t : e; try { return JSON.parse(this.fs.readFileSync(i)) } catch (t) { return {} } } } } writedata() { if (this.isNode()) { this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path"); const t = this.path.resolve(this.dataFile), e = this.path.resolve(process.cwd(), this.dataFile), s = this.fs.existsSync(t), i = !s && this.fs.existsSync(e), r = JSON.stringify(this.data); s ? this.fs.writeFileSync(t, r) : i ? this.fs.writeFileSync(e, r) : this.fs.writeFileSync(t, r) } } lodash_get(t, e, s) { const i = e.replace(/\[(\d+)\]/g, ".$1").split("."); let r = t; for (const t of i) if (r = Object(r)[t], void 0 === r) return s; return r } lodash_set(t, e, s) { return Object(t) !== t ? t : (Array.isArray(e) || (e = e.toString().match(/[^.[\]]+/g) || []), e.slice(0, -1).reduce((t, s, i) => Object(t[s]) === t[s] ? t[s] : t[s] = Math.abs(e[i + 1]) >> 0 == +e[i + 1] ? [] : {}, t)[e[e.length - 1]] = s, t) } getdata(t) { let e = this.getval(t); if (/^@/.test(t)) { const [, s, i] = /^@(.*?)\.(.*?)$/.exec(t), r = s ? this.getval(s) : ""; if (r) try { const t = JSON.parse(r); e = t ? this.lodash_get(t, i, "") : e } catch (t) { e = "" } } return e } setdata(t, e) { let s = !1; if (/^@/.test(e)) { const [, i, r] = /^@(.*?)\.(.*?)$/.exec(e), o = this.getval(i), h = i ? "null" === o ? null : o || "{}" : "{}"; try { const e = JSON.parse(h); this.lodash_set(e, r, t), s = this.setval(JSON.stringify(e), i) } catch (e) { const o = {}; this.lodash_set(o, r, t), s = this.setval(JSON.stringify(o), i) } } else s = this.setval(t, e); return s } getval(t) { return this.isSurge() || this.isLoon() ? $persistentStore.read(t) : this.isQuanX() ? $prefs.valueForKey(t) : this.isNode() ? (this.data = this.loaddata(), this.data[t]) : this.data && this.data[t] || null } setval(t, e) { return this.isSurge() || this.isLoon() ? $persistentStore.write(t, e) : this.isQuanX() ? $prefs.setValueForKey(t, e) : this.isNode() ? (this.data = this.loaddata(), this.data[e] = t, this.writedata(), !0) : this.data && this.data[e] || null } initGotEnv(t) { this.got = this.got ? this.got : require("got"), this.cktough = this.cktough ? this.cktough : require("tough-cookie"), this.ckjar = this.ckjar ? this.ckjar : new this.cktough.CookieJar, t && (t.headers = t.headers ? t.headers : {}, void 0 === t.headers.Cookie && void 0 === t.cookieJar && (t.cookieJar = this.ckjar)) } get(t, e = (() => { })) { t.headers && (delete t.headers["Content-Type"], delete t.headers["Content-Length"]), this.isSurge() || this.isLoon() ? (this.isSurge() && this.isNeedRewrite && (t.headers = t.headers || {}, Object.assign(t.headers, { "X-Surge-Skip-Scripting": !1 })), $httpClient.get(t, (t, s, i) => { !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i) })) : this.isQuanX() ? (this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, { hints: !1 })), $task.fetch(t).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => e(t))) : this.isNode() && (this.initGotEnv(t), this.got(t).on("redirect", (t, e) => { try { if (t.headers["set-cookie"]) { const s = t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString(); s && this.ckjar.setCookieSync(s, null), e.cookieJar = this.ckjar } } catch (t) { this.logErr(t) } }).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => { const { message: s, response: i } = t; e(s, i, i && i.body) })) } post(t, e = (() => { })) { if (t.body && t.headers && !t.headers["Content-Type"] && (t.headers["Content-Type"] = "application/x-www-form-urlencoded"), t.headers && delete t.headers["Content-Length"], this.isSurge() || this.isLoon()) this.isSurge() && this.isNeedRewrite && (t.headers = t.headers || {}, Object.assign(t.headers, { "X-Surge-Skip-Scripting": !1 })), $httpClient.post(t, (t, s, i) => { !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i) }); else if (this.isQuanX()) t.method = "POST", this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, { hints: !1 })), $task.fetch(t).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => e(t)); else if (this.isNode()) { this.initGotEnv(t); const { url: s, ...i } = t; this.got.post(s, i).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => { const { message: s, response: i } = t; e(s, i, i && i.body) }) } } time(t, e = null) { const s = e ? new Date(e) : new Date; let i = { "M+": s.getMonth() + 1, "d+": s.getDate(), "H+": s.getHours(), "m+": s.getMinutes(), "s+": s.getSeconds(), "q+": Math.floor((s.getMonth() + 3) / 3), S: s.getMilliseconds() }; /(y+)/.test(t) && (t = t.replace(RegExp.$1, (s.getFullYear() + "").substr(4 - RegExp.$1.length))); for (let e in i) new RegExp("(" + e + ")").test(t) && (t = t.replace(RegExp.$1, 1 == RegExp.$1.length ? i[e] : ("00" + i[e]).substr(("" + i[e]).length))); return t } msg(e = t, s = "", i = "", r) { const o = t => { if (!t) return t; if ("string" == typeof t) return this.isLoon() ? t : this.isQuanX() ? { "open-url": t } : this.isSurge() ? { url: t } : void 0; if ("object" == typeof t) { if (this.isLoon()) { let e = t.openUrl || t.url || t["open-url"], s = t.mediaUrl || t["media-url"]; return { openUrl: e, mediaUrl: s } } if (this.isQuanX()) { let e = t["open-url"] || t.url || t.openUrl, s = t["media-url"] || t.mediaUrl; return { "open-url": e, "media-url": s } } if (this.isSurge()) { let e = t.url || t.openUrl || t["open-url"]; return { url: e } } } }; if (this.isMute || (this.isSurge() || this.isLoon() ? $notification.post(e, s, i, o(r)) : this.isQuanX() && $notify(e, s, i, o(r))), !this.isMuteLog) { let t = ["", "==============📣系统通知📣=============="]; t.push(e), s && t.push(s), i && t.push(i), console.log(t.join("\n")), this.logs = this.logs.concat(t) } } log(...t) { t.length > 0 && (this.logs = [...this.logs, ...t]), console.log(t.join(this.logSeparator)) } logErr(t, e) { const s = !this.isSurge() && !this.isQuanX() && !this.isLoon(); s ? this.log("", `❗️${this.name}, 错误!`, t.stack) : this.log("", `❗️${this.name}, 错误!`, t) } wait(t) { return new Promise(e => setTimeout(e, t)) } done(t = {}) { const e = (new Date).getTime(), s = (e - this.startTime) / 1e3; this.log("", `🔔${this.name}, 结束! 🕛 ${s} 秒`), this.log(), (this.isSurge() || this.isQuanX() || this.isLoon()) && $done(t) } }(t, e) } diff --git a/activity/jd_opencard10.js b/activity/jd_opencard10.js new file mode 100644 index 0000000..7c8100c --- /dev/null +++ b/activity/jd_opencard10.js @@ -0,0 +1,600 @@ +/* +惠聚11.11 好物乐享不停 +11.1 - 11.12 +https://lzdz1-isv.isvjcloud.com/dingzhi/dz/openCard/activity?activityId=dzlbklzmsk20211101A&shareUuid=83c98a7fb761406f9b9872c0049b2b7c + +cron 37 3,19 * * * https://raw.githubusercontent.com/KingRan/JDJB/main/jd_opencard10.js + +默认执行脚本。如果需要不执行 +环境变量 NO_RUSH=false +*/ +const $ = new Env("11.1 - 11.12 惠聚11.11 好物乐享不停"); +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const notify = $.isNode() ? require('./sendNotify') : ''; +let cookiesArr = [], cookie = '', message = ''; +let ownCode = null; +let isRush = true; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => { }; +} else { + let cookiesData = $.getdata('CookiesJD') || "[]"; + cookiesData = JSON.parse(cookiesData); + cookiesArr = cookiesData.map(item => item.cookie); + cookiesArr.reverse(); + cookiesArr.push(...[$.getdata('CookieJD2'), $.getdata('CookieJD')]); + cookiesArr.reverse(); + cookiesArr = cookiesArr.filter(item => !!item); +} +if (process.env.NO_RUSH && process.env.NO_RUSH != "") { + isRush = process.env.NO_RUSH; +} +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', { "open-url": "https://bean.m.jd.com/bean/signIndex.action" }); + return; + } + + authorCodeList = await getAuthorCodeList('https://gitee.com/KingRan521/JD-Scripts/raw/master/shareCodes/opencard10.json') + if(authorCodeList === '404: Not Found'){ + authorCodeList = [ + '83c98a7fb761406f9b9872c0049b2b7c', + ] + } + + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i] + originCookie = cookiesArr[i] + newCookie = '' + $.UserName = decodeURIComponent(cookie.match(/pt_pin=(.+?);/) && cookie.match(/pt_pin=(.+?);/)[1]) + $.index = i + 1; + $.isLogin = true; + $.nickName = ''; + await checkCookie(); + console.log(`\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + if (!$.isLogin) { + $.msg($.name, `【提示】cookie已失效`, `京东账号${$.index} ${$.nickName || $.UserName}\n请重新登录获取\nhttps://bean.m.jd.com/bean/signIndex.action`, { "open-url": "https://bean.m.jd.com/bean/signIndex.action" }); + if ($.isNode()) { + await notify.sendNotify(`${$.name}cookie已失效 - ${$.UserName}`, `京东账号${$.index} ${$.UserName}\n请重新登录获取cookie`); + } + continue + } + $.bean = 0; + $.ADID = getUUID('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', 1); + $.UUID = getUUID('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'); + // $.authorCode = authorCodeList[random(0, authorCodeList.length)] + $.authorCode = ownCode ? ownCode : authorCodeList[random(0, authorCodeList.length)] + $.authorNum = `${random(1000000, 9999999)}` + $.randomCode = random(1000000, 9999999) + $.activityId = 'dzlbklzmsk20211101A' + $.activityShopId = '1000004489' + $.activityUrl = `https://lzdz1-isv.isvjd.com/dingzhi/dz/openCard/activity/${$.authorNum}?activityId=${$.activityId}&shareUuid=${encodeURIComponent($.authorCode)}&adsource=null&shareuserid4minipg=null&shopid=${$.activityShopId}&lng=00.000000&lat=00.000000&sid=&un_area=` + if (isRush === true) { + console.log("未检测到不执行环境变量,执行任务") + await rush(); + } else { + console.log("检测到不执行环境变量,退出任务,环境变量 NO_RUSH") + break + } + await $.wait(3000) + if ($.bean > 0) { + message += `\n【京东账号${$.index}】${$.nickName || $.UserName} \n └ 获得 ${$.bean} 京豆。` + } + } + } + if (message !== '') { + if ($.isNode()) { + await notify.sendNotify($.name, message, '', `\n`); + } else { + $.msg($.name, '有点儿收获', message); + } + } +})() + .catch((e) => { + $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') + }) + .finally(() => { + $.done(); + }) + + +async function rush() { + $.token = null; + $.secretPin = null; + $.openCardActivityId = null + await getFirstLZCK() + await getToken(); + if ($.token) { + await getMyPing(); + if ($.secretPin) { + console.log("去助力 -> "+$.authorCode) + await task('common/accessLogWithAD', `venderId=${$.activityShopId}&code=99&pin=${encodeURIComponent($.secretPin)}&activityId=${$.activityId}&pageUrl=${$.activityUrl}&subType=app&adSource=null`, 1); + await task('wxActionCommon/getUserInfo', `pin=${encodeURIComponent($.secretPin)}`, 1) + if ($.index === 1) { + await task('dz/openCard/activityContent', `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}&pinImg=&nick=${encodeURIComponent($.pin)}&cjyxPin=&cjhyPin=&shareUuid=${encodeURIComponent($.authorCode)}`, 0, 1) + } else { + await task('dz/openCard/activityContent', `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}&pinImg=&nick=${encodeURIComponent($.pin)}&cjyxPin=&cjhyPin=&shareUuid=${encodeURIComponent($.authorCode)}`) + } + await task('dz/openCard/checkOpenCard', `activityId=${$.activityId}&actorUuid=${$.actorUuid}&shareUuid=${$.authorCode}&pin=${encodeURIComponent($.secretPin)}`) + $.log("->关注店铺") + if ($.shopTask) { + if (!$.shopTask.allStatus) { + await task('dz/openCard/followShop', `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}&actorUuid=${encodeURIComponent($.actorUuid)}&taskType=23&taskValue=1000002520`) + } else { + $.log(" >>>已经关注过了\n") + await $.wait(2000) + return + } + } else { + $.log("没有获取到对应的任务。\n") + } + $.log("->->->> 加入店铺会员") + if ($.openCardStatus) { + for (let i = 0; i < ($.openCardStatus.cardList1.length + $.openCardStatus.cardList2.length); i++) { + $.log("模拟上报访问记录") + await task('crm/pageVisit/insertCrmPageVisit', `venderId=1000004065&pageId=dz20211013skcnurdk11jhdue84752hp&elementId=${encodeURIComponent(`去开卡${i}`)}&pin=${encodeURIComponent($.secretPin)}`, 1) + await $.wait(2000) + } + t1TaskList = [] + $.openCardStatus.cardList1.filter((x) => { if (x.status === 0) { t1TaskList.push(x) } }) + t2TaskList = [] + $.openCardStatus.cardList2.filter((x) => { if (x.status === 0) { t2TaskList.push(x) } }) + if (t1TaskList.length < 1) { + console.log(" >>>已经完成入会任务") + + } else { + for (const vo of t1TaskList) { + $.log(` >>>去加入${vo.name}`) + await getShopOpenCardInfo({ "venderId": `${vo.value}`, "channel": "401" }, vo.value) + await bindWithVender({ "venderId": `${vo.value}`, "bindByVerifyCodeFlag": 1, "registerExtend": {}, "writeChildFlag": 0, "activityId": $.openCardActivityId, "channel": 401 }, vo.value) + await $.wait(2000) + } + for (const vo of t2TaskList) { + $.log(` >>>${vo.name}`) + await getShopOpenCardInfo({ "venderId": `${vo.value}`, "channel": "401" }) + await bindWithVender({ "venderId": `${vo.value}`, "bindByVerifyCodeFlag": 1, "registerExtend": {}, "writeChildFlag": 0, "activityId": $.openCardActivityId, "channel": 401 }, vo.value) + await $.wait(2000) + } + } + + await task("taskact/openCardcommon/drawContent", `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}`) + await $.wait(2000) + await task('dz/openCard/checkOpenCard', `activityId=${$.activityId}&actorUuid=${$.actorUuid}&shareUuid=${$.authorCode}&pin=${encodeURIComponent($.secretPin)}`) + await $.wait(2000) + await task("dz/openCard/startDraw", `activityId=${$.activityId}&actorUuid=${$.actorUuid}&type=1&pin=${encodeURIComponent($.secretPin)}`) + await $.wait(2000) + await task("dz/openCard/startDraw", `activityId=${$.activityId}&actorUuid=${$.actorUuid}&type=2&pin=${encodeURIComponent($.secretPin)}`) + + } else { + $.log("没有获取到对应的任务。\n") + } + $.log("->->->> 加购物车") + await task("dz/openCard/saveTask", `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}&actorUuid=${$.actorUuid}&type=2&taskValue=100025232454`) + } + } +} + +function task(function_id, body, isCommon = 0, own = 0) { + return new Promise(resolve => { + $.post(taskUrl(function_id, body, isCommon), async (err, resp, data) => { + try { + if (err) { + $.log(err) + } else { + + if (data) { + data = JSON.parse(data); + if (data.result) { + switch (function_id) { + case 'wxActionCommon/getUserInfo': + break; + case 'dz/openCard/activityContent': + if (!data.data.hasEnd) { + $.log(`开启【${data.data.activityName}】活动`) + $.log("-------------------") + if ($.index === 1) { + ownCode = data.data.actorUuid + console.log(ownCode) + } + $.actorUuid = data.data.actorUuid; + $.skuTask = data.data.addSku; + $.shopTask = data.data.followShop; + } else { + $.log("活动已经结束"); + } + break; + case 'dz/openCard/checkOpenCard': + $.openCardStatus = data.data; + break; + case 'dz/openCard/saveTask': + console.log(data.data.addBeanNum) + break; + case 'dz/openCard/saveTask': + if (data.data) { + if (data.data.addBeanNum) { + $.bean += data.data.addBeanNum; + $.log(`==>获得【${data.data.addBeanNum}】京豆\n`) + } + } + break; + case 'dz/openCard/startDraw': + if (data.data.drawOk) { + switch (data.data.drawInfo.type) { + case 6: + $.bean += data.data.drawInfo.beanNum; + $.log(`==>获得【${data.data.drawInfo.beanNum}】京豆\n`) + break; + default: + if ($.isNode()) { + await notify.sendNotify("中奖了", `中奖信息:${JSON.stringify(data.data.drawInfo)}\n活动链接:${$.activityUrl}`) + } else { + $.msg("中奖了", `获得${data.data.drawInfo.name}`, `中奖信息:${JSON.stringify(data.data.drawInfo)}\n活动链接:${$.activityUrl}`) + } + break; + } + } + break; + case 'crm/pageVisit/insertCrmPageVisit': + $.log("==> 上报成功") + + case 'dz/openCard/followShop': + if (data.data) { + if (data.data.addBeanNum) { + $.bean += data.data.addBeanNum; + $.log(`==>获得【${data.data.addBeanNum}】京豆\n`) + } + } + break; + + break; + default: + $.log(JSON.stringify(data)) + break; + } + } else { + $.log(JSON.stringify(data)) + } + } else { + // $.log("京东没有返回数据") + } + } + } catch (error) { + $.log(error) + } finally { + resolve(); + } + }) + }) +} +function getShopOpenCardInfo(body, venderId) { + let opt = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body=${encodeURIComponent(JSON.stringify(body))}&client=H5&clientVersion=9.2.0&uuid=88888`, + headers: { + Host: 'api.m.jd.com', + Accept: '*/*', + Connection: 'keep-alive', + Cookie: cookie, + 'User-Agent': `jdapp;iPhone;9.5.4;13.6;${$.UUID};network/wifi;ADID/${$.ADID};model/iPhone10,3;addressid/0;appBuild/167668;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1`, + 'Accept-Language': 'zh-cn', + Referer: `https://shopmember.m.jd.com/shopcard/?venderId=${venderId}}&channel=801&returnUrl=${encodeURIComponent($.activityUrl)}`, + 'Accept-Encoding': 'gzip, deflate, br' + } + } + return new Promise(resolve => { + $.get(opt, (err, resp, data) => { + try { + if (err) { + console.log(err) + } else { + res = JSON.parse(data) + if (res.success) { + if (res.result.interestsRuleList) { + $.openCardActivityId = res.result.interestsRuleList[0].interestsInfo.activityId; + } + } + } + } catch (error) { + console.log(error) + } finally { + resolve(); + } + }) + + }) +} +function bindWithVender(body, venderId) { + let opt = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body=${encodeURIComponent(JSON.stringify(body))}&client=H5&clientVersion=9.2.0&uuid=88888`, + headers: { + Host: 'api.m.jd.com', + Accept: '*/*', + Connection: 'keep-alive', + Cookie: cookie, + 'User-Agent': `jdapp;iPhone;9.5.4;13.6;${$.UUID};network/wifi;ADID/${$.ADID};model/iPhone10,3;addressid/0;appBuild/167668;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1`, + 'Accept-Language': 'zh-cn', + Referer: `https://shopmember.m.jd.com/shopcard/?venderId=${venderId}}&channel=401&returnUrl=${encodeURIComponent($.activityUrl)}`, + 'Accept-Encoding': 'gzip, deflate, br' + } + } + return new Promise(resolve => { + $.get(opt, (err, resp, data) => { + try { + if (err) { + console.log(err) + } else { + res = JSON.parse(data) + if (res.success) { + if (res.result.giftInfo && res.result.giftInfo.giftList) { + for (const vo of res.result.giftInfo.giftList) { + if (vo.prizeType === 4) { + $.log(`==>获得【${vo.quantity}】京豆`) + $.bean += vo.quantity + } + } + } + } + } + } catch (error) { + console.log(error) + } finally { + resolve(); + } + }) + + }) +} +function taskUrl(function_id, body, isCommon) { + return { + url: isCommon ? `https://lzdz1-isv.isvjd.com/${function_id}` : `https://lzdz1-isv.isvjd.com/dingzhi/${function_id}`, + headers: { + Host: 'lzdz1-isv.isvjd.com', + Accept: 'application/json', + 'X-Requested-With': 'XMLHttpRequest', + 'Accept-Language': 'zh-cn', + 'Accept-Encoding': 'gzip, deflate, br', + 'Content-Type': 'application/x-www-form-urlencoded', + Origin: 'https://lzdz1-isv.isvjd.com', + 'User-Agent': `jdapp;iPhone;9.5.4;13.6;${$.UUID};network/wifi;ADID/${$.ADID};model/iPhone10,3;addressid/0;appBuild/167668;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1`, + Connection: 'keep-alive', + Referer: $.activityUrl, + Cookie: cookie + }, + body: body + + } +} +function getAuthorCodeList(url) { + return new Promise(resolve => { + const options = { + url: `${url}?${new Date()}`, "timeout": 10000, headers: { + "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1 Edg/87.0.4280.88" + } + }; + $.get(options, async (err, resp, data) => { + try { + if (err) { + $.log(err) + } else { + if (data) data = JSON.parse(data) + } + } catch (e) { + $.logErr(e, resp) + data = null; + } finally { + resolve(data); + } + }) + }) +} +function getMyPing() { + let opt = { + url: `https://lzdz1-isv.isvjd.com/customer/getMyPing`, + headers: { + Host: 'lzdz1-isv.isvjd.com', + Accept: 'application/json', + 'X-Requested-With': 'XMLHttpRequest', + 'Accept-Language': 'zh-cn', + 'Accept-Encoding': 'gzip, deflate, br', + 'Content-Type': 'application/x-www-form-urlencoded', + Origin: 'https://lzdz1-isv.isvjd.com', + 'User-Agent': `jdapp;iPhone;9.5.4;13.6;${$.UUID};network/wifi;ADID/${$.ADID};model/iPhone10,3;addressid/0;appBuild/167668;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1`, + Connection: 'keep-alive', + Referer: $.activityUrl, + Cookie: cookie, + }, + body: `userId=${$.activityShopId}&token=${$.token}&fromType=APP&riskType=1` + } + return new Promise(resolve => { + $.post(opt, (err, resp, data) => { + try { + if (err) { + $.log(err) + } else { + if (resp['headers']['set-cookie']) { + cookie = `${originCookie}` + if ($.isNode()) { + for (let sk of resp['headers']['set-cookie']) { + cookie = `${cookie}${sk.split(";")[0]};` + } + } else { + for (let ck of resp['headers']['Set-Cookie'].split(',')) { + cookie = `${cookie}${ck.split(";")[0]};` + } + } + } + if (resp['headers']['Set-Cookie']) { + cookie = `${originCookie}` + if ($.isNode()) { + for (let sk of resp['headers']['set-cookie']) { + cookie = `${cookie}${sk.split(";")[0]};` + } + } else { + for (let ck of resp['headers']['Set-Cookie'].split(',')) { + cookie = `${cookie}${ck.split(";")[0]};` + } + } + } + if (data) { + data = JSON.parse(data) + if (data.result) { + $.log(`你好:${data.data.nickname}`) + $.pin = data.data.nickname; + $.secretPin = data.data.secretPin; + cookie = `${cookie};AUTH_C_USER=${data.data.secretPin}` + } else { + $.log(data.errorMessage) + } + } else { + // $.log("京东返回了空数据") + } + } + } catch (error) { + $.log(error) + } finally { + resolve(); + } + + }) + }) +} +function getFirstLZCK() { + return new Promise(resolve => { + $.get({ url: $.activityUrl }, (err, resp, data) => { + try { + if (err) { + console.log(err) + } else { + if (resp['headers']['set-cookie']) { + cookie = `${originCookie}` + if ($.isNode()) { + for (let sk of resp['headers']['set-cookie']) { + cookie = `${cookie}${sk.split(";")[0]};` + } + } else { + for (let ck of resp['headers']['Set-Cookie'].split(',')) { + cookie = `${cookie}${ck.split(";")[0]};` + } + } + } + if (resp['headers']['Set-Cookie']) { + cookie = `${originCookie}` + if ($.isNode()) { + for (let sk of resp['headers']['set-cookie']) { + cookie = `${cookie}${sk.split(";")[0]};` + } + } else { + for (let ck of resp['headers']['Set-Cookie'].split(',')) { + cookie = `${cookie}${ck.split(";")[0]};` + } + } + } + } + } catch (error) { + console.log(error) + } finally { + resolve(); + } + }) + }) +} +function getToken() { + let opt = { + url: `https://api.m.jd.com/client.action?functionId=isvObfuscator`, + headers: { + Host: 'api.m.jd.com', + 'Content-Type': 'application/x-www-form-urlencoded', + Accept: '*/*', + Connection: 'keep-alive', + Cookie: cookie, + 'User-Agent': 'JD4iPhone/167650 (iPhone; iOS 13.7; Scale/3.00)', + 'Accept-Language': 'zh-Hans-CN;q=1', + 'Accept-Encoding': 'gzip, deflate, br', + }, + body: `body=%7B%22url%22%3A%20%22https%3A//lzkj-isv.isvjcloud.com%22%2C%20%22id%22%3A%20%22%22%7D&uuid=hjudwgohxzVu96krv&client=apple&clientVersion=9.4.0&st=1620476162000&sv=111&sign=f9d1b7e3b943b6a136d54fe4f892af05` + } + return new Promise(resolve => { + $.post(opt, (err, resp, data) => { + try { + if (err) { + $.log(err) + } else { + if (data) { + data = JSON.parse(data); + if (data.code === "0") { + $.token = data.token + } + } else { + $.log("京东返回了空数据") + } + } + } catch (error) { + $.log(error) + } finally { + resolve(); + } + }) + }) +} +function random(min, max) { + + return Math.floor(Math.random() * (max - min)) + min; + +} +function getUUID(format = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', UpperCase = 0) { + return format.replace(/[xy]/g, function (c) { + var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8); + if (UpperCase) { + uuid = v.toString(36).toUpperCase(); + } else { + uuid = v.toString(36) + } + return uuid; + }); +} +function checkCookie() { + const options = { + url: "https://me-api.jd.com/user_new/info/GetJDUserInfoUnion", + headers: { + "Host": "me-api.jd.com", + "Accept": "*/*", + "Connection": "keep-alive", + "Cookie": cookie, + "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.2 Mobile/15E148 Safari/604.1", + "Accept-Language": "zh-cn", + "Referer": "https://home.m.jd.com/myJd/newhome.action?sceneval=2&ufc=&", + "Accept-Encoding": "gzip, deflate, br", + } + }; + return new Promise(resolve => { + $.get(options, (err, resp, data) => { + try { + if (err) { + $.logErr(err) + } else { + if (data) { + data = JSON.parse(data); + if (data.retcode === "1001") { + $.isLogin = false; //cookie过期 + return; + } + if (data.retcode === "0" && data.data.hasOwnProperty("userInfo")) { + $.nickName = data.data.userInfo.baseInfo.nickname; + } + } else { + $.log('京东返回了空数据'); + } + } + } catch (e) { + $.logErr(e) + } finally { + resolve(); + } + }) + }) +} +// prettier-ignore +!function (n) { "use strict"; function t(n, t) { var r = (65535 & n) + (65535 & t); return (n >> 16) + (t >> 16) + (r >> 16) << 16 | 65535 & r } function r(n, t) { return n << t | n >>> 32 - t } function e(n, e, o, u, c, f) { return t(r(t(t(e, n), t(u, f)), c), o) } function o(n, t, r, o, u, c, f) { return e(t & r | ~t & o, n, t, u, c, f) } function u(n, t, r, o, u, c, f) { return e(t & o | r & ~o, n, t, u, c, f) } function c(n, t, r, o, u, c, f) { return e(t ^ r ^ o, n, t, u, c, f) } function f(n, t, r, o, u, c, f) { return e(r ^ (t | ~o), n, t, u, c, f) } function i(n, r) { n[r >> 5] |= 128 << r % 32, n[14 + (r + 64 >>> 9 << 4)] = r; var e, i, a, d, h, l = 1732584193, g = -271733879, v = -1732584194, m = 271733878; for (e = 0; e < n.length; e += 16)i = l, a = g, d = v, h = m, g = f(g = f(g = f(g = f(g = c(g = c(g = c(g = c(g = u(g = u(g = u(g = u(g = o(g = o(g = o(g = o(g, v = o(v, m = o(m, l = o(l, g, v, m, n[e], 7, -680876936), g, v, n[e + 1], 12, -389564586), l, g, n[e + 2], 17, 606105819), m, l, n[e + 3], 22, -1044525330), v = o(v, m = o(m, l = o(l, g, v, m, n[e + 4], 7, -176418897), g, v, n[e + 5], 12, 1200080426), l, g, n[e + 6], 17, -1473231341), m, l, n[e + 7], 22, -45705983), v = o(v, m = o(m, l = o(l, g, v, m, n[e + 8], 7, 1770035416), g, v, n[e + 9], 12, -1958414417), l, g, n[e + 10], 17, -42063), m, l, n[e + 11], 22, -1990404162), v = o(v, m = o(m, l = o(l, g, v, m, n[e + 12], 7, 1804603682), g, v, n[e + 13], 12, -40341101), l, g, n[e + 14], 17, -1502002290), m, l, n[e + 15], 22, 1236535329), v = u(v, m = u(m, l = u(l, g, v, m, n[e + 1], 5, -165796510), g, v, n[e + 6], 9, -1069501632), l, g, n[e + 11], 14, 643717713), m, l, n[e], 20, -373897302), v = u(v, m = u(m, l = u(l, g, v, m, n[e + 5], 5, -701558691), g, v, n[e + 10], 9, 38016083), l, g, n[e + 15], 14, -660478335), m, l, n[e + 4], 20, -405537848), v = u(v, m = u(m, l = u(l, g, v, m, n[e + 9], 5, 568446438), g, v, n[e + 14], 9, -1019803690), l, g, n[e + 3], 14, -187363961), m, l, n[e + 8], 20, 1163531501), v = u(v, m = u(m, l = u(l, g, v, m, n[e + 13], 5, -1444681467), g, v, n[e + 2], 9, -51403784), l, g, n[e + 7], 14, 1735328473), m, l, n[e + 12], 20, -1926607734), v = c(v, m = c(m, l = c(l, g, v, m, n[e + 5], 4, -378558), g, v, n[e + 8], 11, -2022574463), l, g, n[e + 11], 16, 1839030562), m, l, n[e + 14], 23, -35309556), v = c(v, m = c(m, l = c(l, g, v, m, n[e + 1], 4, -1530992060), g, v, n[e + 4], 11, 1272893353), l, g, n[e + 7], 16, -155497632), m, l, n[e + 10], 23, -1094730640), v = c(v, m = c(m, l = c(l, g, v, m, n[e + 13], 4, 681279174), g, v, n[e], 11, -358537222), l, g, n[e + 3], 16, -722521979), m, l, n[e + 6], 23, 76029189), v = c(v, m = c(m, l = c(l, g, v, m, n[e + 9], 4, -640364487), g, v, n[e + 12], 11, -421815835), l, g, n[e + 15], 16, 530742520), m, l, n[e + 2], 23, -995338651), v = f(v, m = f(m, l = f(l, g, v, m, n[e], 6, -198630844), g, v, n[e + 7], 10, 1126891415), l, g, n[e + 14], 15, -1416354905), m, l, n[e + 5], 21, -57434055), v = f(v, m = f(m, l = f(l, g, v, m, n[e + 12], 6, 1700485571), g, v, n[e + 3], 10, -1894986606), l, g, n[e + 10], 15, -1051523), m, l, n[e + 1], 21, -2054922799), v = f(v, m = f(m, l = f(l, g, v, m, n[e + 8], 6, 1873313359), g, v, n[e + 15], 10, -30611744), l, g, n[e + 6], 15, -1560198380), m, l, n[e + 13], 21, 1309151649), v = f(v, m = f(m, l = f(l, g, v, m, n[e + 4], 6, -145523070), g, v, n[e + 11], 10, -1120210379), l, g, n[e + 2], 15, 718787259), m, l, n[e + 9], 21, -343485551), l = t(l, i), g = t(g, a), v = t(v, d), m = t(m, h); return [l, g, v, m] } function a(n) { var t, r = "", e = 32 * n.length; for (t = 0; t < e; t += 8)r += String.fromCharCode(n[t >> 5] >>> t % 32 & 255); return r } function d(n) { var t, r = []; for (r[(n.length >> 2) - 1] = void 0, t = 0; t < r.length; t += 1)r[t] = 0; var e = 8 * n.length; for (t = 0; t < e; t += 8)r[t >> 5] |= (255 & n.charCodeAt(t / 8)) << t % 32; return r } function h(n) { return a(i(d(n), 8 * n.length)) } function l(n, t) { var r, e, o = d(n), u = [], c = []; for (u[15] = c[15] = void 0, o.length > 16 && (o = i(o, 8 * n.length)), r = 0; r < 16; r += 1)u[r] = 909522486 ^ o[r], c[r] = 1549556828 ^ o[r]; return e = i(u.concat(d(t)), 512 + 8 * t.length), a(i(c.concat(e), 640)) } function g(n) { var t, r, e = ""; for (r = 0; r < n.length; r += 1)t = n.charCodeAt(r), e += "0123456789abcdef".charAt(t >>> 4 & 15) + "0123456789abcdef".charAt(15 & t); return e } function v(n) { return unescape(encodeURIComponent(n)) } function m(n) { return h(v(n)) } function p(n) { return g(m(n)) } function s(n, t) { return l(v(n), v(t)) } function C(n, t) { return g(s(n, t)) } function A(n, t, r) { return t ? r ? s(t, n) : C(t, n) : r ? m(n) : p(n) } $.md5 = A }(this); +function Env(t, e) { "undefined" != typeof process && JSON.stringify(process.env).indexOf("GITHUB") > -1 && process.exit(0); class s { constructor(t) { this.env = t } send(t, e = "GET") { t = "string" == typeof t ? { url: t } : t; let s = this.get; return "POST" === e && (s = this.post), new Promise((e, i) => { s.call(this, t, (t, s, r) => { t ? i(t) : e(s) }) }) } get(t) { return this.send.call(this.env, t) } post(t) { return this.send.call(this.env, t, "POST") } } return new class { constructor(t, e) { this.name = t, this.http = new s(this), this.data = null, this.dataFile = "box.dat", this.logs = [], this.isMute = !1, this.isNeedRewrite = !1, this.logSeparator = "\n", this.startTime = (new Date).getTime(), Object.assign(this, e), this.log("", `🔔${this.name}, 开始!`) } isNode() { return "undefined" != typeof module && !!module.exports } isQuanX() { return "undefined" != typeof $task } isSurge() { return "undefined" != typeof $httpClient && "undefined" == typeof $loon } isLoon() { return "undefined" != typeof $loon } toObj(t, e = null) { try { return JSON.parse(t) } catch { return e } } toStr(t, e = null) { try { return JSON.stringify(t) } catch { return e } } getjson(t, e) { let s = e; const i = this.getdata(t); if (i) try { s = JSON.parse(this.getdata(t)) } catch { } return s } setjson(t, e) { try { return this.setdata(JSON.stringify(t), e) } catch { return !1 } } getScript(t) { return new Promise(e => { this.get({ url: t }, (t, s, i) => e(i)) }) } runScript(t, e) { return new Promise(s => { let i = this.getdata("@chavy_boxjs_userCfgs.httpapi"); i = i ? i.replace(/\n/g, "").trim() : i; let r = this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout"); r = r ? 1 * r : 20, r = e && e.timeout ? e.timeout : r; const [o, h] = i.split("@"), n = { url: `http://${h}/v1/scripting/evaluate`, body: { script_text: t, mock_type: "cron", timeout: r }, headers: { "X-Key": o, Accept: "*/*" } }; this.post(n, (t, e, i) => s(i)) }).catch(t => this.logErr(t)) } loaddata() { if (!this.isNode()) return {}; { this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path"); const t = this.path.resolve(this.dataFile), e = this.path.resolve(process.cwd(), this.dataFile), s = this.fs.existsSync(t), i = !s && this.fs.existsSync(e); if (!s && !i) return {}; { const i = s ? t : e; try { return JSON.parse(this.fs.readFileSync(i)) } catch (t) { return {} } } } } writedata() { if (this.isNode()) { this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path"); const t = this.path.resolve(this.dataFile), e = this.path.resolve(process.cwd(), this.dataFile), s = this.fs.existsSync(t), i = !s && this.fs.existsSync(e), r = JSON.stringify(this.data); s ? this.fs.writeFileSync(t, r) : i ? this.fs.writeFileSync(e, r) : this.fs.writeFileSync(t, r) } } lodash_get(t, e, s) { const i = e.replace(/\[(\d+)\]/g, ".$1").split("."); let r = t; for (const t of i) if (r = Object(r)[t], void 0 === r) return s; return r } lodash_set(t, e, s) { return Object(t) !== t ? t : (Array.isArray(e) || (e = e.toString().match(/[^.[\]]+/g) || []), e.slice(0, -1).reduce((t, s, i) => Object(t[s]) === t[s] ? t[s] : t[s] = Math.abs(e[i + 1]) >> 0 == +e[i + 1] ? [] : {}, t)[e[e.length - 1]] = s, t) } getdata(t) { let e = this.getval(t); if (/^@/.test(t)) { const [, s, i] = /^@(.*?)\.(.*?)$/.exec(t), r = s ? this.getval(s) : ""; if (r) try { const t = JSON.parse(r); e = t ? this.lodash_get(t, i, "") : e } catch (t) { e = "" } } return e } setdata(t, e) { let s = !1; if (/^@/.test(e)) { const [, i, r] = /^@(.*?)\.(.*?)$/.exec(e), o = this.getval(i), h = i ? "null" === o ? null : o || "{}" : "{}"; try { const e = JSON.parse(h); this.lodash_set(e, r, t), s = this.setval(JSON.stringify(e), i) } catch (e) { const o = {}; this.lodash_set(o, r, t), s = this.setval(JSON.stringify(o), i) } } else s = this.setval(t, e); return s } getval(t) { return this.isSurge() || this.isLoon() ? $persistentStore.read(t) : this.isQuanX() ? $prefs.valueForKey(t) : this.isNode() ? (this.data = this.loaddata(), this.data[t]) : this.data && this.data[t] || null } setval(t, e) { return this.isSurge() || this.isLoon() ? $persistentStore.write(t, e) : this.isQuanX() ? $prefs.setValueForKey(t, e) : this.isNode() ? (this.data = this.loaddata(), this.data[e] = t, this.writedata(), !0) : this.data && this.data[e] || null } initGotEnv(t) { this.got = this.got ? this.got : require("got"), this.cktough = this.cktough ? this.cktough : require("tough-cookie"), this.ckjar = this.ckjar ? this.ckjar : new this.cktough.CookieJar, t && (t.headers = t.headers ? t.headers : {}, void 0 === t.headers.Cookie && void 0 === t.cookieJar && (t.cookieJar = this.ckjar)) } get(t, e = (() => { })) { t.headers && (delete t.headers["Content-Type"], delete t.headers["Content-Length"]), this.isSurge() || this.isLoon() ? (this.isSurge() && this.isNeedRewrite && (t.headers = t.headers || {}, Object.assign(t.headers, { "X-Surge-Skip-Scripting": !1 })), $httpClient.get(t, (t, s, i) => { !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i) })) : this.isQuanX() ? (this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, { hints: !1 })), $task.fetch(t).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => e(t))) : this.isNode() && (this.initGotEnv(t), this.got(t).on("redirect", (t, e) => { try { if (t.headers["set-cookie"]) { const s = t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString(); s && this.ckjar.setCookieSync(s, null), e.cookieJar = this.ckjar } } catch (t) { this.logErr(t) } }).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => { const { message: s, response: i } = t; e(s, i, i && i.body) })) } post(t, e = (() => { })) { if (t.body && t.headers && !t.headers["Content-Type"] && (t.headers["Content-Type"] = "application/x-www-form-urlencoded"), t.headers && delete t.headers["Content-Length"], this.isSurge() || this.isLoon()) this.isSurge() && this.isNeedRewrite && (t.headers = t.headers || {}, Object.assign(t.headers, { "X-Surge-Skip-Scripting": !1 })), $httpClient.post(t, (t, s, i) => { !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i) }); else if (this.isQuanX()) t.method = "POST", this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, { hints: !1 })), $task.fetch(t).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => e(t)); else if (this.isNode()) { this.initGotEnv(t); const { url: s, ...i } = t; this.got.post(s, i).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => { const { message: s, response: i } = t; e(s, i, i && i.body) }) } } time(t, e = null) { const s = e ? new Date(e) : new Date; let i = { "M+": s.getMonth() + 1, "d+": s.getDate(), "H+": s.getHours(), "m+": s.getMinutes(), "s+": s.getSeconds(), "q+": Math.floor((s.getMonth() + 3) / 3), S: s.getMilliseconds() }; /(y+)/.test(t) && (t = t.replace(RegExp.$1, (s.getFullYear() + "").substr(4 - RegExp.$1.length))); for (let e in i) new RegExp("(" + e + ")").test(t) && (t = t.replace(RegExp.$1, 1 == RegExp.$1.length ? i[e] : ("00" + i[e]).substr(("" + i[e]).length))); return t } msg(e = t, s = "", i = "", r) { const o = t => { if (!t) return t; if ("string" == typeof t) return this.isLoon() ? t : this.isQuanX() ? { "open-url": t } : this.isSurge() ? { url: t } : void 0; if ("object" == typeof t) { if (this.isLoon()) { let e = t.openUrl || t.url || t["open-url"], s = t.mediaUrl || t["media-url"]; return { openUrl: e, mediaUrl: s } } if (this.isQuanX()) { let e = t["open-url"] || t.url || t.openUrl, s = t["media-url"] || t.mediaUrl; return { "open-url": e, "media-url": s } } if (this.isSurge()) { let e = t.url || t.openUrl || t["open-url"]; return { url: e } } } }; if (this.isMute || (this.isSurge() || this.isLoon() ? $notification.post(e, s, i, o(r)) : this.isQuanX() && $notify(e, s, i, o(r))), !this.isMuteLog) { let t = ["", "==============📣系统通知📣=============="]; t.push(e), s && t.push(s), i && t.push(i), console.log(t.join("\n")), this.logs = this.logs.concat(t) } } log(...t) { t.length > 0 && (this.logs = [...this.logs, ...t]), console.log(t.join(this.logSeparator)) } logErr(t, e) { const s = !this.isSurge() && !this.isQuanX() && !this.isLoon(); s ? this.log("", `❗️${this.name}, 错误!`, t.stack) : this.log("", `❗️${this.name}, 错误!`, t) } wait(t) { return new Promise(e => setTimeout(e, t)) } done(t = {}) { const e = (new Date).getTime(), s = (e - this.startTime) / 1e3; this.log("", `🔔${this.name}, 结束! 🕛 ${s} 秒`), this.log(), (this.isSurge() || this.isQuanX() || this.isLoon()) && $done(t) } }(t, e) } diff --git a/activity/jd_opencard105.js b/activity/jd_opencard105.js new file mode 100644 index 0000000..e5c39c7 --- /dev/null +++ b/activity/jd_opencard105.js @@ -0,0 +1,754 @@ +/* +1.6~1.20 山海之巅,冲刺大牌盲盒 +新增开卡脚本,一次性脚本 + +1.邀请一人200豆 +2.开12张 成功开1张 可能获得30京豆 +3.关注120山海值 +4.加购100山海值 +5.抽奖(200山海值) + + +第一个账号助力作者 其他依次助力CK1 +第一个CK失效会退出脚本 + +———————————————— +入口:[ 1.6~1.20 山海之巅,冲刺大牌盲盒 (https://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/index/activity?activityId=dz220106100001616201Union&shareUuid=18510cf80be44e718d86e90cf0dc9241)] +请求太频繁会被黑ip +过10分钟再执行 + +cron:30 4,18 6-20/2 1 * +============Quantumultx=============== +[task_local] +#1.6~1.20 山海之巅,冲刺大牌盲盒 +30 4,18 6-20/2 1 * jd_opencard105.js, tag=1.6~1.20 山海之巅,冲刺大牌盲盒, enabled=true + +*/ +const $ = new Env('1.6~1.20 山海之巅,冲刺大牌盲盒'); +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const notify = $.isNode() ? require('./sendNotify') : ''; + +let cookiesArr = [], + cookie = ''; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} +allMessage = "" +message = "" +$.hotFlag = false +$.outFlag = false +$.activityEnd = false +let lz_jdpin_token_cookie ='' +let activityCookie ='' +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', { + "open-url": "https://bean.m.jd.com/" + }); + return; + } + $.activityId = "dz220106100001616201Union" + $.shareUuid = "18510cf80be44e718d86e90cf0dc9241" + console.log(`入口:\nhttps://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/index/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}`) + let shareUuidArr = [$.shareUuid,"18510cf80be44e718d86e90cf0dc9241","1160ce40cedd40c7bd62d702f8e300a8","a95818413b514ae4b2ac3872894c999d"] + let s = Math.floor((Math.random()*10)) + let n = 0 + if(s == 1) n = Math.floor((Math.random()*shareUuidArr.length)) + $.shareUuid = shareUuidArr[n] ? shareUuidArr[n] : $.shareUuid + + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i]; + if (cookie) { + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + message = "" + $.bean = 0 + $.hotFlag = false + $.nickName = ''; + console.log(`\n\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + await getUA() + await run(); + if(i == 0 && !$.actorUuid) break + if($.outFlag || $.activityEnd) break + } + } + if($.outFlag) { + let msg = '此ip已被限制,请过10分钟后再执行脚本' + $.msg($.name, ``, `${msg}`); + if ($.isNode()) await notify.sendNotify(`${$.name}`, `${msg}`); + } +})() + .catch((e) => $.logErr(e)) + .finally(() => $.done()) + + +async function run() { + try { + $.hasEnd = true + $.endTime = 0 + lz_jdpin_token_cookie = '' + $.Token = '' + $.Pin = '' + let flag = false + await takePostRequest('isvObfuscator'); + if($.Token == ''){ + console.log('获取[token]失败!') + return + } + await getCk() + if (activityCookie == '') { + console.log(`获取cookie失败`); return; + } + if($.activityEnd === true){ + console.log('活动结束') + return + } + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + await takePostRequest('getSimpleActInfoVo'); + await takePostRequest('getMyPing'); + if(!$.Pin){ + console.log('获取[Pin]失败!') + return + } + await takePostRequest('accessLogWithAD'); + await takePostRequest('getUserInfo'); + await takePostRequest('activityContent'); + if($.hotFlag) return + if(!$.actorUuid){ + console.log('获取不到[actorUuid]退出执行,请重新执行') + return + } + if($.hasEnd === true || Date.now() > $.endTime){ + $.activityEnd = true + console.log('活动结束') + return + } + await takePostRequest('drawContent'); + await $.wait(1000) + $.openList = [] + $.allOpenCard = false + await takePostRequest('checkOpenCard'); + await takePostRequest('getTaskInfos'); + // console.log($.actorUuid) + // return + if($.allOpenCard == false){ + console.log('开卡任务') + for(o of $.openList){ + $.openCard = false + if(o.status == 0){ + flag = true + $.joinVenderId = o.venderId + await joinShop() + await $.wait(parseInt(Math.random() * 2000 + 3000, 10)) + await takePostRequest('drawContent'); + await takePostRequest('checkOpenCard'); + await $.wait(parseInt(Math.random() * 3000 + 2000, 10)) + } + } + await takePostRequest('activityContent'); + }else{ + console.log('已全部开卡') + } + $.log("关注: " + $.followShop) + if(!$.followShop && !$.outFlag){ + flag = true + $.followShopValue = 23 + await takePostRequest('followShop'); + await $.wait(parseInt(Math.random() * 1000 + 5000, 10)) + } + $.log("加购: " + $.addSku) + if(!$.addSku && !$.outFlag){ + await takePostRequest('addSkus'); + await $.wait(parseInt(Math.random() * 1000 + 5000, 10)) + } + if(flag){ + await takePostRequest('activityContent'); + } + $.runFalag = true + let count = parseInt($.score/200) + console.log(`抽奖次数为:${count}`) + for(m=1;count--;m++){ + console.log(`第${m}次抽奖`) + await takePostRequest('抽奖'); + if($.runFalag == false) break + if(Number(count) <= 0) break + if(m >= 10){ + console.log("抽奖太多次,多余的次数请再执行脚本") + break + } + await $.wait(parseInt(Math.random() * 2000 + 2000, 10)) + } + + await $.wait(parseInt(Math.random() * 1000 + 2000, 10)) + await takePostRequest('getDrawRecordHasCoupon'); + await takePostRequest('getShareRecord'); + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + console.log($.actorUuid) + console.log(`当前助力:${$.shareUuid}`) + if($.index == 1){ + $.shareUuid = $.actorUuid + console.log(`后面的号都会助力:${$.shareUuid}`) + } + await $.wait(parseInt(Math.random() * 1000 + 5000, 10)) + if(flag) await $.wait(parseInt(Math.random() * 1000 + 10000, 10)) + if($.index % 3 == 0) console.log('休息1分钟,别被黑ip了\n可持续发展') + if($.index % 3 == 0) await $.wait(parseInt(Math.random() * 5000 + 60000, 10)) + } catch (e) { + console.log(e) + } +} + +async function takePostRequest(type) { + if($.outFlag) return + let domain = 'https://lzdz1-isv.isvjcloud.com'; + let body = ``; + let method = 'POST' + let admJson = '' + switch (type) { + case 'isvObfuscator': + url = `https://api.m.jd.com/client.action?functionId=isvObfuscator`; + body = `body=%7B%22url%22%3A%22https%3A//lzdz1-isv.isvjcloud.com%22%2C%22id%22%3A%22%22%7D&uuid=0846724fe8d803b8e84ebd14b3ba7fac6df80e7a&client=apple&clientVersion=10.1.4&st=1634616247215&sv=120&sign=91a16ae2feb0bd0e1ea48d99e7953c58`; + break; + case 'getSimpleActInfoVo': + url = `${domain}/dz/common/getSimpleActInfoVo`; + body = `activityId=${$.activityId}`; + break; + case 'getMyPing': + url = `${domain}/customer/getMyPing`; + body = `userId=${$.shopId || $.venderId || ''}&token=${$.Token}&fromType=APP`; + break; + case 'accessLogWithAD': + url = `${domain}/common/accessLogWithAD`; + let pageurl = `${domain}/drawCenter/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}` + body = `venderId=${$.shopId || $.venderId || ''}&code=99&pin=${encodeURIComponent($.Pin)}&activityId=${$.activityId}&pageUrl=${encodeURIComponent(pageurl)}&subType=app&adSource=` + break; + case 'getUserInfo': + url = `${domain}/wxActionCommon/getUserInfo`; + body = `pin=${encodeURIComponent($.Pin)}`; + break; + case 'activityContent': + url = `${domain}/dz/customized/common/activityContent`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&pinImg=${encodeURIComponent($.attrTouXiang)}&nick=${encodeURIComponent($.nickname)}&cjyxPin=&cjhyPin=&shareUuid=${$.shareUuid}` + break; + case 'drawContent': + url = `${domain}/dingzhi/taskact/openCardcommon/drawContent`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case 'checkOpenCard': + url = `${domain}/tongrentang/union/checkOpenCard`; + body = `activityId=${$.activityId}&actorUuid=${$.actorUuid}&pin=${encodeURIComponent($.Pin)}&shareUuid=${$.shareUuid}` + break; + case 'getTaskInfos': + url = `${domain}/tongrentang/union/getTaskInfos`; + body = `activityId=${$.activityId}&actorUuid=${$.actorUuid}&pin=${encodeURIComponent($.Pin)}` + break; + case 'startDraw': + url = `${domain}/dingzhi/shop/league/startDraw`; + body = `activityId=${$.activityId}&actorUuid=${$.actorUuid}&pin=${encodeURIComponent($.Pin)}${$.startDraw && '&type='+$.startDraw || ''}` + break; + case 'followShop': + url = `${domain}/tongrentang/union/saveTask`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&taskType=${$.followShopValue}` + break; + case 'addSkus': + url = `${domain}/tongrentang/union/saveTask`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&taskType=${$.followShopValue}` + break; + case 'viewVideo': + case 'visitSku': + case 'toShop': + case 'addSku': + url = `${domain}/dingzhi/shop/league/saveTask`; + let taskType = '' + let taskValue = '' + if(type == 'viewVideo'){ + taskType = 31 + taskValue = 31 + }else if(type == 'visitSku'){ + taskType = 5 + taskValue = $.visitSkuValue || 5 + }else if(type == 'toShop'){ + taskType = 14 + taskValue = $.toShopValue || 14 + }else if(type == 'addSku'){ + taskType = 2 + taskValue = $.addSkuValue || 2 + } + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&taskType=${taskType}&taskValue=${taskValue}` + break; + case 'getDrawRecordHasCoupon': + url = `${domain}/dz/customized/common/myPrize`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case 'getShareRecord': + url = `${domain}/tongrentang/union/getMyFriend`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case '抽奖': + url = `${domain}/tongrentang/union/start-draw`; + body = `activityId=${$.activityId}&actorUuid=${$.actorUuid}&pin=${encodeURIComponent($.Pin)}` + break; + default: + console.log(`错误${type}`); + } + let myRequest = getPostRequest(url, body, method); + // console.log(myRequest) + return new Promise(async resolve => { + $.post(myRequest, (err, resp, data) => { + try { + setActivityCookie(resp) + if (err) { + if(resp && typeof resp.statusCode != 'undefined'){ + if(resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + } + console.log(`${$.toStr(err,err)}`) + console.log(`${type} API请求失败,请检查网路重试`) + } else { + dealReturn(type, data); + } + } catch (e) { + // console.log(data); + console.log(e, resp) + } finally { + resolve(); + } + }) + }) + } + +async function dealReturn(type, data) { + let res = '' + try { + if(type != 'accessLogWithAD' || type != 'drawContent'){ + if(data){ + res = JSON.parse(data); + } + } + } catch (e) { + console.log(`${type} 执行任务异常`); + console.log(data); + $.runFalag = false; + } + try { + switch (type) { + case 'isvObfuscator': + if(typeof res == 'object'){ + if(res.errcode == 0){ + if(typeof res.token != 'undefined') $.Token = res.token + }else if(res.message){ + console.log(`isvObfuscator ${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + break; + case 'getSimpleActInfoVo': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(typeof res.data.shopId != 'undefined') $.shopId = res.data.shopId + if(typeof res.data.venderId != 'undefined') $.venderId = res.data.venderId + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getMyPing': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(res.data && typeof res.data.secretPin != 'undefined') $.Pin = res.data.secretPin + if(res.data && typeof res.data.nickname != 'undefined') $.nickname = res.data.nickname + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getUserInfo': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(res.data && typeof res.data.yunMidImageUrl != 'undefined') $.attrTouXiang = res.data.yunMidImageUrl || "https://img10.360buyimg.com/imgzone/jfs/t1/7020/27/13511/6142/5c5138d8E4df2e764/5a1216a3a5043c5d.png" + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'activityContent': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + $.endTime = res.data.endTime || (res.data.activityVO && res.data.activityVO.endTime) || 0 + $.hasEnd = res.data.hasEnd || false + $.actorUuid = res.data.actorUuid || (res.data.actorVO && res.data.actorVO.uuid) || '' + $.score = res.data.actorVO && res.data.actorVO.score || 0 + if(res.data.followShop && res.data.followShop.settings && res.data.followShop.settings[0]){ + $.followShopValue = res.data.followShop.settings[0].value || 1 + } + if(res.data.addSku && res.data.addSku.settings && res.data.addSku.settings[0]){ + $.addSkuValue = res.data.addSku.settings[0].value || 2 + } + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getTaskInfos': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + $.followShop = res.data.followShopTaskVO.allStatus || false + $.addSku = res.data.addCartTaskVO.allStatus || false + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'checkOpenCard': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + let cardList1 = res.data.cardList1 || [] + let cardList2 = res.data.cardList2 || [] + let cardList = res.data.cardList || [] + let infoSettingVos = res.data.infoSettingVos || [] + $.openList = [...cardList,...cardList1,...cardList2,...infoSettingVos] + $.allOpenCard = res.data.allOpenCard || res.data.allOpenCardStatus || false + $.openCardScore1 = res.data.score1 || res.data.drawScore1 || 0 + $.openCardScore2 = res.data.score2 || res.data.drawScore2 || 0 + $.openCardScore3 = res.data.score3 || res.data.drawScore3 || 0 + if(res.data.sendBeanNum) console.log(`开卡获得:${res.data.sendBeanNum}京豆`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'startDraw': + case 'followShop': + case 'viewVideo': + case 'visitSku': + case 'toShop': + case 'addSku': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(typeof res.data == 'object'){ + let msg = '' + let title = '抽奖' + if(res.data.addBeanNum && res.data.sendStatus){ + msg = `${res.data.addBeanNum}京豆` + } + if(type == 'followShop'){ + title = '关注' + if(res.data.beanNumMember && res.data.assistSendStatus){ + msg += ` 额外获得:${res.data.beanNumMember}京豆` + } + }else if(type == 'addSku'){ + title = '加购' + }else if(type == 'viewVideo'){ + title = '热门文章' + }else if(type == 'toShop'){ + title = '浏览店铺' + }else if(type == 'visitSku'){ + title = '浏览商品' + }else{ + msg = res.data.drawOk == true && (res.data.drawInfoType == 6 && res.data.name || '') || '空气💨' + } + if(!msg){ + msg = '空气💨' + } + console.log(`${title}获得:${msg || data}`) + }else{ + console.log(`${type} ${data}`) + } + }else if(res.errorMessage){ + $.runFalag = false; + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getDrawRecordHasCoupon': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + console.log(`我的奖品:`) + let num = 0 + let value = 0 + for(let i in res.data.recordList){ + let item = res.data.recordList[i] + if(item.infoName == '200京豆'){ + num++; + value = item.infoName.replace('京豆',''); + }else{ + console.log(`${item.infoName}`) + } + } + if(num > 0) console.log(`邀请好友(${num}):${num*parseInt(value, 10) || 30}京豆`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getShareRecord': + if(typeof res == 'object'){ + if(res.result && res.result === true && res.data){ + $.ShareCount = res.data.shareList.length + $.log(`=========== 你邀请了:${$.ShareCount}个`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'accessLogWithAD': + case 'drawContent': + break; + default: + console.log(`${type}-> ${data}`); + } + if(typeof res == 'object'){ + if(res.errorMessage){ + if(res.errorMessage.indexOf('火爆') >-1 ){ + $.hotFlag = true + } + } + } + } catch (e) { + console.log(e) + } +} + +function getPostRequest(url, body, method="POST") { + let headers = { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Content-Type": "application/x-www-form-urlencoded", + "Cookie": cookie, + "User-Agent": $.UA, + "X-Requested-With": "XMLHttpRequest" + } + if(url.indexOf('https://lzdz1-isv.isvjcloud.com') > -1){ + headers["Referer"] = `https://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/index/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}` + headers["Cookie"] = `${lz_jdpin_token_cookie && lz_jdpin_token_cookie || ''}${$.Pin && "AUTH_C_USER=" + $.Pin + ";" || ""}${activityCookie}` + } + // console.log(headers) + // console.log(headers.Cookie) + return {url: url, method: method, headers: headers, body: body, timeout:30000}; +} + +function getCk() { + return new Promise(resolve => { + let get = { + url:`https://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/index/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}`, + followRedirect:false, + headers: { + "User-Agent": $.UA, + }, + timeout:30000 + } + $.get(get, async(err, resp, data) => { + try { + if (err) { + if(resp && typeof resp.statusCode != 'undefined'){ + if(resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + } + console.log(`${$.toStr(err)}`) + console.log(`${$.name} cookie API请求失败,请检查网路重试`) + } else { + let end = data.match(/(活动已经结束)/) && data.match(/(活动已经结束)/)[1] || '' + if(end){ + $.activityEnd = true + console.log('活动已结束') + } + setActivityCookie(resp) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function setActivityCookie(resp){ + let LZ_TOKEN_KEY = '' + let LZ_TOKEN_VALUE = '' + let lz_jdpin_token = '' + let setcookies = resp && resp['headers'] && (resp['headers']['set-cookie'] || resp['headers']['Set-Cookie'] || '') || '' + let setcookie = '' + if(setcookies){ + if(typeof setcookies != 'object'){ + setcookie = setcookies.split(',') + }else setcookie = setcookies + for (let ck of setcookie) { + let name = ck.split(";")[0].trim() + if(name.split("=")[1]){ + // console.log(name.replace(/ /g,'')) + if(name.indexOf('LZ_TOKEN_KEY=')>-1) LZ_TOKEN_KEY = name.replace(/ /g,'')+';' + if(name.indexOf('LZ_TOKEN_VALUE=')>-1) LZ_TOKEN_VALUE = name.replace(/ /g,'')+';' + if(name.indexOf('lz_jdpin_token=')>-1) lz_jdpin_token = ''+name.replace(/ /g,'')+';' + } + } + } + if(LZ_TOKEN_KEY && LZ_TOKEN_VALUE) activityCookie = `${LZ_TOKEN_KEY} ${LZ_TOKEN_VALUE}` + if(lz_jdpin_token) lz_jdpin_token_cookie = lz_jdpin_token +} + +async function getUA(){ + $.UA = `jdapp;iPhone;10.1.4;13.1.2;${randomString(40)};network/wifi;model/iPhone8,1;addressid/2308460611;appBuild/167814;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_1_2 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 joinShop() { + if(!$.joinVenderId) return + return new Promise(async resolve => { + $.shopactivityId = '' + await $.wait(1000) + await getshopactivityId() + let activityId = `` + if($.shopactivityId) activityId = `,"activityId":${$.shopactivityId}` + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body={"venderId":"${$.joinVenderId}","shopId":"${$.joinVenderId}","bindByVerifyCodeFlag":1,"registerExtend":{},"writeChildFlag":0${activityId},"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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + // console.log(data) + let res = $.toObj(data,data); + if(typeof res == 'object'){ + if(res.success === true){ + console.log(res.message) + if(res.result && res.result.giftInfo){ + for(let i of res.result.giftInfo.giftList){ + console.log(`入会获得:${i.discountString}${i.prizeName}${i.secondLineDesc}`) + } + } + }else if(typeof res == 'object' && res.message){ + console.log(`${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function getshopactivityId() { + return new Promise(resolve => { + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body=%7B%22venderId%22%3A%22${$.joinVenderId}%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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + let res = $.toObj(data,data); + if(typeof res == 'object'){ + if(res.success == true){ + // console.log($.toStr(res.result)) + console.log(`入会:${res.result.shopMemberCardInfo.venderCardName || ''}`) + $.shopactivityId = res.result.interestsRuleList && res.result.interestsRuleList[0] && res.result.interestsRuleList[0].interestsInfo && res.result.interestsRuleList[0].interestsInfo.activityId || '' + } + }else{ + console.log(data) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} + + +// 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)} + diff --git a/activity/jd_opencard11.js b/activity/jd_opencard11.js new file mode 100644 index 0000000..17edf34 --- /dev/null +++ b/activity/jd_opencard11.js @@ -0,0 +1,542 @@ +/* +大牌联合开卡 +2021年11月1日 - 2021年11月11日 + +cron 15 2,21 * * * https://raw.githubusercontent.com/KingRan/JDJB/main/jd_opencard11.js +*/ +const $ = new Env("2021-11.1-11-11 大牌联合"); +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const notify = $.isNode() ? require('./sendNotify') : ''; +const cp = $.isNode() ? require('child_process') : ''; +let cookiesArr = [], cookie = '', message = ''; +const Base64 = require("js-base64") +let ownCode = null; +if ($.isNode()) { + console.log('先运行一次查看是否有豆,有豆再运行!!!') + console.log('安装依赖:pnpm install js-base64') + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => { }; +} else { + let cookiesData = $.getdata('CookiesJD') || "[]"; + cookiesData = JSON.parse(cookiesData); + cookiesArr = cookiesData.map(item => item.cookie); + cookiesArr.reverse(); + cookiesArr.push(...[$.getdata('CookieJD2'), $.getdata('CookieJD')]); + cookiesArr.reverse(); + cookiesArr = cookiesArr.filter(item => !!item); +} +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', { "open-url": "https://bean.m.jd.com/bean/signIndex.action" }); + return; + } + authorCodeList = await getAuthorCodeList('https://gitee.com/KingRan521/JD-Scripts/raw/master/shareCodes/opencard11.json') + if(authorCodeList === '404: Not Found'){ + authorCodeList = [ + 'k1Nobb+P0er+C2sysxnx/P2KELO9izRVpwCyqu0eqVZ5aW7RHzlMobrzJ/e9r/uf', + ] + } + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i] + originCookie = cookiesArr[i] + newCookie = '' + $.UserName = decodeURIComponent(cookie.match(/pt_pin=(.+?);/) && cookie.match(/pt_pin=(.+?);/)[1]) + $.index = i + 1; + $.isLogin = true; + $.nickName = ''; + await checkCookie(); + console.log(`\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + if (!$.isLogin) { + $.msg($.name, `【提示】cookie已失效`, `京东账号${$.index} ${$.nickName || $.UserName}\n请重新登录获取\nhttps://bean.m.jd.com/bean/signIndex.action`, { "open-url": "https://bean.m.jd.com/bean/signIndex.action" }); + if ($.isNode()) { + // await notify.sendNotify(`${$.name}cookie已失效 - ${$.UserName}`, `京东账号${$.index} ${$.UserName}\n请重新登录获取cookie`); + } + continue + } + $.bean = 0; + $.ADID = getUUID('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', 1); + $.UUID = getUUID('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'); + $.appkey = "51B59BB805903DA4CE513D29EC448375" + $.userId = "10299171" + $.actId = "2c5156ff82714_11013" + $.authorCode = ownCode ? ownCode : authorCodeList[random(0, authorCodeList.length)] + console.log('去助力 -> '+$.authorCode); + await openCardNew(); + if ($.bean > 0) { + message += `\n【京东账号${$.index}】${$.nickName || $.UserName} \n └ 获得 ${$.bean} 京豆。` + } + } + } + if (message !== '') { + if ($.isNode()) { + await notify.sendNotify($.name, message, '', `\n`); + } else { + $.msg($.name, '有点儿收获', message); + } + } +})() + .catch((e) => { + $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') + }) + .finally(() => { + $.done(); + }) + + +async function openCardNew() { + $.token = null; + $.buyerNick = null; + $.activityInfo = null; + await getToken(); + if ($.token) { + await task('activity_load', { + "actId": $.actId, + "inviteNick": $.authorCode, + "jdToken": $.token, + "source": "01", + }) + if ($.buyerNick) { + console.log('1.助力码 -> '+$.buyerNick) + if ($.index === 1) { + ownCode = $.buyerNick + console.log("后面的将给这个助力码助力 -> "+ownCode) + } + console.log('2.绑定助力 ->') + await task('complete/mission', { + "actId": $.actId, + "missionType": "relationBind", + "inviterNick": $.authorCode, + }) + await task('shopList', { + "actId": $.actId, + }) + console.log('3.关注店铺 ->') + await task('complete/mission', { + "actId": $.actId, + "missionType": "uniteCollectShop", + }) + console.log('4.抽奖 ->') + await task('draw/post', { + "actId": $.actId, + "usedGameNum": "2", + "dataType": "draw", + }) + console.log('5.加入会员 ->') + if ($.shopList) { + console.log('会员卡数量 -> '+$.shopList.length) + for (const vo of $.shopList) { + $.log(`${vo.userId}`) + if (!vo.open) { + $.log("开通会员") + await getShopOpenCardInfo(vo.userId) + await bindWithVender(vo.userId) + await task('complete/mission', { + "actId": $.actId, + "shopId": vo.userId, + "missionType": "openCard", + }) + await $.wait(3000) + } else { + $.log("已经是会员了") + } + await $.wait(500) + } + } + console.log('6.加入购物车 ->') + await task('complete/mission', { + "actId": $.actId, + "missionType": "uniteAddCart", + }) + } else { + $.log("没有成功获取到用户信息") + } + } else { + $.log("没有成功获取到用户鉴权信息") + } +} + +function task(function_id, preParams) { + body = { + "jsonRpc": "2.0", + "params": { + "commonParameter": { + "appkey": $.appkey, + "m": "POST", + "timestamp": new Date(), + "userId": $.userId + }, + "admJson": { + "method": `/openCardNew/${function_id}`, + "userId": $.userId, + "buyerNick": $.buyerNick ? $.buyerNick : "" + } + } + } + Object.assign(body.params.admJson, preParams) + return new Promise(resolve => { + $.post(taskUrl(function_id, body), async (err, resp, data) => { + try { + if (err) { + $.log(err) + } else { + + if (data) { + data = JSON.parse(data); + if (data.success) { + if (data.data.status === 200) { + switch (function_id) { + case 'activity_load': + $.buyerNick = data.data.data.buyerNick; + console.log("[ "+data.data.data.cusActivity.actName+" ]"); + break; + case 'shopList': + $.shopList = data.data.data.cusShops; + break; + case 'complete/mission': + console.log(data.data.data.remark); + break; + case 'draw/post': + console.log(data.data.data.awardSetting.awardName); + break; + default: + break; + } + } + } + + } else { + $.log("京东没有返回数据") + } + } + } catch (error) { + $.log(error) + } finally { + resolve(); + } + }) + }) +} +function getShopOpenCardInfo(venderId) { + let opt = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body=${encodeURIComponent(JSON.stringify({ venderId: venderId, channel: 401 }))}&client=H5&clientVersion=9.2.0&uuid=88888`, + headers: { + Host: 'api.m.jd.com', + Accept: '*/*', + Connection: 'keep-alive', + Cookie: cookie, + 'User-Agent': `jdapp;iPhone;9.5.4;13.6;${$.UUID};network/wifi;ADID/${$.ADID};model/iPhone10,3;addressid/0;appBuild/167668;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1`, + 'Accept-Language': 'zh-cn', + Referer: `https://shopmember.m.jd.com/shopcard/?venderId=${venderId}}&channel=401&returnUrl=${encodeURIComponent('https://jinggengjcq-isv.isvjcloud.com/fronth5')}`, + 'Accept-Encoding': 'gzip, deflate, br' + } + } + return new Promise(resolve => { + $.get(opt, (err, resp, data) => { + try { + if (err) { + console.log(err) + } else { + res = JSON.parse(data) + if (res.success) { + if (res.result.interestsRuleList) { + $.openCardActivityId = res.result.interestsRuleList[0].interestsInfo.activityId; + } + } + } + } catch (error) { + console.log(error) + } finally { + resolve(); + } + }) + + }) +} +function bindWithVender(venderId) { + let opt = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body=${encodeURIComponent(JSON.stringify({ "venderId": venderId, "bindByVerifyCodeFlag": 1, "registerExtend": {}, "writeChildFlag": 0, "channel": 401 }))}&client=H5&clientVersion=9.2.0&uuid=88888`, + headers: { + Host: 'api.m.jd.com', + Accept: '*/*', + Connection: 'keep-alive', + Cookie: cookie, + 'User-Agent': `jdapp;iPhone;9.5.4;13.6;${$.UUID};network/wifi;ADID/${$.ADID};model/iPhone10,3;addressid/0;appBuild/167668;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1`, + 'Accept-Language': 'zh-cn', + Referer: `https://shopmember.m.jd.com/shopcard/?venderId=${venderId}}&channel=401&returnUrl=${encodeURIComponent('https://jinggengjcq-isv.isvjcloud.com/fronth5')}`, + 'Accept-Encoding': 'gzip, deflate, br' + } + } + return new Promise(resolve => { + $.get(opt, (err, resp, data) => { + try { + if (err) { + console.log(err) + } else { + res = JSON.parse(data) + if (res.success) { + console.log("开卡成功") + } + } + } catch (error) { + console.log(error) + } finally { + resolve(); + } + }) + + }) +} +function taskUrl(function_id, body) { + return { + url: `https://jinggengjcq-isv.isvjcloud.com/dm/front/openCardNew/${function_id}?&mix_nick=${$.buyerNick ? $.buyerNick : ""}`, + headers: { + Host: 'jinggengjcq-isv.isvjcloud.com', + Accept: 'application/json', + 'X-Requested-With': 'XMLHttpRequest', + 'Accept-Language': 'zh-cn', + 'Accept-Encoding': 'gzip, deflate, br', + 'Content-Type': 'application/json; charset=utf-8', + Origin: 'https://jinggengjcq-isv.isvjcloud.com', + 'User-Agent': `jdapp;iPhone;9.5.4;13.6;${$.UUID};network/wifi;ADID/${$.ADID};model/iPhone10,3;addressid/0;appBuild/167668;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1`, + Connection: 'keep-alive', + Referer: 'https://jinggengjcq-isv.isvjcloud.com/fronth5/', + Cookie: cookie + }, + body: JSON.stringify(body) + + } +} + +function getMyPing() { + let opt = { + url: `https://lzdz1-isv.isvjcloud.com/customer/getMyPing`, + headers: { + Host: 'lzdz1-isv.isvjcloud.com', + Accept: 'application/json', + 'X-Requested-With': 'XMLHttpRequest', + 'Accept-Language': 'zh-cn', + 'Accept-Encoding': 'gzip, deflate, br', + 'Content-Type': 'application/x-www-form-urlencoded', + Origin: 'https://lzdz1-isv.isvjcloud.com', + 'User-Agent': `jdapp;iPhone;9.5.4;13.6;${$.UUID};network/wifi;ADID/${$.ADID};model/iPhone10,3;addressid/0;appBuild/167668;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1`, + Connection: 'keep-alive', + Referer: $.activityUrl, + Cookie: cookie, + }, + body: `userId=${$.activityShopId}&token=${$.token}&fromType=APP&riskType=1` + } + return new Promise(resolve => { + $.post(opt, (err, resp, data) => { + try { + if (err) { + $.log(err) + } else { + if (resp['headers']['set-cookie']) { + cookie = `${originCookie}` + if ($.isNode()) { + for (let sk of resp['headers']['set-cookie']) { + cookie = `${cookie}${sk.split(";")[0]};` + } + } else { + for (let ck of resp['headers']['Set-Cookie'].split(',')) { + cookie = `${cookie}${ck.split(";")[0]};` + } + } + } + if (resp['headers']['Set-Cookie']) { + cookie = `${originCookie}` + if ($.isNode()) { + for (let sk of resp['headers']['set-cookie']) { + cookie = `${cookie}${sk.split(";")[0]};` + } + } else { + for (let ck of resp['headers']['Set-Cookie'].split(',')) { + cookie = `${cookie}${ck.split(";")[0]};` + } + } + } + if (data) { + data = JSON.parse(data) + if (data.result) { + $.log(`你好:${data.data.nickname}`) + $.pin = data.data.nickname; + $.secretPin = data.data.secretPin; + cookie = `${cookie};AUTH_C_USER=${data.data.secretPin}` + } else { + $.log(data.errorMessage) + } + } + } + } catch (error) { + $.log(error) + } finally { + resolve(); + } + + }) + }) +} +function getFirstLZCK() { + return new Promise(resolve => { + $.get({ url: $.activityUrl }, (err, resp, data) => { + try { + if (err) { + console.log(err) + } else { + if (resp['headers']['set-cookie']) { + cookie = `${originCookie}` + if ($.isNode()) { + for (let sk of resp['headers']['set-cookie']) { + cookie = `${cookie}${sk.split(";")[0]};` + } + } else { + for (let ck of resp['headers']['Set-Cookie'].split(',')) { + cookie = `${cookie}${ck.split(";")[0]};` + } + } + } + if (resp['headers']['Set-Cookie']) { + cookie = `${originCookie}` + if ($.isNode()) { + for (let sk of resp['headers']['set-cookie']) { + cookie = `${cookie}${sk.split(";")[0]};` + } + } else { + for (let ck of resp['headers']['Set-Cookie'].split(',')) { + cookie = `${cookie}${ck.split(";")[0]};` + } + } + } + } + } catch (error) { + console.log(error) + } finally { + resolve(); + } + }) + }) +} +function getAuthorCodeList(url) { + return new Promise(resolve => { + const options = { + url: `${url}?${new Date()}`, "timeout": 10000, headers: { + "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1 Edg/87.0.4280.88" + } + }; + $.get(options, async (err, resp, data) => { + try { + if (err) { + $.log(err) + } else { + if (data) data = JSON.parse(data) + } + } catch (e) { + $.logErr(e, resp) + data = null; + } finally { + resolve(data); + } + }) + }) +} +function getToken() { + let opt = { + url: `https://api.m.jd.com/client.action?functionId=isvObfuscator`, + headers: { + Host: 'api.m.jd.com', + 'Content-Type': 'application/x-www-form-urlencoded', + Accept: '*/*', + Connection: 'keep-alive', + Cookie: cookie, + 'User-Agent': 'JD4iPhone/167650 (iPhone; iOS 13.7; Scale/3.00)', + 'Accept-Language': 'zh-Hans-CN;q=1', + 'Accept-Encoding': 'gzip, deflate, br', + }, + body: `body=%7B%22url%22%3A%20%22https%3A//lzkj-isv.isvjcloud.com%22%2C%20%22id%22%3A%20%22%22%7D&uuid=hjudwgohxzVu96krv&client=apple&clientVersion=9.4.0&st=1620476162000&sv=111&sign=f9d1b7e3b943b6a136d54fe4f892af05` + } + return new Promise(resolve => { + $.post(opt, (err, resp, data) => { + try { + if (err) { + $.log(err) + } else { + if (data) { + data = JSON.parse(data); + if (data.code === "0") { + $.token = data.token + } + } else { + $.log("京东返回了空数据") + } + } + } catch (error) { + $.log(error) + } finally { + resolve(); + } + }) + }) +} +function random(min, max) { + + return Math.floor(Math.random() * (max - min)) + min; + +} +function getUUID(format = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', UpperCase = 0) { + return format.replace(/[xy]/g, function (c) { + var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8); + if (UpperCase) { + uuid = v.toString(36).toUpperCase(); + } else { + uuid = v.toString(36) + } + return uuid; + }); +} +function checkCookie() { + const options = { + url: "https://me-api.jd.com/user_new/info/GetJDUserInfoUnion", + headers: { + "Host": "me-api.jd.com", + "Accept": "*/*", + "Connection": "keep-alive", + "Cookie": cookie, + "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.2 Mobile/15E148 Safari/604.1", + "Accept-Language": "zh-cn", + "Referer": "https://home.m.jd.com/myJd/newhome.action?sceneval=2&ufc=&", + "Accept-Encoding": "gzip, deflate, br", + } + }; + return new Promise(resolve => { + $.get(options, (err, resp, data) => { + try { + if (err) { + $.logErr(err) + } else { + if (data) { + data = JSON.parse(data); + if (data.retcode === "1001") { + $.isLogin = false; //cookie过期 + return; + } + if (data.retcode === "0" && data.data.hasOwnProperty("userInfo")) { + $.nickName = data.data.userInfo.baseInfo.nickname; + } + } else { + $.log('京东返回了空数据'); + } + } + } catch (e) { + $.logErr(e) + } finally { + resolve(); + } + }) + }) +} +// prettier-ignore +!function (n) { "use strict"; function t(n, t) { var r = (65535 & n) + (65535 & t); return (n >> 16) + (t >> 16) + (r >> 16) << 16 | 65535 & r } function r(n, t) { return n << t | n >>> 32 - t } function e(n, e, o, u, c, f) { return t(r(t(t(e, n), t(u, f)), c), o) } function o(n, t, r, o, u, c, f) { return e(t & r | ~t & o, n, t, u, c, f) } function u(n, t, r, o, u, c, f) { return e(t & o | r & ~o, n, t, u, c, f) } function c(n, t, r, o, u, c, f) { return e(t ^ r ^ o, n, t, u, c, f) } function f(n, t, r, o, u, c, f) { return e(r ^ (t | ~o), n, t, u, c, f) } function i(n, r) { n[r >> 5] |= 128 << r % 32, n[14 + (r + 64 >>> 9 << 4)] = r; var e, i, a, d, h, l = 1732584193, g = -271733879, v = -1732584194, m = 271733878; for (e = 0; e < n.length; e += 16)i = l, a = g, d = v, h = m, g = f(g = f(g = f(g = f(g = c(g = c(g = c(g = c(g = u(g = u(g = u(g = u(g = o(g = o(g = o(g = o(g, v = o(v, m = o(m, l = o(l, g, v, m, n[e], 7, -680876936), g, v, n[e + 1], 12, -389564586), l, g, n[e + 2], 17, 606105819), m, l, n[e + 3], 22, -1044525330), v = o(v, m = o(m, l = o(l, g, v, m, n[e + 4], 7, -176418897), g, v, n[e + 5], 12, 1200080426), l, g, n[e + 6], 17, -1473231341), m, l, n[e + 7], 22, -45705983), v = o(v, m = o(m, l = o(l, g, v, m, n[e + 8], 7, 1770035416), g, v, n[e + 9], 12, -1958414417), l, g, n[e + 10], 17, -42063), m, l, n[e + 11], 22, -1990404162), v = o(v, m = o(m, l = o(l, g, v, m, n[e + 12], 7, 1804603682), g, v, n[e + 13], 12, -40341101), l, g, n[e + 14], 17, -1502002290), m, l, n[e + 15], 22, 1236535329), v = u(v, m = u(m, l = u(l, g, v, m, n[e + 1], 5, -165796510), g, v, n[e + 6], 9, -1069501632), l, g, n[e + 11], 14, 643717713), m, l, n[e], 20, -373897302), v = u(v, m = u(m, l = u(l, g, v, m, n[e + 5], 5, -701558691), g, v, n[e + 10], 9, 38016083), l, g, n[e + 15], 14, -660478335), m, l, n[e + 4], 20, -405537848), v = u(v, m = u(m, l = u(l, g, v, m, n[e + 9], 5, 568446438), g, v, n[e + 14], 9, -1019803690), l, g, n[e + 3], 14, -187363961), m, l, n[e + 8], 20, 1163531501), v = u(v, m = u(m, l = u(l, g, v, m, n[e + 13], 5, -1444681467), g, v, n[e + 2], 9, -51403784), l, g, n[e + 7], 14, 1735328473), m, l, n[e + 12], 20, -1926607734), v = c(v, m = c(m, l = c(l, g, v, m, n[e + 5], 4, -378558), g, v, n[e + 8], 11, -2022574463), l, g, n[e + 11], 16, 1839030562), m, l, n[e + 14], 23, -35309556), v = c(v, m = c(m, l = c(l, g, v, m, n[e + 1], 4, -1530992060), g, v, n[e + 4], 11, 1272893353), l, g, n[e + 7], 16, -155497632), m, l, n[e + 10], 23, -1094730640), v = c(v, m = c(m, l = c(l, g, v, m, n[e + 13], 4, 681279174), g, v, n[e], 11, -358537222), l, g, n[e + 3], 16, -722521979), m, l, n[e + 6], 23, 76029189), v = c(v, m = c(m, l = c(l, g, v, m, n[e + 9], 4, -640364487), g, v, n[e + 12], 11, -421815835), l, g, n[e + 15], 16, 530742520), m, l, n[e + 2], 23, -995338651), v = f(v, m = f(m, l = f(l, g, v, m, n[e], 6, -198630844), g, v, n[e + 7], 10, 1126891415), l, g, n[e + 14], 15, -1416354905), m, l, n[e + 5], 21, -57434055), v = f(v, m = f(m, l = f(l, g, v, m, n[e + 12], 6, 1700485571), g, v, n[e + 3], 10, -1894986606), l, g, n[e + 10], 15, -1051523), m, l, n[e + 1], 21, -2054922799), v = f(v, m = f(m, l = f(l, g, v, m, n[e + 8], 6, 1873313359), g, v, n[e + 15], 10, -30611744), l, g, n[e + 6], 15, -1560198380), m, l, n[e + 13], 21, 1309151649), v = f(v, m = f(m, l = f(l, g, v, m, n[e + 4], 6, -145523070), g, v, n[e + 11], 10, -1120210379), l, g, n[e + 2], 15, 718787259), m, l, n[e + 9], 21, -343485551), l = t(l, i), g = t(g, a), v = t(v, d), m = t(m, h); return [l, g, v, m] } function a(n) { var t, r = "", e = 32 * n.length; for (t = 0; t < e; t += 8)r += String.fromCharCode(n[t >> 5] >>> t % 32 & 255); return r } function d(n) { var t, r = []; for (r[(n.length >> 2) - 1] = void 0, t = 0; t < r.length; t += 1)r[t] = 0; var e = 8 * n.length; for (t = 0; t < e; t += 8)r[t >> 5] |= (255 & n.charCodeAt(t / 8)) << t % 32; return r } function h(n) { return a(i(d(n), 8 * n.length)) } function l(n, t) { var r, e, o = d(n), u = [], c = []; for (u[15] = c[15] = void 0, o.length > 16 && (o = i(o, 8 * n.length)), r = 0; r < 16; r += 1)u[r] = 909522486 ^ o[r], c[r] = 1549556828 ^ o[r]; return e = i(u.concat(d(t)), 512 + 8 * t.length), a(i(c.concat(e), 640)) } function g(n) { var t, r, e = ""; for (r = 0; r < n.length; r += 1)t = n.charCodeAt(r), e += "0123456789abcdef".charAt(t >>> 4 & 15) + "0123456789abcdef".charAt(15 & t); return e } function v(n) { return unescape(encodeURIComponent(n)) } function m(n) { return h(v(n)) } function p(n) { return g(m(n)) } function s(n, t) { return l(v(n), v(t)) } function C(n, t) { return g(s(n, t)) } function A(n, t, r) { return t ? r ? s(t, n) : C(t, n) : r ? m(n) : p(n) } $.md5 = A }(this); +function Env(t, e) { "undefined" != typeof process && JSON.stringify(process.env).indexOf("GITHUB") > -1 && process.exit(0); class s { constructor(t) { this.env = t } send(t, e = "GET") { t = "string" == typeof t ? { url: t } : t; let s = this.get; return "POST" === e && (s = this.post), new Promise((e, i) => { s.call(this, t, (t, s, r) => { t ? i(t) : e(s) }) }) } get(t) { return this.send.call(this.env, t) } post(t) { return this.send.call(this.env, t, "POST") } } return new class { constructor(t, e) { this.name = t, this.http = new s(this), this.data = null, this.dataFile = "box.dat", this.logs = [], this.isMute = !1, this.isNeedRewrite = !1, this.logSeparator = "\n", this.startTime = (new Date).getTime(), Object.assign(this, e), this.log("", `🔔${this.name}, 开始!`) } isNode() { return "undefined" != typeof module && !!module.exports } isQuanX() { return "undefined" != typeof $task } isSurge() { return "undefined" != typeof $httpClient && "undefined" == typeof $loon } isLoon() { return "undefined" != typeof $loon } toObj(t, e = null) { try { return JSON.parse(t) } catch { return e } } toStr(t, e = null) { try { return JSON.stringify(t) } catch { return e } } getjson(t, e) { let s = e; const i = this.getdata(t); if (i) try { s = JSON.parse(this.getdata(t)) } catch { } return s } setjson(t, e) { try { return this.setdata(JSON.stringify(t), e) } catch { return !1 } } getScript(t) { return new Promise(e => { this.get({ url: t }, (t, s, i) => e(i)) }) } runScript(t, e) { return new Promise(s => { let i = this.getdata("@chavy_boxjs_userCfgs.httpapi"); i = i ? i.replace(/\n/g, "").trim() : i; let r = this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout"); r = r ? 1 * r : 20, r = e && e.timeout ? e.timeout : r; const [o, h] = i.split("@"), n = { url: `http://${h}/v1/scripting/evaluate`, body: { script_text: t, mock_type: "cron", timeout: r }, headers: { "X-Key": o, Accept: "*/*" } }; this.post(n, (t, e, i) => s(i)) }).catch(t => this.logErr(t)) } loaddata() { if (!this.isNode()) return {}; { this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path"); const t = this.path.resolve(this.dataFile), e = this.path.resolve(process.cwd(), this.dataFile), s = this.fs.existsSync(t), i = !s && this.fs.existsSync(e); if (!s && !i) return {}; { const i = s ? t : e; try { return JSON.parse(this.fs.readFileSync(i)) } catch (t) { return {} } } } } writedata() { if (this.isNode()) { this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path"); const t = this.path.resolve(this.dataFile), e = this.path.resolve(process.cwd(), this.dataFile), s = this.fs.existsSync(t), i = !s && this.fs.existsSync(e), r = JSON.stringify(this.data); s ? this.fs.writeFileSync(t, r) : i ? this.fs.writeFileSync(e, r) : this.fs.writeFileSync(t, r) } } lodash_get(t, e, s) { const i = e.replace(/\[(\d+)\]/g, ".$1").split("."); let r = t; for (const t of i) if (r = Object(r)[t], void 0 === r) return s; return r } lodash_set(t, e, s) { return Object(t) !== t ? t : (Array.isArray(e) || (e = e.toString().match(/[^.[\]]+/g) || []), e.slice(0, -1).reduce((t, s, i) => Object(t[s]) === t[s] ? t[s] : t[s] = Math.abs(e[i + 1]) >> 0 == +e[i + 1] ? [] : {}, t)[e[e.length - 1]] = s, t) } getdata(t) { let e = this.getval(t); if (/^@/.test(t)) { const [, s, i] = /^@(.*?)\.(.*?)$/.exec(t), r = s ? this.getval(s) : ""; if (r) try { const t = JSON.parse(r); e = t ? this.lodash_get(t, i, "") : e } catch (t) { e = "" } } return e } setdata(t, e) { let s = !1; if (/^@/.test(e)) { const [, i, r] = /^@(.*?)\.(.*?)$/.exec(e), o = this.getval(i), h = i ? "null" === o ? null : o || "{}" : "{}"; try { const e = JSON.parse(h); this.lodash_set(e, r, t), s = this.setval(JSON.stringify(e), i) } catch (e) { const o = {}; this.lodash_set(o, r, t), s = this.setval(JSON.stringify(o), i) } } else s = this.setval(t, e); return s } getval(t) { return this.isSurge() || this.isLoon() ? $persistentStore.read(t) : this.isQuanX() ? $prefs.valueForKey(t) : this.isNode() ? (this.data = this.loaddata(), this.data[t]) : this.data && this.data[t] || null } setval(t, e) { return this.isSurge() || this.isLoon() ? $persistentStore.write(t, e) : this.isQuanX() ? $prefs.setValueForKey(t, e) : this.isNode() ? (this.data = this.loaddata(), this.data[e] = t, this.writedata(), !0) : this.data && this.data[e] || null } initGotEnv(t) { this.got = this.got ? this.got : require("got"), this.cktough = this.cktough ? this.cktough : require("tough-cookie"), this.ckjar = this.ckjar ? this.ckjar : new this.cktough.CookieJar, t && (t.headers = t.headers ? t.headers : {}, void 0 === t.headers.Cookie && void 0 === t.cookieJar && (t.cookieJar = this.ckjar)) } get(t, e = (() => { })) { t.headers && (delete t.headers["Content-Type"], delete t.headers["Content-Length"]), this.isSurge() || this.isLoon() ? (this.isSurge() && this.isNeedRewrite && (t.headers = t.headers || {}, Object.assign(t.headers, { "X-Surge-Skip-Scripting": !1 })), $httpClient.get(t, (t, s, i) => { !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i) })) : this.isQuanX() ? (this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, { hints: !1 })), $task.fetch(t).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => e(t))) : this.isNode() && (this.initGotEnv(t), this.got(t).on("redirect", (t, e) => { try { if (t.headers["set-cookie"]) { const s = t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString(); s && this.ckjar.setCookieSync(s, null), e.cookieJar = this.ckjar } } catch (t) { this.logErr(t) } }).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => { const { message: s, response: i } = t; e(s, i, i && i.body) })) } post(t, e = (() => { })) { if (t.body && t.headers && !t.headers["Content-Type"] && (t.headers["Content-Type"] = "application/x-www-form-urlencoded"), t.headers && delete t.headers["Content-Length"], this.isSurge() || this.isLoon()) this.isSurge() && this.isNeedRewrite && (t.headers = t.headers || {}, Object.assign(t.headers, { "X-Surge-Skip-Scripting": !1 })), $httpClient.post(t, (t, s, i) => { !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i) }); else if (this.isQuanX()) t.method = "POST", this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, { hints: !1 })), $task.fetch(t).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => e(t)); else if (this.isNode()) { this.initGotEnv(t); const { url: s, ...i } = t; this.got.post(s, i).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => { const { message: s, response: i } = t; e(s, i, i && i.body) }) } } time(t, e = null) { const s = e ? new Date(e) : new Date; let i = { "M+": s.getMonth() + 1, "d+": s.getDate(), "H+": s.getHours(), "m+": s.getMinutes(), "s+": s.getSeconds(), "q+": Math.floor((s.getMonth() + 3) / 3), S: s.getMilliseconds() }; /(y+)/.test(t) && (t = t.replace(RegExp.$1, (s.getFullYear() + "").substr(4 - RegExp.$1.length))); for (let e in i) new RegExp("(" + e + ")").test(t) && (t = t.replace(RegExp.$1, 1 == RegExp.$1.length ? i[e] : ("00" + i[e]).substr(("" + i[e]).length))); return t } msg(e = t, s = "", i = "", r) { const o = t => { if (!t) return t; if ("string" == typeof t) return this.isLoon() ? t : this.isQuanX() ? { "open-url": t } : this.isSurge() ? { url: t } : void 0; if ("object" == typeof t) { if (this.isLoon()) { let e = t.openUrl || t.url || t["open-url"], s = t.mediaUrl || t["media-url"]; return { openUrl: e, mediaUrl: s } } if (this.isQuanX()) { let e = t["open-url"] || t.url || t.openUrl, s = t["media-url"] || t.mediaUrl; return { "open-url": e, "media-url": s } } if (this.isSurge()) { let e = t.url || t.openUrl || t["open-url"]; return { url: e } } } }; if (this.isMute || (this.isSurge() || this.isLoon() ? $notification.post(e, s, i, o(r)) : this.isQuanX() && $notify(e, s, i, o(r))), !this.isMuteLog) { let t = ["", "==============📣系统通知📣=============="]; t.push(e), s && t.push(s), i && t.push(i), console.log(t.join("\n")), this.logs = this.logs.concat(t) } } log(...t) { t.length > 0 && (this.logs = [...this.logs, ...t]), console.log(t.join(this.logSeparator)) } logErr(t, e) { const s = !this.isSurge() && !this.isQuanX() && !this.isLoon(); s ? this.log("", `❗️${this.name}, 错误!`, t.stack) : this.log("", `❗️${this.name}, 错误!`, t) } wait(t) { return new Promise(e => setTimeout(e, t)) } done(t = {}) { const e = (new Date).getTime(), s = (e - this.startTime) / 1e3; this.log("", `🔔${this.name}, 结束! 🕛 ${s} 秒`), this.log(), (this.isSurge() || this.isQuanX() || this.isLoon()) && $done(t) } }(t, e) } diff --git a/activity/jd_opencard12.js b/activity/jd_opencard12.js new file mode 100644 index 0000000..6930d74 --- /dev/null +++ b/activity/jd_opencard12.js @@ -0,0 +1,600 @@ +/* +品质女装 年终狂欢 + +https://lzdz1-isv.isvjcloud.com/dingzhi/dz/openCard/activity?activityId=dzkbblntbt20211101A&shareUuid=814d73647bdd4da5a6ba4904ec20de7f + +cron 21 4,18 * * * https://raw.githubusercontent.com/KingRan/JDJB/main/jd_opencard12.js + +默认执行脚本。如果需要不执行 +环境变量 NO_RUSH=false +*/ +const $ = new Env("品质女装 年终狂欢"); +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const notify = $.isNode() ? require('./sendNotify') : ''; +let cookiesArr = [], cookie = '', message = ''; +let ownCode = null; +let isRush = true; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => { }; +} else { + let cookiesData = $.getdata('CookiesJD') || "[]"; + cookiesData = JSON.parse(cookiesData); + cookiesArr = cookiesData.map(item => item.cookie); + cookiesArr.reverse(); + cookiesArr.push(...[$.getdata('CookieJD2'), $.getdata('CookieJD')]); + cookiesArr.reverse(); + cookiesArr = cookiesArr.filter(item => !!item); +} +if (process.env.NO_RUSH && process.env.NO_RUSH != "") { + isRush = process.env.NO_RUSH; +} +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', { "open-url": "https://bean.m.jd.com/bean/signIndex.action" }); + return; + } + + authorCodeList = await getAuthorCodeList('https://gitee.com/KingRan521/JD-Scripts/raw/master/shareCodes/opencard12.json') + if(authorCodeList === '404: Not Found'){ + authorCodeList = [ + '814d73647bdd4da5a6ba4904ec20de7f', + ] + } + + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i] + originCookie = cookiesArr[i] + newCookie = '' + $.UserName = decodeURIComponent(cookie.match(/pt_pin=(.+?);/) && cookie.match(/pt_pin=(.+?);/)[1]) + $.index = i + 1; + $.isLogin = true; + $.nickName = ''; + await checkCookie(); + console.log(`\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + if (!$.isLogin) { + $.msg($.name, `【提示】cookie已失效`, `京东账号${$.index} ${$.nickName || $.UserName}\n请重新登录获取\nhttps://bean.m.jd.com/bean/signIndex.action`, { "open-url": "https://bean.m.jd.com/bean/signIndex.action" }); + if ($.isNode()) { + await notify.sendNotify(`${$.name}cookie已失效 - ${$.UserName}`, `京东账号${$.index} ${$.UserName}\n请重新登录获取cookie`); + } + continue + } + $.bean = 0; + $.ADID = getUUID('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', 1); + $.UUID = getUUID('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'); + // $.authorCode = authorCodeList[random(0, authorCodeList.length)] + $.authorCode = ownCode ? ownCode : authorCodeList[random(0, authorCodeList.length)] + $.authorNum = `${random(1000000, 9999999)}` + $.randomCode = random(1000000, 9999999) + $.activityId = 'dzkbblntbt20211101A' + $.activityShopId = '1000007653' + $.activityUrl = `https://lzdz1-isv.isvjd.com/dingzhi/dz/openCard/activity/${$.authorNum}?activityId=${$.activityId}&shareUuid=${encodeURIComponent($.authorCode)}&adsource=null&shareuserid4minipg=null&shopid=${$.activityShopId}&lng=00.000000&lat=00.000000&sid=&un_area=` + if (isRush === true) { + console.log("未检测到不执行环境变量,执行任务") + await rush(); + } else { + console.log("检测到不执行环境变量,退出任务,环境变量 NO_RUSH") + break + } + await $.wait(3000) + if ($.bean > 0) { + message += `\n【京东账号${$.index}】${$.nickName || $.UserName} \n └ 获得 ${$.bean} 京豆。` + } + } + } + if (message !== '') { + if ($.isNode()) { + await notify.sendNotify($.name, message, '', `\n`); + } else { + $.msg($.name, '有点儿收获', message); + } + } +})() + .catch((e) => { + $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') + }) + .finally(() => { + $.done(); + }) + + +async function rush() { + $.token = null; + $.secretPin = null; + $.openCardActivityId = null + await getFirstLZCK() + await getToken(); + if ($.token) { + await getMyPing(); + if ($.secretPin) { + console.log("去助力 -> "+$.authorCode) + await task('common/accessLogWithAD', `venderId=${$.activityShopId}&code=99&pin=${encodeURIComponent($.secretPin)}&activityId=${$.activityId}&pageUrl=${$.activityUrl}&subType=app&adSource=null`, 1); + await task('wxActionCommon/getUserInfo', `pin=${encodeURIComponent($.secretPin)}`, 1) + if ($.index === 1) { + await task('dz/openCard/activityContent', `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}&pinImg=&nick=${encodeURIComponent($.pin)}&cjyxPin=&cjhyPin=&shareUuid=${encodeURIComponent($.authorCode)}`, 0, 1) + } else { + await task('dz/openCard/activityContent', `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}&pinImg=&nick=${encodeURIComponent($.pin)}&cjyxPin=&cjhyPin=&shareUuid=${encodeURIComponent($.authorCode)}`) + } + await task('dz/openCard/checkOpenCard', `activityId=${$.activityId}&actorUuid=${$.actorUuid}&shareUuid=${$.authorCode}&pin=${encodeURIComponent($.secretPin)}`) + $.log("->关注店铺") + if ($.shopTask) { + if (!$.shopTask.allStatus) { + await task('dz/openCard/followShop', `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}&actorUuid=${encodeURIComponent($.actorUuid)}&taskType=23&taskValue=1000002520`) + } else { + $.log(" >>>已经关注过了\n") + await $.wait(2000) + return + } + } else { + $.log("没有获取到对应的任务。\n") + } + $.log("->->->> 加入店铺会员") + if ($.openCardStatus) { + for (let i = 0; i < ($.openCardStatus.cardList1.length + $.openCardStatus.cardList2.length); i++) { + $.log("模拟上报访问记录") + await task('crm/pageVisit/insertCrmPageVisit', `venderId=1000004065&pageId=dz20211013skcnurdk11jhdue84752hp&elementId=${encodeURIComponent(`去开卡${i}`)}&pin=${encodeURIComponent($.secretPin)}`, 1) + await $.wait(2000) + } + t1TaskList = [] + $.openCardStatus.cardList1.filter((x) => { if (x.status === 0) { t1TaskList.push(x) } }) + t2TaskList = [] + $.openCardStatus.cardList2.filter((x) => { if (x.status === 0) { t2TaskList.push(x) } }) + if (t1TaskList.length < 1) { + console.log(" >>>已经完成入会任务") + + } else { + for (const vo of t1TaskList) { + $.log(` >>>去加入${vo.name}`) + await getShopOpenCardInfo({ "venderId": `${vo.value}`, "channel": "401" }, vo.value) + await bindWithVender({ "venderId": `${vo.value}`, "bindByVerifyCodeFlag": 1, "registerExtend": {}, "writeChildFlag": 0, "activityId": $.openCardActivityId, "channel": 401 }, vo.value) + await $.wait(2000) + } + for (const vo of t2TaskList) { + $.log(` >>>${vo.name}`) + await getShopOpenCardInfo({ "venderId": `${vo.value}`, "channel": "401" }) + await bindWithVender({ "venderId": `${vo.value}`, "bindByVerifyCodeFlag": 1, "registerExtend": {}, "writeChildFlag": 0, "activityId": $.openCardActivityId, "channel": 401 }, vo.value) + await $.wait(2000) + } + } + + await task("taskact/openCardcommon/drawContent", `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}`) + await $.wait(2000) + await task('dz/openCard/checkOpenCard', `activityId=${$.activityId}&actorUuid=${$.actorUuid}&shareUuid=${$.authorCode}&pin=${encodeURIComponent($.secretPin)}`) + await $.wait(2000) + await task("dz/openCard/startDraw", `activityId=${$.activityId}&actorUuid=${$.actorUuid}&type=1&pin=${encodeURIComponent($.secretPin)}`) + await $.wait(2000) + await task("dz/openCard/startDraw", `activityId=${$.activityId}&actorUuid=${$.actorUuid}&type=2&pin=${encodeURIComponent($.secretPin)}`) + + } else { + $.log("没有获取到对应的任务。\n") + } + $.log("->->->> 加购物车") + await task("dz/openCard/saveTask", `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}&actorUuid=${$.actorUuid}&type=2&taskValue=100025232454`) + } + } +} + +function task(function_id, body, isCommon = 0, own = 0) { + return new Promise(resolve => { + $.post(taskUrl(function_id, body, isCommon), async (err, resp, data) => { + try { + if (err) { + $.log(err) + } else { + + if (data) { + data = JSON.parse(data); + if (data.result) { + switch (function_id) { + case 'wxActionCommon/getUserInfo': + break; + case 'dz/openCard/activityContent': + if (!data.data.hasEnd) { + $.log(`开启【${data.data.activityName}】活动`) + $.log("-------------------") + if ($.index === 1) { + ownCode = data.data.actorUuid + console.log(ownCode) + } + $.actorUuid = data.data.actorUuid; + $.skuTask = data.data.addSku; + $.shopTask = data.data.followShop; + } else { + $.log("活动已经结束"); + } + break; + case 'dz/openCard/checkOpenCard': + $.openCardStatus = data.data; + break; + case 'dz/openCard/saveTask': + console.log(data.data.addBeanNum) + break; + case 'dz/openCard/saveTask': + if (data.data) { + if (data.data.addBeanNum) { + $.bean += data.data.addBeanNum; + $.log(`==>获得【${data.data.addBeanNum}】京豆\n`) + } + } + break; + case 'dz/openCard/startDraw': + if (data.data.drawOk) { + switch (data.data.drawInfo.type) { + case 6: + $.bean += data.data.drawInfo.beanNum; + $.log(`==>获得【${data.data.drawInfo.beanNum}】京豆\n`) + break; + default: + if ($.isNode()) { + await notify.sendNotify("中奖了", `中奖信息:${JSON.stringify(data.data.drawInfo)}\n活动链接:${$.activityUrl}`) + } else { + $.msg("中奖了", `获得${data.data.drawInfo.name}`, `中奖信息:${JSON.stringify(data.data.drawInfo)}\n活动链接:${$.activityUrl}`) + } + break; + } + } + break; + case 'crm/pageVisit/insertCrmPageVisit': + $.log("==> 上报成功") + + case 'dz/openCard/followShop': + if (data.data) { + if (data.data.addBeanNum) { + $.bean += data.data.addBeanNum; + $.log(`==>获得【${data.data.addBeanNum}】京豆\n`) + } + } + break; + + break; + default: + $.log(JSON.stringify(data)) + break; + } + } else { + $.log(JSON.stringify(data)) + } + } else { + // $.log("京东没有返回数据") + } + } + } catch (error) { + $.log(error) + } finally { + resolve(); + } + }) + }) +} +function getShopOpenCardInfo(body, venderId) { + let opt = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body=${encodeURIComponent(JSON.stringify(body))}&client=H5&clientVersion=9.2.0&uuid=88888`, + headers: { + Host: 'api.m.jd.com', + Accept: '*/*', + Connection: 'keep-alive', + Cookie: cookie, + 'User-Agent': `jdapp;iPhone;9.5.4;13.6;${$.UUID};network/wifi;ADID/${$.ADID};model/iPhone10,3;addressid/0;appBuild/167668;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1`, + 'Accept-Language': 'zh-cn', + Referer: `https://shopmember.m.jd.com/shopcard/?venderId=${venderId}}&channel=801&returnUrl=${encodeURIComponent($.activityUrl)}`, + 'Accept-Encoding': 'gzip, deflate, br' + } + } + return new Promise(resolve => { + $.get(opt, (err, resp, data) => { + try { + if (err) { + console.log(err) + } else { + res = JSON.parse(data) + if (res.success) { + if (res.result.interestsRuleList) { + $.openCardActivityId = res.result.interestsRuleList[0].interestsInfo.activityId; + } + } + } + } catch (error) { + console.log(error) + } finally { + resolve(); + } + }) + + }) +} +function bindWithVender(body, venderId) { + let opt = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body=${encodeURIComponent(JSON.stringify(body))}&client=H5&clientVersion=9.2.0&uuid=88888`, + headers: { + Host: 'api.m.jd.com', + Accept: '*/*', + Connection: 'keep-alive', + Cookie: cookie, + 'User-Agent': `jdapp;iPhone;9.5.4;13.6;${$.UUID};network/wifi;ADID/${$.ADID};model/iPhone10,3;addressid/0;appBuild/167668;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1`, + 'Accept-Language': 'zh-cn', + Referer: `https://shopmember.m.jd.com/shopcard/?venderId=${venderId}}&channel=401&returnUrl=${encodeURIComponent($.activityUrl)}`, + 'Accept-Encoding': 'gzip, deflate, br' + } + } + return new Promise(resolve => { + $.get(opt, (err, resp, data) => { + try { + if (err) { + console.log(err) + } else { + res = JSON.parse(data) + if (res.success) { + if (res.result.giftInfo && res.result.giftInfo.giftList) { + for (const vo of res.result.giftInfo.giftList) { + if (vo.prizeType === 4) { + $.log(`==>获得【${vo.quantity}】京豆`) + $.bean += vo.quantity + } + } + } + } + } + } catch (error) { + console.log(error) + } finally { + resolve(); + } + }) + + }) +} +function taskUrl(function_id, body, isCommon) { + return { + url: isCommon ? `https://lzdz1-isv.isvjd.com/${function_id}` : `https://lzdz1-isv.isvjd.com/dingzhi/${function_id}`, + headers: { + Host: 'lzdz1-isv.isvjd.com', + Accept: 'application/json', + 'X-Requested-With': 'XMLHttpRequest', + 'Accept-Language': 'zh-cn', + 'Accept-Encoding': 'gzip, deflate, br', + 'Content-Type': 'application/x-www-form-urlencoded', + Origin: 'https://lzdz1-isv.isvjd.com', + 'User-Agent': `jdapp;iPhone;9.5.4;13.6;${$.UUID};network/wifi;ADID/${$.ADID};model/iPhone10,3;addressid/0;appBuild/167668;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1`, + Connection: 'keep-alive', + Referer: $.activityUrl, + Cookie: cookie + }, + body: body + + } +} +function getAuthorCodeList(url) { + return new Promise(resolve => { + const options = { + url: `${url}?${new Date()}`, "timeout": 10000, headers: { + "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1 Edg/87.0.4280.88" + } + }; + $.get(options, async (err, resp, data) => { + try { + if (err) { + $.log(err) + } else { + if (data) data = JSON.parse(data) + } + } catch (e) { + $.logErr(e, resp) + data = null; + } finally { + resolve(data); + } + }) + }) +} +function getMyPing() { + let opt = { + url: `https://lzdz1-isv.isvjd.com/customer/getMyPing`, + headers: { + Host: 'lzdz1-isv.isvjd.com', + Accept: 'application/json', + 'X-Requested-With': 'XMLHttpRequest', + 'Accept-Language': 'zh-cn', + 'Accept-Encoding': 'gzip, deflate, br', + 'Content-Type': 'application/x-www-form-urlencoded', + Origin: 'https://lzdz1-isv.isvjd.com', + 'User-Agent': `jdapp;iPhone;9.5.4;13.6;${$.UUID};network/wifi;ADID/${$.ADID};model/iPhone10,3;addressid/0;appBuild/167668;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1`, + Connection: 'keep-alive', + Referer: $.activityUrl, + Cookie: cookie, + }, + body: `userId=${$.activityShopId}&token=${$.token}&fromType=APP&riskType=1` + } + return new Promise(resolve => { + $.post(opt, (err, resp, data) => { + try { + if (err) { + $.log(err) + } else { + if (resp['headers']['set-cookie']) { + cookie = `${originCookie}` + if ($.isNode()) { + for (let sk of resp['headers']['set-cookie']) { + cookie = `${cookie}${sk.split(";")[0]};` + } + } else { + for (let ck of resp['headers']['Set-Cookie'].split(',')) { + cookie = `${cookie}${ck.split(";")[0]};` + } + } + } + if (resp['headers']['Set-Cookie']) { + cookie = `${originCookie}` + if ($.isNode()) { + for (let sk of resp['headers']['set-cookie']) { + cookie = `${cookie}${sk.split(";")[0]};` + } + } else { + for (let ck of resp['headers']['Set-Cookie'].split(',')) { + cookie = `${cookie}${ck.split(";")[0]};` + } + } + } + if (data) { + data = JSON.parse(data) + if (data.result) { + $.log(`你好:${data.data.nickname}`) + $.pin = data.data.nickname; + $.secretPin = data.data.secretPin; + cookie = `${cookie};AUTH_C_USER=${data.data.secretPin}` + } else { + $.log(data.errorMessage) + } + } else { + // $.log("京东返回了空数据") + } + } + } catch (error) { + $.log(error) + } finally { + resolve(); + } + + }) + }) +} +function getFirstLZCK() { + return new Promise(resolve => { + $.get({ url: $.activityUrl }, (err, resp, data) => { + try { + if (err) { + console.log(err) + } else { + if (resp['headers']['set-cookie']) { + cookie = `${originCookie}` + if ($.isNode()) { + for (let sk of resp['headers']['set-cookie']) { + cookie = `${cookie}${sk.split(";")[0]};` + } + } else { + for (let ck of resp['headers']['Set-Cookie'].split(',')) { + cookie = `${cookie}${ck.split(";")[0]};` + } + } + } + if (resp['headers']['Set-Cookie']) { + cookie = `${originCookie}` + if ($.isNode()) { + for (let sk of resp['headers']['set-cookie']) { + cookie = `${cookie}${sk.split(";")[0]};` + } + } else { + for (let ck of resp['headers']['Set-Cookie'].split(',')) { + cookie = `${cookie}${ck.split(";")[0]};` + } + } + } + } + } catch (error) { + console.log(error) + } finally { + resolve(); + } + }) + }) +} +function getToken() { + let opt = { + url: `https://api.m.jd.com/client.action?functionId=isvObfuscator`, + headers: { + Host: 'api.m.jd.com', + 'Content-Type': 'application/x-www-form-urlencoded', + Accept: '*/*', + Connection: 'keep-alive', + Cookie: cookie, + 'User-Agent': 'JD4iPhone/167650 (iPhone; iOS 13.7; Scale/3.00)', + 'Accept-Language': 'zh-Hans-CN;q=1', + 'Accept-Encoding': 'gzip, deflate, br', + }, + body: `body=%7B%22url%22%3A%20%22https%3A//lzkj-isv.isvjcloud.com%22%2C%20%22id%22%3A%20%22%22%7D&uuid=hjudwgohxzVu96krv&client=apple&clientVersion=9.4.0&st=1620476162000&sv=111&sign=f9d1b7e3b943b6a136d54fe4f892af05` + } + return new Promise(resolve => { + $.post(opt, (err, resp, data) => { + try { + if (err) { + $.log(err) + } else { + if (data) { + data = JSON.parse(data); + if (data.code === "0") { + $.token = data.token + } + } else { + $.log("京东返回了空数据") + } + } + } catch (error) { + $.log(error) + } finally { + resolve(); + } + }) + }) +} +function random(min, max) { + + return Math.floor(Math.random() * (max - min)) + min; + +} +function getUUID(format = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', UpperCase = 0) { + return format.replace(/[xy]/g, function (c) { + var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8); + if (UpperCase) { + uuid = v.toString(36).toUpperCase(); + } else { + uuid = v.toString(36) + } + return uuid; + }); +} +function checkCookie() { + const options = { + url: "https://me-api.jd.com/user_new/info/GetJDUserInfoUnion", + headers: { + "Host": "me-api.jd.com", + "Accept": "*/*", + "Connection": "keep-alive", + "Cookie": cookie, + "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.2 Mobile/15E148 Safari/604.1", + "Accept-Language": "zh-cn", + "Referer": "https://home.m.jd.com/myJd/newhome.action?sceneval=2&ufc=&", + "Accept-Encoding": "gzip, deflate, br", + } + }; + return new Promise(resolve => { + $.get(options, (err, resp, data) => { + try { + if (err) { + $.logErr(err) + } else { + if (data) { + data = JSON.parse(data); + if (data.retcode === "1001") { + $.isLogin = false; //cookie过期 + return; + } + if (data.retcode === "0" && data.data.hasOwnProperty("userInfo")) { + $.nickName = data.data.userInfo.baseInfo.nickname; + } + } else { + $.log('京东返回了空数据'); + } + } + } catch (e) { + $.logErr(e) + } finally { + resolve(); + } + }) + }) +} +// prettier-ignore +!function (n) { "use strict"; function t(n, t) { var r = (65535 & n) + (65535 & t); return (n >> 16) + (t >> 16) + (r >> 16) << 16 | 65535 & r } function r(n, t) { return n << t | n >>> 32 - t } function e(n, e, o, u, c, f) { return t(r(t(t(e, n), t(u, f)), c), o) } function o(n, t, r, o, u, c, f) { return e(t & r | ~t & o, n, t, u, c, f) } function u(n, t, r, o, u, c, f) { return e(t & o | r & ~o, n, t, u, c, f) } function c(n, t, r, o, u, c, f) { return e(t ^ r ^ o, n, t, u, c, f) } function f(n, t, r, o, u, c, f) { return e(r ^ (t | ~o), n, t, u, c, f) } function i(n, r) { n[r >> 5] |= 128 << r % 32, n[14 + (r + 64 >>> 9 << 4)] = r; var e, i, a, d, h, l = 1732584193, g = -271733879, v = -1732584194, m = 271733878; for (e = 0; e < n.length; e += 16)i = l, a = g, d = v, h = m, g = f(g = f(g = f(g = f(g = c(g = c(g = c(g = c(g = u(g = u(g = u(g = u(g = o(g = o(g = o(g = o(g, v = o(v, m = o(m, l = o(l, g, v, m, n[e], 7, -680876936), g, v, n[e + 1], 12, -389564586), l, g, n[e + 2], 17, 606105819), m, l, n[e + 3], 22, -1044525330), v = o(v, m = o(m, l = o(l, g, v, m, n[e + 4], 7, -176418897), g, v, n[e + 5], 12, 1200080426), l, g, n[e + 6], 17, -1473231341), m, l, n[e + 7], 22, -45705983), v = o(v, m = o(m, l = o(l, g, v, m, n[e + 8], 7, 1770035416), g, v, n[e + 9], 12, -1958414417), l, g, n[e + 10], 17, -42063), m, l, n[e + 11], 22, -1990404162), v = o(v, m = o(m, l = o(l, g, v, m, n[e + 12], 7, 1804603682), g, v, n[e + 13], 12, -40341101), l, g, n[e + 14], 17, -1502002290), m, l, n[e + 15], 22, 1236535329), v = u(v, m = u(m, l = u(l, g, v, m, n[e + 1], 5, -165796510), g, v, n[e + 6], 9, -1069501632), l, g, n[e + 11], 14, 643717713), m, l, n[e], 20, -373897302), v = u(v, m = u(m, l = u(l, g, v, m, n[e + 5], 5, -701558691), g, v, n[e + 10], 9, 38016083), l, g, n[e + 15], 14, -660478335), m, l, n[e + 4], 20, -405537848), v = u(v, m = u(m, l = u(l, g, v, m, n[e + 9], 5, 568446438), g, v, n[e + 14], 9, -1019803690), l, g, n[e + 3], 14, -187363961), m, l, n[e + 8], 20, 1163531501), v = u(v, m = u(m, l = u(l, g, v, m, n[e + 13], 5, -1444681467), g, v, n[e + 2], 9, -51403784), l, g, n[e + 7], 14, 1735328473), m, l, n[e + 12], 20, -1926607734), v = c(v, m = c(m, l = c(l, g, v, m, n[e + 5], 4, -378558), g, v, n[e + 8], 11, -2022574463), l, g, n[e + 11], 16, 1839030562), m, l, n[e + 14], 23, -35309556), v = c(v, m = c(m, l = c(l, g, v, m, n[e + 1], 4, -1530992060), g, v, n[e + 4], 11, 1272893353), l, g, n[e + 7], 16, -155497632), m, l, n[e + 10], 23, -1094730640), v = c(v, m = c(m, l = c(l, g, v, m, n[e + 13], 4, 681279174), g, v, n[e], 11, -358537222), l, g, n[e + 3], 16, -722521979), m, l, n[e + 6], 23, 76029189), v = c(v, m = c(m, l = c(l, g, v, m, n[e + 9], 4, -640364487), g, v, n[e + 12], 11, -421815835), l, g, n[e + 15], 16, 530742520), m, l, n[e + 2], 23, -995338651), v = f(v, m = f(m, l = f(l, g, v, m, n[e], 6, -198630844), g, v, n[e + 7], 10, 1126891415), l, g, n[e + 14], 15, -1416354905), m, l, n[e + 5], 21, -57434055), v = f(v, m = f(m, l = f(l, g, v, m, n[e + 12], 6, 1700485571), g, v, n[e + 3], 10, -1894986606), l, g, n[e + 10], 15, -1051523), m, l, n[e + 1], 21, -2054922799), v = f(v, m = f(m, l = f(l, g, v, m, n[e + 8], 6, 1873313359), g, v, n[e + 15], 10, -30611744), l, g, n[e + 6], 15, -1560198380), m, l, n[e + 13], 21, 1309151649), v = f(v, m = f(m, l = f(l, g, v, m, n[e + 4], 6, -145523070), g, v, n[e + 11], 10, -1120210379), l, g, n[e + 2], 15, 718787259), m, l, n[e + 9], 21, -343485551), l = t(l, i), g = t(g, a), v = t(v, d), m = t(m, h); return [l, g, v, m] } function a(n) { var t, r = "", e = 32 * n.length; for (t = 0; t < e; t += 8)r += String.fromCharCode(n[t >> 5] >>> t % 32 & 255); return r } function d(n) { var t, r = []; for (r[(n.length >> 2) - 1] = void 0, t = 0; t < r.length; t += 1)r[t] = 0; var e = 8 * n.length; for (t = 0; t < e; t += 8)r[t >> 5] |= (255 & n.charCodeAt(t / 8)) << t % 32; return r } function h(n) { return a(i(d(n), 8 * n.length)) } function l(n, t) { var r, e, o = d(n), u = [], c = []; for (u[15] = c[15] = void 0, o.length > 16 && (o = i(o, 8 * n.length)), r = 0; r < 16; r += 1)u[r] = 909522486 ^ o[r], c[r] = 1549556828 ^ o[r]; return e = i(u.concat(d(t)), 512 + 8 * t.length), a(i(c.concat(e), 640)) } function g(n) { var t, r, e = ""; for (r = 0; r < n.length; r += 1)t = n.charCodeAt(r), e += "0123456789abcdef".charAt(t >>> 4 & 15) + "0123456789abcdef".charAt(15 & t); return e } function v(n) { return unescape(encodeURIComponent(n)) } function m(n) { return h(v(n)) } function p(n) { return g(m(n)) } function s(n, t) { return l(v(n), v(t)) } function C(n, t) { return g(s(n, t)) } function A(n, t, r) { return t ? r ? s(t, n) : C(t, n) : r ? m(n) : p(n) } $.md5 = A }(this); +function Env(t, e) { "undefined" != typeof process && JSON.stringify(process.env).indexOf("GITHUB") > -1 && process.exit(0); class s { constructor(t) { this.env = t } send(t, e = "GET") { t = "string" == typeof t ? { url: t } : t; let s = this.get; return "POST" === e && (s = this.post), new Promise((e, i) => { s.call(this, t, (t, s, r) => { t ? i(t) : e(s) }) }) } get(t) { return this.send.call(this.env, t) } post(t) { return this.send.call(this.env, t, "POST") } } return new class { constructor(t, e) { this.name = t, this.http = new s(this), this.data = null, this.dataFile = "box.dat", this.logs = [], this.isMute = !1, this.isNeedRewrite = !1, this.logSeparator = "\n", this.startTime = (new Date).getTime(), Object.assign(this, e), this.log("", `🔔${this.name}, 开始!`) } isNode() { return "undefined" != typeof module && !!module.exports } isQuanX() { return "undefined" != typeof $task } isSurge() { return "undefined" != typeof $httpClient && "undefined" == typeof $loon } isLoon() { return "undefined" != typeof $loon } toObj(t, e = null) { try { return JSON.parse(t) } catch { return e } } toStr(t, e = null) { try { return JSON.stringify(t) } catch { return e } } getjson(t, e) { let s = e; const i = this.getdata(t); if (i) try { s = JSON.parse(this.getdata(t)) } catch { } return s } setjson(t, e) { try { return this.setdata(JSON.stringify(t), e) } catch { return !1 } } getScript(t) { return new Promise(e => { this.get({ url: t }, (t, s, i) => e(i)) }) } runScript(t, e) { return new Promise(s => { let i = this.getdata("@chavy_boxjs_userCfgs.httpapi"); i = i ? i.replace(/\n/g, "").trim() : i; let r = this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout"); r = r ? 1 * r : 20, r = e && e.timeout ? e.timeout : r; const [o, h] = i.split("@"), n = { url: `http://${h}/v1/scripting/evaluate`, body: { script_text: t, mock_type: "cron", timeout: r }, headers: { "X-Key": o, Accept: "*/*" } }; this.post(n, (t, e, i) => s(i)) }).catch(t => this.logErr(t)) } loaddata() { if (!this.isNode()) return {}; { this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path"); const t = this.path.resolve(this.dataFile), e = this.path.resolve(process.cwd(), this.dataFile), s = this.fs.existsSync(t), i = !s && this.fs.existsSync(e); if (!s && !i) return {}; { const i = s ? t : e; try { return JSON.parse(this.fs.readFileSync(i)) } catch (t) { return {} } } } } writedata() { if (this.isNode()) { this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path"); const t = this.path.resolve(this.dataFile), e = this.path.resolve(process.cwd(), this.dataFile), s = this.fs.existsSync(t), i = !s && this.fs.existsSync(e), r = JSON.stringify(this.data); s ? this.fs.writeFileSync(t, r) : i ? this.fs.writeFileSync(e, r) : this.fs.writeFileSync(t, r) } } lodash_get(t, e, s) { const i = e.replace(/\[(\d+)\]/g, ".$1").split("."); let r = t; for (const t of i) if (r = Object(r)[t], void 0 === r) return s; return r } lodash_set(t, e, s) { return Object(t) !== t ? t : (Array.isArray(e) || (e = e.toString().match(/[^.[\]]+/g) || []), e.slice(0, -1).reduce((t, s, i) => Object(t[s]) === t[s] ? t[s] : t[s] = Math.abs(e[i + 1]) >> 0 == +e[i + 1] ? [] : {}, t)[e[e.length - 1]] = s, t) } getdata(t) { let e = this.getval(t); if (/^@/.test(t)) { const [, s, i] = /^@(.*?)\.(.*?)$/.exec(t), r = s ? this.getval(s) : ""; if (r) try { const t = JSON.parse(r); e = t ? this.lodash_get(t, i, "") : e } catch (t) { e = "" } } return e } setdata(t, e) { let s = !1; if (/^@/.test(e)) { const [, i, r] = /^@(.*?)\.(.*?)$/.exec(e), o = this.getval(i), h = i ? "null" === o ? null : o || "{}" : "{}"; try { const e = JSON.parse(h); this.lodash_set(e, r, t), s = this.setval(JSON.stringify(e), i) } catch (e) { const o = {}; this.lodash_set(o, r, t), s = this.setval(JSON.stringify(o), i) } } else s = this.setval(t, e); return s } getval(t) { return this.isSurge() || this.isLoon() ? $persistentStore.read(t) : this.isQuanX() ? $prefs.valueForKey(t) : this.isNode() ? (this.data = this.loaddata(), this.data[t]) : this.data && this.data[t] || null } setval(t, e) { return this.isSurge() || this.isLoon() ? $persistentStore.write(t, e) : this.isQuanX() ? $prefs.setValueForKey(t, e) : this.isNode() ? (this.data = this.loaddata(), this.data[e] = t, this.writedata(), !0) : this.data && this.data[e] || null } initGotEnv(t) { this.got = this.got ? this.got : require("got"), this.cktough = this.cktough ? this.cktough : require("tough-cookie"), this.ckjar = this.ckjar ? this.ckjar : new this.cktough.CookieJar, t && (t.headers = t.headers ? t.headers : {}, void 0 === t.headers.Cookie && void 0 === t.cookieJar && (t.cookieJar = this.ckjar)) } get(t, e = (() => { })) { t.headers && (delete t.headers["Content-Type"], delete t.headers["Content-Length"]), this.isSurge() || this.isLoon() ? (this.isSurge() && this.isNeedRewrite && (t.headers = t.headers || {}, Object.assign(t.headers, { "X-Surge-Skip-Scripting": !1 })), $httpClient.get(t, (t, s, i) => { !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i) })) : this.isQuanX() ? (this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, { hints: !1 })), $task.fetch(t).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => e(t))) : this.isNode() && (this.initGotEnv(t), this.got(t).on("redirect", (t, e) => { try { if (t.headers["set-cookie"]) { const s = t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString(); s && this.ckjar.setCookieSync(s, null), e.cookieJar = this.ckjar } } catch (t) { this.logErr(t) } }).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => { const { message: s, response: i } = t; e(s, i, i && i.body) })) } post(t, e = (() => { })) { if (t.body && t.headers && !t.headers["Content-Type"] && (t.headers["Content-Type"] = "application/x-www-form-urlencoded"), t.headers && delete t.headers["Content-Length"], this.isSurge() || this.isLoon()) this.isSurge() && this.isNeedRewrite && (t.headers = t.headers || {}, Object.assign(t.headers, { "X-Surge-Skip-Scripting": !1 })), $httpClient.post(t, (t, s, i) => { !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i) }); else if (this.isQuanX()) t.method = "POST", this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, { hints: !1 })), $task.fetch(t).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => e(t)); else if (this.isNode()) { this.initGotEnv(t); const { url: s, ...i } = t; this.got.post(s, i).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => { const { message: s, response: i } = t; e(s, i, i && i.body) }) } } time(t, e = null) { const s = e ? new Date(e) : new Date; let i = { "M+": s.getMonth() + 1, "d+": s.getDate(), "H+": s.getHours(), "m+": s.getMinutes(), "s+": s.getSeconds(), "q+": Math.floor((s.getMonth() + 3) / 3), S: s.getMilliseconds() }; /(y+)/.test(t) && (t = t.replace(RegExp.$1, (s.getFullYear() + "").substr(4 - RegExp.$1.length))); for (let e in i) new RegExp("(" + e + ")").test(t) && (t = t.replace(RegExp.$1, 1 == RegExp.$1.length ? i[e] : ("00" + i[e]).substr(("" + i[e]).length))); return t } msg(e = t, s = "", i = "", r) { const o = t => { if (!t) return t; if ("string" == typeof t) return this.isLoon() ? t : this.isQuanX() ? { "open-url": t } : this.isSurge() ? { url: t } : void 0; if ("object" == typeof t) { if (this.isLoon()) { let e = t.openUrl || t.url || t["open-url"], s = t.mediaUrl || t["media-url"]; return { openUrl: e, mediaUrl: s } } if (this.isQuanX()) { let e = t["open-url"] || t.url || t.openUrl, s = t["media-url"] || t.mediaUrl; return { "open-url": e, "media-url": s } } if (this.isSurge()) { let e = t.url || t.openUrl || t["open-url"]; return { url: e } } } }; if (this.isMute || (this.isSurge() || this.isLoon() ? $notification.post(e, s, i, o(r)) : this.isQuanX() && $notify(e, s, i, o(r))), !this.isMuteLog) { let t = ["", "==============📣系统通知📣=============="]; t.push(e), s && t.push(s), i && t.push(i), console.log(t.join("\n")), this.logs = this.logs.concat(t) } } log(...t) { t.length > 0 && (this.logs = [...this.logs, ...t]), console.log(t.join(this.logSeparator)) } logErr(t, e) { const s = !this.isSurge() && !this.isQuanX() && !this.isLoon(); s ? this.log("", `❗️${this.name}, 错误!`, t.stack) : this.log("", `❗️${this.name}, 错误!`, t) } wait(t) { return new Promise(e => setTimeout(e, t)) } done(t = {}) { const e = (new Date).getTime(), s = (e - this.startTime) / 1e3; this.log("", `🔔${this.name}, 结束! 🕛 ${s} 秒`), this.log(), (this.isSurge() || this.isQuanX() || this.isLoon()) && $done(t) } }(t, e) } diff --git a/activity/jd_opencard2.js b/activity/jd_opencard2.js new file mode 100644 index 0000000..1f7adb5 --- /dev/null +++ b/activity/jd_opencard2.js @@ -0,0 +1,588 @@ +/* +大牌强联合 好物提前购 + +https://lzdz1-isv.isvjcloud.com/dingzhi/dz/openCard/activity?activityId=dz2021101420000sjleowq&shareUuid=52e625399b1b40f9abaecccdbdc58e75 + +cron 27 4,18 * * * https://raw.githubusercontent.com/KingRan/JDJB/main/jd_opencard2.js +*/ +const $ = new Env("大牌强联合 好物提前购"); +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const notify = $.isNode() ? require('./sendNotify') : ''; +let cookiesArr = [], cookie = '', message = ''; +let ownCode = null; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => { }; +} else { + let cookiesData = $.getdata('CookiesJD') || "[]"; + cookiesData = JSON.parse(cookiesData); + cookiesArr = cookiesData.map(item => item.cookie); + cookiesArr.reverse(); + cookiesArr.push(...[$.getdata('CookieJD2'), $.getdata('CookieJD')]); + cookiesArr.reverse(); + cookiesArr = cookiesArr.filter(item => !!item); +} +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', { "open-url": "https://bean.m.jd.com/bean/signIndex.action" }); + return; + } + + authorCodeList = await getAuthorCodeList('https://gitee.com/fatelight/dongge/raw/master/dongge/lzdz1_dapai.json11') + if(authorCodeList === '404: Not Found'){ + authorCodeList = [ + '52e625399b1b40f9abaecccdbdc58e75', + ] + } + + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i] + originCookie = cookiesArr[i] + newCookie = '' + $.UserName = decodeURIComponent(cookie.match(/pt_pin=(.+?);/) && cookie.match(/pt_pin=(.+?);/)[1]) + $.index = i + 1; + $.isLogin = true; + $.nickName = ''; + await checkCookie(); + console.log(`\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + if (!$.isLogin) { + $.msg($.name, `【提示】cookie已失效`, `京东账号${$.index} ${$.nickName || $.UserName}\n请重新登录获取\nhttps://bean.m.jd.com/bean/signIndex.action`, { "open-url": "https://bean.m.jd.com/bean/signIndex.action" }); + if ($.isNode()) { + await notify.sendNotify(`${$.name}cookie已失效 - ${$.UserName}`, `京东账号${$.index} ${$.UserName}\n请重新登录获取cookie`); + } + continue + } + $.bean = 0; + $.ADID = getUUID('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', 1); + $.UUID = getUUID('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'); + // $.authorCode = authorCodeList[random(0, authorCodeList.length)] + $.authorCode = ownCode ? ownCode : authorCodeList[random(0, authorCodeList.length)] + $.authorNum = `${random(1000000, 9999999)}` + $.randomCode = random(1000000, 9999999) + $.activityId = 'dz2021101420000sjleowq' + $.activityShopId = '1000221763' + $.activityUrl = `https://lzdz1-isv.isvjd.com/dingzhi/dz/openCard/activity/${$.authorNum}?activityId=${$.activityId}&shareUuid=${encodeURIComponent($.authorCode)}&adsource=null&shareuserid4minipg=null&shopid=${$.activityShopId}&lng=00.000000&lat=00.000000&sid=&un_area=` + await marry(); + await $.wait(3000) + if ($.bean > 0) { + message += `\n【京东账号${$.index}】${$.nickName || $.UserName} \n └ 获得 ${$.bean} 京豆。` + } + } + } + if (message !== '') { + if ($.isNode()) { + await notify.sendNotify($.name, message, '', `\n`); + } else { + $.msg($.name, '有点儿收获', message); + } + } +})() + .catch((e) => { + $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') + }) + .finally(() => { + $.done(); + }) + + +async function marry() { + $.log('那就开始吧。') + $.token = null; + $.secretPin = null; + $.openCardActivityId = null + await getFirstLZCK() + await getToken(); + if ($.token) { + await getMyPing(); + if ($.secretPin) { + console.log("去助力 -> "+$.authorCode) + await task('common/accessLogWithAD', `venderId=${$.activityShopId}&code=99&pin=${encodeURIComponent($.secretPin)}&activityId=${$.activityId}&pageUrl=${$.activityUrl}&subType=app&adSource=null`, 1); + await task('wxActionCommon/getUserInfo', `pin=${encodeURIComponent($.secretPin)}`, 1) + if ($.index === 1) { + await task('dz/openCard/activityContent', `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}&pinImg=&nick=${encodeURIComponent($.pin)}&cjyxPin=&cjhyPin=&shareUuid=${encodeURIComponent($.authorCode)}`, 0, 1) + } else { + await task('dz/openCard/activityContent', `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}&pinImg=&nick=${encodeURIComponent($.pin)}&cjyxPin=&cjhyPin=&shareUuid=${encodeURIComponent($.authorCode)}`) + } + await task('dz/openCard/checkOpenCard', `activityId=${$.activityId}&actorUuid=${$.actorUuid}&shareUuid=${$.authorCode}&pin=${encodeURIComponent($.secretPin)}`) + $.log("->关注店铺") + if ($.shopTask) { + if (!$.shopTask.allStatus) { + await task('dz/openCard/followShop', `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}&actorUuid=${encodeURIComponent($.actorUuid)}&taskType=23&taskValue=1000002520`) + } else { + $.log(" >>>已经关注过了\n") + await $.wait(2000) + return + } + } else { + $.log("没有获取到对应的任务。\n") + } + $.log("->->->> 加入店铺会员") + if ($.openCardStatus) { + for (let i = 0; i < ($.openCardStatus.cardList1.length + $.openCardStatus.cardList2.length); i++) { + $.log("模拟上报访问记录") + await task('crm/pageVisit/insertCrmPageVisit', `venderId=1000004065&pageId=dz20211013skcnurdk11jhdue84752hp&elementId=${encodeURIComponent(`去开卡${i}`)}&pin=${encodeURIComponent($.secretPin)}`, 1) + await $.wait(2000) + } + t1TaskList = [] + $.openCardStatus.cardList1.filter((x) => { if (x.status === 0) { t1TaskList.push(x) } }) + t2TaskList = [] + $.openCardStatus.cardList2.filter((x) => { if (x.status === 0) { t2TaskList.push(x) } }) + if (t1TaskList.length < 1) { + console.log(" >>>已经完成入会任务") + + } else { + for (const vo of t1TaskList) { + $.log(` >>>去加入${vo.name}`) + await getShopOpenCardInfo({ "venderId": `${vo.value}`, "channel": "401" }, vo.value) + await bindWithVender({ "venderId": `${vo.value}`, "bindByVerifyCodeFlag": 1, "registerExtend": {}, "writeChildFlag": 0, "activityId": $.openCardActivityId, "channel": 401 }, vo.value) + await $.wait(2000) + } + for (const vo of t2TaskList) { + $.log(` >>>${vo.name}`) + await getShopOpenCardInfo({ "venderId": `${vo.value}`, "channel": "401" }) + await bindWithVender({ "venderId": `${vo.value}`, "bindByVerifyCodeFlag": 1, "registerExtend": {}, "writeChildFlag": 0, "activityId": $.openCardActivityId, "channel": 401 }, vo.value) + await $.wait(2000) + } + } + + await task("taskact/openCardcommon/drawContent", `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}`) + await $.wait(2000) + await task('dz/openCard/checkOpenCard', `activityId=${$.activityId}&actorUuid=${$.actorUuid}&shareUuid=${$.authorCode}&pin=${encodeURIComponent($.secretPin)}`) + await $.wait(2000) + await task("dz/openCard/startDraw", `activityId=${$.activityId}&actorUuid=${$.actorUuid}&type=1&pin=${encodeURIComponent($.secretPin)}`) + await $.wait(2000) + await task("dz/openCard/startDraw", `activityId=${$.activityId}&actorUuid=${$.actorUuid}&type=2&pin=${encodeURIComponent($.secretPin)}`) + + } else { + $.log("没有获取到对应的任务。\n") + } + $.log("->->->> 加购物车") + await task("dz/openCard/saveTask", `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}&actorUuid=${$.actorUuid}&type=2&taskValue=100025232454`) + } + } +} + +function task(function_id, body, isCommon = 0, own = 0) { + return new Promise(resolve => { + $.post(taskUrl(function_id, body, isCommon), async (err, resp, data) => { + try { + if (err) { + $.log(err) + } else { + + if (data) { + data = JSON.parse(data); + if (data.result) { + switch (function_id) { + case 'wxActionCommon/getUserInfo': + break; + case 'dz/openCard/activityContent': + if (!data.data.hasEnd) { + $.log(`开启【${data.data.activityName}】活动`) + $.log("-------------------") + if ($.index === 1) { + ownCode = data.data.actorUuid + console.log(ownCode) + } + $.actorUuid = data.data.actorUuid; + $.skuTask = data.data.addSku; + $.shopTask = data.data.followShop; + } else { + $.log("活动已经结束"); + } + break; + case 'dz/openCard/checkOpenCard': + $.openCardStatus = data.data; + break; + case 'dz/openCard/saveTask': + console.log(data.data.addBeanNum) + break; + case 'dz/openCard/saveTask': + if (data.data) { + if (data.data.addBeanNum) { + $.bean += data.data.addBeanNum; + $.log(`==>获得【${data.data.addBeanNum}】京豆\n`) + } + } + break; + case 'dz/openCard/startDraw': + if (data.data.drawOk) { + switch (data.data.drawInfo.type) { + case 6: + $.bean += data.data.drawInfo.beanNum; + $.log(`==>获得【${data.data.drawInfo.beanNum}】京豆\n`) + break; + default: + if ($.isNode()) { + await notify.sendNotify("中奖了", `中奖信息:${JSON.stringify(data.data.drawInfo)}\n活动链接:${$.activityUrl}`) + } else { + $.msg("中奖了", `获得${data.data.drawInfo.name}`, `中奖信息:${JSON.stringify(data.data.drawInfo)}\n活动链接:${$.activityUrl}`) + } + break; + } + } + break; + case 'crm/pageVisit/insertCrmPageVisit': + $.log("==> 上报成功") + + case 'dz/openCard/followShop': + if (data.data) { + if (data.data.addBeanNum) { + $.bean += data.data.addBeanNum; + $.log(`==>获得【${data.data.addBeanNum}】京豆\n`) + } + } + break; + + break; + default: + $.log(JSON.stringify(data)) + break; + } + } else { + $.log(JSON.stringify(data)) + } + } else { + // $.log("京东没有返回数据") + } + } + } catch (error) { + $.log(error) + } finally { + resolve(); + } + }) + }) +} +function getShopOpenCardInfo(body, venderId) { + let opt = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body=${encodeURIComponent(JSON.stringify(body))}&client=H5&clientVersion=9.2.0&uuid=88888`, + headers: { + Host: 'api.m.jd.com', + Accept: '*/*', + Connection: 'keep-alive', + Cookie: cookie, + 'User-Agent': `jdapp;iPhone;9.5.4;13.6;${$.UUID};network/wifi;ADID/${$.ADID};model/iPhone10,3;addressid/0;appBuild/167668;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1`, + 'Accept-Language': 'zh-cn', + Referer: `https://shopmember.m.jd.com/shopcard/?venderId=${venderId}}&channel=801&returnUrl=${encodeURIComponent($.activityUrl)}`, + 'Accept-Encoding': 'gzip, deflate, br' + } + } + return new Promise(resolve => { + $.get(opt, (err, resp, data) => { + try { + if (err) { + console.log(err) + } else { + res = JSON.parse(data) + if (res.success) { + if (res.result.interestsRuleList) { + $.openCardActivityId = res.result.interestsRuleList[0].interestsInfo.activityId; + } + } + } + } catch (error) { + console.log(error) + } finally { + resolve(); + } + }) + + }) +} +function bindWithVender(body, venderId) { + let opt = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body=${encodeURIComponent(JSON.stringify(body))}&client=H5&clientVersion=9.2.0&uuid=88888`, + headers: { + Host: 'api.m.jd.com', + Accept: '*/*', + Connection: 'keep-alive', + Cookie: cookie, + 'User-Agent': `jdapp;iPhone;9.5.4;13.6;${$.UUID};network/wifi;ADID/${$.ADID};model/iPhone10,3;addressid/0;appBuild/167668;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1`, + 'Accept-Language': 'zh-cn', + Referer: `https://shopmember.m.jd.com/shopcard/?venderId=${venderId}}&channel=401&returnUrl=${encodeURIComponent($.activityUrl)}`, + 'Accept-Encoding': 'gzip, deflate, br' + } + } + return new Promise(resolve => { + $.get(opt, (err, resp, data) => { + try { + if (err) { + console.log(err) + } else { + res = JSON.parse(data) + if (res.success) { + if (res.result.giftInfo && res.result.giftInfo.giftList) { + for (const vo of res.result.giftInfo.giftList) { + if (vo.prizeType === 4) { + $.log(`==>获得【${vo.quantity}】京豆`) + $.bean += vo.quantity + } + } + } + } + } + } catch (error) { + console.log(error) + } finally { + resolve(); + } + }) + + }) +} +function taskUrl(function_id, body, isCommon) { + return { + url: isCommon ? `https://lzdz1-isv.isvjd.com/${function_id}` : `https://lzdz1-isv.isvjd.com/dingzhi/${function_id}`, + headers: { + Host: 'lzdz1-isv.isvjd.com', + Accept: 'application/json', + 'X-Requested-With': 'XMLHttpRequest', + 'Accept-Language': 'zh-cn', + 'Accept-Encoding': 'gzip, deflate, br', + 'Content-Type': 'application/x-www-form-urlencoded', + Origin: 'https://lzdz1-isv.isvjd.com', + 'User-Agent': `jdapp;iPhone;9.5.4;13.6;${$.UUID};network/wifi;ADID/${$.ADID};model/iPhone10,3;addressid/0;appBuild/167668;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1`, + Connection: 'keep-alive', + Referer: $.activityUrl, + Cookie: cookie + }, + body: body + + } +} +function getAuthorCodeList(url) { + return new Promise(resolve => { + const options = { + url: `${url}?${new Date()}`, "timeout": 10000, headers: { + "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1 Edg/87.0.4280.88" + } + }; + $.get(options, async (err, resp, data) => { + try { + if (err) { + $.log(err) + } else { + if (data) data = JSON.parse(data) + } + } catch (e) { + $.logErr(e, resp) + data = null; + } finally { + resolve(data); + } + }) + }) +} +function getMyPing() { + let opt = { + url: `https://lzdz1-isv.isvjd.com/customer/getMyPing`, + headers: { + Host: 'lzdz1-isv.isvjd.com', + Accept: 'application/json', + 'X-Requested-With': 'XMLHttpRequest', + 'Accept-Language': 'zh-cn', + 'Accept-Encoding': 'gzip, deflate, br', + 'Content-Type': 'application/x-www-form-urlencoded', + Origin: 'https://lzdz1-isv.isvjd.com', + 'User-Agent': `jdapp;iPhone;9.5.4;13.6;${$.UUID};network/wifi;ADID/${$.ADID};model/iPhone10,3;addressid/0;appBuild/167668;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1`, + Connection: 'keep-alive', + Referer: $.activityUrl, + Cookie: cookie, + }, + body: `userId=${$.activityShopId}&token=${$.token}&fromType=APP&riskType=1` + } + return new Promise(resolve => { + $.post(opt, (err, resp, data) => { + try { + if (err) { + $.log(err) + } else { + if (resp['headers']['set-cookie']) { + cookie = `${originCookie}` + if ($.isNode()) { + for (let sk of resp['headers']['set-cookie']) { + cookie = `${cookie}${sk.split(";")[0]};` + } + } else { + for (let ck of resp['headers']['Set-Cookie'].split(',')) { + cookie = `${cookie}${ck.split(";")[0]};` + } + } + } + if (resp['headers']['Set-Cookie']) { + cookie = `${originCookie}` + if ($.isNode()) { + for (let sk of resp['headers']['set-cookie']) { + cookie = `${cookie}${sk.split(";")[0]};` + } + } else { + for (let ck of resp['headers']['Set-Cookie'].split(',')) { + cookie = `${cookie}${ck.split(";")[0]};` + } + } + } + if (data) { + data = JSON.parse(data) + if (data.result) { + $.log(`你好:${data.data.nickname}`) + $.pin = data.data.nickname; + $.secretPin = data.data.secretPin; + cookie = `${cookie};AUTH_C_USER=${data.data.secretPin}` + } else { + $.log(data.errorMessage) + } + } else { + // $.log("京东返回了空数据") + } + } + } catch (error) { + $.log(error) + } finally { + resolve(); + } + + }) + }) +} +function getFirstLZCK() { + return new Promise(resolve => { + $.get({ url: $.activityUrl }, (err, resp, data) => { + try { + if (err) { + console.log(err) + } else { + if (resp['headers']['set-cookie']) { + cookie = `${originCookie}` + if ($.isNode()) { + for (let sk of resp['headers']['set-cookie']) { + cookie = `${cookie}${sk.split(";")[0]};` + } + } else { + for (let ck of resp['headers']['Set-Cookie'].split(',')) { + cookie = `${cookie}${ck.split(";")[0]};` + } + } + } + if (resp['headers']['Set-Cookie']) { + cookie = `${originCookie}` + if ($.isNode()) { + for (let sk of resp['headers']['set-cookie']) { + cookie = `${cookie}${sk.split(";")[0]};` + } + } else { + for (let ck of resp['headers']['Set-Cookie'].split(',')) { + cookie = `${cookie}${ck.split(";")[0]};` + } + } + } + } + } catch (error) { + console.log(error) + } finally { + resolve(); + } + }) + }) +} +function getToken() { + let opt = { + url: `https://api.m.jd.com/client.action?functionId=isvObfuscator`, + headers: { + Host: 'api.m.jd.com', + 'Content-Type': 'application/x-www-form-urlencoded', + Accept: '*/*', + Connection: 'keep-alive', + Cookie: cookie, + 'User-Agent': 'JD4iPhone/167650 (iPhone; iOS 13.7; Scale/3.00)', + 'Accept-Language': 'zh-Hans-CN;q=1', + 'Accept-Encoding': 'gzip, deflate, br', + }, + body: `body=%7B%22url%22%3A%20%22https%3A//lzkj-isv.isvjcloud.com%22%2C%20%22id%22%3A%20%22%22%7D&uuid=hjudwgohxzVu96krv&client=apple&clientVersion=9.4.0&st=1620476162000&sv=111&sign=f9d1b7e3b943b6a136d54fe4f892af05` + } + return new Promise(resolve => { + $.post(opt, (err, resp, data) => { + try { + if (err) { + $.log(err) + } else { + if (data) { + data = JSON.parse(data); + if (data.code === "0") { + $.token = data.token + } + } else { + $.log("京东返回了空数据") + } + } + } catch (error) { + $.log(error) + } finally { + resolve(); + } + }) + }) +} +function random(min, max) { + + return Math.floor(Math.random() * (max - min)) + min; + +} +function getUUID(format = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', UpperCase = 0) { + return format.replace(/[xy]/g, function (c) { + var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8); + if (UpperCase) { + uuid = v.toString(36).toUpperCase(); + } else { + uuid = v.toString(36) + } + return uuid; + }); +} +function checkCookie() { + const options = { + url: "https://me-api.jd.com/user_new/info/GetJDUserInfoUnion", + headers: { + "Host": "me-api.jd.com", + "Accept": "*/*", + "Connection": "keep-alive", + "Cookie": cookie, + "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.2 Mobile/15E148 Safari/604.1", + "Accept-Language": "zh-cn", + "Referer": "https://home.m.jd.com/myJd/newhome.action?sceneval=2&ufc=&", + "Accept-Encoding": "gzip, deflate, br", + } + }; + return new Promise(resolve => { + $.get(options, (err, resp, data) => { + try { + if (err) { + $.logErr(err) + } else { + if (data) { + data = JSON.parse(data); + if (data.retcode === "1001") { + $.isLogin = false; //cookie过期 + return; + } + if (data.retcode === "0" && data.data.hasOwnProperty("userInfo")) { + $.nickName = data.data.userInfo.baseInfo.nickname; + } + } else { + $.log('京东返回了空数据'); + } + } + } catch (e) { + $.logErr(e) + } finally { + resolve(); + } + }) + }) +} +// prettier-ignore +!function (n) { "use strict"; function t(n, t) { var r = (65535 & n) + (65535 & t); return (n >> 16) + (t >> 16) + (r >> 16) << 16 | 65535 & r } function r(n, t) { return n << t | n >>> 32 - t } function e(n, e, o, u, c, f) { return t(r(t(t(e, n), t(u, f)), c), o) } function o(n, t, r, o, u, c, f) { return e(t & r | ~t & o, n, t, u, c, f) } function u(n, t, r, o, u, c, f) { return e(t & o | r & ~o, n, t, u, c, f) } function c(n, t, r, o, u, c, f) { return e(t ^ r ^ o, n, t, u, c, f) } function f(n, t, r, o, u, c, f) { return e(r ^ (t | ~o), n, t, u, c, f) } function i(n, r) { n[r >> 5] |= 128 << r % 32, n[14 + (r + 64 >>> 9 << 4)] = r; var e, i, a, d, h, l = 1732584193, g = -271733879, v = -1732584194, m = 271733878; for (e = 0; e < n.length; e += 16)i = l, a = g, d = v, h = m, g = f(g = f(g = f(g = f(g = c(g = c(g = c(g = c(g = u(g = u(g = u(g = u(g = o(g = o(g = o(g = o(g, v = o(v, m = o(m, l = o(l, g, v, m, n[e], 7, -680876936), g, v, n[e + 1], 12, -389564586), l, g, n[e + 2], 17, 606105819), m, l, n[e + 3], 22, -1044525330), v = o(v, m = o(m, l = o(l, g, v, m, n[e + 4], 7, -176418897), g, v, n[e + 5], 12, 1200080426), l, g, n[e + 6], 17, -1473231341), m, l, n[e + 7], 22, -45705983), v = o(v, m = o(m, l = o(l, g, v, m, n[e + 8], 7, 1770035416), g, v, n[e + 9], 12, -1958414417), l, g, n[e + 10], 17, -42063), m, l, n[e + 11], 22, -1990404162), v = o(v, m = o(m, l = o(l, g, v, m, n[e + 12], 7, 1804603682), g, v, n[e + 13], 12, -40341101), l, g, n[e + 14], 17, -1502002290), m, l, n[e + 15], 22, 1236535329), v = u(v, m = u(m, l = u(l, g, v, m, n[e + 1], 5, -165796510), g, v, n[e + 6], 9, -1069501632), l, g, n[e + 11], 14, 643717713), m, l, n[e], 20, -373897302), v = u(v, m = u(m, l = u(l, g, v, m, n[e + 5], 5, -701558691), g, v, n[e + 10], 9, 38016083), l, g, n[e + 15], 14, -660478335), m, l, n[e + 4], 20, -405537848), v = u(v, m = u(m, l = u(l, g, v, m, n[e + 9], 5, 568446438), g, v, n[e + 14], 9, -1019803690), l, g, n[e + 3], 14, -187363961), m, l, n[e + 8], 20, 1163531501), v = u(v, m = u(m, l = u(l, g, v, m, n[e + 13], 5, -1444681467), g, v, n[e + 2], 9, -51403784), l, g, n[e + 7], 14, 1735328473), m, l, n[e + 12], 20, -1926607734), v = c(v, m = c(m, l = c(l, g, v, m, n[e + 5], 4, -378558), g, v, n[e + 8], 11, -2022574463), l, g, n[e + 11], 16, 1839030562), m, l, n[e + 14], 23, -35309556), v = c(v, m = c(m, l = c(l, g, v, m, n[e + 1], 4, -1530992060), g, v, n[e + 4], 11, 1272893353), l, g, n[e + 7], 16, -155497632), m, l, n[e + 10], 23, -1094730640), v = c(v, m = c(m, l = c(l, g, v, m, n[e + 13], 4, 681279174), g, v, n[e], 11, -358537222), l, g, n[e + 3], 16, -722521979), m, l, n[e + 6], 23, 76029189), v = c(v, m = c(m, l = c(l, g, v, m, n[e + 9], 4, -640364487), g, v, n[e + 12], 11, -421815835), l, g, n[e + 15], 16, 530742520), m, l, n[e + 2], 23, -995338651), v = f(v, m = f(m, l = f(l, g, v, m, n[e], 6, -198630844), g, v, n[e + 7], 10, 1126891415), l, g, n[e + 14], 15, -1416354905), m, l, n[e + 5], 21, -57434055), v = f(v, m = f(m, l = f(l, g, v, m, n[e + 12], 6, 1700485571), g, v, n[e + 3], 10, -1894986606), l, g, n[e + 10], 15, -1051523), m, l, n[e + 1], 21, -2054922799), v = f(v, m = f(m, l = f(l, g, v, m, n[e + 8], 6, 1873313359), g, v, n[e + 15], 10, -30611744), l, g, n[e + 6], 15, -1560198380), m, l, n[e + 13], 21, 1309151649), v = f(v, m = f(m, l = f(l, g, v, m, n[e + 4], 6, -145523070), g, v, n[e + 11], 10, -1120210379), l, g, n[e + 2], 15, 718787259), m, l, n[e + 9], 21, -343485551), l = t(l, i), g = t(g, a), v = t(v, d), m = t(m, h); return [l, g, v, m] } function a(n) { var t, r = "", e = 32 * n.length; for (t = 0; t < e; t += 8)r += String.fromCharCode(n[t >> 5] >>> t % 32 & 255); return r } function d(n) { var t, r = []; for (r[(n.length >> 2) - 1] = void 0, t = 0; t < r.length; t += 1)r[t] = 0; var e = 8 * n.length; for (t = 0; t < e; t += 8)r[t >> 5] |= (255 & n.charCodeAt(t / 8)) << t % 32; return r } function h(n) { return a(i(d(n), 8 * n.length)) } function l(n, t) { var r, e, o = d(n), u = [], c = []; for (u[15] = c[15] = void 0, o.length > 16 && (o = i(o, 8 * n.length)), r = 0; r < 16; r += 1)u[r] = 909522486 ^ o[r], c[r] = 1549556828 ^ o[r]; return e = i(u.concat(d(t)), 512 + 8 * t.length), a(i(c.concat(e), 640)) } function g(n) { var t, r, e = ""; for (r = 0; r < n.length; r += 1)t = n.charCodeAt(r), e += "0123456789abcdef".charAt(t >>> 4 & 15) + "0123456789abcdef".charAt(15 & t); return e } function v(n) { return unescape(encodeURIComponent(n)) } function m(n) { return h(v(n)) } function p(n) { return g(m(n)) } function s(n, t) { return l(v(n), v(t)) } function C(n, t) { return g(s(n, t)) } function A(n, t, r) { return t ? r ? s(t, n) : C(t, n) : r ? m(n) : p(n) } $.md5 = A }(this); +function Env(t, e) { "undefined" != typeof process && JSON.stringify(process.env).indexOf("GITHUB") > -1 && process.exit(0); class s { constructor(t) { this.env = t } send(t, e = "GET") { t = "string" == typeof t ? { url: t } : t; let s = this.get; return "POST" === e && (s = this.post), new Promise((e, i) => { s.call(this, t, (t, s, r) => { t ? i(t) : e(s) }) }) } get(t) { return this.send.call(this.env, t) } post(t) { return this.send.call(this.env, t, "POST") } } return new class { constructor(t, e) { this.name = t, this.http = new s(this), this.data = null, this.dataFile = "box.dat", this.logs = [], this.isMute = !1, this.isNeedRewrite = !1, this.logSeparator = "\n", this.startTime = (new Date).getTime(), Object.assign(this, e), this.log("", `🔔${this.name}, 开始!`) } isNode() { return "undefined" != typeof module && !!module.exports } isQuanX() { return "undefined" != typeof $task } isSurge() { return "undefined" != typeof $httpClient && "undefined" == typeof $loon } isLoon() { return "undefined" != typeof $loon } toObj(t, e = null) { try { return JSON.parse(t) } catch { return e } } toStr(t, e = null) { try { return JSON.stringify(t) } catch { return e } } getjson(t, e) { let s = e; const i = this.getdata(t); if (i) try { s = JSON.parse(this.getdata(t)) } catch { } return s } setjson(t, e) { try { return this.setdata(JSON.stringify(t), e) } catch { return !1 } } getScript(t) { return new Promise(e => { this.get({ url: t }, (t, s, i) => e(i)) }) } runScript(t, e) { return new Promise(s => { let i = this.getdata("@chavy_boxjs_userCfgs.httpapi"); i = i ? i.replace(/\n/g, "").trim() : i; let r = this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout"); r = r ? 1 * r : 20, r = e && e.timeout ? e.timeout : r; const [o, h] = i.split("@"), n = { url: `http://${h}/v1/scripting/evaluate`, body: { script_text: t, mock_type: "cron", timeout: r }, headers: { "X-Key": o, Accept: "*/*" } }; this.post(n, (t, e, i) => s(i)) }).catch(t => this.logErr(t)) } loaddata() { if (!this.isNode()) return {}; { this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path"); const t = this.path.resolve(this.dataFile), e = this.path.resolve(process.cwd(), this.dataFile), s = this.fs.existsSync(t), i = !s && this.fs.existsSync(e); if (!s && !i) return {}; { const i = s ? t : e; try { return JSON.parse(this.fs.readFileSync(i)) } catch (t) { return {} } } } } writedata() { if (this.isNode()) { this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path"); const t = this.path.resolve(this.dataFile), e = this.path.resolve(process.cwd(), this.dataFile), s = this.fs.existsSync(t), i = !s && this.fs.existsSync(e), r = JSON.stringify(this.data); s ? this.fs.writeFileSync(t, r) : i ? this.fs.writeFileSync(e, r) : this.fs.writeFileSync(t, r) } } lodash_get(t, e, s) { const i = e.replace(/\[(\d+)\]/g, ".$1").split("."); let r = t; for (const t of i) if (r = Object(r)[t], void 0 === r) return s; return r } lodash_set(t, e, s) { return Object(t) !== t ? t : (Array.isArray(e) || (e = e.toString().match(/[^.[\]]+/g) || []), e.slice(0, -1).reduce((t, s, i) => Object(t[s]) === t[s] ? t[s] : t[s] = Math.abs(e[i + 1]) >> 0 == +e[i + 1] ? [] : {}, t)[e[e.length - 1]] = s, t) } getdata(t) { let e = this.getval(t); if (/^@/.test(t)) { const [, s, i] = /^@(.*?)\.(.*?)$/.exec(t), r = s ? this.getval(s) : ""; if (r) try { const t = JSON.parse(r); e = t ? this.lodash_get(t, i, "") : e } catch (t) { e = "" } } return e } setdata(t, e) { let s = !1; if (/^@/.test(e)) { const [, i, r] = /^@(.*?)\.(.*?)$/.exec(e), o = this.getval(i), h = i ? "null" === o ? null : o || "{}" : "{}"; try { const e = JSON.parse(h); this.lodash_set(e, r, t), s = this.setval(JSON.stringify(e), i) } catch (e) { const o = {}; this.lodash_set(o, r, t), s = this.setval(JSON.stringify(o), i) } } else s = this.setval(t, e); return s } getval(t) { return this.isSurge() || this.isLoon() ? $persistentStore.read(t) : this.isQuanX() ? $prefs.valueForKey(t) : this.isNode() ? (this.data = this.loaddata(), this.data[t]) : this.data && this.data[t] || null } setval(t, e) { return this.isSurge() || this.isLoon() ? $persistentStore.write(t, e) : this.isQuanX() ? $prefs.setValueForKey(t, e) : this.isNode() ? (this.data = this.loaddata(), this.data[e] = t, this.writedata(), !0) : this.data && this.data[e] || null } initGotEnv(t) { this.got = this.got ? this.got : require("got"), this.cktough = this.cktough ? this.cktough : require("tough-cookie"), this.ckjar = this.ckjar ? this.ckjar : new this.cktough.CookieJar, t && (t.headers = t.headers ? t.headers : {}, void 0 === t.headers.Cookie && void 0 === t.cookieJar && (t.cookieJar = this.ckjar)) } get(t, e = (() => { })) { t.headers && (delete t.headers["Content-Type"], delete t.headers["Content-Length"]), this.isSurge() || this.isLoon() ? (this.isSurge() && this.isNeedRewrite && (t.headers = t.headers || {}, Object.assign(t.headers, { "X-Surge-Skip-Scripting": !1 })), $httpClient.get(t, (t, s, i) => { !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i) })) : this.isQuanX() ? (this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, { hints: !1 })), $task.fetch(t).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => e(t))) : this.isNode() && (this.initGotEnv(t), this.got(t).on("redirect", (t, e) => { try { if (t.headers["set-cookie"]) { const s = t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString(); s && this.ckjar.setCookieSync(s, null), e.cookieJar = this.ckjar } } catch (t) { this.logErr(t) } }).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => { const { message: s, response: i } = t; e(s, i, i && i.body) })) } post(t, e = (() => { })) { if (t.body && t.headers && !t.headers["Content-Type"] && (t.headers["Content-Type"] = "application/x-www-form-urlencoded"), t.headers && delete t.headers["Content-Length"], this.isSurge() || this.isLoon()) this.isSurge() && this.isNeedRewrite && (t.headers = t.headers || {}, Object.assign(t.headers, { "X-Surge-Skip-Scripting": !1 })), $httpClient.post(t, (t, s, i) => { !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i) }); else if (this.isQuanX()) t.method = "POST", this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, { hints: !1 })), $task.fetch(t).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => e(t)); else if (this.isNode()) { this.initGotEnv(t); const { url: s, ...i } = t; this.got.post(s, i).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => { const { message: s, response: i } = t; e(s, i, i && i.body) }) } } time(t, e = null) { const s = e ? new Date(e) : new Date; let i = { "M+": s.getMonth() + 1, "d+": s.getDate(), "H+": s.getHours(), "m+": s.getMinutes(), "s+": s.getSeconds(), "q+": Math.floor((s.getMonth() + 3) / 3), S: s.getMilliseconds() }; /(y+)/.test(t) && (t = t.replace(RegExp.$1, (s.getFullYear() + "").substr(4 - RegExp.$1.length))); for (let e in i) new RegExp("(" + e + ")").test(t) && (t = t.replace(RegExp.$1, 1 == RegExp.$1.length ? i[e] : ("00" + i[e]).substr(("" + i[e]).length))); return t } msg(e = t, s = "", i = "", r) { const o = t => { if (!t) return t; if ("string" == typeof t) return this.isLoon() ? t : this.isQuanX() ? { "open-url": t } : this.isSurge() ? { url: t } : void 0; if ("object" == typeof t) { if (this.isLoon()) { let e = t.openUrl || t.url || t["open-url"], s = t.mediaUrl || t["media-url"]; return { openUrl: e, mediaUrl: s } } if (this.isQuanX()) { let e = t["open-url"] || t.url || t.openUrl, s = t["media-url"] || t.mediaUrl; return { "open-url": e, "media-url": s } } if (this.isSurge()) { let e = t.url || t.openUrl || t["open-url"]; return { url: e } } } }; if (this.isMute || (this.isSurge() || this.isLoon() ? $notification.post(e, s, i, o(r)) : this.isQuanX() && $notify(e, s, i, o(r))), !this.isMuteLog) { let t = ["", "==============📣系统通知📣=============="]; t.push(e), s && t.push(s), i && t.push(i), console.log(t.join("\n")), this.logs = this.logs.concat(t) } } log(...t) { t.length > 0 && (this.logs = [...this.logs, ...t]), console.log(t.join(this.logSeparator)) } logErr(t, e) { const s = !this.isSurge() && !this.isQuanX() && !this.isLoon(); s ? this.log("", `❗️${this.name}, 错误!`, t.stack) : this.log("", `❗️${this.name}, 错误!`, t) } wait(t) { return new Promise(e => setTimeout(e, t)) } done(t = {}) { const e = (new Date).getTime(), s = (e - this.startTime) / 1e3; this.log("", `🔔${this.name}, 结束! 🕛 ${s} 秒`), this.log(), (this.isSurge() || this.isQuanX() || this.isLoon()) && $done(t) } }(t, e) } diff --git a/activity/jd_opencard3.js b/activity/jd_opencard3.js new file mode 100644 index 0000000..d7c2d92 --- /dev/null +++ b/activity/jd_opencard3.js @@ -0,0 +1,588 @@ +/* +大牌联合 狂欢抢先GO + +https://lzdz1-isv.isvjcloud.com/dingzhi/dz/openCard/activity?activityId=dz20211013skcnurdk11jhdue84752hp&shareUuid=9f8d9375310b487bbb5bc3a08d67fac3 + +cron 27 6,21 * * * https://raw.githubusercontent.com/KingRan/JDJB/main/jd_opencard3.js +*/ +const $ = new Env("大牌联合 狂欢抢先GO"); +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const notify = $.isNode() ? require('./sendNotify') : ''; +let cookiesArr = [], cookie = '', message = ''; +let ownCode = null; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => { }; +} else { + let cookiesData = $.getdata('CookiesJD') || "[]"; + cookiesData = JSON.parse(cookiesData); + cookiesArr = cookiesData.map(item => item.cookie); + cookiesArr.reverse(); + cookiesArr.push(...[$.getdata('CookieJD2'), $.getdata('CookieJD')]); + cookiesArr.reverse(); + cookiesArr = cookiesArr.filter(item => !!item); +} +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', { "open-url": "https://bean.m.jd.com/bean/signIndex.action" }); + return; + } + + authorCodeList = await getAuthorCodeList('https://gitee.com/fatelight/dongge/raw/master/dongge/lzdz1_dapai.json11') + if(authorCodeList === '404: Not Found'){ + authorCodeList = [ + '9f8d9375310b487bbb5bc3a08d67fac3', + ] + } + + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i] + originCookie = cookiesArr[i] + newCookie = '' + $.UserName = decodeURIComponent(cookie.match(/pt_pin=(.+?);/) && cookie.match(/pt_pin=(.+?);/)[1]) + $.index = i + 1; + $.isLogin = true; + $.nickName = ''; + await checkCookie(); + console.log(`\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + if (!$.isLogin) { + $.msg($.name, `【提示】cookie已失效`, `京东账号${$.index} ${$.nickName || $.UserName}\n请重新登录获取\nhttps://bean.m.jd.com/bean/signIndex.action`, { "open-url": "https://bean.m.jd.com/bean/signIndex.action" }); + if ($.isNode()) { + await notify.sendNotify(`${$.name}cookie已失效 - ${$.UserName}`, `京东账号${$.index} ${$.UserName}\n请重新登录获取cookie`); + } + continue + } + $.bean = 0; + $.ADID = getUUID('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', 1); + $.UUID = getUUID('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'); + // $.authorCode = authorCodeList[random(0, authorCodeList.length)] + $.authorCode = ownCode ? ownCode : authorCodeList[random(0, authorCodeList.length)] + $.authorNum = `${random(1000000, 9999999)}` + $.randomCode = random(1000000, 9999999) + $.activityId = 'dz20211013skcnurdk11jhdue84752hp' + $.activityShopId = '1000004065' + $.activityUrl = `https://lzdz1-isv.isvjd.com/dingzhi/dz/openCard/activity/${$.authorNum}?activityId=${$.activityId}&shareUuid=${encodeURIComponent($.authorCode)}&adsource=null&shareuserid4minipg=null&shopid=${$.activityShopId}&lng=00.000000&lat=00.000000&sid=&un_area=` + await marry(); + await $.wait(3000) + if ($.bean > 0) { + message += `\n【京东账号${$.index}】${$.nickName || $.UserName} \n └ 获得 ${$.bean} 京豆。` + } + } + } + if (message !== '') { + if ($.isNode()) { + await notify.sendNotify($.name, message, '', `\n`); + } else { + $.msg($.name, '有点儿收获', message); + } + } +})() + .catch((e) => { + $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') + }) + .finally(() => { + $.done(); + }) + + +async function marry() { + $.log('那就开始吧。') + $.token = null; + $.secretPin = null; + $.openCardActivityId = null + await getFirstLZCK() + await getToken(); + if ($.token) { + await getMyPing(); + if ($.secretPin) { + console.log("去助力 -> "+$.authorCode) + await task('common/accessLogWithAD', `venderId=${$.activityShopId}&code=99&pin=${encodeURIComponent($.secretPin)}&activityId=${$.activityId}&pageUrl=${$.activityUrl}&subType=app&adSource=null`, 1); + await task('wxActionCommon/getUserInfo', `pin=${encodeURIComponent($.secretPin)}`, 1) + if ($.index === 1) { + await task('dz/openCard/activityContent', `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}&pinImg=&nick=${encodeURIComponent($.pin)}&cjyxPin=&cjhyPin=&shareUuid=${encodeURIComponent($.authorCode)}`, 0, 1) + } else { + await task('dz/openCard/activityContent', `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}&pinImg=&nick=${encodeURIComponent($.pin)}&cjyxPin=&cjhyPin=&shareUuid=${encodeURIComponent($.authorCode)}`) + } + await task('dz/openCard/checkOpenCard', `activityId=${$.activityId}&actorUuid=${$.actorUuid}&shareUuid=${$.authorCode}&pin=${encodeURIComponent($.secretPin)}`) + $.log("->关注店铺") + if ($.shopTask) { + if (!$.shopTask.allStatus) { + await task('dz/openCard/followShop', `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}&actorUuid=${encodeURIComponent($.actorUuid)}&taskType=23&taskValue=1000002520`) + } else { + $.log(" >>>已经关注过了\n") + await $.wait(2000) + return + } + } else { + $.log("没有获取到对应的任务。\n") + } + $.log("->->->> 加入店铺会员") + if ($.openCardStatus) { + for (let i = 0; i < ($.openCardStatus.cardList1.length + $.openCardStatus.cardList2.length); i++) { + $.log("模拟上报访问记录") + await task('crm/pageVisit/insertCrmPageVisit', `venderId=1000004065&pageId=dz20211013skcnurdk11jhdue84752hp&elementId=${encodeURIComponent(`去开卡${i}`)}&pin=${encodeURIComponent($.secretPin)}`, 1) + await $.wait(2000) + } + t1TaskList = [] + $.openCardStatus.cardList1.filter((x) => { if (x.status === 0) { t1TaskList.push(x) } }) + t2TaskList = [] + $.openCardStatus.cardList2.filter((x) => { if (x.status === 0) { t2TaskList.push(x) } }) + if (t1TaskList.length < 1) { + console.log(" >>>已经完成入会任务") + + } else { + for (const vo of t1TaskList) { + $.log(` >>>去加入${vo.name}`) + await getShopOpenCardInfo({ "venderId": `${vo.value}`, "channel": "401" }, vo.value) + await bindWithVender({ "venderId": `${vo.value}`, "bindByVerifyCodeFlag": 1, "registerExtend": {}, "writeChildFlag": 0, "activityId": $.openCardActivityId, "channel": 401 }, vo.value) + await $.wait(2000) + } + for (const vo of t2TaskList) { + $.log(` >>>${vo.name}`) + await getShopOpenCardInfo({ "venderId": `${vo.value}`, "channel": "401" }) + await bindWithVender({ "venderId": `${vo.value}`, "bindByVerifyCodeFlag": 1, "registerExtend": {}, "writeChildFlag": 0, "activityId": $.openCardActivityId, "channel": 401 }, vo.value) + await $.wait(2000) + } + } + + await task("taskact/openCardcommon/drawContent", `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}`) + await $.wait(2000) + await task('dz/openCard/checkOpenCard', `activityId=${$.activityId}&actorUuid=${$.actorUuid}&shareUuid=${$.authorCode}&pin=${encodeURIComponent($.secretPin)}`) + await $.wait(2000) + await task("dz/openCard/startDraw", `activityId=${$.activityId}&actorUuid=${$.actorUuid}&type=1&pin=${encodeURIComponent($.secretPin)}`) + await $.wait(2000) + await task("dz/openCard/startDraw", `activityId=${$.activityId}&actorUuid=${$.actorUuid}&type=2&pin=${encodeURIComponent($.secretPin)}`) + + } else { + $.log("没有获取到对应的任务。\n") + } + $.log("->->->> 加购物车") + await task("dz/openCard/saveTask", `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}&actorUuid=${$.actorUuid}&type=2&taskValue=100025232454`) + } + } +} + +function task(function_id, body, isCommon = 0, own = 0) { + return new Promise(resolve => { + $.post(taskUrl(function_id, body, isCommon), async (err, resp, data) => { + try { + if (err) { + $.log(err) + } else { + + if (data) { + data = JSON.parse(data); + if (data.result) { + switch (function_id) { + case 'wxActionCommon/getUserInfo': + break; + case 'dz/openCard/activityContent': + if (!data.data.hasEnd) { + $.log(`开启【${data.data.activityName}】活动`) + $.log("-------------------") + if ($.index === 1) { + ownCode = data.data.actorUuid + console.log(ownCode) + } + $.actorUuid = data.data.actorUuid; + $.skuTask = data.data.addSku; + $.shopTask = data.data.followShop; + } else { + $.log("活动已经结束"); + } + break; + case 'dz/openCard/checkOpenCard': + $.openCardStatus = data.data; + break; + case 'dz/openCard/saveTask': + console.log(data.data.addBeanNum) + break; + case 'dz/openCard/saveTask': + if (data.data) { + if (data.data.addBeanNum) { + $.bean += data.data.addBeanNum; + $.log(`==>获得【${data.data.addBeanNum}】京豆\n`) + } + } + break; + case 'dz/openCard/startDraw': + if (data.data.drawOk) { + switch (data.data.drawInfo.type) { + case 6: + $.bean += data.data.drawInfo.beanNum; + $.log(`==>获得【${data.data.drawInfo.beanNum}】京豆\n`) + break; + default: + if ($.isNode()) { + await notify.sendNotify("中奖了", `中奖信息:${JSON.stringify(data.data.drawInfo)}\n活动链接:${$.activityUrl}`) + } else { + $.msg("中奖了", `获得${data.data.drawInfo.name}`, `中奖信息:${JSON.stringify(data.data.drawInfo)}\n活动链接:${$.activityUrl}`) + } + break; + } + } + break; + case 'crm/pageVisit/insertCrmPageVisit': + $.log("==> 上报成功") + + case 'dz/openCard/followShop': + if (data.data) { + if (data.data.addBeanNum) { + $.bean += data.data.addBeanNum; + $.log(`==>获得【${data.data.addBeanNum}】京豆\n`) + } + } + break; + + break; + default: + $.log(JSON.stringify(data)) + break; + } + } else { + $.log(JSON.stringify(data)) + } + } else { + // $.log("京东没有返回数据") + } + } + } catch (error) { + $.log(error) + } finally { + resolve(); + } + }) + }) +} +function getShopOpenCardInfo(body, venderId) { + let opt = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body=${encodeURIComponent(JSON.stringify(body))}&client=H5&clientVersion=9.2.0&uuid=88888`, + headers: { + Host: 'api.m.jd.com', + Accept: '*/*', + Connection: 'keep-alive', + Cookie: cookie, + 'User-Agent': `jdapp;iPhone;9.5.4;13.6;${$.UUID};network/wifi;ADID/${$.ADID};model/iPhone10,3;addressid/0;appBuild/167668;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1`, + 'Accept-Language': 'zh-cn', + Referer: `https://shopmember.m.jd.com/shopcard/?venderId=${venderId}}&channel=801&returnUrl=${encodeURIComponent($.activityUrl)}`, + 'Accept-Encoding': 'gzip, deflate, br' + } + } + return new Promise(resolve => { + $.get(opt, (err, resp, data) => { + try { + if (err) { + console.log(err) + } else { + res = JSON.parse(data) + if (res.success) { + if (res.result.interestsRuleList) { + $.openCardActivityId = res.result.interestsRuleList[0].interestsInfo.activityId; + } + } + } + } catch (error) { + console.log(error) + } finally { + resolve(); + } + }) + + }) +} +function bindWithVender(body, venderId) { + let opt = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body=${encodeURIComponent(JSON.stringify(body))}&client=H5&clientVersion=9.2.0&uuid=88888`, + headers: { + Host: 'api.m.jd.com', + Accept: '*/*', + Connection: 'keep-alive', + Cookie: cookie, + 'User-Agent': `jdapp;iPhone;9.5.4;13.6;${$.UUID};network/wifi;ADID/${$.ADID};model/iPhone10,3;addressid/0;appBuild/167668;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1`, + 'Accept-Language': 'zh-cn', + Referer: `https://shopmember.m.jd.com/shopcard/?venderId=${venderId}}&channel=401&returnUrl=${encodeURIComponent($.activityUrl)}`, + 'Accept-Encoding': 'gzip, deflate, br' + } + } + return new Promise(resolve => { + $.get(opt, (err, resp, data) => { + try { + if (err) { + console.log(err) + } else { + res = JSON.parse(data) + if (res.success) { + if (res.result.giftInfo && res.result.giftInfo.giftList) { + for (const vo of res.result.giftInfo.giftList) { + if (vo.prizeType === 4) { + $.log(`==>获得【${vo.quantity}】京豆`) + $.bean += vo.quantity + } + } + } + } + } + } catch (error) { + console.log(error) + } finally { + resolve(); + } + }) + + }) +} +function taskUrl(function_id, body, isCommon) { + return { + url: isCommon ? `https://lzdz1-isv.isvjd.com/${function_id}` : `https://lzdz1-isv.isvjd.com/dingzhi/${function_id}`, + headers: { + Host: 'lzdz1-isv.isvjd.com', + Accept: 'application/json', + 'X-Requested-With': 'XMLHttpRequest', + 'Accept-Language': 'zh-cn', + 'Accept-Encoding': 'gzip, deflate, br', + 'Content-Type': 'application/x-www-form-urlencoded', + Origin: 'https://lzdz1-isv.isvjd.com', + 'User-Agent': `jdapp;iPhone;9.5.4;13.6;${$.UUID};network/wifi;ADID/${$.ADID};model/iPhone10,3;addressid/0;appBuild/167668;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1`, + Connection: 'keep-alive', + Referer: $.activityUrl, + Cookie: cookie + }, + body: body + + } +} +function getAuthorCodeList(url) { + return new Promise(resolve => { + const options = { + url: `${url}?${new Date()}`, "timeout": 10000, headers: { + "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1 Edg/87.0.4280.88" + } + }; + $.get(options, async (err, resp, data) => { + try { + if (err) { + $.log(err) + } else { + if (data) data = JSON.parse(data) + } + } catch (e) { + $.logErr(e, resp) + data = null; + } finally { + resolve(data); + } + }) + }) +} +function getMyPing() { + let opt = { + url: `https://lzdz1-isv.isvjd.com/customer/getMyPing`, + headers: { + Host: 'lzdz1-isv.isvjd.com', + Accept: 'application/json', + 'X-Requested-With': 'XMLHttpRequest', + 'Accept-Language': 'zh-cn', + 'Accept-Encoding': 'gzip, deflate, br', + 'Content-Type': 'application/x-www-form-urlencoded', + Origin: 'https://lzdz1-isv.isvjd.com', + 'User-Agent': `jdapp;iPhone;9.5.4;13.6;${$.UUID};network/wifi;ADID/${$.ADID};model/iPhone10,3;addressid/0;appBuild/167668;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1`, + Connection: 'keep-alive', + Referer: $.activityUrl, + Cookie: cookie, + }, + body: `userId=${$.activityShopId}&token=${$.token}&fromType=APP&riskType=1` + } + return new Promise(resolve => { + $.post(opt, (err, resp, data) => { + try { + if (err) { + $.log(err) + } else { + if (resp['headers']['set-cookie']) { + cookie = `${originCookie}` + if ($.isNode()) { + for (let sk of resp['headers']['set-cookie']) { + cookie = `${cookie}${sk.split(";")[0]};` + } + } else { + for (let ck of resp['headers']['Set-Cookie'].split(',')) { + cookie = `${cookie}${ck.split(";")[0]};` + } + } + } + if (resp['headers']['Set-Cookie']) { + cookie = `${originCookie}` + if ($.isNode()) { + for (let sk of resp['headers']['set-cookie']) { + cookie = `${cookie}${sk.split(";")[0]};` + } + } else { + for (let ck of resp['headers']['Set-Cookie'].split(',')) { + cookie = `${cookie}${ck.split(";")[0]};` + } + } + } + if (data) { + data = JSON.parse(data) + if (data.result) { + $.log(`你好:${data.data.nickname}`) + $.pin = data.data.nickname; + $.secretPin = data.data.secretPin; + cookie = `${cookie};AUTH_C_USER=${data.data.secretPin}` + } else { + $.log(data.errorMessage) + } + } else { + $.log("京东返回了空数据") + } + } + } catch (error) { + $.log(error) + } finally { + resolve(); + } + + }) + }) +} +function getFirstLZCK() { + return new Promise(resolve => { + $.get({ url: $.activityUrl }, (err, resp, data) => { + try { + if (err) { + console.log(err) + } else { + if (resp['headers']['set-cookie']) { + cookie = `${originCookie}` + if ($.isNode()) { + for (let sk of resp['headers']['set-cookie']) { + cookie = `${cookie}${sk.split(";")[0]};` + } + } else { + for (let ck of resp['headers']['Set-Cookie'].split(',')) { + cookie = `${cookie}${ck.split(";")[0]};` + } + } + } + if (resp['headers']['Set-Cookie']) { + cookie = `${originCookie}` + if ($.isNode()) { + for (let sk of resp['headers']['set-cookie']) { + cookie = `${cookie}${sk.split(";")[0]};` + } + } else { + for (let ck of resp['headers']['Set-Cookie'].split(',')) { + cookie = `${cookie}${ck.split(";")[0]};` + } + } + } + } + } catch (error) { + console.log(error) + } finally { + resolve(); + } + }) + }) +} +function getToken() { + let opt = { + url: `https://api.m.jd.com/client.action?functionId=isvObfuscator`, + headers: { + Host: 'api.m.jd.com', + 'Content-Type': 'application/x-www-form-urlencoded', + Accept: '*/*', + Connection: 'keep-alive', + Cookie: cookie, + 'User-Agent': 'JD4iPhone/167650 (iPhone; iOS 13.7; Scale/3.00)', + 'Accept-Language': 'zh-Hans-CN;q=1', + 'Accept-Encoding': 'gzip, deflate, br', + }, + body: `body=%7B%22url%22%3A%20%22https%3A//lzkj-isv.isvjcloud.com%22%2C%20%22id%22%3A%20%22%22%7D&uuid=hjudwgohxzVu96krv&client=apple&clientVersion=9.4.0&st=1620476162000&sv=111&sign=f9d1b7e3b943b6a136d54fe4f892af05` + } + return new Promise(resolve => { + $.post(opt, (err, resp, data) => { + try { + if (err) { + $.log(err) + } else { + if (data) { + data = JSON.parse(data); + if (data.code === "0") { + $.token = data.token + } + } else { + $.log("京东返回了空数据") + } + } + } catch (error) { + $.log(error) + } finally { + resolve(); + } + }) + }) +} +function random(min, max) { + + return Math.floor(Math.random() * (max - min)) + min; + +} +function getUUID(format = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', UpperCase = 0) { + return format.replace(/[xy]/g, function (c) { + var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8); + if (UpperCase) { + uuid = v.toString(36).toUpperCase(); + } else { + uuid = v.toString(36) + } + return uuid; + }); +} +function checkCookie() { + const options = { + url: "https://me-api.jd.com/user_new/info/GetJDUserInfoUnion", + headers: { + "Host": "me-api.jd.com", + "Accept": "*/*", + "Connection": "keep-alive", + "Cookie": cookie, + "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.2 Mobile/15E148 Safari/604.1", + "Accept-Language": "zh-cn", + "Referer": "https://home.m.jd.com/myJd/newhome.action?sceneval=2&ufc=&", + "Accept-Encoding": "gzip, deflate, br", + } + }; + return new Promise(resolve => { + $.get(options, (err, resp, data) => { + try { + if (err) { + $.logErr(err) + } else { + if (data) { + data = JSON.parse(data); + if (data.retcode === "1001") { + $.isLogin = false; //cookie过期 + return; + } + if (data.retcode === "0" && data.data.hasOwnProperty("userInfo")) { + $.nickName = data.data.userInfo.baseInfo.nickname; + } + } else { + $.log('京东返回了空数据'); + } + } + } catch (e) { + $.logErr(e) + } finally { + resolve(); + } + }) + }) +} +// prettier-ignore +!function (n) { "use strict"; function t(n, t) { var r = (65535 & n) + (65535 & t); return (n >> 16) + (t >> 16) + (r >> 16) << 16 | 65535 & r } function r(n, t) { return n << t | n >>> 32 - t } function e(n, e, o, u, c, f) { return t(r(t(t(e, n), t(u, f)), c), o) } function o(n, t, r, o, u, c, f) { return e(t & r | ~t & o, n, t, u, c, f) } function u(n, t, r, o, u, c, f) { return e(t & o | r & ~o, n, t, u, c, f) } function c(n, t, r, o, u, c, f) { return e(t ^ r ^ o, n, t, u, c, f) } function f(n, t, r, o, u, c, f) { return e(r ^ (t | ~o), n, t, u, c, f) } function i(n, r) { n[r >> 5] |= 128 << r % 32, n[14 + (r + 64 >>> 9 << 4)] = r; var e, i, a, d, h, l = 1732584193, g = -271733879, v = -1732584194, m = 271733878; for (e = 0; e < n.length; e += 16)i = l, a = g, d = v, h = m, g = f(g = f(g = f(g = f(g = c(g = c(g = c(g = c(g = u(g = u(g = u(g = u(g = o(g = o(g = o(g = o(g, v = o(v, m = o(m, l = o(l, g, v, m, n[e], 7, -680876936), g, v, n[e + 1], 12, -389564586), l, g, n[e + 2], 17, 606105819), m, l, n[e + 3], 22, -1044525330), v = o(v, m = o(m, l = o(l, g, v, m, n[e + 4], 7, -176418897), g, v, n[e + 5], 12, 1200080426), l, g, n[e + 6], 17, -1473231341), m, l, n[e + 7], 22, -45705983), v = o(v, m = o(m, l = o(l, g, v, m, n[e + 8], 7, 1770035416), g, v, n[e + 9], 12, -1958414417), l, g, n[e + 10], 17, -42063), m, l, n[e + 11], 22, -1990404162), v = o(v, m = o(m, l = o(l, g, v, m, n[e + 12], 7, 1804603682), g, v, n[e + 13], 12, -40341101), l, g, n[e + 14], 17, -1502002290), m, l, n[e + 15], 22, 1236535329), v = u(v, m = u(m, l = u(l, g, v, m, n[e + 1], 5, -165796510), g, v, n[e + 6], 9, -1069501632), l, g, n[e + 11], 14, 643717713), m, l, n[e], 20, -373897302), v = u(v, m = u(m, l = u(l, g, v, m, n[e + 5], 5, -701558691), g, v, n[e + 10], 9, 38016083), l, g, n[e + 15], 14, -660478335), m, l, n[e + 4], 20, -405537848), v = u(v, m = u(m, l = u(l, g, v, m, n[e + 9], 5, 568446438), g, v, n[e + 14], 9, -1019803690), l, g, n[e + 3], 14, -187363961), m, l, n[e + 8], 20, 1163531501), v = u(v, m = u(m, l = u(l, g, v, m, n[e + 13], 5, -1444681467), g, v, n[e + 2], 9, -51403784), l, g, n[e + 7], 14, 1735328473), m, l, n[e + 12], 20, -1926607734), v = c(v, m = c(m, l = c(l, g, v, m, n[e + 5], 4, -378558), g, v, n[e + 8], 11, -2022574463), l, g, n[e + 11], 16, 1839030562), m, l, n[e + 14], 23, -35309556), v = c(v, m = c(m, l = c(l, g, v, m, n[e + 1], 4, -1530992060), g, v, n[e + 4], 11, 1272893353), l, g, n[e + 7], 16, -155497632), m, l, n[e + 10], 23, -1094730640), v = c(v, m = c(m, l = c(l, g, v, m, n[e + 13], 4, 681279174), g, v, n[e], 11, -358537222), l, g, n[e + 3], 16, -722521979), m, l, n[e + 6], 23, 76029189), v = c(v, m = c(m, l = c(l, g, v, m, n[e + 9], 4, -640364487), g, v, n[e + 12], 11, -421815835), l, g, n[e + 15], 16, 530742520), m, l, n[e + 2], 23, -995338651), v = f(v, m = f(m, l = f(l, g, v, m, n[e], 6, -198630844), g, v, n[e + 7], 10, 1126891415), l, g, n[e + 14], 15, -1416354905), m, l, n[e + 5], 21, -57434055), v = f(v, m = f(m, l = f(l, g, v, m, n[e + 12], 6, 1700485571), g, v, n[e + 3], 10, -1894986606), l, g, n[e + 10], 15, -1051523), m, l, n[e + 1], 21, -2054922799), v = f(v, m = f(m, l = f(l, g, v, m, n[e + 8], 6, 1873313359), g, v, n[e + 15], 10, -30611744), l, g, n[e + 6], 15, -1560198380), m, l, n[e + 13], 21, 1309151649), v = f(v, m = f(m, l = f(l, g, v, m, n[e + 4], 6, -145523070), g, v, n[e + 11], 10, -1120210379), l, g, n[e + 2], 15, 718787259), m, l, n[e + 9], 21, -343485551), l = t(l, i), g = t(g, a), v = t(v, d), m = t(m, h); return [l, g, v, m] } function a(n) { var t, r = "", e = 32 * n.length; for (t = 0; t < e; t += 8)r += String.fromCharCode(n[t >> 5] >>> t % 32 & 255); return r } function d(n) { var t, r = []; for (r[(n.length >> 2) - 1] = void 0, t = 0; t < r.length; t += 1)r[t] = 0; var e = 8 * n.length; for (t = 0; t < e; t += 8)r[t >> 5] |= (255 & n.charCodeAt(t / 8)) << t % 32; return r } function h(n) { return a(i(d(n), 8 * n.length)) } function l(n, t) { var r, e, o = d(n), u = [], c = []; for (u[15] = c[15] = void 0, o.length > 16 && (o = i(o, 8 * n.length)), r = 0; r < 16; r += 1)u[r] = 909522486 ^ o[r], c[r] = 1549556828 ^ o[r]; return e = i(u.concat(d(t)), 512 + 8 * t.length), a(i(c.concat(e), 640)) } function g(n) { var t, r, e = ""; for (r = 0; r < n.length; r += 1)t = n.charCodeAt(r), e += "0123456789abcdef".charAt(t >>> 4 & 15) + "0123456789abcdef".charAt(15 & t); return e } function v(n) { return unescape(encodeURIComponent(n)) } function m(n) { return h(v(n)) } function p(n) { return g(m(n)) } function s(n, t) { return l(v(n), v(t)) } function C(n, t) { return g(s(n, t)) } function A(n, t, r) { return t ? r ? s(t, n) : C(t, n) : r ? m(n) : p(n) } $.md5 = A }(this); +function Env(t, e) { "undefined" != typeof process && JSON.stringify(process.env).indexOf("GITHUB") > -1 && process.exit(0); class s { constructor(t) { this.env = t } send(t, e = "GET") { t = "string" == typeof t ? { url: t } : t; let s = this.get; return "POST" === e && (s = this.post), new Promise((e, i) => { s.call(this, t, (t, s, r) => { t ? i(t) : e(s) }) }) } get(t) { return this.send.call(this.env, t) } post(t) { return this.send.call(this.env, t, "POST") } } return new class { constructor(t, e) { this.name = t, this.http = new s(this), this.data = null, this.dataFile = "box.dat", this.logs = [], this.isMute = !1, this.isNeedRewrite = !1, this.logSeparator = "\n", this.startTime = (new Date).getTime(), Object.assign(this, e), this.log("", `🔔${this.name}, 开始!`) } isNode() { return "undefined" != typeof module && !!module.exports } isQuanX() { return "undefined" != typeof $task } isSurge() { return "undefined" != typeof $httpClient && "undefined" == typeof $loon } isLoon() { return "undefined" != typeof $loon } toObj(t, e = null) { try { return JSON.parse(t) } catch { return e } } toStr(t, e = null) { try { return JSON.stringify(t) } catch { return e } } getjson(t, e) { let s = e; const i = this.getdata(t); if (i) try { s = JSON.parse(this.getdata(t)) } catch { } return s } setjson(t, e) { try { return this.setdata(JSON.stringify(t), e) } catch { return !1 } } getScript(t) { return new Promise(e => { this.get({ url: t }, (t, s, i) => e(i)) }) } runScript(t, e) { return new Promise(s => { let i = this.getdata("@chavy_boxjs_userCfgs.httpapi"); i = i ? i.replace(/\n/g, "").trim() : i; let r = this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout"); r = r ? 1 * r : 20, r = e && e.timeout ? e.timeout : r; const [o, h] = i.split("@"), n = { url: `http://${h}/v1/scripting/evaluate`, body: { script_text: t, mock_type: "cron", timeout: r }, headers: { "X-Key": o, Accept: "*/*" } }; this.post(n, (t, e, i) => s(i)) }).catch(t => this.logErr(t)) } loaddata() { if (!this.isNode()) return {}; { this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path"); const t = this.path.resolve(this.dataFile), e = this.path.resolve(process.cwd(), this.dataFile), s = this.fs.existsSync(t), i = !s && this.fs.existsSync(e); if (!s && !i) return {}; { const i = s ? t : e; try { return JSON.parse(this.fs.readFileSync(i)) } catch (t) { return {} } } } } writedata() { if (this.isNode()) { this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path"); const t = this.path.resolve(this.dataFile), e = this.path.resolve(process.cwd(), this.dataFile), s = this.fs.existsSync(t), i = !s && this.fs.existsSync(e), r = JSON.stringify(this.data); s ? this.fs.writeFileSync(t, r) : i ? this.fs.writeFileSync(e, r) : this.fs.writeFileSync(t, r) } } lodash_get(t, e, s) { const i = e.replace(/\[(\d+)\]/g, ".$1").split("."); let r = t; for (const t of i) if (r = Object(r)[t], void 0 === r) return s; return r } lodash_set(t, e, s) { return Object(t) !== t ? t : (Array.isArray(e) || (e = e.toString().match(/[^.[\]]+/g) || []), e.slice(0, -1).reduce((t, s, i) => Object(t[s]) === t[s] ? t[s] : t[s] = Math.abs(e[i + 1]) >> 0 == +e[i + 1] ? [] : {}, t)[e[e.length - 1]] = s, t) } getdata(t) { let e = this.getval(t); if (/^@/.test(t)) { const [, s, i] = /^@(.*?)\.(.*?)$/.exec(t), r = s ? this.getval(s) : ""; if (r) try { const t = JSON.parse(r); e = t ? this.lodash_get(t, i, "") : e } catch (t) { e = "" } } return e } setdata(t, e) { let s = !1; if (/^@/.test(e)) { const [, i, r] = /^@(.*?)\.(.*?)$/.exec(e), o = this.getval(i), h = i ? "null" === o ? null : o || "{}" : "{}"; try { const e = JSON.parse(h); this.lodash_set(e, r, t), s = this.setval(JSON.stringify(e), i) } catch (e) { const o = {}; this.lodash_set(o, r, t), s = this.setval(JSON.stringify(o), i) } } else s = this.setval(t, e); return s } getval(t) { return this.isSurge() || this.isLoon() ? $persistentStore.read(t) : this.isQuanX() ? $prefs.valueForKey(t) : this.isNode() ? (this.data = this.loaddata(), this.data[t]) : this.data && this.data[t] || null } setval(t, e) { return this.isSurge() || this.isLoon() ? $persistentStore.write(t, e) : this.isQuanX() ? $prefs.setValueForKey(t, e) : this.isNode() ? (this.data = this.loaddata(), this.data[e] = t, this.writedata(), !0) : this.data && this.data[e] || null } initGotEnv(t) { this.got = this.got ? this.got : require("got"), this.cktough = this.cktough ? this.cktough : require("tough-cookie"), this.ckjar = this.ckjar ? this.ckjar : new this.cktough.CookieJar, t && (t.headers = t.headers ? t.headers : {}, void 0 === t.headers.Cookie && void 0 === t.cookieJar && (t.cookieJar = this.ckjar)) } get(t, e = (() => { })) { t.headers && (delete t.headers["Content-Type"], delete t.headers["Content-Length"]), this.isSurge() || this.isLoon() ? (this.isSurge() && this.isNeedRewrite && (t.headers = t.headers || {}, Object.assign(t.headers, { "X-Surge-Skip-Scripting": !1 })), $httpClient.get(t, (t, s, i) => { !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i) })) : this.isQuanX() ? (this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, { hints: !1 })), $task.fetch(t).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => e(t))) : this.isNode() && (this.initGotEnv(t), this.got(t).on("redirect", (t, e) => { try { if (t.headers["set-cookie"]) { const s = t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString(); s && this.ckjar.setCookieSync(s, null), e.cookieJar = this.ckjar } } catch (t) { this.logErr(t) } }).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => { const { message: s, response: i } = t; e(s, i, i && i.body) })) } post(t, e = (() => { })) { if (t.body && t.headers && !t.headers["Content-Type"] && (t.headers["Content-Type"] = "application/x-www-form-urlencoded"), t.headers && delete t.headers["Content-Length"], this.isSurge() || this.isLoon()) this.isSurge() && this.isNeedRewrite && (t.headers = t.headers || {}, Object.assign(t.headers, { "X-Surge-Skip-Scripting": !1 })), $httpClient.post(t, (t, s, i) => { !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i) }); else if (this.isQuanX()) t.method = "POST", this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, { hints: !1 })), $task.fetch(t).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => e(t)); else if (this.isNode()) { this.initGotEnv(t); const { url: s, ...i } = t; this.got.post(s, i).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => { const { message: s, response: i } = t; e(s, i, i && i.body) }) } } time(t, e = null) { const s = e ? new Date(e) : new Date; let i = { "M+": s.getMonth() + 1, "d+": s.getDate(), "H+": s.getHours(), "m+": s.getMinutes(), "s+": s.getSeconds(), "q+": Math.floor((s.getMonth() + 3) / 3), S: s.getMilliseconds() }; /(y+)/.test(t) && (t = t.replace(RegExp.$1, (s.getFullYear() + "").substr(4 - RegExp.$1.length))); for (let e in i) new RegExp("(" + e + ")").test(t) && (t = t.replace(RegExp.$1, 1 == RegExp.$1.length ? i[e] : ("00" + i[e]).substr(("" + i[e]).length))); return t } msg(e = t, s = "", i = "", r) { const o = t => { if (!t) return t; if ("string" == typeof t) return this.isLoon() ? t : this.isQuanX() ? { "open-url": t } : this.isSurge() ? { url: t } : void 0; if ("object" == typeof t) { if (this.isLoon()) { let e = t.openUrl || t.url || t["open-url"], s = t.mediaUrl || t["media-url"]; return { openUrl: e, mediaUrl: s } } if (this.isQuanX()) { let e = t["open-url"] || t.url || t.openUrl, s = t["media-url"] || t.mediaUrl; return { "open-url": e, "media-url": s } } if (this.isSurge()) { let e = t.url || t.openUrl || t["open-url"]; return { url: e } } } }; if (this.isMute || (this.isSurge() || this.isLoon() ? $notification.post(e, s, i, o(r)) : this.isQuanX() && $notify(e, s, i, o(r))), !this.isMuteLog) { let t = ["", "==============📣系统通知📣=============="]; t.push(e), s && t.push(s), i && t.push(i), console.log(t.join("\n")), this.logs = this.logs.concat(t) } } log(...t) { t.length > 0 && (this.logs = [...this.logs, ...t]), console.log(t.join(this.logSeparator)) } logErr(t, e) { const s = !this.isSurge() && !this.isQuanX() && !this.isLoon(); s ? this.log("", `❗️${this.name}, 错误!`, t.stack) : this.log("", `❗️${this.name}, 错误!`, t) } wait(t) { return new Promise(e => setTimeout(e, t)) } done(t = {}) { const e = (new Date).getTime(), s = (e - this.startTime) / 1e3; this.log("", `🔔${this.name}, 结束! 🕛 ${s} 秒`), this.log(), (this.isSurge() || this.isQuanX() || this.isLoon()) && $done(t) } }(t, e) } diff --git a/activity/jd_opencard4.js b/activity/jd_opencard4.js new file mode 100644 index 0000000..a7d33d9 --- /dev/null +++ b/activity/jd_opencard4.js @@ -0,0 +1,587 @@ +/* +惠聚京东 好物连连10-20 ~ 11-3 + +https://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity/5063373?activityId=llk20211020&shareUuid=169b20a20b4040d4bd8ddb813803e558 + +cron 15 2,9 * * * https://raw.githubusercontent.com/KingRan/JDJB/main/jd_opencard4.js +*/ +const $ = new Env("惠聚京东 好物连连10-20 ~ 11-3"); +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const notify = $.isNode() ? require('./sendNotify') : ''; +let cookiesArr = [], cookie = '', message = ''; +let ownCode = null; +let authorCodeList = [] +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => { }; +} else { + let cookiesData = $.getdata('CookiesJD') || "[]"; + cookiesData = JSON.parse(cookiesData); + cookiesArr = cookiesData.map(item => item.cookie); + cookiesArr.reverse(); + cookiesArr.push(...[$.getdata('CookieJD2'), $.getdata('CookieJD')]); + cookiesArr.reverse(); + cookiesArr = cookiesArr.filter(item => !!item); +} +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', { "open-url": "https://bean.m.jd.com/bean/signIndex.action" }); + return; + } + authorCodeList = await getAuthorCodeList('https://gitee.com/KingRan521/JD-Scripts/raw/master/shareCodes/qjd.json') + if(authorCodeList === '404: Not Found'){ + authorCodeList = [ + '169b20a20b4040d4bd8ddb813803e558', + ] + } + // console.log(authorCodeList) + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i] + originCookie = cookiesArr[i] + newCookie = '' + $.UserName = decodeURIComponent(cookie.match(/pt_pin=(.+?);/) && cookie.match(/pt_pin=(.+?);/)[1]) + $.index = i + 1; + $.isLogin = true; + $.nickName = ''; + await checkCookie(); + console.log(`\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + if (!$.isLogin) { + $.msg($.name, `【提示】cookie已失效`, `京东账号${$.index} ${$.nickName || $.UserName}\n请重新登录获取\nhttps://bean.m.jd.com/bean/signIndex.action`, { "open-url": "https://bean.m.jd.com/bean/signIndex.action" }); + // if ($.isNode()) { + // await notify.sendNotify(`${$.name}cookie已失效 - ${$.UserName}`, `京东账号${$.index} ${$.UserName}\n请重新登录获取cookie`); + // } + continue + } + $.bean = 0; + $.ADID = getUUID('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', 1); + $.UUID = getUUID('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'); + // $.authorCode = authorCodeList[random(0, authorCodeList.length)] + $.authorCode = ownCode ? ownCode : authorCodeList[random(0, authorCodeList.length)] + $.authorNum = `${random(1000000, 9999999)}` + $.randomCode = random(1000000, 9999999) + $.activityId = 'llk20211020' + $.activityShopId = '1000001373' + $.activityUrl = `https://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity/${$.authorNum}?activityId=${$.activityId}&shareUuid=${encodeURIComponent($.authorCode)}&adsource=null&shareuserid4minipg=null&shopid=undefined&lng=00.000000&lat=00.000000&sid=&un_area=` + await member(); + await $.wait(5000) + if ($.bean > 0) { + message += `\n【京东账号${$.index}】${$.nickName || $.UserName} \n └ 获得 ${$.bean} 京豆。` + } + } + } + if (message !== '') { + if ($.isNode()) { + await notify.sendNotify($.name, message, '', `\n`); + } else { + $.msg($.name, '有点儿收获', message); + } + } +})() + .catch((e) => { + $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') + }) + .finally(() => { + $.done(); + }) + + +async function member() { + $.token = null; + $.secretPin = null; + $.openCardActivityId = null + await getFirstLZCK() + await getToken(); + await task('dz/common/getSimpleActInfoVo', `activityId=${$.activityId}`, 1) + if ($.token) { + await getMyPing(); + if ($.secretPin) { + console.log("去助力 -> "+$.authorCode) + await task('common/accessLogWithAD', `venderId=${$.activityShopId}&code=99&pin=${encodeURIComponent($.secretPin)}&activityId=${$.activityId}&pageUrl=${$.activityUrl}&subType=app&adSource=null`, 1); + await task('wxActionCommon/getUserInfo', `pin=${encodeURIComponent($.secretPin)}`, 1) + if ($.index === 1) { + await task('linkgame/activity/content', `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}&pinImg=&nick=${encodeURIComponent($.pin)}&cjyxPin=&cjhyPin=&shareUuid=${encodeURIComponent($.authorCode)}`, 0, 1) + } else { + await task('linkgame/activity/content', `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}&pinImg=&nick=${encodeURIComponent($.pin)}&cjyxPin=&cjhyPin=&shareUuid=${encodeURIComponent($.authorCode)}`) + } + $.log("关注店铺") + await task('linkgame/follow/shop', `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}`) + await task('taskact/common/drawContent', `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}`) + await task('linkgame/checkOpenCard', `pin=${encodeURIComponent($.secretPin)}&activityId=${$.activityId}`) + $.log("加入店铺会员") + if ($.openCardList) { + for (let i = 0; i < ($.openCardList.length); i++) { + $.log(">>> 模拟上报访问记录") + await task('crm/pageVisit/insertCrmPageVisit', `venderId=1000001373&pageId=llk20211020&elementId=入会跳转&pin=${encodeURIComponent($.secretPin)}`, 1) + await $.wait(2000) + } + + for (const vo of $.openCardList) { + $.log(`>>> 去加入${vo.name} ${vo.venderId}`) + if (vo.status === 0) { + await getShopOpenCardInfo({ "venderId": `${vo.venderId}`, "channel": "401" }, vo.venderId) + await bindWithVender({ "venderId": `${vo.venderId}`, "bindByVerifyCodeFlag": 1, "registerExtend": {}, "writeChildFlag": 0, "activityId": $.openCardActivityId, "channel": 401 }, vo.venderId) + await $.wait(2000) + } else { + $.log(`>>> 已经是会员`) + } + + } + } else { + $.log("没有获取到对应的任务。\n") + } + await task('linkgame/checkOpenCard', `pin=${encodeURIComponent($.secretPin)}&activityId=${$.activityId}`) + if ($.openCardStatus) { + console.log('去助力 -> ' + $.authorCode) + if ($.openCardStatus.allOpenCard) { + await task('linkgame/assist/status', `pin=${encodeURIComponent($.secretPin)}&activityId=${$.activityId}&shareUuid=${$.authorCode}`) + await task('linkgame/assist', `pin=${encodeURIComponent($.secretPin)}&activityId=${$.activityId}&shareUuid=${$.authorCode}`) + + } + } + await task('linkgame/help/list', `pin=${encodeURIComponent($.secretPin)}&activityId=${$.activityId}`) + + await task('linkgame/task/info', `pin=${encodeURIComponent($.secretPin)}&activityId=${$.activityId}`) + if ($.TaskList) { + tasklist = $.TaskList + if (!$.TaskList.sign) { + await task('linkgame/sign', `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}`); + } else { + console.log("已完成签到") + } + if (!$.TaskList.visitSku) { + for (const vo of tasklist.visitSkuList) { + if (vo.status === 0) { + await task('linkgame/browseGoods', `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}&value=${vo.goodsCode}`) + } + } + } else { + console.log("已完成浏览任务"); + } + if (!$.TaskList.addCart) { + await task('linkgame/addCart', `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}`); + } else { + console.log("加购任务已完成") + } + } + } + } +} + +function task(function_id, body, isCommon = 0, own = 0) { + return new Promise(resolve => { + $.post(taskUrl(function_id, body, isCommon), async (err, resp, data) => { + try { + if (err) { + $.log(err) + } else { + + if (data) { + data = JSON.parse(data); + if (data.result) { + switch (function_id) { + case 'dz/common/getSimpleActInfoVo': + $.jdActivityId = data.data.jdActivityId; + $.venderId = data.data.venderId; + $.activityType = data.data.activityType; + break; + case 'wxActionCommon/getUserInfo': + break; + case 'linkgame/activity/content': + if (!data.data.hasEnd) { + $.log(`开启【${data.data.activity['name']}】活动`) + $.log("-------------------") + if ($.index === 1) { + ownCode = data.data.actor['actorUuid'] + console.log(ownCode) + } + $.actorUuid = data.data.actor['actorUuid']; + } else { + $.log("活动已经结束"); + } + break; + case 'linkgame/checkOpenCard': + $.openCardList = data.data.openCardList; + $.openCardStatus = data.data; + // console.log(data) + break; + case 'linkgame/follow/shop': + console.log(data) + break; + case 'linkgame/sign': + console.log(data) + break; + case 'linkgame/addCart': + console.log(data) + break; + case 'linkgame/browseGoods': + console.log(data) + break; + case 'interaction/write/writePersonInfo': + console.log(data) + break; + case 'linkgame/task/info': + console.log(data) + break; + case 'linkgame/assist/status': + console.log(data) + break; + case 'linkgame/assist': + console.log(data) + break; + case 'linkgame/help/list': + console.log(data) + break; + default: + // $.log(JSON.stringify(data)) + break; + } + } else { + // $.log(JSON.stringify(data)) + } + } else { + // $.log("京东没有返回数据") + } + } + } catch (error) { + $.log(error) + } finally { + resolve(); + } + }) + }) +} +function getShopOpenCardInfo(body, venderId) { + let opt = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body=${encodeURIComponent(JSON.stringify(body))}&client=H5&clientVersion=9.2.0&uuid=88888`, + headers: { + Host: 'api.m.jd.com', + Accept: '*/*', + Connection: 'keep-alive', + Cookie: cookie, + 'User-Agent': `jdapp;iPhone;9.5.4;13.6;${$.UUID};network/wifi;ADID/${$.ADID};model/iPhone10,3;addressid/0;appBuild/167668;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1`, + 'Accept-Language': 'zh-cn', + Referer: `https://shopmember.m.jd.com/shopcard/?venderId=${venderId}}&channel=801&returnUrl=${encodeURIComponent($.activityUrl)}`, + 'Accept-Encoding': 'gzip, deflate, br' + } + } + return new Promise(resolve => { + $.get(opt, (err, resp, data) => { + try { + if (err) { + console.log(err) + } else { + res = JSON.parse(data) + if (res.success) { + if (res.result.interestsRuleList) { + $.openCardActivityId = res.result.interestsRuleList[0].interestsInfo.activityId; + } + } + } + } catch (error) { + console.log(error) + } finally { + resolve(); + } + }) + + }) +} +function bindWithVender(body, venderId) { + let opt = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body=${encodeURIComponent(JSON.stringify(body))}&client=H5&clientVersion=9.2.0&uuid=88888`, + headers: { + Host: 'api.m.jd.com', + Accept: '*/*', + Connection: 'keep-alive', + Cookie: cookie, + 'User-Agent': `jdapp;iPhone;9.5.4;13.6;${$.UUID};network/wifi;ADID/${$.ADID};model/iPhone10,3;addressid/0;appBuild/167668;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1`, + 'Accept-Language': 'zh-cn', + Referer: `https://shopmember.m.jd.com/shopcard/?venderId=${venderId}}&channel=401&returnUrl=${encodeURIComponent($.activityUrl)}`, + 'Accept-Encoding': 'gzip, deflate, br' + } + } + return new Promise(resolve => { + $.get(opt, (err, resp, data) => { + try { + if (err) { + console.log(err) + } else { + res = JSON.parse(data) + if (res.success) { + if (res.result.giftInfo && res.result.giftInfo.giftList) { + for (const vo of res.result.giftInfo.giftList) { + if (vo.prizeType === 4) { + $.log(`==>获得【${vo.quantity}】京豆`) + $.bean += vo.quantity + } + } + } + } + } + } catch (error) { + console.log(error) + } finally { + resolve(); + } + }) + + }) +} + +function getAuthorCodeList(url) { + return new Promise(resolve => { + const options = { + url: `${url}?${new Date()}`, "timeout": 10000, headers: { + "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1 Edg/87.0.4280.88" + } + }; + $.get(options, async (err, resp, data) => { + try { + if (err) { + $.log(err) + } else { + if (data) data = JSON.parse(data) + } + } catch (e) { + $.logErr(e, resp) + data = null; + } finally { + resolve(data); + } + }) + }) +} + +function taskUrl(function_id, body, isCommon) { + return { + url: isCommon ? `https://lzdz1-isv.isvjcloud.com/${function_id}` : `https://lzdz1-isv.isvjcloud.com/dingzhi/${function_id}`, + headers: { + Host: 'lzdz1-isv.isvjcloud.com', + Accept: 'application/json', + 'X-Requested-With': 'XMLHttpRequest', + 'Accept-Language': 'zh-cn', + 'Accept-Encoding': 'gzip, deflate, br', + 'Content-Type': 'application/x-www-form-urlencoded', + Origin: 'https://lzdz1-isv.isvjcloud.com', + 'User-Agent': `jdapp;iPhone;9.5.4;13.6;${$.UUID};network/wifi;ADID/${$.ADID};model/iPhone10,3;addressid/0;appBuild/167668;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1`, + Connection: 'keep-alive', + Referer: $.activityUrl, + Cookie: cookie + }, + body: body + + } +} + +function getMyPing() { + let opt = { + url: `https://lzdz1-isv.isvjcloud.com/customer/getMyPing`, + headers: { + Host: 'lzdz1-isv.isvjcloud.com', + Accept: 'application/json', + 'X-Requested-With': 'XMLHttpRequest', + 'Accept-Language': 'zh-cn', + 'Accept-Encoding': 'gzip, deflate, br', + 'Content-Type': 'application/x-www-form-urlencoded', + Origin: 'https://lzdz1-isv.isvjcloud.com', + 'User-Agent': `jdapp;iPhone;9.5.4;13.6;${$.UUID};network/wifi;ADID/${$.ADID};model/iPhone10,3;addressid/0;appBuild/167668;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1`, + Connection: 'keep-alive', + Referer: $.activityUrl, + Cookie: cookie, + }, + body: `userId=${$.activityShopId}&token=${$.token}&fromType=APP&riskType=1` + } + return new Promise(resolve => { + $.post(opt, (err, resp, data) => { + try { + if (err) { + $.log(err) + } else { + if (resp['headers']['set-cookie']) { + cookie = `${originCookie}` + if ($.isNode()) { + for (let sk of resp['headers']['set-cookie']) { + cookie = `${cookie}${sk.split(";")[0]};` + } + } else { + for (let ck of resp['headers']['Set-Cookie'].split(',')) { + cookie = `${cookie}${ck.split(";")[0]};` + } + } + } + if (resp['headers']['Set-Cookie']) { + cookie = `${originCookie}` + if ($.isNode()) { + for (let sk of resp['headers']['set-cookie']) { + cookie = `${cookie}${sk.split(";")[0]};` + } + } else { + for (let ck of resp['headers']['Set-Cookie'].split(',')) { + cookie = `${cookie}${ck.split(";")[0]};` + } + } + } + if (data) { + data = JSON.parse(data) + if (data.result) { + $.log(`你好:${data.data.nickname}`) + $.pin = data.data.nickname; + $.secretPin = data.data.secretPin; + cookie = `${cookie};AUTH_C_USER=${data.data.secretPin}` + } else { + $.log(data.errorMessage) + } + } else { + $.log("京东返回了空数据") + } + } + } catch (error) { + $.log(error) + } finally { + resolve(); + } + + }) + }) +} +function getFirstLZCK() { + return new Promise(resolve => { + $.get({ url: $.activityUrl }, (err, resp, data) => { + try { + if (err) { + console.log(err) + } else { + if (resp['headers']['set-cookie']) { + cookie = `${originCookie}` + if ($.isNode()) { + for (let sk of resp['headers']['set-cookie']) { + cookie = `${cookie}${sk.split(";")[0]};` + } + } else { + for (let ck of resp['headers']['Set-Cookie'].split(',')) { + cookie = `${cookie}${ck.split(";")[0]};` + } + } + } + if (resp['headers']['Set-Cookie']) { + cookie = `${originCookie}` + if ($.isNode()) { + for (let sk of resp['headers']['set-cookie']) { + cookie = `${cookie}${sk.split(";")[0]};` + } + } else { + for (let ck of resp['headers']['Set-Cookie'].split(',')) { + cookie = `${cookie}${ck.split(";")[0]};` + } + } + } + } + } catch (error) { + console.log(error) + } finally { + resolve(); + } + }) + }) +} +function getToken() { + let opt = { + url: `https://api.m.jd.com/client.action?functionId=isvObfuscator`, + headers: { + Host: 'api.m.jd.com', + 'Content-Type': 'application/x-www-form-urlencoded', + Accept: '*/*', + Connection: 'keep-alive', + Cookie: cookie, + 'User-Agent': 'JD4iPhone/167650 (iPhone; iOS 13.7; Scale/3.00)', + 'Accept-Language': 'zh-Hans-CN;q=1', + 'Accept-Encoding': 'gzip, deflate, br', + }, + body: `body=%7B%22url%22%3A%20%22https%3A//lzkj-isv.isvjcloud.com%22%2C%20%22id%22%3A%20%22%22%7D&uuid=hjudwgohxzVu96krv&client=apple&clientVersion=9.4.0&st=1620476162000&sv=111&sign=f9d1b7e3b943b6a136d54fe4f892af05` + } + return new Promise(resolve => { + $.post(opt, (err, resp, data) => { + try { + if (err) { + $.log(err) + } else { + if (data) { + data = JSON.parse(data); + if (data.code === "0") { + $.token = data.token + } + } else { + $.log("京东返回了空数据") + } + } + } catch (error) { + $.log(error) + } finally { + resolve(); + } + }) + }) +} +function random(min, max) { + + return Math.floor(Math.random() * (max - min)) + min; + +} +function getUUID(format = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', UpperCase = 0) { + return format.replace(/[xy]/g, function (c) { + var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8); + if (UpperCase) { + uuid = v.toString(36).toUpperCase(); + } else { + uuid = v.toString(36) + } + return uuid; + }); +} +function checkCookie() { + const options = { + url: "https://me-api.jd.com/user_new/info/GetJDUserInfoUnion", + headers: { + "Host": "me-api.jd.com", + "Accept": "*/*", + "Connection": "keep-alive", + "Cookie": cookie, + "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.2 Mobile/15E148 Safari/604.1", + "Accept-Language": "zh-cn", + "Referer": "https://home.m.jd.com/myJd/newhome.action?sceneval=2&ufc=&", + "Accept-Encoding": "gzip, deflate, br", + } + }; + return new Promise(resolve => { + $.get(options, (err, resp, data) => { + try { + if (err) { + $.logErr(err) + } else { + if (data) { + data = JSON.parse(data); + if (data.retcode === "1001") { + $.isLogin = false; //cookie过期 + return; + } + if (data.retcode === "0" && data.data.hasOwnProperty("userInfo")) { + $.nickName = data.data.userInfo.baseInfo.nickname; + } + } else { + $.log('京东返回了空数据'); + } + } + } catch (e) { + $.logErr(e) + } finally { + resolve(); + } + }) + }) +} +// prettier-ignore +!function (n) { "use strict"; function t(n, t) { var r = (65535 & n) + (65535 & t); return (n >> 16) + (t >> 16) + (r >> 16) << 16 | 65535 & r } function r(n, t) { return n << t | n >>> 32 - t } function e(n, e, o, u, c, f) { return t(r(t(t(e, n), t(u, f)), c), o) } function o(n, t, r, o, u, c, f) { return e(t & r | ~t & o, n, t, u, c, f) } function u(n, t, r, o, u, c, f) { return e(t & o | r & ~o, n, t, u, c, f) } function c(n, t, r, o, u, c, f) { return e(t ^ r ^ o, n, t, u, c, f) } function f(n, t, r, o, u, c, f) { return e(r ^ (t | ~o), n, t, u, c, f) } function i(n, r) { n[r >> 5] |= 128 << r % 32, n[14 + (r + 64 >>> 9 << 4)] = r; var e, i, a, d, h, l = 1732584193, g = -271733879, v = -1732584194, m = 271733878; for (e = 0; e < n.length; e += 16)i = l, a = g, d = v, h = m, g = f(g = f(g = f(g = f(g = c(g = c(g = c(g = c(g = u(g = u(g = u(g = u(g = o(g = o(g = o(g = o(g, v = o(v, m = o(m, l = o(l, g, v, m, n[e], 7, -680876936), g, v, n[e + 1], 12, -389564586), l, g, n[e + 2], 17, 606105819), m, l, n[e + 3], 22, -1044525330), v = o(v, m = o(m, l = o(l, g, v, m, n[e + 4], 7, -176418897), g, v, n[e + 5], 12, 1200080426), l, g, n[e + 6], 17, -1473231341), m, l, n[e + 7], 22, -45705983), v = o(v, m = o(m, l = o(l, g, v, m, n[e + 8], 7, 1770035416), g, v, n[e + 9], 12, -1958414417), l, g, n[e + 10], 17, -42063), m, l, n[e + 11], 22, -1990404162), v = o(v, m = o(m, l = o(l, g, v, m, n[e + 12], 7, 1804603682), g, v, n[e + 13], 12, -40341101), l, g, n[e + 14], 17, -1502002290), m, l, n[e + 15], 22, 1236535329), v = u(v, m = u(m, l = u(l, g, v, m, n[e + 1], 5, -165796510), g, v, n[e + 6], 9, -1069501632), l, g, n[e + 11], 14, 643717713), m, l, n[e], 20, -373897302), v = u(v, m = u(m, l = u(l, g, v, m, n[e + 5], 5, -701558691), g, v, n[e + 10], 9, 38016083), l, g, n[e + 15], 14, -660478335), m, l, n[e + 4], 20, -405537848), v = u(v, m = u(m, l = u(l, g, v, m, n[e + 9], 5, 568446438), g, v, n[e + 14], 9, -1019803690), l, g, n[e + 3], 14, -187363961), m, l, n[e + 8], 20, 1163531501), v = u(v, m = u(m, l = u(l, g, v, m, n[e + 13], 5, -1444681467), g, v, n[e + 2], 9, -51403784), l, g, n[e + 7], 14, 1735328473), m, l, n[e + 12], 20, -1926607734), v = c(v, m = c(m, l = c(l, g, v, m, n[e + 5], 4, -378558), g, v, n[e + 8], 11, -2022574463), l, g, n[e + 11], 16, 1839030562), m, l, n[e + 14], 23, -35309556), v = c(v, m = c(m, l = c(l, g, v, m, n[e + 1], 4, -1530992060), g, v, n[e + 4], 11, 1272893353), l, g, n[e + 7], 16, -155497632), m, l, n[e + 10], 23, -1094730640), v = c(v, m = c(m, l = c(l, g, v, m, n[e + 13], 4, 681279174), g, v, n[e], 11, -358537222), l, g, n[e + 3], 16, -722521979), m, l, n[e + 6], 23, 76029189), v = c(v, m = c(m, l = c(l, g, v, m, n[e + 9], 4, -640364487), g, v, n[e + 12], 11, -421815835), l, g, n[e + 15], 16, 530742520), m, l, n[e + 2], 23, -995338651), v = f(v, m = f(m, l = f(l, g, v, m, n[e], 6, -198630844), g, v, n[e + 7], 10, 1126891415), l, g, n[e + 14], 15, -1416354905), m, l, n[e + 5], 21, -57434055), v = f(v, m = f(m, l = f(l, g, v, m, n[e + 12], 6, 1700485571), g, v, n[e + 3], 10, -1894986606), l, g, n[e + 10], 15, -1051523), m, l, n[e + 1], 21, -2054922799), v = f(v, m = f(m, l = f(l, g, v, m, n[e + 8], 6, 1873313359), g, v, n[e + 15], 10, -30611744), l, g, n[e + 6], 15, -1560198380), m, l, n[e + 13], 21, 1309151649), v = f(v, m = f(m, l = f(l, g, v, m, n[e + 4], 6, -145523070), g, v, n[e + 11], 10, -1120210379), l, g, n[e + 2], 15, 718787259), m, l, n[e + 9], 21, -343485551), l = t(l, i), g = t(g, a), v = t(v, d), m = t(m, h); return [l, g, v, m] } function a(n) { var t, r = "", e = 32 * n.length; for (t = 0; t < e; t += 8)r += String.fromCharCode(n[t >> 5] >>> t % 32 & 255); return r } function d(n) { var t, r = []; for (r[(n.length >> 2) - 1] = void 0, t = 0; t < r.length; t += 1)r[t] = 0; var e = 8 * n.length; for (t = 0; t < e; t += 8)r[t >> 5] |= (255 & n.charCodeAt(t / 8)) << t % 32; return r } function h(n) { return a(i(d(n), 8 * n.length)) } function l(n, t) { var r, e, o = d(n), u = [], c = []; for (u[15] = c[15] = void 0, o.length > 16 && (o = i(o, 8 * n.length)), r = 0; r < 16; r += 1)u[r] = 909522486 ^ o[r], c[r] = 1549556828 ^ o[r]; return e = i(u.concat(d(t)), 512 + 8 * t.length), a(i(c.concat(e), 640)) } function g(n) { var t, r, e = ""; for (r = 0; r < n.length; r += 1)t = n.charCodeAt(r), e += "0123456789abcdef".charAt(t >>> 4 & 15) + "0123456789abcdef".charAt(15 & t); return e } function v(n) { return unescape(encodeURIComponent(n)) } function m(n) { return h(v(n)) } function p(n) { return g(m(n)) } function s(n, t) { return l(v(n), v(t)) } function C(n, t) { return g(s(n, t)) } function A(n, t, r) { return t ? r ? s(t, n) : C(t, n) : r ? m(n) : p(n) } $.md5 = A }(this); +function Env(t, e) { "undefined" != typeof process && JSON.stringify(process.env).indexOf("GITHUB") > -1 && process.exit(0); class s { constructor(t) { this.env = t } send(t, e = "GET") { t = "string" == typeof t ? { url: t } : t; let s = this.get; return "POST" === e && (s = this.post), new Promise((e, i) => { s.call(this, t, (t, s, r) => { t ? i(t) : e(s) }) }) } get(t) { return this.send.call(this.env, t) } post(t) { return this.send.call(this.env, t, "POST") } } return new class { constructor(t, e) { this.name = t, this.http = new s(this), this.data = null, this.dataFile = "box.dat", this.logs = [], this.isMute = !1, this.isNeedRewrite = !1, this.logSeparator = "\n", this.startTime = (new Date).getTime(), Object.assign(this, e), this.log("", `🔔${this.name}, 开始!`) } isNode() { return "undefined" != typeof module && !!module.exports } isQuanX() { return "undefined" != typeof $task } isSurge() { return "undefined" != typeof $httpClient && "undefined" == typeof $loon } isLoon() { return "undefined" != typeof $loon } toObj(t, e = null) { try { return JSON.parse(t) } catch { return e } } toStr(t, e = null) { try { return JSON.stringify(t) } catch { return e } } getjson(t, e) { let s = e; const i = this.getdata(t); if (i) try { s = JSON.parse(this.getdata(t)) } catch { } return s } setjson(t, e) { try { return this.setdata(JSON.stringify(t), e) } catch { return !1 } } getScript(t) { return new Promise(e => { this.get({ url: t }, (t, s, i) => e(i)) }) } runScript(t, e) { return new Promise(s => { let i = this.getdata("@chavy_boxjs_userCfgs.httpapi"); i = i ? i.replace(/\n/g, "").trim() : i; let r = this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout"); r = r ? 1 * r : 20, r = e && e.timeout ? e.timeout : r; const [o, h] = i.split("@"), n = { url: `http://${h}/v1/scripting/evaluate`, body: { script_text: t, mock_type: "cron", timeout: r }, headers: { "X-Key": o, Accept: "*/*" } }; this.post(n, (t, e, i) => s(i)) }).catch(t => this.logErr(t)) } loaddata() { if (!this.isNode()) return {}; { this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path"); const t = this.path.resolve(this.dataFile), e = this.path.resolve(process.cwd(), this.dataFile), s = this.fs.existsSync(t), i = !s && this.fs.existsSync(e); if (!s && !i) return {}; { const i = s ? t : e; try { return JSON.parse(this.fs.readFileSync(i)) } catch (t) { return {} } } } } writedata() { if (this.isNode()) { this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path"); const t = this.path.resolve(this.dataFile), e = this.path.resolve(process.cwd(), this.dataFile), s = this.fs.existsSync(t), i = !s && this.fs.existsSync(e), r = JSON.stringify(this.data); s ? this.fs.writeFileSync(t, r) : i ? this.fs.writeFileSync(e, r) : this.fs.writeFileSync(t, r) } } lodash_get(t, e, s) { const i = e.replace(/\[(\d+)\]/g, ".$1").split("."); let r = t; for (const t of i) if (r = Object(r)[t], void 0 === r) return s; return r } lodash_set(t, e, s) { return Object(t) !== t ? t : (Array.isArray(e) || (e = e.toString().match(/[^.[\]]+/g) || []), e.slice(0, -1).reduce((t, s, i) => Object(t[s]) === t[s] ? t[s] : t[s] = Math.abs(e[i + 1]) >> 0 == +e[i + 1] ? [] : {}, t)[e[e.length - 1]] = s, t) } getdata(t) { let e = this.getval(t); if (/^@/.test(t)) { const [, s, i] = /^@(.*?)\.(.*?)$/.exec(t), r = s ? this.getval(s) : ""; if (r) try { const t = JSON.parse(r); e = t ? this.lodash_get(t, i, "") : e } catch (t) { e = "" } } return e } setdata(t, e) { let s = !1; if (/^@/.test(e)) { const [, i, r] = /^@(.*?)\.(.*?)$/.exec(e), o = this.getval(i), h = i ? "null" === o ? null : o || "{}" : "{}"; try { const e = JSON.parse(h); this.lodash_set(e, r, t), s = this.setval(JSON.stringify(e), i) } catch (e) { const o = {}; this.lodash_set(o, r, t), s = this.setval(JSON.stringify(o), i) } } else s = this.setval(t, e); return s } getval(t) { return this.isSurge() || this.isLoon() ? $persistentStore.read(t) : this.isQuanX() ? $prefs.valueForKey(t) : this.isNode() ? (this.data = this.loaddata(), this.data[t]) : this.data && this.data[t] || null } setval(t, e) { return this.isSurge() || this.isLoon() ? $persistentStore.write(t, e) : this.isQuanX() ? $prefs.setValueForKey(t, e) : this.isNode() ? (this.data = this.loaddata(), this.data[e] = t, this.writedata(), !0) : this.data && this.data[e] || null } initGotEnv(t) { this.got = this.got ? this.got : require("got"), this.cktough = this.cktough ? this.cktough : require("tough-cookie"), this.ckjar = this.ckjar ? this.ckjar : new this.cktough.CookieJar, t && (t.headers = t.headers ? t.headers : {}, void 0 === t.headers.Cookie && void 0 === t.cookieJar && (t.cookieJar = this.ckjar)) } get(t, e = (() => { })) { t.headers && (delete t.headers["Content-Type"], delete t.headers["Content-Length"]), this.isSurge() || this.isLoon() ? (this.isSurge() && this.isNeedRewrite && (t.headers = t.headers || {}, Object.assign(t.headers, { "X-Surge-Skip-Scripting": !1 })), $httpClient.get(t, (t, s, i) => { !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i) })) : this.isQuanX() ? (this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, { hints: !1 })), $task.fetch(t).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => e(t))) : this.isNode() && (this.initGotEnv(t), this.got(t).on("redirect", (t, e) => { try { if (t.headers["set-cookie"]) { const s = t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString(); s && this.ckjar.setCookieSync(s, null), e.cookieJar = this.ckjar } } catch (t) { this.logErr(t) } }).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => { const { message: s, response: i } = t; e(s, i, i && i.body) })) } post(t, e = (() => { })) { if (t.body && t.headers && !t.headers["Content-Type"] && (t.headers["Content-Type"] = "application/x-www-form-urlencoded"), t.headers && delete t.headers["Content-Length"], this.isSurge() || this.isLoon()) this.isSurge() && this.isNeedRewrite && (t.headers = t.headers || {}, Object.assign(t.headers, { "X-Surge-Skip-Scripting": !1 })), $httpClient.post(t, (t, s, i) => { !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i) }); else if (this.isQuanX()) t.method = "POST", this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, { hints: !1 })), $task.fetch(t).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => e(t)); else if (this.isNode()) { this.initGotEnv(t); const { url: s, ...i } = t; this.got.post(s, i).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => { const { message: s, response: i } = t; e(s, i, i && i.body) }) } } time(t, e = null) { const s = e ? new Date(e) : new Date; let i = { "M+": s.getMonth() + 1, "d+": s.getDate(), "H+": s.getHours(), "m+": s.getMinutes(), "s+": s.getSeconds(), "q+": Math.floor((s.getMonth() + 3) / 3), S: s.getMilliseconds() }; /(y+)/.test(t) && (t = t.replace(RegExp.$1, (s.getFullYear() + "").substr(4 - RegExp.$1.length))); for (let e in i) new RegExp("(" + e + ")").test(t) && (t = t.replace(RegExp.$1, 1 == RegExp.$1.length ? i[e] : ("00" + i[e]).substr(("" + i[e]).length))); return t } msg(e = t, s = "", i = "", r) { const o = t => { if (!t) return t; if ("string" == typeof t) return this.isLoon() ? t : this.isQuanX() ? { "open-url": t } : this.isSurge() ? { url: t } : void 0; if ("object" == typeof t) { if (this.isLoon()) { let e = t.openUrl || t.url || t["open-url"], s = t.mediaUrl || t["media-url"]; return { openUrl: e, mediaUrl: s } } if (this.isQuanX()) { let e = t["open-url"] || t.url || t.openUrl, s = t["media-url"] || t.mediaUrl; return { "open-url": e, "media-url": s } } if (this.isSurge()) { let e = t.url || t.openUrl || t["open-url"]; return { url: e } } } }; if (this.isMute || (this.isSurge() || this.isLoon() ? $notification.post(e, s, i, o(r)) : this.isQuanX() && $notify(e, s, i, o(r))), !this.isMuteLog) { let t = ["", "==============📣系统通知📣=============="]; t.push(e), s && t.push(s), i && t.push(i), console.log(t.join("\n")), this.logs = this.logs.concat(t) } } log(...t) { t.length > 0 && (this.logs = [...this.logs, ...t]), console.log(t.join(this.logSeparator)) } logErr(t, e) { const s = !this.isSurge() && !this.isQuanX() && !this.isLoon(); s ? this.log("", `❗️${this.name}, 错误!`, t.stack) : this.log("", `❗️${this.name}, 错误!`, t) } wait(t) { return new Promise(e => setTimeout(e, t)) } done(t = {}) { const e = (new Date).getTime(), s = (e - this.startTime) / 1e3; this.log("", `🔔${this.name}, 结束! 🕛 ${s} 秒`), this.log(), (this.isSurge() || this.isQuanX() || this.isLoon()) && $done(t) } }(t, e) } diff --git a/activity/jd_opencard5.js b/activity/jd_opencard5.js new file mode 100644 index 0000000..59f9660 --- /dev/null +++ b/activity/jd_opencard5.js @@ -0,0 +1,532 @@ +/* +时尚宠粉趴 +https://lzdz2-isv.isvjcloud.com/dingzhi/fashion/recruit/activity/13145?activityId=754da1fe6cc64146981ae7a9f2f1e727 + +cron 17 3,17 * * * https://raw.githubusercontent.com/KingRan/JDJB/main/jd_opencard5.js +**/ + +const $ = new Env("时尚宠粉趴"); +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const notify = $.isNode() ? require('./sendNotify') : ''; +let cookiesArr = [], cookie = '', message = ''; +let ownCode = null; +let authorCodeList = [] +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => { }; +} else { + let cookiesData = $.getdata('CookiesJD') || "[]"; + cookiesData = JSON.parse(cookiesData); + cookiesArr = cookiesData.map(item => item.cookie); + cookiesArr.reverse(); + cookiesArr.push(...[$.getdata('CookieJD2'), $.getdata('CookieJD')]); + cookiesArr.reverse(); + cookiesArr = cookiesArr.filter(item => !!item); +} +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', { "open-url": "https://bean.m.jd.com/bean/signIndex.action" }); + return; + } + authorCodeList = await getAuthorCodeList('https://gitee.com/KingRan521/JD-Scripts/raw/master/shareCodes/opencard5.json') + if(authorCodeList === '404: Not Found'){ + authorCodeList = [ + '754da1fe6cc64146981ae7a9f2f1e727', + ] + } + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i] + originCookie = cookiesArr[i] + newCookie = '' + $.UserName = decodeURIComponent(cookie.match(/pt_pin=(.+?);/) && cookie.match(/pt_pin=(.+?);/)[1]) + $.index = i + 1; + $.isLogin = true; + $.nickName = ''; + await checkCookie(); + console.log(`\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + if (!$.isLogin) { + console.log('更新ck'); + continue + } + // authorCodeList = [ + // 'b3b3f59c9015493a9d8e2f1d5d9b92ea', + // ] + $.bean = 0; + $.ADID = getUUID('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', 1); + $.UUID = getUUID('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'); + // $.authorCode = authorCodeList[random(0, authorCodeList.length)] + $.authorCode = ownCode ? ownCode : authorCodeList[random(0, authorCodeList.length)] + $.authorNum = `${random(1000000, 9999999)}` + $.activityId = '1ad06f0cb93e4928a894e3b984c2fa4b' + $.activityShopId = '59809' + $.activityUrl = `https://lzdz2-isv.isvjcloud.com/dingzhi/fashion/recruit/activity/${$.authorNum}?activityId=${$.activityId}&shareUuid=${encodeURIComponent($.authorCode)}&adsource=null&shareuserid4minipg=null&shopid=${$.activityShopId}&lng=00.000000&lat=00.000000&sid=&un_area=` + await rush(); + await $.wait(1000) + console.log("重复执行一次,技术有限不知道为什么") + await rush(); + if ($.bean > 0) { + message += `\n【京东账号${$.index}】${$.nickName || $.UserName} \n └ 获得 ${$.bean} 京豆。` + } + } + } + if (message !== '') { + if ($.isNode()) { + await notify.sendNotify($.name, message, '', `\n`); + } else { + $.msg($.name, '有点儿收获', message); + } + } +})() + .catch((e) => { + $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') + }) + .finally(() => { + $.done(); + }) + + +async function rush() { + $.token = null; + $.secretPin = null; + $.openCardActivityId = null + $.openStatusNum = 0 + await getFirstLZCK() + await getToken(); + await task('wxCommonInfo/getSystemConfigForNew', `activityId=${$.activityId}&activityType=99`, 1) + await task('dz/common/getSimpleActInfoVo', `activityId=${$.activityId}`, 1) + if ($.token) { + await getMyPing(); + if ($.secretPin) { + console.log("去助力: "+$.authorCode) + await $.wait(1000) + await task('common/accessLogWithAD', `venderId=${$.venderId}&code=99&pin=${encodeURIComponent($.secretPin)}&activityId=${$.activityId}&pageUrl=${$.activityUrl}&subType=app&adSource=null`, 1); + await task('wxActionCommon/getUserInfo', `pin=${encodeURIComponent($.secretPin)}`, 1) + await task('fashion/recruit/activityContent', `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}&pinImg=${encodeURIComponent($.pinImg)}&nick=${encodeURIComponent($.pin)}&cjyxPin=&cjhyPin=&shareUuid=${encodeURIComponent($.authorCode)}`) + await task("fashion/recruit/getInitInfo", `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}`) + await $.wait(1000) + await task('fashion/recruit/initOpenCard', `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}&shareUuid=${encodeURIComponent($.authorCode)}`) + if ($.activityContent) { + for(let i in $.openInfo){ + console.log($.openInfo[i]) + if(!$.openInfo[i]['openStatus']){ + console.log("加入会员: "+$.openInfo[i]['venderId']) + await getShopOpenCardInfo({ "venderId": $.openInfo[i]['venderId'], "channel": "401" }, $.openInfo[i]['venderId']) + await bindWithVender({ "venderId": $.openInfo[i]['venderId'], "bindByVerifyCodeFlag": 1, "registerExtend": {}, "writeChildFlag": 0, "activityId": $.openCardActivityId, "channel": 401 }, $.openInfo[i]['venderId']) + await $.wait(1000) + } + } + console.log("关注店铺: ") + await task("fashion/recruit/saveTask", `activityId=${$.activityId}&actorUuid=${encodeURIComponent($.actorUuid)}&shareUuid=${encodeURIComponent($.authorCode)}&pin=${encodeURIComponent($.secretPin)}&taskType=23&taskValue=23`) + await $.wait(1000) + console.log("流览会场: ") + await task("fashion/recruit/saveTask", `activityId=${$.activityId}&actorUuid=${encodeURIComponent($.actorUuid)}&shareUuid=${encodeURIComponent($.authorCode)}&pin=${encodeURIComponent($.secretPin)}&taskType=12&taskValue=12`) + } + await task("fashion/recruit/getInitInfo", `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}`) + } else { + $.log("没有成功获取到用户信息") + } + } else { + $.log("没有成功获取到用户鉴权信息") + } +} + +function task(function_id, body, isCommon = 0) { + return new Promise(resolve => { + $.post(taskUrl(function_id, body, isCommon), async (err, resp, data) => { + try { + if (err) { + $.log(err) + } else { + + if (data) { + data = JSON.parse(data); + if (data.result) { + switch (function_id) { + case 'dz/common/getSimpleActInfoVo': + $.jdActivityId = data.data.jdActivityId; + $.venderId = data.data.venderId; + $.activityShopId = data.data.shopId; + $.activityType = data.data.activityType; + break; + case 'wxActionCommon/getUserInfo': + $.pinImg = 'https://img10.360buyimg.com/imgzone/jfs/t1/7020/27/13511/6142/5c5138d8E4df2e764/5a1216a3a5043c5d.png' + break; + case 'fashion/recruit/activityContent': + if (!data.data.hasEnd) { + $.log(`开启【${data.data.activityName}】活动`) + $.log("-------------------") + if ($.index === 1) { + ownCode = data.data.actorUuid + console.log("你的助力码 -> "+ownCode) + } + $.activityContent = data.data; + $.actorUuid = data.data.actorUuid; + } else { + $.log("活动已经结束"); + } + break; + case 'fashion/recruit/saveFirst': + if(data.result){ + console.log("获得抽奖次数") + } + break; + case 'fashion/recruit/saveTask': + console.log(data) + break; + case 'fashion/recruit/getInitInfo': + console.log(data) + break; + case 'fashion/recruit/initOpenCard': + $.openInfo = data.data.openInfo + break; + default: + $.log(JSON.stringify(data)) + break; + } + } else { + $.log(JSON.stringify(data)) + } + } else { + $.log("京东没有返回数据") + } + } + } catch (error) { + $.log(error) + } finally { + resolve(); + } + }) + }) +} +function getShopOpenCardInfo(body, venderId) { + let opt = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body=${encodeURIComponent(JSON.stringify(body))}&client=H5&clientVersion=9.2.0&uuid=88888`, + headers: { + Host: 'api.m.jd.com', + Accept: '*/*', + Connection: 'keep-alive', + Cookie: cookie, + 'User-Agent': `jdapp;iPhone;9.5.4;13.6;${$.UUID};network/wifi;ADID/${$.ADID};model/iPhone10,3;addressid/0;appBuild/167668;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1`, + 'Accept-Language': 'zh-cn', + Referer: `https://shopmember.m.jd.com/shopcard/?venderId=${venderId}}&channel=801&returnUrl=${encodeURIComponent($.activityUrl)}`, + 'Accept-Encoding': 'gzip, deflate, br' + } + } + return new Promise(resolve => { + $.get(opt, (err, resp, data) => { + try { + if (err) { + console.log(err) + } else { + res = JSON.parse(data) + if (res.success) { + if (res.result.interestsRuleList) { + $.openCardActivityId = res.result.interestsRuleList[0].interestsInfo.activityId; + } + } + } + } catch (error) { + console.log(error) + } finally { + resolve(); + } + }) + + }) +} +function bindWithVender(body, venderId) { + let opt = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body=${encodeURIComponent(JSON.stringify(body))}&client=H5&clientVersion=9.2.0&uuid=88888`, + headers: { + Host: 'api.m.jd.com', + Accept: '*/*', + Connection: 'keep-alive', + Cookie: cookie, + 'User-Agent': `jdapp;iPhone;9.5.4;13.6;${$.UUID};network/wifi;ADID/${$.ADID};model/iPhone10,3;addressid/0;appBuild/167668;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1`, + 'Accept-Language': 'zh-cn', + Referer: `https://shopmember.m.jd.com/shopcard/?venderId=${venderId}}&channel=801&returnUrl=${encodeURIComponent($.activityUrl)}`, + 'Accept-Encoding': 'gzip, deflate, br' + } + } + return new Promise(resolve => { + $.get(opt, (err, resp, data) => { + try { + if (err) { + console.log(err) + } else { + res = JSON.parse(data) + if (res.success) { + if (res.result.giftInfo && res.result.giftInfo.giftList) { + for (const vo of res.result.giftInfo.giftList) { + if (vo.prizeType === 4) { + $.log(`获得【${vo.quantity}】京豆`) + $.bean += vo.quantity + } + } + } + } + } + } catch (error) { + console.log(error) + } finally { + resolve(); + } + }) + + }) +} +function taskUrl(function_id, body, isCommon) { + return { + url: isCommon ? `https://lzdz2-isv.isvjcloud.com/${function_id}` : `https://lzdz2-isv.isvjcloud.com/dingzhi/${function_id}`, + headers: { + Host: 'lzdz2-isv.isvjcloud.com', + Accept: 'application/json', + 'X-Requested-With': 'XMLHttpRequest', + 'Accept-Language': 'zh-cn', + 'Accept-Encoding': 'gzip, deflate, br', + 'Content-Type': 'application/x-www-form-urlencoded', + Origin: 'https://lzdz2-isv.isvjcloud.com', + 'User-Agent': `jdapp;iPhone;9.5.4;13.6;${$.UUID};network/wifi;ADID/${$.ADID};model/iPhone10,3;addressid/0;appBuild/167668;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1`, + Connection: 'keep-alive', + Referer: $.activityUrl, + Cookie: cookie + }, + body: body + + } +} +function getAuthorCodeList(url) { + return new Promise(resolve => { + const options = { + url: `${url}?${new Date()}`, "timeout": 10000, headers: { + "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1 Edg/87.0.4280.88" + } + }; + $.get(options, async (err, resp, data) => { + try { + if (err) { + $.log(err) + } else { + if (data) data = JSON.parse(data) + } + } catch (e) { + $.logErr(e, resp) + data = null; + } finally { + resolve(data); + } + }) + }) +} +function getMyPing() { + let opt = { + url: `https://lzdz2-isv.isvjcloud.com/customer/getMyPing`, + headers: { + Host: 'lzdz2-isv.isvjcloud.com', + Accept: 'application/json', + 'X-Requested-With': 'XMLHttpRequest', + 'Accept-Language': 'zh-cn', + 'Accept-Encoding': 'gzip, deflate, br', + 'Content-Type': 'application/x-www-form-urlencoded', + Origin: 'https://lzdz2-isv.isvjcloud.com', + 'User-Agent': `jdapp;iPhone;9.5.4;13.6;${$.UUID};network/wifi;ADID/${$.ADID};model/iPhone10,3;addressid/0;appBuild/167668;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1`, + Connection: 'keep-alive', + Referer: $.activityUrl, + Cookie: cookie, + }, + body: `userId=${$.venderId}&token=${$.token}&fromType=APP` + } + return new Promise(resolve => { + $.post(opt, (err, resp, data) => { + try { + if (err) { + $.log(err) + } else { + if (resp['headers']['set-cookie']) { + cookie = `${originCookie}` + if ($.isNode()) { + for (let sk of resp['headers']['set-cookie']) { + cookie = `${cookie}${sk.split(";")[0]};` + } + } else { + for (let ck of resp['headers']['Set-Cookie'].split(',')) { + cookie = `${cookie}${ck.split(";")[0]};` + } + } + } + if (resp['headers']['Set-Cookie']) { + cookie = `${originCookie}` + if ($.isNode()) { + for (let sk of resp['headers']['set-cookie']) { + cookie = `${cookie}${sk.split(";")[0]};` + } + } else { + for (let ck of resp['headers']['Set-Cookie'].split(',')) { + cookie = `${cookie}${ck.split(";")[0]};` + } + } + } + if (data) { + data = JSON.parse(data) + if (data.result) { + $.log(`你好:${data.data.nickname}`) + $.pin = data.data.nickname; + $.secretPin = data.data.secretPin; + cookie = `${cookie};AUTH_C_USER=${data.data.secretPin}` + } else { + $.log(data.errorMessage) + } + } else { + $.log("京东返回了空数据") + } + } + } catch (error) { + $.log(error) + } finally { + resolve(); + } + + }) + }) +} +function getFirstLZCK() { + return new Promise(resolve => { + $.get({ url: $.activityUrl }, (err, resp, data) => { + try { + if (err) { + console.log(err) + } else { + if (resp['headers']['set-cookie']) { + cookie = `${originCookie}` + if ($.isNode()) { + for (let sk of resp['headers']['set-cookie']) { + cookie = `${cookie}${sk.split(";")[0]};` + } + } else { + for (let ck of resp['headers']['Set-Cookie'].split(',')) { + cookie = `${cookie}${ck.split(";")[0]};` + } + } + } + if (resp['headers']['Set-Cookie']) { + cookie = `${originCookie}` + if ($.isNode()) { + for (let sk of resp['headers']['set-cookie']) { + cookie = `${cookie}${sk.split(";")[0]};` + } + } else { + for (let ck of resp['headers']['Set-Cookie'].split(',')) { + cookie = `${cookie}${ck.split(";")[0]};` + } + } + } + } + } catch (error) { + console.log(error) + } finally { + resolve(); + } + }) + }) +} +function getToken() { + let opt = { + url: `https://api.m.jd.com/client.action?functionId=isvObfuscator`, + headers: { + Host: 'api.m.jd.com', + 'Content-Type': 'application/x-www-form-urlencoded', + Accept: '*/*', + Connection: 'keep-alive', + Cookie: cookie, + 'User-Agent': 'JD4iPhone/167650 (iPhone; iOS 13.7; Scale/3.00)', + 'Accept-Language': 'zh-Hans-CN;q=1', + 'Accept-Encoding': 'gzip, deflate, br', + }, + body: `body=%7B%22url%22%3A%20%22https%3A//lzkj-isv.isvjcloud.com%22%2C%20%22id%22%3A%20%22%22%7D&uuid=hjudwgohxzVu96krv&client=apple&clientVersion=9.4.0&st=1620476162000&sv=111&sign=f9d1b7e3b943b6a136d54fe4f892af05` + } + return new Promise(resolve => { + $.post(opt, (err, resp, data) => { + try { + if (err) { + $.log(err) + } else { + if (data) { + data = JSON.parse(data); + if (data.code === "0") { + $.token = data.token + } + } else { + $.log("京东返回了空数据") + } + } + } catch (error) { + $.log(error) + } finally { + resolve(); + } + }) + }) +} +function random(min, max) { + + return Math.floor(Math.random() * (max - min)) + min; + +} +function getUUID(format = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', UpperCase = 0) { + return format.replace(/[xy]/g, function (c) { + var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8); + if (UpperCase) { + uuid = v.toString(36).toUpperCase(); + } else { + uuid = v.toString(36) + } + return uuid; + }); +} +function checkCookie() { + const options = { + url: "https://me-api.jd.com/user_new/info/GetJDUserInfoUnion", + headers: { + "Host": "me-api.jd.com", + "Accept": "*/*", + "Connection": "keep-alive", + "Cookie": cookie, + "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.2 Mobile/15E148 Safari/604.1", + "Accept-Language": "zh-cn", + "Referer": "https://home.m.jd.com/myJd/newhome.action?sceneval=2&ufc=&", + "Accept-Encoding": "gzip, deflate, br", + } + }; + return new Promise(resolve => { + $.get(options, (err, resp, data) => { + try { + if (err) { + $.logErr(err) + } else { + if (data) { + data = JSON.parse(data); + if (data.retcode === "1001") { + $.isLogin = false; //cookie过期 + return; + } + if (data.retcode === "0" && data.data.hasOwnProperty("userInfo")) { + $.nickName = data.data.userInfo.baseInfo.nickname; + } + } else { + $.log('京东返回了空数据'); + } + } + } catch (e) { + $.logErr(e) + } finally { + resolve(); + } + }) + }) +} +// prettier-ignore +!function (n) { "use strict"; function t(n, t) { var r = (65535 & n) + (65535 & t); return (n >> 16) + (t >> 16) + (r >> 16) << 16 | 65535 & r } function r(n, t) { return n << t | n >>> 32 - t } function e(n, e, o, u, c, f) { return t(r(t(t(e, n), t(u, f)), c), o) } function o(n, t, r, o, u, c, f) { return e(t & r | ~t & o, n, t, u, c, f) } function u(n, t, r, o, u, c, f) { return e(t & o | r & ~o, n, t, u, c, f) } function c(n, t, r, o, u, c, f) { return e(t ^ r ^ o, n, t, u, c, f) } function f(n, t, r, o, u, c, f) { return e(r ^ (t | ~o), n, t, u, c, f) } function i(n, r) { n[r >> 5] |= 128 << r % 32, n[14 + (r + 64 >>> 9 << 4)] = r; var e, i, a, d, h, l = 1732584193, g = -271733879, v = -1732584194, m = 271733878; for (e = 0; e < n.length; e += 16)i = l, a = g, d = v, h = m, g = f(g = f(g = f(g = f(g = c(g = c(g = c(g = c(g = u(g = u(g = u(g = u(g = o(g = o(g = o(g = o(g, v = o(v, m = o(m, l = o(l, g, v, m, n[e], 7, -680876936), g, v, n[e + 1], 12, -389564586), l, g, n[e + 2], 17, 606105819), m, l, n[e + 3], 22, -1044525330), v = o(v, m = o(m, l = o(l, g, v, m, n[e + 4], 7, -176418897), g, v, n[e + 5], 12, 1200080426), l, g, n[e + 6], 17, -1473231341), m, l, n[e + 7], 22, -45705983), v = o(v, m = o(m, l = o(l, g, v, m, n[e + 8], 7, 1770035416), g, v, n[e + 9], 12, -1958414417), l, g, n[e + 10], 17, -42063), m, l, n[e + 11], 22, -1990404162), v = o(v, m = o(m, l = o(l, g, v, m, n[e + 12], 7, 1804603682), g, v, n[e + 13], 12, -40341101), l, g, n[e + 14], 17, -1502002290), m, l, n[e + 15], 22, 1236535329), v = u(v, m = u(m, l = u(l, g, v, m, n[e + 1], 5, -165796510), g, v, n[e + 6], 9, -1069501632), l, g, n[e + 11], 14, 643717713), m, l, n[e], 20, -373897302), v = u(v, m = u(m, l = u(l, g, v, m, n[e + 5], 5, -701558691), g, v, n[e + 10], 9, 38016083), l, g, n[e + 15], 14, -660478335), m, l, n[e + 4], 20, -405537848), v = u(v, m = u(m, l = u(l, g, v, m, n[e + 9], 5, 568446438), g, v, n[e + 14], 9, -1019803690), l, g, n[e + 3], 14, -187363961), m, l, n[e + 8], 20, 1163531501), v = u(v, m = u(m, l = u(l, g, v, m, n[e + 13], 5, -1444681467), g, v, n[e + 2], 9, -51403784), l, g, n[e + 7], 14, 1735328473), m, l, n[e + 12], 20, -1926607734), v = c(v, m = c(m, l = c(l, g, v, m, n[e + 5], 4, -378558), g, v, n[e + 8], 11, -2022574463), l, g, n[e + 11], 16, 1839030562), m, l, n[e + 14], 23, -35309556), v = c(v, m = c(m, l = c(l, g, v, m, n[e + 1], 4, -1530992060), g, v, n[e + 4], 11, 1272893353), l, g, n[e + 7], 16, -155497632), m, l, n[e + 10], 23, -1094730640), v = c(v, m = c(m, l = c(l, g, v, m, n[e + 13], 4, 681279174), g, v, n[e], 11, -358537222), l, g, n[e + 3], 16, -722521979), m, l, n[e + 6], 23, 76029189), v = c(v, m = c(m, l = c(l, g, v, m, n[e + 9], 4, -640364487), g, v, n[e + 12], 11, -421815835), l, g, n[e + 15], 16, 530742520), m, l, n[e + 2], 23, -995338651), v = f(v, m = f(m, l = f(l, g, v, m, n[e], 6, -198630844), g, v, n[e + 7], 10, 1126891415), l, g, n[e + 14], 15, -1416354905), m, l, n[e + 5], 21, -57434055), v = f(v, m = f(m, l = f(l, g, v, m, n[e + 12], 6, 1700485571), g, v, n[e + 3], 10, -1894986606), l, g, n[e + 10], 15, -1051523), m, l, n[e + 1], 21, -2054922799), v = f(v, m = f(m, l = f(l, g, v, m, n[e + 8], 6, 1873313359), g, v, n[e + 15], 10, -30611744), l, g, n[e + 6], 15, -1560198380), m, l, n[e + 13], 21, 1309151649), v = f(v, m = f(m, l = f(l, g, v, m, n[e + 4], 6, -145523070), g, v, n[e + 11], 10, -1120210379), l, g, n[e + 2], 15, 718787259), m, l, n[e + 9], 21, -343485551), l = t(l, i), g = t(g, a), v = t(v, d), m = t(m, h); return [l, g, v, m] } function a(n) { var t, r = "", e = 32 * n.length; for (t = 0; t < e; t += 8)r += String.fromCharCode(n[t >> 5] >>> t % 32 & 255); return r } function d(n) { var t, r = []; for (r[(n.length >> 2) - 1] = void 0, t = 0; t < r.length; t += 1)r[t] = 0; var e = 8 * n.length; for (t = 0; t < e; t += 8)r[t >> 5] |= (255 & n.charCodeAt(t / 8)) << t % 32; return r } function h(n) { return a(i(d(n), 8 * n.length)) } function l(n, t) { var r, e, o = d(n), u = [], c = []; for (u[15] = c[15] = void 0, o.length > 16 && (o = i(o, 8 * n.length)), r = 0; r < 16; r += 1)u[r] = 909522486 ^ o[r], c[r] = 1549556828 ^ o[r]; return e = i(u.concat(d(t)), 512 + 8 * t.length), a(i(c.concat(e), 640)) } function g(n) { var t, r, e = ""; for (r = 0; r < n.length; r += 1)t = n.charCodeAt(r), e += "0123456789abcdef".charAt(t >>> 4 & 15) + "0123456789abcdef".charAt(15 & t); return e } function v(n) { return unescape(encodeURIComponent(n)) } function m(n) { return h(v(n)) } function p(n) { return g(m(n)) } function s(n, t) { return l(v(n), v(t)) } function C(n, t) { return g(s(n, t)) } function A(n, t, r) { return t ? r ? s(t, n) : C(t, n) : r ? m(n) : p(n) } $.md5 = A }(this); +function Env(t, e) { "undefined" != typeof process && JSON.stringify(process.env).indexOf("GITHUB") > -1 && process.exit(0); class s { constructor(t) { this.env = t } send(t, e = "GET") { t = "string" == typeof t ? { url: t } : t; let s = this.get; return "POST" === e && (s = this.post), new Promise((e, i) => { s.call(this, t, (t, s, r) => { t ? i(t) : e(s) }) }) } get(t) { return this.send.call(this.env, t) } post(t) { return this.send.call(this.env, t, "POST") } } return new class { constructor(t, e) { this.name = t, this.http = new s(this), this.data = null, this.dataFile = "box.dat", this.logs = [], this.isMute = !1, this.isNeedRewrite = !1, this.logSeparator = "\n", this.startTime = (new Date).getTime(), Object.assign(this, e), this.log("", `🔔${this.name}, 开始!`) } isNode() { return "undefined" != typeof module && !!module.exports } isQuanX() { return "undefined" != typeof $task } isSurge() { return "undefined" != typeof $httpClient && "undefined" == typeof $loon } isLoon() { return "undefined" != typeof $loon } toObj(t, e = null) { try { return JSON.parse(t) } catch { return e } } toStr(t, e = null) { try { return JSON.stringify(t) } catch { return e } } getjson(t, e) { let s = e; const i = this.getdata(t); if (i) try { s = JSON.parse(this.getdata(t)) } catch { } return s } setjson(t, e) { try { return this.setdata(JSON.stringify(t), e) } catch { return !1 } } getScript(t) { return new Promise(e => { this.get({ url: t }, (t, s, i) => e(i)) }) } runScript(t, e) { return new Promise(s => { let i = this.getdata("@chavy_boxjs_userCfgs.httpapi"); i = i ? i.replace(/\n/g, "").trim() : i; let r = this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout"); r = r ? 1 * r : 20, r = e && e.timeout ? e.timeout : r; const [o, h] = i.split("@"), n = { url: `http://${h}/v1/scripting/evaluate`, body: { script_text: t, mock_type: "cron", timeout: r }, headers: { "X-Key": o, Accept: "*/*" } }; this.post(n, (t, e, i) => s(i)) }).catch(t => this.logErr(t)) } loaddata() { if (!this.isNode()) return {}; { this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path"); const t = this.path.resolve(this.dataFile), e = this.path.resolve(process.cwd(), this.dataFile), s = this.fs.existsSync(t), i = !s && this.fs.existsSync(e); if (!s && !i) return {}; { const i = s ? t : e; try { return JSON.parse(this.fs.readFileSync(i)) } catch (t) { return {} } } } } writedata() { if (this.isNode()) { this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path"); const t = this.path.resolve(this.dataFile), e = this.path.resolve(process.cwd(), this.dataFile), s = this.fs.existsSync(t), i = !s && this.fs.existsSync(e), r = JSON.stringify(this.data); s ? this.fs.writeFileSync(t, r) : i ? this.fs.writeFileSync(e, r) : this.fs.writeFileSync(t, r) } } lodash_get(t, e, s) { const i = e.replace(/\[(\d+)\]/g, ".$1").split("."); let r = t; for (const t of i) if (r = Object(r)[t], void 0 === r) return s; return r } lodash_set(t, e, s) { return Object(t) !== t ? t : (Array.isArray(e) || (e = e.toString().match(/[^.[\]]+/g) || []), e.slice(0, -1).reduce((t, s, i) => Object(t[s]) === t[s] ? t[s] : t[s] = Math.abs(e[i + 1]) >> 0 == +e[i + 1] ? [] : {}, t)[e[e.length - 1]] = s, t) } getdata(t) { let e = this.getval(t); if (/^@/.test(t)) { const [, s, i] = /^@(.*?)\.(.*?)$/.exec(t), r = s ? this.getval(s) : ""; if (r) try { const t = JSON.parse(r); e = t ? this.lodash_get(t, i, "") : e } catch (t) { e = "" } } return e } setdata(t, e) { let s = !1; if (/^@/.test(e)) { const [, i, r] = /^@(.*?)\.(.*?)$/.exec(e), o = this.getval(i), h = i ? "null" === o ? null : o || "{}" : "{}"; try { const e = JSON.parse(h); this.lodash_set(e, r, t), s = this.setval(JSON.stringify(e), i) } catch (e) { const o = {}; this.lodash_set(o, r, t), s = this.setval(JSON.stringify(o), i) } } else s = this.setval(t, e); return s } getval(t) { return this.isSurge() || this.isLoon() ? $persistentStore.read(t) : this.isQuanX() ? $prefs.valueForKey(t) : this.isNode() ? (this.data = this.loaddata(), this.data[t]) : this.data && this.data[t] || null } setval(t, e) { return this.isSurge() || this.isLoon() ? $persistentStore.write(t, e) : this.isQuanX() ? $prefs.setValueForKey(t, e) : this.isNode() ? (this.data = this.loaddata(), this.data[e] = t, this.writedata(), !0) : this.data && this.data[e] || null } initGotEnv(t) { this.got = this.got ? this.got : require("got"), this.cktough = this.cktough ? this.cktough : require("tough-cookie"), this.ckjar = this.ckjar ? this.ckjar : new this.cktough.CookieJar, t && (t.headers = t.headers ? t.headers : {}, void 0 === t.headers.Cookie && void 0 === t.cookieJar && (t.cookieJar = this.ckjar)) } get(t, e = (() => { })) { t.headers && (delete t.headers["Content-Type"], delete t.headers["Content-Length"]), this.isSurge() || this.isLoon() ? (this.isSurge() && this.isNeedRewrite && (t.headers = t.headers || {}, Object.assign(t.headers, { "X-Surge-Skip-Scripting": !1 })), $httpClient.get(t, (t, s, i) => { !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i) })) : this.isQuanX() ? (this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, { hints: !1 })), $task.fetch(t).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => e(t))) : this.isNode() && (this.initGotEnv(t), this.got(t).on("redirect", (t, e) => { try { if (t.headers["set-cookie"]) { const s = t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString(); s && this.ckjar.setCookieSync(s, null), e.cookieJar = this.ckjar } } catch (t) { this.logErr(t) } }).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => { const { message: s, response: i } = t; e(s, i, i && i.body) })) } post(t, e = (() => { })) { if (t.body && t.headers && !t.headers["Content-Type"] && (t.headers["Content-Type"] = "application/x-www-form-urlencoded"), t.headers && delete t.headers["Content-Length"], this.isSurge() || this.isLoon()) this.isSurge() && this.isNeedRewrite && (t.headers = t.headers || {}, Object.assign(t.headers, { "X-Surge-Skip-Scripting": !1 })), $httpClient.post(t, (t, s, i) => { !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i) }); else if (this.isQuanX()) t.method = "POST", this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, { hints: !1 })), $task.fetch(t).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => e(t)); else if (this.isNode()) { this.initGotEnv(t); const { url: s, ...i } = t; this.got.post(s, i).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => { const { message: s, response: i } = t; e(s, i, i && i.body) }) } } time(t, e = null) { const s = e ? new Date(e) : new Date; let i = { "M+": s.getMonth() + 1, "d+": s.getDate(), "H+": s.getHours(), "m+": s.getMinutes(), "s+": s.getSeconds(), "q+": Math.floor((s.getMonth() + 3) / 3), S: s.getMilliseconds() }; /(y+)/.test(t) && (t = t.replace(RegExp.$1, (s.getFullYear() + "").substr(4 - RegExp.$1.length))); for (let e in i) new RegExp("(" + e + ")").test(t) && (t = t.replace(RegExp.$1, 1 == RegExp.$1.length ? i[e] : ("00" + i[e]).substr(("" + i[e]).length))); return t } msg(e = t, s = "", i = "", r) { const o = t => { if (!t) return t; if ("string" == typeof t) return this.isLoon() ? t : this.isQuanX() ? { "open-url": t } : this.isSurge() ? { url: t } : void 0; if ("object" == typeof t) { if (this.isLoon()) { let e = t.openUrl || t.url || t["open-url"], s = t.mediaUrl || t["media-url"]; return { openUrl: e, mediaUrl: s } } if (this.isQuanX()) { let e = t["open-url"] || t.url || t.openUrl, s = t["media-url"] || t.mediaUrl; return { "open-url": e, "media-url": s } } if (this.isSurge()) { let e = t.url || t.openUrl || t["open-url"]; return { url: e } } } }; if (this.isMute || (this.isSurge() || this.isLoon() ? $notification.post(e, s, i, o(r)) : this.isQuanX() && $notify(e, s, i, o(r))), !this.isMuteLog) { let t = ["", "==============📣系统通知📣=============="]; t.push(e), s && t.push(s), i && t.push(i), console.log(t.join("\n")), this.logs = this.logs.concat(t) } } log(...t) { t.length > 0 && (this.logs = [...this.logs, ...t]), console.log(t.join(this.logSeparator)) } logErr(t, e) { const s = !this.isSurge() && !this.isQuanX() && !this.isLoon(); s ? this.log("", `❗️${this.name}, 错误!`, t.stack) : this.log("", `❗️${this.name}, 错误!`, t) } wait(t) { return new Promise(e => setTimeout(e, t)) } done(t = {}) { const e = (new Date).getTime(), s = (e - this.startTime) / 1e3; this.log("", `🔔${this.name}, 结束! 🕛 ${s} 秒`), this.log(), (this.isSurge() || this.isQuanX() || this.isLoon()) && $done(t) } }(t, e) } diff --git a/activity/jd_opencard55.js b/activity/jd_opencard55.js new file mode 100644 index 0000000..82230eb --- /dev/null +++ b/activity/jd_opencard55.js @@ -0,0 +1,620 @@ +/* +11.1~11.11 联合开卡 [gua_opencard55.js] +新增开卡脚本 +一次性脚本 + +1.邀请一人20豆(有可能没有豆 +2.开17张 成功开1张 可能获得5京豆 + 全部开完获得1次抽奖 +3.关注10京豆 获得1次抽奖 +4.加购5京豆 获得1次抽奖(默认不加购 如需加购请设置环境变量[guaopencard_addSku55]为"true" +5.抽奖 (默认不抽奖 如需抽奖请设置环境变量[guaopencard_draw55]为"3" +填写要抽奖的次数 不足已自身次数为准 +guaopencard_draw55="3" +填非数字会全都抽奖 + +第一个账号助力作者 其他依次助力CK1 +第一个CK失效会退出脚本 + +默认脚本不执行 +如需执行脚本请设置环境变量 +guaopencard55="true" +每个账号之间延迟 100=延迟100秒 0=延迟0秒会使用每3个账号延迟60秒 +guaopenwait_All 所有 +guaopenwait55="0" + + +All变量适用 +———————————————— +入口:[ 11.1~11.11 联合开卡 (https://3.cn/103-i8Nva)] + +请求太频繁会被黑ip +过10分钟再执行 + +12:/#X4fjm5t5xaVYeJ@ + +============Quantumultx=============== +[task_local] +#11.1~11.11 联合开卡 +47 6 1-11 11 * https://raw.githubusercontent.com/smiek2121/scripts/master/gua_opencard55.js, tag=11.1~11.11 联合开卡, enabled=true + +*/ +let guaopencard_addSku = "false" +let guaopencard = "false" +let guaopenwait = "0" +let guaopencard_draw = "0" + +const $ = new Env('11.1~11.11 联合开卡'); +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const notify = $.isNode() ? require('./sendNotify') : ''; +let cleanCart = '' +if($.isNode()){ + try{ + const fs = require('fs'); + if (fs.existsSync('./cleancart_activity.js')) { + cleanCart = require('./cleancart_activity'); + } + }catch(e){ + } +} +//IOS等用户直接用NobyDa的jd cookie +let cookiesArr = [], + cookie = ''; +if ($.isNode()) { + console.log('添加瓜佬开卡脚本,请在配置文件填入下方所有变量') + console.log('export guaopencard_All="true" # 青蛙开卡总开关') + console.log('export guaopencard_addSku_All="false" # 青蛙开卡加购') + console.log('export guaopencardRun_All="true" # 青蛙开卡做任务') + console.log('export guaopencard_draw="true" # 青蛙开卡抽奖') + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} + +guaopencard_addSku = $.isNode() ? (process.env.guaopencard_addSku55 ? process.env.guaopencard_addSku55 : `${guaopencard_addSku}`) : ($.getdata('guaopencard_addSku55') ? $.getdata('guaopencard_addSku55') : `${guaopencard_addSku}`); +guaopencard_addSku = $.isNode() ? (process.env.guaopencard_addSku_All ? process.env.guaopencard_addSku_All : `${guaopencard_addSku}`) : ($.getdata('guaopencard_addSku_All') ? $.getdata('guaopencard_addSku_All') : `${guaopencard_addSku}`); +guaopencard = $.isNode() ? (process.env.guaopencard55 ? process.env.guaopencard55 : `${guaopencard}`) : ($.getdata('guaopencard55') ? $.getdata('guaopencard55') : `${guaopencard}`); +guaopencard = $.isNode() ? (process.env.guaopencard_All ? process.env.guaopencard_All : `${guaopencard}`) : ($.getdata('guaopencard_All') ? $.getdata('guaopencard_All') : `${guaopencard}`); +guaopenwait = $.isNode() ? (process.env.guaopenwait55 ? process.env.guaopenwait55 : `${guaopenwait}`) : ($.getdata('guaopenwait55') ? $.getdata('guaopenwait55') : `${guaopenwait}`); +guaopenwait = $.isNode() ? (process.env.guaopenwait_All ? process.env.guaopenwait_All : `${guaopenwait}`) : ($.getdata('guaopenwait_All') ? $.getdata('guaopenwait_All') : `${guaopenwait}`); +guaopenwait = parseInt(guaopenwait, 10) || 0 +guaopencard_draw = $.isNode() ? (process.env.guaopencard_draw55 ? process.env.guaopencard_draw55 : guaopencard_draw) : ($.getdata('guaopencard_draw55') ? $.getdata('guaopencard_draw55') : guaopencard_draw); +guaopencard_draw = $.isNode() ? (process.env.guaopencard_draw ? process.env.guaopencard_draw : guaopencard_draw) : ($.getdata('guaopencard_draw') ? $.getdata('guaopencard_draw') : guaopencard_draw); +guaopenwait = parseInt(guaopenwait, 10) || 0 +allMessage = "" +message = "" +$.hotFlag = false +$.outFlag = false +$.activityEnd = false +let lz_jdpin_token_cookie ='' +let activityCookie ='' +!(async () => { + if ($.isNode()) { + if(guaopencard+"" != "true"){ + console.log('如需执行脚本请设置环境变量[guaopencard55]为"true"') + } + if(guaopencard+"" != "true"){ + return + } + } + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', { + "open-url": "https://bean.m.jd.com/" + }); + return; + } + // return + $.appkey = '51B59BB805903DA4CE513D29EC448375' + $.userId = '10299171' + $.actId = '5256d57baccc480f94_11012' + $.MixNicks = '' + $.inviteNick = 'k1Nobb+P0er+C2sysxnx/P2KELO9izRVpwCyqu0eqVZ5aW7RHzlMobrzJ/e9r/uf' + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i]; + if (cookie) { + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + message = "" + $.bean = 0 + $.hotFlag = false + $.nickName = ''; + console.log(`\n\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + await getUA() + await run(); + if(i == 0 && !$.MixNick) break + if($.outFlag || $.activityEnd) break + } + } + if($.outFlag) { + let msg = '此ip已被限制,请过10分钟后再执行脚本' + $.msg($.name, ``, `${msg}`); + if ($.isNode()) await notify.sendNotify(`${$.name}`, `${msg}`); + } +})() + .catch((e) => $.logErr(e)) + .finally(() => $.done()) + + +async function run() { + try { + $.hasEnd = true + $.endTime = 0 + lz_jdpin_token_cookie = '' + $.Token = '' + $.Pin = '' + $.MixNick = '' + let flag = false + if($.activityEnd) return + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + await takePostRequest('isvObfuscator'); + if($.Token == ''){ + console.log('获取[token]失败!') + return + } + await takePostRequest('activity_load'); + if($.hotFlag) return + if(Date.now() > $.endTime){ + $.MixNick = '' + $.activityEnd = true + console.log('活动结束') + return + } + if ($.MixNick == '') { + console.log(`获取cookie失败`); return; + } + // console.log($.MixNick) + // return + $.toBind = 0 + $.openList = [] + await takePostRequest('绑定'); + await takePostRequest('shopList'); + for(o of $.openList){ + $.missionType = 'openCard' + if(o.open != true && o.openCardUrl){ + $.openCard = false + $.joinVenderId = o.userId + await takePostRequest('mission'); + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + if($.openCard == true){ + await joinShop() + await takePostRequest('activity_load'); + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + // break + } + $.joinVenderId = '' + } + } + $.joinVenderId = '' + if($.hasCollectShop === 0){ + // 关注 + $.missionType = 'uniteCollectShop' + await takePostRequest('mission'); + await $.wait(parseInt(Math.random() * 2000 + 3000, 10)) + }else{ + console.log('已经关注') + } + if(guaopencard_addSku+"" == "true"){ + $.missionType = 'uniteAddCart' + let goodsArr = [] + if(cleanCart){ + goodsArr = await cleanCart.clean(cookie,'https://jd.smiek.tk/jdcleancatr_21102717','') + await $.wait(parseInt(Math.random() * 1000 + 4000, 10)) + if(cleanCart && goodsArr !== false){ + await $.wait(parseInt(Math.random() * 1000 + 4000, 10)) + await cleanCart.clean(cookie,'https://jd.smiek.tk/jdcleancatr_21102717',goodsArr || [ ]) + } + } + await takePostRequest('mission'); + await $.wait(parseInt(Math.random() * 2000 + 3000, 10)) + }else{ + console.log('如需加购请设置环境变量[guaopencard_addSku55]为"true"'); + } + await takePostRequest('activity_load'); + if(guaopencard_draw+"" !== "0"){ + $.runFalag = true + let count = parseInt($.usedChance, 10) + guaopencard_draw = parseInt(guaopencard_draw, 10) + if(count > guaopencard_draw) count = guaopencard_draw + console.log(`抽奖次数为:${count}`) + for(m=1;count--;m++){ + console.log(`第${m}次抽奖`) + await takePostRequest('抽奖'); + if($.runFalag == false) break + if(Number(count) <= 0) break + if(m >= 10){ + console.log("抽奖太多次,多余的次数请再执行脚本") + break + } + await $.wait(parseInt(Math.random() * 2000 + 2000, 10)) + } + }else console.log('如需抽奖请设置环境变量[guaopencard_draw55]为"3" 3为次数'); + await takePostRequest('myAward'); + await takePostRequest('missionInviteList'); + console.log($.MixNick) + console.log(`当前助力:${$.inviteNick}`) + if($.index == 1){ + $.inviteNick = $.MixNick + console.log(`后面的号都会助力:${$.inviteNick}`) + } + await $.wait(parseInt(Math.random() * 1000 + 5000, 10)) + if(flag) await $.wait(parseInt(Math.random() * 1000 + 10000, 10)) + if(guaopenwait){ + if($.index != cookiesArr.length){ + console.log(`等待${guaopenwait}秒`) + await $.wait(parseInt(guaopenwait, 10) * 1000) + } + }else{ + if($.index % 3 == 0) console.log('休息1分钟,别被黑ip了\n可持续发展') + if($.index % 3 == 0) await $.wait(parseInt(Math.random() * 5000 + 60000, 10)) + } + } catch (e) { + console.log(e) + } +} + +async function takePostRequest(type) { + if($.outFlag) return + let domain = 'https://jinggengjcq-isv.isvjcloud.com'; + let body = ``; + let method = 'POST' + let admJson = '' + switch (type) { + case 'isvObfuscator': + url = `https://api.m.jd.com/client.action?functionId=isvObfuscator`; + body = `body=%7B%22url%22%3A%22https%3A//jinggengjcq-isv.isvjcloud.com/fronth5/%3Flng%3D0%26lat%3D0%26sid%3D49687cd64aca2ae93aa43748a04e8f6w%26un_area%3D16_1315_1316_53522%23/pages/unitedCardNew20211010-ka/unitedCardNew20211010-ka%3FactId%3D9150e1d16b9d40_10101%22%2C%22id%22%3A%22%22%7D&uuid=b9b4ce69d42dacb64084279d51cdee764d7781fa&client=apple&clientVersion=10.1.4&st=1634100732991&sv=111&sign=67e254ffbcb13be9e12a9782c9cdf398`; + break; + case 'activity_load': + url = `${domain}/dm/front/openCardNew/activity_load?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"jdToken": $.Token, "source": "01", "inviteNick":($.inviteNick || "")} + if($.joinVenderId) admJson = {...admJson, "shopId": `${$.joinVenderId}`} + body = taskPostUrl("/openCardNew/activity_load", admJson); + break; + case 'shopList': + url = `${domain}/dm/front/openCardNew/shopList?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {} + body = taskPostUrl("/openCardNew/shopList", admJson); + break; + case '绑定': + url = `${domain}/dm/front/openCardNew/complete/mission?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"missionType": "relationBind", "inviterNick":($.inviteNick || "")} + body = taskPostUrl("/openCardNew/complete/mission", admJson); + break; + case 'mission': + url = `${domain}/dm/front/openCardNew/complete/mission?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"missionType": $.missionType} + if($.joinVenderId) admJson = {...admJson, "shopId": $.joinVenderId} + body = taskPostUrl("/openCardNew/complete/mission", admJson); + break; + case '抽奖': + url = `${domain}/dm/front/openCardNew/draw/post?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"dataType": "draw", "usedGameNum": "2"} + body = taskPostUrl("/openCardNew/draw/post", admJson); + break; + case 'followShop': + url = `${domain}/dm/front/openCardNew/followShop?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"actId": $.actId, "missionType": "collectShop"} + body = taskPostUrl("/openCardNew/followShop", admJson); + break; + case 'addCart': + url = `${domain}/dm/front/openCardNew/addCart?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"actId": $.actId, "missionType": "addCart"} + body = taskPostUrl("/openCardNew/addCart", admJson); + break; + case 'myAward': + url = `${domain}/dm/front/openCardNew/myAwards?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"pageNo": 1,"pageSize":9999} + body = taskPostUrl("/openCardNew/myAwards", admJson); + break; + case 'missionInviteList': + url = `${domain}/dm/front/openCardNew/missionInviteList?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"inviteListRequest":{"actId":$.actId,"userId":10299171,"missionType":"shareAct","inviteType": 1,"buyerNick":($.MixNick || '')}} + body = taskPostUrl("/openCardNew/missionInviteList", admJson); + break; + default: + console.log(`错误${type}`); + } + let myRequest = getPostRequest(url, body, method); + return new Promise(async resolve => { + $.post(myRequest, (err, resp, data) => { + try { + if (err) { + if(resp && resp.statusCode && resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + console.log(`${$.toStr(err,err)}`) + console.log(`${type} API请求失败,请检查网路重试`) + } else { + dealReturn(type, data); + } + } catch (e) { + // console.log(data); + console.log(e, resp) + } finally { + resolve(); + } + }) + }) + } + +async function dealReturn(type, data) { + let res = '' + try { + if(type != 'accessLogWithAD' || type != 'drawContent'){ + if(data){ + res = JSON.parse(data); + } + } + } catch (e) { + console.log(`${type} 执行任务异常`); + console.log(data); + $.runFalag = false; + } + try { + let title = '' + switch (type) { + case 'isvObfuscator': + if(typeof res == 'object'){ + if(res.errcode == 0){ + if(typeof res.token != 'undefined') $.Token = res.token + }else if(res.message){ + console.log(`${type} ${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + break; + case 'accessLogWithAD': + case 'drawContent': + break; + case 'activity_load': + case 'mission': + case 'shopList': + case 'loadUniteOpenCard': + case 'setMixNick': + case 'uniteOpenCardOne': + case 'checkOpenCard': + case 'followShop': + case 'addCart': + case 'myAward': + case 'missionInviteList': + case '抽奖': + title = '' + if(type == "followShop") title = '关注' + if(type == "addCart") title = '加购' + if(typeof res == 'object'){ + if(res.success && res.success === true && res.data){ + if(res.data.status && res.data.status == 200){ + res = res.data + if(type != "setMixNick" && (res.msg || res.data.isOpenCard || res.data.remark)) console.log(`${title && title+":" || ""}${res.msg || res.data.isOpenCard || res.data.remark || ''}`) + if(type == "activity_load"){ + if(res.msg || res.data.isOpenCard) { + if((res.msg || res.data.isOpenCard || '').indexOf('绑定成功') > -1) $.toBind = 1 + } + if(res.data){ + $.endTime = res.data.cusActivity.endTime || 0 + $.MixNick = res.data.buyerNick || "" + $.usedChance = res.data.missionCustomer.usedChance || 0 + $.hasCollectShop = res.data.missionCustomer.hasCollectShop || 0 + } + }else if(type == "shopList"){ + $.openList = res.data.cusShops || [] + }else if(type == "mission"){ + if(res.data.remark.indexOf('不是会员') > -1){ + $.openCard = true + }else{ + $.openCard = false + } + }else if(type == "uniteOpenCardOne"){ + $.uniteOpenCar = res.msg || res.data.msg || '' + }else if(type == "myAward"){ + console.log(`我的奖品:`) + let num = 0 + let value = 0 + for(let i in res.data.list || []){ + let item = res.data.list[i] + if(item.awardDes == '20'){ + num++ + value = item.awardDes + }else{ + console.log(`${item.awardName}`) + } + } + if(num > 0) console.log(`邀请好友(${num}):${num*parseInt(value, 10) || 30}京豆`) + }else if(type == "missionInviteList"){ + console.log(`邀请人数(${res.data.invitedLogList.total})`) + } + }else if(res.data.msg){ + console.log(`${title || type} ${res.data.msg || ''}`) + }else if(res.errorMessage){ + if(res.errorMessage.indexOf('火爆') >-1 ){ + $.hotFlag = true + } + console.log(`${title || type} ${res.errorMessage || ''}`) + }else{ + console.log(`${title || type} ${data}`) + } + }else if(res.errorMessage){ + console.log(`${title || type} ${res.errorMessage || ''}`) + }else{ + console.log(`${title || type} ${data}`) + } + }else{ + console.log(`${title || type} ${data}`) + } + break; + default: + console.log(`${title || type}-> ${data}`); + } + if(typeof res == 'object'){ + if(res.errorMessage){ + if(res.errorMessage.indexOf('火爆') >-1 ){ + $.hotFlag = true + } + } + } + } catch (e) { + console.log(e) + } +} + +function getPostRequest(url, body, method="POST") { + let headers = { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Content-Type": "application/x-www-form-urlencoded", + "Cookie": cookie, + "User-Agent": $.UA, + "X-Requested-With": "XMLHttpRequest" + } + if(url.indexOf('https://jinggengjcq-isv.isvjcloud.com') > -1){ + headers["Origin"] = `https://jinggengjcq-isv.isvjcloud.com` + headers["Content-Type"] = `application/json; charset=utf-8` + delete headers["Cookie"] + } + // console.log(headers) + // console.log(headers.Cookie) + return {url: url, method: method, headers: headers, body: body, timeout:30000}; +} + + +function taskPostUrl(url, t) { + + const b = { + "jsonRpc": "2.0", + "params": { + "commonParameter": { + "appkey": $.appkey, + "m": "POST", + "timestamp": Date.now(), + "userId": $.userId + }, + "admJson": { + "actId": $.actId, + "userId": $.userId, + ...t, + "method": url, + "buyerNick": ($.MixNick || ''), + } + }, + } + if(url.indexOf('missionInviteList') > -1){ + delete b.params.admJson.actId + } + return $.toStr(b,b) +} +async function getUA(){ + $.UA = `jdapp;iPhone;10.1.4;13.1.2;${randomString(40)};network/wifi;model/iPhone8,1;addressid/2308460611;appBuild/167814;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_1_2 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 jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} + +function joinShop() { + if(!$.joinVenderId) return + return new Promise(async resolve => { + $.shopactivityId = '' + await $.wait(1000) + await getshopactivityId() + let activityId = `` + if($.shopactivityId) activityId = `,"activityId":${$.shopactivityId}` + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body={"venderId":"${$.joinVenderId}","shopId":"${$.joinVenderId}","bindByVerifyCodeFlag":1,"registerExtend":{},"writeChildFlag":0${activityId},"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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + // console.log(data) + let res = $.toObj(data); + if(typeof res == 'object'){ + if(res.success === true){ + console.log(res.message) + if(res.result && res.result.giftInfo){ + for(let i of res.result.giftInfo.giftList){ + console.log(`入会获得:${i.discountString}${i.prizeName}${i.secondLineDesc}`) + } + } + }else if(typeof res == 'object' && res.message){ + console.log(`${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function getshopactivityId() { + return new Promise(resolve => { + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body=%7B%22venderId%22%3A%22${$.joinVenderId}%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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + let res = $.toObj(data); + if(res.success == true){ + // console.log($.toStr(res.result)) + console.log(`入会:${res.result.shopMemberCardInfo.venderCardName || ''}`) + $.shopactivityId = res.result.interestsRuleList && res.result.interestsRuleList[0] && res.result.interestsRuleList[0].interestsInfo && res.result.interestsRuleList[0].interestsInfo.activityId || '' + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +// 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)} + diff --git a/activity/jd_opencard6.js b/activity/jd_opencard6.js new file mode 100644 index 0000000..d960257 --- /dev/null +++ b/activity/jd_opencard6.js @@ -0,0 +1,585 @@ +/* +大牌联合 狂欢抢先GO +10-23 ~ 10-29 +https://lzdz1-isv.isvjcloud.com/dingzhi/dz/openCard/activity?activityId=dz20211023wkcn14cn5cnd0sdbs5sbx&shareUuid=0fc1f4f0763948fc962d05eca7cf77af + +cron 17 2,19 * * * https://raw.githubusercontent.com/KingRan/JDJB/main/jd_opencard6.js +*/ +const $ = new Env("大牌联合 狂欢抢先GO"); +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const notify = $.isNode() ? require('./sendNotify') : ''; +let cookiesArr = [], cookie = '', message = ''; +let ownCode = null; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => { }; +} else { + let cookiesData = $.getdata('CookiesJD') || "[]"; + cookiesData = JSON.parse(cookiesData); + cookiesArr = cookiesData.map(item => item.cookie); + cookiesArr.reverse(); + cookiesArr.push(...[$.getdata('CookieJD2'), $.getdata('CookieJD')]); + cookiesArr.reverse(); + cookiesArr = cookiesArr.filter(item => !!item); +} +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', { "open-url": "https://bean.m.jd.com/bean/signIndex.action" }); + return; + } + + authorCodeList = await getAuthorCodeList('https://gitee.com/KingRan521/JD-Scripts/raw/master/shareCodes/opencard6.json') + if(authorCodeList === '404: Not Found'){ + authorCodeList = [ + '0fc1f4f0763948fc962d05eca7cf77af', + ] + } + + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i] + originCookie = cookiesArr[i] + newCookie = '' + $.UserName = decodeURIComponent(cookie.match(/pt_pin=(.+?);/) && cookie.match(/pt_pin=(.+?);/)[1]) + $.index = i + 1; + $.isLogin = true; + $.nickName = ''; + await checkCookie(); + console.log(`\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + if (!$.isLogin) { + $.msg($.name, `【提示】cookie已失效`, `京东账号${$.index} ${$.nickName || $.UserName}\n请重新登录获取\nhttps://bean.m.jd.com/bean/signIndex.action`, { "open-url": "https://bean.m.jd.com/bean/signIndex.action" }); + if ($.isNode()) { + await notify.sendNotify(`${$.name}cookie已失效 - ${$.UserName}`, `京东账号${$.index} ${$.UserName}\n请重新登录获取cookie`); + } + continue + } + $.bean = 0; + $.ADID = getUUID('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', 1); + $.UUID = getUUID('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'); + // $.authorCode = authorCodeList[random(0, authorCodeList.length)] + $.authorCode = ownCode ? ownCode : authorCodeList[random(0, authorCodeList.length)] + $.authorNum = `${random(1000000, 9999999)}` + $.randomCode = random(1000000, 9999999) + $.activityId = 'dz20211023wkcn14cn5cnd0sdbs5sbx' + $.activityShopId = '1000387143' + $.activityUrl = `https://lzdz1-isv.isvjd.com/dingzhi/dz/openCard/activity/${$.authorNum}?activityId=${$.activityId}&shareUuid=${encodeURIComponent($.authorCode)}&adsource=null&shareuserid4minipg=null&shopid=${$.activityShopId}&lng=00.000000&lat=00.000000&sid=&un_area=` + await rush(); + await $.wait(3000) + if ($.bean > 0) { + message += `\n【京东账号${$.index}】${$.nickName || $.UserName} \n └ 获得 ${$.bean} 京豆。` + } + } + } + if (message !== '') { + if ($.isNode()) { + await notify.sendNotify($.name, message, '', `\n`); + } else { + $.msg($.name, '有点儿收获', message); + } + } +})() + .catch((e) => { + $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') + }) + .finally(() => { + $.done(); + }) + + +async function rush() { + $.token = null; + $.secretPin = null; + $.openCardActivityId = null + await getFirstLZCK() + await getToken(); + if ($.token) { + await getMyPing(); + if ($.secretPin) { + console.log("去助力 -> "+$.authorCode) + await task('common/accessLogWithAD', `venderId=${$.activityShopId}&code=99&pin=${encodeURIComponent($.secretPin)}&activityId=${$.activityId}&pageUrl=${$.activityUrl}&subType=app&adSource=null`, 1); + await task('wxActionCommon/getUserInfo', `pin=${encodeURIComponent($.secretPin)}`, 1) + if ($.index === 1) { + await task('dz/openCard/activityContent', `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}&pinImg=&nick=${encodeURIComponent($.pin)}&cjyxPin=&cjhyPin=&shareUuid=${encodeURIComponent($.authorCode)}`, 0, 1) + } else { + await task('dz/openCard/activityContent', `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}&pinImg=&nick=${encodeURIComponent($.pin)}&cjyxPin=&cjhyPin=&shareUuid=${encodeURIComponent($.authorCode)}`) + } + await task('dz/openCard/checkOpenCard', `activityId=${$.activityId}&actorUuid=${$.actorUuid}&shareUuid=${$.authorCode}&pin=${encodeURIComponent($.secretPin)}`) + $.log("->关注店铺") + if ($.shopTask) { + if (!$.shopTask.allStatus) { + await task('dz/openCard/followShop', `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}&actorUuid=${encodeURIComponent($.actorUuid)}&taskType=23&taskValue=1000002520`) + } else { + $.log(" >>>已经关注过了\n") + await $.wait(2000) + return + } + } else { + $.log("没有获取到对应的任务。\n") + } + $.log("->->->> 加入店铺会员") + if ($.openCardStatus) { + for (let i = 0; i < ($.openCardStatus.cardList1.length + $.openCardStatus.cardList2.length); i++) { + $.log("模拟上报访问记录") + await task('crm/pageVisit/insertCrmPageVisit', `venderId=1000004065&pageId=dz20211013skcnurdk11jhdue84752hp&elementId=${encodeURIComponent(`去开卡${i}`)}&pin=${encodeURIComponent($.secretPin)}`, 1) + await $.wait(2000) + } + t1TaskList = [] + $.openCardStatus.cardList1.filter((x) => { if (x.status === 0) { t1TaskList.push(x) } }) + t2TaskList = [] + $.openCardStatus.cardList2.filter((x) => { if (x.status === 0) { t2TaskList.push(x) } }) + if (t1TaskList.length < 1) { + console.log(" >>>已经完成入会任务") + + } else { + for (const vo of t1TaskList) { + $.log(` >>>去加入${vo.name}`) + await getShopOpenCardInfo({ "venderId": `${vo.value}`, "channel": "401" }, vo.value) + await bindWithVender({ "venderId": `${vo.value}`, "bindByVerifyCodeFlag": 1, "registerExtend": {}, "writeChildFlag": 0, "activityId": $.openCardActivityId, "channel": 401 }, vo.value) + await $.wait(2000) + } + for (const vo of t2TaskList) { + $.log(` >>>${vo.name}`) + await getShopOpenCardInfo({ "venderId": `${vo.value}`, "channel": "401" }) + await bindWithVender({ "venderId": `${vo.value}`, "bindByVerifyCodeFlag": 1, "registerExtend": {}, "writeChildFlag": 0, "activityId": $.openCardActivityId, "channel": 401 }, vo.value) + await $.wait(2000) + } + } + + await task("taskact/openCardcommon/drawContent", `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}`) + await $.wait(2000) + await task('dz/openCard/checkOpenCard', `activityId=${$.activityId}&actorUuid=${$.actorUuid}&shareUuid=${$.authorCode}&pin=${encodeURIComponent($.secretPin)}`) + await $.wait(2000) + await task("dz/openCard/startDraw", `activityId=${$.activityId}&actorUuid=${$.actorUuid}&type=1&pin=${encodeURIComponent($.secretPin)}`) + await $.wait(2000) + await task("dz/openCard/startDraw", `activityId=${$.activityId}&actorUuid=${$.actorUuid}&type=2&pin=${encodeURIComponent($.secretPin)}`) + + } else { + $.log("没有获取到对应的任务。\n") + } + $.log("->->->> 加购物车") + await task("dz/openCard/saveTask", `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}&actorUuid=${$.actorUuid}&type=2&taskValue=100025232454`) + } + } +} + +function task(function_id, body, isCommon = 0, own = 0) { + return new Promise(resolve => { + $.post(taskUrl(function_id, body, isCommon), async (err, resp, data) => { + try { + if (err) { + $.log(err) + } else { + + if (data) { + data = JSON.parse(data); + if (data.result) { + switch (function_id) { + case 'wxActionCommon/getUserInfo': + break; + case 'dz/openCard/activityContent': + if (!data.data.hasEnd) { + $.log(`开启【${data.data.activityName}】活动`) + $.log("-------------------") + if ($.index === 1) { + ownCode = data.data.actorUuid + console.log(ownCode) + } + $.actorUuid = data.data.actorUuid; + $.skuTask = data.data.addSku; + $.shopTask = data.data.followShop; + } else { + $.log("活动已经结束"); + } + break; + case 'dz/openCard/checkOpenCard': + $.openCardStatus = data.data; + break; + case 'dz/openCard/saveTask': + console.log(data.data.addBeanNum) + break; + case 'dz/openCard/saveTask': + if (data.data) { + if (data.data.addBeanNum) { + $.bean += data.data.addBeanNum; + $.log(`==>获得【${data.data.addBeanNum}】京豆\n`) + } + } + break; + case 'dz/openCard/startDraw': + if (data.data.drawOk) { + switch (data.data.drawInfo.type) { + case 6: + $.bean += data.data.drawInfo.beanNum; + $.log(`==>获得【${data.data.drawInfo.beanNum}】京豆\n`) + break; + default: + if ($.isNode()) { + await notify.sendNotify("中奖了", `中奖信息:${JSON.stringify(data.data.drawInfo)}\n活动链接:${$.activityUrl}`) + } else { + $.msg("中奖了", `获得${data.data.drawInfo.name}`, `中奖信息:${JSON.stringify(data.data.drawInfo)}\n活动链接:${$.activityUrl}`) + } + break; + } + } + break; + case 'crm/pageVisit/insertCrmPageVisit': + $.log("==> 上报成功") + + case 'dz/openCard/followShop': + if (data.data) { + if (data.data.addBeanNum) { + $.bean += data.data.addBeanNum; + $.log(`==>获得【${data.data.addBeanNum}】京豆\n`) + } + } + break; + default: + $.log(JSON.stringify(data)) + break; + } + } else { + $.log(JSON.stringify(data)) + } + } else { + // $.log("京东没有返回数据") + } + } + } catch (error) { + $.log(error) + } finally { + resolve(); + } + }) + }) +} +function getShopOpenCardInfo(body, venderId) { + let opt = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body=${encodeURIComponent(JSON.stringify(body))}&client=H5&clientVersion=9.2.0&uuid=88888`, + headers: { + Host: 'api.m.jd.com', + Accept: '*/*', + Connection: 'keep-alive', + Cookie: cookie, + 'User-Agent': `jdapp;iPhone;9.5.4;13.6;${$.UUID};network/wifi;ADID/${$.ADID};model/iPhone10,3;addressid/0;appBuild/167668;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1`, + 'Accept-Language': 'zh-cn', + Referer: `https://shopmember.m.jd.com/shopcard/?venderId=${venderId}}&channel=801&returnUrl=${encodeURIComponent($.activityUrl)}`, + 'Accept-Encoding': 'gzip, deflate, br' + } + } + return new Promise(resolve => { + $.get(opt, (err, resp, data) => { + try { + if (err) { + console.log(err) + } else { + res = JSON.parse(data) + if (res.success) { + if (res.result.interestsRuleList) { + $.openCardActivityId = res.result.interestsRuleList[0].interestsInfo.activityId; + } + } + } + } catch (error) { + console.log(error) + } finally { + resolve(); + } + }) + + }) +} +function bindWithVender(body, venderId) { + let opt = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body=${encodeURIComponent(JSON.stringify(body))}&client=H5&clientVersion=9.2.0&uuid=88888`, + headers: { + Host: 'api.m.jd.com', + Accept: '*/*', + Connection: 'keep-alive', + Cookie: cookie, + 'User-Agent': `jdapp;iPhone;9.5.4;13.6;${$.UUID};network/wifi;ADID/${$.ADID};model/iPhone10,3;addressid/0;appBuild/167668;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1`, + 'Accept-Language': 'zh-cn', + Referer: `https://shopmember.m.jd.com/shopcard/?venderId=${venderId}}&channel=401&returnUrl=${encodeURIComponent($.activityUrl)}`, + 'Accept-Encoding': 'gzip, deflate, br' + } + } + return new Promise(resolve => { + $.get(opt, (err, resp, data) => { + try { + if (err) { + console.log(err) + } else { + res = JSON.parse(data) + if (res.success) { + if (res.result.giftInfo && res.result.giftInfo.giftList) { + for (const vo of res.result.giftInfo.giftList) { + if (vo.prizeType === 4) { + $.log(`==>获得【${vo.quantity}】京豆`) + $.bean += vo.quantity + } + } + } + } + } + } catch (error) { + console.log(error) + } finally { + resolve(); + } + }) + + }) +} +function taskUrl(function_id, body, isCommon) { + return { + url: isCommon ? `https://lzdz1-isv.isvjd.com/${function_id}` : `https://lzdz1-isv.isvjd.com/dingzhi/${function_id}`, + headers: { + Host: 'lzdz1-isv.isvjd.com', + Accept: 'application/json', + 'X-Requested-With': 'XMLHttpRequest', + 'Accept-Language': 'zh-cn', + 'Accept-Encoding': 'gzip, deflate, br', + 'Content-Type': 'application/x-www-form-urlencoded', + Origin: 'https://lzdz1-isv.isvjd.com', + 'User-Agent': `jdapp;iPhone;9.5.4;13.6;${$.UUID};network/wifi;ADID/${$.ADID};model/iPhone10,3;addressid/0;appBuild/167668;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1`, + Connection: 'keep-alive', + Referer: $.activityUrl, + Cookie: cookie + }, + body: body + + } +} +function getAuthorCodeList(url) { + return new Promise(resolve => { + const options = { + url: `${url}?${new Date()}`, "timeout": 10000, headers: { + "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1 Edg/87.0.4280.88" + } + }; + $.get(options, async (err, resp, data) => { + try { + if (err) { + $.log(err) + } else { + if (data) data = JSON.parse(data) + } + } catch (e) { + $.logErr(e, resp) + data = null; + } finally { + resolve(data); + } + }) + }) +} +function getMyPing() { + let opt = { + url: `https://lzdz1-isv.isvjd.com/customer/getMyPing`, + headers: { + Host: 'lzdz1-isv.isvjd.com', + Accept: 'application/json', + 'X-Requested-With': 'XMLHttpRequest', + 'Accept-Language': 'zh-cn', + 'Accept-Encoding': 'gzip, deflate, br', + 'Content-Type': 'application/x-www-form-urlencoded', + Origin: 'https://lzdz1-isv.isvjd.com', + 'User-Agent': `jdapp;iPhone;9.5.4;13.6;${$.UUID};network/wifi;ADID/${$.ADID};model/iPhone10,3;addressid/0;appBuild/167668;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1`, + Connection: 'keep-alive', + Referer: $.activityUrl, + Cookie: cookie, + }, + body: `userId=${$.activityShopId}&token=${$.token}&fromType=APP&riskType=1` + } + return new Promise(resolve => { + $.post(opt, (err, resp, data) => { + try { + if (err) { + $.log(err) + } else { + if (resp['headers']['set-cookie']) { + cookie = `${originCookie}` + if ($.isNode()) { + for (let sk of resp['headers']['set-cookie']) { + cookie = `${cookie}${sk.split(";")[0]};` + } + } else { + for (let ck of resp['headers']['Set-Cookie'].split(',')) { + cookie = `${cookie}${ck.split(";")[0]};` + } + } + } + if (resp['headers']['Set-Cookie']) { + cookie = `${originCookie}` + if ($.isNode()) { + for (let sk of resp['headers']['set-cookie']) { + cookie = `${cookie}${sk.split(";")[0]};` + } + } else { + for (let ck of resp['headers']['Set-Cookie'].split(',')) { + cookie = `${cookie}${ck.split(";")[0]};` + } + } + } + if (data) { + data = JSON.parse(data) + if (data.result) { + $.log(`你好:${data.data.nickname}`) + $.pin = data.data.nickname; + $.secretPin = data.data.secretPin; + cookie = `${cookie};AUTH_C_USER=${data.data.secretPin}` + } else { + $.log(data.errorMessage) + } + } else { + // $.log("京东返回了空数据") + } + } + } catch (error) { + $.log(error) + } finally { + resolve(); + } + + }) + }) +} +function getFirstLZCK() { + return new Promise(resolve => { + $.get({ url: $.activityUrl }, (err, resp, data) => { + try { + if (err) { + console.log(err) + } else { + if (resp['headers']['set-cookie']) { + cookie = `${originCookie}` + if ($.isNode()) { + for (let sk of resp['headers']['set-cookie']) { + cookie = `${cookie}${sk.split(";")[0]};` + } + } else { + for (let ck of resp['headers']['Set-Cookie'].split(',')) { + cookie = `${cookie}${ck.split(";")[0]};` + } + } + } + if (resp['headers']['Set-Cookie']) { + cookie = `${originCookie}` + if ($.isNode()) { + for (let sk of resp['headers']['set-cookie']) { + cookie = `${cookie}${sk.split(";")[0]};` + } + } else { + for (let ck of resp['headers']['Set-Cookie'].split(',')) { + cookie = `${cookie}${ck.split(";")[0]};` + } + } + } + } + } catch (error) { + console.log(error) + } finally { + resolve(); + } + }) + }) +} +function getToken() { + let opt = { + url: `https://api.m.jd.com/client.action?functionId=isvObfuscator`, + headers: { + Host: 'api.m.jd.com', + 'Content-Type': 'application/x-www-form-urlencoded', + Accept: '*/*', + Connection: 'keep-alive', + Cookie: cookie, + 'User-Agent': 'JD4iPhone/167650 (iPhone; iOS 13.7; Scale/3.00)', + 'Accept-Language': 'zh-Hans-CN;q=1', + 'Accept-Encoding': 'gzip, deflate, br', + }, + body: `body=%7B%22url%22%3A%20%22https%3A//lzkj-isv.isvjcloud.com%22%2C%20%22id%22%3A%20%22%22%7D&uuid=hjudwgohxzVu96krv&client=apple&clientVersion=9.4.0&st=1620476162000&sv=111&sign=f9d1b7e3b943b6a136d54fe4f892af05` + } + return new Promise(resolve => { + $.post(opt, (err, resp, data) => { + try { + if (err) { + $.log(err) + } else { + if (data) { + data = JSON.parse(data); + if (data.code === "0") { + $.token = data.token + } + } else { + $.log("京东返回了空数据") + } + } + } catch (error) { + $.log(error) + } finally { + resolve(); + } + }) + }) +} +function random(min, max) { + + return Math.floor(Math.random() * (max - min)) + min; + +} +function getUUID(format = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', UpperCase = 0) { + return format.replace(/[xy]/g, function (c) { + var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8); + if (UpperCase) { + uuid = v.toString(36).toUpperCase(); + } else { + uuid = v.toString(36) + } + return uuid; + }); +} +function checkCookie() { + const options = { + url: "https://me-api.jd.com/user_new/info/GetJDUserInfoUnion", + headers: { + "Host": "me-api.jd.com", + "Accept": "*/*", + "Connection": "keep-alive", + "Cookie": cookie, + "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.2 Mobile/15E148 Safari/604.1", + "Accept-Language": "zh-cn", + "Referer": "https://home.m.jd.com/myJd/newhome.action?sceneval=2&ufc=&", + "Accept-Encoding": "gzip, deflate, br", + } + }; + return new Promise(resolve => { + $.get(options, (err, resp, data) => { + try { + if (err) { + $.logErr(err) + } else { + if (data) { + data = JSON.parse(data); + if (data.retcode === "1001") { + $.isLogin = false; //cookie过期 + return; + } + if (data.retcode === "0" && data.data.hasOwnProperty("userInfo")) { + $.nickName = data.data.userInfo.baseInfo.nickname; + } + } else { + $.log('京东返回了空数据'); + } + } + } catch (e) { + $.logErr(e) + } finally { + resolve(); + } + }) + }) +} +// prettier-ignore +!function (n) { "use strict"; function t(n, t) { var r = (65535 & n) + (65535 & t); return (n >> 16) + (t >> 16) + (r >> 16) << 16 | 65535 & r } function r(n, t) { return n << t | n >>> 32 - t } function e(n, e, o, u, c, f) { return t(r(t(t(e, n), t(u, f)), c), o) } function o(n, t, r, o, u, c, f) { return e(t & r | ~t & o, n, t, u, c, f) } function u(n, t, r, o, u, c, f) { return e(t & o | r & ~o, n, t, u, c, f) } function c(n, t, r, o, u, c, f) { return e(t ^ r ^ o, n, t, u, c, f) } function f(n, t, r, o, u, c, f) { return e(r ^ (t | ~o), n, t, u, c, f) } function i(n, r) { n[r >> 5] |= 128 << r % 32, n[14 + (r + 64 >>> 9 << 4)] = r; var e, i, a, d, h, l = 1732584193, g = -271733879, v = -1732584194, m = 271733878; for (e = 0; e < n.length; e += 16)i = l, a = g, d = v, h = m, g = f(g = f(g = f(g = f(g = c(g = c(g = c(g = c(g = u(g = u(g = u(g = u(g = o(g = o(g = o(g = o(g, v = o(v, m = o(m, l = o(l, g, v, m, n[e], 7, -680876936), g, v, n[e + 1], 12, -389564586), l, g, n[e + 2], 17, 606105819), m, l, n[e + 3], 22, -1044525330), v = o(v, m = o(m, l = o(l, g, v, m, n[e + 4], 7, -176418897), g, v, n[e + 5], 12, 1200080426), l, g, n[e + 6], 17, -1473231341), m, l, n[e + 7], 22, -45705983), v = o(v, m = o(m, l = o(l, g, v, m, n[e + 8], 7, 1770035416), g, v, n[e + 9], 12, -1958414417), l, g, n[e + 10], 17, -42063), m, l, n[e + 11], 22, -1990404162), v = o(v, m = o(m, l = o(l, g, v, m, n[e + 12], 7, 1804603682), g, v, n[e + 13], 12, -40341101), l, g, n[e + 14], 17, -1502002290), m, l, n[e + 15], 22, 1236535329), v = u(v, m = u(m, l = u(l, g, v, m, n[e + 1], 5, -165796510), g, v, n[e + 6], 9, -1069501632), l, g, n[e + 11], 14, 643717713), m, l, n[e], 20, -373897302), v = u(v, m = u(m, l = u(l, g, v, m, n[e + 5], 5, -701558691), g, v, n[e + 10], 9, 38016083), l, g, n[e + 15], 14, -660478335), m, l, n[e + 4], 20, -405537848), v = u(v, m = u(m, l = u(l, g, v, m, n[e + 9], 5, 568446438), g, v, n[e + 14], 9, -1019803690), l, g, n[e + 3], 14, -187363961), m, l, n[e + 8], 20, 1163531501), v = u(v, m = u(m, l = u(l, g, v, m, n[e + 13], 5, -1444681467), g, v, n[e + 2], 9, -51403784), l, g, n[e + 7], 14, 1735328473), m, l, n[e + 12], 20, -1926607734), v = c(v, m = c(m, l = c(l, g, v, m, n[e + 5], 4, -378558), g, v, n[e + 8], 11, -2022574463), l, g, n[e + 11], 16, 1839030562), m, l, n[e + 14], 23, -35309556), v = c(v, m = c(m, l = c(l, g, v, m, n[e + 1], 4, -1530992060), g, v, n[e + 4], 11, 1272893353), l, g, n[e + 7], 16, -155497632), m, l, n[e + 10], 23, -1094730640), v = c(v, m = c(m, l = c(l, g, v, m, n[e + 13], 4, 681279174), g, v, n[e], 11, -358537222), l, g, n[e + 3], 16, -722521979), m, l, n[e + 6], 23, 76029189), v = c(v, m = c(m, l = c(l, g, v, m, n[e + 9], 4, -640364487), g, v, n[e + 12], 11, -421815835), l, g, n[e + 15], 16, 530742520), m, l, n[e + 2], 23, -995338651), v = f(v, m = f(m, l = f(l, g, v, m, n[e], 6, -198630844), g, v, n[e + 7], 10, 1126891415), l, g, n[e + 14], 15, -1416354905), m, l, n[e + 5], 21, -57434055), v = f(v, m = f(m, l = f(l, g, v, m, n[e + 12], 6, 1700485571), g, v, n[e + 3], 10, -1894986606), l, g, n[e + 10], 15, -1051523), m, l, n[e + 1], 21, -2054922799), v = f(v, m = f(m, l = f(l, g, v, m, n[e + 8], 6, 1873313359), g, v, n[e + 15], 10, -30611744), l, g, n[e + 6], 15, -1560198380), m, l, n[e + 13], 21, 1309151649), v = f(v, m = f(m, l = f(l, g, v, m, n[e + 4], 6, -145523070), g, v, n[e + 11], 10, -1120210379), l, g, n[e + 2], 15, 718787259), m, l, n[e + 9], 21, -343485551), l = t(l, i), g = t(g, a), v = t(v, d), m = t(m, h); return [l, g, v, m] } function a(n) { var t, r = "", e = 32 * n.length; for (t = 0; t < e; t += 8)r += String.fromCharCode(n[t >> 5] >>> t % 32 & 255); return r } function d(n) { var t, r = []; for (r[(n.length >> 2) - 1] = void 0, t = 0; t < r.length; t += 1)r[t] = 0; var e = 8 * n.length; for (t = 0; t < e; t += 8)r[t >> 5] |= (255 & n.charCodeAt(t / 8)) << t % 32; return r } function h(n) { return a(i(d(n), 8 * n.length)) } function l(n, t) { var r, e, o = d(n), u = [], c = []; for (u[15] = c[15] = void 0, o.length > 16 && (o = i(o, 8 * n.length)), r = 0; r < 16; r += 1)u[r] = 909522486 ^ o[r], c[r] = 1549556828 ^ o[r]; return e = i(u.concat(d(t)), 512 + 8 * t.length), a(i(c.concat(e), 640)) } function g(n) { var t, r, e = ""; for (r = 0; r < n.length; r += 1)t = n.charCodeAt(r), e += "0123456789abcdef".charAt(t >>> 4 & 15) + "0123456789abcdef".charAt(15 & t); return e } function v(n) { return unescape(encodeURIComponent(n)) } function m(n) { return h(v(n)) } function p(n) { return g(m(n)) } function s(n, t) { return l(v(n), v(t)) } function C(n, t) { return g(s(n, t)) } function A(n, t, r) { return t ? r ? s(t, n) : C(t, n) : r ? m(n) : p(n) } $.md5 = A }(this); +function Env(t, e) { "undefined" != typeof process && JSON.stringify(process.env).indexOf("GITHUB") > -1 && process.exit(0); class s { constructor(t) { this.env = t } send(t, e = "GET") { t = "string" == typeof t ? { url: t } : t; let s = this.get; return "POST" === e && (s = this.post), new Promise((e, i) => { s.call(this, t, (t, s, r) => { t ? i(t) : e(s) }) }) } get(t) { return this.send.call(this.env, t) } post(t) { return this.send.call(this.env, t, "POST") } } return new class { constructor(t, e) { this.name = t, this.http = new s(this), this.data = null, this.dataFile = "box.dat", this.logs = [], this.isMute = !1, this.isNeedRewrite = !1, this.logSeparator = "\n", this.startTime = (new Date).getTime(), Object.assign(this, e), this.log("", `🔔${this.name}, 开始!`) } isNode() { return "undefined" != typeof module && !!module.exports } isQuanX() { return "undefined" != typeof $task } isSurge() { return "undefined" != typeof $httpClient && "undefined" == typeof $loon } isLoon() { return "undefined" != typeof $loon } toObj(t, e = null) { try { return JSON.parse(t) } catch { return e } } toStr(t, e = null) { try { return JSON.stringify(t) } catch { return e } } getjson(t, e) { let s = e; const i = this.getdata(t); if (i) try { s = JSON.parse(this.getdata(t)) } catch { } return s } setjson(t, e) { try { return this.setdata(JSON.stringify(t), e) } catch { return !1 } } getScript(t) { return new Promise(e => { this.get({ url: t }, (t, s, i) => e(i)) }) } runScript(t, e) { return new Promise(s => { let i = this.getdata("@chavy_boxjs_userCfgs.httpapi"); i = i ? i.replace(/\n/g, "").trim() : i; let r = this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout"); r = r ? 1 * r : 20, r = e && e.timeout ? e.timeout : r; const [o, h] = i.split("@"), n = { url: `http://${h}/v1/scripting/evaluate`, body: { script_text: t, mock_type: "cron", timeout: r }, headers: { "X-Key": o, Accept: "*/*" } }; this.post(n, (t, e, i) => s(i)) }).catch(t => this.logErr(t)) } loaddata() { if (!this.isNode()) return {}; { this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path"); const t = this.path.resolve(this.dataFile), e = this.path.resolve(process.cwd(), this.dataFile), s = this.fs.existsSync(t), i = !s && this.fs.existsSync(e); if (!s && !i) return {}; { const i = s ? t : e; try { return JSON.parse(this.fs.readFileSync(i)) } catch (t) { return {} } } } } writedata() { if (this.isNode()) { this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path"); const t = this.path.resolve(this.dataFile), e = this.path.resolve(process.cwd(), this.dataFile), s = this.fs.existsSync(t), i = !s && this.fs.existsSync(e), r = JSON.stringify(this.data); s ? this.fs.writeFileSync(t, r) : i ? this.fs.writeFileSync(e, r) : this.fs.writeFileSync(t, r) } } lodash_get(t, e, s) { const i = e.replace(/\[(\d+)\]/g, ".$1").split("."); let r = t; for (const t of i) if (r = Object(r)[t], void 0 === r) return s; return r } lodash_set(t, e, s) { return Object(t) !== t ? t : (Array.isArray(e) || (e = e.toString().match(/[^.[\]]+/g) || []), e.slice(0, -1).reduce((t, s, i) => Object(t[s]) === t[s] ? t[s] : t[s] = Math.abs(e[i + 1]) >> 0 == +e[i + 1] ? [] : {}, t)[e[e.length - 1]] = s, t) } getdata(t) { let e = this.getval(t); if (/^@/.test(t)) { const [, s, i] = /^@(.*?)\.(.*?)$/.exec(t), r = s ? this.getval(s) : ""; if (r) try { const t = JSON.parse(r); e = t ? this.lodash_get(t, i, "") : e } catch (t) { e = "" } } return e } setdata(t, e) { let s = !1; if (/^@/.test(e)) { const [, i, r] = /^@(.*?)\.(.*?)$/.exec(e), o = this.getval(i), h = i ? "null" === o ? null : o || "{}" : "{}"; try { const e = JSON.parse(h); this.lodash_set(e, r, t), s = this.setval(JSON.stringify(e), i) } catch (e) { const o = {}; this.lodash_set(o, r, t), s = this.setval(JSON.stringify(o), i) } } else s = this.setval(t, e); return s } getval(t) { return this.isSurge() || this.isLoon() ? $persistentStore.read(t) : this.isQuanX() ? $prefs.valueForKey(t) : this.isNode() ? (this.data = this.loaddata(), this.data[t]) : this.data && this.data[t] || null } setval(t, e) { return this.isSurge() || this.isLoon() ? $persistentStore.write(t, e) : this.isQuanX() ? $prefs.setValueForKey(t, e) : this.isNode() ? (this.data = this.loaddata(), this.data[e] = t, this.writedata(), !0) : this.data && this.data[e] || null } initGotEnv(t) { this.got = this.got ? this.got : require("got"), this.cktough = this.cktough ? this.cktough : require("tough-cookie"), this.ckjar = this.ckjar ? this.ckjar : new this.cktough.CookieJar, t && (t.headers = t.headers ? t.headers : {}, void 0 === t.headers.Cookie && void 0 === t.cookieJar && (t.cookieJar = this.ckjar)) } get(t, e = (() => { })) { t.headers && (delete t.headers["Content-Type"], delete t.headers["Content-Length"]), this.isSurge() || this.isLoon() ? (this.isSurge() && this.isNeedRewrite && (t.headers = t.headers || {}, Object.assign(t.headers, { "X-Surge-Skip-Scripting": !1 })), $httpClient.get(t, (t, s, i) => { !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i) })) : this.isQuanX() ? (this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, { hints: !1 })), $task.fetch(t).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => e(t))) : this.isNode() && (this.initGotEnv(t), this.got(t).on("redirect", (t, e) => { try { if (t.headers["set-cookie"]) { const s = t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString(); s && this.ckjar.setCookieSync(s, null), e.cookieJar = this.ckjar } } catch (t) { this.logErr(t) } }).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => { const { message: s, response: i } = t; e(s, i, i && i.body) })) } post(t, e = (() => { })) { if (t.body && t.headers && !t.headers["Content-Type"] && (t.headers["Content-Type"] = "application/x-www-form-urlencoded"), t.headers && delete t.headers["Content-Length"], this.isSurge() || this.isLoon()) this.isSurge() && this.isNeedRewrite && (t.headers = t.headers || {}, Object.assign(t.headers, { "X-Surge-Skip-Scripting": !1 })), $httpClient.post(t, (t, s, i) => { !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i) }); else if (this.isQuanX()) t.method = "POST", this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, { hints: !1 })), $task.fetch(t).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => e(t)); else if (this.isNode()) { this.initGotEnv(t); const { url: s, ...i } = t; this.got.post(s, i).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => { const { message: s, response: i } = t; e(s, i, i && i.body) }) } } time(t, e = null) { const s = e ? new Date(e) : new Date; let i = { "M+": s.getMonth() + 1, "d+": s.getDate(), "H+": s.getHours(), "m+": s.getMinutes(), "s+": s.getSeconds(), "q+": Math.floor((s.getMonth() + 3) / 3), S: s.getMilliseconds() }; /(y+)/.test(t) && (t = t.replace(RegExp.$1, (s.getFullYear() + "").substr(4 - RegExp.$1.length))); for (let e in i) new RegExp("(" + e + ")").test(t) && (t = t.replace(RegExp.$1, 1 == RegExp.$1.length ? i[e] : ("00" + i[e]).substr(("" + i[e]).length))); return t } msg(e = t, s = "", i = "", r) { const o = t => { if (!t) return t; if ("string" == typeof t) return this.isLoon() ? t : this.isQuanX() ? { "open-url": t } : this.isSurge() ? { url: t } : void 0; if ("object" == typeof t) { if (this.isLoon()) { let e = t.openUrl || t.url || t["open-url"], s = t.mediaUrl || t["media-url"]; return { openUrl: e, mediaUrl: s } } if (this.isQuanX()) { let e = t["open-url"] || t.url || t.openUrl, s = t["media-url"] || t.mediaUrl; return { "open-url": e, "media-url": s } } if (this.isSurge()) { let e = t.url || t.openUrl || t["open-url"]; return { url: e } } } }; if (this.isMute || (this.isSurge() || this.isLoon() ? $notification.post(e, s, i, o(r)) : this.isQuanX() && $notify(e, s, i, o(r))), !this.isMuteLog) { let t = ["", "==============📣系统通知📣=============="]; t.push(e), s && t.push(s), i && t.push(i), console.log(t.join("\n")), this.logs = this.logs.concat(t) } } log(...t) { t.length > 0 && (this.logs = [...this.logs, ...t]), console.log(t.join(this.logSeparator)) } logErr(t, e) { const s = !this.isSurge() && !this.isQuanX() && !this.isLoon(); s ? this.log("", `❗️${this.name}, 错误!`, t.stack) : this.log("", `❗️${this.name}, 错误!`, t) } wait(t) { return new Promise(e => setTimeout(e, t)) } done(t = {}) { const e = (new Date).getTime(), s = (e - this.startTime) / 1e3; this.log("", `🔔${this.name}, 结束! 🕛 ${s} 秒`), this.log(), (this.isSurge() || this.isQuanX() || this.isLoon()) && $done(t) } }(t, e) } diff --git a/activity/jd_opencard64.js b/activity/jd_opencard64.js new file mode 100644 index 0000000..673735c --- /dev/null +++ b/activity/jd_opencard64.js @@ -0,0 +1,619 @@ +/* +10.29~11.3 联合开卡 [gua_opencard64.js] +新增开卡脚本 +一次性脚本 + +1.邀请一人20豆(有可能没有豆 +2.开18张 成功开1张 可能获得5京豆 + 全部开完获得1次抽奖 +3.关注10京豆 获得1次抽奖 +4.加购5京豆 获得1次抽奖(默认不加购 如需加购请设置环境变量[guaopencard_addSku64]为"true" +5.抽奖 (默认不抽奖 如需抽奖请设置环境变量[guaopencard_draw64]为"3" +填写要抽奖的次数 不足已自身次数为准 +guaopencard_draw64="3" +填非数字会全都抽奖 + +第一个账号助力作者 其他依次助力CK1 +第一个CK失效会退出脚本 + +默认脚本不执行 +如需执行脚本请设置环境变量 +guaopencard64="true" +每个账号之间延迟 100=延迟100秒 0=延迟0秒会使用每3个账号延迟60秒 +guaopenwait_All 所有 +guaopenwait64="0" + + +All变量适用 +———————————————— +入口:[ 10.29~11.3 联合开卡 (https://3.cn/103jBB2-0)] + +请求太频繁会被黑ip +过10分钟再执行 + +18:/¥R0mkcE4Qg2uhKH¥ + +============Quantumultx=============== +[task_local] +#10.29~11.3 联合开卡 +47 14 1-3 11 * https://raw.githubusercontent.com/smiek2121/scripts/master/gua_opencard64.js, tag=10.29~11.3 联合开卡, enabled=true + +*/ +let guaopencard_addSku = "false" +let guaopencard = "false" +let guaopenwait = "0" +let guaopencard_draw = "0" + +const $ = new Env('10.29~11.3 联合开卡'); +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const notify = $.isNode() ? require('./sendNotify') : ''; +let cleanCart = '' +if($.isNode()){ + try{ + const fs = require('fs'); + if (fs.existsSync('./cleancart_activity.js')) { + cleanCart = require('./cleancart_activity'); + } + }catch(e){ + } +} +//IOS等用户直接用NobyDa的jd cookie +let cookiesArr = [], + cookie = ''; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} + +guaopencard_addSku = $.isNode() ? (process.env.guaopencard_addSku64 ? process.env.guaopencard_addSku64 : `${guaopencard_addSku}`) : ($.getdata('guaopencard_addSku64') ? $.getdata('guaopencard_addSku64') : `${guaopencard_addSku}`); +guaopencard_addSku = $.isNode() ? (process.env.guaopencard_addSku_All ? process.env.guaopencard_addSku_All : `${guaopencard_addSku}`) : ($.getdata('guaopencard_addSku_All') ? $.getdata('guaopencard_addSku_All') : `${guaopencard_addSku}`); +guaopencard = $.isNode() ? (process.env.guaopencard64 ? process.env.guaopencard64 : `${guaopencard}`) : ($.getdata('guaopencard64') ? $.getdata('guaopencard64') : `${guaopencard}`); +guaopencard = $.isNode() ? (process.env.guaopencard_All ? process.env.guaopencard_All : `${guaopencard}`) : ($.getdata('guaopencard_All') ? $.getdata('guaopencard_All') : `${guaopencard}`); +guaopenwait = $.isNode() ? (process.env.guaopenwait64 ? process.env.guaopenwait64 : `${guaopenwait}`) : ($.getdata('guaopenwait64') ? $.getdata('guaopenwait64') : `${guaopenwait}`); +guaopenwait = $.isNode() ? (process.env.guaopenwait_All ? process.env.guaopenwait_All : `${guaopenwait}`) : ($.getdata('guaopenwait_All') ? $.getdata('guaopenwait_All') : `${guaopenwait}`); +guaopenwait = parseInt(guaopenwait, 10) || 0 +guaopencard_draw = $.isNode() ? (process.env.guaopencard_draw64 ? process.env.guaopencard_draw64 : guaopencard_draw) : ($.getdata('guaopencard_draw64') ? $.getdata('guaopencard_draw64') : guaopencard_draw); +guaopencard_draw = $.isNode() ? (process.env.guaopencard_draw ? process.env.guaopencard_draw : guaopencard_draw) : ($.getdata('guaopencard_draw') ? $.getdata('guaopencard_draw') : guaopencard_draw); +guaopenwait = parseInt(guaopenwait, 10) || 0 +allMessage = "" +message = "" +$.hotFlag = false +$.outFlag = false +$.activityEnd = false +let lz_jdpin_token_cookie ='' +let activityCookie ='' +!(async () => { + console.log('添加瓜佬开卡脚本,请在配置文件填入下方所有变量') + console.log('export guaopencard_All="true" # 青蛙开卡总开关') + console.log('export guaopencard_addSku_All="false" # 青蛙开卡加购') + console.log('export guaopencardRun_All="true" # 青蛙开卡做任务') + console.log('export guaopencard_draw="true" # 青蛙开卡抽奖') + if ($.isNode()) { + if(guaopencard+"" != "true"){ + console.log('如需执行脚本请设置环境变量[guaopencard64]为"true"') + } + if(guaopencard+"" != "true"){ + return + } + } + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', { + "open-url": "https://bean.m.jd.com/" + }); + return; + } + // return + $.appkey = '51B59BB805903DA4CE513D29EC448375' + $.userId = '10299171' + $.actId = '26d52498bc034abbb91521_1029' + $.MixNicks = '' + $.inviteNick = 'k1Nobb+P0er+C2sysxnx/P2KELO9izRVpwCyqu0eqVZ5aW7RHzlMobrzJ/e9r/uf' + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i]; + if (cookie) { + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + message = "" + $.bean = 0 + $.hotFlag = false + $.nickName = ''; + console.log(`\n\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + await getUA() + await run(); + if(i == 0 && !$.MixNick) break + if($.outFlag || $.activityEnd) break + } + } + if($.outFlag) { + let msg = '此ip已被限制,请过10分钟后再执行脚本' + $.msg($.name, ``, `${msg}`); + if ($.isNode()) await notify.sendNotify(`${$.name}`, `${msg}`); + } +})() + .catch((e) => $.logErr(e)) + .finally(() => $.done()) + + +async function run() { + try { + $.hasEnd = true + $.endTime = 0 + lz_jdpin_token_cookie = '' + $.Token = '' + $.Pin = '' + $.MixNick = '' + let flag = false + if($.activityEnd) return + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + await takePostRequest('isvObfuscator'); + if($.Token == ''){ + console.log('获取[token]失败!') + return + } + await takePostRequest('activity_load'); + if($.hotFlag) return + if(Date.now() > $.endTime){ + $.MixNick = '' + $.activityEnd = true + console.log('活动结束') + return + } + if ($.MixNick == '') { + console.log(`获取cookie失败`); return; + } + // console.log($.MixNick) + // return + $.toBind = 0 + $.openList = [] + await takePostRequest('绑定'); + await takePostRequest('shopList'); + for(o of $.openList){ + $.missionType = 'openCard' + if(o.open != true && o.openCardUrl){ + $.openCard = false + $.joinVenderId = o.userId + await takePostRequest('mission'); + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + if($.openCard == true){ + await joinShop() + await takePostRequest('activity_load'); + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + // break + } + $.joinVenderId = '' + } + } + $.joinVenderId = '' + if($.hasCollectShop === 0){ + // 关注 + $.missionType = 'uniteCollectShop' + await takePostRequest('mission'); + await $.wait(parseInt(Math.random() * 2000 + 3000, 10)) + }else{ + console.log('已经关注') + } + if(guaopencard_addSku+"" == "true"){ + $.missionType = 'uniteAddCart' + let goodsArr = [] + if(cleanCart){ + goodsArr = await cleanCart.clean(cookie,'https://jd.smiek.tk/jdcleancatr_21102717','') + await takePostRequest('mission'); + await $.wait(parseInt(Math.random() * 2000 + 3000, 10)) + if(cleanCart && goodsArr !== false){ + await $.wait(parseInt(Math.random() * 1000 + 7000, 10)) + await cleanCart.clean(cookie,'https://jd.smiek.tk/jdcleancatr_21102717',goodsArr || [ ]) + } + } + }else{ + console.log('如需加购请设置环境变量[guaopencard_addSku64]为"true"'); + } + await takePostRequest('activity_load'); + if(guaopencard_draw+"" !== "0"){ + $.runFalag = true + let count = parseInt($.usedChance, 10) + guaopencard_draw = parseInt(guaopencard_draw, 10) + if(count > guaopencard_draw) count = guaopencard_draw + console.log(`抽奖次数为:${count}`) + for(m=1;count--;m++){ + console.log(`第${m}次抽奖`) + await takePostRequest('抽奖'); + if($.runFalag == false) break + if(Number(count) <= 0) break + if(m >= 10){ + console.log("抽奖太多次,多余的次数请再执行脚本") + break + } + await $.wait(parseInt(Math.random() * 2000 + 2000, 10)) + } + }else console.log('如需抽奖请设置环境变量[guaopencard_draw64]为"3" 3为次数'); + await takePostRequest('myAward'); + await takePostRequest('missionInviteList'); + console.log($.MixNick) + console.log(`当前助力:${$.inviteNick}`) + if($.index == 1){ + $.inviteNick = $.MixNick + console.log(`后面的号都会助力:${$.inviteNick}`) + } + await $.wait(parseInt(Math.random() * 1000 + 5000, 10)) + if(flag) await $.wait(parseInt(Math.random() * 1000 + 10000, 10)) + if(guaopenwait){ + if($.index != cookiesArr.length){ + console.log(`等待${guaopenwait}秒`) + await $.wait(parseInt(guaopenwait, 10) * 1000) + } + }else{ + if($.index % 3 == 0) console.log('休息1分钟,别被黑ip了\n可持续发展') + if($.index % 3 == 0) await $.wait(parseInt(Math.random() * 5000 + 60000, 10)) + } + } catch (e) { + console.log(e) + } +} + +async function takePostRequest(type) { + if($.outFlag) return + let domain = 'https://jinggengjcq-isv.isvjcloud.com'; + let body = ``; + let method = 'POST' + let admJson = '' + switch (type) { + case 'isvObfuscator': + url = `https://api.m.jd.com/client.action?functionId=isvObfuscator`; + body = `body=%7B%22url%22%3A%22https%3A//jinggengjcq-isv.isvjcloud.com/fronth5/%3Flng%3D0%26lat%3D0%26sid%3D49687cd64aca2ae93aa43748a04e8f6w%26un_area%3D16_1315_1316_53522%23/pages/unitedCardNew20211010-ka/unitedCardNew20211010-ka%3FactId%3D9150e1d16b9d40_10101%22%2C%22id%22%3A%22%22%7D&uuid=b9b4ce69d42dacb64084279d51cdee764d7781fa&client=apple&clientVersion=10.1.4&st=1634100732991&sv=111&sign=67e254ffbcb13be9e12a9782c9cdf398`; + break; + case 'activity_load': + url = `${domain}/dm/front/openCardNew/activity_load?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"jdToken": $.Token, "source": "01", "inviteNick":($.inviteNick || "")} + if($.joinVenderId) admJson = {...admJson, "shopId": `${$.joinVenderId}`} + body = taskPostUrl("/openCardNew/activity_load", admJson); + break; + case 'shopList': + url = `${domain}/dm/front/openCardNew/shopList?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {} + body = taskPostUrl("/openCardNew/shopList", admJson); + break; + case '绑定': + url = `${domain}/dm/front/openCardNew/complete/mission?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"missionType": "relationBind", "inviterNick":($.inviteNick || "")} + body = taskPostUrl("/openCardNew/complete/mission", admJson); + break; + case 'mission': + url = `${domain}/dm/front/openCardNew/complete/mission?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"missionType": $.missionType} + if($.joinVenderId) admJson = {...admJson, "shopId": $.joinVenderId} + body = taskPostUrl("/openCardNew/complete/mission", admJson); + break; + case '抽奖': + url = `${domain}/dm/front/openCardNew/draw/post?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"dataType": "draw", "usedGameNum": "2"} + body = taskPostUrl("/openCardNew/draw/post", admJson); + break; + case 'followShop': + url = `${domain}/dm/front/openCardNew/followShop?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"actId": $.actId, "missionType": "collectShop"} + body = taskPostUrl("/openCardNew/followShop", admJson); + break; + case 'addCart': + url = `${domain}/dm/front/openCardNew/addCart?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"actId": $.actId, "missionType": "addCart"} + body = taskPostUrl("/openCardNew/addCart", admJson); + break; + case 'myAward': + url = `${domain}/dm/front/openCardNew/myAwards?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"pageNo": 1,"pageSize":9999} + body = taskPostUrl("/openCardNew/myAwards", admJson); + break; + case 'missionInviteList': + url = `${domain}/dm/front/openCardNew/missionInviteList?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"inviteListRequest":{"actId":$.actId,"userId":10299171,"missionType":"shareAct","inviteType": 1,"buyerNick":($.MixNick || '')}} + body = taskPostUrl("/openCardNew/missionInviteList", admJson); + break; + default: + console.log(`错误${type}`); + } + let myRequest = getPostRequest(url, body, method); + return new Promise(async resolve => { + $.post(myRequest, (err, resp, data) => { + try { + if (err) { + if(resp && resp.statusCode && resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + console.log(`${$.toStr(err,err)}`) + console.log(`${type} API请求失败,请检查网路重试`) + } else { + dealReturn(type, data); + } + } catch (e) { + // console.log(data); + console.log(e, resp) + } finally { + resolve(); + } + }) + }) + } + +async function dealReturn(type, data) { + let res = '' + try { + if(type != 'accessLogWithAD' || type != 'drawContent'){ + if(data){ + res = JSON.parse(data); + } + } + } catch (e) { + console.log(`${type} 执行任务异常`); + console.log(data); + $.runFalag = false; + } + try { + let title = '' + switch (type) { + case 'isvObfuscator': + if(typeof res == 'object'){ + if(res.errcode == 0){ + if(typeof res.token != 'undefined') $.Token = res.token + }else if(res.message){ + console.log(`${type} ${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + break; + case 'accessLogWithAD': + case 'drawContent': + break; + case 'activity_load': + case 'mission': + case 'shopList': + case 'loadUniteOpenCard': + case 'setMixNick': + case 'uniteOpenCardOne': + case 'checkOpenCard': + case 'followShop': + case 'addCart': + case 'myAward': + case 'missionInviteList': + case '抽奖': + title = '' + if(type == "followShop") title = '关注' + if(type == "addCart") title = '加购' + if(typeof res == 'object'){ + if(res.success && res.success === true && res.data){ + if(res.data.status && res.data.status == 200){ + res = res.data + if(type != "setMixNick" && (res.msg || res.data.isOpenCard || res.data.remark)) console.log(`${title && title+":" || ""}${res.msg || res.data.isOpenCard || res.data.remark || ''}`) + if(type == "activity_load"){ + if(res.msg || res.data.isOpenCard) { + if((res.msg || res.data.isOpenCard || '').indexOf('绑定成功') > -1) $.toBind = 1 + } + if(res.data){ + $.endTime = res.data.cusActivity.endTime || 0 + $.MixNick = res.data.buyerNick || "" + $.usedChance = res.data.missionCustomer.usedChance || 0 + $.hasCollectShop = res.data.missionCustomer.hasCollectShop || 0 + } + }else if(type == "shopList"){ + $.openList = res.data.cusShops || [] + }else if(type == "mission"){ + if(res.data.remark.indexOf('不是会员') > -1){ + $.openCard = true + }else{ + $.openCard = false + } + }else if(type == "uniteOpenCardOne"){ + $.uniteOpenCar = res.msg || res.data.msg || '' + }else if(type == "myAward"){ + console.log(`我的奖品:`) + let num = 0 + let value = 0 + for(let i in res.data.list || []){ + let item = res.data.list[i] + if(item.awardDes == '20'){ + num++ + value = item.awardDes + }else{ + console.log(`${item.awardName}`) + } + } + if(num > 0) console.log(`邀请好友(${num}):${num*parseInt(value, 10) || 30}京豆`) + }else if(type == "missionInviteList"){ + console.log(`邀请人数(${res.data.invitedLogList.total})`) + } + }else if(res.data.msg){ + console.log(`${title || type} ${res.data.msg || ''}`) + }else if(res.errorMessage){ + if(res.errorMessage.indexOf('火爆') >-1 ){ + $.hotFlag = true + } + console.log(`${title || type} ${res.errorMessage || ''}`) + }else{ + console.log(`${title || type} ${data}`) + } + }else if(res.errorMessage){ + console.log(`${title || type} ${res.errorMessage || ''}`) + }else{ + console.log(`${title || type} ${data}`) + } + }else{ + console.log(`${title || type} ${data}`) + } + break; + default: + console.log(`${title || type}-> ${data}`); + } + if(typeof res == 'object'){ + if(res.errorMessage){ + if(res.errorMessage.indexOf('火爆') >-1 ){ + $.hotFlag = true + } + } + } + } catch (e) { + console.log(e) + } +} + +function getPostRequest(url, body, method="POST") { + let headers = { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Content-Type": "application/x-www-form-urlencoded", + "Cookie": cookie, + "User-Agent": $.UA, + "X-Requested-With": "XMLHttpRequest" + } + if(url.indexOf('https://jinggengjcq-isv.isvjcloud.com') > -1){ + headers["Origin"] = `https://jinggengjcq-isv.isvjcloud.com` + headers["Content-Type"] = `application/json; charset=utf-8` + delete headers["Cookie"] + } + // console.log(headers) + // console.log(headers.Cookie) + return {url: url, method: method, headers: headers, body: body, timeout:30000}; +} + + +function taskPostUrl(url, t) { + + const b = { + "jsonRpc": "2.0", + "params": { + "commonParameter": { + "appkey": $.appkey, + "m": "POST", + "timestamp": Date.now(), + "userId": $.userId + }, + "admJson": { + "actId": $.actId, + "userId": $.userId, + ...t, + "method": url, + "buyerNick": ($.MixNick || ''), + } + }, + } + if(url.indexOf('missionInviteList') > -1){ + delete b.params.admJson.actId + } + return $.toStr(b,b) +} +async function getUA(){ + $.UA = `jdapp;iPhone;10.1.4;13.1.2;${randomString(40)};network/wifi;model/iPhone8,1;addressid/2308460611;appBuild/167814;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_1_2 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 jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} + +function joinShop() { + if(!$.joinVenderId) return + return new Promise(async resolve => { + $.shopactivityId = '' + await $.wait(1000) + await getshopactivityId() + let activityId = `` + if($.shopactivityId) activityId = `,"activityId":${$.shopactivityId}` + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body={"venderId":"${$.joinVenderId}","shopId":"${$.joinVenderId}","bindByVerifyCodeFlag":1,"registerExtend":{},"writeChildFlag":0${activityId},"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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + // console.log(data) + let res = $.toObj(data); + if(typeof res == 'object'){ + if(res.success === true){ + console.log(res.message) + if(res.result && res.result.giftInfo){ + for(let i of res.result.giftInfo.giftList){ + console.log(`入会获得:${i.discountString}${i.prizeName}${i.secondLineDesc}`) + } + } + }else if(typeof res == 'object' && res.message){ + console.log(`${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function getshopactivityId() { + return new Promise(resolve => { + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body=%7B%22venderId%22%3A%22${$.joinVenderId}%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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + let res = $.toObj(data); + if(res.success == true){ + // console.log($.toStr(res.result)) + console.log(`入会:${res.result.shopMemberCardInfo.venderCardName || ''}`) + $.shopactivityId = res.result.interestsRuleList && res.result.interestsRuleList[0] && res.result.interestsRuleList[0].interestsInfo && res.result.interestsRuleList[0].interestsInfo.activityId || '' + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +// 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)} + diff --git a/activity/jd_opencard7.js b/activity/jd_opencard7.js new file mode 100644 index 0000000..a54e981 --- /dev/null +++ b/activity/jd_opencard7.js @@ -0,0 +1,526 @@ +/* +10.25~11.12 立即入会 瓜分百万京豆 + +cron 17 2,19 * * * https://raw.githubusercontent.com/KingRan/JDJB/main/jd_opencard7.js +**/ + +const $ = new Env("10.25~11.12 立即入会 瓜分百万京豆"); +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const notify = $.isNode() ? require('./sendNotify') : ''; +let cookiesArr = [], cookie = '', message = ''; +let ownCode = null; +let authorCodeList = [] +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => { }; +} else { + let cookiesData = $.getdata('CookiesJD') || "[]"; + cookiesData = JSON.parse(cookiesData); + cookiesArr = cookiesData.map(item => item.cookie); + cookiesArr.reverse(); + cookiesArr.push(...[$.getdata('CookieJD2'), $.getdata('CookieJD')]); + cookiesArr.reverse(); + cookiesArr = cookiesArr.filter(item => !!item); +} +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', { "open-url": "https://bean.m.jd.com/bean/signIndex.action" }); + return; + } + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i] + originCookie = cookiesArr[i] + newCookie = '' + $.UserName = decodeURIComponent(cookie.match(/pt_pin=(.+?);/) && cookie.match(/pt_pin=(.+?);/)[1]) + $.index = i + 1; + $.isLogin = true; + $.nickName = ''; + await checkCookie(); + console.log(`\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + if (!$.isLogin) { + console.log('更新ck'); + continue + } + authorCodeList = [ + '519d3cf326194283ac72331dfe5a3d8a', + '119fd8f789bc42dab50a4ad6a264e890' + ] + $.bean = 0; + $.ADID = getUUID('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', 1); + $.UUID = getUUID('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'); + // $.authorCode = authorCodeList[random(0, authorCodeList.length)] + $.authorCode = ownCode ? ownCode : authorCodeList[random(0, authorCodeList.length)] + $.authorNum = `${random(1000000, 9999999)}` + $.activityId = 'cfc218d9250d445a870b3c18b58b5475' + $.activityShopId = '1000015026' + $.activityUrl = `https://lzdz1-isv.isvjcloud.com/dingzhi/fashion/recruit/activity/${$.authorNum}?activityId=${$.activityId}&shareUuid=${encodeURIComponent($.authorCode)}&adsource=null&shareuserid4minipg=null&shopid=${$.activityShopId}&lng=00.000000&lat=00.000000&sid=&un_area=` + await rush(); + await $.wait(1000) + console.log("重复执行一次,技术有限不知道为什么") + await rush(); + if ($.bean > 0) { + message += `\n【京东账号${$.index}】${$.nickName || $.UserName} \n └ 获得 ${$.bean} 京豆。` + } + } + } + if (message !== '') { + if ($.isNode()) { + await notify.sendNotify($.name, message, '', `\n`); + } else { + $.msg($.name, '有点儿收获', message); + } + } +})() + .catch((e) => { + $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') + }) + .finally(() => { + $.done(); + }) + + +async function rush() { + $.token = null; + $.secretPin = null; + $.openCardActivityId = null + $.openStatusNum = 0 + await getFirstLZCK() + await getToken(); + await task('wxCommonInfo/getSystemConfigForNew', `activityId=${$.activityId}&activityType=99`, 1) + await task('dz/common/getSimpleActInfoVo', `activityId=${$.activityId}`, 1) + if ($.token) { + await getMyPing(); + if ($.secretPin) { + console.log("去助力: "+$.authorCode) + await $.wait(1000) + await task('common/accessLogWithAD', `venderId=${$.venderId}&code=99&pin=${encodeURIComponent($.secretPin)}&activityId=${$.activityId}&pageUrl=${$.activityUrl}&subType=app&adSource=null`, 1); + await task('wxActionCommon/getUserInfo', `pin=${encodeURIComponent($.secretPin)}`, 1) + await task('fashion/recruit/activityContent', `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}&pinImg=${encodeURIComponent($.pinImg)}&nick=${encodeURIComponent($.pin)}&cjyxPin=&cjhyPin=&shareUuid=${encodeURIComponent($.authorCode)}`) + await task("fashion/recruit/getInitInfo", `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}`) + await $.wait(1000) + await task('fashion/recruit/initOpenCard', `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}&shareUuid=${encodeURIComponent($.authorCode)}`) + if ($.activityContent) { + for(let i in $.openInfo){ + console.log($.openInfo[i]) + if(!$.openInfo[i]['openStatus']){ + console.log("加入会员: "+$.openInfo[i]['venderId']) + await getShopOpenCardInfo({ "venderId": $.openInfo[i]['venderId'], "channel": "401" }, $.openInfo[i]['venderId']) + await bindWithVender({ "venderId": $.openInfo[i]['venderId'], "bindByVerifyCodeFlag": 1, "registerExtend": {}, "writeChildFlag": 0, "activityId": $.openCardActivityId, "channel": 401 }, $.openInfo[i]['venderId']) + await $.wait(1000) + } + } + console.log("关注店铺: ") + await task("fashion/recruit/saveTask", `activityId=${$.activityId}&actorUuid=${encodeURIComponent($.actorUuid)}&shareUuid=${encodeURIComponent($.authorCode)}&pin=${encodeURIComponent($.secretPin)}&taskType=23&taskValue=23`) + await $.wait(1000) + console.log("流览会场: ") + await task("fashion/recruit/saveTask", `activityId=${$.activityId}&actorUuid=${encodeURIComponent($.actorUuid)}&shareUuid=${encodeURIComponent($.authorCode)}&pin=${encodeURIComponent($.secretPin)}&taskType=12&taskValue=12`) + } + await task("fashion/recruit/getInitInfo", `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}`) + } else { + $.log("没有成功获取到用户信息") + } + } else { + $.log("没有成功获取到用户鉴权信息") + } +} + +function task(function_id, body, isCommon = 0) { + return new Promise(resolve => { + $.post(taskUrl(function_id, body, isCommon), async (err, resp, data) => { + try { + if (err) { + $.log(err) + } else { + + if (data) { + data = JSON.parse(data); + if (data.result) { + switch (function_id) { + case 'dz/common/getSimpleActInfoVo': + $.jdActivityId = data.data.jdActivityId; + $.venderId = data.data.venderId; + $.activityShopId = data.data.shopId; + $.activityType = data.data.activityType; + break; + case 'wxActionCommon/getUserInfo': + $.pinImg = 'https://img10.360buyimg.com/imgzone/jfs/t1/7020/27/13511/6142/5c5138d8E4df2e764/5a1216a3a5043c5d.png' + break; + case 'fashion/recruit/activityContent': + if (!data.data.hasEnd) { + $.log(`开启【${data.data.activityName}】活动`) + $.log("-------------------") + if ($.index === 1) { + ownCode = data.data.actorUuid + console.log("你的助力码 -> "+ownCode) + } + $.activityContent = data.data; + $.actorUuid = data.data.actorUuid; + } else { + $.log("活动已经结束"); + } + break; + case 'fashion/recruit/saveFirst': + if(data.result){ + console.log("获得抽奖次数") + } + break; + case 'fashion/recruit/saveTask': + console.log(data) + break; + case 'fashion/recruit/getInitInfo': + console.log(data) + break; + case 'fashion/recruit/initOpenCard': + $.openInfo = data.data.openInfo + break; + default: + $.log(JSON.stringify(data)) + break; + } + } else { + $.log(JSON.stringify(data)) + } + } else { + $.log("京东没有返回数据") + } + } + } catch (error) { + $.log(error) + } finally { + resolve(); + } + }) + }) +} +function getShopOpenCardInfo(body, venderId) { + let opt = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body=${encodeURIComponent(JSON.stringify(body))}&client=H5&clientVersion=9.2.0&uuid=88888`, + headers: { + Host: 'api.m.jd.com', + Accept: '*/*', + Connection: 'keep-alive', + Cookie: cookie, + 'User-Agent': `jdapp;iPhone;9.5.4;13.6;${$.UUID};network/wifi;ADID/${$.ADID};model/iPhone10,3;addressid/0;appBuild/167668;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1`, + 'Accept-Language': 'zh-cn', + Referer: `https://shopmember.m.jd.com/shopcard/?venderId=${venderId}}&channel=801&returnUrl=${encodeURIComponent($.activityUrl)}`, + 'Accept-Encoding': 'gzip, deflate, br' + } + } + return new Promise(resolve => { + $.get(opt, (err, resp, data) => { + try { + if (err) { + console.log(err) + } else { + res = JSON.parse(data) + if (res.success) { + if (res.result.interestsRuleList) { + $.openCardActivityId = res.result.interestsRuleList[0].interestsInfo.activityId; + } + } + } + } catch (error) { + console.log(error) + } finally { + resolve(); + } + }) + + }) +} +function bindWithVender(body, venderId) { + let opt = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body=${encodeURIComponent(JSON.stringify(body))}&client=H5&clientVersion=9.2.0&uuid=88888`, + headers: { + Host: 'api.m.jd.com', + Accept: '*/*', + Connection: 'keep-alive', + Cookie: cookie, + 'User-Agent': `jdapp;iPhone;9.5.4;13.6;${$.UUID};network/wifi;ADID/${$.ADID};model/iPhone10,3;addressid/0;appBuild/167668;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1`, + 'Accept-Language': 'zh-cn', + Referer: `https://shopmember.m.jd.com/shopcard/?venderId=${venderId}}&channel=801&returnUrl=${encodeURIComponent($.activityUrl)}`, + 'Accept-Encoding': 'gzip, deflate, br' + } + } + return new Promise(resolve => { + $.get(opt, (err, resp, data) => { + try { + if (err) { + console.log(err) + } else { + res = JSON.parse(data) + if (res.success) { + if (res.result.giftInfo && res.result.giftInfo.giftList) { + for (const vo of res.result.giftInfo.giftList) { + if (vo.prizeType === 4) { + $.log(`获得【${vo.quantity}】京豆`) + $.bean += vo.quantity + } + } + } + } + } + } catch (error) { + console.log(error) + } finally { + resolve(); + } + }) + + }) +} +function taskUrl(function_id, body, isCommon) { + return { + url: isCommon ? `https://lzdz1-isv.isvjcloud.com/${function_id}` : `https://lzdz1-isv.isvjcloud.com/dingzhi/${function_id}`, + headers: { + Host: 'lzdz1-isv.isvjcloud.com', + Accept: 'application/json', + 'X-Requested-With': 'XMLHttpRequest', + 'Accept-Language': 'zh-cn', + 'Accept-Encoding': 'gzip, deflate, br', + 'Content-Type': 'application/x-www-form-urlencoded', + Origin: 'https://lzdz1-isv.isvjcloud.com', + 'User-Agent': `jdapp;iPhone;9.5.4;13.6;${$.UUID};network/wifi;ADID/${$.ADID};model/iPhone10,3;addressid/0;appBuild/167668;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1`, + Connection: 'keep-alive', + Referer: $.activityUrl, + Cookie: cookie + }, + body: body + + } +} +function getAuthorCodeList(url) { + return new Promise(resolve => { + const options = { + url: `${url}?${new Date()}`, "timeout": 10000, headers: { + "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1 Edg/87.0.4280.88" + } + }; + $.get(options, async (err, resp, data) => { + try { + if (err) { + $.log(err) + } else { + if (data) data = JSON.parse(data) + } + } catch (e) { + $.logErr(e, resp) + data = null; + } finally { + resolve(data); + } + }) + }) +} +function getMyPing() { + let opt = { + url: `https://lzdz1-isv.isvjcloud.com/customer/getMyPing`, + headers: { + Host: 'lzdz1-isv.isvjcloud.com', + Accept: 'application/json', + 'X-Requested-With': 'XMLHttpRequest', + 'Accept-Language': 'zh-cn', + 'Accept-Encoding': 'gzip, deflate, br', + 'Content-Type': 'application/x-www-form-urlencoded', + Origin: 'https://lzdz1-isv.isvjcloud.com', + 'User-Agent': `jdapp;iPhone;9.5.4;13.6;${$.UUID};network/wifi;ADID/${$.ADID};model/iPhone10,3;addressid/0;appBuild/167668;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1`, + Connection: 'keep-alive', + Referer: $.activityUrl, + Cookie: cookie, + }, + body: `userId=${$.venderId}&token=${$.token}&fromType=APP` + } + return new Promise(resolve => { + $.post(opt, (err, resp, data) => { + try { + if (err) { + $.log(err) + } else { + if (resp['headers']['set-cookie']) { + cookie = `${originCookie}` + if ($.isNode()) { + for (let sk of resp['headers']['set-cookie']) { + cookie = `${cookie}${sk.split(";")[0]};` + } + } else { + for (let ck of resp['headers']['Set-Cookie'].split(',')) { + cookie = `${cookie}${ck.split(";")[0]};` + } + } + } + if (resp['headers']['Set-Cookie']) { + cookie = `${originCookie}` + if ($.isNode()) { + for (let sk of resp['headers']['set-cookie']) { + cookie = `${cookie}${sk.split(";")[0]};` + } + } else { + for (let ck of resp['headers']['Set-Cookie'].split(',')) { + cookie = `${cookie}${ck.split(";")[0]};` + } + } + } + if (data) { + data = JSON.parse(data) + if (data.result) { + $.log(`你好:${data.data.nickname}`) + $.pin = data.data.nickname; + $.secretPin = data.data.secretPin; + cookie = `${cookie};AUTH_C_USER=${data.data.secretPin}` + } else { + $.log(data.errorMessage) + } + } else { + $.log("京东返回了空数据") + } + } + } catch (error) { + $.log(error) + } finally { + resolve(); + } + + }) + }) +} +function getFirstLZCK() { + return new Promise(resolve => { + $.get({ url: $.activityUrl }, (err, resp, data) => { + try { + if (err) { + console.log(err) + } else { + if (resp['headers']['set-cookie']) { + cookie = `${originCookie}` + if ($.isNode()) { + for (let sk of resp['headers']['set-cookie']) { + cookie = `${cookie}${sk.split(";")[0]};` + } + } else { + for (let ck of resp['headers']['Set-Cookie'].split(',')) { + cookie = `${cookie}${ck.split(";")[0]};` + } + } + } + if (resp['headers']['Set-Cookie']) { + cookie = `${originCookie}` + if ($.isNode()) { + for (let sk of resp['headers']['set-cookie']) { + cookie = `${cookie}${sk.split(";")[0]};` + } + } else { + for (let ck of resp['headers']['Set-Cookie'].split(',')) { + cookie = `${cookie}${ck.split(";")[0]};` + } + } + } + } + } catch (error) { + console.log(error) + } finally { + resolve(); + } + }) + }) +} +function getToken() { + let opt = { + url: `https://api.m.jd.com/client.action?functionId=isvObfuscator`, + headers: { + Host: 'api.m.jd.com', + 'Content-Type': 'application/x-www-form-urlencoded', + Accept: '*/*', + Connection: 'keep-alive', + Cookie: cookie, + 'User-Agent': 'JD4iPhone/167650 (iPhone; iOS 13.7; Scale/3.00)', + 'Accept-Language': 'zh-Hans-CN;q=1', + 'Accept-Encoding': 'gzip, deflate, br', + }, + body: `body=%7B%22url%22%3A%20%22https%3A//lzkj-isv.isvjcloud.com%22%2C%20%22id%22%3A%20%22%22%7D&uuid=hjudwgohxzVu96krv&client=apple&clientVersion=9.4.0&st=1620476162000&sv=111&sign=f9d1b7e3b943b6a136d54fe4f892af05` + } + return new Promise(resolve => { + $.post(opt, (err, resp, data) => { + try { + if (err) { + $.log(err) + } else { + if (data) { + data = JSON.parse(data); + if (data.code === "0") { + $.token = data.token + } + } else { + $.log("京东返回了空数据") + } + } + } catch (error) { + $.log(error) + } finally { + resolve(); + } + }) + }) +} +function random(min, max) { + + return Math.floor(Math.random() * (max - min)) + min; + +} +function getUUID(format = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', UpperCase = 0) { + return format.replace(/[xy]/g, function (c) { + var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8); + if (UpperCase) { + uuid = v.toString(36).toUpperCase(); + } else { + uuid = v.toString(36) + } + return uuid; + }); +} +function checkCookie() { + const options = { + url: "https://me-api.jd.com/user_new/info/GetJDUserInfoUnion", + headers: { + "Host": "me-api.jd.com", + "Accept": "*/*", + "Connection": "keep-alive", + "Cookie": cookie, + "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.2 Mobile/15E148 Safari/604.1", + "Accept-Language": "zh-cn", + "Referer": "https://home.m.jd.com/myJd/newhome.action?sceneval=2&ufc=&", + "Accept-Encoding": "gzip, deflate, br", + } + }; + return new Promise(resolve => { + $.get(options, (err, resp, data) => { + try { + if (err) { + $.logErr(err) + } else { + if (data) { + data = JSON.parse(data); + if (data.retcode === "1001") { + $.isLogin = false; //cookie过期 + return; + } + if (data.retcode === "0" && data.data.hasOwnProperty("userInfo")) { + $.nickName = data.data.userInfo.baseInfo.nickname; + } + } else { + $.log('京东返回了空数据'); + } + } + } catch (e) { + $.logErr(e) + } finally { + resolve(); + } + }) + }) +} +// prettier-ignore +!function (n) { "use strict"; function t(n, t) { var r = (65535 & n) + (65535 & t); return (n >> 16) + (t >> 16) + (r >> 16) << 16 | 65535 & r } function r(n, t) { return n << t | n >>> 32 - t } function e(n, e, o, u, c, f) { return t(r(t(t(e, n), t(u, f)), c), o) } function o(n, t, r, o, u, c, f) { return e(t & r | ~t & o, n, t, u, c, f) } function u(n, t, r, o, u, c, f) { return e(t & o | r & ~o, n, t, u, c, f) } function c(n, t, r, o, u, c, f) { return e(t ^ r ^ o, n, t, u, c, f) } function f(n, t, r, o, u, c, f) { return e(r ^ (t | ~o), n, t, u, c, f) } function i(n, r) { n[r >> 5] |= 128 << r % 32, n[14 + (r + 64 >>> 9 << 4)] = r; var e, i, a, d, h, l = 1732584193, g = -271733879, v = -1732584194, m = 271733878; for (e = 0; e < n.length; e += 16)i = l, a = g, d = v, h = m, g = f(g = f(g = f(g = f(g = c(g = c(g = c(g = c(g = u(g = u(g = u(g = u(g = o(g = o(g = o(g = o(g, v = o(v, m = o(m, l = o(l, g, v, m, n[e], 7, -680876936), g, v, n[e + 1], 12, -389564586), l, g, n[e + 2], 17, 606105819), m, l, n[e + 3], 22, -1044525330), v = o(v, m = o(m, l = o(l, g, v, m, n[e + 4], 7, -176418897), g, v, n[e + 5], 12, 1200080426), l, g, n[e + 6], 17, -1473231341), m, l, n[e + 7], 22, -45705983), v = o(v, m = o(m, l = o(l, g, v, m, n[e + 8], 7, 1770035416), g, v, n[e + 9], 12, -1958414417), l, g, n[e + 10], 17, -42063), m, l, n[e + 11], 22, -1990404162), v = o(v, m = o(m, l = o(l, g, v, m, n[e + 12], 7, 1804603682), g, v, n[e + 13], 12, -40341101), l, g, n[e + 14], 17, -1502002290), m, l, n[e + 15], 22, 1236535329), v = u(v, m = u(m, l = u(l, g, v, m, n[e + 1], 5, -165796510), g, v, n[e + 6], 9, -1069501632), l, g, n[e + 11], 14, 643717713), m, l, n[e], 20, -373897302), v = u(v, m = u(m, l = u(l, g, v, m, n[e + 5], 5, -701558691), g, v, n[e + 10], 9, 38016083), l, g, n[e + 15], 14, -660478335), m, l, n[e + 4], 20, -405537848), v = u(v, m = u(m, l = u(l, g, v, m, n[e + 9], 5, 568446438), g, v, n[e + 14], 9, -1019803690), l, g, n[e + 3], 14, -187363961), m, l, n[e + 8], 20, 1163531501), v = u(v, m = u(m, l = u(l, g, v, m, n[e + 13], 5, -1444681467), g, v, n[e + 2], 9, -51403784), l, g, n[e + 7], 14, 1735328473), m, l, n[e + 12], 20, -1926607734), v = c(v, m = c(m, l = c(l, g, v, m, n[e + 5], 4, -378558), g, v, n[e + 8], 11, -2022574463), l, g, n[e + 11], 16, 1839030562), m, l, n[e + 14], 23, -35309556), v = c(v, m = c(m, l = c(l, g, v, m, n[e + 1], 4, -1530992060), g, v, n[e + 4], 11, 1272893353), l, g, n[e + 7], 16, -155497632), m, l, n[e + 10], 23, -1094730640), v = c(v, m = c(m, l = c(l, g, v, m, n[e + 13], 4, 681279174), g, v, n[e], 11, -358537222), l, g, n[e + 3], 16, -722521979), m, l, n[e + 6], 23, 76029189), v = c(v, m = c(m, l = c(l, g, v, m, n[e + 9], 4, -640364487), g, v, n[e + 12], 11, -421815835), l, g, n[e + 15], 16, 530742520), m, l, n[e + 2], 23, -995338651), v = f(v, m = f(m, l = f(l, g, v, m, n[e], 6, -198630844), g, v, n[e + 7], 10, 1126891415), l, g, n[e + 14], 15, -1416354905), m, l, n[e + 5], 21, -57434055), v = f(v, m = f(m, l = f(l, g, v, m, n[e + 12], 6, 1700485571), g, v, n[e + 3], 10, -1894986606), l, g, n[e + 10], 15, -1051523), m, l, n[e + 1], 21, -2054922799), v = f(v, m = f(m, l = f(l, g, v, m, n[e + 8], 6, 1873313359), g, v, n[e + 15], 10, -30611744), l, g, n[e + 6], 15, -1560198380), m, l, n[e + 13], 21, 1309151649), v = f(v, m = f(m, l = f(l, g, v, m, n[e + 4], 6, -145523070), g, v, n[e + 11], 10, -1120210379), l, g, n[e + 2], 15, 718787259), m, l, n[e + 9], 21, -343485551), l = t(l, i), g = t(g, a), v = t(v, d), m = t(m, h); return [l, g, v, m] } function a(n) { var t, r = "", e = 32 * n.length; for (t = 0; t < e; t += 8)r += String.fromCharCode(n[t >> 5] >>> t % 32 & 255); return r } function d(n) { var t, r = []; for (r[(n.length >> 2) - 1] = void 0, t = 0; t < r.length; t += 1)r[t] = 0; var e = 8 * n.length; for (t = 0; t < e; t += 8)r[t >> 5] |= (255 & n.charCodeAt(t / 8)) << t % 32; return r } function h(n) { return a(i(d(n), 8 * n.length)) } function l(n, t) { var r, e, o = d(n), u = [], c = []; for (u[15] = c[15] = void 0, o.length > 16 && (o = i(o, 8 * n.length)), r = 0; r < 16; r += 1)u[r] = 909522486 ^ o[r], c[r] = 1549556828 ^ o[r]; return e = i(u.concat(d(t)), 512 + 8 * t.length), a(i(c.concat(e), 640)) } function g(n) { var t, r, e = ""; for (r = 0; r < n.length; r += 1)t = n.charCodeAt(r), e += "0123456789abcdef".charAt(t >>> 4 & 15) + "0123456789abcdef".charAt(15 & t); return e } function v(n) { return unescape(encodeURIComponent(n)) } function m(n) { return h(v(n)) } function p(n) { return g(m(n)) } function s(n, t) { return l(v(n), v(t)) } function C(n, t) { return g(s(n, t)) } function A(n, t, r) { return t ? r ? s(t, n) : C(t, n) : r ? m(n) : p(n) } $.md5 = A }(this); +function Env(t, e) { "undefined" != typeof process && JSON.stringify(process.env).indexOf("GITHUB") > -1 && process.exit(0); class s { constructor(t) { this.env = t } send(t, e = "GET") { t = "string" == typeof t ? { url: t } : t; let s = this.get; return "POST" === e && (s = this.post), new Promise((e, i) => { s.call(this, t, (t, s, r) => { t ? i(t) : e(s) }) }) } get(t) { return this.send.call(this.env, t) } post(t) { return this.send.call(this.env, t, "POST") } } return new class { constructor(t, e) { this.name = t, this.http = new s(this), this.data = null, this.dataFile = "box.dat", this.logs = [], this.isMute = !1, this.isNeedRewrite = !1, this.logSeparator = "\n", this.startTime = (new Date).getTime(), Object.assign(this, e), this.log("", `🔔${this.name}, 开始!`) } isNode() { return "undefined" != typeof module && !!module.exports } isQuanX() { return "undefined" != typeof $task } isSurge() { return "undefined" != typeof $httpClient && "undefined" == typeof $loon } isLoon() { return "undefined" != typeof $loon } toObj(t, e = null) { try { return JSON.parse(t) } catch { return e } } toStr(t, e = null) { try { return JSON.stringify(t) } catch { return e } } getjson(t, e) { let s = e; const i = this.getdata(t); if (i) try { s = JSON.parse(this.getdata(t)) } catch { } return s } setjson(t, e) { try { return this.setdata(JSON.stringify(t), e) } catch { return !1 } } getScript(t) { return new Promise(e => { this.get({ url: t }, (t, s, i) => e(i)) }) } runScript(t, e) { return new Promise(s => { let i = this.getdata("@chavy_boxjs_userCfgs.httpapi"); i = i ? i.replace(/\n/g, "").trim() : i; let r = this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout"); r = r ? 1 * r : 20, r = e && e.timeout ? e.timeout : r; const [o, h] = i.split("@"), n = { url: `http://${h}/v1/scripting/evaluate`, body: { script_text: t, mock_type: "cron", timeout: r }, headers: { "X-Key": o, Accept: "*/*" } }; this.post(n, (t, e, i) => s(i)) }).catch(t => this.logErr(t)) } loaddata() { if (!this.isNode()) return {}; { this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path"); const t = this.path.resolve(this.dataFile), e = this.path.resolve(process.cwd(), this.dataFile), s = this.fs.existsSync(t), i = !s && this.fs.existsSync(e); if (!s && !i) return {}; { const i = s ? t : e; try { return JSON.parse(this.fs.readFileSync(i)) } catch (t) { return {} } } } } writedata() { if (this.isNode()) { this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path"); const t = this.path.resolve(this.dataFile), e = this.path.resolve(process.cwd(), this.dataFile), s = this.fs.existsSync(t), i = !s && this.fs.existsSync(e), r = JSON.stringify(this.data); s ? this.fs.writeFileSync(t, r) : i ? this.fs.writeFileSync(e, r) : this.fs.writeFileSync(t, r) } } lodash_get(t, e, s) { const i = e.replace(/\[(\d+)\]/g, ".$1").split("."); let r = t; for (const t of i) if (r = Object(r)[t], void 0 === r) return s; return r } lodash_set(t, e, s) { return Object(t) !== t ? t : (Array.isArray(e) || (e = e.toString().match(/[^.[\]]+/g) || []), e.slice(0, -1).reduce((t, s, i) => Object(t[s]) === t[s] ? t[s] : t[s] = Math.abs(e[i + 1]) >> 0 == +e[i + 1] ? [] : {}, t)[e[e.length - 1]] = s, t) } getdata(t) { let e = this.getval(t); if (/^@/.test(t)) { const [, s, i] = /^@(.*?)\.(.*?)$/.exec(t), r = s ? this.getval(s) : ""; if (r) try { const t = JSON.parse(r); e = t ? this.lodash_get(t, i, "") : e } catch (t) { e = "" } } return e } setdata(t, e) { let s = !1; if (/^@/.test(e)) { const [, i, r] = /^@(.*?)\.(.*?)$/.exec(e), o = this.getval(i), h = i ? "null" === o ? null : o || "{}" : "{}"; try { const e = JSON.parse(h); this.lodash_set(e, r, t), s = this.setval(JSON.stringify(e), i) } catch (e) { const o = {}; this.lodash_set(o, r, t), s = this.setval(JSON.stringify(o), i) } } else s = this.setval(t, e); return s } getval(t) { return this.isSurge() || this.isLoon() ? $persistentStore.read(t) : this.isQuanX() ? $prefs.valueForKey(t) : this.isNode() ? (this.data = this.loaddata(), this.data[t]) : this.data && this.data[t] || null } setval(t, e) { return this.isSurge() || this.isLoon() ? $persistentStore.write(t, e) : this.isQuanX() ? $prefs.setValueForKey(t, e) : this.isNode() ? (this.data = this.loaddata(), this.data[e] = t, this.writedata(), !0) : this.data && this.data[e] || null } initGotEnv(t) { this.got = this.got ? this.got : require("got"), this.cktough = this.cktough ? this.cktough : require("tough-cookie"), this.ckjar = this.ckjar ? this.ckjar : new this.cktough.CookieJar, t && (t.headers = t.headers ? t.headers : {}, void 0 === t.headers.Cookie && void 0 === t.cookieJar && (t.cookieJar = this.ckjar)) } get(t, e = (() => { })) { t.headers && (delete t.headers["Content-Type"], delete t.headers["Content-Length"]), this.isSurge() || this.isLoon() ? (this.isSurge() && this.isNeedRewrite && (t.headers = t.headers || {}, Object.assign(t.headers, { "X-Surge-Skip-Scripting": !1 })), $httpClient.get(t, (t, s, i) => { !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i) })) : this.isQuanX() ? (this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, { hints: !1 })), $task.fetch(t).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => e(t))) : this.isNode() && (this.initGotEnv(t), this.got(t).on("redirect", (t, e) => { try { if (t.headers["set-cookie"]) { const s = t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString(); s && this.ckjar.setCookieSync(s, null), e.cookieJar = this.ckjar } } catch (t) { this.logErr(t) } }).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => { const { message: s, response: i } = t; e(s, i, i && i.body) })) } post(t, e = (() => { })) { if (t.body && t.headers && !t.headers["Content-Type"] && (t.headers["Content-Type"] = "application/x-www-form-urlencoded"), t.headers && delete t.headers["Content-Length"], this.isSurge() || this.isLoon()) this.isSurge() && this.isNeedRewrite && (t.headers = t.headers || {}, Object.assign(t.headers, { "X-Surge-Skip-Scripting": !1 })), $httpClient.post(t, (t, s, i) => { !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i) }); else if (this.isQuanX()) t.method = "POST", this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, { hints: !1 })), $task.fetch(t).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => e(t)); else if (this.isNode()) { this.initGotEnv(t); const { url: s, ...i } = t; this.got.post(s, i).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => { const { message: s, response: i } = t; e(s, i, i && i.body) }) } } time(t, e = null) { const s = e ? new Date(e) : new Date; let i = { "M+": s.getMonth() + 1, "d+": s.getDate(), "H+": s.getHours(), "m+": s.getMinutes(), "s+": s.getSeconds(), "q+": Math.floor((s.getMonth() + 3) / 3), S: s.getMilliseconds() }; /(y+)/.test(t) && (t = t.replace(RegExp.$1, (s.getFullYear() + "").substr(4 - RegExp.$1.length))); for (let e in i) new RegExp("(" + e + ")").test(t) && (t = t.replace(RegExp.$1, 1 == RegExp.$1.length ? i[e] : ("00" + i[e]).substr(("" + i[e]).length))); return t } msg(e = t, s = "", i = "", r) { const o = t => { if (!t) return t; if ("string" == typeof t) return this.isLoon() ? t : this.isQuanX() ? { "open-url": t } : this.isSurge() ? { url: t } : void 0; if ("object" == typeof t) { if (this.isLoon()) { let e = t.openUrl || t.url || t["open-url"], s = t.mediaUrl || t["media-url"]; return { openUrl: e, mediaUrl: s } } if (this.isQuanX()) { let e = t["open-url"] || t.url || t.openUrl, s = t["media-url"] || t.mediaUrl; return { "open-url": e, "media-url": s } } if (this.isSurge()) { let e = t.url || t.openUrl || t["open-url"]; return { url: e } } } }; if (this.isMute || (this.isSurge() || this.isLoon() ? $notification.post(e, s, i, o(r)) : this.isQuanX() && $notify(e, s, i, o(r))), !this.isMuteLog) { let t = ["", "==============📣系统通知📣=============="]; t.push(e), s && t.push(s), i && t.push(i), console.log(t.join("\n")), this.logs = this.logs.concat(t) } } log(...t) { t.length > 0 && (this.logs = [...this.logs, ...t]), console.log(t.join(this.logSeparator)) } logErr(t, e) { const s = !this.isSurge() && !this.isQuanX() && !this.isLoon(); s ? this.log("", `❗️${this.name}, 错误!`, t.stack) : this.log("", `❗️${this.name}, 错误!`, t) } wait(t) { return new Promise(e => setTimeout(e, t)) } done(t = {}) { const e = (new Date).getTime(), s = (e - this.startTime) / 1e3; this.log("", `🔔${this.name}, 结束! 🕛 ${s} 秒`), this.log(), (this.isSurge() || this.isQuanX() || this.isLoon()) && $done(t) } }(t, e) } diff --git a/activity/jd_opencard8.js b/activity/jd_opencard8.js new file mode 100644 index 0000000..6824677 --- /dev/null +++ b/activity/jd_opencard8.js @@ -0,0 +1,17 @@ +/* +婴乐家会员日 + +17 3,11,19 * * * https://raw.githubusercontent.com/KingRan/JDJB/main/jd_opencard8.js + +*/ +const $ = new Env("婴乐家会员日"); +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const notify = $.isNode() ? require('./sendNotify') : ''; +const cp = $.isNode() ? require('child_process') : ''; +let cookiesArr = [], cookie = '', message = ''; +const Base64 = require("js-base64") +let ownCode = {}; +var _0xod9='jsjiami.com.v6',_0x4d72=[_0xod9,'KhnCui0=','wrLCjxE=','AsKMw53CgA==','wrzDpMK4','w7HDj8OhDXY=','wqLDiAHDmcKAwpk=','5L+h5aeT776J','I8KIKGQ=','IBHCrSc+w5/DgMK3','SD7Dgg==','wpvCrsOQCA==','H8KWOiRcwpDDq3M=','wrFKRB7DjV0tw7sO','cMOpw44p','QsOPw5MEbcOcwrJcbA==','wolAwooLw71uNELCmsK9SlPChw==','G8K7wqvDusOPw7kjK8K0','w4LChcKiw7PDpsORwoLClE7DsmgA','O8OLVcOGYg==','w5bjgaHku6XkuZDotIzljKA=','KcKAP24Rw7/CsMOd','w7x7aWwKw7fCpmLCh+KUsArojJjlv6HDgw==','csKVwrRx','a+S4rOiwiOOAkQ==','wrzDghU=','MsOGd8OmXcKLwpUl','w43CvzHDogrCslPCtg==','wrJhwrXDnSfChBlo','w67CjMOrNx3ChwZo','wrhFXhjDrA==','Ww5LwqNG','w7kVwqVBw7Y=','A8O5C3su','5rOZ5py55ouc5YiI6I+U5Y+f5YmD5rWV5YmJ5L+65oGJ','wpRkw6R+w7g=','wqV+wo7Cn8K+GnVVZWs=','DsKZw53CkcOQw6HCnsOCwo96IcO+O8Osw5XCtQHCoMOqwpI9w7XCqzzCk8Kdw50Ywr57YsODVSLCpMKwwrnCuUPCisKMwpTCowBZ','wqlhwoLCn8K/W31ZdWLDtsK8Q8KzwqgZw6Q=','wrvDtR7CjRbCpsKaw6fChsOGA8OZTMO5w7rDvAPDjsO7wqrCnMOLJiDDl8KRAcKuwpjCmsKiw4Vkwq1Nwrpod8OfwoZPwrrDp8KzJ8O8w6IcEMKXw74lBlsLw7k+esOBGjvCiB1nF8OZOnvCgGBWRmnDvcKDw7zClw7DvcKnMMK+DsKlPcOww5fCmcK+CcOHGQ==','w4dxw7o5A1QUwqR4','w4Vsw5BGw6cdcsKhwpDCn2bCvxTCuxAAVMObw48mPj06H8KiwoUMasOJWcKiRcKxw51ob8ObO8KeN8KH','aTpOw4tzPcKKb1bDtGLCiA==','w7nCrkA=','wp0ofsOmEQ==','EB86wrJKwqnDosKxVsKww4fCh8K4w6HCm8O0w4zDsMKGw53Du29yOw==','CsKBw7BKwo3Dl8K+diPCssK9wpQ7w5VtAHXCg8Ky','J8Kpw6DCpQ==','wrnDkMOqfSvCt8OpO8KNOsKpEcKgwpYxKi9oND0XQMKAIsKSw7zCtMO8wppTwpvDgMOqw6Rbw7pmX8O+Oi3DhcO1wonCvcKwZMKEAsO6wq1AHMO3B8ORwoB2wrHDucOTwrQFw7vDlsOXwpR2wqHDl011wpo6wow6woLCsMO8VcK5wrjCrBvDr8KjwofCvcKeGU3DoMObw6vDjsOrYsK6AFMvwo/DgcKgM8KHADxZKHxnUyZ2V0Q1w6rDgMKCw6YLw4zDvMK0OVJgwqVHKgrCpHbCusOOPsOQw7vDvcKgVHVaPMO4QzfCkcORQivDssO/cCvCtQpnG1fDk8O1w5bDl1McwrJqwrgpwqIsEEdJS8KTwqfCry7CqsKGa3rCncO1w4PDs8KM','LsOwwrvCmsK4Y1NnwonDs2DDkEzCqMOYLHt3AMO0woBLaR4=','U8O/w7w+Ow==','TS9Owqpr','FcKdCAh2','SMKHwrtKJw==','XzLDmA==','w6ZWwqkrw68=','DsOzw5tFMQ==','ZMKnw6xCwpQ=','JcOlwrM=','5L6f5aay776+','KcKUwoDDrg==','BsK3wqvDo8OEw6weJw==','w78awr8=','dMKRwqF+','T8KWw6NewpXDr8Knw4M=','w6TChMO8PQ==','cQnDtcOBX3IcYcOIw5PCsBwa','OS3Dg8OnclkPV8Oz','w6zChzbDlBE=','JsOnwqbDukU=','J8Ohw4N+GQ==','A8KaKjpewoU=','woZiwq7Ch8Og','wpR2w7lBw6w=','w4Rww7s4','w7PDi8OgC3/DhQ==','EMKcLSZEwpjDsm8rXw==','FxfCq39x','CWfDgsKcwps=','XsO8w7c=','Q8OLw54SZ8OF','IMKcMVUX','W8Oyw4nCvsOM','J8K5wo3CgsKpaE9BwoTCvTE=','M8KGD3Etw7fCs8Of','wqbDsg/CjyzDssOTwqc=','wqszET1v','wrTCpDNTZw==','wpF7w45sw6U=','wrN4SwnDgg==','EMKPMGFfw5/DrHJMWG9F','wqVcw7s=','ER4+wrIXw7PDp8KISMK6','w45twqUzAw==','wot7w4hfw7FJKcKzwrnDminDshXDvB8KDsOuw4U5Yjc5GMO6w5JWdsKGCsOwWcKrw5ozM8KTc8OPa8KCAj9nASnDl8OyTQrCpcKCwrd3IEEKbS4JKRM/Q8OAwoPCk8O0EMOOwrnCoiXCikrCtwbDkMOTwr7Di8K+BMOcHMOEwq8=','wq3ClARjSsO6w4rCqjg=','wppfwrLCmMO1','DcKcOXQX','w6XDucORJEA=','wpbCmcKTwqE=','Q17CqcOjFGYBBcOObE/Dt8OMYsKIZsKXw750','wo9fwqLCqw==','wpZJTTXDkg==','NsKmLXs8w4AnwoLCoDllecOSAS0uw5rDoSF9OMOmbcOD','w6LCtcKBw5fDmw==','WyFvwqpa','IUXCvsOyMw==','wpLDpAXDlcKq','PMK3woHCk8Ks','w6d3w5oDIA==','Hh3Chm9S','HcO0BFw2','D8OIAWEo','wrdlwrI=','PMKSwqnDicOk','TsOSw4vCtsOk','wp8YBAB/','wpnDjw3CliA=','w5TCh8K8w7XDoA==','PcKUwobDvMOG','wpjDl8OjwrIEZcO4','D0nDusK+wrk=','L8OyLEIZ','wrcEbcOLEg==','w4Zgw7slAUc=','LSHDhsOhXkM5UQ==','wrELUsOKCxMNw4g=','MMOpw5d5MFPDvcKz','ZcKjw7R/wrQ=','worDnzDDgcK+','w6hzwp0yw6c=','wrx+wpjCmsO/Dw==','Xz7DisKiBmRHwrQ=','w5Nsw64kIVoOwrY=','w5hqw68=','TcOww5LCvw==','UcKNw6lPwp7DmsKzw5bClA==','44Cu5Lua6LGZ','wpJ6w51Bw7YacsOl','QcOLw4IFbQ==','EsOhfcOXSw==','Q8KKw6FdwpXDnMKp','VgVTwo9CTMKz','wp3DjwPCpz0=','wqvCrcKpwqpEw6g0wqR1IsOQwp9EAA==','w63ClsKSw7/DsQ==','f8KyHMKgwprCt8ORwoI=','E8KeKip7wp/DoHk=','wrAeLg==','w7h7wocbw5Q=','wpwYbMO6Iw==','Q8K2w6VkwoA=','CsKCw44=','KcKIMWA=','T8O+w5g=','w6FMd+iPu+W+veODhw==','CUXCrcO5F2AHFw==','44G35LmB6LOv','w5rCqTXDvg==','MD3CssKfehXDrcOHNmnCjcKCw6YG','FsKFMD8ew5HDonMEV2FcJU3DlXlK','wrLDsRrCkQzDv8OUwrzCjsOZBMOYS8Kkw7/DthbCjcO3wq/DksOaOSzDhsOCAMO0wp/DlMOu','wqjCqcK/wpUew6cIwr9sNw==','LcKOw4dGwqzDoV0fXnDCucOrVAgBw7tHw4fCmHMqTsKNw6HCqyRGcHknNXxgwqPDqhJzIGXDtXwbaH3DvEtePMO1Qj3CqMOTasOPPg==','OXDDosKawoXCjFtmIw==','wqfDjMO6BFbDicKZwo/DiMOAJQzCtMKY','fsKuO8KzwqDCvMKBw5k=','FcKFw4jCk8OGwpXDmMKOwo4p','KMO/wqDDsWLCoGBewqbCqA==','VsOiw5rCqMOXQA==','wrQOXsOkOw==','HMKFwoTCgsON','FcKjw6t8wpE=','wpXClSNlag==','L8KdKHUswqTDssKXcg3ChmNJw5kAasO3wobDl8OVw4rDosKWesOFC8OLPcKrQ8OEJcOMw5xKw4Jw','IcOkL2MtwpUgwrfCpGs/LMOYHnF+woDCoGgiXsK6N8OF','dsKbwpHDu8OUwqXDrsOow60BKHscw4XCpMKoTkY2','w7NFwpYb','CsKCw7pawp/DlMOjdFzCrcK7wpw3w58caA/DvMO8LQRHwqgOw7/Cq3/Ci0hRw7ZuF8OYExFBOFYowrvCuMKlwqrCu8OraQHCq8KBw6pPDRXCncKOw5fCm0dTw5cTfcOewoTDjcOCbDJkTHJxwqtYU3HDlGEGw640w6QhDMKEYMK1CsO3wprDtcOvwpPDtsK2Q8KZwp7CmVYTw7MmwqdePsK7AVLCsMKNw5Arw4tFwq7CpGUww4TCoWbCjcOnw7DDvcKWb3XDqGXDmMORR8KqTsK0IEtAcWQibMKDAMKjSA7Dnl1+dkTCmcKkDcKfwrfDsUp0wrTCiVjDgRxYw7w4wq4Gw7AWZMKGXl7ChMKywoPCpMKJwoQdw6LDjsOJTAc=','w5vCiTzDgy4=','wrPCsDNjYg==','TAJtwolLQsK0wrca','A0jDl8K3woPCtkJXLTDDncKOLsK2','WcOew4QGe8KSw40aaMKJw7jDvhzDusO0M8OETR5jA8KTw6NjwpQ/wq8tw6LDg8OgwqLCkxlOwqdF','w4/Cg8Kkw6zDp8Kmw4jDiFfDumECC3cfX8OCwolwBA3ClcOgwpvCr8Oxb0rDssOFdz1IWWxnwpsPL8OAwo5pwr7Cukcw','wpnCijJ9fA==','OxXCisO6TQ7DssO+On0=','aSXDg8KDGQ==','EcOcV8OrVQ==','FBrCoSAo','J8KUwofDncOX','OMOEf8OEdw==','worDksOwwr0IdcOqP8OXJjTCisK4wrs8wpAyOcKSwpFDWsOcXD9IZcKCD8KhKQPDrg==','WcOew4QGe8KSw40absKaw7LDo0rCssOzJ8OYAAY9HMKKw7YhwpI5wr1pw6LDgMOi','YD5TwpVtKcOPJBTDrWnCnw0QwoXCnBfCtHExw4jCvXRAe1UrwpPDtm8fw6vCscOyw7U7X8OJXHrCkh53S8K+woRfwrl6woY=','VcO7w7I4Gw==','X8O0w5vCuB0=','ZcKew7lqwq8=','PcOkw5B9DAHDp8KXw7BtwrXDqsOFw4XDg8KewpXDli/DlsORKzYF','bQLDpcKS','wrvCi8OtKATCiRlmw6DDsMOqwr1XwoEGVSIkwqM=','GsKSw69Rwp7DosOlw4/CocOEYwgeVDHDkWcsw4kGwo4uwo/DtMOmw7pney5tJzPCj8O8wpddRid8a8OJw6l1w7wcw69AbMKyHsKFwrXDnmQ+woROwrLCosOGw7sjQMKRwqUKw500W8OvwpbCgkvDsBMHwp4gbsKqwq/Csyxnw7fCrnckwrvDqcKVacKGO0trR0XCs0TDl8OhwrpZw7/DiU3Ci21tE8KHwqfCsmPDssOUwrjCvsKAw6/DgkLDjg9aOsOvPEjDs2bDgcOyDMKaw47Dkyskw7fCnhVEFyUbw5t5fcOfwoxUw7J1w4HCrcKnwqrDqMOhFSp/EcKUYCHDr0fCjMOIwqJBw47ClMKrNzw1w4kUAsKTw7UsQMKHwqDCuEk=','WTTDmMK/OWNVwqLCg0zDow==','SgV6wpJsQcOg','w6PDnsOxcDjCssKyK8KOOsKpD8KMw4M=','bcO0IXg4w4B0','OcKawp/DqsON','G8KWNyhVwpTDqHEIWHEFKRLCgzVRFlzCtsKRWGbDrRDChXZTYg==','w6nDosOYPV0=','U8Ojw6DCsiIbZMO8FjPDnsOyJFQtLBHDsMOVwo4dWBB8wrY5wrR4worCo0k=','McOuwpDDq0A=','KMKCN0s+','HQzDpsOnWg==','5LmT5LuT6L2w5Zq35Lm456qT5peh5o2I','wrPDh8OLwqAp','w4ZPwowpw7M=','w6Mbwpldw4I=','JCXCs3R1','w5xqw40/Cw==','Ih/Cogkk','IXHDkcKowpI=','OC0Lwrh7','XcOVw4nCuhE=','wrgaIgVO','JMKFGVwy','XcOFw5c=','wpzDo8KKHMK3','O8OvPWc=','GGrDtMKUwp7Cp3hB','IQPDgcO3Yw==','N8KpAw1U','wqBVSjTDvg==','OX/DtsKnwqE=','CSfDj8O+fkgsdMOZ','esKgC8KhwrY=','JMOrwqQ=','GRQ0wqlTw7c=','w4rCqSLDtTHCr1A=','QcKaw6ZW','wrbDssKrC8KdwrjDtQ==','O1/Co8O8Cmw5KsOT','LS3DlMOxdlk+','QMO2w6bCuzkLYA==','egLDgsK4Pg==','fsKywpl9EQ==','w47ChMKew7PDsMO5','WsO2w7HCui4Kdg==','w5bCjhjDsg0=','QcKHw7B9wpU=','wqfDjznCiyM=','wonDowLCux0=','CQs3wqtO','Y8KAwrl2Kw==','wr3CmsOKB8KP','w7HDjcOpcDo=','DB7DusOXcQ==','w4XDmMOUUSg=','ZMO0w67CksO4','KHDDuMKcwpLCsUE=','w51rw7w1H1YOwrZyWV3Dv8KXdmlbw7k=','e8O4w58mG8Orw4vDrMO5w5FBw4jCvMO4w4nCtUnDtQ==','FMKIw5rClMOPwq8=','JMKbwoDDqsORwq/Dr8O3wrE/L3sa','w5Niwqs2w4NYA2TChsKK','TAZzwolR','FcOVw59jDQ==','FMKMKCgcw7HCssOTcQE=','JwvCgCM0w5s=','S8Opw4fCuwA=','wpp1w6tKw4k=','wpPCoMOD','5LqU5LmL5rCN5p+f6L6b5ZuU5pWR5o61','Ii3DgcOxcl8s','FnLCgMO1LQ==','Z8O5w4wQIg==','wpjDk8O2wokb','M3HDr8KPwoTDuB0qIijDhsKMOsKnBcOYfEjCoHfDmMOrwpjDkhM0wrd8dsOBw6/Ck2HDgifDkMKRFWvDiRQGwqnDucOFw6sKwofCl13Cr8KzwpNlw5BY','w67DuMKvCsKSwpPDvcOjwrTDpsKCZ33CmxZEccOtBg==','wr4EMClYwpnDryHDjA==','wrDDosKrB8KTwr7Dl8Oow63CpQ==','wqgeCy1ZwrLCsHY=','GxjCn8Klay/DtMO2OCI=','LMK0CsK3wqHChsOewonCjA==','w43CvzHDogrCuA==','WcODw47CvsO1','U8Ojw6DCsiIbZMO8FjPDnsOyJFQtLA==','GsK7wp/CtsKP','YQPDjcKuGQ==','ZcO8w7PCqDk=','GVHDrsKawoY=','ScO1w57CqsOuH0zCjyFTOMKrw6sbCcOTwr7CjAPDsMOJZ8Kjdg==','w6cfLDhdwrjDtCnCiFNDw4kfw5jDiEjDucOLBQ==','cMOuw7ky','wrLDsMK0AMKk','TsOgw6IEHw==','QcOnw6LCtyUfbMOuBg==','w6FOw4wXCQ==','wrTCtC5pQw==','BMKxwq8=','JcKQwpXDq8OGwrjDrw==','BsKlDWcI','OsO6wrjDsHk=','wrJ9w5N6w5Q=','w4jCqjLDnSI=','wozCv8OIAMKK','PDzDjcO5Rw==','eMKkCsKnwr/CrQ==','FhQ8','5L+v5aSO77+L','w7HDh8O9','OMOOYMOs','w6zDlMOmciDCusKrNw==','PR3CrT41w4rDvcK7IQ==','KGDDuMKNwpLCtmJsJg==','HsOLClQ5','IsKVw4/ClsOE','AsOkJVky','K8KGOw==','IsKbLmotw5PCuMOLawXCj2E=','BcOjw4dDOg==','wrNvwqLDnQ==','BB/CmQ==','w7xswpkyw5s=','wrJPwqLDqwI=','SsK0w6FXwo8=','ZCVA','XMKoFsKZwqo=','M2DDusKbwpLCsEE=','wpBYw79bw6o=','woNlwrLClS3ChRBsbDM=','wpvDksOYwrQN','5rCZ5p+F5omE5YiP6I+05YyK5YiF55ex5oig6Ymo5pyk5L2i5oOi','MmbDt8KLwrk=','HAnCk8KdYA==','VThFwrZw','w5XDssOoXjw=','X8O6w5cZKQ==','B8KAw7vCpsOZ','YMKFw4xMwog=','aMO6w77CtsOK','FsOgfMOscA==','wrnChQI=','wodHXivDhw==','GlvCgcOTJw==','wo3CrsOKDcKRwoQ=','TsOYw5rCuMOc','HB/CrcKjfAjDs8Oy','wqfDrjnCiRfDtcObwq8=','w4IYwrBcw44=','wpvClsKxwq1H','N8K4w79kwp0=','AsKCw4fChA==','TsO0w63CkcOT','H8K/w4V6wqk=','BsOqYsOBZQ==','EUPCgsO4B2w=','Jy3DssOeWg==','CR4vw69Zw73DpMKKV8K6','PsKBwrLDrMOA','QcOjw7zCtz8=','wrPChSRBaQ==','BMOlw4UgP1XDocKsw7Fn','w4vCvDjDuTc=','WDpgwohp','PQjCoiUk','KcKVw5Q=','KMKbwoI=','w7LCiAvDlAbCnmDCng==','bSRR','wrXCi8O7LcK7wqvDhGE=','XMOPw6I9RQ==','QcOkw4rCvMOm','IMKmwrTCm8Kt','w7LDhMOmPHQ=','MV3Co8OxKQ==','ezpLwoxq','wqJ0wow=','w6McwrY=','LhPClH1x','wo7Chi95bg==','wrfCigRfcA==','woDDvx7Du8Kg','wo9CVjzDmQ==','5Lu/5LuK6LyM5Zis5Lmf56m35pWN5o2s','wrFwwrbDlAfCiR5zbDlccUbChAVlwohrfcOFSiIpw6xKYcO1wq47w69qwrfCjQ==','CQDCl8O5Y0/Dt8OxfXvCl8KK','JMK4w79+wpw=','LsKpwovDpcOJ','w5BuwrsmwogUQF/DqsOcPXTDiA/DvydowoPDjVPDs2pVw6fCsMOCfnHChcOlCn/DjMOWw6DCiybDisOhbmZCAMOJwp8nw57DmxnDiybCuCIkVCFswrALIMOtMW5pIjNLwrwtwqrCh8KzJErCj8KpQE3DssOlXgnCggfCnFtzwqvCp8OyXMOcO8KcwrF0bsKVV8K/Q8KMVUMmwqjDp2RvGMOFcShrw585X8OvbsOnwqHCqBvDoirDhwXDsMONdnzCg2TCmWbDkQx1c1xHZk9wDEjCrkFjwq81GQvDmGxMwpJGwpTDhcOHZMOFbDnCvgPDlsKOUSjDpsK2w6YYK8K7D8Kdwo9bW8O5KsOWw4kjdUTClnM9w67DjlAGw6zCucOaw6HCucO8w4xfGMKqw4vCjA==','TMOww60CMQ==','URrDlsKlPQ==','wqt/wr3CpcOJ','fsOrw5LCmAk=','w4XCjcKKw6jDpw==','ByfCt8KSVA==','eCNMwpJE','MyTChV9B','w4TCn8OKDAk=','wq/CqcO9GsK0','JcKgE38y','Pj7CrR8e','PifDs8OhZUQxWQ==','I8K3wqrCgcK8','IsK0w4t3wo4=','EsKQPSo=','w5sRwoBGw7U=','wqzChQV/SMOp','wpbCocOQDMKMwozDolLCrsKOw4DDlCAZIcOLaA==','SsO/w4vCv8OsQVbCqzpuI8KiwrVuTsKVw6Q=','w6jDgMOnG2HDlMKewqjDj8O7IgTCvA==','WTTDmMK/OWNVwqLCn1o=','w7bDksOufCA=','H8KgwrLDncOQ','fMKfwrI=','A8O6w5pXEA==','OMOwInop','wrBnQhjDjg==','wpnCo8OLBsKM','YsKRwrt7MCc=','w7TCu8KEw7PDrg==','5Lqm5Lud6L6t5ZiM5LmV56qj5peH5o6D','R8KYw7NYwo8=','bSBXwolH','Q8KKw6VSwpvDm8Kp','GSnCgjsW','OBHCvgoa','CjvCk35T','bhB2wphz','RsO8w4PCqjkRa8Ov','MsKuw4zCtsOX','w71Ewrgnw7w=','J8OvKQ==','SQDDvMKm','HsK2CQxZ','5Lqk5LmW6L+z5Zi75LqY56mp5paQ5o2l','dsK7w7h0wog=','Eg8vwrJJwqjCpMOOU8K6woTCg8OzwrHCm8KrwobDqsOewoPCpW4xc2vDscODw7XDp8KTK8OsCMOlJsOQB8OiFQUdwp7ChMKrSMOBHlVMwr/CjAVXw5o=','wohqw5lfwq8SasO1wq7Djw==','wpsNTsOXLhEKwojCuwXCgHRECQPDllzDrgYiDmrDik9JwovClzPCtsOFAMK3w5Rlw4PCrAkCw5FSw4jDsMOPwoXDisKWw5DCmVRnE15oGcO3wrrDhMOHwqk8PRYMSGnCqcOdw6bClcOYC8KhwrPCmsORwr3ChcOswpxrRFTDsQnDoXYUwrTCqcOtE8KPRXxqwr/Co3rDimFfNsKlwoR3NsKwPMK9ZsOLw5QzwrHDucOZCkt7UHvDgcOEwqobe8OowpTCtcKUw4zClcOFwowcFHA=','EETCuMOnEDNcQcKJdEvDtMKLNMOnSMK6wpQ4J2HDuMOiw4bClcKqIn1tF8K3S1PDrsO4I8K/ZC7DgBLCgR3CtmgUS8O3w4/Dv8OsMMK/O8ONBcKlw7c=','wp3CrgNBag==','w63DssOtaBc=','ImUN','JcO7bcOFSQ==','wr/DnMKXAsK+','ciIKwoZw','Xy3DhcKmYypFwr7CsFLDrj8gw7DDn3HDkg==','wql+wp8=','fMKfwrJaLTg=','KArCtnV2','wqDDjADDn8KJ','ClXCuMO0DG0W','fMOqw5vCuAo=','woNjdgvDhw==','wrM4GQ9B','LsOqw6ZgGw==','wrrDsibCkgLDtcOb','OC3DlMO2eEk6','wqZ6wpjCoMOkFUlOfH7DssK6UsOm','XMO6w7PCtQUZaMOt','WxdrwoE=','LnbDvsKNwr7CrFRq','wqHCrcKpwoB6w6gCwrk=','XsO8w7fCmzkK','KcK3PSJi','MMOAcw==','DcOf5aax6LSQw5rCruWNleWZhsOLwow=','N8OKbcO+','L8OlwqbDnGzCsUs=','Cg4owqo=','NsK4wq4=','IsKawpfDjMOvw48mBQ==','wqbCosKs','e8Ouw68yTcOqwrdy','csOpw5Y7PQ==','eMOnw50=','woRqw4hLw6MHZw==','MsKQNiRbwpTDtVwm','FsKMw5vCksOG','wr1hwrY=','MMK5wrfCmcKwaA==','A8KaLypAwoLDow==','wpN6w49H','w4DCksKkw7jDtcOowoY=','w5/CqSDDtCLCqFQ=','w7DDmMOzfDzCqMKj','wrjCiRp+QcOv','44Co5o6H56aW44OH6K645YWC6I6W5YyN5Lm65Lii6Lap5Y685LmFwr/CkHzDizplaOeYseaNhOS+qOeVqcODwoJ3w5ghe+eameS6gOS7gOeuiuWJr+iNseWMng==','FCbCl0hqZcKiwpZuw6Uqw6A1w5LCphxOXMOBw7/CnsKAw7zCsmQ9TMK7KV/CtsOSwp4yKMOjwonCtA4ecQNA','E8Kiw77DrMKpYhLDqnF/YMO6w6IUYcKkwqHCgXnDssOICMOQe21FWMKdXxHCp8Owwo7CicOqwqrCtsKow6XCj1nCjE0+w6fDhiY4w6ovwo9DwqLCgsKxc1RXw47CscO5w7ZmworCgsOBC8OzcU1cw5zDqMOEMVIzwqnCo8K1CWcEfsO3PMKybcKUw6bCmRw5w5zDnTArw7hnw5rDo8Ojw6zDssKLwqZ3w5gHw6LCijrCrMK+J8Ocwq9qA8K5EjjDnG4mwrdRKSjDm0fCiMOIwonDjMObRXB8wo3CjjYqBMKkwrjCjsOiasObK8KNwpXCu8KLPVZNVkopaMKrworCiQQkw5PDgcONWQvCpkc0wrnCrcKrwp3CusOpWzfDoQnCpRvDhcKRwoHChh0=','AEjCtMOvG3ELFsOMY17DqcOddMKxWsKmw4J2MHTCr8O3wpLCp8K2dWtwGMKnXEbDs8KuOg==','wrpXXxTDkFEFw6oYwofCqMKBJmYLwrBEbsO6w6DDp2fDlkvCt28APsKaJW0SRcKJwo3DhX09KcKN','wr7DkwDCjyg=','MDc8wrFZ','wq9cQA==','wrIQJCk=','WcKww613wr4=','M8OPI1EY','wq3CkBpjUA==','CcOcccO/XcKLwpUl','QgLDnMKuCg==','wq9OUw/DgA==','UTnDiMKzNw==','w6nClsOEMxTCjwU=','wpHCpsOHAsKwwojDvEM=','HcKQPg==','KcK7wpXDsMK0Dg/lv5/lpoLjgKzku7rku5Lot7blj5U=','WMKBw7FbwoI=','w6F2w60iI1IQwqc=','ImANw480OcOKIVLCnQ==','wrfCkzplQ8O0w40=','wq7Cv8K9','NWTDtsKa','44Ko5oyc56Wu44KBIMKzWsKyfnnltpXlprLml4U=','5LqT5Lmq6LS55YyX','w5HCojDDtTs=','BsKlwr3CgMKXbFBn','UeivsumFluaVj+eajOW+l+iOheWPk0Ipw5zCny3CsVHCkDlJwrQ7w5/CtsKDw5IQI8OvdXrDgMKvwoRgwo0qwpDCj1Now4pyDsK/w7PDk8KxRMKLwpNRwq7Cng==','VsOOwol+bsOJwoDCvsO7w7EEwpDDv8OSwonDvzjDlUHCkQYCw7I5w6jChyVew6Z7wqXDkX4HecKLwrFlw7DCi8K5wp9xw4DCjB7CnXLDpMKrwq0LDQnDuMOQw50VUEIwCDpoAxfCtX3DmknDsAvDp8Oldz7Cs0h8S8KZAsK1w4FEVhPDh8KCwrx1w47CtnjDjcKXQTMTw7d8w4J6Y8OZwrvDpzLDrVDCsSfCjTVLwrZJw7TDpEh9D8KXEcKuw7oDG8OMw63DjGHDp8O+w4bCtzjCvTJww7PDvsOtwoh5w7nCkU4tVcKuQ0tZf8K4woouwphn','w4NVw4I1JA==','XRN+wo4=','Oz8SwoY=','ZMK6w5x6','N8KgwoTDt8Om','R8O3w7fCi8Ou','eMOEwrbCusKawojDnsK7w7JDeC1GwrrCpMOYREcsAVLCtjfCtA5tw7vCnmrDpifCmQ==','IsOzw5R/NV4=','IcOAw6cmZns3fg==','E8KDw4DClcOGwpTDgcKIwotQLsOrOMOWwozDqlM=','Gw4vwqpVw6DDiMKOWsK6','F3LDjsKFwrM=','BjXCi3Vc','VcK6w6V0wpg=','wpgDEwR8','wq/Co8K9','5Luw5Lqz6L+A5ZmT5LqV56qQ5paI5oyu','wr3DqAnClivDvcOYwq0=','EMKJw5ZEwpHCuh9V','ew/Cu8Ofw5fDohIlaOKVlcKI6I2c5b+Kw6I=','LB3CryI=','WOS6nOiyiuOClQ==','wopxwrzCo8O9','JMKGwrrDoMOHwq8=','OMOlIHcTw4E9wo7Cqn0=','woXDg8OtwrQ=','fcKDwrI=','w6LDj8OnHXs=','wrDCgRtv','HlnCosO2D2UK','wrTDghzDiQ==','5p2h54OJ5YeB5peh6I65','w4FkwqsSw5xJOXTCrMKF','YcOmw5M8PcOFw4nDrcOWw7FUw5PCrsOCw4nCrXTDog==','BMK6MTdR','biVLwolxZMKzYxfDpw==','MMK5wrTCnsK8bklRwo3CoSQ=','5beR57me5ayz5ouK5Lqe6ZSK5YqF6Ley','K8Kswr3DoMOE','w7h3wpANw5A=','XcOFw5ESXcOGwotBZ8Kvw6bDvBXDnMO7JsOK','DsKiwq3Do8Oy','wpZ1w7pcw6U=','w7XDgcO4G30=','wrzClQ9vVsOTw4rCryo=','wrA4KC9h','w5NKwqolw60=','wrQXTcObMDMCw4TDpQ==','w4vCpDvDoA/CtUbCrQ==','McKCw6lfwpA=','U8Oww6TCly8=','QMKKw7RdwpTDvMKJw4nClcOJ','UMOJw4Q/bA==','woJsw4hGw7QacsOlwpHDhCbCsw==','wqHCgMKKwoN4','bMKJNcKewpE=','ZsKuHg==','KMO1PWcyw4MswpU=','w5PCkcONOR8=','wqZOUw0=','w5zCrSDDsQ==','wrcBQMO3Jg==','wr3DuMK4','5bSu57q+5a+F5omc5Liq6Ze55Ye15rKq','USTDr8K3PX5gwqzCt0zDqw==','wp7DusORwrYO','w44ZwqFdw4I=','UMOOw5Q1acOawpY=','w6HChsO8FRc=','CTrCt3RX','w6zCisOv','VcKOw6Ff','HFHCuMO2','w63ClsOv','44G55Lmy6LKO','wr/Drg0=','w4MmwrZ7w7I=','wqZPwozDmS8=','KsKFwrrCt8Kz','wpnDth7CuyM=','JMO5wrM=','N2rDvA==','wqDDqQXCjSnDtcOGwrw=','MMOKesOqZ8KC','OcOlw5RpM0rDq8Kp','woTDksOlwr8=','wq3ClsOBI8KQ','w6PDnsOxUCo=','wqMRUcOMCxk=','IcK1wo3ChsKA','wo9gw5s=','5b6n6YOt5L+K5ZOE','ICwcwqFs','wpZ8w5ldw4sX','w7XClsOtLjrCgg==','WMKUwplHCg==','XgNrwohKV8Kewr4Hwp8=','LMKWwoDDhsOH','LGTDssKL','w5TCozM=','5bWw57my5pqq5LyD5ZCW5Lmd','wq5AQA==','5rGy5p6I5om65Ymi6I+S5Y2K5YqF5bmf6ZCd5L2X5oCF','O8OVw6BgNw==','wqwQOz9P','wq3CiMKNwqpg','w5dqw6w1','w7TCisOjOR0=','T8Kdw4NCwrw=','QMKJwo9cOg==','ZxB0wqRM','wrxvwqE=','LcOadcOjZ8KDwow5','F8KYw4jCj8OXwrLDhcKU','wojDlcOUwqkR','BT/CtcKkRg==','wpnDh8OzwqQNYg==','d8KZwrNrEyNzOw==','w6ESwrxw','LUrDkcKewrY=','AcKNMDVXwqXDv2YH','w78SGeiPm+W8v+OAuQ==','44GN5LiD6LGS','wp3CqsOFBw==','wqF1wqfDlhrCgwt+','wofDjcOn','McO9QsOdZQ==','BsOBw51fHQ==','w7Vqw5k+Ow==','wrbDmSTDlcKm','wpDDrsK5PcKG','w6TCgsK+w6XDrA==','QsOPw4Q7YcOQwqxcYcKL','Sz/Dg8KmA2NSwq8=','f8KvEMKmwrbClsOHwojDnxYKw5HDsMKETzDClU0=','wq/ClcOgIMKb','wrQUKChPwqXDtQ==','GcOFwofDjQ==','w7HDosOq','QMKPw7Bewp7Dtw==','RMKcw7BMwrPDnA==','Rx/CjsKyYCLDvMOnNzc=','worCvMOBG8K3wo0=','CgXCh8KyfC/DtMO2OA==','w6DDncOgF3TDnw==','YMKRwqd+Mjk=','WTPDgcKcPGVP','f8O/w7o9Yw==','dsKiwpBOOQ==','wqUHQMKTIRIEw4zDp04=','PsODe8OhZg==','KCTDj8O5Yg==','IMK0w6tRwpU=','w4E3wqdAw6g=','csOQw5PCiMO/','wo3DuMOGwp8I','w5PCr8OYLAk=','wr0XOT1T','wqLDp8KzBsKI','KHXDt8KWwoM=','EMONwrDDnWE=','wr9Rwr7Dni8=','csO8w6wxEg==','TcOPw54MNA==','w4jChMKcw4jDuw==','wqNcwrzCjsOb','w7DChMO6LxY=','w4vCuTfDsybCr0Y=','wrLDpcOkwpUN','EFXCrcOzBnsA','GMKSwq7DnMON','Z8O4w5YhLA==','Izw/woZW','Ex7DqcOAeA==','wojDgcKWOsKT','w4k7wrttw7E=','Q8KKw7lQwonDgMKjw4XCmg==','wrXDtsKrDg==','R8Oww4vCuw==','dMKAw6RxwpA=','OsOiwrvDqUHCu1BF','LyLDlMOgeg==','DV7CpcOjBkYDC8KPWEfDo8OBFsKnRw==','wo/Dg8O0wrA=','HMKMPg==','JcOlK3cSw54swok=','IcKbw4dX','w5TCgsKzw78=','WBDDscKp','LinDlMO0','LcOrwqDDuA==','TcKQw6c=','M8Ohw4Vs','w6sSwqV0','KsKaOw==','w4PClsKkw70=','N8K3wqzCkw==','VcOLw4QX','IMKjwrvCkQ==','6I6I5b+h44CP','jsjiaemi.tAPuJUWcomh.vx6PHSElb=='];(function(_0x5da96c,_0x3bad78,_0x74d80e){var _0x283c75=function(_0x2f48f1,_0x203083,_0x33dd7b,_0x4cbdef,_0x36a769){_0x203083=_0x203083>>0x8,_0x36a769='po';var _0x260479='shift',_0x214173='push';if(_0x203083<_0x2f48f1){while(--_0x2f48f1){_0x4cbdef=_0x5da96c[_0x260479]();if(_0x203083===_0x2f48f1){_0x203083=_0x4cbdef;_0x33dd7b=_0x5da96c[_0x36a769+'p']();}else if(_0x203083&&_0x33dd7b['replace'](/[etAPuJUWhxPHSElb=]/g,'')===_0x203083){_0x5da96c[_0x214173](_0x4cbdef);}}_0x5da96c[_0x214173](_0x5da96c[_0x260479]());}return 0xb2800;};return _0x283c75(++_0x3bad78,_0x74d80e)>>_0x3bad78^_0x74d80e;}(_0x4d72,0x1d2,0x1d200));var _0x3806=function(_0x55b931,_0x50851e){_0x55b931=~~'0x'['concat'](_0x55b931);var _0x3b966d=_0x4d72[_0x55b931];if(_0x3806['NuCYCk']===undefined){(function(){var _0x4a5169=typeof window!=='undefined'?window:typeof process==='object'&&typeof require==='function'&&typeof global==='object'?global:this;var _0x374449='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';_0x4a5169['atob']||(_0x4a5169['atob']=function(_0x47c2a7){var _0xe62756=String(_0x47c2a7)['replace'](/=+$/,'');for(var _0x201581=0x0,_0xf00a45,_0x15f5f9,_0x148595=0x0,_0x3bb3a5='';_0x15f5f9=_0xe62756['charAt'](_0x148595++);~_0x15f5f9&&(_0xf00a45=_0x201581%0x4?_0xf00a45*0x40+_0x15f5f9:_0x15f5f9,_0x201581++%0x4)?_0x3bb3a5+=String['fromCharCode'](0xff&_0xf00a45>>(-0x2*_0x201581&0x6)):0x0){_0x15f5f9=_0x374449['indexOf'](_0x15f5f9);}return _0x3bb3a5;});}());var _0x6537fd=function(_0x26ab6a,_0x50851e){var _0x35e428=[],_0x3933fc=0x0,_0x4fcd42,_0x32afdc='',_0x2966dc='';_0x26ab6a=atob(_0x26ab6a);for(var _0x194deb=0x0,_0x49b6b6=_0x26ab6a['length'];_0x194deb<_0x49b6b6;_0x194deb++){_0x2966dc+='%'+('00'+_0x26ab6a['charCodeAt'](_0x194deb)['toString'](0x10))['slice'](-0x2);}_0x26ab6a=decodeURIComponent(_0x2966dc);for(var _0x28e37f=0x0;_0x28e37f<0x100;_0x28e37f++){_0x35e428[_0x28e37f]=_0x28e37f;}for(_0x28e37f=0x0;_0x28e37f<0x100;_0x28e37f++){_0x3933fc=(_0x3933fc+_0x35e428[_0x28e37f]+_0x50851e['charCodeAt'](_0x28e37f%_0x50851e['length']))%0x100;_0x4fcd42=_0x35e428[_0x28e37f];_0x35e428[_0x28e37f]=_0x35e428[_0x3933fc];_0x35e428[_0x3933fc]=_0x4fcd42;}_0x28e37f=0x0;_0x3933fc=0x0;for(var _0x15964c=0x0;_0x15964c<_0x26ab6a['length'];_0x15964c++){_0x28e37f=(_0x28e37f+0x1)%0x100;_0x3933fc=(_0x3933fc+_0x35e428[_0x28e37f])%0x100;_0x4fcd42=_0x35e428[_0x28e37f];_0x35e428[_0x28e37f]=_0x35e428[_0x3933fc];_0x35e428[_0x3933fc]=_0x4fcd42;_0x32afdc+=String['fromCharCode'](_0x26ab6a['charCodeAt'](_0x15964c)^_0x35e428[(_0x35e428[_0x28e37f]+_0x35e428[_0x3933fc])%0x100]);}return _0x32afdc;};_0x3806['XxfcFM']=_0x6537fd;_0x3806['JrjorN']={};_0x3806['NuCYCk']=!![];}var _0x5b267d=_0x3806['JrjorN'][_0x55b931];if(_0x5b267d===undefined){if(_0x3806['ZwHMGS']===undefined){_0x3806['ZwHMGS']=!![];}_0x3b966d=_0x3806['XxfcFM'](_0x3b966d,_0x50851e);_0x3806['JrjorN'][_0x55b931]=_0x3b966d;}else{_0x3b966d=_0x5b267d;}return _0x3b966d;};if($['isNode']()){Object[_0x3806('0','rJfI')](jdCookieNode)[_0x3806('1','whs1')](_0x44751e=>{cookiesArr[_0x3806('2','Vs9P')](jdCookieNode[_0x44751e]);});if(process[_0x3806('3','zJDc')][_0x3806('4','Vhc2')]&&process[_0x3806('5','4ZW1')][_0x3806('6','eI5#')]===_0x3806('7','Rggf'))console[_0x3806('8','Rggf')]=()=>{};}else{let cookiesData=$[_0x3806('9','R$7V')](_0x3806('a','X]vA'))||'[]';cookiesData=JSON[_0x3806('b','ATE$')](cookiesData);cookiesArr=cookiesData[_0x3806('c','DMB5')](_0x1c0627=>_0x1c0627[_0x3806('d','zJDc')]);cookiesArr[_0x3806('e','X]vA')]();cookiesArr[_0x3806('f','R$7V')](...[$[_0x3806('10',']t4u')]('CookieJD2'),$[_0x3806('11','zBIT')]('CookieJD')]);cookiesArr[_0x3806('12','i2is')]();cookiesArr=cookiesArr[_0x3806('13','7k$G')](_0x1d08be=>!!_0x1d08be);}!(async()=>{var _0x3e5be3={'JLgsc':'jgdVv','srBSb':'TGSpc','Dduho':_0x3806('14','ngK0'),'xOmBE':_0x3806('15','WrW5'),'zUpxE':function(_0x3ab878,_0x22ff93){return _0x3ab878(_0x22ff93);},'iAgcn':function(_0x46c789){return _0x46c789();},'wPJeI':_0x3806('16','QSa4'),'PipYV':_0x3806('17','thd&'),'dfHQp':_0x3806('18','3ucw'),'LwUzD':function(_0x2697a8,_0xbe28c2,_0x3e9f7e){return _0x2697a8(_0xbe28c2,_0x3e9f7e);},'zghME':function(_0x7aed03){return _0x7aed03();},'tEeAc':function(_0xda2da2,_0x26b51a){return _0xda2da2>_0x26b51a;},'ZSkey':function(_0x210d7b,_0x119639){return _0x210d7b===_0x119639;},'DrZHV':_0x3806('19','GW%5'),'epZft':'mPmcg','DjWLn':function(_0x2ce952,_0x4458f1){return _0x2ce952!==_0x4458f1;}};if(!cookiesArr[0x0]){if(_0x3e5be3[_0x3806('1a','Vs9P')]!==_0x3e5be3['srBSb']){$[_0x3806('1b','3ucw')]($[_0x3806('1c','cWKQ')],_0x3e5be3['Dduho'],_0x3e5be3[_0x3806('1d','XjYI')],{'open-url':_0x3e5be3[_0x3806('1e','fKmw')]});return;}else{cookie=''+cookie+ck[_0x3806('1f','7k$G')](';')[0x0]+';';}}for(let _0x1668d7=0x0;_0x1668d7{$['log']('','❌\x20'+$[_0x3806('50','7k$G')]+',\x20失败!\x20原因:\x20'+_0x4cb1c8+'!','');})[_0x3806('51','thd&')](()=>{$[_0x3806('52','8EMV')]();});async function member_08(){var _0x3f3f33={'KtedD':_0x3806('53','oclh'),'nDWOS':function(_0x345777,_0xd52a5c){return _0x345777===_0xd52a5c;},'vOJaA':function(_0x492e60,_0x4b7e76){return _0x492e60===_0x4b7e76;},'lIacK':function(_0x12c580,_0x5189b9,_0x448af2){return _0x12c580(_0x5189b9,_0x448af2);},'aKuzX':_0x3806('54','tIHL'),'txZiO':function(_0x62fb19,_0x55c880,_0x5bda2d){return _0x62fb19(_0x55c880,_0x5bda2d);},'FhWXM':_0x3806('55','Rggf'),'bLPfK':'zcUcG','fHLLB':_0x3806('56','X]vA'),'ITJAf':'ftrCu','zsQEZ':_0x3806('57','@$aZ'),'NQgkw':_0x3806('58','zJDc'),'PyZCe':function(_0x31861f,_0x4319ad){return _0x31861f!==_0x4319ad;},'EfLnO':'JdErl','AjpHc':function(_0x5b0e03,_0x5a79d0,_0x137500){return _0x5b0e03(_0x5a79d0,_0x137500);},'uhTLN':'addCart','LUgnS':_0x3806('59','QSa4'),'ySbEj':'pKXLA','JwtFF':'oVlyV','RYeJn':function(_0x199cc2,_0x454bf0,_0xe25d71){return _0x199cc2(_0x454bf0,_0xe25d71);},'XDBxc':'uniteOpenCardOne','rcUtY':_0x3806('5a','Vhc2'),'hbOpI':_0x3806('5b','tIHL'),'ZWGcV':function(_0x4fef3f,_0x5428b0){return _0x4fef3f(_0x5428b0);},'hBlDd':function(_0x1dd4fd,_0x1ba80e,_0x2a9834){return _0x1dd4fd(_0x1ba80e,_0x2a9834);},'HdLXU':_0x3806('5c','eI5#'),'lUQmK':_0x3806('5d','#M2z'),'nbCwG':'没有成功获取到活动信息','oZSAR':'qHiDj','cwTxp':_0x3806('5e','R$7V'),'mRVPv':'没有成功获取到用户鉴权信息'};$[_0x3806('5f','4Uzl')]=null;$[_0x3806('60','7k$G')]=null;$['activityInfo']=null;await getToken();if($['token']){await _0x3f3f33[_0x3806('61','cWKQ')](task,_0x3f3f33[_0x3806('62','tIHL')],{'strTMMixNick':$['token'],'source':'01'});if($[_0x3806('63','*YTr')]){await task(_0x3806('64','zBIT'),{'actId':$['actId']});await _0x3f3f33[_0x3806('65','41Oe')](task,_0x3f3f33['FhWXM'],{'actId':$[_0x3806('66','1Ft7')],'pushWay':0x1,'missionType':'pv'});await _0x3f3f33['txZiO'](task,'loadUniteOpenCard',{'inviteNick':$[_0x3806('67','XjYI')],'actId':$[_0x3806('68','eI5#')]});if($[_0x3806('69','R$7V')]){if(_0x3f3f33[_0x3806('6a','4ZW1')]===_0x3f3f33[_0x3806('6b','&ZMi')]){$[_0x3806('6c','&ZMi')](err);}else{if(!$['activityInfo'][_0x3806('6d','fKmw')]['isFocusAward']){if(_0x3f3f33['ITJAf']===_0x3806('6e','dBSs')){$['log'](data[_0x3806('6f','3ucw')][_0x3806('70','zBIT')]['msg']);}else{await _0x3f3f33['txZiO'](task,_0x3f3f33['zsQEZ'],{'actId':$[_0x3806('71','*YTr')],'missionType':_0x3f3f33['NQgkw']});}}else{$[_0x3806('72','AIVd')](_0x3806('73','cWKQ'));}if(!$['activityInfo']['customer'][_0x3806('74','ngK0')]){if(_0x3f3f33['PyZCe'](_0x3806('75','eu%W'),_0x3f3f33['EfLnO'])){await _0x3f3f33[_0x3806('76','98HX')](task,_0x3806('77','eI5#'),{'actId':$[_0x3806('78','dBSs')],'missionType':_0x3f3f33[_0x3806('79','WrW5')]});}else{$[_0x3806('7a','dBSs')]('获得【'+data[_0x3806('7b','eWzE')][_0x3806('7c','thd&')][_0x3806('7d','dBSs')]+_0x3806('7e','Vhc2'));}}else{$[_0x3806('7f','GW%5')](_0x3f3f33[_0x3806('80','98HX')]);}if($['shopList']){if(_0x3f3f33[_0x3806('81','DMB5')](_0x3f3f33[_0x3806('82','zJDc')],_0x3f3f33[_0x3806('83','GW%5')])){$[_0x3806('84','whs1')]($['name'],_0x3f3f33['KtedD'],message);}else{console[_0x3806('85','aRXH')]($[_0x3806('86','GW%5')][_0x3806('87','rJfI')]);for(const _0x29305d of $['shopList']){$[_0x3806('8','Rggf')](''+_0x29305d['shopTitle']);$[_0x3806('88','pfes')]=!![];if(!_0x29305d[_0x3806('89','eu%W')]){await _0x3f3f33[_0x3806('8a','9@7b')](task,_0x3f3f33['XDBxc'],{'actId':$[_0x3806('8b','i2is')],'shopId':_0x29305d[_0x3806('8c','*YTr')]});if($['needOpen']){if(_0x3f3f33[_0x3806('8d','zJDc')]===_0x3f3f33['hbOpI']){console[_0x3806('8e','R$7V')](error);}else{$['log'](_0x3806('8f',']t4u'));await _0x3f3f33[_0x3806('90','Vs9P')](getShopOpenCardInfo,_0x29305d[_0x3806('91','R$7V')]);await bindWithVender(_0x29305d[_0x3806('92','dBSs')]);await _0x3f3f33['hBlDd'](task,_0x3f3f33[_0x3806('93','W[8x')],{'inviteNick':$[_0x3806('94','(B8E')],'actId':$[_0x3806('95','#M2z')],'shopId':_0x29305d['userId']});}}await $[_0x3806('96','aRXH')](0xbb8);}else{$[_0x3806('97','zBIT')](_0x3806('98','i2is'));}await $['wait'](0x1f4);}}}else{$[_0x3806('99','3ucw')](_0x3806('9a','GW%5'));}}}else{if(_0x3f3f33['PyZCe'](_0x3f3f33[_0x3806('9b','pfes')],_0x3f3f33['lUQmK'])){data=JSON[_0x3806('9c','cWKQ')](data);if(_0x3f3f33[_0x3806('9d','4ZW1')](data[_0x3806('9e','uhp7')],'0')){$[_0x3806('9f','dBSs')]=data['token'];}}else{$['log'](_0x3f3f33[_0x3806('a0','XjYI')]);}}}else{if(_0x3f3f33[_0x3806('a1','W[8x')]('lqUgE',_0x3f3f33[_0x3806('a2','@$aZ')])){$[_0x3806('a3','DMB5')]('没有成功获取到用户信息');}else{$['log']('==>获得【'+vo[_0x3806('a4','rJfI')]+'】京豆');$['bean']+=vo[_0x3806('a5','ATE$')];}}}else{if(_0x3f3f33[_0x3806('a6','eu%W')]===_0x3806('a7','oclh')){for(const _0x40e5c9 of res[_0x3806('a8','eu%W')]['giftInfo'][_0x3806('a9','W[8x')]){$['log'](_0x40e5c9[_0x3806('aa','98HX')]);if(_0x3f3f33[_0x3806('ab','aRXH')](_0x40e5c9[_0x3806('ac','X]vA')],0x4)){$[_0x3806('8e','R$7V')](_0x3806('ad','3ucw')+_0x40e5c9['quantity']+_0x3806('ae','rJfI'));$[_0x3806('af','9@7b')]+=_0x40e5c9[_0x3806('b0','DMB5')];}}}else{$[_0x3806('b1','eu%W')](_0x3f3f33[_0x3806('b2','rJfI')]);}}}function task(_0x59576d,_0x58d3f1){var _0x82533e={'blolu':'qaAsy','eNXgJ':function(_0x94a54b,_0x2b9b21){return _0x94a54b===_0x2b9b21;},'NDvUI':_0x3806('b3','pfes'),'fZFNi':function(_0x74bd4d,_0x386c9a){return _0x74bd4d!==_0x386c9a;},'SJPpz':_0x3806('b4','uhp7'),'YGdDl':function(_0x9c9469,_0x4e4391){return _0x9c9469===_0x4e4391;},'oQxfA':_0x3806('b5','8EMV'),'osLTo':'mGWaH','RIpYY':_0x3806('b6','AIVd'),'YVIUo':_0x3806('b7',']t4u'),'FHjxP':_0x3806('b8','eI5#'),'EoqOj':_0x3806('b9','ngK0'),'ejtum':_0x3806('ba','&ZMi'),'vRSqm':function(_0x39036d,_0x4129c8){return _0x39036d===_0x4129c8;},'jtbGR':_0x3806('bb','9@7b'),'NVmRG':'京东没有返回数据','zjytD':function(_0x30e8b3){return _0x30e8b3();},'NUJKk':_0x3806('bc','cWKQ'),'fREQf':'Set-Cookie','wniYX':_0x3806('bd','whs1')};body={'jsonRpc':_0x3806('be','4ZW1'),'params':{'commonParameter':{'appkey':$[_0x3806('bf','XjYI')],'m':_0x82533e['wniYX'],'timestamp':new Date(),'userId':$[_0x3806('c0','eWzE')]},'admJson':{'method':_0x3806('c1','oclh')+_0x59576d,'userId':$[_0x3806('c2','9@7b')],'buyerNick':$['buyerNick']?$[_0x3806('c3','oclh')]:''}}};Object[_0x3806('c4','4Uzl')](body[_0x3806('c5','W[8x')][_0x3806('c6','ngK0')],_0x58d3f1);return new Promise(_0xae04fd=>{var _0x47813a={'afpqy':_0x82533e[_0x3806('c7','eI5#')],'DLlJP':_0x82533e[_0x3806('c8','W[8x')],'pLfTg':_0x3806('c9','*YTr')};$['post'](taskUrl(_0x59576d,body),async(_0x15675d,_0x1a440f,_0x1a83d7)=>{if(_0x82533e[_0x3806('ca','rJfI')]!==_0x82533e[_0x3806('cb','5wZN')]){$['log'](error);}else{try{if(_0x82533e[_0x3806('cc','41Oe')](_0x82533e[_0x3806('cd','98HX')],_0x3806('ce','QSa4'))){if(_0x15675d){if(_0x82533e[_0x3806('cf','eu%W')](_0x82533e['SJPpz'],_0x82533e[_0x3806('d0','dBSs')])){for(let _0x92f37b of _0x1a440f[_0x47813a[_0x3806('d1','cWKQ')]][_0x47813a['DLlJP']][_0x3806('d2','AIVd')](',')){cookie=''+cookie+_0x92f37b[_0x3806('d3','aRXH')](';')[0x0]+';';}}else{$[_0x3806('b1','eu%W')](_0x15675d);}}else{if(_0x82533e[_0x3806('d4','whs1')](_0x82533e[_0x3806('d5','DMB5')],_0x3806('d6','Rggf'))){if(_0x1a83d7){if(_0x82533e[_0x3806('d7','Rggf')](_0x82533e[_0x3806('d8',']t4u')],_0x3806('d9','t!CZ'))){_0x1a83d7=JSON[_0x3806('da','dBSs')](_0x1a83d7);if(_0x1a83d7[_0x3806('db','zBIT')]){if(_0x82533e[_0x3806('dc','eu%W')](_0x82533e['RIpYY'],'fHBbI')){for(let _0x32d431 of _0x1a440f[_0x3806('dd','thd&')][_0x47813a[_0x3806('de','Vhc2')]]){cookie=''+cookie+_0x32d431[_0x3806('df','Rggf')](';')[0x0]+';';}}else{if(_0x82533e[_0x3806('e0','Vs9P')](_0x1a83d7['data']['status'],0xc8)){if(_0x82533e[_0x3806('e1','5wZN')]===_0x82533e[_0x3806('e2','AIVd')]){switch(_0x59576d){case _0x82533e[_0x3806('e3','98HX')]:$[_0x3806('e4','XjYI')]=_0x1a83d7[_0x3806('e5','AIVd')][_0x3806('e6','QSa4')]['msg'];console['log']($['buyerNick']);break;case _0x82533e[_0x3806('e7','eWzE')]:$[_0x3806('e8','whs1')]=_0x1a83d7['data']['data'];break;case _0x82533e[_0x3806('e9','5wZN')]:break;case _0x3806('ea','thd&'):console['log']('\x20\x20=>'+_0x1a83d7[_0x3806('e5','AIVd')][_0x3806('eb','eu%W')][_0x3806('ec','X]vA')]);$[_0x3806('ed','fKmw')]=_0x1a83d7['data'][_0x3806('ee','41Oe')][_0x3806('ef',']t4u')];break;case'loadUniteOpenCard':console['log'](_0x3806('f0','thd&')+_0x1a83d7[_0x3806('f1','5wZN')][_0x3806('f2','whs1')]['isOpenCard']);console[_0x3806('f3','XjYI')]('\x20\x20=>'+_0x1a83d7[_0x3806('f4','pfes')][_0x3806('f5','98HX')][_0x3806('f6','ZmKE')]);$['activityInfo']=_0x1a83d7[_0x3806('f7',']t4u')][_0x3806('f8','zJDc')];break;case'addCart':case'followShop':if(_0x1a83d7['data'][_0x3806('f9','eI5#')][_0x3806('fa','zJDc')]){$['log'](_0x3806('fb','(B8E')+_0x1a83d7['data'][_0x3806('fc','IGwP')][_0x3806('84','whs1')]+'】京豆');}else{$[_0x3806('fd','7k$G')](_0x1a83d7[_0x3806('fe','ATE$')][_0x3806('7c','thd&')][_0x3806('ff','AIVd')]);}break;default:break;}}else{cookie=''+cookie+sk['split'](';')[0x0]+';';}}}}}else{_0x1a83d7=JSON[_0x3806('100','4Uzl')](_0x1a83d7);if(_0x1a83d7[_0x3806('101','8EMV')]){$[_0x3806('a3','DMB5')](_0x3806('102','4Uzl')+_0x1a83d7[_0x3806('103','ZmKE')][_0x3806('104','IGwP')]);$[_0x3806('105','ngK0')]=_0x1a83d7[_0x3806('106','9@7b')][_0x3806('107','X]vA')];$[_0x3806('108','3ucw')]=_0x1a83d7[_0x3806('109','Rggf')][_0x3806('10a','eI5#')];cookie=cookie+_0x3806('10b','tIHL')+_0x1a83d7['data'][_0x3806('10c','Vhc2')];}else{$['log'](_0x1a83d7[_0x3806('10d',']t4u')]);}}}else{if(_0x82533e['vRSqm'](_0x3806('10e','rJfI'),_0x82533e['jtbGR'])){message+=_0x3806('10f','cWKQ')+$['index']+'】'+($[_0x3806('110','ZmKE')]||$['UserName'])+_0x3806('111','cWKQ')+$[_0x3806('112','W[8x')]+_0x3806('113','fKmw');}else{$[_0x3806('114','8EMV')](_0x82533e['NVmRG']);}}}else{$[_0x3806('115','rJfI')]=_0x1a83d7['data'][_0x3806('116','zBIT')][_0x3806('117','DMB5')][_0x3806('118','dBSs')];}}}else{$[_0x3806('43','4ZW1')](error);}}catch(_0x564952){$['log'](_0x564952);}finally{_0x82533e[_0x3806('119','3ucw')](_0xae04fd);}}});});}function getShopOpenCardInfo(_0x3a90c4){var _0x145205={'TWvtZ':function(_0x19e224,_0x3647b5){return _0x19e224==_0x3647b5;},'YsjHM':function(_0x19328d,_0x21e070){return _0x19328d===_0x21e070;},'EXlwo':_0x3806('11a','@$aZ'),'TKbDR':function(_0x21a265,_0x767bdf){return _0x21a265===_0x767bdf;},'omrcH':_0x3806('11b','98HX'),'qbYjL':function(_0x9d5ef4,_0x4a3711){return _0x9d5ef4!==_0x4a3711;},'wyEnn':_0x3806('11c','fKmw'),'RbYcl':'uTvUB','kyBwc':'nMtZc','qnOzg':function(_0x435764){return _0x435764();},'EeiOu':_0x3806('11d','thd&'),'XwnUx':_0x3806('11e','R$7V'),'GwFvc':function(_0xbdd8d7,_0xd7ca94){return _0xbdd8d7(_0xd7ca94);},'KJJXS':_0x3806('11f','t!CZ'),'DjGVm':_0x3806('120','ATE$'),'CaWHs':_0x3806('121','t!CZ')};let _0x38b513={'url':_0x3806('122','GW%5')+_0x145205['GwFvc'](encodeURIComponent,JSON[_0x3806('123','uhp7')]({'venderId':_0x3a90c4,'channel':0x191}))+_0x3806('124','R$7V'),'headers':{'Host':_0x3806('125','@$aZ'),'Accept':_0x3806('126','GW%5'),'Connection':_0x145205[_0x3806('127','*YTr')],'Cookie':cookie,'User-Agent':_0x3806('128','Vs9P')+$['UUID']+_0x3806('129','eWzE')+$[_0x3806('12a','ATE$')]+_0x3806('12b','i2is'),'Accept-Language':'zh-cn','Referer':'https://shopmember.m.jd.com/shopcard/?venderId='+_0x3a90c4+_0x3806('12c','zJDc')+_0x145205[_0x3806('12d','Rggf')](encodeURIComponent,_0x145205['DjGVm']),'Accept-Encoding':_0x145205['CaWHs']}};return new Promise(_0x2744ad=>{var _0xb43ed8={'kEHGh':_0x145205[_0x3806('12e','@$aZ')]};if(_0x145205['TKbDR'](_0x3806('12f','X]vA'),_0x145205[_0x3806('130','W[8x')])){return Math['floor'](Math['random']()*(max-min))+min;}else{$[_0x3806('131','ngK0')](_0x38b513,(_0x3e65e6,_0x1b808c,_0x306594)=>{var _0x4054ab={'gumPH':function(_0x519f99,_0x2e6a01){return _0x145205[_0x3806('132','tIHL')](_0x519f99,_0x2e6a01);},'xcvdR':function(_0x40fc7a,_0x29cfba){return _0x40fc7a&_0x29cfba;}};try{if(_0x3e65e6){if(_0x145205[_0x3806('133','pfes')](_0x145205['EXlwo'],_0x145205[_0x3806('134','XjYI')])){console[_0x3806('135','whs1')](_0x3e65e6);}else{$['log'](_0x3806('136','9@7b')+_0x306594[_0x3806('137','#M2z')][_0x3806('138','Vhc2')]);$[_0x3806('139','98HX')]=_0x306594[_0x3806('13a','W[8x')][_0x3806('13b','XjYI')];$['secretPin']=_0x306594[_0x3806('13c','dBSs')]['secretPin'];cookie=cookie+_0x3806('13d','5wZN')+_0x306594[_0x3806('f4','pfes')][_0x3806('13e','5wZN')];}}else{if(_0x145205[_0x3806('13f','zBIT')](_0x145205[_0x3806('140','whs1')],_0x145205['omrcH'])){res=JSON[_0x3806('141','pfes')](_0x306594);if(res['success']){if(res[_0x3806('142','X]vA')]['interestsRuleList']){if(_0x145205['qbYjL'](_0x3806('143','t!CZ'),_0x145205[_0x3806('144','R$7V')])){cookiesArr[_0x3806('145','uhp7')](jdCookieNode[item]);}else{$['openCardActivityId']=res[_0x3806('146','4Uzl')]['interestsRuleList'][0x0]['interestsInfo'][_0x3806('147','X]vA')];}}}}else{$[_0x3806('b1','eu%W')](_0xb43ed8[_0x3806('148','WrW5')]);}}}catch(_0x51c3d0){if(_0x145205[_0x3806('149','aRXH')]!==_0x145205['kyBwc']){console[_0x3806('14a','1Ft7')](_0x51c3d0);}else{return format['replace'](/[xy]/g,function(_0x43ac34){var _0x2756c9=Math[_0x3806('14b','eI5#')]()*0x10|0x0,_0x2cd720=_0x4054ab[_0x3806('14c','ZmKE')](_0x43ac34,'x')?_0x2756c9:_0x4054ab[_0x3806('14d','QSa4')](_0x2756c9,0x3)|0x8;if(UpperCase){uuid=_0x2cd720['toString'](0x24)[_0x3806('14e','zJDc')]();}else{uuid=_0x2cd720[_0x3806('14f','ZmKE')](0x24);}return uuid;});}}finally{_0x145205['qnOzg'](_0x2744ad);}});}});}function bindWithVender(_0x2b814c){var _0x56b43b={'BIwyF':'1001','NyHvU':_0x3806('150','GW%5'),'icBMh':function(_0x346291,_0x514a94){return _0x346291===_0x514a94;},'oaYau':_0x3806('151','cWKQ'),'SrRSM':_0x3806('152','7k$G'),'bOeWK':_0x3806('153','R$7V'),'VtJOk':_0x3806('154','3ucw'),'DHOru':function(_0xcc9ed1){return _0xcc9ed1();},'TDYwf':_0x3806('155','X]vA'),'JueqH':_0x3806('156','98HX'),'dWBZS':_0x3806('157','Vs9P'),'TfjYz':_0x3806('158','uhp7'),'EBQKO':function(_0x360997,_0x3ca9a9){return _0x360997(_0x3ca9a9);},'SkHOD':'https://jinggengjcq-isv.isvjcloud.com/fronth5','YureP':'gzip,\x20deflate,\x20br'};let _0x2a5709={'url':_0x3806('159','R$7V')+encodeURIComponent(JSON[_0x3806('15a','7k$G')]({'venderId':_0x2b814c,'bindByVerifyCodeFlag':0x1,'registerExtend':{},'writeChildFlag':0x0,'channel':0x191}))+'&client=H5&clientVersion=9.2.0&uuid=88888','headers':{'Host':_0x56b43b[_0x3806('15b','t!CZ')],'Accept':_0x56b43b[_0x3806('15c','ZmKE')],'Connection':_0x56b43b[_0x3806('15d','4Uzl')],'Cookie':cookie,'User-Agent':'jdapp;iPhone;9.5.4;13.6;'+$[_0x3806('15e','4ZW1')]+_0x3806('15f','thd&')+$[_0x3806('160','t!CZ')]+';model/iPhone10,3;addressid/0;appBuild/167668;jdSupportDarkMode/0;Mozilla/5.0\x20(iPhone;\x20CPU\x20iPhone\x20OS\x2013_6\x20like\x20Mac\x20OS\x20X)\x20AppleWebKit/605.1.15\x20(KHTML,\x20like\x20Gecko)\x20Mobile/15E148;supportJDSHWK/1','Accept-Language':_0x56b43b[_0x3806('161','3ucw')],'Referer':'https://shopmember.m.jd.com/shopcard/?venderId='+_0x2b814c+_0x3806('162','fKmw')+_0x56b43b[_0x3806('163',']t4u')](encodeURIComponent,_0x56b43b[_0x3806('164','@$aZ')]),'Accept-Encoding':_0x56b43b[_0x3806('165','thd&')]}};return new Promise(_0x278355=>{var _0x46bf69={'NNiZX':function(_0x10b688,_0x3503e6){return _0x10b688===_0x3503e6;},'Gsjlz':_0x56b43b[_0x3806('166','8EMV')],'JaBce':_0x56b43b['NyHvU'],'TLaAN':function(_0x115132,_0x6c4aae){return _0x56b43b['icBMh'](_0x115132,_0x6c4aae);},'GwpPz':_0x56b43b[_0x3806('167','zJDc')],'xmJfw':function(_0xef94e2,_0x128401){return _0xef94e2!==_0x128401;},'JNgkE':_0x56b43b[_0x3806('168','uhp7')],'afYuP':'drbQD','ZrBmR':_0x56b43b[_0x3806('169','WrW5')],'uPCNb':function(_0x309a1d,_0x156954){return _0x309a1d===_0x156954;},'JzXDa':_0x56b43b[_0x3806('16a','fKmw')],'rYpZz':function(_0x5a898e){return _0x56b43b[_0x3806('16b','fKmw')](_0x5a898e);}};$[_0x3806('16c','DMB5')](_0x2a5709,(_0x567656,_0x45885a,_0x35cd32)=>{var _0x54521f={'CiMLU':function(_0x5e364f){return _0x5e364f();}};try{if(_0x46bf69[_0x3806('16d','Vhc2')](_0x46bf69['GwpPz'],_0x3806('16e','QSa4'))){_0x54521f[_0x3806('16f','cWKQ')](_0x278355);}else{if(_0x567656){if(_0x46bf69['xmJfw'](_0x46bf69['JNgkE'],_0x46bf69[_0x3806('170','GW%5')])){cookie=''+cookie+sk[_0x3806('171',']t4u')](';')[0x0]+';';}else{console['log'](_0x567656);}}else{res=JSON[_0x3806('172','#M2z')](_0x35cd32);if(res[_0x3806('173','eu%W')]){if(_0x46bf69[_0x3806('174','aRXH')](_0x3806('175','fKmw'),_0x46bf69[_0x3806('176','*YTr')])){if(res[_0x3806('177','uhp7')][_0x3806('178','5wZN')]){if(res['result'][_0x3806('179','*YTr')][_0x3806('17a','pfes')]){if(_0x46bf69[_0x3806('17b','eWzE')](_0x46bf69[_0x3806('17c','8EMV')],_0x46bf69[_0x3806('17d','tIHL')])){for(const _0x1be4a8 of res[_0x3806('17e','t!CZ')][_0x3806('17f','ngK0')][_0x3806('180','uhp7')]){$[_0x3806('181','uhp7')](_0x1be4a8[_0x3806('182','QSa4')]);if(_0x46bf69['uPCNb'](_0x1be4a8[_0x3806('183','XjYI')],0x4)){$[_0x3806('14a','1Ft7')](_0x3806('ad','3ucw')+_0x1be4a8['quantity']+_0x3806('184','(B8E'));$[_0x3806('48','IGwP')]+=_0x1be4a8[_0x3806('185','R$7V')];}}}else{_0x35cd32=JSON[_0x3806('186','eI5#')](_0x35cd32);if(_0x46bf69[_0x3806('187','rJfI')](_0x35cd32[_0x3806('188','eWzE')],_0x46bf69['Gsjlz'])){$[_0x3806('189','(B8E')]=![];return;}if(_0x46bf69[_0x3806('18a','GW%5')](_0x35cd32['retcode'],'0')&&_0x35cd32['data'][_0x3806('18b','4ZW1')](_0x46bf69[_0x3806('18c',']t4u')])){$['nickName']=_0x35cd32[_0x3806('106','9@7b')][_0x3806('18d','&ZMi')][_0x3806('18e','X]vA')]['nickname'];}}}}}else{$[_0x3806('18f','cWKQ')](error);}}}}}catch(_0xd08c){console['log'](_0xd08c);}finally{if(_0x46bf69[_0x3806('190','tIHL')]===_0x46bf69[_0x3806('191','*YTr')]){_0x46bf69[_0x3806('192','eWzE')](_0x278355);}else{$[_0x3806('193','ATE$')](vo[_0x3806('194','ZmKE')]);if(vo['prizeType']===0x4){$[_0x3806('195','QSa4')](_0x3806('196','cWKQ')+vo[_0x3806('197','thd&')]+_0x3806('198','ATE$'));$[_0x3806('199','zBIT')]+=vo['quantity'];}}}});});}function taskUrl(_0x55d35c,_0x32495f){var _0x23e16a={'xPTbs':'jinggengjcq-isv.isvjcloud.com','yQMTV':'application/json','bljZy':_0x3806('19a','oclh'),'PYXJN':_0x3806('19b','X]vA'),'KuUoN':_0x3806('19c','GW%5'),'cEhSm':_0x3806('19d','4ZW1'),'mPEiF':'https://jinggengjcq-isv.isvjcloud.com/fronth5/'};return{'url':_0x3806('19e','41Oe')+_0x55d35c+'?open_id=&mix_nick='+($['buyerNick']?$[_0x3806('19f','aRXH')]:'')+_0x3806('1a0','4Uzl')+($['authorCode']?Base64[_0x3806('1a1','&ZMi')](_0x3806('1a2','ATE$')+$[_0x3806('1a3','whs1')]):'')+'&user_id='+$[_0x3806('1a4','QSa4')],'headers':{'Host':_0x23e16a['xPTbs'],'Accept':_0x23e16a['yQMTV'],'X-Requested-With':_0x23e16a[_0x3806('1a5','*YTr')],'Accept-Language':_0x3806('1a6','ATE$'),'Accept-Encoding':_0x23e16a[_0x3806('1a7','41Oe')],'Content-Type':_0x23e16a[_0x3806('1a8','7k$G')],'Origin':_0x3806('1a9','ZmKE'),'User-Agent':_0x3806('1aa','fKmw')+$['UUID']+_0x3806('1ab','#M2z')+$[_0x3806('1ac','tIHL')]+_0x3806('1ad','eWzE'),'Connection':_0x23e16a[_0x3806('1ae','zBIT')],'Referer':_0x23e16a[_0x3806('1af','7k$G')],'Cookie':cookie},'body':JSON[_0x3806('1b0','(B8E')](_0x32495f)};}function getMyPing(){var _0x5a7075={'MtUsK':'已经是会员了','hLKCN':_0x3806('1b1','aRXH'),'mgKfV':_0x3806('1a6','ATE$'),'TqlTU':'gzip,\x20deflate,\x20br','xdDrM':_0x3806('1b2','eI5#'),'okkNa':'keep-alive','WDFrM':_0x3806('1b3',']t4u'),'UbbrK':'headers','lhHHc':function(_0x30e01e,_0x9f462c){return _0x30e01e!==_0x9f462c;},'XwPLl':'jEbyy','GAlBG':_0x3806('1b4','7k$G'),'hoEof':_0x3806('1b5','oclh'),'hKbho':_0x3806('1b6','ngK0'),'lglEt':function(_0x89ac,_0x55a044){return _0x89ac===_0x55a044;},'ztJWe':'ITjWI','BVPzA':_0x3806('1b7','rJfI'),'oFYdZ':_0x3806('1b8','IGwP'),'PEcqA':_0x3806('1b9','#M2z'),'clEYm':_0x3806('1ba','rJfI'),'AsHpC':'lzdz1-isv.isvjcloud.com','QicgT':_0x3806('1bb','eu%W'),'MMhfi':_0x3806('1bc','eI5#')};let _0x5d1d17={'url':_0x3806('1bd','@$aZ'),'headers':{'Host':_0x5a7075[_0x3806('1be','Rggf')],'Accept':'application/json','X-Requested-With':_0x5a7075['hLKCN'],'Accept-Language':_0x5a7075[_0x3806('1bf','1Ft7')],'Accept-Encoding':_0x5a7075[_0x3806('1c0','eWzE')],'Content-Type':_0x5a7075['QicgT'],'Origin':_0x5a7075['MMhfi'],'User-Agent':_0x3806('1c1','pfes')+$[_0x3806('1c2','ngK0')]+_0x3806('1c3','dBSs')+$['ADID']+_0x3806('1c4','XjYI'),'Connection':'keep-alive','Referer':$[_0x3806('1c5','ngK0')],'Cookie':cookie},'body':_0x3806('1c6','(B8E')+$[_0x3806('1c7','i2is')]+_0x3806('1c8','fKmw')+$[_0x3806('1c9','#M2z')]+'&fromType=APP&riskType=1'};return new Promise(_0x484bfb=>{var _0x42bb6a={'zRqdk':_0x3806('1ca','X]vA'),'ImGDV':_0x5a7075[_0x3806('1cb','4Uzl')],'YTaxV':_0x5a7075['mgKfV'],'XnCFy':_0x5a7075['TqlTU'],'Wocvr':_0x3806('1cc','1Ft7'),'BTueq':_0x5a7075[_0x3806('1cd','whs1')],'cgkoX':_0x5a7075[_0x3806('1ce','ZmKE')],'ZhXLG':_0x5a7075[_0x3806('1cf','5wZN')],'BUnnq':_0x5a7075['UbbrK'],'nBLbN':'set-cookie','VioKy':function(_0x2f9442){return _0x2f9442();},'kKabt':_0x3806('1d0','9@7b'),'FVZBf':function(_0x1e7e39,_0xe2f1b2){return _0x1e7e39!==_0xe2f1b2;},'bzmXV':_0x3806('1d1','eu%W'),'pheCo':function(_0x33979f,_0x2b2939){return _0x33979f===_0x2b2939;},'ZbhFx':_0x3806('1d2','tIHL'),'cAhVy':function(_0x29bc9d,_0x3fd442){return _0x5a7075[_0x3806('1d3','98HX')](_0x29bc9d,_0x3fd442);},'yzWeK':'SBRwA','WMrYE':function(_0x3839e1,_0x373005){return _0x3839e1===_0x373005;},'sqvXz':_0x5a7075[_0x3806('1d4','WrW5')],'UKDGd':function(_0x15bd9c,_0x226f81){return _0x15bd9c!==_0x226f81;},'jTXcg':_0x5a7075['GAlBG'],'ALQbW':_0x5a7075[_0x3806('1d5','uhp7')],'DwVKJ':function(_0x23c5c1,_0x38807f){return _0x23c5c1===_0x38807f;},'pffMa':_0x5a7075['hKbho'],'NmFmn':function(_0x8c7fb2,_0x2f056f){return _0x5a7075[_0x3806('1d6','IGwP')](_0x8c7fb2,_0x2f056f);},'vtmlP':_0x5a7075[_0x3806('1d7','aRXH')],'Dxfwg':_0x5a7075[_0x3806('1d8','Vs9P')],'LtPhY':_0x5a7075[_0x3806('1d9','1Ft7')],'bOdSl':_0x5a7075['PEcqA']};if(_0x5a7075['lhHHc'](_0x3806('1da','cWKQ'),_0x5a7075[_0x3806('1db','ZmKE')])){$[_0x3806('1dc','eI5#')](_0x5a7075[_0x3806('1dd','AIVd')]);}else{$[_0x3806('1de','fKmw')](_0x5d1d17,(_0x1d6dea,_0x546b37,_0x2c8201)=>{var _0x46e1a4={'lqNGo':_0x3806('1df','aRXH'),'RcvNF':function(_0x549d9f){return _0x42bb6a['VioKy'](_0x549d9f);},'rkjJS':_0x42bb6a[_0x3806('1e0','5wZN')]};try{if(_0x42bb6a[_0x3806('1e1','X]vA')](_0x42bb6a[_0x3806('1e2','3ucw')],_0x42bb6a[_0x3806('1e3','aRXH')])){let _0x1cd4f8=$['getdata'](_0x3806('1e4','5wZN'))||'[]';_0x1cd4f8=JSON[_0x3806('1e5','&ZMi')](_0x1cd4f8);cookiesArr=_0x1cd4f8[_0x3806('1e6','whs1')](_0x14c6a1=>_0x14c6a1[_0x3806('1e7','Vs9P')]);cookiesArr[_0x3806('1e8','zBIT')]();cookiesArr[_0x3806('1e9','eWzE')](...[$[_0x3806('1ea','AIVd')](_0x3806('1eb','thd&')),$[_0x3806('1ec','5wZN')](_0x46e1a4['lqNGo'])]);cookiesArr[_0x3806('1ed','1Ft7')]();cookiesArr=cookiesArr['filter'](_0x38af60=>!!_0x38af60);}else{if(_0x1d6dea){$['log'](_0x1d6dea);}else{if(_0x546b37[_0x42bb6a[_0x3806('1ee','ngK0')]][_0x42bb6a[_0x3806('1ef','W[8x')]]){cookie=''+originCookie;if($[_0x3806('1f0',']t4u')]()){for(let _0x35f4e7 of _0x546b37[_0x3806('1f1','1Ft7')][_0x42bb6a[_0x3806('1f2','zBIT')]]){if(_0x42bb6a[_0x3806('1f3','eWzE')](_0x3806('1f4','GW%5'),_0x42bb6a[_0x3806('1f5','GW%5')])){cookie=''+cookie+_0x35f4e7[_0x3806('1f6','Vs9P')](';')[0x0]+';';}else{cookie=''+cookie+_0x35f4e7[_0x3806('1f7','W[8x')](';')[0x0]+';';}}}else{for(let _0x386f2d of _0x546b37[_0x42bb6a[_0x3806('1f8','9@7b')]]['Set-Cookie'][_0x3806('1f9','i2is')](',')){if(_0x42bb6a[_0x3806('1fa','5wZN')](_0x3806('1fb','i2is'),_0x3806('1fc','QSa4'))){res=JSON['parse'](_0x2c8201);if(res[_0x3806('1fd','aRXH')]){if(res['result'][_0x3806('1fe','uhp7')]){$[_0x3806('1ff','Rggf')]=res[_0x3806('200','ATE$')]['interestsRuleList'][0x0][_0x3806('201','#M2z')][_0x3806('202','tIHL')];}}}else{cookie=''+cookie+_0x386f2d[_0x3806('203','(B8E')](';')[0x0]+';';}}}}if(_0x546b37[_0x42bb6a[_0x3806('204','pfes')]][_0x3806('205','ZmKE')]){cookie=''+originCookie;if($[_0x3806('206','IGwP')]()){if(_0x42bb6a['cAhVy'](_0x42bb6a[_0x3806('207','1Ft7')],_0x42bb6a[_0x3806('208','R$7V')])){$[_0x3806('209','9@7b')](_0x3806('20a','ngK0'));}else{for(let _0x3a1cd4 of _0x546b37[_0x3806('20b','5wZN')][_0x42bb6a[_0x3806('20c','thd&')]]){if(_0x42bb6a['WMrYE'](_0x42bb6a[_0x3806('20d','Rggf')],_0x42bb6a[_0x3806('20e','eu%W')])){cookie=''+cookie+_0x3a1cd4[_0x3806('1f7','W[8x')](';')[0x0]+';';}else{return{'url':_0x3806('20f','aRXH')+function_id+_0x3806('210','AIVd')+($[_0x3806('211','cWKQ')]?$[_0x3806('c3','oclh')]:'')+'&bizExtString='+($[_0x3806('212','AIVd')]?Base64[_0x3806('213','cWKQ')](_0x3806('214','oclh')+$['authorCode']):'')+_0x3806('215','&ZMi')+$[_0x3806('216','zBIT')],'headers':{'Host':_0x42bb6a[_0x3806('217','QSa4')],'Accept':_0x3806('218','1Ft7'),'X-Requested-With':_0x42bb6a[_0x3806('219','zJDc')],'Accept-Language':_0x42bb6a[_0x3806('21a','ngK0')],'Accept-Encoding':_0x42bb6a['XnCFy'],'Content-Type':_0x42bb6a[_0x3806('21b','1Ft7')],'Origin':_0x42bb6a[_0x3806('21c','aRXH')],'User-Agent':_0x3806('21d','QSa4')+$['UUID']+_0x3806('21e','cWKQ')+$[_0x3806('21f','eI5#')]+';model/iPhone10,3;addressid/0;appBuild/167668;jdSupportDarkMode/0;Mozilla/5.0\x20(iPhone;\x20CPU\x20iPhone\x20OS\x2013_6\x20like\x20Mac\x20OS\x20X)\x20AppleWebKit/605.1.15\x20(KHTML,\x20like\x20Gecko)\x20Mobile/15E148;supportJDSHWK/1','Connection':_0x42bb6a[_0x3806('220','AIVd')],'Referer':_0x42bb6a[_0x3806('221','Rggf')],'Cookie':cookie},'body':JSON[_0x3806('222','1Ft7')](body)};}}}}else{if(_0x42bb6a[_0x3806('223','uhp7')](_0x42bb6a['jTXcg'],_0x42bb6a[_0x3806('224','7k$G')])){console[_0x3806('225','Vhc2')](_0x1d6dea);}else{for(let _0x171ba9 of _0x546b37[_0x3806('226','#M2z')][_0x42bb6a[_0x3806('227','ZmKE')]][_0x3806('228','whs1')](',')){if(_0x42bb6a['DwVKJ'](_0x3806('229','R$7V'),_0x42bb6a[_0x3806('22a','zBIT')])){cookie=''+cookie+_0x171ba9[_0x3806('22b','9@7b')](';')[0x0]+';';}else{for(let _0x154f19 of _0x546b37[_0x42bb6a[_0x3806('1ee','ngK0')]][_0x42bb6a['nBLbN']]){cookie=''+cookie+_0x154f19['split'](';')[0x0]+';';}}}}}}if(_0x2c8201){if(_0x42bb6a['NmFmn'](_0x42bb6a[_0x3806('22c','5wZN')],_0x42bb6a['vtmlP'])){_0x2c8201=JSON['parse'](_0x2c8201);if(_0x2c8201[_0x3806('22d','&ZMi')]){$[_0x3806('22e','Vs9P')](_0x3806('22f','98HX')+_0x2c8201[_0x3806('fe','ATE$')]['nickname']);$[_0x3806('230','4Uzl')]=_0x2c8201[_0x3806('231','rJfI')][_0x3806('232','i2is')];$['secretPin']=_0x2c8201['data'][_0x3806('233','IGwP')];cookie=cookie+';AUTH_C_USER='+_0x2c8201['data'][_0x3806('234','aRXH')];}else{if(_0x42bb6a[_0x3806('235','fKmw')](_0x42bb6a[_0x3806('236','ATE$')],_0x3806('237','fKmw'))){$[_0x3806('238','ZmKE')](_0x2c8201[_0x3806('239','ZmKE')]);}else{_0x46e1a4[_0x3806('23a','pfes')](_0x484bfb);}}}else{if(_0x2c8201){_0x2c8201=JSON['parse'](_0x2c8201);if(_0x2c8201[_0x3806('23b','DMB5')]==='0'){$['token']=_0x2c8201['token'];}}else{$[_0x3806('23c','oclh')](_0x46e1a4['rkjJS']);}}}else{if(_0x42bb6a[_0x3806('23d','tIHL')](_0x42bb6a['LtPhY'],_0x42bb6a[_0x3806('23e','DMB5')])){console[_0x3806('23c','oclh')](_0x1d6dea);}else{$[_0x3806('99','3ucw')](_0x42bb6a[_0x3806('23f','XjYI')]);}}}}}catch(_0x915f94){$[_0x3806('240','@$aZ')](_0x915f94);}finally{_0x42bb6a[_0x3806('241','&ZMi')](_0x484bfb);}});}});}function getFirstLZCK(){var _0x450b3e={'ydEHu':function(_0x39614c,_0x3a0306){return _0x39614c&_0x3a0306;},'tymJn':_0x3806('242','aRXH'),'jNZVU':'set-cookie','KrmQq':_0x3806('243','R$7V'),'amRGz':function(_0x1d5123,_0x60cc1a){return _0x1d5123!==_0x60cc1a;},'KkAlT':_0x3806('244','DMB5'),'JOhac':'sjuBg','xAVML':_0x3806('245','eu%W')};return new Promise(_0x256084=>{var _0x125d1d={'DlmBS':function(_0x37899b,_0x12edf4){return _0x37899b|_0x12edf4;},'mIebB':function(_0x4a6a11,_0x1f60ad){return _0x450b3e['ydEHu'](_0x4a6a11,_0x1f60ad);},'VHhqh':_0x3806('246','zBIT'),'EhyGo':_0x3806('247','aRXH'),'MkaIo':function(_0xeda729,_0x506003){return _0xeda729===_0x506003;},'rBLRB':'kzQcI','meRKM':_0x450b3e[_0x3806('248','oclh')],'buufx':_0x450b3e[_0x3806('249','(B8E')],'ZEvLv':_0x3806('24a','i2is'),'stFcc':function(_0xb4e968,_0x499b08){return _0xb4e968!==_0x499b08;},'EOKHa':_0x450b3e[_0x3806('24b','Rggf')],'PpGmw':function(_0x22c4f4,_0x59f1d9){return _0x450b3e[_0x3806('24c','ATE$')](_0x22c4f4,_0x59f1d9);},'ojOFu':'Oqgpi','RZvte':_0x3806('24d','eWzE'),'zGKiP':_0x450b3e[_0x3806('24e','QSa4')],'ImofJ':_0x450b3e[_0x3806('24f','rJfI')],'yDgMa':_0x450b3e['xAVML'],'RAwEh':function(_0x486ed4){return _0x486ed4();}};$[_0x3806('250','7k$G')]({'url':$['activityUrl']},(_0x41448c,_0x368de0,_0x2babb9)=>{var _0x89fee7={'YznBE':'false'};if(_0x125d1d[_0x3806('251','3ucw')]===_0x3806('252','thd&')){var _0x2ab35a=Math[_0x3806('253','9@7b')]()*0x10|0x0,_0x302de1=c=='x'?_0x2ab35a:_0x125d1d['DlmBS'](_0x125d1d[_0x3806('254','QSa4')](_0x2ab35a,0x3),0x8);if(UpperCase){uuid=_0x302de1[_0x3806('255','oclh')](0x24)['toUpperCase']();}else{uuid=_0x302de1[_0x3806('256','GW%5')](0x24);}return uuid;}else{try{if(_0x125d1d[_0x3806('257','98HX')](_0x3806('258','4ZW1'),_0x125d1d[_0x3806('259','41Oe')])){$[_0x3806('25a','ATE$')]();}else{if(_0x41448c){console['log'](_0x41448c);}else{if(_0x368de0[_0x125d1d[_0x3806('25b','QSa4')]][_0x125d1d['buufx']]){if(_0x125d1d[_0x3806('25c','41Oe')]===_0x125d1d[_0x3806('25d','rJfI')]){cookie=''+originCookie;if($[_0x3806('25e','thd&')]()){for(let _0x59d56e of _0x368de0[_0x125d1d[_0x3806('25f','5wZN')]][_0x3806('260','Vs9P')]){if(_0x125d1d[_0x3806('261','#M2z')](_0x125d1d['EOKHa'],_0x125d1d['EOKHa'])){$['log'](_0x125d1d['VHhqh']);}else{cookie=''+cookie+_0x59d56e[_0x3806('262','1Ft7')](';')[0x0]+';';}}}else{for(let _0x245577 of _0x368de0[_0x125d1d[_0x3806('263','7k$G')]][_0x3806('264','pfes')][_0x3806('265','zBIT')](',')){if(_0x125d1d[_0x3806('266','@$aZ')](_0x125d1d['ojOFu'],_0x125d1d['RZvte'])){cookie=''+cookie+_0x245577[_0x3806('267','IGwP')](';')[0x0]+';';}else{$[_0x3806('268','41Oe')](_0x41448c);}}}}else{Object['keys'](jdCookieNode)['forEach'](_0xa9c4bb=>{cookiesArr['push'](jdCookieNode[_0xa9c4bb]);});if(process[_0x3806('269','#M2z')][_0x3806('26a','zBIT')]&&process[_0x3806('26b','@$aZ')][_0x3806('26c','9@7b')]===_0x89fee7['YznBE'])console[_0x3806('114','8EMV')]=()=>{};}}if(_0x368de0[_0x125d1d[_0x3806('26d','eI5#')]][_0x125d1d['zGKiP']]){cookie=''+originCookie;if($['isNode']()){for(let _0xb38a09 of _0x368de0[_0x125d1d['meRKM']][_0x125d1d[_0x3806('26e','QSa4')]]){cookie=''+cookie+_0xb38a09[_0x3806('26f','zJDc')](';')[0x0]+';';}}else{if(_0x3806('270','4Uzl')===_0x125d1d[_0x3806('271','thd&')]){for(let _0x564b3d of _0x368de0[_0x125d1d['meRKM']][_0x125d1d['zGKiP']][_0x3806('272','@$aZ')](',')){cookie=''+cookie+_0x564b3d['split'](';')[0x0]+';';}}else{console[_0x3806('273','t!CZ')](_0x41448c);}}}}}}catch(_0x1f5986){if(_0x125d1d['PpGmw']('clhiD',_0x125d1d['yDgMa'])){console[_0x3806('274','98HX')](_0x1f5986);}else{$['log']('京东返回了空数据');}}finally{_0x125d1d[_0x3806('275','WrW5')](_0x256084);}}});});}function getToken(){var _0x312730={'XxWJi':'没有成功获取到店铺信息','MNzRE':function(_0x56a02b,_0x387536){return _0x56a02b===_0x387536;},'iMzsr':_0x3806('276','7k$G'),'edVJZ':'FGgHt','LxBFB':_0x3806('277','7k$G'),'arokh':_0x3806('278','8EMV'),'SdrtP':_0x3806('279','3ucw'),'JVAlk':_0x3806('27a','zJDc'),'oWIEZ':function(_0x5755c0,_0xf12e23){return _0x5755c0!==_0xf12e23;},'GUSra':'uJURk','OvfgX':'sVJju','ZxMdq':_0x3806('27b','DMB5'),'aBLHC':'keep-alive','FwCmc':'zh-Hans-CN;q=1'};let _0x166cbe={'url':'https://api.m.jd.com/client.action?functionId=isvObfuscator','headers':{'Host':_0x3806('27c','oclh'),'Content-Type':_0x312730['ZxMdq'],'Accept':'*/*','Connection':_0x312730[_0x3806('27d','41Oe')],'Cookie':cookie,'User-Agent':'JD4iPhone/167650\x20(iPhone;\x20iOS\x2013.7;\x20Scale/3.00)','Accept-Language':_0x312730[_0x3806('27e','Vhc2')],'Accept-Encoding':'gzip,\x20deflate,\x20br'},'body':_0x3806('27f','tIHL')};return new Promise(_0x43b1ba=>{var _0x338b24={'DzBPz':_0x312730[_0x3806('280','Rggf')],'uxBwu':function(_0x2117d0,_0x5018c4){return _0x312730['MNzRE'](_0x2117d0,_0x5018c4);},'OQWeM':_0x312730[_0x3806('281','ngK0')],'bIOzm':_0x312730[_0x3806('282','t!CZ')],'gNxAQ':function(_0x13be33,_0x57bf4f){return _0x13be33===_0x57bf4f;},'GJMOL':_0x312730[_0x3806('283','1Ft7')],'TbQST':_0x312730['arokh'],'RUFRs':_0x312730['SdrtP'],'eBCab':_0x3806('284',']t4u'),'gKXzb':_0x312730['JVAlk']};if(_0x312730[_0x3806('285','oclh')](_0x312730[_0x3806('286','(B8E')],_0x312730[_0x3806('287','WrW5')])){$['post'](_0x166cbe,(_0x358ee2,_0x544dd6,_0xf30898)=>{var _0x239f4e={'TzkZl':_0x338b24[_0x3806('288','dBSs')]};if(_0x338b24['uxBwu'](_0x338b24['OQWeM'],_0x3806('289','9@7b'))){try{if(_0x338b24[_0x3806('28a','ZmKE')]===_0x3806('28b','IGwP')){uuid=v[_0x3806('28c','5wZN')](0x24);}else{if(_0x358ee2){$[_0x3806('72','AIVd')](_0x358ee2);}else{if(_0xf30898){_0xf30898=JSON[_0x3806('28d','zJDc')](_0xf30898);if(_0x338b24[_0x3806('28e','41Oe')](_0xf30898[_0x3806('28f','X]vA')],'0')){if(_0x338b24['gNxAQ'](_0x338b24['GJMOL'],_0x338b24[_0x3806('290','98HX')])){if(res[_0x3806('291','7k$G')][_0x3806('292','9@7b')]){$['openCardActivityId']=res['result'][_0x3806('293','QSa4')][0x0][_0x3806('294','4Uzl')][_0x3806('295','ngK0')];}}else{$['token']=_0xf30898[_0x3806('296','i2is')];}}}else{if(_0x338b24[_0x3806('297','#M2z')]!==_0x338b24['eBCab']){$['log'](_0x338b24['gKXzb']);}else{$[_0x3806('1dc','eI5#')](_0x358ee2);}}}}}catch(_0x234e53){$[_0x3806('298','W[8x')](_0x234e53);}finally{_0x43b1ba();}}else{$[_0x3806('8e','R$7V')](_0x239f4e[_0x3806('299','pfes')]);}});}else{cookie=''+cookie+ck[_0x3806('29a','fKmw')](';')[0x0]+';';}});}function random(_0x16175b,_0x45ee7f){var _0x19a4c9={'rHetf':function(_0x414f06,_0x174a6d){return _0x414f06+_0x174a6d;},'MusSv':function(_0x4e89d1,_0x252212){return _0x4e89d1*_0x252212;},'SLToz':function(_0x898eab,_0x400f44){return _0x898eab-_0x400f44;}};return _0x19a4c9[_0x3806('29b','3ucw')](Math[_0x3806('29c','9@7b')](_0x19a4c9['MusSv'](Math[_0x3806('29d','W[8x')](),_0x19a4c9[_0x3806('29e',']t4u')](_0x45ee7f,_0x16175b))),_0x16175b);}function getUUID(_0x491daf='xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',_0x38357f=0x0){var _0x58f755={'QfixV':_0x3806('29f','&ZMi'),'WQLwF':function(_0x35865e,_0x1b5a57){return _0x35865e!==_0x1b5a57;},'vipFJ':_0x3806('2a0','eWzE'),'dSUem':function(_0x222b4d,_0x1796b4){return _0x222b4d|_0x1796b4;},'ADUOj':function(_0xc0b492,_0x3d1b54){return _0xc0b492*_0x3d1b54;},'TCeWt':function(_0x198119,_0xf23598){return _0x198119!==_0xf23598;},'OEgxI':_0x3806('2a1','@$aZ')};return _0x491daf[_0x3806('2a2','eWzE')](/[xy]/g,function(_0x181bce){if(_0x58f755[_0x3806('2a3','IGwP')](_0x58f755[_0x3806('2a4','IGwP')],_0x58f755[_0x3806('2a5','WrW5')])){$[_0x3806('8','Rggf')](_0x58f755[_0x3806('2a6','(B8E')]);}else{var _0xc5687a=_0x58f755['dSUem'](_0x58f755['ADUOj'](Math['random'](),0x10),0x0),_0x536071=_0x181bce=='x'?_0xc5687a:_0xc5687a&0x3|0x8;if(_0x38357f){uuid=_0x536071[_0x3806('2a7','1Ft7')](0x24)['toUpperCase']();}else{if(_0x58f755[_0x3806('2a8','ATE$')](_0x58f755[_0x3806('2a9','tIHL')],_0x58f755['OEgxI'])){console[_0x3806('2aa','fKmw')](error);}else{uuid=_0x536071[_0x3806('255','oclh')](0x24);}}return uuid;}});}function checkCookie(){var _0x3bd01a={'UpgeE':'TXUMo','NyKfA':_0x3806('2ab','thd&'),'ALQgo':function(_0x3f0721,_0x132132){return _0x3f0721===_0x132132;},'yjWmg':_0x3806('2ac','X]vA'),'kXQCC':function(_0x2d5805,_0x32fa07){return _0x2d5805===_0x32fa07;},'HhgUM':_0x3806('2ad','@$aZ'),'RTVhG':function(_0x10be3e,_0x16d50a){return _0x10be3e!==_0x16d50a;},'XHdmP':_0x3806('2ae','eWzE'),'CNuKN':_0x3806('2af','Vs9P'),'oOhqY':'me-api.jd.com','yTyHZ':_0x3806('2b0','R$7V'),'nKHmB':_0x3806('2b1','*YTr'),'HICDe':_0x3806('2b2','thd&')};const _0x20e165={'url':_0x3bd01a[_0x3806('2b3','7k$G')],'headers':{'Host':_0x3bd01a[_0x3806('2b4','i2is')],'Accept':_0x3806('2b5','@$aZ'),'Connection':_0x3bd01a[_0x3806('2b6','rJfI')],'Cookie':cookie,'User-Agent':_0x3bd01a[_0x3806('2b7','AIVd')],'Accept-Language':_0x3806('2b8','@$aZ'),'Referer':_0x3bd01a['HICDe'],'Accept-Encoding':_0x3806('2b9','ngK0')}};return new Promise(_0x4dda1b=>{$[_0x3806('2ba','t!CZ')](_0x20e165,(_0x52fcd2,_0x59eeff,_0x559cc7)=>{try{if(_0x52fcd2){$[_0x3806('2bb','W[8x')](_0x52fcd2);}else{if(_0x3806('2bc','WrW5')!==_0x3bd01a['UpgeE']){_0x4dda1b();}else{if(_0x559cc7){_0x559cc7=JSON[_0x3806('2bd','8EMV')](_0x559cc7);if(_0x559cc7[_0x3806('2be','thd&')]===_0x3bd01a[_0x3806('2bf','1Ft7')]){if(_0x3bd01a[_0x3806('2c0','3ucw')](_0x3806('2c1','cWKQ'),_0x3bd01a[_0x3806('2c2','pfes')])){$[_0x3806('2c3','GW%5')]=![];return;}else{cookie=''+cookie+ck['split'](';')[0x0]+';';}}if(_0x3bd01a['kXQCC'](_0x559cc7[_0x3806('2c4','5wZN')],'0')&&_0x559cc7['data'][_0x3806('2c5','t!CZ')]('userInfo')){$[_0x3806('2c6','1Ft7')]=_0x559cc7[_0x3806('2c7','(B8E')][_0x3806('2c8','aRXH')][_0x3806('2c9','4ZW1')]['nickname'];}}else{$[_0x3806('26','X]vA')](_0x3bd01a['HhgUM']);}}}}catch(_0xcd8500){$[_0x3806('2ca','1Ft7')](_0xcd8500);}finally{if(_0x3bd01a['RTVhG'](_0x3bd01a['XHdmP'],_0x3bd01a[_0x3806('2cb','X]vA')])){$[_0x3806('2cc','rJfI')]('','❌\x20'+$[_0x3806('194','ZmKE')]+_0x3806('2cd','XjYI')+e+'!','');}else{_0x4dda1b();}}});});};_0xod9='jsjiami.com.v6'; +// prettier-ignore +!function (n) { "use strict"; function t(n, t) { var r = (65535 & n) + (65535 & t); return (n >> 16) + (t >> 16) + (r >> 16) << 16 | 65535 & r } function r(n, t) { return n << t | n >>> 32 - t } function e(n, e, o, u, c, f) { return t(r(t(t(e, n), t(u, f)), c), o) } function o(n, t, r, o, u, c, f) { return e(t & r | ~t & o, n, t, u, c, f) } function u(n, t, r, o, u, c, f) { return e(t & o | r & ~o, n, t, u, c, f) } function c(n, t, r, o, u, c, f) { return e(t ^ r ^ o, n, t, u, c, f) } function f(n, t, r, o, u, c, f) { return e(r ^ (t | ~o), n, t, u, c, f) } function i(n, r) { n[r >> 5] |= 128 << r % 32, n[14 + (r + 64 >>> 9 << 4)] = r; var e, i, a, d, h, l = 1732584193, g = -271733879, v = -1732584194, m = 271733878; for (e = 0; e < n.length; e += 16)i = l, a = g, d = v, h = m, g = f(g = f(g = f(g = f(g = c(g = c(g = c(g = c(g = u(g = u(g = u(g = u(g = o(g = o(g = o(g = o(g, v = o(v, m = o(m, l = o(l, g, v, m, n[e], 7, -680876936), g, v, n[e + 1], 12, -389564586), l, g, n[e + 2], 17, 606105819), m, l, n[e + 3], 22, -1044525330), v = o(v, m = o(m, l = o(l, g, v, m, n[e + 4], 7, -176418897), g, v, n[e + 5], 12, 1200080426), l, g, n[e + 6], 17, -1473231341), m, l, n[e + 7], 22, -45705983), v = o(v, m = o(m, l = o(l, g, v, m, n[e + 8], 7, 1770035416), g, v, n[e + 9], 12, -1958414417), l, g, n[e + 10], 17, -42063), m, l, n[e + 11], 22, -1990404162), v = o(v, m = o(m, l = o(l, g, v, m, n[e + 12], 7, 1804603682), g, v, n[e + 13], 12, -40341101), l, g, n[e + 14], 17, -1502002290), m, l, n[e + 15], 22, 1236535329), v = u(v, m = u(m, l = u(l, g, v, m, n[e + 1], 5, -165796510), g, v, n[e + 6], 9, -1069501632), l, g, n[e + 11], 14, 643717713), m, l, n[e], 20, -373897302), v = u(v, m = u(m, l = u(l, g, v, m, n[e + 5], 5, -701558691), g, v, n[e + 10], 9, 38016083), l, g, n[e + 15], 14, -660478335), m, l, n[e + 4], 20, -405537848), v = u(v, m = u(m, l = u(l, g, v, m, n[e + 9], 5, 568446438), g, v, n[e + 14], 9, -1019803690), l, g, n[e + 3], 14, -187363961), m, l, n[e + 8], 20, 1163531501), v = u(v, m = u(m, l = u(l, g, v, m, n[e + 13], 5, -1444681467), g, v, n[e + 2], 9, -51403784), l, g, n[e + 7], 14, 1735328473), m, l, n[e + 12], 20, -1926607734), v = c(v, m = c(m, l = c(l, g, v, m, n[e + 5], 4, -378558), g, v, n[e + 8], 11, -2022574463), l, g, n[e + 11], 16, 1839030562), m, l, n[e + 14], 23, -35309556), v = c(v, m = c(m, l = c(l, g, v, m, n[e + 1], 4, -1530992060), g, v, n[e + 4], 11, 1272893353), l, g, n[e + 7], 16, -155497632), m, l, n[e + 10], 23, -1094730640), v = c(v, m = c(m, l = c(l, g, v, m, n[e + 13], 4, 681279174), g, v, n[e], 11, -358537222), l, g, n[e + 3], 16, -722521979), m, l, n[e + 6], 23, 76029189), v = c(v, m = c(m, l = c(l, g, v, m, n[e + 9], 4, -640364487), g, v, n[e + 12], 11, -421815835), l, g, n[e + 15], 16, 530742520), m, l, n[e + 2], 23, -995338651), v = f(v, m = f(m, l = f(l, g, v, m, n[e], 6, -198630844), g, v, n[e + 7], 10, 1126891415), l, g, n[e + 14], 15, -1416354905), m, l, n[e + 5], 21, -57434055), v = f(v, m = f(m, l = f(l, g, v, m, n[e + 12], 6, 1700485571), g, v, n[e + 3], 10, -1894986606), l, g, n[e + 10], 15, -1051523), m, l, n[e + 1], 21, -2054922799), v = f(v, m = f(m, l = f(l, g, v, m, n[e + 8], 6, 1873313359), g, v, n[e + 15], 10, -30611744), l, g, n[e + 6], 15, -1560198380), m, l, n[e + 13], 21, 1309151649), v = f(v, m = f(m, l = f(l, g, v, m, n[e + 4], 6, -145523070), g, v, n[e + 11], 10, -1120210379), l, g, n[e + 2], 15, 718787259), m, l, n[e + 9], 21, -343485551), l = t(l, i), g = t(g, a), v = t(v, d), m = t(m, h); return [l, g, v, m] } function a(n) { var t, r = "", e = 32 * n.length; for (t = 0; t < e; t += 8)r += String.fromCharCode(n[t >> 5] >>> t % 32 & 255); return r } function d(n) { var t, r = []; for (r[(n.length >> 2) - 1] = void 0, t = 0; t < r.length; t += 1)r[t] = 0; var e = 8 * n.length; for (t = 0; t < e; t += 8)r[t >> 5] |= (255 & n.charCodeAt(t / 8)) << t % 32; return r } function h(n) { return a(i(d(n), 8 * n.length)) } function l(n, t) { var r, e, o = d(n), u = [], c = []; for (u[15] = c[15] = void 0, o.length > 16 && (o = i(o, 8 * n.length)), r = 0; r < 16; r += 1)u[r] = 909522486 ^ o[r], c[r] = 1549556828 ^ o[r]; return e = i(u.concat(d(t)), 512 + 8 * t.length), a(i(c.concat(e), 640)) } function g(n) { var t, r, e = ""; for (r = 0; r < n.length; r += 1)t = n.charCodeAt(r), e += "0123456789abcdef".charAt(t >>> 4 & 15) + "0123456789abcdef".charAt(15 & t); return e } function v(n) { return unescape(encodeURIComponent(n)) } function m(n) { return h(v(n)) } function p(n) { return g(m(n)) } function s(n, t) { return l(v(n), v(t)) } function C(n, t) { return g(s(n, t)) } function A(n, t, r) { return t ? r ? s(t, n) : C(t, n) : r ? m(n) : p(n) } $.md5 = A }(this); +function Env(t, e) { "undefined" != typeof process && JSON.stringify(process.env).indexOf("GITHUB") > -1 && process.exit(0); class s { constructor(t) { this.env = t } send(t, e = "GET") { t = "string" == typeof t ? { url: t } : t; let s = this.get; return "POST" === e && (s = this.post), new Promise((e, i) => { s.call(this, t, (t, s, r) => { t ? i(t) : e(s) }) }) } get(t) { return this.send.call(this.env, t) } post(t) { return this.send.call(this.env, t, "POST") } } return new class { constructor(t, e) { this.name = t, this.http = new s(this), this.data = null, this.dataFile = "box.dat", this.logs = [], this.isMute = !1, this.isNeedRewrite = !1, this.logSeparator = "\n", this.startTime = (new Date).getTime(), Object.assign(this, e), this.log("", `🔔${this.name}, 开始!`) } isNode() { return "undefined" != typeof module && !!module.exports } isQuanX() { return "undefined" != typeof $task } isSurge() { return "undefined" != typeof $httpClient && "undefined" == typeof $loon } isLoon() { return "undefined" != typeof $loon } toObj(t, e = null) { try { return JSON.parse(t) } catch { return e } } toStr(t, e = null) { try { return JSON.stringify(t) } catch { return e } } getjson(t, e) { let s = e; const i = this.getdata(t); if (i) try { s = JSON.parse(this.getdata(t)) } catch { } return s } setjson(t, e) { try { return this.setdata(JSON.stringify(t), e) } catch { return !1 } } getScript(t) { return new Promise(e => { this.get({ url: t }, (t, s, i) => e(i)) }) } runScript(t, e) { return new Promise(s => { let i = this.getdata("@chavy_boxjs_userCfgs.httpapi"); i = i ? i.replace(/\n/g, "").trim() : i; let r = this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout"); r = r ? 1 * r : 20, r = e && e.timeout ? e.timeout : r; const [o, h] = i.split("@"), n = { url: `http://${h}/v1/scripting/evaluate`, body: { script_text: t, mock_type: "cron", timeout: r }, headers: { "X-Key": o, Accept: "*/*" } }; this.post(n, (t, e, i) => s(i)) }).catch(t => this.logErr(t)) } loaddata() { if (!this.isNode()) return {}; { this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path"); const t = this.path.resolve(this.dataFile), e = this.path.resolve(process.cwd(), this.dataFile), s = this.fs.existsSync(t), i = !s && this.fs.existsSync(e); if (!s && !i) return {}; { const i = s ? t : e; try { return JSON.parse(this.fs.readFileSync(i)) } catch (t) { return {} } } } } writedata() { if (this.isNode()) { this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path"); const t = this.path.resolve(this.dataFile), e = this.path.resolve(process.cwd(), this.dataFile), s = this.fs.existsSync(t), i = !s && this.fs.existsSync(e), r = JSON.stringify(this.data); s ? this.fs.writeFileSync(t, r) : i ? this.fs.writeFileSync(e, r) : this.fs.writeFileSync(t, r) } } lodash_get(t, e, s) { const i = e.replace(/\[(\d+)\]/g, ".$1").split("."); let r = t; for (const t of i) if (r = Object(r)[t], void 0 === r) return s; return r } lodash_set(t, e, s) { return Object(t) !== t ? t : (Array.isArray(e) || (e = e.toString().match(/[^.[\]]+/g) || []), e.slice(0, -1).reduce((t, s, i) => Object(t[s]) === t[s] ? t[s] : t[s] = Math.abs(e[i + 1]) >> 0 == +e[i + 1] ? [] : {}, t)[e[e.length - 1]] = s, t) } getdata(t) { let e = this.getval(t); if (/^@/.test(t)) { const [, s, i] = /^@(.*?)\.(.*?)$/.exec(t), r = s ? this.getval(s) : ""; if (r) try { const t = JSON.parse(r); e = t ? this.lodash_get(t, i, "") : e } catch (t) { e = "" } } return e } setdata(t, e) { let s = !1; if (/^@/.test(e)) { const [, i, r] = /^@(.*?)\.(.*?)$/.exec(e), o = this.getval(i), h = i ? "null" === o ? null : o || "{}" : "{}"; try { const e = JSON.parse(h); this.lodash_set(e, r, t), s = this.setval(JSON.stringify(e), i) } catch (e) { const o = {}; this.lodash_set(o, r, t), s = this.setval(JSON.stringify(o), i) } } else s = this.setval(t, e); return s } getval(t) { return this.isSurge() || this.isLoon() ? $persistentStore.read(t) : this.isQuanX() ? $prefs.valueForKey(t) : this.isNode() ? (this.data = this.loaddata(), this.data[t]) : this.data && this.data[t] || null } setval(t, e) { return this.isSurge() || this.isLoon() ? $persistentStore.write(t, e) : this.isQuanX() ? $prefs.setValueForKey(t, e) : this.isNode() ? (this.data = this.loaddata(), this.data[e] = t, this.writedata(), !0) : this.data && this.data[e] || null } initGotEnv(t) { this.got = this.got ? this.got : require("got"), this.cktough = this.cktough ? this.cktough : require("tough-cookie"), this.ckjar = this.ckjar ? this.ckjar : new this.cktough.CookieJar, t && (t.headers = t.headers ? t.headers : {}, void 0 === t.headers.Cookie && void 0 === t.cookieJar && (t.cookieJar = this.ckjar)) } get(t, e = (() => { })) { t.headers && (delete t.headers["Content-Type"], delete t.headers["Content-Length"]), this.isSurge() || this.isLoon() ? (this.isSurge() && this.isNeedRewrite && (t.headers = t.headers || {}, Object.assign(t.headers, { "X-Surge-Skip-Scripting": !1 })), $httpClient.get(t, (t, s, i) => { !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i) })) : this.isQuanX() ? (this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, { hints: !1 })), $task.fetch(t).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => e(t))) : this.isNode() && (this.initGotEnv(t), this.got(t).on("redirect", (t, e) => { try { if (t.headers["set-cookie"]) { const s = t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString(); s && this.ckjar.setCookieSync(s, null), e.cookieJar = this.ckjar } } catch (t) { this.logErr(t) } }).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => { const { message: s, response: i } = t; e(s, i, i && i.body) })) } post(t, e = (() => { })) { if (t.body && t.headers && !t.headers["Content-Type"] && (t.headers["Content-Type"] = "application/x-www-form-urlencoded"), t.headers && delete t.headers["Content-Length"], this.isSurge() || this.isLoon()) this.isSurge() && this.isNeedRewrite && (t.headers = t.headers || {}, Object.assign(t.headers, { "X-Surge-Skip-Scripting": !1 })), $httpClient.post(t, (t, s, i) => { !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i) }); else if (this.isQuanX()) t.method = "POST", this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, { hints: !1 })), $task.fetch(t).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => e(t)); else if (this.isNode()) { this.initGotEnv(t); const { url: s, ...i } = t; this.got.post(s, i).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => { const { message: s, response: i } = t; e(s, i, i && i.body) }) } } time(t, e = null) { const s = e ? new Date(e) : new Date; let i = { "M+": s.getMonth() + 1, "d+": s.getDate(), "H+": s.getHours(), "m+": s.getMinutes(), "s+": s.getSeconds(), "q+": Math.floor((s.getMonth() + 3) / 3), S: s.getMilliseconds() }; /(y+)/.test(t) && (t = t.replace(RegExp.$1, (s.getFullYear() + "").substr(4 - RegExp.$1.length))); for (let e in i) new RegExp("(" + e + ")").test(t) && (t = t.replace(RegExp.$1, 1 == RegExp.$1.length ? i[e] : ("00" + i[e]).substr(("" + i[e]).length))); return t } msg(e = t, s = "", i = "", r) { const o = t => { if (!t) return t; if ("string" == typeof t) return this.isLoon() ? t : this.isQuanX() ? { "open-url": t } : this.isSurge() ? { url: t } : void 0; if ("object" == typeof t) { if (this.isLoon()) { let e = t.openUrl || t.url || t["open-url"], s = t.mediaUrl || t["media-url"]; return { openUrl: e, mediaUrl: s } } if (this.isQuanX()) { let e = t["open-url"] || t.url || t.openUrl, s = t["media-url"] || t.mediaUrl; return { "open-url": e, "media-url": s } } if (this.isSurge()) { let e = t.url || t.openUrl || t["open-url"]; return { url: e } } } }; if (this.isMute || (this.isSurge() || this.isLoon() ? $notification.post(e, s, i, o(r)) : this.isQuanX() && $notify(e, s, i, o(r))), !this.isMuteLog) { let t = ["", "==============📣系统通知📣=============="]; t.push(e), s && t.push(s), i && t.push(i), console.log(t.join("\n")), this.logs = this.logs.concat(t) } } log(...t) { t.length > 0 && (this.logs = [...this.logs, ...t]), console.log(t.join(this.logSeparator)) } logErr(t, e) { const s = !this.isSurge() && !this.isQuanX() && !this.isLoon(); s ? this.log("", `❗️${this.name}, 错误!`, t.stack) : this.log("", `❗️${this.name}, 错误!`, t) } wait(t) { return new Promise(e => setTimeout(e, t)) } done(t = {}) { const e = (new Date).getTime(), s = (e - this.startTime) / 1e3; this.log("", `🔔${this.name}, 结束! 🕛 ${s} 秒`), this.log(), (this.isSurge() || this.isQuanX() || this.isLoon()) && $done(t) } }(t, e) } diff --git a/activity/jd_opencard9.js b/activity/jd_opencard9.js new file mode 100644 index 0000000..157ff40 --- /dev/null +++ b/activity/jd_opencard9.js @@ -0,0 +1,588 @@ +/* +跨界宠粉 豪礼放送 +2021年10月31日 - 2021年11月13日 +https://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity/5063373?activityId=llk20211031b&shareUuid=2638499a2a0340178a217b32705faa5a + +cron 17 0,20 * * * https://raw.githubusercontent.com/KingRan/JDJB/main/jd_opencard9.js +*/ +const $ = new Env("2021.10.31-11-13跨界宠粉 豪礼放送"); +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const notify = $.isNode() ? require('./sendNotify') : ''; +let cookiesArr = [], cookie = '', message = ''; +let ownCode = null; +let authorCodeList = [] +if ($.isNode()) { + console.log('先运行一次查看是否有豆,有豆再运行!!!') + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => { }; +} else { + let cookiesData = $.getdata('CookiesJD') || "[]"; + cookiesData = JSON.parse(cookiesData); + cookiesArr = cookiesData.map(item => item.cookie); + cookiesArr.reverse(); + cookiesArr.push(...[$.getdata('CookieJD2'), $.getdata('CookieJD')]); + cookiesArr.reverse(); + cookiesArr = cookiesArr.filter(item => !!item); +} +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', { "open-url": "https://bean.m.jd.com/bean/signIndex.action" }); + return; + } + authorCodeList = await getAuthorCodeList('https://gitee.com/KingRan521/JD-Scripts/raw/master/shareCodes/opencard9.json') + if(authorCodeList === '404: Not Found'){ + authorCodeList = [ + '2638499a2a0340178a217b32705faa5a', + ] + } + // console.log(authorCodeList) + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i] + originCookie = cookiesArr[i] + newCookie = '' + $.UserName = decodeURIComponent(cookie.match(/pt_pin=(.+?);/) && cookie.match(/pt_pin=(.+?);/)[1]) + $.index = i + 1; + $.isLogin = true; + $.nickName = ''; + await checkCookie(); + console.log(`\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + if (!$.isLogin) { + $.msg($.name, `【提示】cookie已失效`, `京东账号${$.index} ${$.nickName || $.UserName}\n请重新登录获取\nhttps://bean.m.jd.com/bean/signIndex.action`, { "open-url": "https://bean.m.jd.com/bean/signIndex.action" }); + // if ($.isNode()) { + // await notify.sendNotify(`${$.name}cookie已失效 - ${$.UserName}`, `京东账号${$.index} ${$.UserName}\n请重新登录获取cookie`); + // } + continue + } + $.bean = 0; + $.ADID = getUUID('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', 1); + $.UUID = getUUID('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'); + // $.authorCode = authorCodeList[random(0, authorCodeList.length)] + $.authorCode = ownCode ? ownCode : authorCodeList[random(0, authorCodeList.length)] + $.authorNum = `${random(1000000, 9999999)}` + $.randomCode = random(1000000, 9999999) + $.activityId = 'llk20211031b' + $.activityShopId = '1000001195' + $.activityUrl = `https://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity/${$.authorNum}?activityId=${$.activityId}&shareUuid=${encodeURIComponent($.authorCode)}&adsource=null&shareuserid4minipg=null&shopid=undefined&lng=00.000000&lat=00.000000&sid=&un_area=` + await member(); + await $.wait(5000) + if ($.bean > 0) { + message += `\n【京东账号${$.index}】${$.nickName || $.UserName} \n └ 获得 ${$.bean} 京豆。` + } + } + } + if (message !== '') { + if ($.isNode()) { + await notify.sendNotify($.name, message, '', `\n`); + } else { + $.msg($.name, '有点儿收获', message); + } + } +})() + .catch((e) => { + $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') + }) + .finally(() => { + $.done(); + }) + + +async function member() { + $.token = null; + $.secretPin = null; + $.openCardActivityId = null + await getFirstLZCK() + await getToken(); + await task('dz/common/getSimpleActInfoVo', `activityId=${$.activityId}`, 1) + if ($.token) { + await getMyPing(); + if ($.secretPin) { + console.log("去助力 -> "+$.authorCode) + await task('common/accessLogWithAD', `venderId=${$.activityShopId}&code=99&pin=${encodeURIComponent($.secretPin)}&activityId=${$.activityId}&pageUrl=${$.activityUrl}&subType=app&adSource=null`, 1); + await task('wxActionCommon/getUserInfo', `pin=${encodeURIComponent($.secretPin)}`, 1) + if ($.index === 1) { + await task('linkgame/activity/content', `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}&pinImg=&nick=${encodeURIComponent($.pin)}&cjyxPin=&cjhyPin=&shareUuid=${encodeURIComponent($.authorCode)}`, 0, 1) + } else { + await task('linkgame/activity/content', `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}&pinImg=&nick=${encodeURIComponent($.pin)}&cjyxPin=&cjhyPin=&shareUuid=${encodeURIComponent($.authorCode)}`) + } + $.log("关注店铺") + await task('linkgame/follow/shop', `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}`) + await task('taskact/common/drawContent', `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}`) + await task('linkgame/checkOpenCard', `pin=${encodeURIComponent($.secretPin)}&activityId=${$.activityId}`) + $.log("加入店铺会员") + if ($.openCardList) { + for (let i = 0; i < ($.openCardList.length); i++) { + $.log(">>> 模拟上报访问记录") + await task('crm/pageVisit/insertCrmPageVisit', `venderId=1000001373&pageId=llk20211020&elementId=入会跳转&pin=${encodeURIComponent($.secretPin)}`, 1) + await $.wait(2000) + } + + for (const vo of $.openCardList) { + $.log(`>>> 去加入${vo.name} ${vo.venderId}`) + if (vo.status === 0) { + await getShopOpenCardInfo({ "venderId": `${vo.venderId}`, "channel": "401" }, vo.venderId) + await bindWithVender({ "venderId": `${vo.venderId}`, "bindByVerifyCodeFlag": 1, "registerExtend": {}, "writeChildFlag": 0, "activityId": $.openCardActivityId, "channel": 401 }, vo.venderId) + await $.wait(2000) + } else { + $.log(`>>> 已经是会员`) + } + + } + } else { + $.log("没有获取到对应的任务。\n") + } + await task('linkgame/checkOpenCard', `pin=${encodeURIComponent($.secretPin)}&activityId=${$.activityId}`) + if ($.openCardStatus) { + // console.log('去助力 -> ' + $.authorCode) + if ($.openCardStatus.allOpenCard) { + await task('linkgame/assist/status', `pin=${encodeURIComponent($.secretPin)}&activityId=${$.activityId}&shareUuid=${$.authorCode}`) + await task('linkgame/assist', `pin=${encodeURIComponent($.secretPin)}&activityId=${$.activityId}&shareUuid=${$.authorCode}`) + + } + } + await task('linkgame/help/list', `pin=${encodeURIComponent($.secretPin)}&activityId=${$.activityId}`) + + await task('linkgame/task/info', `pin=${encodeURIComponent($.secretPin)}&activityId=${$.activityId}`) + if ($.TaskList) { + tasklist = $.TaskList + if (!$.TaskList.sign) { + await task('linkgame/sign', `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}`); + } else { + console.log("已完成签到") + } + if (!$.TaskList.visitSku) { + for (const vo of tasklist.visitSkuList) { + if (vo.status === 0) { + await task('linkgame/browseGoods', `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}&value=${vo.goodsCode}`) + } + } + } else { + console.log("已完成浏览任务"); + } + if (!$.TaskList.addCart) { + await task('linkgame/addCart', `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}`); + } else { + console.log("加购任务已完成") + } + } + } + } +} + +function task(function_id, body, isCommon = 0, own = 0) { + return new Promise(resolve => { + $.post(taskUrl(function_id, body, isCommon), async (err, resp, data) => { + try { + if (err) { + $.log(err) + } else { + + if (data) { + data = JSON.parse(data); + if (data.result) { + switch (function_id) { + case 'dz/common/getSimpleActInfoVo': + $.jdActivityId = data.data.jdActivityId; + $.venderId = data.data.venderId; + $.activityType = data.data.activityType; + break; + case 'wxActionCommon/getUserInfo': + break; + case 'linkgame/activity/content': + if (!data.data.hasEnd) { + $.log(`开启【${data.data.activity['name']}】活动`) + $.log("-------------------") + if ($.index === 1) { + ownCode = data.data.actor['actorUuid'] + console.log(ownCode) + } + $.actorUuid = data.data.actor['actorUuid']; + } else { + $.log("活动已经结束"); + } + break; + case 'linkgame/checkOpenCard': + $.openCardList = data.data.openCardList; + $.openCardStatus = data.data; + // console.log(data) + break; + case 'linkgame/follow/shop': + console.log(data) + break; + case 'linkgame/sign': + console.log(data) + break; + case 'linkgame/addCart': + console.log(data) + break; + case 'linkgame/browseGoods': + console.log(data) + break; + case 'interaction/write/writePersonInfo': + console.log(data) + break; + case 'linkgame/task/info': + console.log(data) + break; + case 'linkgame/assist/status': + console.log(data) + break; + case 'linkgame/assist': + console.log(data) + break; + case 'linkgame/help/list': + console.log(data) + break; + default: + // $.log(JSON.stringify(data)) + break; + } + } else { + // $.log(JSON.stringify(data)) + } + } else { + // $.log("京东没有返回数据") + } + } + } catch (error) { + $.log(error) + } finally { + resolve(); + } + }) + }) +} +function getShopOpenCardInfo(body, venderId) { + let opt = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body=${encodeURIComponent(JSON.stringify(body))}&client=H5&clientVersion=9.2.0&uuid=88888`, + headers: { + Host: 'api.m.jd.com', + Accept: '*/*', + Connection: 'keep-alive', + Cookie: cookie, + 'User-Agent': `jdapp;iPhone;9.5.4;13.6;${$.UUID};network/wifi;ADID/${$.ADID};model/iPhone10,3;addressid/0;appBuild/167668;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1`, + 'Accept-Language': 'zh-cn', + Referer: `https://shopmember.m.jd.com/shopcard/?venderId=${venderId}}&channel=801&returnUrl=${encodeURIComponent($.activityUrl)}`, + 'Accept-Encoding': 'gzip, deflate, br' + } + } + return new Promise(resolve => { + $.get(opt, (err, resp, data) => { + try { + if (err) { + console.log(err) + } else { + res = JSON.parse(data) + if (res.success) { + if (res.result.interestsRuleList) { + $.openCardActivityId = res.result.interestsRuleList[0].interestsInfo.activityId; + } + } + } + } catch (error) { + console.log(error) + } finally { + resolve(); + } + }) + + }) +} +function bindWithVender(body, venderId) { + let opt = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body=${encodeURIComponent(JSON.stringify(body))}&client=H5&clientVersion=9.2.0&uuid=88888`, + headers: { + Host: 'api.m.jd.com', + Accept: '*/*', + Connection: 'keep-alive', + Cookie: cookie, + 'User-Agent': `jdapp;iPhone;9.5.4;13.6;${$.UUID};network/wifi;ADID/${$.ADID};model/iPhone10,3;addressid/0;appBuild/167668;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1`, + 'Accept-Language': 'zh-cn', + Referer: `https://shopmember.m.jd.com/shopcard/?venderId=${venderId}}&channel=401&returnUrl=${encodeURIComponent($.activityUrl)}`, + 'Accept-Encoding': 'gzip, deflate, br' + } + } + return new Promise(resolve => { + $.get(opt, (err, resp, data) => { + try { + if (err) { + console.log(err) + } else { + res = JSON.parse(data) + if (res.success) { + if (res.result.giftInfo && res.result.giftInfo.giftList) { + for (const vo of res.result.giftInfo.giftList) { + if (vo.prizeType === 4) { + $.log(`==>获得【${vo.quantity}】京豆`) + $.bean += vo.quantity + } + } + } + } + } + } catch (error) { + console.log(error) + } finally { + resolve(); + } + }) + + }) +} + +function getAuthorCodeList(url) { + return new Promise(resolve => { + const options = { + url: `${url}?${new Date()}`, "timeout": 10000, headers: { + "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1 Edg/87.0.4280.88" + } + }; + $.get(options, async (err, resp, data) => { + try { + if (err) { + $.log(err) + } else { + if (data) data = JSON.parse(data) + } + } catch (e) { + $.logErr(e, resp) + data = null; + } finally { + resolve(data); + } + }) + }) +} + +function taskUrl(function_id, body, isCommon) { + return { + url: isCommon ? `https://lzdz1-isv.isvjcloud.com/${function_id}` : `https://lzdz1-isv.isvjcloud.com/dingzhi/${function_id}`, + headers: { + Host: 'lzdz1-isv.isvjcloud.com', + Accept: 'application/json', + 'X-Requested-With': 'XMLHttpRequest', + 'Accept-Language': 'zh-cn', + 'Accept-Encoding': 'gzip, deflate, br', + 'Content-Type': 'application/x-www-form-urlencoded', + Origin: 'https://lzdz1-isv.isvjcloud.com', + 'User-Agent': `jdapp;iPhone;9.5.4;13.6;${$.UUID};network/wifi;ADID/${$.ADID};model/iPhone10,3;addressid/0;appBuild/167668;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1`, + Connection: 'keep-alive', + Referer: $.activityUrl, + Cookie: cookie + }, + body: body + + } +} + +function getMyPing() { + let opt = { + url: `https://lzdz1-isv.isvjcloud.com/customer/getMyPing`, + headers: { + Host: 'lzdz1-isv.isvjcloud.com', + Accept: 'application/json', + 'X-Requested-With': 'XMLHttpRequest', + 'Accept-Language': 'zh-cn', + 'Accept-Encoding': 'gzip, deflate, br', + 'Content-Type': 'application/x-www-form-urlencoded', + Origin: 'https://lzdz1-isv.isvjcloud.com', + 'User-Agent': `jdapp;iPhone;9.5.4;13.6;${$.UUID};network/wifi;ADID/${$.ADID};model/iPhone10,3;addressid/0;appBuild/167668;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1`, + Connection: 'keep-alive', + Referer: $.activityUrl, + Cookie: cookie, + }, + body: `userId=${$.activityShopId}&token=${$.token}&fromType=APP&riskType=1` + } + return new Promise(resolve => { + $.post(opt, (err, resp, data) => { + try { + if (err) { + $.log(err) + } else { + if (resp['headers']['set-cookie']) { + cookie = `${originCookie}` + if ($.isNode()) { + for (let sk of resp['headers']['set-cookie']) { + cookie = `${cookie}${sk.split(";")[0]};` + } + } else { + for (let ck of resp['headers']['Set-Cookie'].split(',')) { + cookie = `${cookie}${ck.split(";")[0]};` + } + } + } + if (resp['headers']['Set-Cookie']) { + cookie = `${originCookie}` + if ($.isNode()) { + for (let sk of resp['headers']['set-cookie']) { + cookie = `${cookie}${sk.split(";")[0]};` + } + } else { + for (let ck of resp['headers']['Set-Cookie'].split(',')) { + cookie = `${cookie}${ck.split(";")[0]};` + } + } + } + if (data) { + data = JSON.parse(data) + if (data.result) { + $.log(`你好:${data.data.nickname}`) + $.pin = data.data.nickname; + $.secretPin = data.data.secretPin; + cookie = `${cookie};AUTH_C_USER=${data.data.secretPin}` + } else { + $.log(data.errorMessage) + } + } else { + $.log("京东返回了空数据") + } + } + } catch (error) { + $.log(error) + } finally { + resolve(); + } + + }) + }) +} +function getFirstLZCK() { + return new Promise(resolve => { + $.get({ url: $.activityUrl }, (err, resp, data) => { + try { + if (err) { + console.log(err) + } else { + if (resp['headers']['set-cookie']) { + cookie = `${originCookie}` + if ($.isNode()) { + for (let sk of resp['headers']['set-cookie']) { + cookie = `${cookie}${sk.split(";")[0]};` + } + } else { + for (let ck of resp['headers']['Set-Cookie'].split(',')) { + cookie = `${cookie}${ck.split(";")[0]};` + } + } + } + if (resp['headers']['Set-Cookie']) { + cookie = `${originCookie}` + if ($.isNode()) { + for (let sk of resp['headers']['set-cookie']) { + cookie = `${cookie}${sk.split(";")[0]};` + } + } else { + for (let ck of resp['headers']['Set-Cookie'].split(',')) { + cookie = `${cookie}${ck.split(";")[0]};` + } + } + } + } + } catch (error) { + console.log(error) + } finally { + resolve(); + } + }) + }) +} +function getToken() { + let opt = { + url: `https://api.m.jd.com/client.action?functionId=isvObfuscator`, + headers: { + Host: 'api.m.jd.com', + 'Content-Type': 'application/x-www-form-urlencoded', + Accept: '*/*', + Connection: 'keep-alive', + Cookie: cookie, + 'User-Agent': 'JD4iPhone/167650 (iPhone; iOS 13.7; Scale/3.00)', + 'Accept-Language': 'zh-Hans-CN;q=1', + 'Accept-Encoding': 'gzip, deflate, br', + }, + body: `body=%7B%22url%22%3A%20%22https%3A//lzkj-isv.isvjcloud.com%22%2C%20%22id%22%3A%20%22%22%7D&uuid=hjudwgohxzVu96krv&client=apple&clientVersion=9.4.0&st=1620476162000&sv=111&sign=f9d1b7e3b943b6a136d54fe4f892af05` + } + return new Promise(resolve => { + $.post(opt, (err, resp, data) => { + try { + if (err) { + $.log(err) + } else { + if (data) { + data = JSON.parse(data); + if (data.code === "0") { + $.token = data.token + } + } else { + $.log("京东返回了空数据") + } + } + } catch (error) { + $.log(error) + } finally { + resolve(); + } + }) + }) +} +function random(min, max) { + + return Math.floor(Math.random() * (max - min)) + min; + +} +function getUUID(format = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', UpperCase = 0) { + return format.replace(/[xy]/g, function (c) { + var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8); + if (UpperCase) { + uuid = v.toString(36).toUpperCase(); + } else { + uuid = v.toString(36) + } + return uuid; + }); +} +function checkCookie() { + const options = { + url: "https://me-api.jd.com/user_new/info/GetJDUserInfoUnion", + headers: { + "Host": "me-api.jd.com", + "Accept": "*/*", + "Connection": "keep-alive", + "Cookie": cookie, + "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.2 Mobile/15E148 Safari/604.1", + "Accept-Language": "zh-cn", + "Referer": "https://home.m.jd.com/myJd/newhome.action?sceneval=2&ufc=&", + "Accept-Encoding": "gzip, deflate, br", + } + }; + return new Promise(resolve => { + $.get(options, (err, resp, data) => { + try { + if (err) { + $.logErr(err) + } else { + if (data) { + data = JSON.parse(data); + if (data.retcode === "1001") { + $.isLogin = false; //cookie过期 + return; + } + if (data.retcode === "0" && data.data.hasOwnProperty("userInfo")) { + $.nickName = data.data.userInfo.baseInfo.nickname; + } + } else { + $.log('京东返回了空数据'); + } + } + } catch (e) { + $.logErr(e) + } finally { + resolve(); + } + }) + }) +} +// prettier-ignore +!function (n) { "use strict"; function t(n, t) { var r = (65535 & n) + (65535 & t); return (n >> 16) + (t >> 16) + (r >> 16) << 16 | 65535 & r } function r(n, t) { return n << t | n >>> 32 - t } function e(n, e, o, u, c, f) { return t(r(t(t(e, n), t(u, f)), c), o) } function o(n, t, r, o, u, c, f) { return e(t & r | ~t & o, n, t, u, c, f) } function u(n, t, r, o, u, c, f) { return e(t & o | r & ~o, n, t, u, c, f) } function c(n, t, r, o, u, c, f) { return e(t ^ r ^ o, n, t, u, c, f) } function f(n, t, r, o, u, c, f) { return e(r ^ (t | ~o), n, t, u, c, f) } function i(n, r) { n[r >> 5] |= 128 << r % 32, n[14 + (r + 64 >>> 9 << 4)] = r; var e, i, a, d, h, l = 1732584193, g = -271733879, v = -1732584194, m = 271733878; for (e = 0; e < n.length; e += 16)i = l, a = g, d = v, h = m, g = f(g = f(g = f(g = f(g = c(g = c(g = c(g = c(g = u(g = u(g = u(g = u(g = o(g = o(g = o(g = o(g, v = o(v, m = o(m, l = o(l, g, v, m, n[e], 7, -680876936), g, v, n[e + 1], 12, -389564586), l, g, n[e + 2], 17, 606105819), m, l, n[e + 3], 22, -1044525330), v = o(v, m = o(m, l = o(l, g, v, m, n[e + 4], 7, -176418897), g, v, n[e + 5], 12, 1200080426), l, g, n[e + 6], 17, -1473231341), m, l, n[e + 7], 22, -45705983), v = o(v, m = o(m, l = o(l, g, v, m, n[e + 8], 7, 1770035416), g, v, n[e + 9], 12, -1958414417), l, g, n[e + 10], 17, -42063), m, l, n[e + 11], 22, -1990404162), v = o(v, m = o(m, l = o(l, g, v, m, n[e + 12], 7, 1804603682), g, v, n[e + 13], 12, -40341101), l, g, n[e + 14], 17, -1502002290), m, l, n[e + 15], 22, 1236535329), v = u(v, m = u(m, l = u(l, g, v, m, n[e + 1], 5, -165796510), g, v, n[e + 6], 9, -1069501632), l, g, n[e + 11], 14, 643717713), m, l, n[e], 20, -373897302), v = u(v, m = u(m, l = u(l, g, v, m, n[e + 5], 5, -701558691), g, v, n[e + 10], 9, 38016083), l, g, n[e + 15], 14, -660478335), m, l, n[e + 4], 20, -405537848), v = u(v, m = u(m, l = u(l, g, v, m, n[e + 9], 5, 568446438), g, v, n[e + 14], 9, -1019803690), l, g, n[e + 3], 14, -187363961), m, l, n[e + 8], 20, 1163531501), v = u(v, m = u(m, l = u(l, g, v, m, n[e + 13], 5, -1444681467), g, v, n[e + 2], 9, -51403784), l, g, n[e + 7], 14, 1735328473), m, l, n[e + 12], 20, -1926607734), v = c(v, m = c(m, l = c(l, g, v, m, n[e + 5], 4, -378558), g, v, n[e + 8], 11, -2022574463), l, g, n[e + 11], 16, 1839030562), m, l, n[e + 14], 23, -35309556), v = c(v, m = c(m, l = c(l, g, v, m, n[e + 1], 4, -1530992060), g, v, n[e + 4], 11, 1272893353), l, g, n[e + 7], 16, -155497632), m, l, n[e + 10], 23, -1094730640), v = c(v, m = c(m, l = c(l, g, v, m, n[e + 13], 4, 681279174), g, v, n[e], 11, -358537222), l, g, n[e + 3], 16, -722521979), m, l, n[e + 6], 23, 76029189), v = c(v, m = c(m, l = c(l, g, v, m, n[e + 9], 4, -640364487), g, v, n[e + 12], 11, -421815835), l, g, n[e + 15], 16, 530742520), m, l, n[e + 2], 23, -995338651), v = f(v, m = f(m, l = f(l, g, v, m, n[e], 6, -198630844), g, v, n[e + 7], 10, 1126891415), l, g, n[e + 14], 15, -1416354905), m, l, n[e + 5], 21, -57434055), v = f(v, m = f(m, l = f(l, g, v, m, n[e + 12], 6, 1700485571), g, v, n[e + 3], 10, -1894986606), l, g, n[e + 10], 15, -1051523), m, l, n[e + 1], 21, -2054922799), v = f(v, m = f(m, l = f(l, g, v, m, n[e + 8], 6, 1873313359), g, v, n[e + 15], 10, -30611744), l, g, n[e + 6], 15, -1560198380), m, l, n[e + 13], 21, 1309151649), v = f(v, m = f(m, l = f(l, g, v, m, n[e + 4], 6, -145523070), g, v, n[e + 11], 10, -1120210379), l, g, n[e + 2], 15, 718787259), m, l, n[e + 9], 21, -343485551), l = t(l, i), g = t(g, a), v = t(v, d), m = t(m, h); return [l, g, v, m] } function a(n) { var t, r = "", e = 32 * n.length; for (t = 0; t < e; t += 8)r += String.fromCharCode(n[t >> 5] >>> t % 32 & 255); return r } function d(n) { var t, r = []; for (r[(n.length >> 2) - 1] = void 0, t = 0; t < r.length; t += 1)r[t] = 0; var e = 8 * n.length; for (t = 0; t < e; t += 8)r[t >> 5] |= (255 & n.charCodeAt(t / 8)) << t % 32; return r } function h(n) { return a(i(d(n), 8 * n.length)) } function l(n, t) { var r, e, o = d(n), u = [], c = []; for (u[15] = c[15] = void 0, o.length > 16 && (o = i(o, 8 * n.length)), r = 0; r < 16; r += 1)u[r] = 909522486 ^ o[r], c[r] = 1549556828 ^ o[r]; return e = i(u.concat(d(t)), 512 + 8 * t.length), a(i(c.concat(e), 640)) } function g(n) { var t, r, e = ""; for (r = 0; r < n.length; r += 1)t = n.charCodeAt(r), e += "0123456789abcdef".charAt(t >>> 4 & 15) + "0123456789abcdef".charAt(15 & t); return e } function v(n) { return unescape(encodeURIComponent(n)) } function m(n) { return h(v(n)) } function p(n) { return g(m(n)) } function s(n, t) { return l(v(n), v(t)) } function C(n, t) { return g(s(n, t)) } function A(n, t, r) { return t ? r ? s(t, n) : C(t, n) : r ? m(n) : p(n) } $.md5 = A }(this); +function Env(t, e) { "undefined" != typeof process && JSON.stringify(process.env).indexOf("GITHUB") > -1 && process.exit(0); class s { constructor(t) { this.env = t } send(t, e = "GET") { t = "string" == typeof t ? { url: t } : t; let s = this.get; return "POST" === e && (s = this.post), new Promise((e, i) => { s.call(this, t, (t, s, r) => { t ? i(t) : e(s) }) }) } get(t) { return this.send.call(this.env, t) } post(t) { return this.send.call(this.env, t, "POST") } } return new class { constructor(t, e) { this.name = t, this.http = new s(this), this.data = null, this.dataFile = "box.dat", this.logs = [], this.isMute = !1, this.isNeedRewrite = !1, this.logSeparator = "\n", this.startTime = (new Date).getTime(), Object.assign(this, e), this.log("", `🔔${this.name}, 开始!`) } isNode() { return "undefined" != typeof module && !!module.exports } isQuanX() { return "undefined" != typeof $task } isSurge() { return "undefined" != typeof $httpClient && "undefined" == typeof $loon } isLoon() { return "undefined" != typeof $loon } toObj(t, e = null) { try { return JSON.parse(t) } catch { return e } } toStr(t, e = null) { try { return JSON.stringify(t) } catch { return e } } getjson(t, e) { let s = e; const i = this.getdata(t); if (i) try { s = JSON.parse(this.getdata(t)) } catch { } return s } setjson(t, e) { try { return this.setdata(JSON.stringify(t), e) } catch { return !1 } } getScript(t) { return new Promise(e => { this.get({ url: t }, (t, s, i) => e(i)) }) } runScript(t, e) { return new Promise(s => { let i = this.getdata("@chavy_boxjs_userCfgs.httpapi"); i = i ? i.replace(/\n/g, "").trim() : i; let r = this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout"); r = r ? 1 * r : 20, r = e && e.timeout ? e.timeout : r; const [o, h] = i.split("@"), n = { url: `http://${h}/v1/scripting/evaluate`, body: { script_text: t, mock_type: "cron", timeout: r }, headers: { "X-Key": o, Accept: "*/*" } }; this.post(n, (t, e, i) => s(i)) }).catch(t => this.logErr(t)) } loaddata() { if (!this.isNode()) return {}; { this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path"); const t = this.path.resolve(this.dataFile), e = this.path.resolve(process.cwd(), this.dataFile), s = this.fs.existsSync(t), i = !s && this.fs.existsSync(e); if (!s && !i) return {}; { const i = s ? t : e; try { return JSON.parse(this.fs.readFileSync(i)) } catch (t) { return {} } } } } writedata() { if (this.isNode()) { this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path"); const t = this.path.resolve(this.dataFile), e = this.path.resolve(process.cwd(), this.dataFile), s = this.fs.existsSync(t), i = !s && this.fs.existsSync(e), r = JSON.stringify(this.data); s ? this.fs.writeFileSync(t, r) : i ? this.fs.writeFileSync(e, r) : this.fs.writeFileSync(t, r) } } lodash_get(t, e, s) { const i = e.replace(/\[(\d+)\]/g, ".$1").split("."); let r = t; for (const t of i) if (r = Object(r)[t], void 0 === r) return s; return r } lodash_set(t, e, s) { return Object(t) !== t ? t : (Array.isArray(e) || (e = e.toString().match(/[^.[\]]+/g) || []), e.slice(0, -1).reduce((t, s, i) => Object(t[s]) === t[s] ? t[s] : t[s] = Math.abs(e[i + 1]) >> 0 == +e[i + 1] ? [] : {}, t)[e[e.length - 1]] = s, t) } getdata(t) { let e = this.getval(t); if (/^@/.test(t)) { const [, s, i] = /^@(.*?)\.(.*?)$/.exec(t), r = s ? this.getval(s) : ""; if (r) try { const t = JSON.parse(r); e = t ? this.lodash_get(t, i, "") : e } catch (t) { e = "" } } return e } setdata(t, e) { let s = !1; if (/^@/.test(e)) { const [, i, r] = /^@(.*?)\.(.*?)$/.exec(e), o = this.getval(i), h = i ? "null" === o ? null : o || "{}" : "{}"; try { const e = JSON.parse(h); this.lodash_set(e, r, t), s = this.setval(JSON.stringify(e), i) } catch (e) { const o = {}; this.lodash_set(o, r, t), s = this.setval(JSON.stringify(o), i) } } else s = this.setval(t, e); return s } getval(t) { return this.isSurge() || this.isLoon() ? $persistentStore.read(t) : this.isQuanX() ? $prefs.valueForKey(t) : this.isNode() ? (this.data = this.loaddata(), this.data[t]) : this.data && this.data[t] || null } setval(t, e) { return this.isSurge() || this.isLoon() ? $persistentStore.write(t, e) : this.isQuanX() ? $prefs.setValueForKey(t, e) : this.isNode() ? (this.data = this.loaddata(), this.data[e] = t, this.writedata(), !0) : this.data && this.data[e] || null } initGotEnv(t) { this.got = this.got ? this.got : require("got"), this.cktough = this.cktough ? this.cktough : require("tough-cookie"), this.ckjar = this.ckjar ? this.ckjar : new this.cktough.CookieJar, t && (t.headers = t.headers ? t.headers : {}, void 0 === t.headers.Cookie && void 0 === t.cookieJar && (t.cookieJar = this.ckjar)) } get(t, e = (() => { })) { t.headers && (delete t.headers["Content-Type"], delete t.headers["Content-Length"]), this.isSurge() || this.isLoon() ? (this.isSurge() && this.isNeedRewrite && (t.headers = t.headers || {}, Object.assign(t.headers, { "X-Surge-Skip-Scripting": !1 })), $httpClient.get(t, (t, s, i) => { !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i) })) : this.isQuanX() ? (this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, { hints: !1 })), $task.fetch(t).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => e(t))) : this.isNode() && (this.initGotEnv(t), this.got(t).on("redirect", (t, e) => { try { if (t.headers["set-cookie"]) { const s = t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString(); s && this.ckjar.setCookieSync(s, null), e.cookieJar = this.ckjar } } catch (t) { this.logErr(t) } }).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => { const { message: s, response: i } = t; e(s, i, i && i.body) })) } post(t, e = (() => { })) { if (t.body && t.headers && !t.headers["Content-Type"] && (t.headers["Content-Type"] = "application/x-www-form-urlencoded"), t.headers && delete t.headers["Content-Length"], this.isSurge() || this.isLoon()) this.isSurge() && this.isNeedRewrite && (t.headers = t.headers || {}, Object.assign(t.headers, { "X-Surge-Skip-Scripting": !1 })), $httpClient.post(t, (t, s, i) => { !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i) }); else if (this.isQuanX()) t.method = "POST", this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, { hints: !1 })), $task.fetch(t).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => e(t)); else if (this.isNode()) { this.initGotEnv(t); const { url: s, ...i } = t; this.got.post(s, i).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => { const { message: s, response: i } = t; e(s, i, i && i.body) }) } } time(t, e = null) { const s = e ? new Date(e) : new Date; let i = { "M+": s.getMonth() + 1, "d+": s.getDate(), "H+": s.getHours(), "m+": s.getMinutes(), "s+": s.getSeconds(), "q+": Math.floor((s.getMonth() + 3) / 3), S: s.getMilliseconds() }; /(y+)/.test(t) && (t = t.replace(RegExp.$1, (s.getFullYear() + "").substr(4 - RegExp.$1.length))); for (let e in i) new RegExp("(" + e + ")").test(t) && (t = t.replace(RegExp.$1, 1 == RegExp.$1.length ? i[e] : ("00" + i[e]).substr(("" + i[e]).length))); return t } msg(e = t, s = "", i = "", r) { const o = t => { if (!t) return t; if ("string" == typeof t) return this.isLoon() ? t : this.isQuanX() ? { "open-url": t } : this.isSurge() ? { url: t } : void 0; if ("object" == typeof t) { if (this.isLoon()) { let e = t.openUrl || t.url || t["open-url"], s = t.mediaUrl || t["media-url"]; return { openUrl: e, mediaUrl: s } } if (this.isQuanX()) { let e = t["open-url"] || t.url || t.openUrl, s = t["media-url"] || t.mediaUrl; return { "open-url": e, "media-url": s } } if (this.isSurge()) { let e = t.url || t.openUrl || t["open-url"]; return { url: e } } } }; if (this.isMute || (this.isSurge() || this.isLoon() ? $notification.post(e, s, i, o(r)) : this.isQuanX() && $notify(e, s, i, o(r))), !this.isMuteLog) { let t = ["", "==============📣系统通知📣=============="]; t.push(e), s && t.push(s), i && t.push(i), console.log(t.join("\n")), this.logs = this.logs.concat(t) } } log(...t) { t.length > 0 && (this.logs = [...this.logs, ...t]), console.log(t.join(this.logSeparator)) } logErr(t, e) { const s = !this.isSurge() && !this.isQuanX() && !this.isLoon(); s ? this.log("", `❗️${this.name}, 错误!`, t.stack) : this.log("", `❗️${this.name}, 错误!`, t) } wait(t) { return new Promise(e => setTimeout(e, t)) } done(t = {}) { const e = (new Date).getTime(), s = (e - this.startTime) / 1e3; this.log("", `🔔${this.name}, 结束! 🕛 ${s} 秒`), this.log(), (this.isSurge() || this.isQuanX() || this.isLoon()) && $done(t) } }(t, e) } diff --git a/activity/jd_opencard93.js b/activity/jd_opencard93.js new file mode 100644 index 0000000..fe9f0ed --- /dev/null +++ b/activity/jd_opencard93.js @@ -0,0 +1,809 @@ +/* +1.6~1.31 会员狂欢日 [jd_opencard93.js] +新增开卡脚本,一次性脚本 + +1.邀请一人20豆 被邀请10豆 +2.开18张卡 成功开1张 有机会获得20豆 +3.关注10京豆 +4.逛会场5京豆 +5.抽奖 + + +第一个账号助力作者 其他依次助力CK1 +第一个CK失效会退出脚本 + +———————————————— +入口:[ 1.6~1.31 会员狂欢日 (https://lzdz1-isv.isvjcloud.com/dingzhi/majorsuit/memberday/activity?activityId=dz2112100022468201&shareUuid=b969c736154445c8b0fa91402dad4408)] + +请求太频繁会被黑ip +过10分钟再执行 + +cron:30 1,16 6-31 1 * +============Quantumultx=============== +[task_local] +#1.6~1.31 会员狂欢日 +30 1,16 6-31 1 * jd_opencard93.js, tag=1.6~1.31 会员狂欢日, enabled=true + +*/ + +const $ = new Env('1.6~1.31 会员狂欢日'); +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const notify = $.isNode() ? require('./sendNotify') : ''; +//IOS等用户直接用NobyDa的jd cookie + +let cookiesArr = [], + cookie = ''; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} + +allMessage = "" +message = "" +$.hotFlag = false +$.outFlag = false +$.activityEnd = false +let lz_jdpin_token_cookie ='' +let activityCookie ='' +!(async () => { + + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', { + "open-url": "https://bean.m.jd.com/" + }); + return; + } + $.activityId = "dz2112100022468201" + $.shareUuid = "b969c736154445c8b0fa91402dad4408" + console.log(`入口:\nhttps://lzdz1-isv.isvjcloud.com/dingzhi/majorsuit/memberday/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}`) + + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i]; + if (cookie) { + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + message = "" + $.bean = 0 + $.hotFlag = false + $.nickName = ''; + console.log(`\n\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + await getUA() + await run(); + if(i == 0 && !$.actorUuid) break + if($.outFlag || $.activityEnd) break + } + } + if($.outFlag) { + let msg = '此ip已被限制,请过10分钟后再执行脚本' + $.msg($.name, ``, `${msg}`); + if ($.isNode()) await notify.sendNotify(`${$.name}`, `${msg}`); + } +})() + .catch((e) => $.logErr(e)) + .finally(() => $.done()) + + +async function run() { + try { + $.hasEnd = true + $.endTime = 0 + lz_jdpin_token_cookie = '' + $.Token = '' + $.Pin = '' + let flag = false + await takePostRequest('isvObfuscator'); + if($.Token == ''){ + console.log('获取[token]失败!') + return + } + await getCk() + if (activityCookie == '') { + console.log(`获取cookie失败`); return; + } + if($.activityEnd === true){ + console.log('活动结束') + return + } + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + await takePostRequest('getSimpleActInfoVo'); + await takePostRequest('getMyPing'); + if(!$.Pin){ + console.log('获取[Pin]失败!') + return + } + await takePostRequest('accessLogWithAD'); + await takePostRequest('getUserInfo'); + await takePostRequest('activityContent'); + if($.hotFlag) return + if(!$.actorUuid){ + console.log('获取不到[actorUuid]退出执行,请重新执行') + return + } + if($.hasEnd === true || Date.now() > $.endTime){ + $.activityEnd = true + console.log('活动结束') + return + } + await takePostRequest('drawContent'); + await $.wait(1000) + $.openList = [] + $.allOpenCard = false + await takePostRequest('checkOpenCard'); + // console.log($.actorUuid) + // return + if($.allOpenCard == false){ + console.log('开卡任务') + for(o of $.openList){ + $.openCard = false + if(o.openStatus == false){ + flag = true + $.joinVenderId = o.venderId + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + await joinShop() + await $.wait(parseInt(Math.random() * 1000 + 1000, 10)) + await takePostRequest('activityContent'); + await takePostRequest('drawContent'); + await takePostRequest('checkOpenCard'); + await $.wait(parseInt(Math.random() * 3000 + 2000, 10)) + } + } + }else{ + console.log('已全部开卡') + } + + $.log("关注: " + $.followShop) + if(!$.followShop && !$.outFlag){ + flag = true + await takePostRequest('followShop'); + await $.wait(parseInt(Math.random() * 2000 + 2000, 10)) + } + $.log("逛会场: " + $.toMainActive) + if(!$.toMainActive && !$.outFlag){ + flag = true + await takePostRequest('toMainActive'); + await $.wait(parseInt(Math.random() * 2000 + 2000, 10)) + } + if(flag){ + await takePostRequest('activityContent'); + } + $.runFalag = true + let count = parseInt($.score/1) + console.log(`抽奖次数为:${count}`) + for(m=1;count--;m++){ + console.log(`第${m}次抽奖`) + await takePostRequest('抽奖'); + if($.runFalag == false) break + if(Number(count) <= 0) break + if(m >= 10){ + console.log("抽奖太多次,多余的次数请再执行脚本") + break + } + await $.wait(parseInt(Math.random() * 2000 + 2000, 10)) + } + + await $.wait(parseInt(Math.random() * 1000 + 2000, 10)) + await takePostRequest('getDrawRecordHasCoupon'); + await takePostRequest('getShareRecord'); + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + console.log($.actorUuid) + console.log(`当前助力:${$.shareUuid}`) + if($.index == 1){ + $.shareUuid = $.actorUuid + console.log(`后面的号都会助力:${$.shareUuid}`) + } + await $.wait(parseInt(Math.random() * 1000 + 5000, 10)) + if(flag) await $.wait(parseInt(Math.random() * 1000 + 10000, 10)) + if($.index % 3 == 0) console.log('休息1分钟,别被黑ip了\n可持续发展') + if($.index % 3 == 0) await $.wait(parseInt(Math.random() * 5000 + 60000, 10)) + } catch (e) { + console.log(e) + } +} + +async function takePostRequest(type) { + if($.outFlag) return + let domain = 'https://lzdz1-isv.isvjcloud.com'; + let body = ``; + let method = 'POST' + let admJson = '' + switch (type) { + case 'isvObfuscator': + url = `https://api.m.jd.com/client.action?functionId=isvObfuscator`; + body = `body=%7B%22url%22%3A%22https%3A//lzdz1-isv.isvjcloud.com%22%2C%22id%22%3A%22%22%7D&uuid=7088d9018515b8cb0c88ace6e5479762af3e88f3&client=apple&clientVersion=10.1.4&st=1634343624086&sv=120&sign=8b9cea22c3a0d77026abda5d37d2b7e3`; + break; + case 'getSimpleActInfoVo': + url = `${domain}/dz/common/getSimpleActInfoVo`; + body = `activityId=${$.activityId}`; + break; + case 'getMyPing': + url = `${domain}/customer/getMyPing`; + body = `userId=${$.shopId || $.venderId || ''}&token=${$.Token}&fromType=APP`; + break; + case 'accessLogWithAD': + url = `${domain}/common/accessLogWithAD`; + let pageurl = `${domain}/drawCenter/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}` + body = `venderId=${$.shopId || $.venderId || ''}&code=99&pin=${encodeURIComponent($.Pin)}&activityId=${$.activityId}&pageUrl=${encodeURIComponent(pageurl)}&subType=app&adSource=` + break; + case 'getUserInfo': + url = `${domain}/wxActionCommon/getUserInfo`; + body = `pin=${encodeURIComponent($.Pin)}`; + break; + case 'activityContent': + url = `${domain}/dingzhi/majorsuit/memberday/activityContent`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&pinImg=${encodeURIComponent($.attrTouXiang)}&nick=${encodeURIComponent($.nickname)}&cjyxPin=&cjhyPin=&shareUuid=${$.shareUuid}` + break; + case 'drawContent': + url = `${domain}/dingzhi/taskact/common/drawContent`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case 'checkOpenCard': + url = `${domain}/dingzhi/majorsuit/memberday/initOpenCard`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&shareUuid=${$.shareUuid}` + break; + case 'info': + url = `${domain}/dingzhi/linkgame/task/opencard/info`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case 'startDraw': + url = `${domain}/joint/order/draw`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&drawType=1` + break; + case 'followShop': + url = `${domain}/dingzhi/majorsuit/memberday/saveTask`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&taskType=23&taskValue=1&shareUuid=${$.shareUuid}` + break; + case 'sign': + case 'addCart': + case 'browseGoods': + url = `${domain}/dingzhi/linkgame/${type}`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + if(type == 'browseGoods') body += `&value=${$.visitSkuValue}` + break; + case '邀请': + case '助力': + if(type == '助力'){ + url = `${domain}/dingzhi/linkgame/assist`; + }else{ + url = `${domain}/dingzhi/linkgame/assist/status`; + } + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&shareUuid=${$.shareUuid}` + break; + case 'viewVideo': + case 'visitSku': + case 'toShop': + case 'addSku': + case 'toMainActive': + url = `${domain}/dingzhi/majorsuit/memberday/saveTask`; + let taskType = '' + let taskValue = '' + if(type == 'viewVideo'){ + taskType = 31 + taskValue = 31 + }else if(type == 'visitSku'){ + taskType = 5 + taskValue = $.visitSkuValue || 5 + }else if(type == 'toShop'){ + taskType = 14 + taskValue = $.toShopValue || 14 + }else if(type == 'addSku'){ + taskType = 2 + taskValue = $.addSkuValue || 2 + }else if(type == 'toMainActive'){ + taskType = 12 + taskValue = 3 + } + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&taskType=${taskType}&taskValue=${taskValue}&shareUuid=${$.shareUuid}` + break; + case 'getDrawRecordHasCoupon': + url = `${domain}/dingzhi/taskact/common/getDrawRecordHasCoupon`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case 'getShareRecord': + url = `${domain}/dingzhi/taskact/common/getShareRecord`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case 'getRule': + url = `${domain}/dingzhi/majorsuit/memberday/getRule`; + body = `activityId=${$.activityId}` + break; + case '抽奖': + url = `${domain}/dingzhi/majorsuit/memberday/draw`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + default: + console.log(`错误${type}`); + } + let myRequest = getPostRequest(url, body, method); + return new Promise(async resolve => { + $.post(myRequest, (err, resp, data) => { + try { + setActivityCookie(resp) + if (err) { + if(resp && typeof resp.statusCode != 'undefined'){ + if(resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + } + console.log(`${$.toStr(err,err)}`) + console.log(`${type} API请求失败,请检查网路重试`) + } else { + dealReturn(type, data); + } + } catch (e) { + console.log(e, resp) + } finally { + resolve(); + } + }) + }) + } + +async function dealReturn(type, data) { + let res = '' + try { + if(type != 'accessLogWithAD' || type != 'drawContent'){ + if(data){ + res = JSON.parse(data); + } + } + } catch (e) { + console.log(`${type} 执行任务异常`); + console.log(data); + $.runFalag = false; + } + try { + switch (type) { + case 'isvObfuscator': + if(typeof res == 'object'){ + if(res.errcode == 0){ + if(typeof res.token != 'undefined') $.Token = res.token + }else if(res.message){ + console.log(`isvObfuscator ${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + break; + case 'getSimpleActInfoVo': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(typeof res.data.shopId != 'undefined') $.shopId = res.data.shopId + if(typeof res.data.venderId != 'undefined') $.venderId = res.data.venderId + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getMyPing': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(res.data && typeof res.data.secretPin != 'undefined') $.Pin = res.data.secretPin + if(res.data && typeof res.data.nickname != 'undefined') $.nickname = res.data.nickname + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getUserInfo': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(res.data && typeof res.data.yunMidImageUrl != 'undefined') $.attrTouXiang = res.data.yunMidImageUrl || "https://img10.360buyimg.com/imgzone/jfs/t1/7020/27/13511/6142/5c5138d8E4df2e764/5a1216a3a5043c5d.png" + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'activityContent': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + $.endTime = res.data.endTime || (res.data.activityVo && res.data.activityVo.endTime) || res.data.activity.endTime || 0 + $.hasEnd = res.data.isEnd || false + $.drawCount = res.data.drawCount || (res.data.actor && res.data.actor.drawCount) || 0 + $.point = res.data.point || (res.data.actor && res.data.actor.point) || 0 + $.score = res.data.score || (res.data.actor && res.data.actor.score) || 0 + $.actorUuid = res.data.actorUuid || (res.data.actor && res.data.actor.actorUuid) || '' + $.followShop = res.data.followShop || (res.data.actor && res.data.actor.followShopStatus) || '' + $.toMainActive = res.data.toMainActive || '' + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'info': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + $.addCart = res.data.addCart || false + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'checkOpenCard': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + let cardList1 = res.data.cardList1 || [] + let cardList2 = res.data.cardList2 || [] + let cardList = res.data.cardList || [] + let openInfo = res.data.openInfo || [] + let openCardList = res.data.openCardList || [] + $.openList = [...cardList,...cardList1,...cardList2,...openCardList,...openInfo] + $.allOpenCard = res.data.allOpenCard || res.data.isOpenCardStatus || false + $.openCardScore1 = res.data.score1 || 0 + $.openCardScore2 = res.data.score2 || 0 + $.drawScore = res.data.drawScore || 0 + if(res.data.beans) console.log(`获得:${res.data.beans}豆`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'startDraw': + case 'followShop': + case 'viewVideo': + case 'visitSku': + case 'toShop': + case 'addSku': + case 'sign': + case 'addCart': + case 'browseGoods': + case 'toMainActive': + case '抽奖': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(typeof res.data == 'object'){ + let msg = '' + let title = '抽奖' + if(res.data.addBeanNum || res.data.taskbeanNum){ + msg = `${res.data.addBeanNum || res.data.taskbeanNum}京豆` + } + if(res.data.addPoint){ + msg += ` ${res.data.addPoint}游戏机会` + } + if(type == 'followShop'){ + title = '关注' + if(res.data.beanNumMember && res.data.assistSendStatus){ + msg += ` 额外获得:${res.data.beanNumMember}京豆` + } + }else if(type == 'addSku' || type == 'addCart'){ + title = '加购' + }else if(type == 'viewVideo'){ + title = '热门文章' + }else if(type == 'toShop'){ + title = '浏览店铺' + }else if(type == 'visitSku' || type == 'browseGoods'){ + title = '浏览商品' + }else if(type == 'sign'){ + title = '签到' + }else if(type == 'toMainActive'){ + title = '逛会场' + }else{ + msg = res.data.drawOk == true && (res.data.drawInfoType == 6 && res.data.name || '') || res.data.wdsrvo.drawOk == true && (res.data.wdsrvo.drawInfoType == 6 && res.data.wdsrvo.name || '') || '空气💨' + } + if(!msg){ + msg = '空气💨' + } + console.log(`${title}获得:${msg || data}`) + }else{ + console.log(`${type} ${data}`) + } + }else if(res.errorMessage){ + $.runFalag = false; + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getDrawRecordHasCoupon': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + console.log(`我的奖品:`) + let num = 0 + let value = 0 + let typeArr = { + "dayShareBeans":"邀请", + "dayBeSharedBeans":"被邀请", + "openCardBeans":"开卡", + "saveTaskBeans23":"关注", + "saveTaskBeans12":"逛会场", + } + for(let i in res.data){ + let item = res.data[i] + if(item.drawId == 'dayShareBeans'){ + num++ + value = item.infoName.replace('京豆','') + }else{ + console.log(`${item.infoType != 10 && item.drawId && (typeArr[item.drawId] || item.drawId)+':' || item.value && item.value +':' || ''}${item.infoName}`) + } + } + if(num > 0) console.log(`邀请好友(${num}):${num*parseInt(value, 10) || 30}京豆`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getShareRecord': + if(typeof res == 'object'){ + if(res.result && res.result === true && res.data){ + $.ShareCount = res.data.length + $.log(`=========== 你邀请了:${res.data.length}个`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case '邀请': + case '助力': + if(typeof res == 'object'){ + if(res.data.status == 200){ + if(type == '助力'){ + console.log('助力成功') + }else{ + $.yaoqing = true + } + }else if(res.data.status == 105){ + console.log('已经助力过') + }else if(res.data.status == 104){ + console.log('已经助力其他人') + }else if(res.data.status == 101){ + // console.log('已经助力过') + }else{ + console.log(data) + } + }else{ + console.log(`${type} ${data}`) + } + + case 'accessLogWithAD': + case 'drawContent': + break; + default: + console.log(`${type}-> ${data}`); + } + if(typeof res == 'object'){ + if(res.errorMessage){ + if(res.errorMessage.indexOf('火爆') >-1 ){ + $.hotFlag = true + } + } + } + } catch (e) { + console.log(e) + } +} + +function getPostRequest(url, body, method="POST") { + let headers = { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Content-Type": "application/x-www-form-urlencoded", + "Cookie": cookie, + "User-Agent": $.UA, + "X-Requested-With": "XMLHttpRequest" + } + if(url.indexOf('https://lzdz1-isv.isvjcloud.com') > -1){ + headers["Referer"] = `https://lzdz1-isv.isvjcloud.com/dingzhi/majorsuit/memberday/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}` + headers["Cookie"] = `${lz_jdpin_token_cookie && lz_jdpin_token_cookie || ''}${$.Pin && "AUTH_C_USER=" + $.Pin + ";" || ""}${activityCookie}` + } + // console.log(headers) + // console.log(headers.Cookie) + return {url: url, method: method, headers: headers, body: body, timeout:30000}; +} + +function getCk() { + return new Promise(resolve => { + let get = { + url:`https://lzdz1-isv.isvjcloud.com/dingzhi/majorsuit/memberday/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}`, + followRedirect:false, + headers: { + "User-Agent": $.UA, + }, + timeout:30000 + } + $.get(get, async(err, resp, data) => { + try { + if (err) { + if(resp && typeof resp.statusCode != 'undefined'){ + if(resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + } + console.log(`${$.toStr(err)}`) + console.log(`${$.name} cookie API请求失败,请检查网路重试`) + } else { + let end = data.match(/(活动已经结束)/) && data.match(/(活动已经结束)/)[1] || '' + if(end){ + $.activityEnd = true + console.log('活动已结束') + } + setActivityCookie(resp) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function setActivityCookie(resp){ + let LZ_TOKEN_KEY = '' + let LZ_TOKEN_VALUE = '' + let lz_jdpin_token = '' + let setcookies = resp && resp['headers'] && (resp['headers']['set-cookie'] || resp['headers']['Set-Cookie'] || '') || '' + let setcookie = '' + if(setcookies){ + if(typeof setcookies != 'object'){ + setcookie = setcookies.split(',') + }else setcookie = setcookies + for (let ck of setcookie) { + let name = ck.split(";")[0].trim() + if(name.split("=")[1]){ + // console.log(name.replace(/ /g,'')) + if(name.indexOf('LZ_TOKEN_KEY=')>-1) LZ_TOKEN_KEY = name.replace(/ /g,'')+';' + if(name.indexOf('LZ_TOKEN_VALUE=')>-1) LZ_TOKEN_VALUE = name.replace(/ /g,'')+';' + if(name.indexOf('lz_jdpin_token=')>-1) lz_jdpin_token = ''+name.replace(/ /g,'')+';' + } + } + } + if(LZ_TOKEN_KEY && LZ_TOKEN_VALUE) activityCookie = `${LZ_TOKEN_KEY} ${LZ_TOKEN_VALUE}` + if(lz_jdpin_token) lz_jdpin_token_cookie = lz_jdpin_token +} + +async function getUA(){ + $.UA = `jdapp;iPhone;10.1.4;13.1.2;${randomString(40)};network/wifi;model/iPhone8,1;addressid/2308460611;appBuild/167814;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_1_2 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 joinShop() { + if(!$.joinVenderId) return + return new Promise(async resolve => { + $.shopactivityId = '' + await $.wait(1000) + await getshopactivityId() + let activityId = `` + if($.shopactivityId) activityId = `,"activityId":${$.shopactivityId}` + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body={"venderId":"${$.joinVenderId}","shopId":"${$.joinVenderId}","bindByVerifyCodeFlag":1,"registerExtend":{},"writeChildFlag":0${activityId},"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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + // console.log(data) + let res = $.toObj(data); + if(typeof res == 'object'){ + if(res.success === true){ + console.log(res.message) + if(res.result && res.result.giftInfo){ + for(let i of res.result.giftInfo.giftList){ + console.log(`入会获得:${i.discountString}${i.prizeName}${i.secondLineDesc}`) + } + } + }else if(typeof res == 'object' && res.message){ + console.log(`${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function getshopactivityId() { + return new Promise(resolve => { + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body=%7B%22venderId%22%3A%22${$.joinVenderId}%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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + let res = $.toObj(data); + if(res.success == true){ + // console.log($.toStr(res.result)) + console.log(`入会:${res.result.shopMemberCardInfo.venderCardName || ''}`) + $.shopactivityId = res.result.interestsRuleList && res.result.interestsRuleList[0] && res.result.interestsRuleList[0].interestsInfo && res.result.interestsRuleList[0].interestsInfo.activityId || '' + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} + + +// 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)} + diff --git a/activity/jd_opencard96.js b/activity/jd_opencard96.js new file mode 100644 index 0000000..8600859 --- /dev/null +++ b/activity/jd_opencard96.js @@ -0,0 +1,749 @@ +/* +1.1~2.10 大牌集结 入会有礼 + +1.开2组卡 共10张卡 每组50豆 + 已经入会的也有50豆 + +———————————————— +入口:[ 1.1~2.10 大牌集结 入会有礼 (https://lzdz1-isv.isvjcloud.com/dingzhi/big/openCard/activity?activityId=dz2112100001550202)] + +请求太频繁会被黑ip +过10分钟再执行 + +cron:30 16 1-31/5,31 1,2 * +============Quantumultx=============== +[task_local] +#1.1~2.10 大牌集结 入会有礼 +30 16 1-31/5,31 1,2 * jd_opencard96.js, tag=1.1~2.10 大牌集结 入会有礼, enabled=true + +*/ + +const $ = new Env('1.1~2.10 大牌集结 入会有礼'); +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const notify = $.isNode() ? require('./sendNotify') : ''; +//IOS等用户直接用NobyDa的jd cookie +let cookiesArr = [], + cookie = ''; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} +allMessage = "" +message = "" +$.hotFlag = false +$.outFlag = false +$.activityEnd = false +let lz_jdpin_token_cookie ='' +let activityCookie ='' +!(async () => { + console.log('一次性脚本,运行后请禁用!') + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', { + "open-url": "https://bean.m.jd.com/" + }); + return; + } + $.activityId = "dz2112100001550202" + $.shareUuid = "" + console.log(`入口:\nhttps://lzdz1-isv.isvjcloud.com/dingzhi/big/openCard/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}`) + + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i]; + if (cookie) { + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + message = "" + $.bean = 0 + $.hotFlag = false + $.nickName = ''; + console.log(`\n\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + await getUA() + await run(); + if($.outFlag || $.activityEnd) break + } + } + if($.outFlag) { + let msg = '此ip已被限制,请过10分钟后再执行脚本' + $.msg($.name, ``, `${msg}`); + if ($.isNode()) await notify.sendNotify(`${$.name}`, `${msg}`); + } +})() + .catch((e) => $.logErr(e)) + .finally(() => $.done()) + + +async function run() { + try { + $.hasEnd = true + $.endTime = 0 + lz_jdpin_token_cookie = '' + $.Token = '' + $.Pin = '' + let flag = false + await takePostRequest('isvObfuscator'); + if($.Token == ''){ + console.log('获取[token]失败!') + return + } + await getCk() + if (activityCookie == '') { + console.log(`获取cookie失败`); return; + } + if($.activityEnd === true){ + console.log('活动结束') + return + } + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + await takePostRequest('getSimpleActInfoVo'); + await takePostRequest('getMyPing'); + if(!$.Pin){ + console.log('获取[Pin]失败!') + return + } + await takePostRequest('accessLogWithAD'); + await takePostRequest('getUserInfo'); + $.allOpenCard = false + $.openList = [] + await takePostRequest('activityContent'); + if($.hotFlag) return + if(!$.actorUuid){ + console.log('获取不到[actorUuid]退出执行,请重新执行') + return + } + if($.hasEnd === true || Date.now() > $.endTime){ + $.activityEnd = true + console.log('活动结束') + return + } + await $.wait(1000) + if($.allOpenCard == false){ + console.log('开卡任务') + for(o of $.openList){ + $.openCard = false + if(o.status == 0){ + flag = true + $.joinVenderId = o.value + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + await joinShop() + await $.wait(parseInt(Math.random() * 1000 + 1000, 10)) + await takePostRequest('activityContent'); + await $.wait(parseInt(Math.random() * 3000 + 2000, 10)) + } + } + }else{ + console.log('已全部开卡') + } + + await takePostRequest('getDrawRecordHasCoupon'); + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + await $.wait(parseInt(Math.random() * 1000 + 5000, 10)) + if(flag) await $.wait(parseInt(Math.random() * 1000 + 10000, 10)) + if($.index % 3 == 0) console.log('休息1分钟,别被黑ip了\n可持续发展') + if($.index % 3 == 0) await $.wait(parseInt(Math.random() * 5000 + 60000, 10)) + } catch (e) { + console.log(e) + } +} + +async function takePostRequest(type) { + if($.outFlag) return + let domain = 'https://lzdz1-isv.isvjcloud.com'; + let body = ``; + let method = 'POST' + let admJson = '' + switch (type) { + case 'isvObfuscator': + url = `https://api.m.jd.com/client.action?functionId=isvObfuscator`; + body = `body=%7B%22url%22%3A%22https%3A//lzdz1-isv.isvjcloud.com%22%2C%22id%22%3A%22%22%7D&uuid=7088d9018515b8cb0c88ace6e5479762af3e88f3&client=apple&clientVersion=10.1.4&st=1634343624086&sv=120&sign=8b9cea22c3a0d77026abda5d37d2b7e3`; + break; + case 'getSimpleActInfoVo': + url = `${domain}/dz/common/getSimpleActInfoVo`; + body = `activityId=${$.activityId}`; + break; + case 'getMyPing': + url = `${domain}/customer/getMyPing`; + body = `userId=${$.shopId || $.venderId || ''}&token=${$.Token}&fromType=APP`; + break; + case 'accessLogWithAD': + url = `${domain}/common/accessLogWithAD`; + let pageurl = `${domain}/drawCenter/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}` + body = `venderId=${$.shopId || $.venderId || ''}&code=99&pin=${encodeURIComponent($.Pin)}&activityId=${$.activityId}&pageUrl=${encodeURIComponent(pageurl)}&subType=app&adSource=` + break; + case 'getUserInfo': + url = `${domain}/wxActionCommon/getUserInfo`; + body = `pin=${encodeURIComponent($.Pin)}`; + break; + case 'activityContent': + url = `${domain}/dingzhi/big/openCard/activityContent`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&pinImg=${encodeURIComponent($.attrTouXiang)}&nick=${encodeURIComponent($.nickname)}&cjyxPin=&cjhyPin=&shareUuid=${$.shareUuid}` + break; + case 'drawContent': + url = `${domain}/dingzhi/taskact/common/drawContent`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case 'checkOpenCard': + url = `${domain}/dingzhi/majorsuit/memberday/initOpenCard`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&shareUuid=${$.shareUuid}` + break; + case 'info': + url = `${domain}/dingzhi/linkgame/task/opencard/info`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case 'startDraw': + url = `${domain}/joint/order/draw`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&drawType=1` + break; + case 'followShop': + url = `${domain}/dingzhi/majorsuit/memberday/saveTask`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&taskType=23&taskValue=1&shareUuid=${$.shareUuid}` + break; + case 'sign': + case 'addCart': + case 'browseGoods': + url = `${domain}/dingzhi/linkgame/${type}`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + if(type == 'browseGoods') body += `&value=${$.visitSkuValue}` + break; + case '邀请': + case '助力': + if(type == '助力'){ + url = `${domain}/dingzhi/linkgame/assist`; + }else{ + url = `${domain}/dingzhi/linkgame/assist/status`; + } + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&shareUuid=${$.shareUuid}` + break; + case 'viewVideo': + case 'visitSku': + case 'toShop': + case 'addSku': + case 'toMainActive': + url = `${domain}/dingzhi/majorsuit/memberday/saveTask`; + let taskType = '' + let taskValue = '' + if(type == 'viewVideo'){ + taskType = 31 + taskValue = 31 + }else if(type == 'visitSku'){ + taskType = 5 + taskValue = $.visitSkuValue || 5 + }else if(type == 'toShop'){ + taskType = 14 + taskValue = $.toShopValue || 14 + }else if(type == 'addSku'){ + taskType = 2 + taskValue = $.addSkuValue || 2 + }else if(type == 'toMainActive'){ + taskType = 12 + taskValue = 3 + } + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&taskType=${taskType}&taskValue=${taskValue}&shareUuid=${$.shareUuid}` + break; + case 'getDrawRecordHasCoupon': + url = `${domain}/dingzhi/taskact/common/getDrawRecordHasCoupon`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case 'getShareRecord': + url = `${domain}/dingzhi/taskact/common/getShareRecord`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case 'getRule': + url = `${domain}/dingzhi/majorsuit/memberday/getRule`; + body = `activityId=${$.activityId}` + break; + case '抽奖': + url = `${domain}/dingzhi/majorsuit/memberday/draw`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + default: + console.log(`错误${type}`); + } + let myRequest = getPostRequest(url, body, method); + return new Promise(async resolve => { + $.post(myRequest, (err, resp, data) => { + try { + setActivityCookie(resp) + if (err) { + if(resp && typeof resp.statusCode != 'undefined'){ + if(resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + } + console.log(`${$.toStr(err,err)}`) + console.log(`${type} API请求失败,请检查网路重试`) + } else { + dealReturn(type, data); + } + } catch (e) { + console.log(e, resp) + } finally { + resolve(); + } + }) + }) + } + +async function dealReturn(type, data) { + let res = '' + try { + if(type != 'accessLogWithAD' || type != 'drawContent'){ + if(data){ + res = JSON.parse(data); + } + } + } catch (e) { + console.log(`${type} 执行任务异常`); + console.log(data); + $.runFalag = false; + } + try { + switch (type) { + case 'isvObfuscator': + if(typeof res == 'object'){ + if(res.errcode == 0){ + if(typeof res.token != 'undefined') $.Token = res.token + }else if(res.message){ + console.log(`isvObfuscator ${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + break; + case 'getSimpleActInfoVo': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(typeof res.data.shopId != 'undefined') $.shopId = res.data.shopId + if(typeof res.data.venderId != 'undefined') $.venderId = res.data.venderId + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getMyPing': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(res.data && typeof res.data.secretPin != 'undefined') $.Pin = res.data.secretPin + if(res.data && typeof res.data.nickname != 'undefined') $.nickname = res.data.nickname + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getUserInfo': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(res.data && typeof res.data.yunMidImageUrl != 'undefined') $.attrTouXiang = res.data.yunMidImageUrl || "https://img10.360buyimg.com/imgzone/jfs/t1/7020/27/13511/6142/5c5138d8E4df2e764/5a1216a3a5043c5d.png" + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'activityContent': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + $.endTime = res.data.endTime || (res.data.activityVo && res.data.activityVo.endTime) || res.data.activity.endTime || 0 + $.hasEnd = res.data.isEnd || false + $.actorUuid = res.data.actorUuid || (res.data.actor && res.data.actor.actorUuid) || '' + if(res.data.openCardBeanNum) console.log(`开卡获得:${res.data.openCardBeanNum}京豆`) + $.openCard2 = res.data.openCard2 || false + $.openCard1 = res.data.openCard1 || false + $.allOpenCard = res.data.allOpenCard || false + let cardList2 = res.data.cardList2 || [] + let cardList1 = res.data.cardList1 || [] + $.openList = [...cardList1,...cardList2] + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'info': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + $.addCart = res.data.addCart || false + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'checkOpenCard': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + let cardList1 = res.data.cardList1 || [] + let cardList2 = res.data.cardList2 || [] + let cardList = res.data.cardList || [] + let openInfo = res.data.openInfo || [] + let openCardList = res.data.openCardList || [] + $.openList = [...cardList,...cardList1,...cardList2,...openCardList,...openInfo] + $.allOpenCard = res.data.allOpenCard || res.data.isOpenCardStatus || false + $.openCardScore1 = res.data.score1 || 0 + $.openCardScore2 = res.data.score2 || 0 + $.drawScore = res.data.drawScore || 0 + if(res.data.sendStatus && res.data.beans) console.log(`获得:${res.data.beans}豆`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'startDraw': + case 'followShop': + case 'viewVideo': + case 'visitSku': + case 'toShop': + case 'addSku': + case 'sign': + case 'addCart': + case 'browseGoods': + case 'toMainActive': + case '抽奖': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(typeof res.data == 'object'){ + let msg = '' + let title = '抽奖' + if(res.data.addBeanNum || res.data.taskbeanNum){ + msg = `${res.data.addBeanNum || res.data.taskbeanNum}京豆` + } + if(res.data.addPoint){ + msg += ` ${res.data.addPoint}游戏机会` + } + if(type == 'followShop'){ + title = '关注' + if(res.data.beanNumMember && res.data.assistSendStatus){ + msg += ` 额外获得:${res.data.beanNumMember}京豆` + } + }else if(type == 'addSku' || type == 'addCart'){ + title = '加购' + }else if(type == 'viewVideo'){ + title = '热门文章' + }else if(type == 'toShop'){ + title = '浏览店铺' + }else if(type == 'visitSku' || type == 'browseGoods'){ + title = '浏览商品' + }else if(type == 'sign'){ + title = '签到' + }else if(type == 'toMainActive'){ + title = '逛会场' + }else{ + msg = res.data.drawOk == true && (res.data.drawInfoType == 6 && res.data.name || '') || res.data.wdsrvo.drawOk == true && (res.data.wdsrvo.drawInfoType == 6 && res.data.wdsrvo.name || '') || '空气💨' + } + if(!msg){ + msg = '空气💨' + } + console.log(`${title}获得:${msg || data}`) + }else{ + console.log(`${type} ${data}`) + } + }else if(res.errorMessage){ + $.runFalag = false; + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getDrawRecordHasCoupon': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + console.log(`我的奖品:`) + let num = 0 + let value = 0 + for(let i in res.data){ + let item = res.data[i] + if(item.drawId == 'dayShareBeans'){ + num++ + value = item.infoName.replace('京豆','') + }else{ + console.log(`${item.infoType != 10 && (item.value && item.value +':') || ''}${item.infoName}`) + } + } + // if(num > 0) console.log(`邀请好友(${num}):${num*parseInt(value, 10) || 30}京豆`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getShareRecord': + if(typeof res == 'object'){ + if(res.result && res.result === true && res.data){ + $.ShareCount = res.data.length + $.log(`=========== 你邀请了:${res.data.length}个`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case '邀请': + case '助力': + if(typeof res == 'object'){ + if(res.data.status == 200){ + if(type == '助力'){ + console.log('助力成功') + }else{ + $.yaoqing = true + } + }else if(res.data.status == 105){ + console.log('已经助力过') + }else if(res.data.status == 104){ + console.log('已经助力其他人') + }else if(res.data.status == 101){ + // console.log('已经助力过') + }else{ + console.log(data) + } + }else{ + console.log(`${type} ${data}`) + } + + case 'accessLogWithAD': + case 'drawContent': + break; + default: + console.log(`${type}-> ${data}`); + } + if(typeof res == 'object'){ + if(res.errorMessage){ + if(res.errorMessage.indexOf('火爆') >-1 ){ + $.hotFlag = true + } + } + } + } catch (e) { + console.log(e) + } +} + +function getPostRequest(url, body, method="POST") { + let headers = { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Content-Type": "application/x-www-form-urlencoded", + "Cookie": cookie, + "User-Agent": $.UA, + "X-Requested-With": "XMLHttpRequest" + } + if(url.indexOf('https://lzdz1-isv.isvjcloud.com') > -1){ + headers["Referer"] = `https://lzdz1-isv.isvjcloud.com/dingzhi/big/openCard/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}` + headers["Cookie"] = `${lz_jdpin_token_cookie && lz_jdpin_token_cookie || ''}${$.Pin && "AUTH_C_USER=" + $.Pin + ";" || ""}${activityCookie}` + } + // console.log(headers) + // console.log(headers.Cookie) + return {url: url, method: method, headers: headers, body: body, timeout:30000}; +} + +function getCk() { + return new Promise(resolve => { + let get = { + url:`https://lzdz1-isv.isvjcloud.com/dingzhi/big/openCard/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}`, + followRedirect:false, + headers: { + "User-Agent": $.UA, + }, + timeout:30000 + } + $.get(get, async(err, resp, data) => { + try { + if (err) { + if(resp && typeof resp.statusCode != 'undefined'){ + if(resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + } + console.log(`${$.toStr(err)}`) + console.log(`${$.name} cookie API请求失败,请检查网路重试`) + } else { + let end = data.match(/(活动已经结束)/) && data.match(/(活动已经结束)/)[1] || '' + if(end){ + $.activityEnd = true + console.log('活动已结束') + } + setActivityCookie(resp) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function setActivityCookie(resp){ + let LZ_TOKEN_KEY = '' + let LZ_TOKEN_VALUE = '' + let lz_jdpin_token = '' + let setcookies = resp && resp['headers'] && (resp['headers']['set-cookie'] || resp['headers']['Set-Cookie'] || '') || '' + let setcookie = '' + if(setcookies){ + if(typeof setcookies != 'object'){ + setcookie = setcookies.split(',') + }else setcookie = setcookies + for (let ck of setcookie) { + let name = ck.split(";")[0].trim() + if(name.split("=")[1]){ + // console.log(name.replace(/ /g,'')) + if(name.indexOf('LZ_TOKEN_KEY=')>-1) LZ_TOKEN_KEY = name.replace(/ /g,'')+';' + if(name.indexOf('LZ_TOKEN_VALUE=')>-1) LZ_TOKEN_VALUE = name.replace(/ /g,'')+';' + if(name.indexOf('lz_jdpin_token=')>-1) lz_jdpin_token = ''+name.replace(/ /g,'')+';' + } + } + } + if(LZ_TOKEN_KEY && LZ_TOKEN_VALUE) activityCookie = `${LZ_TOKEN_KEY} ${LZ_TOKEN_VALUE}` + if(lz_jdpin_token) lz_jdpin_token_cookie = lz_jdpin_token +} + +async function getUA(){ + $.UA = `jdapp;iPhone;10.1.4;13.1.2;${randomString(40)};network/wifi;model/iPhone8,1;addressid/2308460611;appBuild/167814;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_1_2 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 joinShop() { + if(!$.joinVenderId) return + return new Promise(async resolve => { + $.shopactivityId = '' + await $.wait(1000) + await getshopactivityId() + let activityId = `` + if($.shopactivityId) activityId = `,"activityId":${$.shopactivityId}` + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body={"venderId":"${$.joinVenderId}","shopId":"${$.joinVenderId}","bindByVerifyCodeFlag":1,"registerExtend":{},"writeChildFlag":0${activityId},"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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + // console.log(data) + let res = $.toObj(data); + if(typeof res == 'object'){ + if(res.success === true){ + console.log(res.message) + if(res.result && res.result.giftInfo){ + for(let i of res.result.giftInfo.giftList){ + console.log(`入会获得:${i.discountString}${i.prizeName}${i.secondLineDesc}`) + } + } + }else if(typeof res == 'object' && res.message){ + console.log(`${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function getshopactivityId() { + return new Promise(resolve => { + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body=%7B%22venderId%22%3A%22${$.joinVenderId}%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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + let res = $.toObj(data); + if(res.success == true){ + // console.log($.toStr(res.result)) + console.log(`入会:${res.result.shopMemberCardInfo.venderCardName || ''}`) + $.shopactivityId = res.result.interestsRuleList && res.result.interestsRuleList[0] && res.result.interestsRuleList[0].interestsInfo && res.result.interestsRuleList[0].interestsInfo.activityId || '' + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} + + +// 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)} + diff --git a/activity/jd_opencard97.js b/activity/jd_opencard97.js new file mode 100644 index 0000000..4aab99b --- /dev/null +++ b/activity/jd_opencard97.js @@ -0,0 +1,880 @@ +/* +1.8~1.27 集年味卡 享年味盛典 +新增开卡脚本,一次性脚本 + +1.邀请一人10豆 +2.开10张卡 成功开1张 获得5豆 +3.关注5豆 +4.抽奖 +5.集卡 +6.大于1张福卡时 1月28号会通知瓜分 + +第一个账号助力作者 其他依次助力CK1 +第一个CK失效会退出脚本 + +———————————————— +入口:[ 1.8~1.27 集年味卡 享年味盛典 (https://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=cd20220108iu890dmnhimj01ied&shareUuid=2d0fcc860b1f4e32acfcb3d275c4fb73)] + +请求太频繁会被黑ip +过10分钟再执行 + +cron:30 3,19 28,7-27 1 * +============Quantumultx=============== +[task_local] +#1.8~1.27 集年味卡 享年味盛典 +30 3,19 28,7-27 1 * jd_opencard97.js, tag=1.8~1.27 集年味卡 享年味盛典, enabled=true + +*/ + +const $ = new Env('1.8~1.27 集年味卡 享年味盛典'); +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const notify = $.isNode() ? require('./sendNotify') : ''; +//IOS等用户直接用NobyDa的jd cookie + +let cookiesArr = [], + cookie = ''; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} + +allMessage = "" +message = "" +$.hotFlag = false +$.outFlag = false +$.activityEnd = false +let lz_jdpin_token_cookie ='' +let activityCookie ='' +const activeEndTime = '2022/01/27 00:00:00+08:00';//活动结束时间 +let nowTime = new Date().getTime() + new Date().getTimezoneOffset()*60*1000 + 8*60*60*1000; +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', { + "open-url": "https://bean.m.jd.com/" + }); + return; + } + $.activityId = "cd20220108iu890dmnhimj01ied" + $.shareUuid = "2d0fcc860b1f4e32acfcb3d275c4fb73" + console.log(`入口:\nhttps://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}`) + + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i]; + if (cookie) { + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + message = "" + $.bean = 0 + $.hotFlag = false + $.nickName = ''; + console.log(`\n\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + await getUA() + await run(); + if(i == 0 && !$.actorUuid) break + if($.outFlag || $.activityEnd) break + } + } + if($.outFlag) { + let msg = '此ip已被限制,请过10分钟后再执行脚本' + $.msg($.name, ``, `${msg}`); + if ($.isNode()) await notify.sendNotify(`${$.name}`, `${msg}`); + } + if(allMessage){ + allMessage = `以下账号可参与瓜分京豆\n${allMessage}\n入口:https://3.cn/104c12-vF` + $.msg($.name, ``, `${allMessage}`); + if ($.isNode()) await notify.sendNotify(`${$.name}`, `${allMessage}`); + } +})() + .catch((e) => $.logErr(e)) + .finally(() => $.done()) + + +async function run() { + try { + $.hasEnd = true + $.endTime = 0 + lz_jdpin_token_cookie = '' + $.Token = '' + $.Pin = '' + let flag = false + await takePostRequest('isvObfuscator'); + if($.Token == ''){ + console.log('获取[token]失败!') + return + } + await getCk() + if (activityCookie == '') { + console.log(`获取cookie失败`); return; + } + if($.activityEnd === true){ + console.log('活动结束') + return + } + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + await takePostRequest('getSimpleActInfoVo'); + await takePostRequest('getMyPing'); + if(!$.Pin){ + console.log('获取[Pin]失败!') + return + } + await takePostRequest('accessLogWithAD'); + await takePostRequest('getUserInfo'); + await takePostRequest('activityContent'); + if($.hotFlag) return + if(!$.actorUuid){ + console.log('获取不到[actorUuid]退出执行,请重新执行') + return + } + if(($.hasEnd === true || Date.now() > $.endTime) && nowTime > new Date('2022/01/27 00:00:00+08:00').getTime()){ + $.activityEnd = true + console.log('活动结束') + return + } + await takePostRequest('drawContent'); + await $.wait(1000) + $.openList = [] + $.allOpenCard = false + await takePostRequest('checkOpenCard'); + if($.allOpenCard == false){ + console.log('开卡任务') + for(o of $.openList){ + $.openCard = false + if(o.status == 0){ + flag = true + $.joinVenderId = o.venderId + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + await joinShop() + await $.wait(parseInt(Math.random() * 1000 + 1000, 10)) + await takePostRequest('activityContent'); + await takePostRequest('drawContent'); + await takePostRequest('checkOpenCard'); + await $.wait(parseInt(Math.random() * 3000 + 2000, 10)) + } + } + }else{ + console.log('已全部开卡') + } + + $.log("关注: " + $.followShop) + if(!$.followShop && !$.outFlag){ + flag = true + await takePostRequest('followShop'); + await $.wait(parseInt(Math.random() * 2000 + 3000, 10)) + } + $.yaoqing = false + await takePostRequest('助力'); + if($.yaoqing){ + await takePostRequest('邀请'); + } + // await takePostRequest('startDraw'); + + if(flag){ + await takePostRequest('activityContent'); + } + await takePostRequest('getCardInfo'); + if($.drawCardNum){ + let count = $.drawCardNum + for(m=1;count--;m++){ + console.log(`第${m}次集卡`) + await takePostRequest('集卡'); + await takePostRequest('getCardInfo'); + if($.runFalag == false || $.compositeCardNum > 0) break + if(Number(count) <= 0) break + if(m >= 5){ + console.log("集卡太多次,多余的次数请再执行脚本") + break + } + await $.wait(parseInt(Math.random() * 2000 + 2000, 10)) + } + if($.compositeCardNum){ + let count = $.compositeCardNum + for(m=1;count--;m++){ + console.log(`第${m}次合卡`) + await takePostRequest('合卡'); + if($.runFalag == false) break + if(Number(count) <= 0) break + if(m >= 5){ + console.log("合卡太多次,多余的次数请再执行脚本") + break + } + await $.wait(parseInt(Math.random() * 2000 + 2000, 10)) + } + } + } + for(let c of $.myCardList || []){ + console.log(`${c.cardName}:${c.cardNum}`) + } + if ($.compositeCardFinishCount >= 1 && nowTime > new Date(activeEndTime).getTime()) { + allMessage += `【京东账号${$.index}】${$.nickName || $.UserName}\n` + } + console.log(`${$.score}值 福卡:${$.compositeCardFinishCount}`) + $.runFalag = true + let count = parseInt($.score/100) + console.log(`抽奖次数为:${count}`) + for(m=1;count--;m++){ + console.log(`第${m}次抽奖`) + await takePostRequest('抽奖'); + if($.runFalag == false) break + if(Number(count) <= 0) break + if(m >= 1){ + console.log("抽奖太多次,多余的次数请再执行脚本") + break + } + await $.wait(parseInt(Math.random() * 2000 + 2000, 10)) + } + + await $.wait(parseInt(Math.random() * 1000 + 2000, 10)) + await takePostRequest('getDrawRecordHasCoupon'); + await takePostRequest('getShareRecord'); + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + console.log($.actorUuid) + console.log(`当前助力:${$.shareUuid}`) + if($.index == 1){ + $.shareUuid = $.actorUuid + console.log(`后面的号都会助力:${$.shareUuid}`) + } + await $.wait(parseInt(Math.random() * 1000 + 5000, 10)) + if(flag) await $.wait(parseInt(Math.random() * 1000 + 10000, 10)) + if($.index % 3 == 0) console.log('休息1分钟,别被黑ip了\n可持续发展') + if($.index % 3 == 0) await $.wait(parseInt(Math.random() * 5000 + 60000, 10)) + } catch (e) { + console.log(e) + } +} + +async function takePostRequest(type) { + if($.outFlag) return + let domain = 'https://lzdz1-isv.isvjcloud.com'; + let body = ``; + let method = 'POST' + let admJson = '' + switch (type) { + case 'isvObfuscator': + url = `https://api.m.jd.com/client.action?functionId=isvObfuscator`; + body = `body=%7B%22url%22%3A%22https%3A//lzdz1-isv.isvjcloud.com%22%2C%22id%22%3A%22%22%7D&uuid=7088d9018515b8cb0c88ace6e5479762af3e88f3&client=apple&clientVersion=10.1.4&st=1634343624086&sv=120&sign=8b9cea22c3a0d77026abda5d37d2b7e3`; + break; + case 'getSimpleActInfoVo': + url = `${domain}/dz/common/getSimpleActInfoVo`; + body = `activityId=${$.activityId}`; + break; + case 'getMyPing': + url = `${domain}/customer/getMyPing`; + body = `userId=${$.shopId || $.venderId || ''}&token=${$.Token}&fromType=APP`; + break; + case 'accessLogWithAD': + url = `${domain}/common/accessLogWithAD`; + let pageurl = `${domain}/drawCenter/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}` + body = `venderId=${$.shopId || $.venderId || ''}&code=99&pin=${encodeURIComponent($.Pin)}&activityId=${$.activityId}&pageUrl=${encodeURIComponent(pageurl)}&subType=app&adSource=` + break; + case 'getUserInfo': + url = `${domain}/wxActionCommon/getUserInfo`; + body = `pin=${encodeURIComponent($.Pin)}`; + break; + case 'activityContent': + url = `${domain}/play/monopoly/getContent`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&pinImg=${encodeURIComponent($.attrTouXiang)}&nick=${encodeURIComponent($.nickname)}&cjyxPin=&cjhyPin=&shareUuid=${$.shareUuid}` + break; + case 'drawContent': + url = `${domain}/dingzhi/taskact/common/drawContent`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case 'checkOpenCard': + url = `${domain}/play/monopoly/checkOpenCard`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case 'info': + url = `${domain}/play/monopoly/getTaskList`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case 'startDraw': + url = `${domain}/play/monopoly/activeDraw`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&drawType=1` + break; + case 'getCardInfo': + url = `${domain}/play/monopoly/getCardInfo`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case '集卡': + url = `${domain}/play/monopoly/drawCard`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case '合卡': + url = `${domain}/play/monopoly/compositeCard`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case 'followShop': + url = `${domain}/play/monopoly/doTasks`; + // url = `${domain}/dingzhi/dz/openCard/saveTask`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&taskType=1` + break; + case 'sign': + case 'addCart': + case 'browseGoods': + url = `${domain}/dingzhi/linkgame/${type}`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + if(type == 'browseGoods') body += `&value=${$.visitSkuValue}` + break; + case '邀请': + case '助力': + if(type == '助力'){ + url = `${domain}/play/monopoly/getAssistStatus`; + }else{ + url = `${domain}/play/monopoly/assist`; + } + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&shareUuid=${$.shareUuid}&actorUuid=${$.actorUuid}` + break; + case 'viewVideo': + case 'visitSku': + case 'toShop': + case 'addSku': + url = `${domain}/dingzhi/dz/openCard/saveTask`; + let taskType = '' + let taskValue = '' + if(type == 'viewVideo'){ + taskType = 31 + taskValue = 31 + }else if(type == 'visitSku'){ + taskType = 5 + taskValue = $.visitSkuValue || 5 + }else if(type == 'toShop'){ + taskType = 14 + taskValue = $.toShopValue || 14 + }else if(type == 'addSku'){ + taskType = 2 + taskValue = $.addSkuValue || 2 + } + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&taskType=${taskType}&taskValue=${taskValue}` + break; + case 'getDrawRecordHasCoupon': + url = `${domain}/play/monopoly/getPrizeList`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case 'getShareRecord': + url = `${domain}/play/monopoly/getHelpList`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case '抽奖': + url = `${domain}/play/monopoly/activeDraw`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&drawType=2` + break; + default: + console.log(`错误${type}`); + } + let myRequest = getPostRequest(url, body, method); + // console.log(myRequest) + return new Promise(async resolve => { + $.post(myRequest, (err, resp, data) => { + try { + setActivityCookie(resp) + if (err) { + if(resp && typeof resp.statusCode != 'undefined'){ + if(resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + } + console.log(`${$.toStr(err,err)}`) + console.log(`${type} API请求失败,请检查网路重试`) + } else { + dealReturn(type, data); + } + } catch (e) { + // console.log(data); + console.log(e, resp) + } finally { + resolve(); + } + }) + }) + } + +async function dealReturn(type, data) { + let res = '' + try { + if(type != 'accessLogWithAD' || type != 'drawContent'){ + if(data){ + res = JSON.parse(data); + } + } + } catch (e) { + console.log(`${type} 执行任务异常`); + console.log(data); + $.runFalag = false; + } + try { + switch (type) { + case 'isvObfuscator': + if(typeof res == 'object'){ + if(res.errcode == 0){ + if(typeof res.token != 'undefined') $.Token = res.token + }else if(res.message){ + console.log(`isvObfuscator ${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + break; + case 'getSimpleActInfoVo': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(typeof res.data.shopId != 'undefined') $.shopId = res.data.shopId + if(typeof res.data.venderId != 'undefined') $.venderId = res.data.venderId + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getMyPing': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(res.data && typeof res.data.secretPin != 'undefined') $.Pin = res.data.secretPin + if(res.data && typeof res.data.nickname != 'undefined') $.nickname = res.data.nickname + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getUserInfo': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(res.data && typeof res.data.yunMidImageUrl != 'undefined') $.attrTouXiang = res.data.yunMidImageUrl || "https://img10.360buyimg.com/imgzone/jfs/t1/7020/27/13511/6142/5c5138d8E4df2e764/5a1216a3a5043c5d.png" + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'activityContent': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + $.endTime = res.data.endTime || (res.data.activityVo && res.data.activityVo.endTime) || res.data.activity.endTime || 0 + $.hasEnd = res.data.isEnd || false + $.drawCount = res.data.actorVo.drawCount || 0 + $.point = res.data.actorVo.point || 0 + $.score = res.data.actorVo.score || 0 + $.actorUuid = res.data.actorVo.actorUuid || '' + $.followShop = res.data.actorVo.followShopStatus || '' + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'info': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + // $.drawCount = res.data.drawCount || 0 + $.addCart = res.data.addCart || false + $.followShop = res.data.followShop || false + $.sign = res.data.isSignStatus || false + $.visitSku = res.data.visitSku || false + $.visitSkuList = res.data.visitSkuList || [] + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'checkOpenCard': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + // console.log(data) + let cardList1 = res.data.cardList1 || [] + let cardList2 = res.data.cardList2 || [] + let cardList = res.data.cardList || [] + let openCardList = res.data.openCardList || [] + $.openList = [...cardList,...cardList1,...cardList2,...openCardList] + $.allOpenCard = res.data.allOpenCard || res.data.isOpenCardStatus || false + $.openCardScore1 = res.data.score1 || 0 + $.openCardScore2 = res.data.score2 || 0 + $.drawScore = res.data.drawScore || 0 + if(res.data.beans || res.data.addBeanNum) console.log(`开卡获得:${res.data.beans || res.data.addBeanNum}豆`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'startDraw': + case 'followShop': + case 'viewVideo': + case 'visitSku': + case 'toShop': + case 'addSku': + case 'sign': + case 'addCart': + case 'browseGoods': + case '抽奖': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(typeof res.data == 'object'){ + let msg = '' + let title = '抽奖' + if(res.data.addBeanNum){ + msg = `${res.data.addBeanNum}京豆` + } + if(res.data.addPoint){ + msg += ` ${res.data.addPoint}游戏机会` + } + if(type == 'followShop'){ + title = '关注' + if(res.data.beanNumMember && res.data.assistSendStatus){ + msg += ` 额外获得:${res.data.beanNumMember}京豆` + } + }else if(type == 'addSku' || type == 'addCart'){ + title = '加购' + }else if(type == 'viewVideo'){ + title = '热门文章' + }else if(type == 'toShop'){ + title = '浏览店铺' + }else if(type == 'visitSku' || type == 'browseGoods'){ + title = '浏览商品' + }else if(type == 'sign'){ + title = '签到' + }else{ + msg = res.data.drawOk == true && (res.data.drawInfoType == 6 && res.data.name || '') || '空气💨' + } + if(!msg){ + msg = '空气💨' + } + console.log(`${title}获得:${msg || data}`) + }else{ + console.log(`${type} ${data}`) + } + }else if(res.errorMessage){ + $.runFalag = false; + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getDrawRecordHasCoupon': + // console.log(data) + if(typeof res == 'object'){ + if(res.result && res.result === true){ + console.log(`我的奖品:`) + let num = 0 + let value = 0 + for(let i in res.data){ + let item = res.data[i] + if(item.drawId == 'assist'){ + num++ + value = item.infoName.replace('京豆','') + }else{ + console.log(`${item.infoType != 10 && item.drawId && item.drawId +':' || ''}${item.infoName}`) + } + } + if(num > 0) console.log(`邀请好友(${num}):${num*parseInt(value, 10) || 30}京豆`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getShareRecord': + if(typeof res == 'object'){ + if(res.result && res.result === true && res.data){ + $.ShareCount = res.data.length + $.log(`=========== 你邀请了:${res.data.length}个`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getCardInfo': + case '集卡': + case '合卡': + if(typeof res == 'object'){ + if(res.result && res.result === true && res.data){ + if(type == "集卡"){ + if(res.data.status == 1) console.log(`集卡成功->${res.data.cardName}`) + else console.log('集卡失败'+ res.data.cardName && '->'+res.data.cardName || '\n'+data) + }else if(type == "合卡"){ + if(res.data.status == 1) console.log('合卡成功') + else console.log('合卡失败\n'+data) + }else if(type == "getCardInfo"){ + $.score = res.data.score || 0 + $.myCardList = res.data.myCardList || [] + $.compositeCardFinishCount = res.data.compositeCardFinishCount || 0 + $.compositeCardNum = res.data.compositeCardNum || 0 + $.drawCardNum = res.data.drawCardNum || 0 + } + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case '邀请': + case '助力': + // console.log(data) + if(typeof res == 'object'){ + if(res.data == 200){ + if(type == '助力'){ + console.log('助力成功') + $.yaoqing = true + } + }else if(res.data == 105){ + console.log('已经助力过') + }else if(res.data == 104){ + console.log('已经助力其他人') + }else if(res.data == 101){ + // console.log('已经助力过') + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + + case 'accessLogWithAD': + case 'drawContent': + break; + default: + console.log(`${type}-> ${data}`); + } + if(typeof res == 'object'){ + if(res.errorMessage){ + if(res.errorMessage.indexOf('火爆') >-1 ){ + $.hotFlag = true + } + } + } + } catch (e) { + console.log(e) + } +} + +function getPostRequest(url, body, method="POST") { + let headers = { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Content-Type": "application/x-www-form-urlencoded", + "Cookie": cookie, + "User-Agent": $.UA, + "X-Requested-With": "XMLHttpRequest" + } + if(url.indexOf('https://lzdz1-isv.isvjcloud.com') > -1){ + headers["Referer"] = `https://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}` + headers["Cookie"] = `${lz_jdpin_token_cookie && lz_jdpin_token_cookie || ''}${$.Pin && "AUTH_C_USER=" + $.Pin + ";" || ""}${activityCookie}` + } + // console.log(headers) + // console.log(headers.Cookie) + return {url: url, method: method, headers: headers, body: body, timeout:30000}; +} + +function getCk() { + return new Promise(resolve => { + let get = { + url:`https://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}`, + followRedirect:false, + headers: { + "User-Agent": $.UA, + }, + timeout:30000 + } + $.get(get, async(err, resp, data) => { + try { + if (err) { + if(resp && typeof resp.statusCode != 'undefined'){ + if(resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + } + console.log(`${$.toStr(err)}`) + console.log(`${$.name} cookie API请求失败,请检查网路重试`) + } else { + let end = data.match(/(活动已经结束)/) && data.match(/(活动已经结束)/)[1] || '' + if(end){ + $.activityEnd = true + console.log('活动已结束') + } + setActivityCookie(resp) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function setActivityCookie(resp){ + let LZ_TOKEN_KEY = '' + let LZ_TOKEN_VALUE = '' + let lz_jdpin_token = '' + let setcookies = resp && resp['headers'] && (resp['headers']['set-cookie'] || resp['headers']['Set-Cookie'] || '') || '' + let setcookie = '' + if(setcookies){ + if(typeof setcookies != 'object'){ + setcookie = setcookies.split(',') + }else setcookie = setcookies + for (let ck of setcookie) { + let name = ck.split(";")[0].trim() + if(name.split("=")[1]){ + // console.log(name.replace(/ /g,'')) + if(name.indexOf('LZ_TOKEN_KEY=')>-1) LZ_TOKEN_KEY = name.replace(/ /g,'')+';' + if(name.indexOf('LZ_TOKEN_VALUE=')>-1) LZ_TOKEN_VALUE = name.replace(/ /g,'')+';' + if(name.indexOf('lz_jdpin_token=')>-1) lz_jdpin_token = ''+name.replace(/ /g,'')+';' + } + } + } + if(LZ_TOKEN_KEY && LZ_TOKEN_VALUE) activityCookie = `${LZ_TOKEN_KEY} ${LZ_TOKEN_VALUE}` + if(lz_jdpin_token) lz_jdpin_token_cookie = lz_jdpin_token +} + +async function getUA(){ + $.UA = `jdapp;iPhone;10.1.4;13.1.2;${randomString(40)};network/wifi;model/iPhone8,1;addressid/2308460611;appBuild/167814;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_1_2 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 joinShop() { + if(!$.joinVenderId) return + return new Promise(async resolve => { + $.shopactivityId = '' + await $.wait(1000) + await getshopactivityId() + let activityId = `` + if($.shopactivityId) activityId = `,"activityId":${$.shopactivityId}` + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body={"venderId":"${$.joinVenderId}","shopId":"${$.joinVenderId}","bindByVerifyCodeFlag":1,"registerExtend":{},"writeChildFlag":0${activityId},"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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + // console.log(data) + let res = $.toObj(data); + if(typeof res == 'object'){ + if(res.success === true){ + console.log(res.message) + if(res.result && res.result.giftInfo){ + for(let i of res.result.giftInfo.giftList){ + console.log(`入会获得:${i.discountString}${i.prizeName}${i.secondLineDesc}`) + } + } + }else if(typeof res == 'object' && res.message){ + console.log(`${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function getshopactivityId() { + return new Promise(resolve => { + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body=%7B%22venderId%22%3A%22${$.joinVenderId}%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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + let res = $.toObj(data); + if(res.success == true){ + // console.log($.toStr(res.result)) + console.log(`入会:${res.result.shopMemberCardInfo.venderCardName || ''}`) + $.shopactivityId = res.result.interestsRuleList && res.result.interestsRuleList[0] && res.result.interestsRuleList[0].interestsInfo && res.result.interestsRuleList[0].interestsInfo.activityId || '' + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} + + +// 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)} + diff --git a/activity/jd_opencard98.js b/activity/jd_opencard98.js new file mode 100644 index 0000000..3afa33e --- /dev/null +++ b/activity/jd_opencard98.js @@ -0,0 +1,881 @@ +/* +1.7~1.26 集“年味卡”,享年货盛宴 +新增开卡脚本,一次性脚本 + +1.邀请一人10豆 +2.开10张卡 成功开1张 获得5豆 +3.关注5豆 +4.抽奖 +5.集卡 +6.大于1张福卡时 1月27号会通知瓜分 + +第一个账号助力作者 其他依次助力CK1 +第一个CK失效会退出脚本 + +———————————————— +入口:[ 1.7~1.26 集“年味卡”,享年货盛宴 (https://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=cd20220107vcowv119979tm7p&shareUuid=5ab83c656ec648a9b417b4ae5824730a)] + +请求太频繁会被黑ip +过10分钟再执行 + +cron:30 2,10 7-27 1 * +============Quantumultx=============== +[task_local] +#1.7~1.26 集“年味卡”,享年货盛宴 +30 2,10 7-27 1 * jd_opencard98.js, tag=1.7~1.26 集“年味卡”,享年货盛宴, enabled=true + +*/ + +const $ = new Env('1.7~1.26 集“年味卡”,享年货盛宴'); +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const notify = $.isNode() ? require('./sendNotify') : ''; +//IOS等用户直接用NobyDa的jd cookie + +let cookiesArr = [], + cookie = ''; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} + +allMessage = "" +message = "" +$.hotFlag = false +$.outFlag = false +$.activityEnd = false +let lz_jdpin_token_cookie ='' +let activityCookie ='' +const activeEndTime = '2022/01/27 00:00:00+08:00';//活动结束时间 +let nowTime = new Date().getTime() + new Date().getTimezoneOffset()*60*1000 + 8*60*60*1000; +!(async () => { + console.log('自行测试是否有水,没水请禁止运行') + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', { + "open-url": "https://bean.m.jd.com/" + }); + return; + } + $.activityId = "cd20220107vcowv119979tm7p" + $.shareUuid = "5ab83c656ec648a9b417b4ae5824730a" + console.log(`入口:\nhttps://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}`) + + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i]; + if (cookie) { + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + message = "" + $.bean = 0 + $.hotFlag = false + $.nickName = ''; + console.log(`\n\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + await getUA() + await run(); + if(i == 0 && !$.actorUuid) break + if($.outFlag || $.activityEnd) break + } + } + if($.outFlag) { + let msg = '此ip已被限制,请过10分钟后再执行脚本' + $.msg($.name, ``, `${msg}`); + if ($.isNode()) await notify.sendNotify(`${$.name}`, `${msg}`); + } + if(allMessage){ + allMessage = `以下账号可参与瓜分京豆\n${allMessage}\n入口:https://3.cn/104c1-1d6` + $.msg($.name, ``, `${allMessage}`); + if ($.isNode()) await notify.sendNotify(`${$.name}`, `${allMessage}`); + } +})() + .catch((e) => $.logErr(e)) + .finally(() => $.done()) + + +async function run() { + try { + $.hasEnd = true + $.endTime = 0 + lz_jdpin_token_cookie = '' + $.Token = '' + $.Pin = '' + let flag = false + await takePostRequest('isvObfuscator'); + if($.Token == ''){ + console.log('获取[token]失败!') + return + } + await getCk() + if (activityCookie == '') { + console.log(`获取cookie失败`); return; + } + if($.activityEnd === true){ + console.log('活动结束') + return + } + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + await takePostRequest('getSimpleActInfoVo'); + await takePostRequest('getMyPing'); + if(!$.Pin){ + console.log('获取[Pin]失败!') + return + } + await takePostRequest('accessLogWithAD'); + await takePostRequest('getUserInfo'); + await takePostRequest('activityContent'); + if($.hotFlag) return + if(!$.actorUuid){ + console.log('获取不到[actorUuid]退出执行,请重新执行') + return + } + if(($.hasEnd === true || Date.now() > $.endTime) && nowTime > new Date('2022/01/27 00:00:00+08:00').getTime()){ + $.activityEnd = true + console.log('活动结束') + return + } + await takePostRequest('drawContent'); + await $.wait(1000) + $.openList = [] + $.allOpenCard = false + await takePostRequest('checkOpenCard'); + if($.allOpenCard == false){ + console.log('开卡任务') + for(o of $.openList){ + $.openCard = false + if(o.status == 0){ + flag = true + $.joinVenderId = o.venderId + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + await joinShop() + await $.wait(parseInt(Math.random() * 1000 + 1000, 10)) + await takePostRequest('activityContent'); + await takePostRequest('drawContent'); + await takePostRequest('checkOpenCard'); + await $.wait(parseInt(Math.random() * 3000 + 2000, 10)) + } + } + }else{ + console.log('已全部开卡') + } + + $.log("关注: " + $.followShop) + if(!$.followShop && !$.outFlag){ + flag = true + await takePostRequest('followShop'); + await $.wait(parseInt(Math.random() * 2000 + 3000, 10)) + } + $.yaoqing = false + await takePostRequest('助力'); + if($.yaoqing){ + await takePostRequest('邀请'); + } + + if(flag){ + await takePostRequest('activityContent'); + } + await takePostRequest('getCardInfo'); + if($.drawCardNum){ + let count = $.drawCardNum + for(m=1;count--;m++){ + console.log(`第${m}次集卡`) + await takePostRequest('集卡'); + await takePostRequest('getCardInfo'); + if($.runFalag == false || $.compositeCardNum > 0) break + if(Number(count) <= 0) break + if(m >= 5){ + console.log("集卡太多次,多余的次数请再执行脚本") + break + } + await $.wait(parseInt(Math.random() * 2000 + 2000, 10)) + } + if($.compositeCardNum){ + let count = $.compositeCardNum + for(m=1;count--;m++){ + console.log(`第${m}次合卡`) + await takePostRequest('合卡'); + if($.runFalag == false) break + if(Number(count) <= 0) break + if(m >= 5){ + console.log("合卡太多次,多余的次数请再执行脚本") + break + } + await $.wait(parseInt(Math.random() * 2000 + 2000, 10)) + } + } + } + for(let c of $.myCardList || []){ + console.log(`${c.cardName}:${c.cardNum}`) + } + if ($.compositeCardFinishCount >= 1 && nowTime > new Date(activeEndTime).getTime()) { + allMessage += `【京东账号${$.index}】${$.nickName || $.UserName}\n` + } + console.log(`${$.score}值 福卡:${$.compositeCardFinishCount}`) + $.runFalag = true + let count = parseInt($.score/100) + console.log(`抽奖次数为:${count}`) + for(m=1;count--;m++){ + console.log(`第${m}次抽奖`) + await takePostRequest('抽奖'); + if($.runFalag == false) break + if(Number(count) <= 0) break + if(m >= 1){ + console.log("抽奖太多次,多余的次数请再执行脚本") + break + } + await $.wait(parseInt(Math.random() * 2000 + 2000, 10)) + } + + await $.wait(parseInt(Math.random() * 1000 + 2000, 10)) + await takePostRequest('getDrawRecordHasCoupon'); + await takePostRequest('getShareRecord'); + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + console.log($.actorUuid) + console.log(`当前助力:${$.shareUuid}`) + if($.index == 1){ + $.shareUuid = $.actorUuid + console.log(`后面的号都会助力:${$.shareUuid}`) + } + await $.wait(parseInt(Math.random() * 1000 + 5000, 10)) + if(flag) await $.wait(parseInt(Math.random() * 1000 + 10000, 10)) + + if($.index % 3 == 0) console.log('休息1分钟,别被黑ip了\n可持续发展') + if($.index % 3 == 0) await $.wait(parseInt(Math.random() * 5000 + 60000, 10)) + } catch (e) { + console.log(e) + } +} + +async function takePostRequest(type) { + if($.outFlag) return + let domain = 'https://lzdz1-isv.isvjcloud.com'; + let body = ``; + let method = 'POST' + let admJson = '' + switch (type) { + case 'isvObfuscator': + url = `https://api.m.jd.com/client.action?functionId=isvObfuscator`; + body = `body=%7B%22url%22%3A%22https%3A//lzdz1-isv.isvjcloud.com%22%2C%22id%22%3A%22%22%7D&uuid=7088d9018515b8cb0c88ace6e5479762af3e88f3&client=apple&clientVersion=10.1.4&st=1634343624086&sv=120&sign=8b9cea22c3a0d77026abda5d37d2b7e3`; + break; + case 'getSimpleActInfoVo': + url = `${domain}/dz/common/getSimpleActInfoVo`; + body = `activityId=${$.activityId}`; + break; + case 'getMyPing': + url = `${domain}/customer/getMyPing`; + body = `userId=${$.shopId || $.venderId || ''}&token=${$.Token}&fromType=APP`; + break; + case 'accessLogWithAD': + url = `${domain}/common/accessLogWithAD`; + let pageurl = `${domain}/drawCenter/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}` + body = `venderId=${$.shopId || $.venderId || ''}&code=99&pin=${encodeURIComponent($.Pin)}&activityId=${$.activityId}&pageUrl=${encodeURIComponent(pageurl)}&subType=app&adSource=` + break; + case 'getUserInfo': + url = `${domain}/wxActionCommon/getUserInfo`; + body = `pin=${encodeURIComponent($.Pin)}`; + break; + case 'activityContent': + url = `${domain}/play/monopoly/getContent`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&pinImg=${encodeURIComponent($.attrTouXiang)}&nick=${encodeURIComponent($.nickname)}&cjyxPin=&cjhyPin=&shareUuid=${$.shareUuid}` + break; + case 'drawContent': + url = `${domain}/dingzhi/taskact/common/drawContent`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case 'checkOpenCard': + url = `${domain}/play/monopoly/checkOpenCard`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case 'info': + url = `${domain}/play/monopoly/getTaskList`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case 'startDraw': + url = `${domain}/play/monopoly/activeDraw`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&drawType=1` + break; + case 'getCardInfo': + url = `${domain}/play/monopoly/getCardInfo`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case '集卡': + url = `${domain}/play/monopoly/drawCard`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case '合卡': + url = `${domain}/play/monopoly/compositeCard`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case 'followShop': + url = `${domain}/play/monopoly/doTasks`; + // url = `${domain}/dingzhi/dz/openCard/saveTask`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&taskType=1` + break; + case 'sign': + case 'addCart': + case 'browseGoods': + url = `${domain}/dingzhi/linkgame/${type}`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + if(type == 'browseGoods') body += `&value=${$.visitSkuValue}` + break; + case '邀请': + case '助力': + if(type == '助力'){ + url = `${domain}/play/monopoly/getAssistStatus`; + }else{ + url = `${domain}/play/monopoly/assist`; + } + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&shareUuid=${$.shareUuid}&actorUuid=${$.actorUuid}` + break; + case 'viewVideo': + case 'visitSku': + case 'toShop': + case 'addSku': + url = `${domain}/dingzhi/dz/openCard/saveTask`; + let taskType = '' + let taskValue = '' + if(type == 'viewVideo'){ + taskType = 31 + taskValue = 31 + }else if(type == 'visitSku'){ + taskType = 5 + taskValue = $.visitSkuValue || 5 + }else if(type == 'toShop'){ + taskType = 14 + taskValue = $.toShopValue || 14 + }else if(type == 'addSku'){ + taskType = 2 + taskValue = $.addSkuValue || 2 + } + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&taskType=${taskType}&taskValue=${taskValue}` + break; + case 'getDrawRecordHasCoupon': + url = `${domain}/play/monopoly/getPrizeList`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case 'getShareRecord': + url = `${domain}/play/monopoly/getHelpList`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case '抽奖': + url = `${domain}/play/monopoly/activeDraw`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&drawType=2` + break; + default: + console.log(`错误${type}`); + } + let myRequest = getPostRequest(url, body, method); + // console.log(myRequest) + return new Promise(async resolve => { + $.post(myRequest, (err, resp, data) => { + try { + setActivityCookie(resp) + if (err) { + if(resp && typeof resp.statusCode != 'undefined'){ + if(resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + } + console.log(`${$.toStr(err,err)}`) + console.log(`${type} API请求失败,请检查网路重试`) + } else { + dealReturn(type, data); + } + } catch (e) { + // console.log(data); + console.log(e, resp) + } finally { + resolve(); + } + }) + }) + } + +async function dealReturn(type, data) { + let res = '' + try { + if(type != 'accessLogWithAD' || type != 'drawContent'){ + if(data){ + res = JSON.parse(data); + } + } + } catch (e) { + console.log(`${type} 执行任务异常`); + console.log(data); + $.runFalag = false; + } + try { + switch (type) { + case 'isvObfuscator': + if(typeof res == 'object'){ + if(res.errcode == 0){ + if(typeof res.token != 'undefined') $.Token = res.token + }else if(res.message){ + console.log(`isvObfuscator ${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + break; + case 'getSimpleActInfoVo': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(typeof res.data.shopId != 'undefined') $.shopId = res.data.shopId + if(typeof res.data.venderId != 'undefined') $.venderId = res.data.venderId + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getMyPing': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(res.data && typeof res.data.secretPin != 'undefined') $.Pin = res.data.secretPin + if(res.data && typeof res.data.nickname != 'undefined') $.nickname = res.data.nickname + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getUserInfo': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(res.data && typeof res.data.yunMidImageUrl != 'undefined') $.attrTouXiang = res.data.yunMidImageUrl || "https://img10.360buyimg.com/imgzone/jfs/t1/7020/27/13511/6142/5c5138d8E4df2e764/5a1216a3a5043c5d.png" + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'activityContent': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + $.endTime = res.data.endTime || (res.data.activityVo && res.data.activityVo.endTime) || res.data.activity.endTime || 0 + $.hasEnd = res.data.isEnd || false + $.drawCount = res.data.actorVo.drawCount || 0 + $.point = res.data.actorVo.point || 0 + $.score = res.data.actorVo.score || 0 + $.actorUuid = res.data.actorVo.actorUuid || '' + $.followShop = res.data.actorVo.followShopStatus || '' + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'info': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + // $.drawCount = res.data.drawCount || 0 + $.addCart = res.data.addCart || false + $.followShop = res.data.followShop || false + $.sign = res.data.isSignStatus || false + $.visitSku = res.data.visitSku || false + $.visitSkuList = res.data.visitSkuList || [] + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'checkOpenCard': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + // console.log(data) + let cardList1 = res.data.cardList1 || [] + let cardList2 = res.data.cardList2 || [] + let cardList = res.data.cardList || [] + let openCardList = res.data.openCardList || [] + $.openList = [...cardList,...cardList1,...cardList2,...openCardList] + $.allOpenCard = res.data.allOpenCard || res.data.isOpenCardStatus || false + $.openCardScore1 = res.data.score1 || 0 + $.openCardScore2 = res.data.score2 || 0 + $.drawScore = res.data.drawScore || 0 + if(res.data.beans || res.data.addBeanNum) console.log(`开卡获得:${res.data.beans || res.data.addBeanNum}豆`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'startDraw': + case 'followShop': + case 'viewVideo': + case 'visitSku': + case 'toShop': + case 'addSku': + case 'sign': + case 'addCart': + case 'browseGoods': + case '抽奖': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(typeof res.data == 'object'){ + let msg = '' + let title = '抽奖' + if(res.data.addBeanNum){ + msg = `${res.data.addBeanNum}京豆` + } + if(res.data.addPoint){ + msg += ` ${res.data.addPoint}游戏机会` + } + if(type == 'followShop'){ + title = '关注' + if(res.data.beanNumMember && res.data.assistSendStatus){ + msg += ` 额外获得:${res.data.beanNumMember}京豆` + } + }else if(type == 'addSku' || type == 'addCart'){ + title = '加购' + }else if(type == 'viewVideo'){ + title = '热门文章' + }else if(type == 'toShop'){ + title = '浏览店铺' + }else if(type == 'visitSku' || type == 'browseGoods'){ + title = '浏览商品' + }else if(type == 'sign'){ + title = '签到' + }else{ + msg = res.data.drawOk == true && (res.data.drawInfoType == 6 && res.data.name || '') || '空气💨' + } + if(!msg){ + msg = '空气💨' + } + console.log(`${title}获得:${msg || data}`) + }else{ + console.log(`${type} ${data}`) + } + }else if(res.errorMessage){ + $.runFalag = false; + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getDrawRecordHasCoupon': + // console.log(data) + if(typeof res == 'object'){ + if(res.result && res.result === true){ + console.log(`我的奖品:`) + let num = 0 + let value = 0 + for(let i in res.data){ + let item = res.data[i] + if(item.drawId == 'assist'){ + num++ + value = item.infoName.replace('京豆','') + }else{ + console.log(`${item.infoType != 10 && item.drawId && item.drawId +':' || ''}${item.infoName}`) + } + } + if(num > 0) console.log(`邀请好友(${num}):${num*parseInt(value, 10) || 30}京豆`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getShareRecord': + if(typeof res == 'object'){ + if(res.result && res.result === true && res.data){ + $.ShareCount = res.data.length + $.log(`=========== 你邀请了:${res.data.length}个`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getCardInfo': + case '集卡': + case '合卡': + if(typeof res == 'object'){ + if(res.result && res.result === true && res.data){ + if(type == "集卡"){ + if(res.data.status == 1) console.log(`集卡成功->${res.data.cardName}`) + else console.log('集卡失败'+ res.data.cardName && '->'+res.data.cardName || '\n'+data) + }else if(type == "合卡"){ + if(res.data.status == 1) console.log('合卡成功') + else console.log('合卡失败\n'+data) + }else if(type == "getCardInfo"){ + $.score = res.data.score || 0 + $.myCardList = res.data.myCardList || [] + $.compositeCardFinishCount = res.data.compositeCardFinishCount || 0 + $.compositeCardNum = res.data.compositeCardNum || 0 + $.drawCardNum = res.data.drawCardNum || 0 + } + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case '邀请': + case '助力': + // console.log(data) + if(typeof res == 'object'){ + if(res.data == 200){ + if(type == '助力'){ + console.log('助力成功') + $.yaoqing = true + } + }else if(res.data == 105){ + console.log('已经助力过') + }else if(res.data == 104){ + console.log('已经助力其他人') + }else if(res.data == 101){ + // console.log('已经助力过') + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + + case 'accessLogWithAD': + case 'drawContent': + break; + default: + console.log(`${type}-> ${data}`); + } + if(typeof res == 'object'){ + if(res.errorMessage){ + if(res.errorMessage.indexOf('火爆') >-1 ){ + $.hotFlag = true + } + } + } + } catch (e) { + console.log(e) + } +} + +function getPostRequest(url, body, method="POST") { + let headers = { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Content-Type": "application/x-www-form-urlencoded", + "Cookie": cookie, + "User-Agent": $.UA, + "X-Requested-With": "XMLHttpRequest" + } + if(url.indexOf('https://lzdz1-isv.isvjcloud.com') > -1){ + headers["Referer"] = `https://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}` + headers["Cookie"] = `${lz_jdpin_token_cookie && lz_jdpin_token_cookie || ''}${$.Pin && "AUTH_C_USER=" + $.Pin + ";" || ""}${activityCookie}` + } + // console.log(headers) + // console.log(headers.Cookie) + return {url: url, method: method, headers: headers, body: body, timeout:30000}; +} + +function getCk() { + return new Promise(resolve => { + let get = { + url:`https://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}`, + followRedirect:false, + headers: { + "User-Agent": $.UA, + }, + timeout:30000 + } + $.get(get, async(err, resp, data) => { + try { + if (err) { + if(resp && typeof resp.statusCode != 'undefined'){ + if(resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + } + console.log(`${$.toStr(err)}`) + console.log(`${$.name} cookie API请求失败,请检查网路重试`) + } else { + let end = data.match(/(活动已经结束)/) && data.match(/(活动已经结束)/)[1] || '' + if(end){ + $.activityEnd = true + console.log('活动已结束') + } + setActivityCookie(resp) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function setActivityCookie(resp){ + let LZ_TOKEN_KEY = '' + let LZ_TOKEN_VALUE = '' + let lz_jdpin_token = '' + let setcookies = resp && resp['headers'] && (resp['headers']['set-cookie'] || resp['headers']['Set-Cookie'] || '') || '' + let setcookie = '' + if(setcookies){ + if(typeof setcookies != 'object'){ + setcookie = setcookies.split(',') + }else setcookie = setcookies + for (let ck of setcookie) { + let name = ck.split(";")[0].trim() + if(name.split("=")[1]){ + // console.log(name.replace(/ /g,'')) + if(name.indexOf('LZ_TOKEN_KEY=')>-1) LZ_TOKEN_KEY = name.replace(/ /g,'')+';' + if(name.indexOf('LZ_TOKEN_VALUE=')>-1) LZ_TOKEN_VALUE = name.replace(/ /g,'')+';' + if(name.indexOf('lz_jdpin_token=')>-1) lz_jdpin_token = ''+name.replace(/ /g,'')+';' + } + } + } + if(LZ_TOKEN_KEY && LZ_TOKEN_VALUE) activityCookie = `${LZ_TOKEN_KEY} ${LZ_TOKEN_VALUE}` + if(lz_jdpin_token) lz_jdpin_token_cookie = lz_jdpin_token +} + +async function getUA(){ + $.UA = `jdapp;iPhone;10.1.4;13.1.2;${randomString(40)};network/wifi;model/iPhone8,1;addressid/2308460611;appBuild/167814;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_1_2 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 joinShop() { + if(!$.joinVenderId) return + return new Promise(async resolve => { + $.shopactivityId = '' + await $.wait(1000) + await getshopactivityId() + let activityId = `` + if($.shopactivityId) activityId = `,"activityId":${$.shopactivityId}` + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body={"venderId":"${$.joinVenderId}","shopId":"${$.joinVenderId}","bindByVerifyCodeFlag":1,"registerExtend":{},"writeChildFlag":0${activityId},"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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + // console.log(data) + let res = $.toObj(data); + if(typeof res == 'object'){ + if(res.success === true){ + console.log(res.message) + if(res.result && res.result.giftInfo){ + for(let i of res.result.giftInfo.giftList){ + console.log(`入会获得:${i.discountString}${i.prizeName}${i.secondLineDesc}`) + } + } + }else if(typeof res == 'object' && res.message){ + console.log(`${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function getshopactivityId() { + return new Promise(resolve => { + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body=%7B%22venderId%22%3A%22${$.joinVenderId}%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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + let res = $.toObj(data); + if(res.success == true){ + // console.log($.toStr(res.result)) + console.log(`入会:${res.result.shopMemberCardInfo.venderCardName || ''}`) + $.shopactivityId = res.result.interestsRuleList && res.result.interestsRuleList[0] && res.result.interestsRuleList[0].interestsInfo && res.result.interestsRuleList[0].interestsInfo.activityId || '' + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} + + +// 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)} + diff --git a/activity/jd_opencard99.js b/activity/jd_opencard99.js new file mode 100644 index 0000000..42750eb --- /dev/null +++ b/activity/jd_opencard99.js @@ -0,0 +1,551 @@ +/* +1.8~1.15 联合开卡-99 +新增开卡脚本,一次性脚本 + +1.邀请一人20豆(有可能没有豆 +2.开12张 成功开1张 可能获得5京豆 + 全部开完获得1次抽奖 +3.关注10京豆 获得1次抽奖 +4.加购5京豆 获得1次抽奖 +5.抽奖 + +第一个账号助力作者 其他依次助力CK1 +第一个CK失效会退出脚本 + +———————————————— +入口:[ 1.8~1.15 联合开卡 (https://3.cn/104c6-0Gl)] + +请求太频繁会被黑ip +过10分钟再执行 + + +cron:50 1,13 8-15 1 * +============Quantumultx=============== +[task_local] +#1.8~1.15 联合开卡 +50 1,13 8-15 1 * jd_opencard99.js, tag=1.8~1.15 联合开卡, enabled=true + +*/ +const $ = new Env('1.8~1.15 联合开卡'); +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const notify = $.isNode() ? require('./sendNotify') : ''; + +//IOS等用户直接用NobyDa的jd cookie +let cookiesArr = [], + cookie = ''; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} +allMessage = "" +message = "" +$.hotFlag = false +$.outFlag = false +$.activityEnd = false +let lz_jdpin_token_cookie ='' +let activityCookie ='' +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', { + "open-url": "https://bean.m.jd.com/" + }); + return; + } + // return + $.appkey = '51B59BB805903DA4CE513D29EC448375' + $.userId = '10299171' + $.actId = '7cc0fa6c45b8450_220108' + $.MixNicks = '' + $.inviteNick = 'k1Nobb+P0er+C2sysxnx/P2KELO9izRVpwCyqu0eqVZ5aW7RHzlMobrzJ/e9r/uf' + console.log(`活动地址:https://3.cn/104c6-0Gl`) + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i]; + if (cookie) { + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + message = "" + $.bean = 0 + $.hotFlag = false + $.nickName = ''; + console.log(`\n\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + await getUA() + await run(); + if(i == 0 && !$.MixNick) break + if($.outFlag || $.activityEnd) break + } + } + if($.outFlag) { + let msg = '此ip已被限制,请过10分钟后再执行脚本' + $.msg($.name, ``, `${msg}`); + if ($.isNode()) await notify.sendNotify(`${$.name}`, `${msg}`); + } +})() + .catch((e) => $.logErr(e)) + .finally(() => $.done()) + + +async function run() { + try { + $.hasEnd = true + $.endTime = 0 + lz_jdpin_token_cookie = '' + $.Token = '' + $.Pin = '' + $.MixNick = '' + let flag = false + if($.activityEnd) return + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + await takePostRequest('isvObfuscator'); + if($.Token == ''){ + console.log('获取[token]失败!') + return + } + await takePostRequest('activity_load'); + if($.hotFlag) return + if(Date.now() > $.endTime){ + $.MixNick = '' + $.activityEnd = true + console.log('活动结束') + return + } + if ($.MixNick == '') { + console.log(`获取cookie失败`); return; + } + // console.log($.MixNick) + // return + $.toBind = 0 + $.openList = [] + await takePostRequest('绑定'); + await takePostRequest('shopList'); + if($.activityEnd) return + for(o of $.openList){ + $.missionType = 'openCard' + if(o.open != true && o.openCardUrl){ + if($.activityEnd) return + $.openCard = false + $.joinVenderId = o.userId + await takePostRequest('mission'); + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + if($.openCard == true){ + await joinShop() + await takePostRequest('activity_load'); + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + // break + } + $.joinVenderId = '' + } + } + $.joinVenderId = '' + if($.hasCollectShop === 0){ + // 关注 + $.missionType = 'uniteCollectShop' + await takePostRequest('mission'); + await $.wait(parseInt(Math.random() * 2000 + 3000, 10)) + }else{ + console.log('已经关注') + } + $.missionType = 'uniteAddCart' + await takePostRequest('mission'); + await $.wait(parseInt(Math.random() * 2000 + 3000, 10)) + await takePostRequest('activity_load'); + $.runFalag = true + let count = parseInt($.usedChance, 10) + console.log(`抽奖次数为:${count}`) + for(m=1;count--;m++){ + console.log(`第${m}次抽奖`) + await takePostRequest('抽奖'); + if($.runFalag == false) break + if(Number(count) <= 0) break + if(m >= 10){ + console.log("抽奖太多次,多余的次数请再执行脚本") + break + } + await $.wait(parseInt(Math.random() * 2000 + 2000, 10)) + } + await takePostRequest('myAward'); + await takePostRequest('missionInviteList'); + console.log($.MixNick) + console.log(`当前助力:${$.inviteNick}`) + if($.index == 1){ + $.inviteNick = $.MixNick + console.log(`后面的号都会助力:${$.inviteNick}`) + } + await $.wait(parseInt(Math.random() * 1000 + 5000, 10)) + if(flag) await $.wait(parseInt(Math.random() * 1000 + 10000, 10)) + if($.index % 3 == 0) console.log('休息1分钟,别被黑ip了\n可持续发展') + if($.index % 3 == 0) await $.wait(parseInt(Math.random() * 5000 + 60000, 10)) + } catch (e) { + console.log(e) + } +} + +async function takePostRequest(type) { + if($.outFlag) return + let domain = 'https://jinggengjcq-isv.isvjcloud.com'; + let body = ``; + let method = 'POST' + let admJson = '' + switch (type) { + case 'isvObfuscator': + url = `https://api.m.jd.com/client.action?functionId=isvObfuscator`; + body = `body=%7B%22url%22%3A%22https%3A//jinggengjcq-isv.isvjcloud.com/fronth5/%3Flng%3D0%26lat%3D0%26sid%3D49687cd64aca2ae93aa43748a04e8f6w%26un_area%3D16_1315_1316_53522%23/pages/unitedCardNew20211010-ka/unitedCardNew20211010-ka%3FactId%3D9150e1d16b9d40_10101%22%2C%22id%22%3A%22%22%7D&uuid=b9b4ce69d42dacb64084279d51cdee764d7781fa&client=apple&clientVersion=10.1.4&st=1634100732991&sv=111&sign=67e254ffbcb13be9e12a9782c9cdf398`; + break; + case 'activity_load': + url = `${domain}/dm/front/openCardNew/activity_load?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"jdToken": $.Token, "source": "01", "inviteNick":($.inviteNick || "")} + if($.joinVenderId) admJson = {...admJson, "shopId": `${$.joinVenderId}`} + body = taskPostUrl("/openCardNew/activity_load", admJson); + break; + case 'shopList': + url = `${domain}/dm/front/openCardNew/shopList?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {} + body = taskPostUrl("/openCardNew/shopList", admJson); + break; + case '绑定': + url = `${domain}/dm/front/openCardNew/complete/mission?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"missionType": "relationBind", "inviterNick":($.inviteNick || "")} + body = taskPostUrl("/openCardNew/complete/mission", admJson); + break; + case 'mission': + url = `${domain}/dm/front/openCardNew/complete/mission?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"missionType": $.missionType} + if($.joinVenderId) admJson = {...admJson, "shopId": $.joinVenderId} + body = taskPostUrl("/openCardNew/complete/mission", admJson); + break; + case '抽奖': + url = `${domain}/dm/front/openCardNew/draw/post?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"dataType": "draw", "usedGameNum": "2"} + body = taskPostUrl("/openCardNew/draw/post", admJson); + break; + case 'followShop': + url = `${domain}/dm/front/openCardNew/followShop?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"actId": $.actId, "missionType": "collectShop"} + body = taskPostUrl("/openCardNew/followShop", admJson); + break; + case 'addCart': + url = `${domain}/dm/front/openCardNew/addCart?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"actId": $.actId, "missionType": "addCart"} + body = taskPostUrl("/openCardNew/addCart", admJson); + break; + case 'myAward': + url = `${domain}/dm/front/openCardNew/myAwards?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"pageNo": 1,"pageSize":9999} + body = taskPostUrl("/openCardNew/myAwards", admJson); + break; + case 'missionInviteList': + url = `${domain}/dm/front/openCardNew/missionInviteList?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"inviteListRequest":{"actId":$.actId,"userId":10299171,"missionType":"shareAct","inviteType": 1,"buyerNick":($.MixNick || '')}} + body = taskPostUrl("/openCardNew/missionInviteList", admJson); + break; + default: + console.log(`错误${type}`); + } + let myRequest = getPostRequest(url, body, method); + return new Promise(async resolve => { + $.post(myRequest, (err, resp, data) => { + try { + if (err) { + if(resp && resp.statusCode && resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + console.log(`${$.toStr(err,err)}`) + console.log(`${type} API请求失败,请检查网路重试`) + } else { + dealReturn(type, data); + } + } catch (e) { + // console.log(data); + console.log(e, resp) + } finally { + resolve(); + } + }) + }) + } + +async function dealReturn(type, data) { + let res = '' + try { + if(type != 'accessLogWithAD' || type != 'drawContent'){ + if(data){ + res = JSON.parse(data); + } + } + } catch (e) { + console.log(`${type} 执行任务异常`); + console.log(data); + $.runFalag = false; + } + try { + let title = '' + switch (type) { + case 'isvObfuscator': + if(typeof res == 'object'){ + if(res.errcode == 0){ + if(typeof res.token != 'undefined') $.Token = res.token + }else if(res.message){ + console.log(`${type} ${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + break; + case 'accessLogWithAD': + case 'drawContent': + break; + case 'activity_load': + case 'mission': + case 'shopList': + case 'loadUniteOpenCard': + case 'setMixNick': + case 'uniteOpenCardOne': + case 'checkOpenCard': + case 'followShop': + case 'addCart': + case 'myAward': + case 'missionInviteList': + case '抽奖': + title = '' + if(type == "followShop") title = '关注' + if(type == "addCart") title = '加购' + if(typeof res == 'object'){ + if(res.success && res.success === true && res.data){ + if(res.data.status && res.data.status == 200){ + res = res.data + if(type != "setMixNick" && (res.msg || res.data.isOpenCard || res.data.remark)) console.log(`${title && title+":" || ""}${res.msg || res.data.isOpenCard || res.data.remark || ''}`) + if(type == "activity_load"){ + if(res.msg || res.data.isOpenCard) { + if((res.msg || res.data.isOpenCard || '').indexOf('绑定成功') > -1) $.toBind = 1 + } + if(res.data){ + $.endTime = res.data.cusActivity.endTime || 0 + $.MixNick = res.data.buyerNick || "" + $.usedChance = res.data.missionCustomer.usedChance || 0 + $.hasCollectShop = res.data.missionCustomer.hasCollectShop || 0 + } + }else if(type == "shopList"){ + $.openList = res.data.cusShops || [] + }else if(type == "mission"){ + if(res.data.remark.indexOf('不是会员') > -1){ + $.openCard = true + }else{ + $.openCard = false + } + }else if(type == "uniteOpenCardOne"){ + $.uniteOpenCar = res.msg || res.data.msg || '' + }else if(type == "myAward"){ + console.log(`我的奖品:`) + let num = 0 + let value = 0 + for(let i in res.data.list || []){ + let item = res.data.list[i] + if(item.awardDes == '20'){ + num++ + value = item.awardDes + }else{ + console.log(`${item.awardName}`) + } + } + if(num > 0) console.log(`邀请好友(${num}):${num*parseInt(value, 10) || 30}京豆`) + }else if(type == "missionInviteList"){ + console.log(`邀请人数(${res.data.invitedLogList.total})`) + } + }else if(res.data.msg){ + if(res.errorMessage.indexOf('活动未开始') >-1 ){ + $.activityEnd = true + } + console.log(`${title || type} ${res.data.msg || ''}`) + }else if(res.errorMessage){ + if(res.errorMessage.indexOf('火爆') >-1 ){ + $.hotFlag = true + } + console.log(`${title || type} ${res.errorMessage || ''}`) + }else{ + console.log(`${title || type} ${data}`) + } + }else if(res.errorMessage){ + console.log(`${title || type} ${res.errorMessage || ''}`) + }else{ + console.log(`${title || type} ${data}`) + } + }else{ + console.log(`${title || type} ${data}`) + } + break; + default: + console.log(`${title || type}-> ${data}`); + } + if(typeof res == 'object'){ + if(res.errorMessage){ + if(res.errorMessage.indexOf('火爆') >-1 ){ + $.hotFlag = true + } + } + } + } catch (e) { + console.log(e) + } +} + +function getPostRequest(url, body, method="POST") { + let headers = { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Content-Type": "application/x-www-form-urlencoded", + "Cookie": cookie, + "User-Agent": $.UA, + "X-Requested-With": "XMLHttpRequest" + } + if(url.indexOf('https://jinggengjcq-isv.isvjcloud.com') > -1){ + headers["Origin"] = `https://jinggengjcq-isv.isvjcloud.com` + headers["Content-Type"] = `application/json; charset=utf-8` + delete headers["Cookie"] + } + // console.log(headers) + // console.log(headers.Cookie) + return {url: url, method: method, headers: headers, body: body, timeout:60000}; +} + + +function taskPostUrl(url, t) { + + const b = { + "jsonRpc": "2.0", + "params": { + "commonParameter": { + "appkey": $.appkey, + "m": "POST", + "timestamp": Date.now(), + "userId": $.userId + }, + "admJson": { + "actId": $.actId, + "userId": $.userId, + ...t, + "method": url, + "buyerNick": ($.MixNick || ''), + } + }, + } + if(url.indexOf('missionInviteList') > -1){ + delete b.params.admJson.actId + } + return $.toStr(b,b) +} +async function getUA(){ + $.UA = `jdapp;iPhone;10.1.4;13.1.2;${randomString(40)};network/wifi;model/iPhone8,1;addressid/2308460611;appBuild/167814;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_1_2 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 jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} + +function joinShop() { + if(!$.joinVenderId) return + return new Promise(async resolve => { + $.shopactivityId = '' + await $.wait(1000) + await getshopactivityId() + let activityId = `` + if($.shopactivityId) activityId = `,"activityId":${$.shopactivityId}` + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body={"venderId":"${$.joinVenderId}","shopId":"${$.joinVenderId}","bindByVerifyCodeFlag":1,"registerExtend":{},"writeChildFlag":0${activityId},"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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + // console.log(data) + let res = $.toObj(data); + if(typeof res == 'object'){ + if(res.success === true){ + console.log(res.message) + if(res.result && res.result.giftInfo){ + for(let i of res.result.giftInfo.giftList){ + console.log(`入会获得:${i.discountString}${i.prizeName}${i.secondLineDesc}`) + } + } + }else if(typeof res == 'object' && res.message){ + console.log(`${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function getshopactivityId() { + return new Promise(resolve => { + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body=%7B%22venderId%22%3A%22${$.joinVenderId}%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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + let res = $.toObj(data); + if(res.success == true){ + // console.log($.toStr(res.result)) + console.log(`入会:${res.result.shopMemberCardInfo.venderCardName || ''}`) + $.shopactivityId = res.result.interestsRuleList && res.result.interestsRuleList[0] && res.result.interestsRuleList[0].interestsInfo && res.result.interestsRuleList[0].interestsInfo.activityId || '' + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +// 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)} + diff --git a/activity/jd_opencardL34.js b/activity/jd_opencardL34.js new file mode 100644 index 0000000..8be9e94 --- /dev/null +++ b/activity/jd_opencardL34.js @@ -0,0 +1,739 @@ +/* +12.18~12.30 京选大牌 超会宠你 [jd_opencardL34.js] +开卡脚本,一次性脚本 + +1.邀请一人20豆 +2.开2组(共6张) 成功开1组 获得1次抽奖 +3.加购5京豆 +4.浏览店铺1豆/个 +5.浏览商品1豆/个 + +第一个账号助力作者 其他依次助力CK1 +第一个CK失效会退出脚本 +———————————————— +入口:[ 12.18~12.30 京选大牌 超会宠你 (https://lzdz1-isv.isvjcloud.com/dingzhi/dz/openCard/activity?activityId=4c1162ed00874ba5ac0447c30cc45f8a&shareUuid=2f706963fc8a4477b18bc3bccd266dcb)] + +请求太频繁会被黑ip +过10分钟再执行 + +cron:40 1,6 23-30 12 * +============Quantumultx=============== +[task_local] +#12.18~12.30 京选大牌 超会宠你 +40 1,6 23-30 12 * https://raw.githubusercontent.com/KingRan/JDJB/main/jd_opencardL34.js, tag=12.18~12.30 京选大牌 超会宠你, enabled=true + +*/ +const $ = new Env('12.18~12.30 京选大牌 超会宠你'); +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const notify = $.isNode() ? require('./sendNotify') : ''; +//IOS等用户直接用NobyDa的jd cookie + +let cookiesArr = [], + cookie = ''; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} + +allMessage = "" +message = "" +$.hotFlag = false +$.outFlag = false +$.activityEnd = false +let lz_jdpin_token_cookie ='' +let activityCookie ='' +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', { + "open-url": "https://bean.m.jd.com/" + }); + return; + } + $.activityId = "4c1162ed00874ba5ac0447c30cc45f8a" + $.shareUuid = "2f706963fc8a4477b18bc3bccd266dcb" + console.log(`入口:\nhttps://lzdz1-isv.isvjcloud.com/dingzhi/dz/openCard/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}`) + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i]; + if (cookie) { + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + message = "" + $.bean = 0 + $.hotFlag = false + $.nickName = ''; + console.log(`\n\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + await getUA() + await run(); + if(i == 0 && !$.actorUuid) break + if($.outFlag || $.activityEnd) break + } + } + if($.outFlag) { + let msg = '此ip已被限制,请过10分钟后再执行脚本' + $.msg($.name, ``, `${msg}`); + if ($.isNode()) await notify.sendNotify(`${$.name}`, `${msg}`); + } +})() + .catch((e) => $.logErr(e)) + .finally(() => $.done()) + + +async function run() { + try { + $.hasEnd = true + $.endTime = 0 + lz_jdpin_token_cookie = '' + $.Token = '' + $.Pin = '' + let flag = false + await takePostRequest('isvObfuscator'); + if($.Token == ''){ + console.log('获取[token]失败!') + return + } + await getCk() + if (activityCookie == '') { + console.log(`获取cookie失败`); return; + } + if($.activityEnd === true){ + console.log('活动结束') + return + } + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + await takePostRequest('getSimpleActInfoVo'); + await takePostRequest('getMyPing'); + if(!$.Pin){ + console.log('获取[Pin]失败!') + return + } + await takePostRequest('accessLogWithAD'); + await takePostRequest('getUserInfo'); + await takePostRequest('activityContent'); + if($.hotFlag) return + if(!$.actorUuid){ + console.log('获取不到[actorUuid]退出执行,请重新执行') + return + } + if($.hasEnd === true || Date.now() > $.endTime){ + $.activityEnd = true + console.log('活动结束') + return + } + await takePostRequest('drawContent'); + await $.wait(1000) + $.openList = [] + $.allOpenCard = false + await takePostRequest('checkOpenCard'); + if($.allOpenCard == false){ + console.log('开卡任务') + for(o of $.openList){ + $.openCard = false + if(o.status == 0){ + flag = true + $.joinVenderId = o.value + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + await joinShop() + await $.wait(parseInt(Math.random() * 1000 + 1000, 10)) + await takePostRequest('drawContent'); + await takePostRequest('checkOpenCard'); + await $.wait(parseInt(Math.random() * 3000 + 2000, 10)) + } + } + await takePostRequest('activityContent'); + }else{ + console.log('已全部开卡') + } + if($.openCardScore1 == 1 && !$.outFlag){ + $.startDraw = 1 + flag = true + await takePostRequest('startDraw'); + await $.wait(parseInt(Math.random() * 1000 + 3000, 10)) + } + if($.openCardScore2 == 1 && !$.outFlag){ + $.startDraw = 2 + flag = true + await takePostRequest('startDraw'); + await $.wait(parseInt(Math.random() * 1000 + 3000, 10)) + } + + $.log("加购: " + $.addSku) + + if(!$.addSku && !$.outFlag){ + flag = true + await takePostRequest('addSku'); + await $.wait(parseInt(Math.random() * 1000 + 5000, 10)) + + } + $.runFalag = true + $.log("浏览店铺: " + $.toShop) + if(!$.toShop && !$.outFlag){ + flag = true + for(let v of $.toShopList || []){ + if($.runFalag == false) break + if(v.value && v.status === 0){ + $.toShopValue = v.value + await takePostRequest('toShop'); + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + } + } + } + $.runFalag = true + $.log("浏览商品: " + $.visitSku) + if(!$.visitSku && !$.outFlag){ + flag = true + for(let v of $.visitSkuList || []){ + if($.runFalag == false) break + if(v.value && v.status === 0){ + $.visitSkuValue = v.value + await takePostRequest('visitSku'); + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + } + } + } + if(flag){ + await takePostRequest('activityContent'); + } + await $.wait(parseInt(Math.random() * 1000 + 2000, 10)) + await takePostRequest('getDrawRecordHasCoupon'); + await takePostRequest('getShareRecord'); + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + console.log($.actorUuid) + console.log(`当前助力:${$.shareUuid}`) + if($.index == 1){ + $.shareUuid = $.actorUuid + console.log(`后面的号都会助力:${$.shareUuid}`) + } + await $.wait(parseInt(Math.random() * 1000 + 5000, 10)) + if(flag) await $.wait(parseInt(Math.random() * 1000 + 10000, 10)) + + if($.index % 3 == 0) console.log('休息1分钟,别被黑ip了\n可持续发展') + if($.index % 3 == 0) await $.wait(parseInt(Math.random() * 5000 + 60000, 10)) + + } catch (e) { + console.log(e) + } +} + +async function takePostRequest(type) { + if($.outFlag) return + let domain = 'https://lzdz1-isv.isvjcloud.com'; + let body = ``; + let method = 'POST' + let admJson = '' + switch (type) { + case 'isvObfuscator': + url = `https://api.m.jd.com/client.action?functionId=isvObfuscator`; + body = `body=%7B%22url%22%3A%22https%3A//lzdz1-isv.isvjcloud.com%22%2C%22id%22%3A%22%22%7D&uuid=0846724fe8d803b8e84ebd14b3ba7fac6df80e7a&client=apple&clientVersion=10.1.4&st=1634616247215&sv=120&sign=91a16ae2feb0bd0e1ea48d99e7953c58`; + break; + case 'getSimpleActInfoVo': + url = `${domain}/dz/common/getSimpleActInfoVo`; + body = `activityId=${$.activityId}`; + break; + case 'getMyPing': + url = `${domain}/customer/getMyPing`; + body = `userId=${$.shopId || $.venderId || ''}&token=${$.Token}&fromType=APP`; + break; + case 'accessLogWithAD': + url = `${domain}/common/accessLogWithAD`; + let pageurl = `${domain}/drawCenter/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}` + body = `venderId=${$.shopId || $.venderId || ''}&code=99&pin=${encodeURIComponent($.Pin)}&activityId=${$.activityId}&pageUrl=${encodeURIComponent(pageurl)}&subType=app&adSource=` + break; + case 'getUserInfo': + url = `${domain}/wxActionCommon/getUserInfo`; + body = `pin=${encodeURIComponent($.Pin)}`; + break; + case 'activityContent': + url = `${domain}/dingzhi/dz/openCard/activityContent`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&pinImg=${encodeURIComponent($.attrTouXiang)}&nick=${encodeURIComponent($.nickname)}&cjyxPin=&cjhyPin=&shareUuid=${$.shareUuid}` + break; + case 'drawContent': + url = `${domain}/dingzhi/taskact/openCardcommon/drawContent`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case 'checkOpenCard': + url = `${domain}/dingzhi/dz/openCard/checkOpenCard`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&shareUuid=${$.shareUuid}` + break; + case 'startDraw': + url = `${domain}/dingzhi/dz/openCard/startDraw`; + body = `activityId=${$.activityId}&actorUuid=${$.actorUuid}&pin=${encodeURIComponent($.Pin)}${$.startDraw && '&type='+$.startDraw || ''}` + break; + case 'followShop': + url = `${domain}/dingzhi/dz/openCard/followShop`; + // url = `${domain}/dingzhi/dz/openCard/saveTask`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&shareUuid=${$.shareUuid}&taskType=23&taskValue=${$.followShopValue}` + break; + case 'viewVideo': + case 'visitSku': + case 'toShop': + case 'addSku': + url = `${domain}/dingzhi/dz/openCard/saveTask`; + let taskType = '' + let taskValue = '' + if(type == 'viewVideo'){ + taskType = 31 + taskValue = 31 + }else if(type == 'visitSku'){ + taskType = 5 + taskValue = $.visitSkuValue || 5 + }else if(type == 'toShop'){ + taskType = 14 + taskValue = $.toShopValue || 14 + }else if(type == 'addSku'){ + taskType = 2 + taskValue = $.addSkuValue || 2 + } + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&taskType=${taskType}&taskValue=${taskValue}` + break; + case 'getDrawRecordHasCoupon': + url = `${domain}/dingzhi/taskact/openCardcommon/getDrawRecordHasCoupon`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case 'getShareRecord': + url = `${domain}/dingzhi/taskact/openCardcommon/getShareRecord`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + default: + console.log(`错误${type}`); + } + let myRequest = getPostRequest(url, body, method); + // console.log(myRequest) + return new Promise(async resolve => { + $.post(myRequest, (err, resp, data) => { + try { + setActivityCookie(resp) + if (err) { + if(resp && typeof resp.statusCode != 'undefined'){ + if(resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + } + console.log(`${$.toStr(err,err)}`) + console.log(`${type} API请求失败,请检查网路重试`) + } else { + dealReturn(type, data); + } + } catch (e) { + // console.log(data); + console.log(e, resp) + } finally { + resolve(); + } + }) + }) + } + +async function dealReturn(type, data) { + let res = '' + try { + if(type != 'accessLogWithAD' || type != 'drawContent'){ + if(data){ + res = JSON.parse(data); + } + } + } catch (e) { + console.log(`${type} 执行任务异常`); + console.log(data); + $.runFalag = false; + } + try { + switch (type) { + case 'isvObfuscator': + if(typeof res == 'object'){ + if(res.errcode == 0){ + if(typeof res.token != 'undefined') $.Token = res.token + }else if(res.message){ + console.log(`isvObfuscator ${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + break; + case 'getSimpleActInfoVo': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(typeof res.data.shopId != 'undefined') $.shopId = res.data.shopId + if(typeof res.data.venderId != 'undefined') $.venderId = res.data.venderId + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getMyPing': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(res.data && typeof res.data.secretPin != 'undefined') $.Pin = res.data.secretPin + if(res.data && typeof res.data.nickname != 'undefined') $.nickname = res.data.nickname + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getUserInfo': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(res.data && typeof res.data.yunMidImageUrl != 'undefined') $.attrTouXiang = res.data.yunMidImageUrl || "https://img10.360buyimg.com/imgzone/jfs/t1/7020/27/13511/6142/5c5138d8E4df2e764/5a1216a3a5043c5d.png" + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'activityContent': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + $.endTime = res.data.endTime || 0 + $.hasEnd = res.data.hasEnd || false + $.actorUuid = res.data.actorUuid || '' + // $.followShop = res.data.followShop.allStatus || false + $.addSku = res.data.addSku.allStatus || false + if(res.data.followShop && res.data.followShop.settings && res.data.followShop.settings[0]){ + $.followShopValue = res.data.followShop.settings[0].value || 1 + } + if(res.data.addSku && res.data.addSku.settings && res.data.addSku.settings[0]){ + $.addSkuValue = res.data.addSku.settings[0].value || 2 + } + $.toShop = res.data.toShop.allStatus || false + $.toShopList = res.data.toShop.settings || [] + $.visitSku = res.data.visitSku.allStatus || false + $.visitSkuList = res.data.visitSku.settings || [] + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'checkOpenCard': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + let cardList1 = res.data.cardList1 || [] + let cardList2 = res.data.cardList2 || [] + let cardList = res.data.cardList || [] + $.openList = [...cardList,...cardList1,...cardList2] + $.allOpenCard = res.data.allOpenCard || false + $.openCardScore1 = res.data.score1 || 0 + $.openCardScore2 = res.data.score2 || 0 + $.drawScore = res.data.drawScore || 0 + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'startDraw': + case 'followShop': + case 'viewVideo': + case 'visitSku': + case 'toShop': + case 'addSku': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(typeof res.data == 'object'){ + let msg = '' + let title = '抽奖' + if(res.data.addBeanNum && res.data.sendStatus){ + msg = `${res.data.addBeanNum}京豆` + } + if(type == 'followShop'){ + title = '关注' + if(res.data.beanNumMember && res.data.assistSendStatus){ + msg += ` 额外获得:${res.data.beanNumMember}京豆` + } + }else if(type == 'addSku'){ + title = '加购' + }else if(type == 'viewVideo'){ + title = '热门文章' + }else if(type == 'toShop'){ + title = '浏览店铺' + }else if(type == 'visitSku'){ + title = '浏览商品' + }else{ + msg = res.data.drawOk == true && (res.data.drawInfoType == 6 && res.data.name || '') || '空气💨' + } + if(!msg){ + msg = '空气💨' + } + console.log(`${title}获得:${msg || data}`) + }else{ + console.log(`${type} ${data}`) + } + }else if(res.errorMessage){ + $.runFalag = false; + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getDrawRecordHasCoupon': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + console.log(`我的奖品:`) + let num = 0 + let value = 0 + for(let i in res.data){ + let item = res.data[i] + if(item.value == '邀请好友') num++; + if(item.value == '邀请好友') value = item.infoName.replace('京豆',''); + if(item.value != '邀请好友') console.log(`${item.infoType != 10 && item.value +':' || ''}${item.infoName}`) + } + if(num > 0) console.log(`邀请好友(${num}):${num*parseInt(value, 10) || 30}京豆`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getShareRecord': + if(typeof res == 'object'){ + if(res.result && res.result === true && res.data){ + $.ShareCount = res.data.length + $.log(`=========== 你邀请了:${res.data.length}个`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'accessLogWithAD': + case 'drawContent': + break; + default: + console.log(`${type}-> ${data}`); + } + if(typeof res == 'object'){ + if(res.errorMessage){ + if(res.errorMessage.indexOf('火爆') >-1 ){ + $.hotFlag = true + } + } + } + } catch (e) { + console.log(e) + } +} + +function getPostRequest(url, body, method="POST") { + let headers = { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Content-Type": "application/x-www-form-urlencoded", + "Cookie": cookie, + "User-Agent": $.UA, + "X-Requested-With": "XMLHttpRequest" + } + if(url.indexOf('https://lzdz1-isv.isvjcloud.com') > -1){ + headers["Referer"] = `https://lzdz1-isv.isvjcloud.com/dingzhi/dz/openCard/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}` + headers["Cookie"] = `${lz_jdpin_token_cookie && lz_jdpin_token_cookie || ''}${$.Pin && "AUTH_C_USER=" + $.Pin + ";" || ""}${activityCookie}` + } + // console.log(headers) + // console.log(headers.Cookie) + return {url: url, method: method, headers: headers, body: body, timeout:30000}; +} + +function getCk() { + return new Promise(resolve => { + let get = { + url:`https://lzdz1-isv.isvjcloud.com/dingzhi/dz/openCard/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}`, + followRedirect:false, + headers: { + "User-Agent": $.UA, + }, + timeout:30000 + } + $.get(get, async(err, resp, data) => { + try { + if (err) { + if(resp && typeof resp.statusCode != 'undefined'){ + if(resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + } + console.log(`${$.toStr(err)}`) + console.log(`${$.name} cookie API请求失败,请检查网路重试`) + } else { + let end = data.match(/(活动已经结束)/) && data.match(/(活动已经结束)/)[1] || '' + if(end){ + $.activityEnd = true + console.log('活动已结束') + } + setActivityCookie(resp) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function setActivityCookie(resp){ + let LZ_TOKEN_KEY = '' + let LZ_TOKEN_VALUE = '' + let lz_jdpin_token = '' + let setcookies = resp && resp['headers'] && (resp['headers']['set-cookie'] || resp['headers']['Set-Cookie'] || '') || '' + let setcookie = '' + if(setcookies){ + if(typeof setcookies != 'object'){ + setcookie = setcookies.split(',') + }else setcookie = setcookies + for (let ck of setcookie) { + let name = ck.split(";")[0].trim() + if(name.split("=")[1]){ + // console.log(name.replace(/ /g,'')) + if(name.indexOf('LZ_TOKEN_KEY=')>-1) LZ_TOKEN_KEY = name.replace(/ /g,'')+';' + if(name.indexOf('LZ_TOKEN_VALUE=')>-1) LZ_TOKEN_VALUE = name.replace(/ /g,'')+';' + if(name.indexOf('lz_jdpin_token=')>-1) lz_jdpin_token = ''+name.replace(/ /g,'')+';' + } + } + } + if(LZ_TOKEN_KEY && LZ_TOKEN_VALUE) activityCookie = `${LZ_TOKEN_KEY} ${LZ_TOKEN_VALUE}` + if(lz_jdpin_token) lz_jdpin_token_cookie = lz_jdpin_token +} + +async function getUA(){ + $.UA = `jdapp;iPhone;10.1.4;13.1.2;${randomString(40)};network/wifi;model/iPhone8,1;addressid/2308460611;appBuild/167814;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_1_2 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 joinShop() { + if(!$.joinVenderId) return + return new Promise(async resolve => { + $.shopactivityId = '' + await $.wait(1000) + await getshopactivityId() + let activityId = `` + if($.shopactivityId) activityId = `,"activityId":${$.shopactivityId}` + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body={"venderId":"${$.joinVenderId}","shopId":"${$.joinVenderId}","bindByVerifyCodeFlag":1,"registerExtend":{},"writeChildFlag":0${activityId},"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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + // console.log(data) + let res = $.toObj(data); + if(typeof res == 'object'){ + if(res.success === true){ + console.log(res.message) + if(res.result && res.result.giftInfo){ + for(let i of res.result.giftInfo.giftList){ + console.log(`入会获得:${i.discountString}${i.prizeName}${i.secondLineDesc}`) + } + } + }else if(typeof res == 'object' && res.message){ + console.log(`${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function getshopactivityId() { + return new Promise(resolve => { + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body=%7B%22venderId%22%3A%22${$.joinVenderId}%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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + let res = $.toObj(data); + if(res.success == true){ + // console.log($.toStr(res.result)) + console.log(`入会:${res.result.shopMemberCardInfo.venderCardName || ''}`) + $.shopactivityId = res.result.interestsRuleList && res.result.interestsRuleList[0] && res.result.interestsRuleList[0].interestsInfo && res.result.interestsRuleList[0].interestsInfo.activityId || '' + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} + + +// 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)} diff --git a/activity/jd_opencardL35.js b/activity/jd_opencardL35.js new file mode 100644 index 0000000..539ad47 --- /dev/null +++ b/activity/jd_opencardL35.js @@ -0,0 +1,797 @@ +/* +12.23~1.9 双旦寻宝 玩转大富翁-3 [jd_opencardL35.js] +开卡脚本,一次性脚本 + +1.邀请一人5豆 +2.开9张卡 成功开1张 获得10豆 + 开通所有可抽奖1次 可能获得5/10/888京豆 +3.关注5豆 +4.抽奖 + +第一个账号助力作者 其他依次助力CK1 +第一个CK失效会退出脚本 +———————————————— +入口:[ 12.23~1.9 双旦寻宝 玩转大富翁-3 (https://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity/5573104?activityId=dfw20211223pe3g4e1zh97m5m&shareUuid=0639a5497919410eab32e272af566626)] + +请求太频繁会被黑ip +过10分钟再执行 + +cron:50 0,9 23-31,1-9 12,1 * +============Quantumultx=============== +[task_local] +#12.23~1.9 双旦寻宝 玩转大富翁-3 +50 0,9 23-31,1-9 12,1 * https://raw.githubusercontent.com/KingRan/JDJB/main/jd_opencardL35.js, tag=12.23~1.9 双旦寻宝 玩转大富翁-3, enabled=true + +*/ + +const $ = new Env('12.23~1.9 双旦寻宝 玩转大富翁-3'); +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const notify = $.isNode() ? require('./sendNotify') : ''; +//IOS等用户直接用NobyDa的jd cookie + +let cookiesArr = [], + cookie = ''; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} + +allMessage = "" +message = "" +$.hotFlag = false +$.outFlag = false +$.activityEnd = false +let lz_jdpin_token_cookie ='' +let activityCookie ='' +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', { + "open-url": "https://bean.m.jd.com/" + }); + return; + } + $.activityId = "dfw20211223pe3g4e1zh97m5m" + $.shareUuid = "0639a5497919410eab32e272af566626" + console.log(`入口:\nhttps://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}`) + + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i]; + if (cookie) { + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + message = "" + $.bean = 0 + $.hotFlag = false + $.nickName = ''; + console.log(`\n\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + await getUA() + await run(); + if(i == 0 && !$.actorUuid) break + if($.outFlag || $.activityEnd) break + } + } + if($.outFlag) { + let msg = '此ip已被限制,请过10分钟后再执行脚本' + $.msg($.name, ``, `${msg}`); + if ($.isNode()) await notify.sendNotify(`${$.name}`, `${msg}`); + } +})() + .catch((e) => $.logErr(e)) + .finally(() => $.done()) + + +async function run() { + try { + $.hasEnd = true + $.endTime = 0 + lz_jdpin_token_cookie = '' + $.Token = '' + $.Pin = '' + let flag = false + await takePostRequest('isvObfuscator'); + if($.Token == ''){ + console.log('获取[token]失败!') + return + } + await getCk() + if (activityCookie == '') { + console.log(`获取cookie失败`); return; + } + if($.activityEnd === true){ + console.log('活动结束') + return + } + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + await takePostRequest('getSimpleActInfoVo'); + await takePostRequest('getMyPing'); + if(!$.Pin){ + console.log('获取[Pin]失败!') + return + } + await takePostRequest('accessLogWithAD'); + await takePostRequest('getUserInfo'); + await takePostRequest('activityContent'); + if($.hotFlag) return + if(!$.actorUuid){ + console.log('获取不到[actorUuid]退出执行,请重新执行') + return + } + if($.hasEnd === true || Date.now() > $.endTime){ + $.activityEnd = true + console.log('活动结束') + return + } + await takePostRequest('drawContent'); + await $.wait(1000) + $.openList = [] + $.allOpenCard = false + await takePostRequest('checkOpenCard'); + // console.log($.actorUuid) + // return + if($.allOpenCard == false){ + console.log('开卡任务') + for(o of $.openList){ + $.openCard = false + if(o.status == 0){ + flag = true + $.joinVenderId = o.venderId + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + await joinShop() + await $.wait(parseInt(Math.random() * 1000 + 1000, 10)) + await takePostRequest('activityContent'); + await takePostRequest('drawContent'); + await takePostRequest('checkOpenCard'); + await $.wait(parseInt(Math.random() * 3000 + 2000, 10)) + } + } + }else{ + console.log('已全部开卡') + } + + $.log("关注: " + $.followShop) + if(!$.followShop && !$.outFlag){ + flag = true + await takePostRequest('followShop'); + await $.wait(parseInt(Math.random() * 2000 + 3000, 10)) + } + $.yaoqing = false + await takePostRequest('助力'); + if($.yaoqing){ + await takePostRequest('邀请'); + } + await takePostRequest('startDraw'); + + if(flag){ + await takePostRequest('activityContent'); + } + console.log(`${$.score}值 游戏:${$.point}`) + $.runFalag = true + let count = parseInt($.score/1000) + console.log(`抽奖次数为:${count}`) + for(m=1;count--;m++){ + console.log(`第${m}次抽奖`) + await takePostRequest('抽奖'); + if($.runFalag == false) break + if(Number(count) <= 0) break + if(m >= 10){ + console.log("抽奖太多次,多余的次数请再执行脚本") + break + } + await $.wait(parseInt(Math.random() * 2000 + 2000, 10)) + } + + await $.wait(parseInt(Math.random() * 1000 + 2000, 10)) + await takePostRequest('getDrawRecordHasCoupon'); + await takePostRequest('getShareRecord'); + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + console.log($.actorUuid) + console.log(`当前助力:${$.shareUuid}`) + if($.index == 1){ + $.shareUuid = $.actorUuid + console.log(`后面的号都会助力:${$.shareUuid}`) + } + await $.wait(parseInt(Math.random() * 1000 + 5000, 10)) + if(flag) await $.wait(parseInt(Math.random() * 1000 + 10000, 10)) + + if($.index % 3 == 0) console.log('休息1分钟,别被黑ip了\n可持续发展') + if($.index % 3 == 0) await $.wait(parseInt(Math.random() * 5000 + 60000, 10)) + + } catch (e) { + console.log(e) + } +} + +async function takePostRequest(type) { + if($.outFlag) return + let domain = 'https://lzdz1-isv.isvjcloud.com'; + let body = ``; + let method = 'POST' + let admJson = '' + switch (type) { + case 'isvObfuscator': + url = `https://api.m.jd.com/client.action?functionId=isvObfuscator`; + body = `body=%7B%22url%22%3A%22https%3A//lzdz1-isv.isvjcloud.com%22%2C%22id%22%3A%22%22%7D&uuid=7088d9018515b8cb0c88ace6e5479762af3e88f3&client=apple&clientVersion=10.1.4&st=1634343624086&sv=120&sign=8b9cea22c3a0d77026abda5d37d2b7e3`; + break; + case 'getSimpleActInfoVo': + url = `${domain}/dz/common/getSimpleActInfoVo`; + body = `activityId=${$.activityId}`; + break; + case 'getMyPing': + url = `${domain}/customer/getMyPing`; + body = `userId=${$.shopId || $.venderId || ''}&token=${$.Token}&fromType=APP`; + break; + case 'accessLogWithAD': + url = `${domain}/common/accessLogWithAD`; + let pageurl = `${domain}/drawCenter/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}` + body = `venderId=${$.shopId || $.venderId || ''}&code=99&pin=${encodeURIComponent($.Pin)}&activityId=${$.activityId}&pageUrl=${encodeURIComponent(pageurl)}&subType=app&adSource=` + break; + case 'getUserInfo': + url = `${domain}/wxActionCommon/getUserInfo`; + body = `pin=${encodeURIComponent($.Pin)}`; + break; + case 'activityContent': + url = `${domain}/play/monopoly/getContent`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&pinImg=${encodeURIComponent($.attrTouXiang)}&nick=${encodeURIComponent($.nickname)}&cjyxPin=&cjhyPin=&shareUuid=${$.shareUuid}` + break; + case 'drawContent': + url = `${domain}/dingzhi/taskact/common/drawContent`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case 'checkOpenCard': + url = `${domain}/play/monopoly/checkOpenCard`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case 'info': + url = `${domain}/play/monopoly/getTaskList`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case 'startDraw': + url = `${domain}/play/monopoly/activeDraw`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&drawType=1` + break; + case 'followShop': + url = `${domain}/play/monopoly/doTasks`; + // url = `${domain}/dingzhi/dz/openCard/saveTask`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&taskType=1` + break; + case 'sign': + case 'addCart': + case 'browseGoods': + url = `${domain}/dingzhi/linkgame/${type}`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + if(type == 'browseGoods') body += `&value=${$.visitSkuValue}` + break; + case '邀请': + case '助力': + if(type == '助力'){ + url = `${domain}/play/monopoly/getAssistStatus`; + }else{ + url = `${domain}/play/monopoly/assist`; + } + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&shareUuid=${$.shareUuid}&actorUuid=${$.actorUuid}` + break; + case 'viewVideo': + case 'visitSku': + case 'toShop': + case 'addSku': + url = `${domain}/dingzhi/dz/openCard/saveTask`; + let taskType = '' + let taskValue = '' + if(type == 'viewVideo'){ + taskType = 31 + taskValue = 31 + }else if(type == 'visitSku'){ + taskType = 5 + taskValue = $.visitSkuValue || 5 + }else if(type == 'toShop'){ + taskType = 14 + taskValue = $.toShopValue || 14 + }else if(type == 'addSku'){ + taskType = 2 + taskValue = $.addSkuValue || 2 + } + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&taskType=${taskType}&taskValue=${taskValue}` + break; + case 'getDrawRecordHasCoupon': + url = `${domain}/play/monopoly/getPrizeList`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case 'getShareRecord': + url = `${domain}/play/monopoly/getHelpList`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case '抽奖': + url = `${domain}/play/monopoly/activeDraw`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&drawType=2` + break; + default: + console.log(`错误${type}`); + } + let myRequest = getPostRequest(url, body, method); + // console.log(myRequest) + return new Promise(async resolve => { + $.post(myRequest, (err, resp, data) => { + try { + setActivityCookie(resp) + if (err) { + if(resp && typeof resp.statusCode != 'undefined'){ + if(resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + } + console.log(`${$.toStr(err,err)}`) + console.log(`${type} API请求失败,请检查网路重试`) + } else { + dealReturn(type, data); + } + } catch (e) { + // console.log(data); + console.log(e, resp) + } finally { + resolve(); + } + }) + }) + } + +async function dealReturn(type, data) { + let res = '' + try { + if(type != 'accessLogWithAD' || type != 'drawContent'){ + if(data){ + res = JSON.parse(data); + } + } + } catch (e) { + console.log(`${type} 执行任务异常`); + console.log(data); + $.runFalag = false; + } + try { + switch (type) { + case 'isvObfuscator': + if(typeof res == 'object'){ + if(res.errcode == 0){ + if(typeof res.token != 'undefined') $.Token = res.token + }else if(res.message){ + console.log(`isvObfuscator ${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + break; + case 'getSimpleActInfoVo': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(typeof res.data.shopId != 'undefined') $.shopId = res.data.shopId + if(typeof res.data.venderId != 'undefined') $.venderId = res.data.venderId + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getMyPing': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(res.data && typeof res.data.secretPin != 'undefined') $.Pin = res.data.secretPin + if(res.data && typeof res.data.nickname != 'undefined') $.nickname = res.data.nickname + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getUserInfo': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(res.data && typeof res.data.yunMidImageUrl != 'undefined') $.attrTouXiang = res.data.yunMidImageUrl || "https://img10.360buyimg.com/imgzone/jfs/t1/7020/27/13511/6142/5c5138d8E4df2e764/5a1216a3a5043c5d.png" + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'activityContent': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + $.endTime = res.data.endTime || (res.data.activityVo && res.data.activityVo.endTime) || res.data.activity.endTime || 0 + $.hasEnd = res.data.isEnd || false + $.drawCount = res.data.actorVo.drawCount || 0 + $.point = res.data.actorVo.point || 0 + $.score = res.data.actorVo.score || 0 + $.actorUuid = res.data.actorVo.actorUuid || '' + $.followShop = res.data.actorVo.followShopStatus || '' + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'info': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + // $.drawCount = res.data.drawCount || 0 + $.addCart = res.data.addCart || false + $.followShop = res.data.followShop || false + $.sign = res.data.isSignStatus || false + $.visitSku = res.data.visitSku || false + $.visitSkuList = res.data.visitSkuList || [] + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'checkOpenCard': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + let cardList1 = res.data.cardList1 || [] + let cardList2 = res.data.cardList2 || [] + let cardList = res.data.cardList || [] + let openCardList = res.data.openCardList || [] + $.openList = [...cardList,...cardList1,...cardList2,...openCardList] + $.allOpenCard = res.data.allOpenCard || res.data.isOpenCardStatus || false + $.openCardScore1 = res.data.score1 || 0 + $.openCardScore2 = res.data.score2 || 0 + $.drawScore = res.data.drawScore || 0 + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'startDraw': + case 'followShop': + case 'viewVideo': + case 'visitSku': + case 'toShop': + case 'addSku': + case 'sign': + case 'addCart': + case 'browseGoods': + case '抽奖': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(typeof res.data == 'object'){ + let msg = '' + let title = '抽奖' + if(res.data.addBeanNum){ + msg = `${res.data.addBeanNum}京豆` + } + if(res.data.addPoint){ + msg += ` ${res.data.addPoint}游戏机会` + } + if(type == 'followShop'){ + title = '关注' + if(res.data.beanNumMember && res.data.assistSendStatus){ + msg += ` 额外获得:${res.data.beanNumMember}京豆` + } + }else if(type == 'addSku' || type == 'addCart'){ + title = '加购' + }else if(type == 'viewVideo'){ + title = '热门文章' + }else if(type == 'toShop'){ + title = '浏览店铺' + }else if(type == 'visitSku' || type == 'browseGoods'){ + title = '浏览商品' + }else if(type == 'sign'){ + title = '签到' + }else{ + msg = res.data.drawOk == true && (res.data.drawInfoType == 6 && res.data.name || '') || '空气💨' + } + if(!msg){ + msg = '空气💨' + } + console.log(`${title}获得:${msg || data}`) + }else{ + console.log(`${type} ${data}`) + } + }else if(res.errorMessage){ + $.runFalag = false; + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getDrawRecordHasCoupon': + // console.log(data) + if(typeof res == 'object'){ + if(res.result && res.result === true){ + console.log(`我的奖品:`) + let num = 0 + let value = 0 + for(let i in res.data){ + let item = res.data[i] + if(item.drawId == 'assist'){ + num++ + value = item.infoName.replace('京豆','') + }else{ + console.log(`${item.infoType != 10 && item.drawId && item.drawId +':' || ''}${item.infoName}`) + } + } + if(num > 0) console.log(`邀请好友(${num}):${num*parseInt(value, 10) || 30}京豆`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getShareRecord': + if(typeof res == 'object'){ + if(res.result && res.result === true && res.data){ + $.ShareCount = res.data.length + $.log(`=========== 你邀请了:${res.data.length}个`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case '邀请': + case '助力': + // console.log(data) + if(typeof res == 'object'){ + if(res.data == 200){ + if(type == '助力'){ + console.log('助力成功') + $.yaoqing = true + } + }else if(res.data == 105){ + console.log('已经助力过') + }else if(res.data == 104){ + console.log('已经助力其他人') + }else if(res.data == 101){ + // console.log('已经助力过') + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + + case 'accessLogWithAD': + case 'drawContent': + break; + default: + console.log(`${type}-> ${data}`); + } + if(typeof res == 'object'){ + if(res.errorMessage){ + if(res.errorMessage.indexOf('火爆') >-1 ){ + $.hotFlag = true + } + } + } + } catch (e) { + console.log(e) + } +} + +function getPostRequest(url, body, method="POST") { + let headers = { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Content-Type": "application/x-www-form-urlencoded", + "Cookie": cookie, + "User-Agent": $.UA, + "X-Requested-With": "XMLHttpRequest" + } + if(url.indexOf('https://lzdz1-isv.isvjcloud.com') > -1){ + headers["Referer"] = `https://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}` + headers["Cookie"] = `${lz_jdpin_token_cookie && lz_jdpin_token_cookie || ''}${$.Pin && "AUTH_C_USER=" + $.Pin + ";" || ""}${activityCookie}` + } + // console.log(headers) + // console.log(headers.Cookie) + return {url: url, method: method, headers: headers, body: body, timeout:30000}; +} + +function getCk() { + return new Promise(resolve => { + let get = { + url:`https://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}`, + followRedirect:false, + headers: { + "User-Agent": $.UA, + }, + timeout:30000 + } + $.get(get, async(err, resp, data) => { + try { + if (err) { + if(resp && typeof resp.statusCode != 'undefined'){ + if(resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + } + console.log(`${$.toStr(err)}`) + console.log(`${$.name} cookie API请求失败,请检查网路重试`) + } else { + let end = data.match(/(活动已经结束)/) && data.match(/(活动已经结束)/)[1] || '' + if(end){ + $.activityEnd = true + console.log('活动已结束') + } + setActivityCookie(resp) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function setActivityCookie(resp){ + let LZ_TOKEN_KEY = '' + let LZ_TOKEN_VALUE = '' + let lz_jdpin_token = '' + let setcookies = resp && resp['headers'] && (resp['headers']['set-cookie'] || resp['headers']['Set-Cookie'] || '') || '' + let setcookie = '' + if(setcookies){ + if(typeof setcookies != 'object'){ + setcookie = setcookies.split(',') + }else setcookie = setcookies + for (let ck of setcookie) { + let name = ck.split(";")[0].trim() + if(name.split("=")[1]){ + // console.log(name.replace(/ /g,'')) + if(name.indexOf('LZ_TOKEN_KEY=')>-1) LZ_TOKEN_KEY = name.replace(/ /g,'')+';' + if(name.indexOf('LZ_TOKEN_VALUE=')>-1) LZ_TOKEN_VALUE = name.replace(/ /g,'')+';' + if(name.indexOf('lz_jdpin_token=')>-1) lz_jdpin_token = ''+name.replace(/ /g,'')+';' + } + } + } + if(LZ_TOKEN_KEY && LZ_TOKEN_VALUE) activityCookie = `${LZ_TOKEN_KEY} ${LZ_TOKEN_VALUE}` + if(lz_jdpin_token) lz_jdpin_token_cookie = lz_jdpin_token +} + +async function getUA(){ + $.UA = `jdapp;iPhone;10.1.4;13.1.2;${randomString(40)};network/wifi;model/iPhone8,1;addressid/2308460611;appBuild/167814;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_1_2 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 joinShop() { + if(!$.joinVenderId) return + return new Promise(async resolve => { + $.shopactivityId = '' + await $.wait(1000) + await getshopactivityId() + let activityId = `` + if($.shopactivityId) activityId = `,"activityId":${$.shopactivityId}` + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body={"venderId":"${$.joinVenderId}","shopId":"${$.joinVenderId}","bindByVerifyCodeFlag":1,"registerExtend":{},"writeChildFlag":0${activityId},"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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + // console.log(data) + let res = $.toObj(data); + if(typeof res == 'object'){ + if(res.success === true){ + console.log(res.message) + if(res.result && res.result.giftInfo){ + for(let i of res.result.giftInfo.giftList){ + console.log(`入会获得:${i.discountString}${i.prizeName}${i.secondLineDesc}`) + } + } + }else if(typeof res == 'object' && res.message){ + console.log(`${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function getshopactivityId() { + return new Promise(resolve => { + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body=%7B%22venderId%22%3A%22${$.joinVenderId}%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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + let res = $.toObj(data); + if(res.success == true){ + // console.log($.toStr(res.result)) + console.log(`入会:${res.result.shopMemberCardInfo.venderCardName || ''}`) + $.shopactivityId = res.result.interestsRuleList && res.result.interestsRuleList[0] && res.result.interestsRuleList[0].interestsInfo && res.result.interestsRuleList[0].interestsInfo.activityId || '' + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} + + +// 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)} diff --git a/activity/jd_opencardL36.js b/activity/jd_opencardL36.js new file mode 100644 index 0000000..c0d6415 --- /dev/null +++ b/activity/jd_opencardL36.js @@ -0,0 +1,829 @@ +/* +大牌联合 年货盛宴 +2021年12月31日 - 2022年1月9日 + + +1.邀请一人20豆(有可能没有豆 +2.开10张 成功开1张 可能获得5京豆 + 全部开完获得1次抽奖 +3.关注10京豆 获得1次抽奖 +4.加购5京豆 获得1次抽奖 +5.抽奖 + +第一个账号助力作者 其他依次助力CK1 +第一个CK失效会退出脚本 + +———————————————— +入口:https://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity/1872126?activityId=dzlhkklblzms20211227&shareUuid=d01a9778ec9143b09531e05ca5d62343 + +请求太频繁会被黑ip +过10分钟再执行 + + +cron:1 1,14 31,1-9 12,1 * +============Quantumultx=============== +[task_local] +#12.23~1.2 联合开卡 +1 1,14 31,1-9 12,1 * https://raw.githubusercontent.com/KingRan/JDJB/main/jd_opencardL36.js, tag=2021.12.31-1.9大牌联合 年货盛宴, enabled=true + +*/ +const $ = new Env("2021.12.31-1.9大牌联合 年货盛宴"); +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const notify = $.isNode() ? require('./sendNotify') : ''; +//IOS等用户直接用NobyDa的jd cookie + +let cookiesArr = [], + cookie = ''; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} +allMessage = "" +message = "" +$.hotFlag = false +$.outFlag = false +$.activityEnd = false +let lz_jdpin_token_cookie ='' +let activityCookie ='' +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', { + "open-url": "https://bean.m.jd.com/" + }); + return; + } + $.activityId = "dzlhkklblzms20211227" + $.shareUuid = "d01a9778ec9143b09531e05ca5d62343" + console.log(`入口:\nhttps://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}`) + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i]; + if (cookie) { + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + message = "" + $.bean = 0 + $.hotFlag = false + $.nickName = ''; + console.log(`\n\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + await getUA() + await run(); + if(i == 0 && !$.actorUuid) break + if($.outFlag || $.activityEnd) break + } + } + if($.outFlag) { + let msg = '此ip已被限制,请过10分钟后再执行脚本' + $.msg($.name, ``, `${msg}`); + if ($.isNode()) await notify.sendNotify(`${$.name}`, `${msg}`); + } +})() + .catch((e) => $.logErr(e)) + .finally(() => $.done()) + + +async function run() { + try { + $.hasEnd = true + $.endTime = 0 + lz_jdpin_token_cookie = '' + $.Token = '' + $.Pin = '' + let flag = false + await takePostRequest('isvObfuscator'); + if($.Token == ''){ + console.log('获取[token]失败!') + return + } + await getCk() + if (activityCookie == '') { + console.log(`获取cookie失败`); return; + } + if($.activityEnd === true){ + console.log('活动结束') + return + } + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + await takePostRequest('getSimpleActInfoVo'); + await takePostRequest('getMyPing'); + if(!$.Pin){ + console.log('获取[Pin]失败!') + return + } + await takePostRequest('accessLogWithAD'); + await takePostRequest('getUserInfo'); + await takePostRequest('activityContent'); + if($.hotFlag) return + if(!$.actorUuid){ + console.log('获取不到[actorUuid]退出执行,请重新执行') + return + } + // console.log($.actorUuid) + // return + if($.hasEnd === true || Date.now() > $.endTime){ + $.activityEnd = true + console.log('活动结束') + return + } + await takePostRequest('drawContent'); + await $.wait(1000) + $.openList = [] + $.allOpenCard = false + await takePostRequest('info'); + await takePostRequest('checkOpenCard'); + if($.allOpenCard == false){ + console.log('开卡任务') + for(o of $.openList){ + $.openCard = false + if(o.status == 0){ + flag = true + $.joinVenderId = o.venderId + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + await joinShop() + await $.wait(parseInt(Math.random() * 1000 + 1000, 10)) + await takePostRequest('activityContent'); + await takePostRequest('drawContent'); + await takePostRequest('checkOpenCard'); + await $.wait(parseInt(Math.random() * 3000 + 2000, 10)) + } + } + }else{ + console.log('已全部开卡') + } + + $.log("关注: " + $.followShop) + if(!$.followShop && !$.outFlag){ + flag = true + await takePostRequest('followShop'); + await $.wait(parseInt(Math.random() * 2000 + 3000, 10)) + } + $.yaoqing = false + await takePostRequest('邀请'); + if($.yaoqing){ + await takePostRequest('助力'); + } + $.log("加购: " + $.addCart) + if(!$.addCart && !$.outFlag){ + flag = true + await takePostRequest('addCart'); + await $.wait(parseInt(Math.random() * 2000 + 4000, 10)) + } + $.runFalag = true + $.log("浏览商品: " + $.visitSku) + if(!$.visitSku && !$.outFlag){ + flag = true + for(let v of $.visitSkuList || []){ + if($.runFalag == false) break + if(v.goodsCode && v.status === 0){ + $.visitSkuValue = v.goodsCode + await takePostRequest('browseGoods'); + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + } + } + } + $.runFalag = true + let count = parseInt($.drawCount, 10) + console.log(`抽奖次数为:${count}`) + for(m=1;count--;m++){ + console.log(`第${m}次抽奖`) + await takePostRequest('startDraw'); + if($.runFalag == false) break + if(Number(count) <= 0) break + if(m >= 30){ + console.log("抽奖太多次,多余的次数请再执行脚本") + break + } + await $.wait(parseInt(Math.random() * 2000 + 2000, 10)) + } + if(flag){ + await takePostRequest('activityContent'); + } + console.log(`${$.score}值 游戏:${$.point}`) + $.runFalag = true + count = parseInt($.score/1000) + console.log(`抽奖次数为:${count}`) + for(m=1;count--;m++){ + console.log(`第${m}次抽奖`) + await takePostRequest('抽奖'); + if($.runFalag == false) break + if(Number(count) <= 0) break + if(m >= 10){ + console.log("抽奖太多次,多余的次数请再执行脚本") + break + } + await $.wait(parseInt(Math.random() * 2000 + 2000, 10)) + } + + await $.wait(parseInt(Math.random() * 1000 + 2000, 10)) + await takePostRequest('getDrawRecordHasCoupon'); + await takePostRequest('getShareRecord'); + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + console.log($.actorUuid) + console.log(`当前助力:${$.shareUuid}`) + if($.index == 1){ + $.shareUuid = $.actorUuid + console.log(`后面的号都会助力:${$.shareUuid}`) + } + await $.wait(parseInt(Math.random() * 1000 + 5000, 10)) + if(flag) await $.wait(parseInt(Math.random() * 1000 + 10000, 10)) + + if($.index % 3 == 0) console.log('休息1分钟,别被黑ip了\n可持续发展') + if($.index % 3 == 0) await $.wait(parseInt(Math.random() * 5000 + 60000, 10)) + + } catch (e) { + console.log(e) + } +} + +async function takePostRequest(type) { + if($.outFlag) return + let domain = 'https://lzdz1-isv.isvjcloud.com'; + let body = ``; + let method = 'POST' + let admJson = '' + switch (type) { + case 'isvObfuscator': + url = `https://api.m.jd.com/client.action?functionId=isvObfuscator`; + body = `body=%7B%22url%22%3A%22https%3A//lzdz1-isv.isvjcloud.com%22%2C%22id%22%3A%22%22%7D&uuid=7088d9018515b8cb0c88ace6e5479762af3e88f3&client=apple&clientVersion=10.1.4&st=1634343624086&sv=120&sign=8b9cea22c3a0d77026abda5d37d2b7e3`; + break; + case 'getSimpleActInfoVo': + url = `${domain}/dz/common/getSimpleActInfoVo`; + body = `activityId=${$.activityId}`; + break; + case 'getMyPing': + url = `${domain}/customer/getMyPing`; + body = `userId=${$.shopId || $.venderId || ''}&token=${$.Token}&fromType=APP`; + break; + case 'accessLogWithAD': + url = `${domain}/common/accessLogWithAD`; + let pageurl = `${domain}/drawCenter/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}` + body = `venderId=${$.shopId || $.venderId || ''}&code=99&pin=${encodeURIComponent($.Pin)}&activityId=${$.activityId}&pageUrl=${encodeURIComponent(pageurl)}&subType=app&adSource=` + break; + case 'getUserInfo': + url = `${domain}/wxActionCommon/getUserInfo`; + body = `pin=${encodeURIComponent($.Pin)}`; + break; + case 'activityContent': + url = `${domain}/dingzhi/linkgame/activity/content`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&pinImg=${encodeURIComponent($.attrTouXiang)}&nick=${encodeURIComponent($.nickname)}&cjyxPin=&cjhyPin=&shareUuid=${$.shareUuid}` + break; + case 'drawContent': + url = `${domain}/dingzhi/taskact/common/drawContent`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case 'checkOpenCard': + url = `${domain}/dingzhi/linkgame/checkOpenCard`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case 'info': + url = `${domain}/dingzhi/linkgame/task/info`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case 'startDraw': + url = `${domain}/dingzhi/linkgame/draw/bean`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case 'followShop': + url = `${domain}/dingzhi/linkgame/follow/shop`; + // url = `${domain}/dingzhi/dz/openCard/saveTask`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case 'sign': + case 'addCart': + case 'browseGoods': + url = `${domain}/dingzhi/linkgame/${type}`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + if(type == 'browseGoods') body += `&value=${$.visitSkuValue}` + break; + case '邀请': + case '助力': + if(type == '助力'){ + url = `${domain}/dingzhi/linkgame/assist`; + }else{ + url = `${domain}/dingzhi/linkgame/assist/status`; + } + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&shareUuid=${$.shareUuid}` + break; + case 'viewVideo': + case 'visitSku': + case 'toShop': + case 'addSku': + url = `${domain}/dingzhi/dz/openCard/saveTask`; + let taskType = '' + let taskValue = '' + if(type == 'viewVideo'){ + taskType = 31 + taskValue = 31 + }else if(type == 'visitSku'){ + taskType = 5 + taskValue = $.visitSkuValue || 5 + }else if(type == 'toShop'){ + taskType = 14 + taskValue = $.toShopValue || 14 + }else if(type == 'addSku'){ + taskType = 2 + taskValue = $.addSkuValue || 2 + } + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&taskType=${taskType}&taskValue=${taskValue}` + break; + case 'getDrawRecordHasCoupon': + url = `${domain}/dingzhi/linkgame/draw/record`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case 'getShareRecord': + url = `${domain}/dingzhi/linkgame/help/list`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case '抽奖': + url = `${domain}/dingzhi/linkgame/draw`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + default: + console.log(`错误${type}`); + } + let myRequest = getPostRequest(url, body, method); + // console.log(myRequest) + return new Promise(async resolve => { + $.post(myRequest, (err, resp, data) => { + try { + setActivityCookie(resp) + if (err) { + if(resp && typeof resp.statusCode != 'undefined'){ + if(resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + } + console.log(`${$.toStr(err,err)}`) + console.log(`${type} API请求失败,请检查网路重试`) + } else { + dealReturn(type, data); + } + } catch (e) { + // console.log(data); + console.log(e, resp) + } finally { + resolve(); + } + }) + }) + } + +async function dealReturn(type, data) { + let res = '' + try { + if(type != 'accessLogWithAD' || type != 'drawContent'){ + if(data){ + res = JSON.parse(data); + } + } + } catch (e) { + console.log(`${type} 执行任务异常`); + console.log(data); + $.runFalag = false; + } + try { + switch (type) { + case 'isvObfuscator': + if(typeof res == 'object'){ + if(res.errcode == 0){ + if(typeof res.token != 'undefined') $.Token = res.token + }else if(res.message){ + console.log(`isvObfuscator ${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + break; + case 'getSimpleActInfoVo': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(typeof res.data.shopId != 'undefined') $.shopId = res.data.shopId + if(typeof res.data.venderId != 'undefined') $.venderId = res.data.venderId + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getMyPing': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(res.data && typeof res.data.secretPin != 'undefined') $.Pin = res.data.secretPin + if(res.data && typeof res.data.nickname != 'undefined') $.nickname = res.data.nickname + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getUserInfo': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(res.data && typeof res.data.yunMidImageUrl != 'undefined') $.attrTouXiang = res.data.yunMidImageUrl || "https://img10.360buyimg.com/imgzone/jfs/t1/7020/27/13511/6142/5c5138d8E4df2e764/5a1216a3a5043c5d.png" + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'activityContent': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + $.endTime = res.data.endTime || res.data.activity.endTime || 0 + $.hasEnd = res.data.isEnd || false + $.drawCount = res.data.actor.drawCount || 0 + $.point = res.data.actor.point || 0 + $.score = res.data.actor.score || 0 + $.actorUuid = res.data.actor.actorUuid || '' + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'info': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + // $.drawCount = res.data.drawCount || 0 + $.addCart = res.data.addCart || false + $.followShop = res.data.followShop || false + $.sign = res.data.sign || false + $.visitSku = res.data.visitSku || false + $.visitSkuList = res.data.visitSkuList || [] + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'checkOpenCard': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + let cardList1 = res.data.cardList1 || [] + let cardList2 = res.data.cardList2 || [] + let cardList = res.data.cardList || [] + let openCardList = res.data.openCardList || [] + $.openList = [...cardList,...cardList1,...cardList2,...openCardList] + $.allOpenCard = res.data.allOpenCard || false + $.openCardScore1 = res.data.score1 || 0 + $.openCardScore2 = res.data.score2 || 0 + $.drawScore = res.data.drawScore || 0 + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'startDraw': + case 'followShop': + case 'viewVideo': + case 'visitSku': + case 'toShop': + case 'addSku': + case 'sign': + case 'addCart': + case 'browseGoods': + case '抽奖': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(typeof res.data == 'object'){ + let msg = '' + let title = '抽奖' + if(res.data.addBeanNum){ + msg = `${res.data.addBeanNum}京豆` + } + if(res.data.addPoint){ + msg += ` ${res.data.addPoint}游戏机会` + } + if(type == 'followShop'){ + title = '关注' + if(res.data.beanNumMember && res.data.assistSendStatus){ + msg += ` 额外获得:${res.data.beanNumMember}京豆` + } + }else if(type == 'addSku' || type == 'addCart'){ + title = '加购' + }else if(type == 'viewVideo'){ + title = '热门文章' + }else if(type == 'toShop'){ + title = '浏览店铺' + }else if(type == 'visitSku' || type == 'browseGoods'){ + title = '浏览商品' + }else if(type == 'sign'){ + title = '签到' + }else{ + msg = res.data.drawOk == true && (res.data.drawInfoType == 6 && res.data.name || '') || '空气💨' + } + if(!msg){ + msg = '空气💨' + } + console.log(`${title}获得:${msg || data}`) + }else{ + console.log(`${type} ${data}`) + } + }else if(res.errorMessage){ + $.runFalag = false; + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getDrawRecordHasCoupon': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + console.log(`我的奖品:`) + let num = 0 + let value = 0 + for(let i in res.data.recordList){ + let item = res.data.recordList[i] + if(item.infoName == '20京豆'){ + num++ + value = item.infoName.replace('京豆','') + }else{ + console.log(`${item.infoType != 10 && item.value && item.value +':' || ''}${item.infoName}`) + } + } + if(num > 0) console.log(`邀请好友(${num}):${num*parseInt(value, 10) || 30}京豆`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getShareRecord': + if(typeof res == 'object'){ + if(res.result && res.result === true && res.data){ + $.ShareCount = res.data.shareList.length + $.log(`=========== 你邀请了:${res.data.shareList.length}个`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case '邀请': + case '助力': + // console.log(data) + if(typeof res == 'object'){ + if(res.data.status == 200){ + if(type == '助力'){ + console.log('助力成功') + }else{ + $.yaoqing = true + } + }else if(res.data.status == 105){ + console.log('已经助力过') + }else if(res.data.status == 104){ + console.log('已经助力其他人') + }else if(res.data.status == 101){ + // console.log('已经助力过') + }else{ + console.log(data) + } + }else{ + console.log(`${type} ${data}`) + } + + case 'accessLogWithAD': + case 'drawContent': + break; + default: + console.log(`${type}-> ${data}`); + } + if(typeof res == 'object'){ + if(res.errorMessage){ + if(res.errorMessage.indexOf('火爆') >-1 ){ + $.hotFlag = true + } + } + } + } catch (e) { + console.log(e) + } +} + +function getPostRequest(url, body, method="POST") { + let headers = { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Content-Type": "application/x-www-form-urlencoded", + "Cookie": cookie, + "User-Agent": $.UA, + "X-Requested-With": "XMLHttpRequest" + } + if(url.indexOf('https://lzdz1-isv.isvjcloud.com') > -1){ + headers["Referer"] = `https://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}` + headers["Cookie"] = `${lz_jdpin_token_cookie && lz_jdpin_token_cookie || ''}${$.Pin && "AUTH_C_USER=" + $.Pin + ";" || ""}${activityCookie}` + } + // console.log(headers) + // console.log(headers.Cookie) + return {url: url, method: method, headers: headers, body: body, timeout:30000}; +} + +function getCk() { + return new Promise(resolve => { + let get = { + url:`https://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}`, + followRedirect:false, + headers: { + "User-Agent": $.UA, + }, + timeout:30000 + } + $.get(get, async(err, resp, data) => { + try { + if (err) { + if(resp && typeof resp.statusCode != 'undefined'){ + if(resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + } + console.log(`${$.toStr(err)}`) + console.log(`${$.name} cookie API请求失败,请检查网路重试`) + } else { + let end = data.match(/(活动已经结束)/) && data.match(/(活动已经结束)/)[1] || '' + if(end){ + $.activityEnd = true + console.log('活动已结束') + } + setActivityCookie(resp) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function setActivityCookie(resp){ + let LZ_TOKEN_KEY = '' + let LZ_TOKEN_VALUE = '' + let lz_jdpin_token = '' + let setcookies = resp && resp['headers'] && (resp['headers']['set-cookie'] || resp['headers']['Set-Cookie'] || '') || '' + let setcookie = '' + if(setcookies){ + if(typeof setcookies != 'object'){ + setcookie = setcookies.split(',') + }else setcookie = setcookies + for (let ck of setcookie) { + let name = ck.split(";")[0].trim() + if(name.split("=")[1]){ + // console.log(name.replace(/ /g,'')) + if(name.indexOf('LZ_TOKEN_KEY=')>-1) LZ_TOKEN_KEY = name.replace(/ /g,'')+';' + if(name.indexOf('LZ_TOKEN_VALUE=')>-1) LZ_TOKEN_VALUE = name.replace(/ /g,'')+';' + if(name.indexOf('lz_jdpin_token=')>-1) lz_jdpin_token = ''+name.replace(/ /g,'')+';' + } + } + } + if(LZ_TOKEN_KEY && LZ_TOKEN_VALUE) activityCookie = `${LZ_TOKEN_KEY} ${LZ_TOKEN_VALUE}` + if(lz_jdpin_token) lz_jdpin_token_cookie = lz_jdpin_token +} + +async function getUA(){ + $.UA = `jdapp;iPhone;10.1.4;13.1.2;${randomString(40)};network/wifi;model/iPhone8,1;addressid/2308460611;appBuild/167814;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_1_2 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 joinShop() { + if(!$.joinVenderId) return + return new Promise(async resolve => { + $.shopactivityId = '' + await $.wait(1000) + await getshopactivityId() + let activityId = `` + if($.shopactivityId) activityId = `,"activityId":${$.shopactivityId}` + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body={"venderId":"${$.joinVenderId}","shopId":"${$.joinVenderId}","bindByVerifyCodeFlag":1,"registerExtend":{},"writeChildFlag":0${activityId},"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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + // console.log(data) + let res = $.toObj(data); + if(typeof res == 'object'){ + if(res.success === true){ + console.log(res.message) + if(res.result && res.result.giftInfo){ + for(let i of res.result.giftInfo.giftList){ + console.log(`入会获得:${i.discountString}${i.prizeName}${i.secondLineDesc}`) + } + } + }else if(typeof res == 'object' && res.message){ + console.log(`${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function getshopactivityId() { + return new Promise(resolve => { + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body=%7B%22venderId%22%3A%22${$.joinVenderId}%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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + let res = $.toObj(data); + if(res.success == true){ + // console.log($.toStr(res.result)) + console.log(`入会:${res.result.shopMemberCardInfo.venderCardName || ''}`) + $.shopactivityId = res.result.interestsRuleList && res.result.interestsRuleList[0] && res.result.interestsRuleList[0].interestsInfo && res.result.interestsRuleList[0].interestsInfo.activityId || '' + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} + + +// 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)} diff --git a/activity/jd_opencardL37.js b/activity/jd_opencardL37.js new file mode 100644 index 0000000..3600b7b --- /dev/null +++ b/activity/jd_opencardL37.js @@ -0,0 +1,822 @@ +/* +2022.1.1-1.3元旦狂欢盛典 +2022年1月1日 - 2022年1月3日 + + +第一个账号助力作者 其他依次助力CK1 +第一个CK失效会退出脚本 + +———————————————— +入口:https://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=dzlhkklblzms20211228&shareUuid=609ba159b730437795603216e13ffd36 + +请求太频繁会被黑ip +过10分钟再执行 + + +cron:1 3,17 1-3 1 * +============Quantumultx=============== +[task_local] +#12.23~1.2 联合开卡 +1 3,17 1-3 1 * https://raw.githubusercontent.com/KingRan/JDJB/main/jd_opencardL37.js, tag=2022.1.1-1.3元旦狂欢盛典, enabled=true + +*/ +const $ = new Env("2022.1.1-1.3元旦狂欢盛典"); +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const notify = $.isNode() ? require('./sendNotify') : ''; +//IOS等用户直接用NobyDa的jd cookie + +let cookiesArr = [], + cookie = ''; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} +allMessage = "" +message = "" +$.hotFlag = false +$.outFlag = false +$.activityEnd = false +let lz_jdpin_token_cookie ='' +let activityCookie ='' +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', { + "open-url": "https://bean.m.jd.com/" + }); + return; + } + $.activityId = "dzlhkklblzms20211228" + $.shareUuid = "609ba159b730437795603216e13ffd36" + console.log(`入口:\nhttps://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}`) + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i]; + if (cookie) { + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + message = "" + $.bean = 0 + $.hotFlag = false + $.nickName = ''; + console.log(`\n\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + await getUA() + await run(); + if(i == 0 && !$.actorUuid) break + if($.outFlag || $.activityEnd) break + } + } + if($.outFlag) { + let msg = '此ip已被限制,请过10分钟后再执行脚本' + $.msg($.name, ``, `${msg}`); + if ($.isNode()) await notify.sendNotify(`${$.name}`, `${msg}`); + } +})() + .catch((e) => $.logErr(e)) + .finally(() => $.done()) + + +async function run() { + try { + $.hasEnd = true + $.endTime = 0 + lz_jdpin_token_cookie = '' + $.Token = '' + $.Pin = '' + let flag = false + await takePostRequest('isvObfuscator'); + if($.Token == ''){ + console.log('获取[token]失败!') + return + } + await getCk() + if (activityCookie == '') { + console.log(`获取cookie失败`); return; + } + if($.activityEnd === true){ + console.log('活动结束') + return + } + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + await takePostRequest('getSimpleActInfoVo'); + await takePostRequest('getMyPing'); + if(!$.Pin){ + console.log('获取[Pin]失败!') + return + } + await takePostRequest('accessLogWithAD'); + await takePostRequest('getUserInfo'); + await takePostRequest('activityContent'); + if($.hotFlag) return + if(!$.actorUuid){ + console.log('获取不到[actorUuid]退出执行,请重新执行') + return + } + // console.log($.actorUuid) + // return + if($.hasEnd === true || Date.now() > $.endTime){ + $.activityEnd = true + console.log('活动结束') + return + } + await takePostRequest('drawContent'); + await $.wait(1000) + $.openList = [] + $.allOpenCard = false + await takePostRequest('info'); + await takePostRequest('checkOpenCard'); + if($.allOpenCard == false){ + console.log('开卡任务') + for(o of $.openList){ + $.openCard = false + if(o.status == 0){ + flag = true + $.joinVenderId = o.venderId + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + await joinShop() + await $.wait(parseInt(Math.random() * 1000 + 1000, 10)) + await takePostRequest('activityContent'); + await takePostRequest('drawContent'); + await takePostRequest('checkOpenCard'); + await $.wait(parseInt(Math.random() * 3000 + 2000, 10)) + } + } + }else{ + console.log('已全部开卡') + } + + $.log("关注: " + $.followShop) + if(!$.followShop && !$.outFlag){ + flag = true + await takePostRequest('followShop'); + await $.wait(parseInt(Math.random() * 2000 + 3000, 10)) + } + $.yaoqing = false + await takePostRequest('邀请'); + if($.yaoqing){ + await takePostRequest('助力'); + } + $.log("加购: " + $.addCart) + if(!$.addCart && !$.outFlag){ + flag = true + await takePostRequest('addCart'); + await $.wait(parseInt(Math.random() * 2000 + 4000, 10)) + } + $.runFalag = true + $.log("浏览商品: " + $.visitSku) + if(!$.visitSku && !$.outFlag){ + flag = true + for(let v of $.visitSkuList || []){ + if($.runFalag == false) break + if(v.goodsCode && v.status === 0){ + $.visitSkuValue = v.goodsCode + await takePostRequest('browseGoods'); + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + } + } + } + $.runFalag = true + let count = parseInt($.drawCount, 10) + console.log(`抽奖次数为:${count}`) + for(m=1;count--;m++){ + console.log(`第${m}次抽奖`) + await takePostRequest('startDraw'); + if($.runFalag == false) break + if(Number(count) <= 0) break + if(m >= 30){ + console.log("抽奖太多次,多余的次数请再执行脚本") + break + } + await $.wait(parseInt(Math.random() * 2000 + 2000, 10)) + } + if(flag){ + await takePostRequest('activityContent'); + } + console.log(`${$.score}值 游戏:${$.point}`) + $.runFalag = true + count = parseInt($.score/1000) + console.log(`抽奖次数为:${count}`) + for(m=1;count--;m++){ + console.log(`第${m}次抽奖`) + await takePostRequest('抽奖'); + if($.runFalag == false) break + if(Number(count) <= 0) break + if(m >= 10){ + console.log("抽奖太多次,多余的次数请再执行脚本") + break + } + await $.wait(parseInt(Math.random() * 2000 + 2000, 10)) + } + + await $.wait(parseInt(Math.random() * 1000 + 2000, 10)) + await takePostRequest('getDrawRecordHasCoupon'); + await takePostRequest('getShareRecord'); + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + console.log($.actorUuid) + console.log(`当前助力:${$.shareUuid}`) + if($.index == 1){ + $.shareUuid = $.actorUuid + console.log(`后面的号都会助力:${$.shareUuid}`) + } + await $.wait(parseInt(Math.random() * 1000 + 5000, 10)) + if(flag) await $.wait(parseInt(Math.random() * 1000 + 10000, 10)) + + if($.index % 3 == 0) console.log('休息1分钟,别被黑ip了\n可持续发展') + if($.index % 3 == 0) await $.wait(parseInt(Math.random() * 5000 + 60000, 10)) + + } catch (e) { + console.log(e) + } +} + +async function takePostRequest(type) { + if($.outFlag) return + let domain = 'https://lzdz1-isv.isvjcloud.com'; + let body = ``; + let method = 'POST' + let admJson = '' + switch (type) { + case 'isvObfuscator': + url = `https://api.m.jd.com/client.action?functionId=isvObfuscator`; + body = `body=%7B%22url%22%3A%22https%3A//lzdz1-isv.isvjcloud.com%22%2C%22id%22%3A%22%22%7D&uuid=7088d9018515b8cb0c88ace6e5479762af3e88f3&client=apple&clientVersion=10.1.4&st=1634343624086&sv=120&sign=8b9cea22c3a0d77026abda5d37d2b7e3`; + break; + case 'getSimpleActInfoVo': + url = `${domain}/dz/common/getSimpleActInfoVo`; + body = `activityId=${$.activityId}`; + break; + case 'getMyPing': + url = `${domain}/customer/getMyPing`; + body = `userId=${$.shopId || $.venderId || ''}&token=${$.Token}&fromType=APP`; + break; + case 'accessLogWithAD': + url = `${domain}/common/accessLogWithAD`; + let pageurl = `${domain}/drawCenter/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}` + body = `venderId=${$.shopId || $.venderId || ''}&code=99&pin=${encodeURIComponent($.Pin)}&activityId=${$.activityId}&pageUrl=${encodeURIComponent(pageurl)}&subType=app&adSource=` + break; + case 'getUserInfo': + url = `${domain}/wxActionCommon/getUserInfo`; + body = `pin=${encodeURIComponent($.Pin)}`; + break; + case 'activityContent': + url = `${domain}/dingzhi/linkgame/activity/content`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&pinImg=${encodeURIComponent($.attrTouXiang)}&nick=${encodeURIComponent($.nickname)}&cjyxPin=&cjhyPin=&shareUuid=${$.shareUuid}` + break; + case 'drawContent': + url = `${domain}/dingzhi/taskact/common/drawContent`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case 'checkOpenCard': + url = `${domain}/dingzhi/linkgame/checkOpenCard`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case 'info': + url = `${domain}/dingzhi/linkgame/task/info`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case 'startDraw': + url = `${domain}/dingzhi/linkgame/draw/bean`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case 'followShop': + url = `${domain}/dingzhi/linkgame/follow/shop`; + // url = `${domain}/dingzhi/dz/openCard/saveTask`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case 'sign': + case 'addCart': + case 'browseGoods': + url = `${domain}/dingzhi/linkgame/${type}`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + if(type == 'browseGoods') body += `&value=${$.visitSkuValue}` + break; + case '邀请': + case '助力': + if(type == '助力'){ + url = `${domain}/dingzhi/linkgame/assist`; + }else{ + url = `${domain}/dingzhi/linkgame/assist/status`; + } + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&shareUuid=${$.shareUuid}` + break; + case 'viewVideo': + case 'visitSku': + case 'toShop': + case 'addSku': + url = `${domain}/dingzhi/dz/openCard/saveTask`; + let taskType = '' + let taskValue = '' + if(type == 'viewVideo'){ + taskType = 31 + taskValue = 31 + }else if(type == 'visitSku'){ + taskType = 5 + taskValue = $.visitSkuValue || 5 + }else if(type == 'toShop'){ + taskType = 14 + taskValue = $.toShopValue || 14 + }else if(type == 'addSku'){ + taskType = 2 + taskValue = $.addSkuValue || 2 + } + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&taskType=${taskType}&taskValue=${taskValue}` + break; + case 'getDrawRecordHasCoupon': + url = `${domain}/dingzhi/linkgame/draw/record`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case 'getShareRecord': + url = `${domain}/dingzhi/linkgame/help/list`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case '抽奖': + url = `${domain}/dingzhi/linkgame/draw`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + default: + console.log(`错误${type}`); + } + let myRequest = getPostRequest(url, body, method); + // console.log(myRequest) + return new Promise(async resolve => { + $.post(myRequest, (err, resp, data) => { + try { + setActivityCookie(resp) + if (err) { + if(resp && typeof resp.statusCode != 'undefined'){ + if(resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + } + console.log(`${$.toStr(err,err)}`) + console.log(`${type} API请求失败,请检查网路重试`) + } else { + dealReturn(type, data); + } + } catch (e) { + // console.log(data); + console.log(e, resp) + } finally { + resolve(); + } + }) + }) + } + +async function dealReturn(type, data) { + let res = '' + try { + if(type != 'accessLogWithAD' || type != 'drawContent'){ + if(data){ + res = JSON.parse(data); + } + } + } catch (e) { + console.log(`${type} 执行任务异常`); + console.log(data); + $.runFalag = false; + } + try { + switch (type) { + case 'isvObfuscator': + if(typeof res == 'object'){ + if(res.errcode == 0){ + if(typeof res.token != 'undefined') $.Token = res.token + }else if(res.message){ + console.log(`isvObfuscator ${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + break; + case 'getSimpleActInfoVo': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(typeof res.data.shopId != 'undefined') $.shopId = res.data.shopId + if(typeof res.data.venderId != 'undefined') $.venderId = res.data.venderId + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getMyPing': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(res.data && typeof res.data.secretPin != 'undefined') $.Pin = res.data.secretPin + if(res.data && typeof res.data.nickname != 'undefined') $.nickname = res.data.nickname + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getUserInfo': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(res.data && typeof res.data.yunMidImageUrl != 'undefined') $.attrTouXiang = res.data.yunMidImageUrl || "https://img10.360buyimg.com/imgzone/jfs/t1/7020/27/13511/6142/5c5138d8E4df2e764/5a1216a3a5043c5d.png" + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'activityContent': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + $.endTime = res.data.endTime || res.data.activity.endTime || 0 + $.hasEnd = res.data.isEnd || false + $.drawCount = res.data.actor.drawCount || 0 + $.point = res.data.actor.point || 0 + $.score = res.data.actor.score || 0 + $.actorUuid = res.data.actor.actorUuid || '' + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'info': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + // $.drawCount = res.data.drawCount || 0 + $.addCart = res.data.addCart || false + $.followShop = res.data.followShop || false + $.sign = res.data.sign || false + $.visitSku = res.data.visitSku || false + $.visitSkuList = res.data.visitSkuList || [] + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'checkOpenCard': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + let cardList1 = res.data.cardList1 || [] + let cardList2 = res.data.cardList2 || [] + let cardList = res.data.cardList || [] + let openCardList = res.data.openCardList || [] + $.openList = [...cardList,...cardList1,...cardList2,...openCardList] + $.allOpenCard = res.data.allOpenCard || false + $.openCardScore1 = res.data.score1 || 0 + $.openCardScore2 = res.data.score2 || 0 + $.drawScore = res.data.drawScore || 0 + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'startDraw': + case 'followShop': + case 'viewVideo': + case 'visitSku': + case 'toShop': + case 'addSku': + case 'sign': + case 'addCart': + case 'browseGoods': + case '抽奖': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(typeof res.data == 'object'){ + let msg = '' + let title = '抽奖' + if(res.data.addBeanNum){ + msg = `${res.data.addBeanNum}京豆` + } + if(res.data.addPoint){ + msg += ` ${res.data.addPoint}游戏机会` + } + if(type == 'followShop'){ + title = '关注' + if(res.data.beanNumMember && res.data.assistSendStatus){ + msg += ` 额外获得:${res.data.beanNumMember}京豆` + } + }else if(type == 'addSku' || type == 'addCart'){ + title = '加购' + }else if(type == 'viewVideo'){ + title = '热门文章' + }else if(type == 'toShop'){ + title = '浏览店铺' + }else if(type == 'visitSku' || type == 'browseGoods'){ + title = '浏览商品' + }else if(type == 'sign'){ + title = '签到' + }else{ + msg = res.data.drawOk == true && (res.data.drawInfoType == 6 && res.data.name || '') || '空气💨' + } + if(!msg){ + msg = '空气💨' + } + console.log(`${title}获得:${msg || data}`) + }else{ + console.log(`${type} ${data}`) + } + }else if(res.errorMessage){ + $.runFalag = false; + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getDrawRecordHasCoupon': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + console.log(`我的奖品:`) + let num = 0 + let value = 0 + for(let i in res.data.recordList){ + let item = res.data.recordList[i] + if(item.infoName == '20京豆'){ + num++ + value = item.infoName.replace('京豆','') + }else{ + console.log(`${item.infoType != 10 && item.value && item.value +':' || ''}${item.infoName}`) + } + } + if(num > 0) console.log(`邀请好友(${num}):${num*parseInt(value, 10) || 30}京豆`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getShareRecord': + if(typeof res == 'object'){ + if(res.result && res.result === true && res.data){ + $.ShareCount = res.data.shareList.length + $.log(`=========== 你邀请了:${res.data.shareList.length}个`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case '邀请': + case '助力': + // console.log(data) + if(typeof res == 'object'){ + if(res.data.status == 200){ + if(type == '助力'){ + console.log('助力成功') + }else{ + $.yaoqing = true + } + }else if(res.data.status == 105){ + console.log('已经助力过') + }else if(res.data.status == 104){ + console.log('已经助力其他人') + }else if(res.data.status == 101){ + // console.log('已经助力过') + }else{ + console.log(data) + } + }else{ + console.log(`${type} ${data}`) + } + + case 'accessLogWithAD': + case 'drawContent': + break; + default: + console.log(`${type}-> ${data}`); + } + if(typeof res == 'object'){ + if(res.errorMessage){ + if(res.errorMessage.indexOf('火爆') >-1 ){ + $.hotFlag = true + } + } + } + } catch (e) { + console.log(e) + } +} + +function getPostRequest(url, body, method="POST") { + let headers = { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Content-Type": "application/x-www-form-urlencoded", + "Cookie": cookie, + "User-Agent": $.UA, + "X-Requested-With": "XMLHttpRequest" + } + if(url.indexOf('https://lzdz1-isv.isvjcloud.com') > -1){ + headers["Referer"] = `https://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}` + headers["Cookie"] = `${lz_jdpin_token_cookie && lz_jdpin_token_cookie || ''}${$.Pin && "AUTH_C_USER=" + $.Pin + ";" || ""}${activityCookie}` + } + // console.log(headers) + // console.log(headers.Cookie) + return {url: url, method: method, headers: headers, body: body, timeout:30000}; +} + +function getCk() { + return new Promise(resolve => { + let get = { + url:`https://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}`, + followRedirect:false, + headers: { + "User-Agent": $.UA, + }, + timeout:30000 + } + $.get(get, async(err, resp, data) => { + try { + if (err) { + if(resp && typeof resp.statusCode != 'undefined'){ + if(resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + } + console.log(`${$.toStr(err)}`) + console.log(`${$.name} cookie API请求失败,请检查网路重试`) + } else { + let end = data.match(/(活动已经结束)/) && data.match(/(活动已经结束)/)[1] || '' + if(end){ + $.activityEnd = true + console.log('活动已结束') + } + setActivityCookie(resp) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function setActivityCookie(resp){ + let LZ_TOKEN_KEY = '' + let LZ_TOKEN_VALUE = '' + let lz_jdpin_token = '' + let setcookies = resp && resp['headers'] && (resp['headers']['set-cookie'] || resp['headers']['Set-Cookie'] || '') || '' + let setcookie = '' + if(setcookies){ + if(typeof setcookies != 'object'){ + setcookie = setcookies.split(',') + }else setcookie = setcookies + for (let ck of setcookie) { + let name = ck.split(";")[0].trim() + if(name.split("=")[1]){ + // console.log(name.replace(/ /g,'')) + if(name.indexOf('LZ_TOKEN_KEY=')>-1) LZ_TOKEN_KEY = name.replace(/ /g,'')+';' + if(name.indexOf('LZ_TOKEN_VALUE=')>-1) LZ_TOKEN_VALUE = name.replace(/ /g,'')+';' + if(name.indexOf('lz_jdpin_token=')>-1) lz_jdpin_token = ''+name.replace(/ /g,'')+';' + } + } + } + if(LZ_TOKEN_KEY && LZ_TOKEN_VALUE) activityCookie = `${LZ_TOKEN_KEY} ${LZ_TOKEN_VALUE}` + if(lz_jdpin_token) lz_jdpin_token_cookie = lz_jdpin_token +} + +async function getUA(){ + $.UA = `jdapp;iPhone;10.1.4;13.1.2;${randomString(40)};network/wifi;model/iPhone8,1;addressid/2308460611;appBuild/167814;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_1_2 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 joinShop() { + if(!$.joinVenderId) return + return new Promise(async resolve => { + $.shopactivityId = '' + await $.wait(1000) + await getshopactivityId() + let activityId = `` + if($.shopactivityId) activityId = `,"activityId":${$.shopactivityId}` + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body={"venderId":"${$.joinVenderId}","shopId":"${$.joinVenderId}","bindByVerifyCodeFlag":1,"registerExtend":{},"writeChildFlag":0${activityId},"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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + // console.log(data) + let res = $.toObj(data); + if(typeof res == 'object'){ + if(res.success === true){ + console.log(res.message) + if(res.result && res.result.giftInfo){ + for(let i of res.result.giftInfo.giftList){ + console.log(`入会获得:${i.discountString}${i.prizeName}${i.secondLineDesc}`) + } + } + }else if(typeof res == 'object' && res.message){ + console.log(`${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function getshopactivityId() { + return new Promise(resolve => { + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body=%7B%22venderId%22%3A%22${$.joinVenderId}%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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + let res = $.toObj(data); + if(res.success == true){ + // console.log($.toStr(res.result)) + console.log(`入会:${res.result.shopMemberCardInfo.venderCardName || ''}`) + $.shopactivityId = res.result.interestsRuleList && res.result.interestsRuleList[0] && res.result.interestsRuleList[0].interestsInfo && res.result.interestsRuleList[0].interestsInfo.activityId || '' + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} + + +// 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)} diff --git a/activity/jd_opencardL38.js b/activity/jd_opencardL38.js new file mode 100644 index 0000000..7c2deb2 --- /dev/null +++ b/activity/jd_opencardL38.js @@ -0,0 +1,874 @@ +/* +1.5~1.25 集“年味卡”,享年货盛宴 +新增开卡脚本,一次性脚本 + +1.邀请一人10豆 +2.开10张卡 成功开1张 获得5豆 +3.关注5豆 +4.抽奖 +5.集卡 +6.大于1张福卡时 26号会通知瓜分 + +———————————————— +入口:[ 1.5~1.25 集“年味卡”,享年货盛宴 (https://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=cd2022n4ci22tlj1s2w3245u1mk&shareUuid=01f9ed66c62d4c418822efa47134ba6c)] + + +cron:30 0,14 5-26 1 * +============Quantumultx=============== +[task_local] +1.5~1.25 集“年味卡”,享年货盛宴 +30 0,14 5-26 1 * jd_opencardL38.js, tag=1.5~1.25 集“年味卡”,享年货盛宴, enabled=true + + +*/ + +const $ = new Env('1.5~1.25 集“年味卡”,享年货盛宴'); +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const notify = $.isNode() ? require('./sendNotify') : ''; +//IOS等用户直接用NobyDa的jd cookie + +let cookiesArr = [], + cookie = ''; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} +allMessage = "" +message = "" +$.hotFlag = false +$.outFlag = false +$.activityEnd = false +let lz_jdpin_token_cookie ='' +let activityCookie ='' +const activeEndTime = '2022/01/26 00:00:00+08:00';//活动结束时间 +let nowTime = new Date().getTime() + new Date().getTimezoneOffset()*60*1000 + 8*60*60*1000; +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', { + "open-url": "https://bean.m.jd.com/" + }); + return; + } + $.activityId = "cd2022n4ci22tlj1s2w3245u1mk" + $.shareUuid = "01f9ed66c62d4c418822efa47134ba6c" + console.log(`入口:\nhttps://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}`) + + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i]; + if (cookie) { + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + message = "" + $.bean = 0 + $.hotFlag = false + $.nickName = ''; + console.log(`\n\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + await getUA() + await run(); + if(i == 0 && !$.actorUuid) break + if($.outFlag || $.activityEnd) break + } + } + if($.outFlag) { + let msg = '此ip已被限制,请过10分钟后再执行脚本' + $.msg($.name, ``, `${msg}`); + if ($.isNode()) await notify.sendNotify(`${$.name}`, `${msg}`); + } + if(allMessage){ + allMessage = `以下账号可参与瓜分京豆\n${allMessage}\n入口:https://3.cn/-10402R7b` + $.msg($.name, ``, `${allMessage}`); + if ($.isNode()) await notify.sendNotify(`${$.name}`, `${allMessage}`); + } +})() + .catch((e) => $.logErr(e)) + .finally(() => $.done()) + + +async function run() { + try { + $.hasEnd = true + $.endTime = 0 + lz_jdpin_token_cookie = '' + $.Token = '' + $.Pin = '' + let flag = false + await takePostRequest('isvObfuscator'); + if($.Token == ''){ + console.log('获取[token]失败!') + return + } + await getCk() + if (activityCookie == '') { + console.log(`获取cookie失败`); return; + } + if($.activityEnd === true){ + console.log('活动结束') + return + } + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + await takePostRequest('getSimpleActInfoVo'); + await takePostRequest('getMyPing'); + if(!$.Pin){ + console.log('获取[Pin]失败!') + return + } + await takePostRequest('accessLogWithAD'); + await takePostRequest('getUserInfo'); + await takePostRequest('activityContent'); + if($.hotFlag) return + if(!$.actorUuid){ + console.log('获取不到[actorUuid]退出执行,请重新执行') + return + } + if(($.hasEnd === true || Date.now() > $.endTime) && nowTime > new Date('2022/01/27 00:00:00+08:00').getTime()){ + $.activityEnd = true + console.log('活动结束') + return + } + await takePostRequest('drawContent'); + await $.wait(1000) + $.openList = [] + $.allOpenCard = false + await takePostRequest('checkOpenCard'); + if($.allOpenCard == false){ + console.log('开卡任务') + for(o of $.openList){ + $.openCard = false + if(o.status == 0){ + flag = true + $.joinVenderId = o.venderId + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + await joinShop() + await $.wait(parseInt(Math.random() * 1000 + 1000, 10)) + await takePostRequest('activityContent'); + await takePostRequest('drawContent'); + await takePostRequest('checkOpenCard'); + await $.wait(parseInt(Math.random() * 3000 + 2000, 10)) + } + } + }else{ + console.log('已全部开卡') + } + + $.log("关注: " + $.followShop) + if(!$.followShop && !$.outFlag){ + flag = true + await takePostRequest('followShop'); + await $.wait(parseInt(Math.random() * 2000 + 3000, 10)) + } + $.yaoqing = false + await takePostRequest('助力'); + if($.yaoqing){ + await takePostRequest('邀请'); + } + if(flag){ + await takePostRequest('activityContent'); + } + await takePostRequest('getCardInfo'); + if($.drawCardNum){ + let count = $.drawCardNum + for(m=1;count--;m++){ + if($.compositeCardNum > 0) break + console.log(`第${m}次集卡`) + await takePostRequest('集卡'); + await takePostRequest('getCardInfo'); + if($.runFalag == false || $.compositeCardNum > 0) break + if(Number(count) <= 0) break + if(m >= 5){ + console.log("集卡太多次,多余的次数请再执行脚本") + break + } + await $.wait(parseInt(Math.random() * 2000 + 2000, 10)) + } + if($.compositeCardNum){ + let count = $.compositeCardNum + for(m=1;count--;m++){ + console.log(`第${m}次合卡`) + await takePostRequest('合卡'); + if($.runFalag == false) break + if(Number(count) <= 0) break + if(m >= 5){ + console.log("合卡太多次,多余的次数请再执行脚本") + break + } + await $.wait(parseInt(Math.random() * 2000 + 2000, 10)) + } + } + } + for(let c of $.myCardList || []){ + console.log(`${c.cardName}:${c.cardNum}`) + } + if ($.compositeCardFinishCount >= 1 && nowTime > new Date(activeEndTime).getTime()) { + allMessage += `【京东账号${$.index}】${$.nickName || $.UserName}\n` + } + console.log(`${$.score}值 福卡:${$.compositeCardFinishCount}`) + $.runFalag = true + let count = parseInt($.score/100) + console.log(`抽奖次数为:${count}`) + for(m=1;count--;m++){ + console.log(`第${m}次抽奖`) + await takePostRequest('抽奖'); + if($.runFalag == false) break + if(Number(count) <= 0) break + if(m >= 1){ + console.log("抽奖太多次,多余的次数请再执行脚本") + break + } + await $.wait(parseInt(Math.random() * 2000 + 2000, 10)) + } + + await $.wait(parseInt(Math.random() * 1000 + 2000, 10)) + await takePostRequest('getDrawRecordHasCoupon'); + await takePostRequest('getShareRecord'); + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + console.log($.actorUuid) + console.log(`当前助力:${$.shareUuid}`) + if($.index == 1){ + $.shareUuid = $.actorUuid + console.log(`后面的号都会助力:${$.shareUuid}`) + } + await $.wait(parseInt(Math.random() * 1000 + 5000, 10)) + if(flag) await $.wait(parseInt(Math.random() * 1000 + 10000, 10)) + if($.index % 3 == 0) console.log('休息1分钟,别被黑ip了\n可持续发展') + if($.index % 3 == 0) await $.wait(parseInt(Math.random() * 5000 + 60000, 10)) + } catch (e) { + console.log(e) + } +} + +async function takePostRequest(type) { + if($.outFlag) return + let domain = 'https://lzdz1-isv.isvjcloud.com'; + let body = ``; + let method = 'POST' + let admJson = '' + switch (type) { + case 'isvObfuscator': + url = `https://api.m.jd.com/client.action?functionId=isvObfuscator`; + body = `body=%7B%22url%22%3A%22https%3A//lzdz1-isv.isvjcloud.com%22%2C%22id%22%3A%22%22%7D&uuid=7088d9018515b8cb0c88ace6e5479762af3e88f3&client=apple&clientVersion=10.1.4&st=1634343624086&sv=120&sign=8b9cea22c3a0d77026abda5d37d2b7e3`; + break; + case 'getSimpleActInfoVo': + url = `${domain}/dz/common/getSimpleActInfoVo`; + body = `activityId=${$.activityId}`; + break; + case 'getMyPing': + url = `${domain}/customer/getMyPing`; + body = `userId=${$.shopId || $.venderId || ''}&token=${$.Token}&fromType=APP`; + break; + case 'accessLogWithAD': + url = `${domain}/common/accessLogWithAD`; + let pageurl = `${domain}/drawCenter/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}` + body = `venderId=${$.shopId || $.venderId || ''}&code=99&pin=${encodeURIComponent($.Pin)}&activityId=${$.activityId}&pageUrl=${encodeURIComponent(pageurl)}&subType=app&adSource=` + break; + case 'getUserInfo': + url = `${domain}/wxActionCommon/getUserInfo`; + body = `pin=${encodeURIComponent($.Pin)}`; + break; + case 'activityContent': + url = `${domain}/play/monopoly/getContent`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&pinImg=${encodeURIComponent($.attrTouXiang)}&nick=${encodeURIComponent($.nickname)}&cjyxPin=&cjhyPin=&shareUuid=${$.shareUuid}` + break; + case 'drawContent': + url = `${domain}/dingzhi/taskact/common/drawContent`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case 'checkOpenCard': + url = `${domain}/play/monopoly/checkOpenCard`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case 'info': + url = `${domain}/play/monopoly/getTaskList`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case 'startDraw': + url = `${domain}/play/monopoly/activeDraw`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&drawType=1` + break; + case 'getCardInfo': + url = `${domain}/play/monopoly/getCardInfo`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case '集卡': + url = `${domain}/play/monopoly/drawCard`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case '合卡': + url = `${domain}/play/monopoly/compositeCard`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case 'followShop': + url = `${domain}/play/monopoly/doTasks`; + // url = `${domain}/dingzhi/dz/openCard/saveTask`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&taskType=1` + break; + case 'sign': + case 'addCart': + case 'browseGoods': + url = `${domain}/dingzhi/linkgame/${type}`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + if(type == 'browseGoods') body += `&value=${$.visitSkuValue}` + break; + case '邀请': + case '助力': + if(type == '助力'){ + url = `${domain}/play/monopoly/getAssistStatus`; + }else{ + url = `${domain}/play/monopoly/assist`; + } + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&shareUuid=${$.shareUuid}&actorUuid=${$.actorUuid}` + break; + case 'viewVideo': + case 'visitSku': + case 'toShop': + case 'addSku': + url = `${domain}/dingzhi/dz/openCard/saveTask`; + let taskType = '' + let taskValue = '' + if(type == 'viewVideo'){ + taskType = 31 + taskValue = 31 + }else if(type == 'visitSku'){ + taskType = 5 + taskValue = $.visitSkuValue || 5 + }else if(type == 'toShop'){ + taskType = 14 + taskValue = $.toShopValue || 14 + }else if(type == 'addSku'){ + taskType = 2 + taskValue = $.addSkuValue || 2 + } + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&taskType=${taskType}&taskValue=${taskValue}` + break; + case 'getDrawRecordHasCoupon': + url = `${domain}/play/monopoly/getPrizeList`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case 'getShareRecord': + url = `${domain}/play/monopoly/getHelpList`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case '抽奖': + url = `${domain}/play/monopoly/activeDraw`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&drawType=2` + break; + default: + console.log(`错误${type}`); + } + let myRequest = getPostRequest(url, body, method); + // console.log(myRequest) + return new Promise(async resolve => { + $.post(myRequest, (err, resp, data) => { + try { + setActivityCookie(resp) + if (err) { + if(resp && typeof resp.statusCode != 'undefined'){ + if(resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + } + console.log(`${$.toStr(err,err)}`) + console.log(`${type} API请求失败,请检查网路重试`) + } else { + dealReturn(type, data); + } + } catch (e) { + // console.log(data); + console.log(e, resp) + } finally { + resolve(); + } + }) + }) + } + +async function dealReturn(type, data) { + let res = '' + try { + if(type != 'accessLogWithAD' || type != 'drawContent'){ + if(data){ + res = JSON.parse(data); + } + } + } catch (e) { + console.log(`${type} 执行任务异常`); + console.log(data); + $.runFalag = false; + } + try { + switch (type) { + case 'isvObfuscator': + if(typeof res == 'object'){ + if(res.errcode == 0){ + if(typeof res.token != 'undefined') $.Token = res.token + }else if(res.message){ + console.log(`isvObfuscator ${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + break; + case 'getSimpleActInfoVo': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(typeof res.data.shopId != 'undefined') $.shopId = res.data.shopId + if(typeof res.data.venderId != 'undefined') $.venderId = res.data.venderId + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getMyPing': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(res.data && typeof res.data.secretPin != 'undefined') $.Pin = res.data.secretPin + if(res.data && typeof res.data.nickname != 'undefined') $.nickname = res.data.nickname + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getUserInfo': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(res.data && typeof res.data.yunMidImageUrl != 'undefined') $.attrTouXiang = res.data.yunMidImageUrl || "https://img10.360buyimg.com/imgzone/jfs/t1/7020/27/13511/6142/5c5138d8E4df2e764/5a1216a3a5043c5d.png" + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'activityContent': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + $.endTime = res.data.endTime || (res.data.activityVo && res.data.activityVo.endTime) || res.data.activity.endTime || 0 + $.hasEnd = res.data.isEnd || false + $.drawCount = res.data.actorVo.drawCount || 0 + $.point = res.data.actorVo.point || 0 + $.score = res.data.actorVo.score || 0 + $.actorUuid = res.data.actorVo.actorUuid || '' + $.followShop = res.data.actorVo.followShopStatus || '' + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'info': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + // $.drawCount = res.data.drawCount || 0 + $.addCart = res.data.addCart || false + $.followShop = res.data.followShop || false + $.sign = res.data.isSignStatus || false + $.visitSku = res.data.visitSku || false + $.visitSkuList = res.data.visitSkuList || [] + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'checkOpenCard': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + // console.log(data) + let cardList1 = res.data.cardList1 || [] + let cardList2 = res.data.cardList2 || [] + let cardList = res.data.cardList || [] + let openCardList = res.data.openCardList || [] + $.openList = [...cardList,...cardList1,...cardList2,...openCardList] + $.allOpenCard = res.data.allOpenCard || res.data.isOpenCardStatus || false + $.openCardScore1 = res.data.score1 || 0 + $.openCardScore2 = res.data.score2 || 0 + $.drawScore = res.data.drawScore || 0 + if(res.data.beans || res.data.addBeanNum) console.log(`开卡获得:${res.data.beans || res.data.addBeanNum}豆`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'startDraw': + case 'followShop': + case 'viewVideo': + case 'visitSku': + case 'toShop': + case 'addSku': + case 'sign': + case 'addCart': + case 'browseGoods': + case '抽奖': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(typeof res.data == 'object'){ + let msg = '' + let title = '抽奖' + if(res.data.addBeanNum){ + msg = `${res.data.addBeanNum}京豆` + } + if(res.data.addPoint){ + msg += ` ${res.data.addPoint}游戏机会` + } + if(type == 'followShop'){ + title = '关注' + if(res.data.beanNumMember && res.data.assistSendStatus){ + msg += ` 额外获得:${res.data.beanNumMember}京豆` + } + }else if(type == 'addSku' || type == 'addCart'){ + title = '加购' + }else if(type == 'viewVideo'){ + title = '热门文章' + }else if(type == 'toShop'){ + title = '浏览店铺' + }else if(type == 'visitSku' || type == 'browseGoods'){ + title = '浏览商品' + }else if(type == 'sign'){ + title = '签到' + }else{ + msg = res.data.drawOk == true && (res.data.drawInfoType == 6 && res.data.name || '') || '空气💨' + } + if(!msg){ + msg = '空气💨' + } + console.log(`${title}获得:${msg || data}`) + }else{ + console.log(`${type} ${data}`) + } + }else if(res.errorMessage){ + $.runFalag = false; + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getDrawRecordHasCoupon': + // console.log(data) + if(typeof res == 'object'){ + if(res.result && res.result === true){ + console.log(`我的奖品:`) + let num = 0 + let value = 0 + for(let i in res.data){ + let item = res.data[i] + if(item.drawId == 'assist'){ + num++ + value = item.infoName.replace('京豆','') + }else{ + console.log(`${item.infoType != 10 && item.drawId && item.drawId +':' || ''}${item.infoName}`) + } + } + if(num > 0) console.log(`邀请好友(${num}):${num*parseInt(value, 10) || 30}京豆`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getShareRecord': + if(typeof res == 'object'){ + if(res.result && res.result === true && res.data){ + $.ShareCount = res.data.length + $.log(`=========== 你邀请了:${res.data.length}个`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getCardInfo': + case '集卡': + case '合卡': + if(typeof res == 'object'){ + if(res.result && res.result === true && res.data){ + if(type == "集卡"){ + if(res.data.status == 1) console.log(`集卡成功->${res.data.cardName}`) + else console.log('集卡失败'+ res.data.cardName && '->'+res.data.cardName || '\n'+data) + }else if(type == "合卡"){ + if(res.data.status == 1) console.log('合卡成功') + else console.log('合卡失败\n'+data) + }else if(type == "getCardInfo"){ + $.score = res.data.score || 0 + $.myCardList = res.data.myCardList || [] + $.compositeCardFinishCount = res.data.compositeCardFinishCount || 0 + $.compositeCardNum = res.data.compositeCardNum || 0 + $.drawCardNum = res.data.drawCardNum || 0 + } + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case '邀请': + case '助力': + // console.log(data) + if(typeof res == 'object'){ + if(res.data == 200){ + if(type == '助力'){ + console.log('助力成功') + $.yaoqing = true + } + }else if(res.data == 105){ + console.log('已经助力过') + }else if(res.data == 104){ + console.log('已经助力其他人') + }else if(res.data == 101){ + // console.log('已经助力过') + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + + case 'accessLogWithAD': + case 'drawContent': + break; + default: + console.log(`${type}-> ${data}`); + } + if(typeof res == 'object'){ + if(res.errorMessage){ + if(res.errorMessage.indexOf('火爆') >-1 ){ + $.hotFlag = true + } + } + } + } catch (e) { + console.log(e) + } +} + +function getPostRequest(url, body, method="POST") { + let headers = { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Content-Type": "application/x-www-form-urlencoded", + "Cookie": cookie, + "User-Agent": $.UA, + "X-Requested-With": "XMLHttpRequest" + } + if(url.indexOf('https://lzdz1-isv.isvjcloud.com') > -1){ + headers["Referer"] = `https://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}` + headers["Cookie"] = `${lz_jdpin_token_cookie && lz_jdpin_token_cookie || ''}${$.Pin && "AUTH_C_USER=" + $.Pin + ";" || ""}${activityCookie}` + } + // console.log(headers) + // console.log(headers.Cookie) + return {url: url, method: method, headers: headers, body: body, timeout:30000}; +} + +function getCk() { + return new Promise(resolve => { + let get = { + url:`https://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}`, + followRedirect:false, + headers: { + "User-Agent": $.UA, + }, + timeout:30000 + } + $.get(get, async(err, resp, data) => { + try { + if (err) { + if(resp && typeof resp.statusCode != 'undefined'){ + if(resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + } + console.log(`${$.toStr(err)}`) + console.log(`${$.name} cookie API请求失败,请检查网路重试`) + } else { + let end = data.match(/(活动已经结束)/) && data.match(/(活动已经结束)/)[1] || '' + if(end){ + $.activityEnd = true + console.log('活动已结束') + } + setActivityCookie(resp) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function setActivityCookie(resp){ + let LZ_TOKEN_KEY = '' + let LZ_TOKEN_VALUE = '' + let lz_jdpin_token = '' + let setcookies = resp && resp['headers'] && (resp['headers']['set-cookie'] || resp['headers']['Set-Cookie'] || '') || '' + let setcookie = '' + if(setcookies){ + if(typeof setcookies != 'object'){ + setcookie = setcookies.split(',') + }else setcookie = setcookies + for (let ck of setcookie) { + let name = ck.split(";")[0].trim() + if(name.split("=")[1]){ + // console.log(name.replace(/ /g,'')) + if(name.indexOf('LZ_TOKEN_KEY=')>-1) LZ_TOKEN_KEY = name.replace(/ /g,'')+';' + if(name.indexOf('LZ_TOKEN_VALUE=')>-1) LZ_TOKEN_VALUE = name.replace(/ /g,'')+';' + if(name.indexOf('lz_jdpin_token=')>-1) lz_jdpin_token = ''+name.replace(/ /g,'')+';' + } + } + } + if(LZ_TOKEN_KEY && LZ_TOKEN_VALUE) activityCookie = `${LZ_TOKEN_KEY} ${LZ_TOKEN_VALUE}` + if(lz_jdpin_token) lz_jdpin_token_cookie = lz_jdpin_token +} + +async function getUA(){ + $.UA = `jdapp;iPhone;10.1.4;13.1.2;${randomString(40)};network/wifi;model/iPhone8,1;addressid/2308460611;appBuild/167814;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_1_2 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 joinShop() { + if(!$.joinVenderId) return + return new Promise(async resolve => { + $.shopactivityId = '' + await $.wait(1000) + await getshopactivityId() + let activityId = `` + if($.shopactivityId) activityId = `,"activityId":${$.shopactivityId}` + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body={"venderId":"${$.joinVenderId}","shopId":"${$.joinVenderId}","bindByVerifyCodeFlag":1,"registerExtend":{},"writeChildFlag":0${activityId},"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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + // console.log(data) + let res = $.toObj(data); + if(typeof res == 'object'){ + if(res.success === true){ + console.log(res.message) + if(res.result && res.result.giftInfo){ + for(let i of res.result.giftInfo.giftList){ + console.log(`入会获得:${i.discountString}${i.prizeName}${i.secondLineDesc}`) + } + } + }else if(typeof res == 'object' && res.message){ + console.log(`${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function getshopactivityId() { + return new Promise(resolve => { + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body=%7B%22venderId%22%3A%22${$.joinVenderId}%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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + let res = $.toObj(data); + if(res.success == true){ + // console.log($.toStr(res.result)) + console.log(`入会:${res.result.shopMemberCardInfo.venderCardName || ''}`) + $.shopactivityId = res.result.interestsRuleList && res.result.interestsRuleList[0] && res.result.interestsRuleList[0].interestsInfo && res.result.interestsRuleList[0].interestsInfo.activityId || '' + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} + + +// 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)} + diff --git a/activity/jd_opencardL39.js b/activity/jd_opencardL39.js new file mode 100644 index 0000000..d2b307b --- /dev/null +++ b/activity/jd_opencardL39.js @@ -0,0 +1,874 @@ +/* +1.5~1.31 年货盛宴,春节集福攻略 +新增开卡脚本,一次性脚本 + +1.邀请一人10豆 +2.开10张卡 成功开1张 获得5豆 +3.关注5豆 +4.抽奖 +5.集卡 +6.大于1张福卡时 31号会通知瓜分 + +———————————————— +入口:[ 1.5~1.31 年货盛宴,春节集福攻略 (https://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity/9810692?activityId=cd20220105fff606x19uj4vijetkg&shareUuid=1ade9f197b6d4966846d69f26e533717)] + + +cron:5 0,17 5-31 1 * +============Quantumultx=============== +[task_local] +1.5~1.31 年货盛宴,春节集福攻略 +5 0,17 5-31 1 * jd_opencardL39.js, tag=1.5~1.31 年货盛宴,春节集福攻略, enabled=true + + +*/ + +const $ = new Env('1.5~1.31 年货盛宴,春节集福攻略'); +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const notify = $.isNode() ? require('./sendNotify') : ''; +//IOS等用户直接用NobyDa的jd cookie + +let cookiesArr = [], + cookie = ''; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} +allMessage = "" +message = "" +$.hotFlag = false +$.outFlag = false +$.activityEnd = false +let lz_jdpin_token_cookie ='' +let activityCookie ='' +const activeEndTime = '2022/01/31 00:00:00+08:00';//活动结束时间 +let nowTime = new Date().getTime() + new Date().getTimezoneOffset()*60*1000 + 8*60*60*1000; +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', { + "open-url": "https://bean.m.jd.com/" + }); + return; + } + $.activityId = "cd20220105fff606x19uj4vijetkg" + $.shareUuid = "1ade9f197b6d4966846d69f26e533717" + console.log(`入口:\nhttps://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}`) + + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i]; + if (cookie) { + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + message = "" + $.bean = 0 + $.hotFlag = false + $.nickName = ''; + console.log(`\n\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + await getUA() + await run(); + if(i == 0 && !$.actorUuid) break + if($.outFlag || $.activityEnd) break + } + } + if($.outFlag) { + let msg = '此ip已被限制,请过10分钟后再执行脚本' + $.msg($.name, ``, `${msg}`); + if ($.isNode()) await notify.sendNotify(`${$.name}`, `${msg}`); + } + if(allMessage){ + allMessage = `以下账号可参与瓜分京豆\n${allMessage}\n` + $.msg($.name, ``, `${allMessage}`); + if ($.isNode()) await notify.sendNotify(`${$.name}`, `${allMessage}`); + } +})() + .catch((e) => $.logErr(e)) + .finally(() => $.done()) + + +async function run() { + try { + $.hasEnd = true + $.endTime = 0 + lz_jdpin_token_cookie = '' + $.Token = '' + $.Pin = '' + let flag = false + await takePostRequest('isvObfuscator'); + if($.Token == ''){ + console.log('获取[token]失败!') + return + } + await getCk() + if (activityCookie == '') { + console.log(`获取cookie失败`); return; + } + if($.activityEnd === true){ + console.log('活动结束') + return + } + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + await takePostRequest('getSimpleActInfoVo'); + await takePostRequest('getMyPing'); + if(!$.Pin){ + console.log('获取[Pin]失败!') + return + } + await takePostRequest('accessLogWithAD'); + await takePostRequest('getUserInfo'); + await takePostRequest('activityContent'); + if($.hotFlag) return + if(!$.actorUuid){ + console.log('获取不到[actorUuid]退出执行,请重新执行') + return + } + if(($.hasEnd === true || Date.now() > $.endTime) && nowTime > new Date('2022/02/1 00:00:00+08:00').getTime()){ + $.activityEnd = true + console.log('活动结束') + return + } + await takePostRequest('drawContent'); + await $.wait(1000) + $.openList = [] + $.allOpenCard = false + await takePostRequest('checkOpenCard'); + if($.allOpenCard == false){ + console.log('开卡任务') + for(o of $.openList){ + $.openCard = false + if(o.status == 0){ + flag = true + $.joinVenderId = o.venderId + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + await joinShop() + await $.wait(parseInt(Math.random() * 1000 + 1000, 10)) + await takePostRequest('activityContent'); + await takePostRequest('drawContent'); + await takePostRequest('checkOpenCard'); + await $.wait(parseInt(Math.random() * 3000 + 2000, 10)) + } + } + }else{ + console.log('已全部开卡') + } + await takePostRequest('addSku'); + $.log("关注: " + $.followShop) + if(!$.followShop && !$.outFlag){ + flag = true + await takePostRequest('followShop'); + await $.wait(parseInt(Math.random() * 2000 + 3000, 10)) + } + $.yaoqing = false + await takePostRequest('助力'); + if($.yaoqing){ + await takePostRequest('邀请'); + } + if(flag){ + await takePostRequest('activityContent'); + } + await takePostRequest('getCardInfo'); + if($.drawCardNum){ + let count = $.drawCardNum + for(m=1;count--;m++){ + if($.compositeCardNum > 0) break + console.log(`第${m}次集卡`) + await takePostRequest('集卡'); + await takePostRequest('getCardInfo'); + if($.runFalag == false || $.compositeCardNum > 0) break + if(Number(count) <= 0) break + if(m >= 5){ + console.log("集卡太多次,多余的次数请再执行脚本") + break + } + await $.wait(parseInt(Math.random() * 2000 + 2000, 10)) + } + if($.compositeCardNum){ + let count = $.compositeCardNum + for(m=1;count--;m++){ + console.log(`第${m}次合卡`) + await takePostRequest('合卡'); + if($.runFalag == false) break + if(Number(count) <= 0) break + if(m >= 5){ + console.log("合卡太多次,多余的次数请再执行脚本") + break + } + await $.wait(parseInt(Math.random() * 2000 + 2000, 10)) + } + } + } + for(let c of $.myCardList || []){ + console.log(`${c.cardName}:${c.cardNum}`) + } + if ($.compositeCardFinishCount >= 1 && nowTime > new Date(activeEndTime).getTime()) { + allMessage += `【京东账号${$.index}】${$.nickName || $.UserName}\n` + } + console.log(`${$.score}值 福卡:${$.compositeCardFinishCount}`) + $.runFalag = true + let count = parseInt($.score/100) + console.log(`抽奖次数为:${count}`) + for(m=1;count--;m++){ + console.log(`第${m}次抽奖`) + await takePostRequest('抽奖'); + if($.runFalag == false) break + if(Number(count) <= 0) break + if(m >= 1){ + console.log("抽奖太多次,多余的次数请再执行脚本") + break + } + await $.wait(parseInt(Math.random() * 2000 + 2000, 10)) + } + + await $.wait(parseInt(Math.random() * 1000 + 2000, 10)) + await takePostRequest('getDrawRecordHasCoupon'); + await takePostRequest('getShareRecord'); + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + console.log($.actorUuid) + console.log(`当前助力:${$.shareUuid}`) + if($.index == 1){ + $.shareUuid = $.actorUuid + console.log(`后面的号都会助力:${$.shareUuid}`) + } + await $.wait(parseInt(Math.random() * 1000 + 5000, 10)) + if(flag) await $.wait(parseInt(Math.random() * 1000 + 10000, 10)) + if($.index % 3 == 0) console.log('休息1分钟,别被黑ip了\n可持续发展') + if($.index % 3 == 0) await $.wait(parseInt(Math.random() * 5000 + 60000, 10)) + } catch (e) { + console.log(e) + } +} + +async function takePostRequest(type) { + if($.outFlag) return + let domain = 'https://lzdz1-isv.isvjcloud.com'; + let body = ``; + let method = 'POST' + let admJson = '' + switch (type) { + case 'isvObfuscator': + url = `https://api.m.jd.com/client.action?functionId=isvObfuscator`; + body = `body=%7B%22url%22%3A%22https%3A//lzdz1-isv.isvjcloud.com%22%2C%22id%22%3A%22%22%7D&uuid=7088d9018515b8cb0c88ace6e5479762af3e88f3&client=apple&clientVersion=10.1.4&st=1634343624086&sv=120&sign=8b9cea22c3a0d77026abda5d37d2b7e3`; + break; + case 'getSimpleActInfoVo': + url = `${domain}/dz/common/getSimpleActInfoVo`; + body = `activityId=${$.activityId}`; + break; + case 'getMyPing': + url = `${domain}/customer/getMyPing`; + body = `userId=${$.shopId || $.venderId || ''}&token=${$.Token}&fromType=APP`; + break; + case 'accessLogWithAD': + url = `${domain}/common/accessLogWithAD`; + let pageurl = `${domain}/drawCenter/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}` + body = `venderId=${$.shopId || $.venderId || ''}&code=99&pin=${encodeURIComponent($.Pin)}&activityId=${$.activityId}&pageUrl=${encodeURIComponent(pageurl)}&subType=app&adSource=` + break; + case 'getUserInfo': + url = `${domain}/wxActionCommon/getUserInfo`; + body = `pin=${encodeURIComponent($.Pin)}`; + break; + case 'activityContent': + url = `${domain}/play/monopoly/getContent`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&pinImg=${encodeURIComponent($.attrTouXiang)}&nick=${encodeURIComponent($.nickname)}&cjyxPin=&cjhyPin=&shareUuid=${$.shareUuid}` + break; + case 'drawContent': + url = `${domain}/dingzhi/taskact/common/drawContent`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case 'checkOpenCard': + url = `${domain}/play/monopoly/checkOpenCard`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case 'info': + url = `${domain}/play/monopoly/getTaskList`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case 'startDraw': + url = `${domain}/play/monopoly/activeDraw`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&drawType=1` + break; + case 'getCardInfo': + url = `${domain}/play/monopoly/getCardInfo`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case '集卡': + url = `${domain}/play/monopoly/drawCard`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case '合卡': + url = `${domain}/play/monopoly/compositeCard`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case 'followShop': + url = `${domain}/play/monopoly/doTasks`; + // url = `${domain}/dingzhi/dz/openCard/saveTask`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&taskType=1` + break; + case 'sign': + case 'addCart': + case 'browseGoods': + url = `${domain}/dingzhi/linkgame/${type}`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + if(type == 'browseGoods') body += `&value=${$.visitSkuValue}` + break; + case '邀请': + case '助力': + if(type == '助力'){ + url = `${domain}/play/monopoly/getAssistStatus`; + }else{ + url = `${domain}/play/monopoly/assist`; + } + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&shareUuid=${$.shareUuid}&actorUuid=${$.actorUuid}` + break; + case 'viewVideo': + case 'visitSku': + case 'toShop': + case 'addSku': + url = `${domain}/play/monopoly/doTasks`; + let taskType = '' + let taskValue = '' + if(type == 'viewVideo'){ + taskType = 31 + taskValue = 31 + }else if(type == 'visitSku'){ + taskType = 5 + taskValue = $.visitSkuValue || 5 + }else if(type == 'toShop'){ + taskType = 14 + taskValue = $.toShopValue || 14 + }else if(type == 'addSku'){ + taskType = 21 + taskValue = $.addSkuValue || 21 + } + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&taskType=${taskType}&taskValue=${taskValue}` + break; + case 'getDrawRecordHasCoupon': + url = `${domain}/play/monopoly/getPrizeList`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case 'getShareRecord': + url = `${domain}/play/monopoly/getHelpList`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case '抽奖': + url = `${domain}/play/monopoly/activeDraw`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&drawType=2` + break; + default: + console.log(`错误${type}`); + } + let myRequest = getPostRequest(url, body, method); + // console.log(myRequest) + return new Promise(async resolve => { + $.post(myRequest, (err, resp, data) => { + try { + setActivityCookie(resp) + if (err) { + if(resp && typeof resp.statusCode != 'undefined'){ + if(resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + } + console.log(`${$.toStr(err,err)}`) + console.log(`${type} API请求失败,请检查网路重试`) + } else { + dealReturn(type, data); + } + } catch (e) { + // console.log(data); + console.log(e, resp) + } finally { + resolve(); + } + }) + }) + } + +async function dealReturn(type, data) { + let res = '' + try { + if(type != 'accessLogWithAD' || type != 'drawContent'){ + if(data){ + res = JSON.parse(data); + } + } + } catch (e) { + console.log(`${type} 执行任务异常`); + console.log(data); + $.runFalag = false; + } + try { + switch (type) { + case 'isvObfuscator': + if(typeof res == 'object'){ + if(res.errcode == 0){ + if(typeof res.token != 'undefined') $.Token = res.token + }else if(res.message){ + console.log(`isvObfuscator ${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + break; + case 'getSimpleActInfoVo': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(typeof res.data.shopId != 'undefined') $.shopId = res.data.shopId + if(typeof res.data.venderId != 'undefined') $.venderId = res.data.venderId + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getMyPing': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(res.data && typeof res.data.secretPin != 'undefined') $.Pin = res.data.secretPin + if(res.data && typeof res.data.nickname != 'undefined') $.nickname = res.data.nickname + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getUserInfo': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(res.data && typeof res.data.yunMidImageUrl != 'undefined') $.attrTouXiang = res.data.yunMidImageUrl || "https://img10.360buyimg.com/imgzone/jfs/t1/7020/27/13511/6142/5c5138d8E4df2e764/5a1216a3a5043c5d.png" + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'activityContent': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + $.endTime = res.data.endTime || (res.data.activityVo && res.data.activityVo.endTime) || res.data.activity.endTime || 0 + $.hasEnd = res.data.isEnd || false + $.drawCount = res.data.actorVo.drawCount || 0 + $.point = res.data.actorVo.point || 0 + $.score = res.data.actorVo.score || 0 + $.actorUuid = res.data.actorVo.actorUuid || '' + $.followShop = res.data.actorVo.followShopStatus || '' + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'info': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + // $.drawCount = res.data.drawCount || 0 + $.addCart = res.data.addCart || false + $.followShop = res.data.followShop || false + $.sign = res.data.isSignStatus || false + $.visitSku = res.data.visitSku || false + $.visitSkuList = res.data.visitSkuList || [] + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'checkOpenCard': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + // console.log(data) + let cardList1 = res.data.cardList1 || [] + let cardList2 = res.data.cardList2 || [] + let cardList = res.data.cardList || [] + let openCardList = res.data.openCardList || [] + $.openList = [...cardList,...cardList1,...cardList2,...openCardList] + $.allOpenCard = res.data.allOpenCard || res.data.isOpenCardStatus || false + $.openCardScore1 = res.data.score1 || 0 + $.openCardScore2 = res.data.score2 || 0 + $.drawScore = res.data.drawScore || 0 + if(res.data.beans || res.data.addBeanNum) console.log(`开卡获得:${res.data.beans || res.data.addBeanNum}豆`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'startDraw': + case 'followShop': + case 'viewVideo': + case 'visitSku': + case 'toShop': + case 'addSku': + case 'sign': + case 'addCart': + case 'browseGoods': + case '抽奖': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(typeof res.data == 'object'){ + let msg = '' + let title = '抽奖' + if(res.data.addBeanNum){ + msg = `${res.data.addBeanNum}京豆` + } + if(res.data.addPoint){ + msg += ` ${res.data.addPoint}游戏机会` + } + if(type == 'followShop'){ + title = '关注' + if(res.data.beanNumMember && res.data.assistSendStatus){ + msg += ` 额外获得:${res.data.beanNumMember}京豆` + } + }else if(type == 'addSku' || type == 'addCart'){ + title = '加购' + }else if(type == 'viewVideo'){ + title = '热门文章' + }else if(type == 'toShop'){ + title = '浏览店铺' + }else if(type == 'visitSku' || type == 'browseGoods'){ + title = '浏览商品' + }else if(type == 'sign'){ + title = '签到' + }else{ + msg = res.data.drawOk == true && (res.data.drawInfoType == 6 && res.data.name || '') || '空气💨' + } + if(!msg){ + msg = '空气💨' + } + console.log(`${title}获得:${msg || data}`) + }else{ + console.log(`${type} ${data}`) + } + }else if(res.errorMessage){ + $.runFalag = false; + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getDrawRecordHasCoupon': + // console.log(data) + if(typeof res == 'object'){ + if(res.result && res.result === true){ + console.log(`我的奖品:`) + let num = 0 + let value = 0 + for(let i in res.data){ + let item = res.data[i] + if(item.drawId == 'assist'){ + num++ + value = item.infoName.replace('京豆','') + }else{ + console.log(`${item.infoType != 10 && item.drawId && item.drawId +':' || ''}${item.infoName}`) + } + } + if(num > 0) console.log(`邀请好友(${num}):${num*parseInt(value, 10) || 30}京豆`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getShareRecord': + if(typeof res == 'object'){ + if(res.result && res.result === true && res.data){ + $.ShareCount = res.data.length + $.log(`=========== 你邀请了:${res.data.length}个`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getCardInfo': + case '集卡': + case '合卡': + if(typeof res == 'object'){ + if(res.result && res.result === true && res.data){ + if(type == "集卡"){ + if(res.data.status == 1) console.log(`集卡成功->${res.data.cardName}`) + else console.log('集卡失败'+ res.data.cardName && '->'+res.data.cardName || '\n'+data) + }else if(type == "合卡"){ + if(res.data.status == 1) console.log('合卡成功') + else console.log('合卡失败\n'+data) + }else if(type == "getCardInfo"){ + $.score = res.data.score || 0 + $.myCardList = res.data.myCardList || [] + $.compositeCardFinishCount = res.data.compositeCardFinishCount || 0 + $.compositeCardNum = res.data.compositeCardNum || 0 + $.drawCardNum = res.data.drawCardNum || 0 + } + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case '邀请': + case '助力': + // console.log(data) + if(typeof res == 'object'){ + if(res.data == 200){ + if(type == '助力'){ + console.log('助力成功') + $.yaoqing = true + } + }else if(res.data == 105){ + console.log('已经助力过') + }else if(res.data == 104){ + console.log('已经助力其他人') + }else if(res.data == 101){ + // console.log('已经助力过') + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + + case 'accessLogWithAD': + case 'drawContent': + break; + default: + console.log(`${type}-> ${data}`); + } + if(typeof res == 'object'){ + if(res.errorMessage){ + if(res.errorMessage.indexOf('火爆') >-1 ){ + $.hotFlag = true + } + } + } + } catch (e) { + console.log(e) + } +} + +function getPostRequest(url, body, method="POST") { + let headers = { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Content-Type": "application/x-www-form-urlencoded", + "Cookie": cookie, + "User-Agent": $.UA, + "X-Requested-With": "XMLHttpRequest" + } + if(url.indexOf('https://lzdz1-isv.isvjcloud.com') > -1){ + headers["Referer"] = `https://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}` + headers["Cookie"] = `${lz_jdpin_token_cookie && lz_jdpin_token_cookie || ''}${$.Pin && "AUTH_C_USER=" + $.Pin + ";" || ""}${activityCookie}` + } + // console.log(headers) + // console.log(headers.Cookie) + return {url: url, method: method, headers: headers, body: body, timeout:30000}; +} + +function getCk() { + return new Promise(resolve => { + let get = { + url:`https://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}`, + followRedirect:false, + headers: { + "User-Agent": $.UA, + }, + timeout:30000 + } + $.get(get, async(err, resp, data) => { + try { + if (err) { + if(resp && typeof resp.statusCode != 'undefined'){ + if(resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + } + console.log(`${$.toStr(err)}`) + console.log(`${$.name} cookie API请求失败,请检查网路重试`) + } else { + let end = data.match(/(活动已经结束)/) && data.match(/(活动已经结束)/)[1] || '' + if(end){ + $.activityEnd = true + console.log('活动已结束') + } + setActivityCookie(resp) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function setActivityCookie(resp){ + let LZ_TOKEN_KEY = '' + let LZ_TOKEN_VALUE = '' + let lz_jdpin_token = '' + let setcookies = resp && resp['headers'] && (resp['headers']['set-cookie'] || resp['headers']['Set-Cookie'] || '') || '' + let setcookie = '' + if(setcookies){ + if(typeof setcookies != 'object'){ + setcookie = setcookies.split(',') + }else setcookie = setcookies + for (let ck of setcookie) { + let name = ck.split(";")[0].trim() + if(name.split("=")[1]){ + // console.log(name.replace(/ /g,'')) + if(name.indexOf('LZ_TOKEN_KEY=')>-1) LZ_TOKEN_KEY = name.replace(/ /g,'')+';' + if(name.indexOf('LZ_TOKEN_VALUE=')>-1) LZ_TOKEN_VALUE = name.replace(/ /g,'')+';' + if(name.indexOf('lz_jdpin_token=')>-1) lz_jdpin_token = ''+name.replace(/ /g,'')+';' + } + } + } + if(LZ_TOKEN_KEY && LZ_TOKEN_VALUE) activityCookie = `${LZ_TOKEN_KEY} ${LZ_TOKEN_VALUE}` + if(lz_jdpin_token) lz_jdpin_token_cookie = lz_jdpin_token +} + +async function getUA(){ + $.UA = `jdapp;iPhone;10.1.4;13.1.2;${randomString(40)};network/wifi;model/iPhone8,1;addressid/2308460611;appBuild/167814;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_1_2 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 joinShop() { + if(!$.joinVenderId) return + return new Promise(async resolve => { + $.shopactivityId = '' + await $.wait(1000) + await getshopactivityId() + let activityId = `` + if($.shopactivityId) activityId = `,"activityId":${$.shopactivityId}` + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body={"venderId":"${$.joinVenderId}","shopId":"${$.joinVenderId}","bindByVerifyCodeFlag":1,"registerExtend":{},"writeChildFlag":0${activityId},"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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + // console.log(data) + let res = $.toObj(data); + if(typeof res == 'object'){ + if(res.success === true){ + console.log(res.message) + if(res.result && res.result.giftInfo){ + for(let i of res.result.giftInfo.giftList){ + console.log(`入会获得:${i.discountString}${i.prizeName}${i.secondLineDesc}`) + } + } + }else if(typeof res == 'object' && res.message){ + console.log(`${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function getshopactivityId() { + return new Promise(resolve => { + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body=%7B%22venderId%22%3A%22${$.joinVenderId}%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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + let res = $.toObj(data); + if(res.success == true){ + // console.log($.toStr(res.result)) + console.log(`入会:${res.result.shopMemberCardInfo.venderCardName || ''}`) + $.shopactivityId = res.result.interestsRuleList && res.result.interestsRuleList[0] && res.result.interestsRuleList[0].interestsInfo && res.result.interestsRuleList[0].interestsInfo.activityId || '' + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} + + +// 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)} + diff --git a/activity/jd_opencardL40.js b/activity/jd_opencardL40.js new file mode 100644 index 0000000..85c4fb1 --- /dev/null +++ b/activity/jd_opencardL40.js @@ -0,0 +1,822 @@ +/* +2022.1.8-1.15 大牌联合 宠爱有礼 +2022年1月8日 - 2022年1月15日 + + +第一个账号助力作者 其他依次助力CK1 +第一个CK失效会退出脚本 + +———————————————— +入口:https://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=dzlhkklblzms20220108&shareUuid=f2276a8dcdb947b5b449f245c81bbb06 + +请求太频繁会被黑ip +过10分钟再执行 + + +cron:1 3,17 8-15 1 * +============Quantumultx=============== +[task_local] +#2022.1.8-1.15 大牌联合 宠爱有礼 +1 3,17 8-15 1 * https://raw.githubusercontent.com/KingRan/JDJB/main/jd_opencardL37.js, tag=2022.1.8-1.15 大牌联合 宠爱有礼, enabled=true + +*/ +const $ = new Env("2022.1.8-1.15 大牌联合 宠爱有礼"); +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const notify = $.isNode() ? require('./sendNotify') : ''; +//IOS等用户直接用NobyDa的jd cookie + +let cookiesArr = [], + cookie = ''; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} +allMessage = "" +message = "" +$.hotFlag = false +$.outFlag = false +$.activityEnd = false +let lz_jdpin_token_cookie ='' +let activityCookie ='' +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', { + "open-url": "https://bean.m.jd.com/" + }); + return; + } + $.activityId = "dzlhkklblzms20220108" + $.shareUuid = "f2276a8dcdb947b5b449f245c81bbb06" + console.log(`入口:\nhttps://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}`) + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i]; + if (cookie) { + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + message = "" + $.bean = 0 + $.hotFlag = false + $.nickName = ''; + console.log(`\n\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + await getUA() + await run(); + if(i == 0 && !$.actorUuid) break + if($.outFlag || $.activityEnd) break + } + } + if($.outFlag) { + let msg = '此ip已被限制,请过10分钟后再执行脚本' + $.msg($.name, ``, `${msg}`); + if ($.isNode()) await notify.sendNotify(`${$.name}`, `${msg}`); + } +})() + .catch((e) => $.logErr(e)) + .finally(() => $.done()) + + +async function run() { + try { + $.hasEnd = true + $.endTime = 0 + lz_jdpin_token_cookie = '' + $.Token = '' + $.Pin = '' + let flag = false + await takePostRequest('isvObfuscator'); + if($.Token == ''){ + console.log('获取[token]失败!') + return + } + await getCk() + if (activityCookie == '') { + console.log(`获取cookie失败`); return; + } + if($.activityEnd === true){ + console.log('活动结束') + return + } + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + await takePostRequest('getSimpleActInfoVo'); + await takePostRequest('getMyPing'); + if(!$.Pin){ + console.log('获取[Pin]失败!') + return + } + await takePostRequest('accessLogWithAD'); + await takePostRequest('getUserInfo'); + await takePostRequest('activityContent'); + if($.hotFlag) return + if(!$.actorUuid){ + console.log('获取不到[actorUuid]退出执行,请重新执行') + return + } + // console.log($.actorUuid) + // return + if($.hasEnd === true || Date.now() > $.endTime){ + $.activityEnd = true + console.log('活动结束') + return + } + await takePostRequest('drawContent'); + await $.wait(1000) + $.openList = [] + $.allOpenCard = false + await takePostRequest('info'); + await takePostRequest('checkOpenCard'); + if($.allOpenCard == false){ + console.log('开卡任务') + for(o of $.openList){ + $.openCard = false + if(o.status == 0){ + flag = true + $.joinVenderId = o.venderId + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + await joinShop() + await $.wait(parseInt(Math.random() * 1000 + 1000, 10)) + await takePostRequest('activityContent'); + await takePostRequest('drawContent'); + await takePostRequest('checkOpenCard'); + await $.wait(parseInt(Math.random() * 3000 + 2000, 10)) + } + } + }else{ + console.log('已全部开卡') + } + + $.log("关注: " + $.followShop) + if(!$.followShop && !$.outFlag){ + flag = true + await takePostRequest('followShop'); + await $.wait(parseInt(Math.random() * 2000 + 3000, 10)) + } + $.yaoqing = false + await takePostRequest('邀请'); + if($.yaoqing){ + await takePostRequest('助力'); + } + $.log("加购: " + $.addCart) + if(!$.addCart && !$.outFlag){ + flag = true + await takePostRequest('addCart'); + await $.wait(parseInt(Math.random() * 2000 + 4000, 10)) + } + $.runFalag = true + $.log("浏览商品: " + $.visitSku) + if(!$.visitSku && !$.outFlag){ + flag = true + for(let v of $.visitSkuList || []){ + if($.runFalag == false) break + if(v.goodsCode && v.status === 0){ + $.visitSkuValue = v.goodsCode + await takePostRequest('browseGoods'); + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + } + } + } + $.runFalag = true + let count = parseInt($.drawCount, 10) + console.log(`抽奖次数为:${count}`) + for(m=1;count--;m++){ + console.log(`第${m}次抽奖`) + await takePostRequest('startDraw'); + if($.runFalag == false) break + if(Number(count) <= 0) break + if(m >= 30){ + console.log("抽奖太多次,多余的次数请再执行脚本") + break + } + await $.wait(parseInt(Math.random() * 2000 + 2000, 10)) + } + if(flag){ + await takePostRequest('activityContent'); + } + console.log(`${$.score}值 游戏:${$.point}`) + $.runFalag = true + count = parseInt($.score/1000) + console.log(`抽奖次数为:${count}`) + for(m=1;count--;m++){ + console.log(`第${m}次抽奖`) + await takePostRequest('抽奖'); + if($.runFalag == false) break + if(Number(count) <= 0) break + if(m >= 10){ + console.log("抽奖太多次,多余的次数请再执行脚本") + break + } + await $.wait(parseInt(Math.random() * 2000 + 2000, 10)) + } + + await $.wait(parseInt(Math.random() * 1000 + 2000, 10)) + await takePostRequest('getDrawRecordHasCoupon'); + await takePostRequest('getShareRecord'); + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + console.log($.actorUuid) + console.log(`当前助力:${$.shareUuid}`) + if($.index == 1){ + $.shareUuid = $.actorUuid + console.log(`后面的号都会助力:${$.shareUuid}`) + } + await $.wait(parseInt(Math.random() * 1000 + 5000, 10)) + if(flag) await $.wait(parseInt(Math.random() * 1000 + 10000, 10)) + + if($.index % 3 == 0) console.log('休息1分钟,别被黑ip了\n可持续发展') + if($.index % 3 == 0) await $.wait(parseInt(Math.random() * 5000 + 60000, 10)) + + } catch (e) { + console.log(e) + } +} + +async function takePostRequest(type) { + if($.outFlag) return + let domain = 'https://lzdz1-isv.isvjcloud.com'; + let body = ``; + let method = 'POST' + let admJson = '' + switch (type) { + case 'isvObfuscator': + url = `https://api.m.jd.com/client.action?functionId=isvObfuscator`; + body = `body=%7B%22url%22%3A%22https%3A//lzdz1-isv.isvjcloud.com%22%2C%22id%22%3A%22%22%7D&uuid=7088d9018515b8cb0c88ace6e5479762af3e88f3&client=apple&clientVersion=10.1.4&st=1634343624086&sv=120&sign=8b9cea22c3a0d77026abda5d37d2b7e3`; + break; + case 'getSimpleActInfoVo': + url = `${domain}/dz/common/getSimpleActInfoVo`; + body = `activityId=${$.activityId}`; + break; + case 'getMyPing': + url = `${domain}/customer/getMyPing`; + body = `userId=${$.shopId || $.venderId || ''}&token=${$.Token}&fromType=APP`; + break; + case 'accessLogWithAD': + url = `${domain}/common/accessLogWithAD`; + let pageurl = `${domain}/drawCenter/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}` + body = `venderId=${$.shopId || $.venderId || ''}&code=99&pin=${encodeURIComponent($.Pin)}&activityId=${$.activityId}&pageUrl=${encodeURIComponent(pageurl)}&subType=app&adSource=` + break; + case 'getUserInfo': + url = `${domain}/wxActionCommon/getUserInfo`; + body = `pin=${encodeURIComponent($.Pin)}`; + break; + case 'activityContent': + url = `${domain}/dingzhi/linkgame/activity/content`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&pinImg=${encodeURIComponent($.attrTouXiang)}&nick=${encodeURIComponent($.nickname)}&cjyxPin=&cjhyPin=&shareUuid=${$.shareUuid}` + break; + case 'drawContent': + url = `${domain}/dingzhi/taskact/common/drawContent`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case 'checkOpenCard': + url = `${domain}/dingzhi/linkgame/checkOpenCard`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case 'info': + url = `${domain}/dingzhi/linkgame/task/info`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case 'startDraw': + url = `${domain}/dingzhi/linkgame/draw/bean`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case 'followShop': + url = `${domain}/dingzhi/linkgame/follow/shop`; + // url = `${domain}/dingzhi/dz/openCard/saveTask`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case 'sign': + case 'addCart': + case 'browseGoods': + url = `${domain}/dingzhi/linkgame/${type}`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + if(type == 'browseGoods') body += `&value=${$.visitSkuValue}` + break; + case '邀请': + case '助力': + if(type == '助力'){ + url = `${domain}/dingzhi/linkgame/assist`; + }else{ + url = `${domain}/dingzhi/linkgame/assist/status`; + } + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&shareUuid=${$.shareUuid}` + break; + case 'viewVideo': + case 'visitSku': + case 'toShop': + case 'addSku': + url = `${domain}/dingzhi/dz/openCard/saveTask`; + let taskType = '' + let taskValue = '' + if(type == 'viewVideo'){ + taskType = 31 + taskValue = 31 + }else if(type == 'visitSku'){ + taskType = 5 + taskValue = $.visitSkuValue || 5 + }else if(type == 'toShop'){ + taskType = 14 + taskValue = $.toShopValue || 14 + }else if(type == 'addSku'){ + taskType = 2 + taskValue = $.addSkuValue || 2 + } + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&taskType=${taskType}&taskValue=${taskValue}` + break; + case 'getDrawRecordHasCoupon': + url = `${domain}/dingzhi/linkgame/draw/record`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case 'getShareRecord': + url = `${domain}/dingzhi/linkgame/help/list`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case '抽奖': + url = `${domain}/dingzhi/linkgame/draw`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + default: + console.log(`错误${type}`); + } + let myRequest = getPostRequest(url, body, method); + // console.log(myRequest) + return new Promise(async resolve => { + $.post(myRequest, (err, resp, data) => { + try { + setActivityCookie(resp) + if (err) { + if(resp && typeof resp.statusCode != 'undefined'){ + if(resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + } + console.log(`${$.toStr(err,err)}`) + console.log(`${type} API请求失败,请检查网路重试`) + } else { + dealReturn(type, data); + } + } catch (e) { + // console.log(data); + console.log(e, resp) + } finally { + resolve(); + } + }) + }) + } + +async function dealReturn(type, data) { + let res = '' + try { + if(type != 'accessLogWithAD' || type != 'drawContent'){ + if(data){ + res = JSON.parse(data); + } + } + } catch (e) { + console.log(`${type} 执行任务异常`); + console.log(data); + $.runFalag = false; + } + try { + switch (type) { + case 'isvObfuscator': + if(typeof res == 'object'){ + if(res.errcode == 0){ + if(typeof res.token != 'undefined') $.Token = res.token + }else if(res.message){ + console.log(`isvObfuscator ${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + break; + case 'getSimpleActInfoVo': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(typeof res.data.shopId != 'undefined') $.shopId = res.data.shopId + if(typeof res.data.venderId != 'undefined') $.venderId = res.data.venderId + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getMyPing': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(res.data && typeof res.data.secretPin != 'undefined') $.Pin = res.data.secretPin + if(res.data && typeof res.data.nickname != 'undefined') $.nickname = res.data.nickname + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getUserInfo': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(res.data && typeof res.data.yunMidImageUrl != 'undefined') $.attrTouXiang = res.data.yunMidImageUrl || "https://img10.360buyimg.com/imgzone/jfs/t1/7020/27/13511/6142/5c5138d8E4df2e764/5a1216a3a5043c5d.png" + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'activityContent': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + $.endTime = res.data.endTime || res.data.activity.endTime || 0 + $.hasEnd = res.data.isEnd || false + $.drawCount = res.data.actor.drawCount || 0 + $.point = res.data.actor.point || 0 + $.score = res.data.actor.score || 0 + $.actorUuid = res.data.actor.actorUuid || '' + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'info': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + // $.drawCount = res.data.drawCount || 0 + $.addCart = res.data.addCart || false + $.followShop = res.data.followShop || false + $.sign = res.data.sign || false + $.visitSku = res.data.visitSku || false + $.visitSkuList = res.data.visitSkuList || [] + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'checkOpenCard': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + let cardList1 = res.data.cardList1 || [] + let cardList2 = res.data.cardList2 || [] + let cardList = res.data.cardList || [] + let openCardList = res.data.openCardList || [] + $.openList = [...cardList,...cardList1,...cardList2,...openCardList] + $.allOpenCard = res.data.allOpenCard || false + $.openCardScore1 = res.data.score1 || 0 + $.openCardScore2 = res.data.score2 || 0 + $.drawScore = res.data.drawScore || 0 + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'startDraw': + case 'followShop': + case 'viewVideo': + case 'visitSku': + case 'toShop': + case 'addSku': + case 'sign': + case 'addCart': + case 'browseGoods': + case '抽奖': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(typeof res.data == 'object'){ + let msg = '' + let title = '抽奖' + if(res.data.addBeanNum){ + msg = `${res.data.addBeanNum}京豆` + } + if(res.data.addPoint){ + msg += ` ${res.data.addPoint}游戏机会` + } + if(type == 'followShop'){ + title = '关注' + if(res.data.beanNumMember && res.data.assistSendStatus){ + msg += ` 额外获得:${res.data.beanNumMember}京豆` + } + }else if(type == 'addSku' || type == 'addCart'){ + title = '加购' + }else if(type == 'viewVideo'){ + title = '热门文章' + }else if(type == 'toShop'){ + title = '浏览店铺' + }else if(type == 'visitSku' || type == 'browseGoods'){ + title = '浏览商品' + }else if(type == 'sign'){ + title = '签到' + }else{ + msg = res.data.drawOk == true && (res.data.drawInfoType == 6 && res.data.name || '') || '空气💨' + } + if(!msg){ + msg = '空气💨' + } + console.log(`${title}获得:${msg || data}`) + }else{ + console.log(`${type} ${data}`) + } + }else if(res.errorMessage){ + $.runFalag = false; + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getDrawRecordHasCoupon': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + console.log(`我的奖品:`) + let num = 0 + let value = 0 + for(let i in res.data.recordList){ + let item = res.data.recordList[i] + if(item.infoName == '20京豆'){ + num++ + value = item.infoName.replace('京豆','') + }else{ + console.log(`${item.infoType != 10 && item.value && item.value +':' || ''}${item.infoName}`) + } + } + if(num > 0) console.log(`邀请好友(${num}):${num*parseInt(value, 10) || 30}京豆`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getShareRecord': + if(typeof res == 'object'){ + if(res.result && res.result === true && res.data){ + $.ShareCount = res.data.shareList.length + $.log(`=========== 你邀请了:${res.data.shareList.length}个`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case '邀请': + case '助力': + // console.log(data) + if(typeof res == 'object'){ + if(res.data.status == 200){ + if(type == '助力'){ + console.log('助力成功') + }else{ + $.yaoqing = true + } + }else if(res.data.status == 105){ + console.log('已经助力过') + }else if(res.data.status == 104){ + console.log('已经助力其他人') + }else if(res.data.status == 101){ + // console.log('已经助力过') + }else{ + console.log(data) + } + }else{ + console.log(`${type} ${data}`) + } + + case 'accessLogWithAD': + case 'drawContent': + break; + default: + console.log(`${type}-> ${data}`); + } + if(typeof res == 'object'){ + if(res.errorMessage){ + if(res.errorMessage.indexOf('火爆') >-1 ){ + $.hotFlag = true + } + } + } + } catch (e) { + console.log(e) + } +} + +function getPostRequest(url, body, method="POST") { + let headers = { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Content-Type": "application/x-www-form-urlencoded", + "Cookie": cookie, + "User-Agent": $.UA, + "X-Requested-With": "XMLHttpRequest" + } + if(url.indexOf('https://lzdz1-isv.isvjcloud.com') > -1){ + headers["Referer"] = `https://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}` + headers["Cookie"] = `${lz_jdpin_token_cookie && lz_jdpin_token_cookie || ''}${$.Pin && "AUTH_C_USER=" + $.Pin + ";" || ""}${activityCookie}` + } + // console.log(headers) + // console.log(headers.Cookie) + return {url: url, method: method, headers: headers, body: body, timeout:30000}; +} + +function getCk() { + return new Promise(resolve => { + let get = { + url:`https://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}`, + followRedirect:false, + headers: { + "User-Agent": $.UA, + }, + timeout:30000 + } + $.get(get, async(err, resp, data) => { + try { + if (err) { + if(resp && typeof resp.statusCode != 'undefined'){ + if(resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + } + console.log(`${$.toStr(err)}`) + console.log(`${$.name} cookie API请求失败,请检查网路重试`) + } else { + let end = data.match(/(活动已经结束)/) && data.match(/(活动已经结束)/)[1] || '' + if(end){ + $.activityEnd = true + console.log('活动已结束') + } + setActivityCookie(resp) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function setActivityCookie(resp){ + let LZ_TOKEN_KEY = '' + let LZ_TOKEN_VALUE = '' + let lz_jdpin_token = '' + let setcookies = resp && resp['headers'] && (resp['headers']['set-cookie'] || resp['headers']['Set-Cookie'] || '') || '' + let setcookie = '' + if(setcookies){ + if(typeof setcookies != 'object'){ + setcookie = setcookies.split(',') + }else setcookie = setcookies + for (let ck of setcookie) { + let name = ck.split(";")[0].trim() + if(name.split("=")[1]){ + // console.log(name.replace(/ /g,'')) + if(name.indexOf('LZ_TOKEN_KEY=')>-1) LZ_TOKEN_KEY = name.replace(/ /g,'')+';' + if(name.indexOf('LZ_TOKEN_VALUE=')>-1) LZ_TOKEN_VALUE = name.replace(/ /g,'')+';' + if(name.indexOf('lz_jdpin_token=')>-1) lz_jdpin_token = ''+name.replace(/ /g,'')+';' + } + } + } + if(LZ_TOKEN_KEY && LZ_TOKEN_VALUE) activityCookie = `${LZ_TOKEN_KEY} ${LZ_TOKEN_VALUE}` + if(lz_jdpin_token) lz_jdpin_token_cookie = lz_jdpin_token +} + +async function getUA(){ + $.UA = `jdapp;iPhone;10.1.4;13.1.2;${randomString(40)};network/wifi;model/iPhone8,1;addressid/2308460611;appBuild/167814;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_1_2 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 joinShop() { + if(!$.joinVenderId) return + return new Promise(async resolve => { + $.shopactivityId = '' + await $.wait(1000) + await getshopactivityId() + let activityId = `` + if($.shopactivityId) activityId = `,"activityId":${$.shopactivityId}` + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body={"venderId":"${$.joinVenderId}","shopId":"${$.joinVenderId}","bindByVerifyCodeFlag":1,"registerExtend":{},"writeChildFlag":0${activityId},"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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + // console.log(data) + let res = $.toObj(data); + if(typeof res == 'object'){ + if(res.success === true){ + console.log(res.message) + if(res.result && res.result.giftInfo){ + for(let i of res.result.giftInfo.giftList){ + console.log(`入会获得:${i.discountString}${i.prizeName}${i.secondLineDesc}`) + } + } + }else if(typeof res == 'object' && res.message){ + console.log(`${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function getshopactivityId() { + return new Promise(resolve => { + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body=%7B%22venderId%22%3A%22${$.joinVenderId}%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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + let res = $.toObj(data); + if(res.success == true){ + // console.log($.toStr(res.result)) + console.log(`入会:${res.result.shopMemberCardInfo.venderCardName || ''}`) + $.shopactivityId = res.result.interestsRuleList && res.result.interestsRuleList[0] && res.result.interestsRuleList[0].interestsInfo && res.result.interestsRuleList[0].interestsInfo.activityId || '' + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} + + +// 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)} diff --git a/activity/jd_opencardL41.js b/activity/jd_opencardL41.js new file mode 100644 index 0000000..ac9331c --- /dev/null +++ b/activity/jd_opencardL41.js @@ -0,0 +1,880 @@ +/* +1.8~1.27 集年味卡 享年味盛典 1 +新增开卡脚本,一次性脚本 + +1.邀请一人10豆 +2.开10张卡 成功开1张 获得5豆 +3.关注5豆 +4.抽奖 +5.集卡 +6.大于1张福卡时 1月28号会通知瓜分 + +第一个账号助力作者 其他依次助力CK1 +第一个CK失效会退出脚本 + +———————————————— +入口:[ 1.8~1.27 集年味卡 享年味盛典 (https://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=cd20220108iu890dmnhimj01ied&shareUuid=2d0fcc860b1f4e32acfcb3d275c4fb73)] + +请求太频繁会被黑ip +过10分钟再执行 + +cron:50 2,14 8-27 1 * +============Quantumultx=============== +[task_local] +#1.8~1.27 集年味卡 享年味盛典 1 +50 2,14 8-27 1 * jd_opencardL41.js, tag=1.8~1.27 集年味卡 享年味盛典, enabled=true + +*/ + +const $ = new Env('1.8~1.27 集年味卡 享年味盛典 1'); +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const notify = $.isNode() ? require('./sendNotify') : ''; +//IOS等用户直接用NobyDa的jd cookie + +let cookiesArr = [], + cookie = ''; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} + +allMessage = "" +message = "" +$.hotFlag = false +$.outFlag = false +$.activityEnd = false +let lz_jdpin_token_cookie ='' +let activityCookie ='' +const activeEndTime = '2022/01/27 00:00:00+08:00';//活动结束时间 +let nowTime = new Date().getTime() + new Date().getTimezoneOffset()*60*1000 + 8*60*60*1000; +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', { + "open-url": "https://bean.m.jd.com/" + }); + return; + } + $.activityId = "cd20220108tpovk25f5b40s07t7" + $.shareUuid = "26d6c4ac83634b2aba965ac62a68f436" + console.log(`入口:\nhttps://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}`) + + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i]; + if (cookie) { + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + message = "" + $.bean = 0 + $.hotFlag = false + $.nickName = ''; + console.log(`\n\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + await getUA() + await run(); + if(i == 0 && !$.actorUuid) break + if($.outFlag || $.activityEnd) break + } + } + if($.outFlag) { + let msg = '此ip已被限制,请过10分钟后再执行脚本' + $.msg($.name, ``, `${msg}`); + if ($.isNode()) await notify.sendNotify(`${$.name}`, `${msg}`); + } + if(allMessage){ + allMessage = `以下账号可参与瓜分京豆\n${allMessage}\n入口:https://3.cn/104c12-vF` + $.msg($.name, ``, `${allMessage}`); + if ($.isNode()) await notify.sendNotify(`${$.name}`, `${allMessage}`); + } +})() + .catch((e) => $.logErr(e)) + .finally(() => $.done()) + + +async function run() { + try { + $.hasEnd = true + $.endTime = 0 + lz_jdpin_token_cookie = '' + $.Token = '' + $.Pin = '' + let flag = false + await takePostRequest('isvObfuscator'); + if($.Token == ''){ + console.log('获取[token]失败!') + return + } + await getCk() + if (activityCookie == '') { + console.log(`获取cookie失败`); return; + } + if($.activityEnd === true){ + console.log('活动结束') + return + } + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + await takePostRequest('getSimpleActInfoVo'); + await takePostRequest('getMyPing'); + if(!$.Pin){ + console.log('获取[Pin]失败!') + return + } + await takePostRequest('accessLogWithAD'); + await takePostRequest('getUserInfo'); + await takePostRequest('activityContent'); + if($.hotFlag) return + if(!$.actorUuid){ + console.log('获取不到[actorUuid]退出执行,请重新执行') + return + } + if(($.hasEnd === true || Date.now() > $.endTime) && nowTime > new Date('2022/01/27 00:00:00+08:00').getTime()){ + $.activityEnd = true + console.log('活动结束') + return + } + await takePostRequest('drawContent'); + await $.wait(1000) + $.openList = [] + $.allOpenCard = false + await takePostRequest('checkOpenCard'); + if($.allOpenCard == false){ + console.log('开卡任务') + for(o of $.openList){ + $.openCard = false + if(o.status == 0){ + flag = true + $.joinVenderId = o.venderId + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + await joinShop() + await $.wait(parseInt(Math.random() * 1000 + 1000, 10)) + await takePostRequest('activityContent'); + await takePostRequest('drawContent'); + await takePostRequest('checkOpenCard'); + await $.wait(parseInt(Math.random() * 3000 + 2000, 10)) + } + } + }else{ + console.log('已全部开卡') + } + + $.log("关注: " + $.followShop) + if(!$.followShop && !$.outFlag){ + flag = true + await takePostRequest('followShop'); + await $.wait(parseInt(Math.random() * 2000 + 3000, 10)) + } + $.yaoqing = false + await takePostRequest('助力'); + if($.yaoqing){ + await takePostRequest('邀请'); + } + // await takePostRequest('startDraw'); + + if(flag){ + await takePostRequest('activityContent'); + } + await takePostRequest('getCardInfo'); + if($.drawCardNum){ + let count = $.drawCardNum + for(m=1;count--;m++){ + console.log(`第${m}次集卡`) + await takePostRequest('集卡'); + await takePostRequest('getCardInfo'); + if($.runFalag == false || $.compositeCardNum > 0) break + if(Number(count) <= 0) break + if(m >= 5){ + console.log("集卡太多次,多余的次数请再执行脚本") + break + } + await $.wait(parseInt(Math.random() * 2000 + 2000, 10)) + } + if($.compositeCardNum){ + let count = $.compositeCardNum + for(m=1;count--;m++){ + console.log(`第${m}次合卡`) + await takePostRequest('合卡'); + if($.runFalag == false) break + if(Number(count) <= 0) break + if(m >= 5){ + console.log("合卡太多次,多余的次数请再执行脚本") + break + } + await $.wait(parseInt(Math.random() * 2000 + 2000, 10)) + } + } + } + for(let c of $.myCardList || []){ + console.log(`${c.cardName}:${c.cardNum}`) + } + if ($.compositeCardFinishCount >= 1 && nowTime > new Date(activeEndTime).getTime()) { + allMessage += `【京东账号${$.index}】${$.nickName || $.UserName}\n` + } + console.log(`${$.score}值 福卡:${$.compositeCardFinishCount}`) + $.runFalag = true + let count = parseInt($.score/100) + console.log(`抽奖次数为:${count}`) + for(m=1;count--;m++){ + console.log(`第${m}次抽奖`) + await takePostRequest('抽奖'); + if($.runFalag == false) break + if(Number(count) <= 0) break + if(m >= 1){ + console.log("抽奖太多次,多余的次数请再执行脚本") + break + } + await $.wait(parseInt(Math.random() * 2000 + 2000, 10)) + } + + await $.wait(parseInt(Math.random() * 1000 + 2000, 10)) + await takePostRequest('getDrawRecordHasCoupon'); + await takePostRequest('getShareRecord'); + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + console.log($.actorUuid) + console.log(`当前助力:${$.shareUuid}`) + if($.index == 1){ + $.shareUuid = $.actorUuid + console.log(`后面的号都会助力:${$.shareUuid}`) + } + await $.wait(parseInt(Math.random() * 1000 + 5000, 10)) + if(flag) await $.wait(parseInt(Math.random() * 1000 + 10000, 10)) + if($.index % 3 == 0) console.log('休息1分钟,别被黑ip了\n可持续发展') + if($.index % 3 == 0) await $.wait(parseInt(Math.random() * 5000 + 60000, 10)) + } catch (e) { + console.log(e) + } +} + +async function takePostRequest(type) { + if($.outFlag) return + let domain = 'https://lzdz1-isv.isvjcloud.com'; + let body = ``; + let method = 'POST' + let admJson = '' + switch (type) { + case 'isvObfuscator': + url = `https://api.m.jd.com/client.action?functionId=isvObfuscator`; + body = `body=%7B%22url%22%3A%22https%3A//lzdz1-isv.isvjcloud.com%22%2C%22id%22%3A%22%22%7D&uuid=7088d9018515b8cb0c88ace6e5479762af3e88f3&client=apple&clientVersion=10.1.4&st=1634343624086&sv=120&sign=8b9cea22c3a0d77026abda5d37d2b7e3`; + break; + case 'getSimpleActInfoVo': + url = `${domain}/dz/common/getSimpleActInfoVo`; + body = `activityId=${$.activityId}`; + break; + case 'getMyPing': + url = `${domain}/customer/getMyPing`; + body = `userId=${$.shopId || $.venderId || ''}&token=${$.Token}&fromType=APP`; + break; + case 'accessLogWithAD': + url = `${domain}/common/accessLogWithAD`; + let pageurl = `${domain}/drawCenter/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}` + body = `venderId=${$.shopId || $.venderId || ''}&code=99&pin=${encodeURIComponent($.Pin)}&activityId=${$.activityId}&pageUrl=${encodeURIComponent(pageurl)}&subType=app&adSource=` + break; + case 'getUserInfo': + url = `${domain}/wxActionCommon/getUserInfo`; + body = `pin=${encodeURIComponent($.Pin)}`; + break; + case 'activityContent': + url = `${domain}/play/monopoly/getContent`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&pinImg=${encodeURIComponent($.attrTouXiang)}&nick=${encodeURIComponent($.nickname)}&cjyxPin=&cjhyPin=&shareUuid=${$.shareUuid}` + break; + case 'drawContent': + url = `${domain}/dingzhi/taskact/common/drawContent`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case 'checkOpenCard': + url = `${domain}/play/monopoly/checkOpenCard`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case 'info': + url = `${domain}/play/monopoly/getTaskList`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case 'startDraw': + url = `${domain}/play/monopoly/activeDraw`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&drawType=1` + break; + case 'getCardInfo': + url = `${domain}/play/monopoly/getCardInfo`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case '集卡': + url = `${domain}/play/monopoly/drawCard`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case '合卡': + url = `${domain}/play/monopoly/compositeCard`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case 'followShop': + url = `${domain}/play/monopoly/doTasks`; + // url = `${domain}/dingzhi/dz/openCard/saveTask`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&taskType=1` + break; + case 'sign': + case 'addCart': + case 'browseGoods': + url = `${domain}/dingzhi/linkgame/${type}`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + if(type == 'browseGoods') body += `&value=${$.visitSkuValue}` + break; + case '邀请': + case '助力': + if(type == '助力'){ + url = `${domain}/play/monopoly/getAssistStatus`; + }else{ + url = `${domain}/play/monopoly/assist`; + } + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&shareUuid=${$.shareUuid}&actorUuid=${$.actorUuid}` + break; + case 'viewVideo': + case 'visitSku': + case 'toShop': + case 'addSku': + url = `${domain}/dingzhi/dz/openCard/saveTask`; + let taskType = '' + let taskValue = '' + if(type == 'viewVideo'){ + taskType = 31 + taskValue = 31 + }else if(type == 'visitSku'){ + taskType = 5 + taskValue = $.visitSkuValue || 5 + }else if(type == 'toShop'){ + taskType = 14 + taskValue = $.toShopValue || 14 + }else if(type == 'addSku'){ + taskType = 2 + taskValue = $.addSkuValue || 2 + } + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&taskType=${taskType}&taskValue=${taskValue}` + break; + case 'getDrawRecordHasCoupon': + url = `${domain}/play/monopoly/getPrizeList`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case 'getShareRecord': + url = `${domain}/play/monopoly/getHelpList`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case '抽奖': + url = `${domain}/play/monopoly/activeDraw`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&drawType=2` + break; + default: + console.log(`错误${type}`); + } + let myRequest = getPostRequest(url, body, method); + // console.log(myRequest) + return new Promise(async resolve => { + $.post(myRequest, (err, resp, data) => { + try { + setActivityCookie(resp) + if (err) { + if(resp && typeof resp.statusCode != 'undefined'){ + if(resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + } + console.log(`${$.toStr(err,err)}`) + console.log(`${type} API请求失败,请检查网路重试`) + } else { + dealReturn(type, data); + } + } catch (e) { + // console.log(data); + console.log(e, resp) + } finally { + resolve(); + } + }) + }) + } + +async function dealReturn(type, data) { + let res = '' + try { + if(type != 'accessLogWithAD' || type != 'drawContent'){ + if(data){ + res = JSON.parse(data); + } + } + } catch (e) { + console.log(`${type} 执行任务异常`); + console.log(data); + $.runFalag = false; + } + try { + switch (type) { + case 'isvObfuscator': + if(typeof res == 'object'){ + if(res.errcode == 0){ + if(typeof res.token != 'undefined') $.Token = res.token + }else if(res.message){ + console.log(`isvObfuscator ${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + break; + case 'getSimpleActInfoVo': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(typeof res.data.shopId != 'undefined') $.shopId = res.data.shopId + if(typeof res.data.venderId != 'undefined') $.venderId = res.data.venderId + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getMyPing': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(res.data && typeof res.data.secretPin != 'undefined') $.Pin = res.data.secretPin + if(res.data && typeof res.data.nickname != 'undefined') $.nickname = res.data.nickname + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getUserInfo': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(res.data && typeof res.data.yunMidImageUrl != 'undefined') $.attrTouXiang = res.data.yunMidImageUrl || "https://img10.360buyimg.com/imgzone/jfs/t1/7020/27/13511/6142/5c5138d8E4df2e764/5a1216a3a5043c5d.png" + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'activityContent': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + $.endTime = res.data.endTime || (res.data.activityVo && res.data.activityVo.endTime) || res.data.activity.endTime || 0 + $.hasEnd = res.data.isEnd || false + $.drawCount = res.data.actorVo.drawCount || 0 + $.point = res.data.actorVo.point || 0 + $.score = res.data.actorVo.score || 0 + $.actorUuid = res.data.actorVo.actorUuid || '' + $.followShop = res.data.actorVo.followShopStatus || '' + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'info': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + // $.drawCount = res.data.drawCount || 0 + $.addCart = res.data.addCart || false + $.followShop = res.data.followShop || false + $.sign = res.data.isSignStatus || false + $.visitSku = res.data.visitSku || false + $.visitSkuList = res.data.visitSkuList || [] + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'checkOpenCard': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + // console.log(data) + let cardList1 = res.data.cardList1 || [] + let cardList2 = res.data.cardList2 || [] + let cardList = res.data.cardList || [] + let openCardList = res.data.openCardList || [] + $.openList = [...cardList,...cardList1,...cardList2,...openCardList] + $.allOpenCard = res.data.allOpenCard || res.data.isOpenCardStatus || false + $.openCardScore1 = res.data.score1 || 0 + $.openCardScore2 = res.data.score2 || 0 + $.drawScore = res.data.drawScore || 0 + if(res.data.beans || res.data.addBeanNum) console.log(`开卡获得:${res.data.beans || res.data.addBeanNum}豆`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'startDraw': + case 'followShop': + case 'viewVideo': + case 'visitSku': + case 'toShop': + case 'addSku': + case 'sign': + case 'addCart': + case 'browseGoods': + case '抽奖': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(typeof res.data == 'object'){ + let msg = '' + let title = '抽奖' + if(res.data.addBeanNum){ + msg = `${res.data.addBeanNum}京豆` + } + if(res.data.addPoint){ + msg += ` ${res.data.addPoint}游戏机会` + } + if(type == 'followShop'){ + title = '关注' + if(res.data.beanNumMember && res.data.assistSendStatus){ + msg += ` 额外获得:${res.data.beanNumMember}京豆` + } + }else if(type == 'addSku' || type == 'addCart'){ + title = '加购' + }else if(type == 'viewVideo'){ + title = '热门文章' + }else if(type == 'toShop'){ + title = '浏览店铺' + }else if(type == 'visitSku' || type == 'browseGoods'){ + title = '浏览商品' + }else if(type == 'sign'){ + title = '签到' + }else{ + msg = res.data.drawOk == true && (res.data.drawInfoType == 6 && res.data.name || '') || '空气💨' + } + if(!msg){ + msg = '空气💨' + } + console.log(`${title}获得:${msg || data}`) + }else{ + console.log(`${type} ${data}`) + } + }else if(res.errorMessage){ + $.runFalag = false; + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getDrawRecordHasCoupon': + // console.log(data) + if(typeof res == 'object'){ + if(res.result && res.result === true){ + console.log(`我的奖品:`) + let num = 0 + let value = 0 + for(let i in res.data){ + let item = res.data[i] + if(item.drawId == 'assist'){ + num++ + value = item.infoName.replace('京豆','') + }else{ + console.log(`${item.infoType != 10 && item.drawId && item.drawId +':' || ''}${item.infoName}`) + } + } + if(num > 0) console.log(`邀请好友(${num}):${num*parseInt(value, 10) || 30}京豆`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getShareRecord': + if(typeof res == 'object'){ + if(res.result && res.result === true && res.data){ + $.ShareCount = res.data.length + $.log(`=========== 你邀请了:${res.data.length}个`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getCardInfo': + case '集卡': + case '合卡': + if(typeof res == 'object'){ + if(res.result && res.result === true && res.data){ + if(type == "集卡"){ + if(res.data.status == 1) console.log(`集卡成功->${res.data.cardName}`) + else console.log('集卡失败'+ res.data.cardName && '->'+res.data.cardName || '\n'+data) + }else if(type == "合卡"){ + if(res.data.status == 1) console.log('合卡成功') + else console.log('合卡失败\n'+data) + }else if(type == "getCardInfo"){ + $.score = res.data.score || 0 + $.myCardList = res.data.myCardList || [] + $.compositeCardFinishCount = res.data.compositeCardFinishCount || 0 + $.compositeCardNum = res.data.compositeCardNum || 0 + $.drawCardNum = res.data.drawCardNum || 0 + } + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case '邀请': + case '助力': + // console.log(data) + if(typeof res == 'object'){ + if(res.data == 200){ + if(type == '助力'){ + console.log('助力成功') + $.yaoqing = true + } + }else if(res.data == 105){ + console.log('已经助力过') + }else if(res.data == 104){ + console.log('已经助力其他人') + }else if(res.data == 101){ + // console.log('已经助力过') + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + + case 'accessLogWithAD': + case 'drawContent': + break; + default: + console.log(`${type}-> ${data}`); + } + if(typeof res == 'object'){ + if(res.errorMessage){ + if(res.errorMessage.indexOf('火爆') >-1 ){ + $.hotFlag = true + } + } + } + } catch (e) { + console.log(e) + } +} + +function getPostRequest(url, body, method="POST") { + let headers = { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Content-Type": "application/x-www-form-urlencoded", + "Cookie": cookie, + "User-Agent": $.UA, + "X-Requested-With": "XMLHttpRequest" + } + if(url.indexOf('https://lzdz1-isv.isvjcloud.com') > -1){ + headers["Referer"] = `https://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}` + headers["Cookie"] = `${lz_jdpin_token_cookie && lz_jdpin_token_cookie || ''}${$.Pin && "AUTH_C_USER=" + $.Pin + ";" || ""}${activityCookie}` + } + // console.log(headers) + // console.log(headers.Cookie) + return {url: url, method: method, headers: headers, body: body, timeout:30000}; +} + +function getCk() { + return new Promise(resolve => { + let get = { + url:`https://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}`, + followRedirect:false, + headers: { + "User-Agent": $.UA, + }, + timeout:30000 + } + $.get(get, async(err, resp, data) => { + try { + if (err) { + if(resp && typeof resp.statusCode != 'undefined'){ + if(resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + } + console.log(`${$.toStr(err)}`) + console.log(`${$.name} cookie API请求失败,请检查网路重试`) + } else { + let end = data.match(/(活动已经结束)/) && data.match(/(活动已经结束)/)[1] || '' + if(end){ + $.activityEnd = true + console.log('活动已结束') + } + setActivityCookie(resp) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function setActivityCookie(resp){ + let LZ_TOKEN_KEY = '' + let LZ_TOKEN_VALUE = '' + let lz_jdpin_token = '' + let setcookies = resp && resp['headers'] && (resp['headers']['set-cookie'] || resp['headers']['Set-Cookie'] || '') || '' + let setcookie = '' + if(setcookies){ + if(typeof setcookies != 'object'){ + setcookie = setcookies.split(',') + }else setcookie = setcookies + for (let ck of setcookie) { + let name = ck.split(";")[0].trim() + if(name.split("=")[1]){ + // console.log(name.replace(/ /g,'')) + if(name.indexOf('LZ_TOKEN_KEY=')>-1) LZ_TOKEN_KEY = name.replace(/ /g,'')+';' + if(name.indexOf('LZ_TOKEN_VALUE=')>-1) LZ_TOKEN_VALUE = name.replace(/ /g,'')+';' + if(name.indexOf('lz_jdpin_token=')>-1) lz_jdpin_token = ''+name.replace(/ /g,'')+';' + } + } + } + if(LZ_TOKEN_KEY && LZ_TOKEN_VALUE) activityCookie = `${LZ_TOKEN_KEY} ${LZ_TOKEN_VALUE}` + if(lz_jdpin_token) lz_jdpin_token_cookie = lz_jdpin_token +} + +async function getUA(){ + $.UA = `jdapp;iPhone;10.1.4;13.1.2;${randomString(40)};network/wifi;model/iPhone8,1;addressid/2308460611;appBuild/167814;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_1_2 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 joinShop() { + if(!$.joinVenderId) return + return new Promise(async resolve => { + $.shopactivityId = '' + await $.wait(1000) + await getshopactivityId() + let activityId = `` + if($.shopactivityId) activityId = `,"activityId":${$.shopactivityId}` + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body={"venderId":"${$.joinVenderId}","shopId":"${$.joinVenderId}","bindByVerifyCodeFlag":1,"registerExtend":{},"writeChildFlag":0${activityId},"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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + // console.log(data) + let res = $.toObj(data); + if(typeof res == 'object'){ + if(res.success === true){ + console.log(res.message) + if(res.result && res.result.giftInfo){ + for(let i of res.result.giftInfo.giftList){ + console.log(`入会获得:${i.discountString}${i.prizeName}${i.secondLineDesc}`) + } + } + }else if(typeof res == 'object' && res.message){ + console.log(`${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function getshopactivityId() { + return new Promise(resolve => { + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body=%7B%22venderId%22%3A%22${$.joinVenderId}%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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + let res = $.toObj(data); + if(res.success == true){ + // console.log($.toStr(res.result)) + console.log(`入会:${res.result.shopMemberCardInfo.venderCardName || ''}`) + $.shopactivityId = res.result.interestsRuleList && res.result.interestsRuleList[0] && res.result.interestsRuleList[0].interestsInfo && res.result.interestsRuleList[0].interestsInfo.activityId || '' + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} + + +// 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)} + diff --git a/activity/jd_opencardL42.js b/activity/jd_opencardL42.js new file mode 100644 index 0000000..f1ba332 --- /dev/null +++ b/activity/jd_opencardL42.js @@ -0,0 +1,796 @@ +/* +1.10~1.28 会员邀新赢万元年货大奖 +新增开卡脚本,一次性脚本 + +第一个账号助力作者 其他依次助力CK1 +第一个CK失效会退出脚本 + +———————————————— +入口:[ 1.10~1.28 会员邀新赢万元年货大奖 (https://lzdz1-isv.isvjcloud.com/dingzhi/majorsuit/memberday/activity?activityId=dz2112100001448501&shareUuid=cb72e9e61c09419d90ebef3ea436ea2a)] + +请求太频繁会被黑ip +过10分钟再执行 + +cron:30 4,18 10-28 1 * +============Quantumultx=============== +[task_local] +#1.10~1.28 会员邀新赢万元年货大奖 +30 4,18 10-28 1 * jd_opencardL42.js, tag=1.10~1.28 会员邀新赢万元年货大奖, enabled=true + +*/ + +const $ = new Env('1.10~1.28 会员邀新赢万元年货大奖'); +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const notify = $.isNode() ? require('./sendNotify') : ''; +//IOS等用户直接用NobyDa的jd cookie + +let cookiesArr = [], + cookie = ''; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} + +allMessage = "" +message = "" +$.hotFlag = false +$.outFlag = false +$.activityEnd = false +let lz_jdpin_token_cookie ='' +let activityCookie ='' +!(async () => { + + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', { + "open-url": "https://bean.m.jd.com/" + }); + return; + } + $.activityId = "dz2112100001448501" + $.shareUuid = "cb72e9e61c09419d90ebef3ea436ea2a" + console.log(`入口:\nhttps://lzdz1-isv.isvjcloud.com/dingzhi/majorsuit/memberday/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}`) + + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i]; + if (cookie) { + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + message = "" + $.bean = 0 + $.hotFlag = false + $.nickName = ''; + console.log(`\n\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + await getUA() + await run(); + if(i == 0 && !$.actorUuid) break + if($.outFlag || $.activityEnd) break + } + } + if($.outFlag) { + let msg = '此ip已被限制,请过10分钟后再执行脚本' + $.msg($.name, ``, `${msg}`); + if ($.isNode()) await notify.sendNotify(`${$.name}`, `${msg}`); + } +})() + .catch((e) => $.logErr(e)) + .finally(() => $.done()) + + +async function run() { + try { + $.hasEnd = true + $.endTime = 0 + lz_jdpin_token_cookie = '' + $.Token = '' + $.Pin = '' + let flag = false + await takePostRequest('isvObfuscator'); + if($.Token == ''){ + console.log('获取[token]失败!') + return + } + await getCk() + if (activityCookie == '') { + console.log(`获取cookie失败`); return; + } + if($.activityEnd === true){ + console.log('活动结束') + return + } + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + await takePostRequest('getSimpleActInfoVo'); + await takePostRequest('getMyPing'); + if(!$.Pin){ + console.log('获取[Pin]失败!') + return + } + await takePostRequest('accessLogWithAD'); + await takePostRequest('getUserInfo'); + await takePostRequest('activityContent'); + if($.hotFlag) return + if(!$.actorUuid){ + console.log('获取不到[actorUuid]退出执行,请重新执行') + return + } + if($.hasEnd === true || Date.now() > $.endTime){ + $.activityEnd = true + console.log('活动结束') + return + } + await takePostRequest('drawContent'); + await $.wait(1000) + $.openList = [] + $.allOpenCard = false + await takePostRequest('checkOpenCard'); + // console.log($.actorUuid) + // return + if($.allOpenCard == false){ + console.log('开卡任务') + for(o of $.openList){ + $.openCard = false + if(o.openStatus == false){ + flag = true + $.joinVenderId = o.venderId + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + await joinShop() + await $.wait(parseInt(Math.random() * 1000 + 1000, 10)) + await takePostRequest('activityContent'); + await takePostRequest('drawContent'); + await takePostRequest('checkOpenCard'); + await $.wait(parseInt(Math.random() * 3000 + 2000, 10)) + } + } + }else{ + console.log('已全部开卡') + } + + $.log("关注: " + $.followShop) + if(!$.followShop && !$.outFlag){ + flag = true + await takePostRequest('followShop'); + await $.wait(parseInt(Math.random() * 2000 + 2000, 10)) + } + if(flag){ + await takePostRequest('activityContent'); + } + $.runFalag = true + let count = parseInt($.score/1) + console.log(`抽奖次数为:${count}`) + for(m=1;count--;m++){ + console.log(`第${m}次抽奖`) + await takePostRequest('抽奖'); + if($.runFalag == false) break + if(Number(count) <= 0) break + if(m >= 10){ + console.log("抽奖太多次,多余的次数请再执行脚本") + break + } + await $.wait(parseInt(Math.random() * 2000 + 2000, 10)) + } + + await $.wait(parseInt(Math.random() * 1000 + 2000, 10)) + await takePostRequest('getDrawRecordHasCoupon'); + await takePostRequest('getShareRecord'); + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + console.log($.actorUuid) + console.log(`当前助力:${$.shareUuid}`) + if($.index == 1){ + $.shareUuid = $.actorUuid + console.log(`后面的号都会助力:${$.shareUuid}`) + } + await $.wait(parseInt(Math.random() * 1000 + 5000, 10)) + if(flag) await $.wait(parseInt(Math.random() * 1000 + 10000, 10)) + if($.index % 3 == 0) console.log('休息1分钟,别被黑ip了\n可持续发展') + if($.index % 3 == 0) await $.wait(parseInt(Math.random() * 5000 + 60000, 10)) + } catch (e) { + console.log(e) + } +} + +async function takePostRequest(type) { + if($.outFlag) return + let domain = 'https://lzdz1-isv.isvjcloud.com'; + let body = ``; + let method = 'POST' + let admJson = '' + switch (type) { + case 'isvObfuscator': + url = `https://api.m.jd.com/client.action?functionId=isvObfuscator`; + body = `body=%7B%22url%22%3A%22https%3A//lzdz1-isv.isvjcloud.com%22%2C%22id%22%3A%22%22%7D&uuid=7088d9018515b8cb0c88ace6e5479762af3e88f3&client=apple&clientVersion=10.1.4&st=1634343624086&sv=120&sign=8b9cea22c3a0d77026abda5d37d2b7e3`; + break; + case 'getSimpleActInfoVo': + url = `${domain}/dz/common/getSimpleActInfoVo`; + body = `activityId=${$.activityId}`; + break; + case 'getMyPing': + url = `${domain}/customer/getMyPing`; + body = `userId=${$.shopId || $.venderId || ''}&token=${$.Token}&fromType=APP`; + break; + case 'accessLogWithAD': + url = `${domain}/common/accessLogWithAD`; + let pageurl = `${domain}/drawCenter/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}` + body = `venderId=${$.shopId || $.venderId || ''}&code=99&pin=${encodeURIComponent($.Pin)}&activityId=${$.activityId}&pageUrl=${encodeURIComponent(pageurl)}&subType=app&adSource=` + break; + case 'getUserInfo': + url = `${domain}/wxActionCommon/getUserInfo`; + body = `pin=${encodeURIComponent($.Pin)}`; + break; + case 'activityContent': + url = `${domain}/dingzhi/majorsuit/memberday/activityContent`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&pinImg=${encodeURIComponent($.attrTouXiang)}&nick=${encodeURIComponent($.nickname)}&cjyxPin=&cjhyPin=&shareUuid=${$.shareUuid}` + break; + case 'drawContent': + url = `${domain}/dingzhi/taskact/common/drawContent`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case 'checkOpenCard': + url = `${domain}/dingzhi/majorsuit/memberday/initOpenCard`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&shareUuid=${$.shareUuid}` + break; + case 'info': + url = `${domain}/dingzhi/linkgame/task/opencard/info`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case 'startDraw': + url = `${domain}/joint/order/draw`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&drawType=1` + break; + case 'followShop': + url = `${domain}/dingzhi/majorsuit/memberday/saveTask`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&taskType=23&taskValue=1&shareUuid=${$.shareUuid}` + break; + case 'sign': + case 'addCart': + case 'browseGoods': + url = `${domain}/dingzhi/linkgame/${type}`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + if(type == 'browseGoods') body += `&value=${$.visitSkuValue}` + break; + case '邀请': + case '助力': + if(type == '助力'){ + url = `${domain}/dingzhi/linkgame/assist`; + }else{ + url = `${domain}/dingzhi/linkgame/assist/status`; + } + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&shareUuid=${$.shareUuid}` + break; + case 'viewVideo': + case 'visitSku': + case 'toShop': + case 'addSku': + case 'toMainActive': + url = `${domain}/dingzhi/majorsuit/memberday/saveTask`; + let taskType = '' + let taskValue = '' + if(type == 'viewVideo'){ + taskType = 31 + taskValue = 31 + }else if(type == 'visitSku'){ + taskType = 5 + taskValue = $.visitSkuValue || 5 + }else if(type == 'toShop'){ + taskType = 14 + taskValue = $.toShopValue || 14 + }else if(type == 'addSku'){ + taskType = 2 + taskValue = $.addSkuValue || 2 + }else if(type == 'toMainActive'){ + taskType = 12 + taskValue = 3 + } + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&taskType=${taskType}&taskValue=${taskValue}&shareUuid=${$.shareUuid}` + break; + case 'getDrawRecordHasCoupon': + url = `${domain}/dingzhi/taskact/common/getDrawRecordHasCoupon`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case 'getShareRecord': + url = `${domain}/dingzhi/taskact/common/getShareRecord`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case 'getRule': + url = `${domain}/dingzhi/majorsuit/memberday/getRule`; + body = `activityId=${$.activityId}` + break; + case '抽奖': + url = `${domain}/dingzhi/majorsuit/memberday/draw`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + default: + console.log(`错误${type}`); + } + let myRequest = getPostRequest(url, body, method); + return new Promise(async resolve => { + $.post(myRequest, (err, resp, data) => { + try { + setActivityCookie(resp) + if (err) { + if(resp && typeof resp.statusCode != 'undefined'){ + if(resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + } + console.log(`${$.toStr(err,err)}`) + console.log(`${type} API请求失败,请检查网路重试`) + } else { + dealReturn(type, data); + } + } catch (e) { + console.log(e, resp) + } finally { + resolve(); + } + }) + }) + } + +async function dealReturn(type, data) { + let res = '' + try { + if(type != 'accessLogWithAD' || type != 'drawContent'){ + if(data){ + res = JSON.parse(data); + } + } + } catch (e) { + console.log(`${type} 执行任务异常`); + console.log(data); + $.runFalag = false; + } + try { + switch (type) { + case 'isvObfuscator': + if(typeof res == 'object'){ + if(res.errcode == 0){ + if(typeof res.token != 'undefined') $.Token = res.token + }else if(res.message){ + console.log(`isvObfuscator ${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + break; + case 'getSimpleActInfoVo': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(typeof res.data.shopId != 'undefined') $.shopId = res.data.shopId + if(typeof res.data.venderId != 'undefined') $.venderId = res.data.venderId + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getMyPing': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(res.data && typeof res.data.secretPin != 'undefined') $.Pin = res.data.secretPin + if(res.data && typeof res.data.nickname != 'undefined') $.nickname = res.data.nickname + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getUserInfo': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(res.data && typeof res.data.yunMidImageUrl != 'undefined') $.attrTouXiang = res.data.yunMidImageUrl || "https://img10.360buyimg.com/imgzone/jfs/t1/7020/27/13511/6142/5c5138d8E4df2e764/5a1216a3a5043c5d.png" + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'activityContent': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + $.endTime = res.data.endTime || (res.data.activityVo && res.data.activityVo.endTime) || res.data.activity.endTime || 0 + $.hasEnd = res.data.isEnd || false + $.drawCount = res.data.drawCount || (res.data.actor && res.data.actor.drawCount) || 0 + $.point = res.data.point || (res.data.actor && res.data.actor.point) || 0 + $.score = res.data.score || (res.data.actor && res.data.actor.score) || 0 + $.actorUuid = res.data.actorUuid || (res.data.actor && res.data.actor.actorUuid) || '' + $.followShop = res.data.followShop || (res.data.actor && res.data.actor.followShopStatus) || '' + $.toMainActive = res.data.toMainActive || '' + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'info': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + $.addCart = res.data.addCart || false + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'checkOpenCard': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + let cardList1 = res.data.cardList1 || [] + let cardList2 = res.data.cardList2 || [] + let cardList = res.data.cardList || [] + let openInfo = res.data.openInfo || [] + let openCardList = res.data.openCardList || [] + $.openList = [...cardList,...cardList1,...cardList2,...openCardList,...openInfo] + $.allOpenCard = res.data.allOpenCard || res.data.isOpenCardStatus || false + $.openCardScore1 = res.data.score1 || 0 + $.openCardScore2 = res.data.score2 || 0 + $.drawScore = res.data.drawScore || 0 + if(res.data.beans) console.log(`获得:${res.data.beans}豆`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'startDraw': + case 'followShop': + case 'viewVideo': + case 'visitSku': + case 'toShop': + case 'addSku': + case 'sign': + case 'addCart': + case 'browseGoods': + case 'toMainActive': + case '抽奖': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(typeof res.data == 'object'){ + let msg = '' + let title = '抽奖' + if(res.data.addBeanNum || res.data.taskbeanNum){ + msg = `${res.data.addBeanNum || res.data.taskbeanNum}京豆` + } + if(res.data.addPoint){ + msg += ` ${res.data.addPoint}游戏机会` + } + if(type == 'followShop'){ + title = '关注' + if(res.data.beanNumMember && res.data.assistSendStatus){ + msg += ` 额外获得:${res.data.beanNumMember}京豆` + } + }else if(type == 'addSku' || type == 'addCart'){ + title = '加购' + }else if(type == 'viewVideo'){ + title = '热门文章' + }else if(type == 'toShop'){ + title = '浏览店铺' + }else if(type == 'visitSku' || type == 'browseGoods'){ + title = '浏览商品' + }else if(type == 'sign'){ + title = '签到' + }else if(type == 'toMainActive'){ + title = '逛会场' + }else{ + msg = res.data.drawOk == true && (res.data.drawInfoType == 6 && res.data.name || '') || res.data.wdsrvo.drawOk == true && (res.data.wdsrvo.drawInfoType == 6 && res.data.wdsrvo.name || '') || '空气💨' + } + if(!msg){ + msg = '空气💨' + } + console.log(`${title}获得:${msg || data}`) + }else{ + console.log(`${type} ${data}`) + } + }else if(res.errorMessage){ + $.runFalag = false; + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getDrawRecordHasCoupon': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + console.log(`我的奖品:`) + let num = 0 + let value = 0 + let typeArr = { + "dayShareBeans":"邀请", + "dayBeSharedBeans":"被邀请", + "openCardBeans":"开卡", + "saveTaskBeans23":"关注", + "saveTaskBeans12":"逛会场", + } + for(let i in res.data){ + let item = res.data[i] + if(item.drawId == 'dayShareBeans'){ + num++ + value = item.infoName.replace('京豆','') + }else{ + console.log(`${item.infoType != 10 && item.drawId && (typeArr[item.drawId] || item.drawId)+':' || item.value && item.value +':' || ''}${item.infoName}`) + } + } + if(num > 0) console.log(`邀请好友(${num}):${num*parseInt(value, 10) || 30}京豆`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getShareRecord': + if(typeof res == 'object'){ + if(res.result && res.result === true && res.data){ + $.ShareCount = res.data.length + $.log(`=========== 你邀请了:${res.data.length}个`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case '邀请': + case '助力': + if(typeof res == 'object'){ + if(res.data.status == 200){ + if(type == '助力'){ + console.log('助力成功') + }else{ + $.yaoqing = true + } + }else if(res.data.status == 105){ + console.log('已经助力过') + }else if(res.data.status == 104){ + console.log('已经助力其他人') + }else if(res.data.status == 101){ + // console.log('已经助力过') + }else{ + console.log(data) + } + }else{ + console.log(`${type} ${data}`) + } + + case 'accessLogWithAD': + case 'drawContent': + break; + default: + console.log(`${type}-> ${data}`); + } + if(typeof res == 'object'){ + if(res.errorMessage){ + if(res.errorMessage.indexOf('火爆') >-1 ){ + $.hotFlag = true + } + } + } + } catch (e) { + console.log(e) + } +} + +function getPostRequest(url, body, method="POST") { + let headers = { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Content-Type": "application/x-www-form-urlencoded", + "Cookie": cookie, + "User-Agent": $.UA, + "X-Requested-With": "XMLHttpRequest" + } + if(url.indexOf('https://lzdz1-isv.isvjcloud.com') > -1){ + headers["Referer"] = `https://lzdz1-isv.isvjcloud.com/dingzhi/majorsuit/memberday/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}` + headers["Cookie"] = `${lz_jdpin_token_cookie && lz_jdpin_token_cookie || ''}${$.Pin && "AUTH_C_USER=" + $.Pin + ";" || ""}${activityCookie}` + } + // console.log(headers) + // console.log(headers.Cookie) + return {url: url, method: method, headers: headers, body: body, timeout:30000}; +} + +function getCk() { + return new Promise(resolve => { + let get = { + url:`https://lzdz1-isv.isvjcloud.com/dingzhi/majorsuit/memberday/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}`, + followRedirect:false, + headers: { + "User-Agent": $.UA, + }, + timeout:30000 + } + $.get(get, async(err, resp, data) => { + try { + if (err) { + if(resp && typeof resp.statusCode != 'undefined'){ + if(resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + } + console.log(`${$.toStr(err)}`) + console.log(`${$.name} cookie API请求失败,请检查网路重试`) + } else { + let end = data.match(/(活动已经结束)/) && data.match(/(活动已经结束)/)[1] || '' + if(end){ + $.activityEnd = true + console.log('活动已结束') + } + setActivityCookie(resp) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function setActivityCookie(resp){ + let LZ_TOKEN_KEY = '' + let LZ_TOKEN_VALUE = '' + let lz_jdpin_token = '' + let setcookies = resp && resp['headers'] && (resp['headers']['set-cookie'] || resp['headers']['Set-Cookie'] || '') || '' + let setcookie = '' + if(setcookies){ + if(typeof setcookies != 'object'){ + setcookie = setcookies.split(',') + }else setcookie = setcookies + for (let ck of setcookie) { + let name = ck.split(";")[0].trim() + if(name.split("=")[1]){ + // console.log(name.replace(/ /g,'')) + if(name.indexOf('LZ_TOKEN_KEY=')>-1) LZ_TOKEN_KEY = name.replace(/ /g,'')+';' + if(name.indexOf('LZ_TOKEN_VALUE=')>-1) LZ_TOKEN_VALUE = name.replace(/ /g,'')+';' + if(name.indexOf('lz_jdpin_token=')>-1) lz_jdpin_token = ''+name.replace(/ /g,'')+';' + } + } + } + if(LZ_TOKEN_KEY && LZ_TOKEN_VALUE) activityCookie = `${LZ_TOKEN_KEY} ${LZ_TOKEN_VALUE}` + if(lz_jdpin_token) lz_jdpin_token_cookie = lz_jdpin_token +} + +async function getUA(){ + $.UA = `jdapp;iPhone;10.1.4;13.1.2;${randomString(40)};network/wifi;model/iPhone8,1;addressid/2308460611;appBuild/167814;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_1_2 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 joinShop() { + if(!$.joinVenderId) return + return new Promise(async resolve => { + $.shopactivityId = '' + await $.wait(1000) + await getshopactivityId() + let activityId = `` + if($.shopactivityId) activityId = `,"activityId":${$.shopactivityId}` + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body={"venderId":"${$.joinVenderId}","shopId":"${$.joinVenderId}","bindByVerifyCodeFlag":1,"registerExtend":{},"writeChildFlag":0${activityId},"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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + // console.log(data) + let res = $.toObj(data); + if(typeof res == 'object'){ + if(res.success === true){ + console.log(res.message) + if(res.result && res.result.giftInfo){ + for(let i of res.result.giftInfo.giftList){ + console.log(`入会获得:${i.discountString}${i.prizeName}${i.secondLineDesc}`) + } + } + }else if(typeof res == 'object' && res.message){ + console.log(`${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function getshopactivityId() { + return new Promise(resolve => { + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body=%7B%22venderId%22%3A%22${$.joinVenderId}%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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + let res = $.toObj(data); + if(res.success == true){ + // console.log($.toStr(res.result)) + console.log(`入会:${res.result.shopMemberCardInfo.venderCardName || ''}`) + $.shopactivityId = res.result.interestsRuleList && res.result.interestsRuleList[0] && res.result.interestsRuleList[0].interestsInfo && res.result.interestsRuleList[0].interestsInfo.activityId || '' + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} + + +// 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)} + diff --git a/activity/jd_opencardL43.js b/activity/jd_opencardL43.js new file mode 100644 index 0000000..af8876b --- /dev/null +++ b/activity/jd_opencardL43.js @@ -0,0 +1,705 @@ +/* +1.13~1.20 瓜分千万京豆 免费抽大奖 +新增开卡脚本,一次性脚本 + +1.邀请一人20豆 +2.开3组(共36张) 成功开1张 可能获得5京豆 + 每开完1组 可以抽1次奖 +3.关注5豆 +4.加购3京豆 + +第一个账号助力作者 其他依次助力CK1 +第一个CK失效会退出脚本 + +———————————————— +入口:[ 1.13~1.20 瓜分千万京豆 免费抽大奖 (https://lzdz1-isv.isvjcloud.com/dingzhi/shop/league/activity?activityId=dz220107100001616201shop&shareUuid=6ab5d2a7da52437eaa53dd541250e21c)] + +请求太频繁会被黑ip +过10分钟再执行 + +cron:30 8,22 12-20 1 * +============Quantumultx=============== +[task_local] +#1.13~1.20 瓜分千万京豆 免费抽大奖 +30 8,22 12-20 1 * jd_opencardL43.js, tag=1.13~1.20 瓜分千万京豆 免费抽大奖, enabled=true + +*/ +const $ = new Env('1.13~1.20 瓜分千万京豆 免费抽大奖'); +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const notify = $.isNode() ? require('./sendNotify') : ''; +//IOS等用户直接用NobyDa的jd cookie + +let cookiesArr = [], + cookie = ''; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} +allMessage = "" +message = "" +$.hotFlag = false +$.outFlag = false +$.activityEnd = false +let lz_jdpin_token_cookie ='' +let activityCookie ='' +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', { + "open-url": "https://bean.m.jd.com/" + }); + return; + } + $.activityId = "dz220107100001616201shop" + $.shareUuid = "bf943ec4a038473f865b13c0f1868b52" + console.log(`入口:\nhttps://lzdz1-isv.isvjcloud.com/dingzhi/shop/league/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}`) + + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i]; + if (cookie) { + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + message = "" + $.bean = 0 + $.hotFlag = false + $.nickName = ''; + console.log(`\n\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + await getUA() + await run(); + if(i == 0 && !$.actorUuid) break + if($.outFlag || $.activityEnd) break + } + } + if($.outFlag) { + let msg = '此ip已被限制,请过10分钟后再执行脚本' + $.msg($.name, ``, `${msg}`); + if ($.isNode()) await notify.sendNotify(`${$.name}`, `${msg}`); + } +})() + .catch((e) => $.logErr(e)) + .finally(() => $.done()) + + +async function run() { + try { + $.hasEnd = true + $.endTime = 0 + lz_jdpin_token_cookie = '' + $.Token = '' + $.Pin = '' + let flag = false + await takePostRequest('isvObfuscator'); + if($.Token == ''){ + console.log('获取[token]失败!') + return + } + await getCk() + if (activityCookie == '') { + console.log(`获取cookie失败`); return; + } + if($.activityEnd === true){ + console.log('活动结束') + return + } + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + await takePostRequest('getSimpleActInfoVo'); + await takePostRequest('getMyPing'); + if(!$.Pin){ + console.log('获取[Pin]失败!') + return + } + await takePostRequest('accessLogWithAD'); + await takePostRequest('getUserInfo'); + await takePostRequest('activityContent'); + if($.hotFlag) return + if(!$.actorUuid){ + console.log('获取不到[actorUuid]退出执行,请重新执行') + return + } + if($.hasEnd === true || Date.now() > $.endTime){ + $.activityEnd = true + console.log('活动结束') + return + } + await takePostRequest('drawContent'); + await $.wait(1000) + $.openList = [] + $.allOpenCard = false + await takePostRequest('checkOpenCard'); + // console.log($.actorUuid) + // return + if($.allOpenCard == false){ + console.log('开卡任务') + for(o of $.openList){ + $.openCard = false + if(o.status == 0){ + flag = true + $.joinVenderId = o.value + await joinShop() + await $.wait(parseInt(Math.random() * 2000 + 3000, 10)) + await takePostRequest('drawContent'); + await takePostRequest('checkOpenCard'); + await $.wait(parseInt(Math.random() * 3000 + 2000, 10)) + } + } + await takePostRequest('activityContent'); + }else{ + console.log('已全部开卡') + } + $.log("关注: " + $.followShop) + if(!$.followShop && !$.outFlag){ + flag = true + $.followShopValue = 1 + await takePostRequest('followShop'); + await $.wait(parseInt(Math.random() * 1000 + 5000, 10)) + } + $.log("加购: " + $.addSku) + if(!$.addSku && !$.outFlag){ + flag = true + $.followShopValue = 2 + await takePostRequest('addSku'); + await $.wait(parseInt(Math.random() * 1000 + 5000, 10)) + } + $.runFalag = true + if(flag){ + await takePostRequest('activityContent'); + } + await $.wait(parseInt(Math.random() * 1000 + 2000, 10)) + await takePostRequest('getDrawRecordHasCoupon'); + await takePostRequest('getShareRecord'); + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + console.log($.actorUuid) + console.log(`当前助力:${$.shareUuid}`) + if($.index == 1){ + $.shareUuid = $.actorUuid + console.log(`后面的号都会助力:${$.shareUuid}`) + } + await $.wait(parseInt(Math.random() * 1000 + 5000, 10)) + if(flag) await $.wait(parseInt(Math.random() * 1000 + 10000, 10)) + if($.index % 3 == 0) console.log('休息1分钟,别被黑ip了\n可持续发展') + if($.index % 3 == 0) await $.wait(parseInt(Math.random() * 5000 + 60000, 10)) + } catch (e) { + console.log(e) + } +} + +async function takePostRequest(type) { + if($.outFlag) return + let domain = 'https://lzdz1-isv.isvjcloud.com'; + let body = ``; + let method = 'POST' + let admJson = '' + switch (type) { + case 'isvObfuscator': + url = `https://api.m.jd.com/client.action?functionId=isvObfuscator`; + body = `body=%7B%22url%22%3A%22https%3A//lzdz1-isv.isvjcloud.com%22%2C%22id%22%3A%22%22%7D&uuid=0846724fe8d803b8e84ebd14b3ba7fac6df80e7a&client=apple&clientVersion=10.1.4&st=1634616247215&sv=120&sign=91a16ae2feb0bd0e1ea48d99e7953c58`; + break; + case 'getSimpleActInfoVo': + url = `${domain}/dz/common/getSimpleActInfoVo`; + body = `activityId=${$.activityId}`; + break; + case 'getMyPing': + url = `${domain}/customer/getMyPing`; + body = `userId=${$.shopId || $.venderId || ''}&token=${$.Token}&fromType=APP`; + break; + case 'accessLogWithAD': + url = `${domain}/common/accessLogWithAD`; + let pageurl = `${domain}/drawCenter/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}` + body = `venderId=${$.shopId || $.venderId || ''}&code=99&pin=${encodeURIComponent($.Pin)}&activityId=${$.activityId}&pageUrl=${encodeURIComponent(pageurl)}&subType=app&adSource=` + break; + case 'getUserInfo': + url = `${domain}/wxActionCommon/getUserInfo`; + body = `pin=${encodeURIComponent($.Pin)}`; + break; + case 'activityContent': + url = `${domain}/dingzhi/shop/league/activityContent`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&pinImg=${encodeURIComponent($.attrTouXiang)}&nick=${encodeURIComponent($.nickname)}&cjyxPin=&cjhyPin=&shareUuid=${$.shareUuid}` + break; + case 'drawContent': + url = `${domain}/dingzhi/taskact/openCardcommon/drawContent`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case 'checkOpenCard': + url = `${domain}/dingzhi/shop/league/checkOpenCard`; + body = `activityId=${$.activityId}&actorUuid=${$.actorUuid}&pin=${encodeURIComponent($.Pin)}&shareUuid=${$.shareUuid}` + break; + case 'startDraw': + url = `${domain}/dingzhi/shop/league/startDraw`; + body = `activityId=${$.activityId}&actorUuid=${$.actorUuid}&pin=${encodeURIComponent($.Pin)}${$.startDraw && '&type='+$.startDraw || ''}` + break; + case 'followShop': + url = `${domain}/dingzhi/shop/league/saveTask`; + // url = `${domain}/dingzhi/dz/openCard/saveTask`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&shareUuid=${$.shareUuid}&taskType=1&taskValue=${$.followShopValue}` + break; + case 'viewVideo': + case 'visitSku': + case 'toShop': + case 'addSku': + url = `${domain}/dingzhi/shop/league/saveTask`; + let taskType = '' + let taskValue = '' + if(type == 'viewVideo'){ + taskType = 31 + taskValue = 31 + }else if(type == 'visitSku'){ + taskType = 5 + taskValue = $.visitSkuValue || 5 + }else if(type == 'toShop'){ + taskType = 14 + taskValue = $.toShopValue || 14 + }else if(type == 'addSku'){ + taskType = 2 + taskValue = $.addSkuValue || 2 + } + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&taskType=${taskType}&taskValue=${taskValue}` + break; + case 'getDrawRecordHasCoupon': + url = `${domain}/dingzhi/taskact/common/getDrawRecordHasCoupon`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case 'getShareRecord': + url = `${domain}/dingzhi/taskact/common/getShareRecord`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + default: + console.log(`错误${type}`); + } + let myRequest = getPostRequest(url, body, method); + // console.log(myRequest) + return new Promise(async resolve => { + $.post(myRequest, (err, resp, data) => { + try { + setActivityCookie(resp) + if (err) { + if(resp && typeof resp.statusCode != 'undefined'){ + if(resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + } + console.log(`${$.toStr(err,err)}`) + console.log(`${type} API请求失败,请检查网路重试`) + } else { + dealReturn(type, data); + } + } catch (e) { + // console.log(data); + console.log(e, resp) + } finally { + resolve(); + } + }) + }) + } + +async function dealReturn(type, data) { + let res = '' + try { + if(type != 'accessLogWithAD' || type != 'drawContent'){ + if(data){ + res = JSON.parse(data); + } + } + } catch (e) { + console.log(`${type} 执行任务异常`); + console.log(data); + $.runFalag = false; + } + try { + switch (type) { + case 'isvObfuscator': + if(typeof res == 'object'){ + if(res.errcode == 0){ + if(typeof res.token != 'undefined') $.Token = res.token + }else if(res.message){ + console.log(`isvObfuscator ${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + break; + case 'getSimpleActInfoVo': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(typeof res.data.shopId != 'undefined') $.shopId = res.data.shopId + if(typeof res.data.venderId != 'undefined') $.venderId = res.data.venderId + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getMyPing': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(res.data && typeof res.data.secretPin != 'undefined') $.Pin = res.data.secretPin + if(res.data && typeof res.data.nickname != 'undefined') $.nickname = res.data.nickname + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getUserInfo': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(res.data && typeof res.data.yunMidImageUrl != 'undefined') $.attrTouXiang = res.data.yunMidImageUrl || "https://img10.360buyimg.com/imgzone/jfs/t1/7020/27/13511/6142/5c5138d8E4df2e764/5a1216a3a5043c5d.png" + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'activityContent': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + $.endTime = res.data.endTime || 0 + $.hasEnd = res.data.hasEnd || false + $.actorUuid = res.data.actorUuid || '' + $.followShop = res.data.followShop.allStatus || false + $.addSku = res.data.addSku.allStatus || false + if(res.data.followShop && res.data.followShop.settings && res.data.followShop.settings[0]){ + $.followShopValue = res.data.followShop.settings[0].value || 1 + } + if(res.data.addSku && res.data.addSku.settings && res.data.addSku.settings[0]){ + $.addSkuValue = res.data.addSku.settings[0].value || 2 + } + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'checkOpenCard': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + let cardList1 = res.data.cardList1 || [] + let cardList2 = res.data.cardList2 || [] + let cardList = res.data.cardList || [] + $.openList = [...cardList,...cardList1,...cardList2] + $.allOpenCard = res.data.allOpenCard || false + $.openCardScore1 = res.data.score1 || res.data.drawScore1 || 0 + $.openCardScore2 = res.data.score2 || res.data.drawScore2 || 0 + $.openCardScore3 = res.data.score3 || res.data.drawScore3 || 0 + $.drawScore = res.data.drawScore || 0 + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'startDraw': + case 'followShop': + case 'viewVideo': + case 'visitSku': + case 'toShop': + case 'addSku': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(typeof res.data == 'object'){ + let msg = '' + let title = '抽奖' + if(res.data.addBeanNum && res.data.sendStatus){ + msg = `${res.data.addBeanNum}京豆` + } + if(type == 'followShop'){ + title = '关注' + if(res.data.beanNumMember && res.data.assistSendStatus){ + msg += ` 额外获得:${res.data.beanNumMember}京豆` + } + }else if(type == 'addSku'){ + title = '加购' + }else if(type == 'viewVideo'){ + title = '热门文章' + }else if(type == 'toShop'){ + title = '浏览店铺' + }else if(type == 'visitSku'){ + title = '浏览商品' + }else{ + msg = res.data.drawOk == true && (res.data.drawInfoType == 6 && res.data.name || '') || '空气💨' + } + if(!msg){ + msg = '空气💨' + } + console.log(`${title}获得:${msg || data}`) + }else{ + console.log(`${type} ${data}`) + } + }else if(res.errorMessage){ + $.runFalag = false; + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getDrawRecordHasCoupon': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + console.log(`我的奖品:`) + let num = 0 + let value = 0 + for(let i in res.data){ + let item = res.data[i] + if(item.value == '邀请好友') num++; + if(item.value == '邀请好友') value = item.infoName.replace('京豆',''); + if(item.value != '邀请好友') console.log(`${item.infoType != 10 && item.value +':' || ''}${item.infoName}`) + } + if(num > 0) console.log(`邀请好友(${num}):${num*parseInt(value, 10) || 30}京豆`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getShareRecord': + if(typeof res == 'object'){ + if(res.result && res.result === true && res.data){ + $.ShareCount = res.data.length + $.log(`=========== 你邀请了:${res.data.length}个`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'accessLogWithAD': + case 'drawContent': + break; + default: + console.log(`${type}-> ${data}`); + } + if(typeof res == 'object'){ + if(res.errorMessage){ + if(res.errorMessage.indexOf('火爆') >-1 ){ + $.hotFlag = true + } + } + } + } catch (e) { + console.log(e) + } +} + +function getPostRequest(url, body, method="POST") { + let headers = { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Content-Type": "application/x-www-form-urlencoded", + "Cookie": cookie, + "User-Agent": $.UA, + "X-Requested-With": "XMLHttpRequest" + } + if(url.indexOf('https://lzdz1-isv.isvjcloud.com') > -1){ + headers["Referer"] = `https://lzdz1-isv.isvjcloud.com/dingzhi/shop/league/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}` + headers["Cookie"] = `${lz_jdpin_token_cookie && lz_jdpin_token_cookie || ''}${$.Pin && "AUTH_C_USER=" + $.Pin + ";" || ""}${activityCookie}` + } + // console.log(headers) + // console.log(headers.Cookie) + return {url: url, method: method, headers: headers, body: body, timeout:30000}; +} + +function getCk() { + return new Promise(resolve => { + let get = { + url:`https://lzdz1-isv.isvjcloud.com/dingzhi/shop/league/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}`, + followRedirect:false, + headers: { + "User-Agent": $.UA, + }, + timeout:30000 + } + $.get(get, async(err, resp, data) => { + try { + if (err) { + if(resp && typeof resp.statusCode != 'undefined'){ + if(resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + } + console.log(`${$.toStr(err)}`) + console.log(`${$.name} cookie API请求失败,请检查网路重试`) + } else { + let end = data.match(/(活动已经结束)/) && data.match(/(活动已经结束)/)[1] || '' + if(end){ + $.activityEnd = true + console.log('活动已结束') + } + setActivityCookie(resp) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function setActivityCookie(resp){ + let LZ_TOKEN_KEY = '' + let LZ_TOKEN_VALUE = '' + let lz_jdpin_token = '' + let setcookies = resp && resp['headers'] && (resp['headers']['set-cookie'] || resp['headers']['Set-Cookie'] || '') || '' + let setcookie = '' + if(setcookies){ + if(typeof setcookies != 'object'){ + setcookie = setcookies.split(',') + }else setcookie = setcookies + for (let ck of setcookie) { + let name = ck.split(";")[0].trim() + if(name.split("=")[1]){ + // console.log(name.replace(/ /g,'')) + if(name.indexOf('LZ_TOKEN_KEY=')>-1) LZ_TOKEN_KEY = name.replace(/ /g,'')+';' + if(name.indexOf('LZ_TOKEN_VALUE=')>-1) LZ_TOKEN_VALUE = name.replace(/ /g,'')+';' + if(name.indexOf('lz_jdpin_token=')>-1) lz_jdpin_token = ''+name.replace(/ /g,'')+';' + } + } + } + if(LZ_TOKEN_KEY && LZ_TOKEN_VALUE) activityCookie = `${LZ_TOKEN_KEY} ${LZ_TOKEN_VALUE}` + if(lz_jdpin_token) lz_jdpin_token_cookie = lz_jdpin_token +} + +async function getUA(){ + $.UA = `jdapp;iPhone;10.1.4;13.1.2;${randomString(40)};network/wifi;model/iPhone8,1;addressid/2308460611;appBuild/167814;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_1_2 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 joinShop() { + if(!$.joinVenderId) return + return new Promise(async resolve => { + $.shopactivityId = '' + await $.wait(1000) + await getshopactivityId() + let activityId = `` + if($.shopactivityId) activityId = `,"activityId":${$.shopactivityId}` + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body={"venderId":"${$.joinVenderId}","shopId":"${$.joinVenderId}","bindByVerifyCodeFlag":1,"registerExtend":{},"writeChildFlag":0${activityId},"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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + // console.log(data) + let res = $.toObj(data); + if(typeof res == 'object'){ + if(res.success === true){ + console.log(res.message) + if(res.result && res.result.giftInfo){ + for(let i of res.result.giftInfo.giftList){ + console.log(`入会获得:${i.discountString}${i.prizeName}${i.secondLineDesc}`) + } + } + }else if(typeof res == 'object' && res.message){ + console.log(`${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function getshopactivityId() { + return new Promise(resolve => { + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body=%7B%22venderId%22%3A%22${$.joinVenderId}%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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + let res = $.toObj(data); + if(res.success == true){ + // console.log($.toStr(res.result)) + console.log(`入会:${res.result.shopMemberCardInfo.venderCardName || ''}`) + $.shopactivityId = res.result.interestsRuleList && res.result.interestsRuleList[0] && res.result.interestsRuleList[0].interestsInfo && res.result.interestsRuleList[0].interestsInfo.activityId || '' + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} + + +// 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)} + diff --git a/activity/jd_opencardL44.js b/activity/jd_opencardL44.js new file mode 100644 index 0000000..061f697 --- /dev/null +++ b/activity/jd_opencardL44.js @@ -0,0 +1,550 @@ +/* +1.13~1.18 联合开卡 +新增开卡脚本,一次性脚本 + +1.邀请一人5豆(有可能没有豆 +2.开12张 成功开1张 可能获得5京豆 + 全部开完获得1次抽奖 +3.关注10京豆 获得1次抽奖 +4.加购5京豆 获得1次抽奖 +5.抽奖 + + +第一个账号助力作者 其他依次助力CK1 +第一个CK失效会退出脚本 + +———————————————— +入口:[ 1.13~1.18 联合开卡 (https://3.cn/10-4FafAy)] + +请求太频繁会被黑ip +过10分钟再执行 + + +cron:6 6,16 13-18 1 * +============Quantumultx=============== +[task_local] +#1.13~1.18 联合开卡 +6 6,16 13-18 1 * jd_opencardL44.js, tag=1.13~1.18 联合开卡, enabled=true + +*/ + +const $ = new Env('1.13~1.18 联合开卡'); +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const notify = $.isNode() ? require('./sendNotify') : ''; + +//IOS等用户直接用NobyDa的jd cookie +let cookiesArr = [], + cookie = ''; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} + +allMessage = "" +message = "" +$.hotFlag = false +$.outFlag = false +$.activityEnd = false +let lz_jdpin_token_cookie ='' +let activityCookie ='' +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', { + "open-url": "https://bean.m.jd.com/" + }); + return; + } + // return + $.appkey = '51B59BB805903DA4CE513D29EC448375' + $.userId = '10299171' + $.actId = 'f6b9469f2ce7439a99bb47_220113' + $.MixNicks = '' + $.inviteNick = 'k1Nobb+P0er+C2sysxnx/P2KELO9izRVpwCyqu0eqVZ5aW7RHzlMobrzJ/e9r/uf' + console.log(`活动地址:https://3.cn/10-4FafAy`) + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i]; + if (cookie) { + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + message = "" + $.bean = 0 + $.hotFlag = false + $.nickName = ''; + console.log(`\n\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + await getUA() + await run(); + if(i == 0 && !$.MixNick) break + if($.outFlag || $.activityEnd) break + } + } + if($.outFlag) { + let msg = '此ip已被限制,请过10分钟后再执行脚本' + $.msg($.name, ``, `${msg}`); + if ($.isNode()) await notify.sendNotify(`${$.name}`, `${msg}`); + } +})() + .catch((e) => $.logErr(e)) + .finally(() => $.done()) + + +async function run() { + try { + $.hasEnd = true + $.endTime = 0 + lz_jdpin_token_cookie = '' + $.Token = '' + $.Pin = '' + $.MixNick = '' + let flag = false + if($.activityEnd) return + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + await takePostRequest('isvObfuscator'); + if($.Token == ''){ + console.log('获取[token]失败!') + return + } + await takePostRequest('activity_load'); + if($.hotFlag) return + if(Date.now() > $.endTime){ + $.MixNick = '' + $.activityEnd = true + console.log('活动结束') + return + } + if ($.MixNick == '') { + console.log(`获取cookie失败`); return; + } + // console.log($.MixNick) + // return + $.toBind = 0 + $.openList = [] + await takePostRequest('绑定'); + await takePostRequest('shopList'); + if($.activityEnd) return + for(o of $.openList){ + $.missionType = 'openCard' + if(o.open != true && o.openCardUrl){ + if($.activityEnd) return + $.openCard = false + $.joinVenderId = o.userId + await takePostRequest('mission'); + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + if($.openCard == true){ + await joinShop() + await takePostRequest('activity_load'); + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + // break + } + $.joinVenderId = '' + } + } + $.joinVenderId = '' + if($.hasCollectShop === 0){ + // 关注 + $.missionType = 'uniteCollectShop' + await takePostRequest('mission'); + await $.wait(parseInt(Math.random() * 2000 + 3000, 10)) + }else{ + console.log('已经关注') + } + $.missionType = 'uniteAddCart' + + await takePostRequest('mission'); + await $.wait(parseInt(Math.random() * 2000 + 3000, 10)) + await takePostRequest('activity_load'); + $.runFalag = true + let count = parseInt($.usedChance, 10) + console.log(`抽奖次数为:${count}`) + for(m=1;count--;m++){ + console.log(`第${m}次抽奖`) + await takePostRequest('抽奖'); + if($.runFalag == false) break + if(Number(count) <= 0) break + if(m >= 10){ + console.log("抽奖太多次,多余的次数请再执行脚本") + break + } + await $.wait(parseInt(Math.random() * 2000 + 2000, 10)) + } + await takePostRequest('myAward'); + await takePostRequest('missionInviteList'); + console.log($.MixNick) + console.log(`当前助力:${$.inviteNick}`) + if($.index == 1){ + $.inviteNick = $.MixNick + console.log(`后面的号都会助力:${$.inviteNick}`) + } + await $.wait(parseInt(Math.random() * 1000 + 5000, 10)) + if(flag) await $.wait(parseInt(Math.random() * 1000 + 10000, 10)) + if($.index % 3 == 0) console.log('休息1分钟,别被黑ip了\n可持续发展') + if($.index % 3 == 0) await $.wait(parseInt(Math.random() * 5000 + 60000, 10)) + } catch (e) { + console.log(e) + } +} + +async function takePostRequest(type) { + if($.outFlag) return + let domain = 'https://jinggengjcq-isv.isvjcloud.com'; + let body = ``; + let method = 'POST' + let admJson = '' + switch (type) { + case 'isvObfuscator': + url = `https://api.m.jd.com/client.action?functionId=isvObfuscator`; + body = `body=%7B%22url%22%3A%22https%3A//jinggengjcq-isv.isvjcloud.com/fronth5/%3Flng%3D0%26lat%3D0%26sid%3D49687cd64aca2ae93aa43748a04e8f6w%26un_area%3D16_1315_1316_53522%23/pages/unitedCardNew20211010-ka/unitedCardNew20211010-ka%3FactId%3D9150e1d16b9d40_10101%22%2C%22id%22%3A%22%22%7D&uuid=b9b4ce69d42dacb64084279d51cdee764d7781fa&client=apple&clientVersion=10.1.4&st=1634100732991&sv=111&sign=67e254ffbcb13be9e12a9782c9cdf398`; + break; + case 'activity_load': + url = `${domain}/dm/front/openCardNew/activity_load?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"jdToken": $.Token, "source": "01", "inviteNick":($.inviteNick || "")} + if($.joinVenderId) admJson = {...admJson, "shopId": `${$.joinVenderId}`} + body = taskPostUrl("/openCardNew/activity_load", admJson); + break; + case 'shopList': + url = `${domain}/dm/front/openCardNew/shopList?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {} + body = taskPostUrl("/openCardNew/shopList", admJson); + break; + case '绑定': + url = `${domain}/dm/front/openCardNew/complete/mission?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"missionType": "relationBind", "inviterNick":($.inviteNick || "")} + body = taskPostUrl("/openCardNew/complete/mission", admJson); + break; + case 'mission': + url = `${domain}/dm/front/openCardNew/complete/mission?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"missionType": $.missionType} + if($.joinVenderId) admJson = {...admJson, "shopId": $.joinVenderId} + body = taskPostUrl("/openCardNew/complete/mission", admJson); + break; + case '抽奖': + url = `${domain}/dm/front/openCardNew/draw/post?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"dataType": "draw", "usedGameNum": "2"} + body = taskPostUrl("/openCardNew/draw/post", admJson); + break; + case 'followShop': + url = `${domain}/dm/front/openCardNew/followShop?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"actId": $.actId, "missionType": "collectShop"} + body = taskPostUrl("/openCardNew/followShop", admJson); + break; + case 'addCart': + url = `${domain}/dm/front/openCardNew/addCart?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"actId": $.actId, "missionType": "addCart"} + body = taskPostUrl("/openCardNew/addCart", admJson); + break; + case 'myAward': + url = `${domain}/dm/front/openCardNew/myAwards?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"pageNo": 1,"pageSize":9999} + body = taskPostUrl("/openCardNew/myAwards", admJson); + break; + case 'missionInviteList': + url = `${domain}/dm/front/openCardNew/missionInviteList?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"inviteListRequest":{"actId":$.actId,"userId":10299171,"missionType":"shareAct","inviteType": 1,"buyerNick":($.MixNick || '')}} + body = taskPostUrl("/openCardNew/missionInviteList", admJson); + break; + default: + console.log(`错误${type}`); + } + let myRequest = getPostRequest(url, body, method); + return new Promise(async resolve => { + $.post(myRequest, (err, resp, data) => { + try { + if (err) { + if(resp && resp.statusCode && resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + console.log(`${$.toStr(err,err)}`) + console.log(`${type} API请求失败,请检查网路重试`) + } else { + dealReturn(type, data); + } + } catch (e) { + // console.log(data); + console.log(e, resp) + } finally { + resolve(); + } + }) + }) + } + +async function dealReturn(type, data) { + let res = '' + try { + if(type != 'accessLogWithAD' || type != 'drawContent'){ + if(data){ + res = JSON.parse(data); + } + } + } catch (e) { + console.log(`${type} 执行任务异常`); + console.log(data); + $.runFalag = false; + } + try { + let title = '' + switch (type) { + case 'isvObfuscator': + if(typeof res == 'object'){ + if(res.errcode == 0){ + if(typeof res.token != 'undefined') $.Token = res.token + }else if(res.message){ + console.log(`${type} ${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + break; + case 'accessLogWithAD': + case 'drawContent': + break; + case 'activity_load': + case 'mission': + case 'shopList': + case 'loadUniteOpenCard': + case 'setMixNick': + case 'uniteOpenCardOne': + case 'checkOpenCard': + case 'followShop': + case 'addCart': + case 'myAward': + case 'missionInviteList': + case '抽奖': + title = '' + if(type == "followShop") title = '关注' + if(type == "addCart") title = '加购' + if(typeof res == 'object'){ + if(res.success && res.success === true && res.data){ + if(res.data.status && res.data.status == 200){ + res = res.data + if(type != "setMixNick" && (res.msg || res.data.isOpenCard || res.data.remark)) console.log(`${title && title+":" || ""}${res.msg || res.data.isOpenCard || res.data.remark || ''}`) + if(type == "activity_load"){ + if(res.msg || res.data.isOpenCard) { + if((res.msg || res.data.isOpenCard || '').indexOf('绑定成功') > -1) $.toBind = 1 + } + if(res.data){ + $.endTime = res.data.cusActivity.endTime || 0 + $.MixNick = res.data.buyerNick || "" + $.usedChance = res.data.missionCustomer.usedChance || 0 + $.hasCollectShop = res.data.missionCustomer.hasCollectShop || 0 + } + }else if(type == "shopList"){ + $.openList = res.data.cusShops || [] + }else if(type == "mission"){ + if(res.data.remark.indexOf('不是会员') > -1){ + $.openCard = true + }else{ + $.openCard = false + } + }else if(type == "uniteOpenCardOne"){ + $.uniteOpenCar = res.msg || res.data.msg || '' + }else if(type == "myAward"){ + console.log(`我的奖品:`) + let num = 0 + let value = 0 + for(let i in res.data.list || []){ + let item = res.data.list[i] + value += Number(item.awardDes) + } + if(value > 0) console.log(`共获得${value}京豆\n无法判断奖励是否为邀请奖励,所以直接显示获得多少豆\n`) + }else if(type == "missionInviteList"){ + console.log(`邀请人数(${res.data.invitedLogList.total})`) + } + }else if(res.data.msg){ + if(res.errorMessage.indexOf('活动未开始') >-1 ){ + $.activityEnd = true + } + console.log(`${title || type} ${res.data.msg || ''}`) + }else if(res.errorMessage){ + if(res.errorMessage.indexOf('火爆') >-1 ){ + $.hotFlag = true + } + console.log(`${title || type} ${res.errorMessage || ''}`) + }else{ + console.log(`${title || type} ${data}`) + } + }else if(res.errorMessage){ + console.log(`${title || type} ${res.errorMessage || ''}`) + }else{ + console.log(`${title || type} ${data}`) + } + }else{ + console.log(`${title || type} ${data}`) + } + break; + default: + console.log(`${title || type}-> ${data}`); + } + if(typeof res == 'object'){ + if(res.errorMessage){ + if(res.errorMessage.indexOf('火爆') >-1 ){ + $.hotFlag = true + } + } + } + } catch (e) { + console.log(e) + } +} + +function getPostRequest(url, body, method="POST") { + let headers = { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Content-Type": "application/x-www-form-urlencoded", + "Cookie": cookie, + "User-Agent": $.UA, + "X-Requested-With": "XMLHttpRequest" + } + if(url.indexOf('https://jinggengjcq-isv.isvjcloud.com') > -1){ + headers["Origin"] = `https://jinggengjcq-isv.isvjcloud.com` + headers["Content-Type"] = `application/json; charset=utf-8` + delete headers["Cookie"] + } + // console.log(headers) + // console.log(headers.Cookie) + return {url: url, method: method, headers: headers, body: body, timeout:60000}; +} + + +function taskPostUrl(url, t) { + + const b = { + "jsonRpc": "2.0", + "params": { + "commonParameter": { + "appkey": $.appkey, + "m": "POST", + "timestamp": Date.now(), + "userId": $.userId + }, + "admJson": { + "actId": $.actId, + "userId": $.userId, + ...t, + "method": url, + "buyerNick": ($.MixNick || ''), + } + }, + } + if(url.indexOf('missionInviteList') > -1){ + delete b.params.admJson.actId + } + return $.toStr(b,b) +} +async function getUA(){ + $.UA = `jdapp;iPhone;10.1.4;13.1.2;${randomString(40)};network/wifi;model/iPhone8,1;addressid/2308460611;appBuild/167814;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_1_2 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 jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} + +function joinShop() { + if(!$.joinVenderId) return + return new Promise(async resolve => { + $.shopactivityId = '' + await $.wait(1000) + await getshopactivityId() + let activityId = `` + if($.shopactivityId) activityId = `,"activityId":${$.shopactivityId}` + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body={"venderId":"${$.joinVenderId}","shopId":"${$.joinVenderId}","bindByVerifyCodeFlag":1,"registerExtend":{},"writeChildFlag":0${activityId},"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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + // console.log(data) + let res = $.toObj(data); + if(typeof res == 'object'){ + if(res.success === true){ + console.log(res.message) + if(res.result && res.result.giftInfo){ + for(let i of res.result.giftInfo.giftList){ + console.log(`入会获得:${i.discountString}${i.prizeName}${i.secondLineDesc}`) + } + } + }else if(typeof res == 'object' && res.message){ + console.log(`${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function getshopactivityId() { + return new Promise(resolve => { + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body=%7B%22venderId%22%3A%22${$.joinVenderId}%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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + let res = $.toObj(data); + if(res.success == true){ + // console.log($.toStr(res.result)) + console.log(`入会:${res.result.shopMemberCardInfo.venderCardName || ''}`) + $.shopactivityId = res.result.interestsRuleList && res.result.interestsRuleList[0] && res.result.interestsRuleList[0].interestsInfo && res.result.interestsRuleList[0].interestsInfo.activityId || '' + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +// 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)} + diff --git a/activity/jd_opencardL45.js b/activity/jd_opencardL45.js new file mode 100644 index 0000000..d4cfdb4 --- /dev/null +++ b/activity/jd_opencardL45.js @@ -0,0 +1,821 @@ +/* +2022.1.14-1.21 超级年货节 惊喜不打烊 + + +第一个账号助力作者 其他依次助力CK1 +第一个CK失效会退出脚本 + +———————————————— +入口:https://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity/6869761?activityId=dzlhkkkbblnt20220114&shareUuid=5b15935c37ce41f6ac929f442407bcbd + +请求太频繁会被黑ip +过10分钟再执行 + + +cron:1 6,21 14-21 1 * +============Quantumultx=============== +[task_local] +#2022.1.14-1.21 超级年货节 惊喜不打烊 +1 6,21 14-21 1 * https://raw.githubusercontent.com/KingRan/JDJB/main/jd_opencardL45.js, tag=2022.1.14-1.21 超级年货节 惊喜不打烊, enabled=true + +*/ +const $ = new Env("2022.1.14-1.21 超级年货节 惊喜不打烊"); +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const notify = $.isNode() ? require('./sendNotify') : ''; +//IOS等用户直接用NobyDa的jd cookie + +let cookiesArr = [], + cookie = ''; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} +allMessage = "" +message = "" +$.hotFlag = false +$.outFlag = false +$.activityEnd = false +let lz_jdpin_token_cookie ='' +let activityCookie ='' +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', { + "open-url": "https://bean.m.jd.com/" + }); + return; + } + $.activityId = "dzlhkkkbblnt20220114" + $.shareUuid = "5b15935c37ce41f6ac929f442407bcbd" + console.log(`入口:\nhttps://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}`) + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i]; + if (cookie) { + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + message = "" + $.bean = 0 + $.hotFlag = false + $.nickName = ''; + console.log(`\n\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + await getUA() + await run(); + if(i == 0 && !$.actorUuid) break + if($.outFlag || $.activityEnd) break + } + } + if($.outFlag) { + let msg = '此ip已被限制,请过10分钟后再执行脚本' + $.msg($.name, ``, `${msg}`); + if ($.isNode()) await notify.sendNotify(`${$.name}`, `${msg}`); + } +})() + .catch((e) => $.logErr(e)) + .finally(() => $.done()) + + +async function run() { + try { + $.hasEnd = true + $.endTime = 0 + lz_jdpin_token_cookie = '' + $.Token = '' + $.Pin = '' + let flag = false + await takePostRequest('isvObfuscator'); + if($.Token == ''){ + console.log('获取[token]失败!') + return + } + await getCk() + if (activityCookie == '') { + console.log(`获取cookie失败`); return; + } + if($.activityEnd === true){ + console.log('活动结束') + return + } + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + await takePostRequest('getSimpleActInfoVo'); + await takePostRequest('getMyPing'); + if(!$.Pin){ + console.log('获取[Pin]失败!') + return + } + await takePostRequest('accessLogWithAD'); + await takePostRequest('getUserInfo'); + await takePostRequest('activityContent'); + if($.hotFlag) return + if(!$.actorUuid){ + console.log('获取不到[actorUuid]退出执行,请重新执行') + return + } + // console.log($.actorUuid) + // return + if($.hasEnd === true || Date.now() > $.endTime){ + $.activityEnd = true + console.log('活动结束') + return + } + await takePostRequest('drawContent'); + await $.wait(1000) + $.openList = [] + $.allOpenCard = false + await takePostRequest('info'); + await takePostRequest('checkOpenCard'); + if($.allOpenCard == false){ + console.log('开卡任务') + for(o of $.openList){ + $.openCard = false + if(o.status == 0){ + flag = true + $.joinVenderId = o.venderId + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + await joinShop() + await $.wait(parseInt(Math.random() * 1000 + 1000, 10)) + await takePostRequest('activityContent'); + await takePostRequest('drawContent'); + await takePostRequest('checkOpenCard'); + await $.wait(parseInt(Math.random() * 3000 + 2000, 10)) + } + } + }else{ + console.log('已全部开卡') + } + + $.log("关注: " + $.followShop) + if(!$.followShop && !$.outFlag){ + flag = true + await takePostRequest('followShop'); + await $.wait(parseInt(Math.random() * 2000 + 3000, 10)) + } + $.yaoqing = false + await takePostRequest('邀请'); + if($.yaoqing){ + await takePostRequest('助力'); + } + $.log("加购: " + $.addCart) + if(!$.addCart && !$.outFlag){ + flag = true + await takePostRequest('addCart'); + await $.wait(parseInt(Math.random() * 2000 + 4000, 10)) + } + $.runFalag = true + $.log("浏览商品: " + $.visitSku) + if(!$.visitSku && !$.outFlag){ + flag = true + for(let v of $.visitSkuList || []){ + if($.runFalag == false) break + if(v.goodsCode && v.status === 0){ + $.visitSkuValue = v.goodsCode + await takePostRequest('browseGoods'); + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + } + } + } + $.runFalag = true + let count = parseInt($.drawCount, 10) + console.log(`抽奖次数为:${count}`) + for(m=1;count--;m++){ + console.log(`第${m}次抽奖`) + await takePostRequest('startDraw'); + if($.runFalag == false) break + if(Number(count) <= 0) break + if(m >= 30){ + console.log("抽奖太多次,多余的次数请再执行脚本") + break + } + await $.wait(parseInt(Math.random() * 2000 + 2000, 10)) + } + if(flag){ + await takePostRequest('activityContent'); + } + console.log(`${$.score}值 游戏:${$.point}`) + $.runFalag = true + count = parseInt($.score/1000) + console.log(`抽奖次数为:${count}`) + for(m=1;count--;m++){ + console.log(`第${m}次抽奖`) + await takePostRequest('抽奖'); + if($.runFalag == false) break + if(Number(count) <= 0) break + if(m >= 10){ + console.log("抽奖太多次,多余的次数请再执行脚本") + break + } + await $.wait(parseInt(Math.random() * 2000 + 2000, 10)) + } + + await $.wait(parseInt(Math.random() * 1000 + 2000, 10)) + await takePostRequest('getDrawRecordHasCoupon'); + await takePostRequest('getShareRecord'); + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + console.log($.actorUuid) + console.log(`当前助力:${$.shareUuid}`) + if($.index == 1){ + $.shareUuid = $.actorUuid + console.log(`后面的号都会助力:${$.shareUuid}`) + } + await $.wait(parseInt(Math.random() * 1000 + 5000, 10)) + if(flag) await $.wait(parseInt(Math.random() * 1000 + 10000, 10)) + + if($.index % 3 == 0) console.log('休息1分钟,别被黑ip了\n可持续发展') + if($.index % 3 == 0) await $.wait(parseInt(Math.random() * 5000 + 60000, 10)) + + } catch (e) { + console.log(e) + } +} + +async function takePostRequest(type) { + if($.outFlag) return + let domain = 'https://lzdz1-isv.isvjcloud.com'; + let body = ``; + let method = 'POST' + let admJson = '' + switch (type) { + case 'isvObfuscator': + url = `https://api.m.jd.com/client.action?functionId=isvObfuscator`; + body = `body=%7B%22url%22%3A%22https%3A//lzdz1-isv.isvjcloud.com%22%2C%22id%22%3A%22%22%7D&uuid=7088d9018515b8cb0c88ace6e5479762af3e88f3&client=apple&clientVersion=10.1.4&st=1634343624086&sv=120&sign=8b9cea22c3a0d77026abda5d37d2b7e3`; + break; + case 'getSimpleActInfoVo': + url = `${domain}/dz/common/getSimpleActInfoVo`; + body = `activityId=${$.activityId}`; + break; + case 'getMyPing': + url = `${domain}/customer/getMyPing`; + body = `userId=${$.shopId || $.venderId || ''}&token=${$.Token}&fromType=APP`; + break; + case 'accessLogWithAD': + url = `${domain}/common/accessLogWithAD`; + let pageurl = `${domain}/drawCenter/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}` + body = `venderId=${$.shopId || $.venderId || ''}&code=99&pin=${encodeURIComponent($.Pin)}&activityId=${$.activityId}&pageUrl=${encodeURIComponent(pageurl)}&subType=app&adSource=` + break; + case 'getUserInfo': + url = `${domain}/wxActionCommon/getUserInfo`; + body = `pin=${encodeURIComponent($.Pin)}`; + break; + case 'activityContent': + url = `${domain}/dingzhi/linkgame/activity/content`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&pinImg=${encodeURIComponent($.attrTouXiang)}&nick=${encodeURIComponent($.nickname)}&cjyxPin=&cjhyPin=&shareUuid=${$.shareUuid}` + break; + case 'drawContent': + url = `${domain}/dingzhi/taskact/common/drawContent`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case 'checkOpenCard': + url = `${domain}/dingzhi/linkgame/checkOpenCard`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case 'info': + url = `${domain}/dingzhi/linkgame/task/info`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case 'startDraw': + url = `${domain}/dingzhi/linkgame/draw/bean`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case 'followShop': + url = `${domain}/dingzhi/linkgame/follow/shop`; + // url = `${domain}/dingzhi/dz/openCard/saveTask`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case 'sign': + case 'addCart': + case 'browseGoods': + url = `${domain}/dingzhi/linkgame/${type}`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + if(type == 'browseGoods') body += `&value=${$.visitSkuValue}` + break; + case '邀请': + case '助力': + if(type == '助力'){ + url = `${domain}/dingzhi/linkgame/assist`; + }else{ + url = `${domain}/dingzhi/linkgame/assist/status`; + } + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&shareUuid=${$.shareUuid}` + break; + case 'viewVideo': + case 'visitSku': + case 'toShop': + case 'addSku': + url = `${domain}/dingzhi/dz/openCard/saveTask`; + let taskType = '' + let taskValue = '' + if(type == 'viewVideo'){ + taskType = 31 + taskValue = 31 + }else if(type == 'visitSku'){ + taskType = 5 + taskValue = $.visitSkuValue || 5 + }else if(type == 'toShop'){ + taskType = 14 + taskValue = $.toShopValue || 14 + }else if(type == 'addSku'){ + taskType = 2 + taskValue = $.addSkuValue || 2 + } + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&taskType=${taskType}&taskValue=${taskValue}` + break; + case 'getDrawRecordHasCoupon': + url = `${domain}/dingzhi/linkgame/draw/record`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case 'getShareRecord': + url = `${domain}/dingzhi/linkgame/help/list`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case '抽奖': + url = `${domain}/dingzhi/linkgame/draw`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + default: + console.log(`错误${type}`); + } + let myRequest = getPostRequest(url, body, method); + // console.log(myRequest) + return new Promise(async resolve => { + $.post(myRequest, (err, resp, data) => { + try { + setActivityCookie(resp) + if (err) { + if(resp && typeof resp.statusCode != 'undefined'){ + if(resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + } + console.log(`${$.toStr(err,err)}`) + console.log(`${type} API请求失败,请检查网路重试`) + } else { + dealReturn(type, data); + } + } catch (e) { + // console.log(data); + console.log(e, resp) + } finally { + resolve(); + } + }) + }) + } + +async function dealReturn(type, data) { + let res = '' + try { + if(type != 'accessLogWithAD' || type != 'drawContent'){ + if(data){ + res = JSON.parse(data); + } + } + } catch (e) { + console.log(`${type} 执行任务异常`); + console.log(data); + $.runFalag = false; + } + try { + switch (type) { + case 'isvObfuscator': + if(typeof res == 'object'){ + if(res.errcode == 0){ + if(typeof res.token != 'undefined') $.Token = res.token + }else if(res.message){ + console.log(`isvObfuscator ${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + break; + case 'getSimpleActInfoVo': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(typeof res.data.shopId != 'undefined') $.shopId = res.data.shopId + if(typeof res.data.venderId != 'undefined') $.venderId = res.data.venderId + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getMyPing': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(res.data && typeof res.data.secretPin != 'undefined') $.Pin = res.data.secretPin + if(res.data && typeof res.data.nickname != 'undefined') $.nickname = res.data.nickname + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getUserInfo': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(res.data && typeof res.data.yunMidImageUrl != 'undefined') $.attrTouXiang = res.data.yunMidImageUrl || "https://img10.360buyimg.com/imgzone/jfs/t1/7020/27/13511/6142/5c5138d8E4df2e764/5a1216a3a5043c5d.png" + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'activityContent': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + $.endTime = res.data.endTime || res.data.activity.endTime || 0 + $.hasEnd = res.data.isEnd || false + $.drawCount = res.data.actor.drawCount || 0 + $.point = res.data.actor.point || 0 + $.score = res.data.actor.score || 0 + $.actorUuid = res.data.actor.actorUuid || '' + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'info': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + // $.drawCount = res.data.drawCount || 0 + $.addCart = res.data.addCart || false + $.followShop = res.data.followShop || false + $.sign = res.data.sign || false + $.visitSku = res.data.visitSku || false + $.visitSkuList = res.data.visitSkuList || [] + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'checkOpenCard': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + let cardList1 = res.data.cardList1 || [] + let cardList2 = res.data.cardList2 || [] + let cardList = res.data.cardList || [] + let openCardList = res.data.openCardList || [] + $.openList = [...cardList,...cardList1,...cardList2,...openCardList] + $.allOpenCard = res.data.allOpenCard || false + $.openCardScore1 = res.data.score1 || 0 + $.openCardScore2 = res.data.score2 || 0 + $.drawScore = res.data.drawScore || 0 + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'startDraw': + case 'followShop': + case 'viewVideo': + case 'visitSku': + case 'toShop': + case 'addSku': + case 'sign': + case 'addCart': + case 'browseGoods': + case '抽奖': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(typeof res.data == 'object'){ + let msg = '' + let title = '抽奖' + if(res.data.addBeanNum){ + msg = `${res.data.addBeanNum}京豆` + } + if(res.data.addPoint){ + msg += ` ${res.data.addPoint}游戏机会` + } + if(type == 'followShop'){ + title = '关注' + if(res.data.beanNumMember && res.data.assistSendStatus){ + msg += ` 额外获得:${res.data.beanNumMember}京豆` + } + }else if(type == 'addSku' || type == 'addCart'){ + title = '加购' + }else if(type == 'viewVideo'){ + title = '热门文章' + }else if(type == 'toShop'){ + title = '浏览店铺' + }else if(type == 'visitSku' || type == 'browseGoods'){ + title = '浏览商品' + }else if(type == 'sign'){ + title = '签到' + }else{ + msg = res.data.drawOk == true && (res.data.drawInfoType == 6 && res.data.name || '') || '空气💨' + } + if(!msg){ + msg = '空气💨' + } + console.log(`${title}获得:${msg || data}`) + }else{ + console.log(`${type} ${data}`) + } + }else if(res.errorMessage){ + $.runFalag = false; + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getDrawRecordHasCoupon': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + console.log(`我的奖品:`) + let num = 0 + let value = 0 + for(let i in res.data.recordList){ + let item = res.data.recordList[i] + if(item.infoName == '20京豆'){ + num++ + value = item.infoName.replace('京豆','') + }else{ + console.log(`${item.infoType != 10 && item.value && item.value +':' || ''}${item.infoName}`) + } + } + if(num > 0) console.log(`邀请好友(${num}):${num*parseInt(value, 10) || 30}京豆`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getShareRecord': + if(typeof res == 'object'){ + if(res.result && res.result === true && res.data){ + $.ShareCount = res.data.shareList.length + $.log(`=========== 你邀请了:${res.data.shareList.length}个`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case '邀请': + case '助力': + // console.log(data) + if(typeof res == 'object'){ + if(res.data.status == 200){ + if(type == '助力'){ + console.log('助力成功') + }else{ + $.yaoqing = true + } + }else if(res.data.status == 105){ + console.log('已经助力过') + }else if(res.data.status == 104){ + console.log('已经助力其他人') + }else if(res.data.status == 101){ + // console.log('已经助力过') + }else{ + console.log(data) + } + }else{ + console.log(`${type} ${data}`) + } + + case 'accessLogWithAD': + case 'drawContent': + break; + default: + console.log(`${type}-> ${data}`); + } + if(typeof res == 'object'){ + if(res.errorMessage){ + if(res.errorMessage.indexOf('火爆') >-1 ){ + $.hotFlag = true + } + } + } + } catch (e) { + console.log(e) + } +} + +function getPostRequest(url, body, method="POST") { + let headers = { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Content-Type": "application/x-www-form-urlencoded", + "Cookie": cookie, + "User-Agent": $.UA, + "X-Requested-With": "XMLHttpRequest" + } + if(url.indexOf('https://lzdz1-isv.isvjcloud.com') > -1){ + headers["Referer"] = `https://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}` + headers["Cookie"] = `${lz_jdpin_token_cookie && lz_jdpin_token_cookie || ''}${$.Pin && "AUTH_C_USER=" + $.Pin + ";" || ""}${activityCookie}` + } + // console.log(headers) + // console.log(headers.Cookie) + return {url: url, method: method, headers: headers, body: body, timeout:30000}; +} + +function getCk() { + return new Promise(resolve => { + let get = { + url:`https://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}`, + followRedirect:false, + headers: { + "User-Agent": $.UA, + }, + timeout:30000 + } + $.get(get, async(err, resp, data) => { + try { + if (err) { + if(resp && typeof resp.statusCode != 'undefined'){ + if(resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + } + console.log(`${$.toStr(err)}`) + console.log(`${$.name} cookie API请求失败,请检查网路重试`) + } else { + let end = data.match(/(活动已经结束)/) && data.match(/(活动已经结束)/)[1] || '' + if(end){ + $.activityEnd = true + console.log('活动已结束') + } + setActivityCookie(resp) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function setActivityCookie(resp){ + let LZ_TOKEN_KEY = '' + let LZ_TOKEN_VALUE = '' + let lz_jdpin_token = '' + let setcookies = resp && resp['headers'] && (resp['headers']['set-cookie'] || resp['headers']['Set-Cookie'] || '') || '' + let setcookie = '' + if(setcookies){ + if(typeof setcookies != 'object'){ + setcookie = setcookies.split(',') + }else setcookie = setcookies + for (let ck of setcookie) { + let name = ck.split(";")[0].trim() + if(name.split("=")[1]){ + // console.log(name.replace(/ /g,'')) + if(name.indexOf('LZ_TOKEN_KEY=')>-1) LZ_TOKEN_KEY = name.replace(/ /g,'')+';' + if(name.indexOf('LZ_TOKEN_VALUE=')>-1) LZ_TOKEN_VALUE = name.replace(/ /g,'')+';' + if(name.indexOf('lz_jdpin_token=')>-1) lz_jdpin_token = ''+name.replace(/ /g,'')+';' + } + } + } + if(LZ_TOKEN_KEY && LZ_TOKEN_VALUE) activityCookie = `${LZ_TOKEN_KEY} ${LZ_TOKEN_VALUE}` + if(lz_jdpin_token) lz_jdpin_token_cookie = lz_jdpin_token +} + +async function getUA(){ + $.UA = `jdapp;iPhone;10.1.4;13.1.2;${randomString(40)};network/wifi;model/iPhone8,1;addressid/2308460611;appBuild/167814;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_1_2 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 joinShop() { + if(!$.joinVenderId) return + return new Promise(async resolve => { + $.shopactivityId = '' + await $.wait(1000) + await getshopactivityId() + let activityId = `` + if($.shopactivityId) activityId = `,"activityId":${$.shopactivityId}` + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body={"venderId":"${$.joinVenderId}","shopId":"${$.joinVenderId}","bindByVerifyCodeFlag":1,"registerExtend":{},"writeChildFlag":0${activityId},"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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + // console.log(data) + let res = $.toObj(data); + if(typeof res == 'object'){ + if(res.success === true){ + console.log(res.message) + if(res.result && res.result.giftInfo){ + for(let i of res.result.giftInfo.giftList){ + console.log(`入会获得:${i.discountString}${i.prizeName}${i.secondLineDesc}`) + } + } + }else if(typeof res == 'object' && res.message){ + console.log(`${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function getshopactivityId() { + return new Promise(resolve => { + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body=%7B%22venderId%22%3A%22${$.joinVenderId}%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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + let res = $.toObj(data); + if(res.success == true){ + // console.log($.toStr(res.result)) + console.log(`入会:${res.result.shopMemberCardInfo.venderCardName || ''}`) + $.shopactivityId = res.result.interestsRuleList && res.result.interestsRuleList[0] && res.result.interestsRuleList[0].interestsInfo && res.result.interestsRuleList[0].interestsInfo.activityId || '' + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} + + +// 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)} diff --git a/activity/jd_opencardL46.js b/activity/jd_opencardL46.js new file mode 100644 index 0000000..3841776 --- /dev/null +++ b/activity/jd_opencardL46.js @@ -0,0 +1,799 @@ +/* +1.14~1.20 大牌会员日 +新增开卡脚本,一次性脚本 + + +第一个账号助力作者 其他依次助力CK1 +第一个CK失效会退出脚本 + +———————————————— +入口:[ 1.14~1.20 大牌会员日 (https://lzdz1-isv.isvjcloud.com/dingzhi/bigname/memberday/activity?activityId=dz2112100022468201&shareUuid=59d9ae0352fd487ba2efbc8dbf740358)] + +请求太频繁会被黑ip +过10分钟再执行 + +cron:30 5,20 14-20 1 * +============Quantumultx=============== +[task_local] +#1.14~1.20 大牌会员日 +30 5,20 14-20 1 * jd_opencardL46.js, tag=1.14~1.20 大牌会员日, enabled=true + +*/ + +const $ = new Env('1.14~1.20 大牌会员日'); +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const notify = $.isNode() ? require('./sendNotify') : ''; +//IOS等用户直接用NobyDa的jd cookie + +let cookiesArr = [], + cookie = ''; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} + +allMessage = "" +message = "" +$.hotFlag = false +$.outFlag = false +$.activityEnd = false +let lz_jdpin_token_cookie ='' +let activityCookie ='' +!(async () => { + + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', { + "open-url": "https://bean.m.jd.com/" + }); + return; + } + $.activityId = "dz2201100008884901" + $.shareUuid = "59d9ae0352fd487ba2efbc8dbf740358" + console.log(`入口:\nhttps://lzdz1-isv.isvjcloud.com/dingzhi/bigname/memberday/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}`) + + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i]; + if (cookie) { + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + message = "" + $.bean = 0 + $.hotFlag = false + $.nickName = ''; + console.log(`\n\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + await getUA() + await run(); + if(i == 0 && !$.actorUuid) break + if($.outFlag || $.activityEnd) break + } + } + if($.outFlag) { + let msg = '此ip已被限制,请过10分钟后再执行脚本' + $.msg($.name, ``, `${msg}`); + if ($.isNode()) await notify.sendNotify(`${$.name}`, `${msg}`); + } +})() + .catch((e) => $.logErr(e)) + .finally(() => $.done()) + + +async function run() { + try { + $.hasEnd = true + $.endTime = 0 + lz_jdpin_token_cookie = '' + $.Token = '' + $.Pin = '' + let flag = false + await takePostRequest('isvObfuscator'); + if($.Token == ''){ + console.log('获取[token]失败!') + return + } + await getCk() + if (activityCookie == '') { + console.log(`获取cookie失败`); return; + } + if($.activityEnd === true){ + console.log('活动结束') + return + } + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + await takePostRequest('getSimpleActInfoVo'); + await takePostRequest('getMyPing'); + if(!$.Pin){ + console.log('获取[Pin]失败!') + return + } + await takePostRequest('accessLogWithAD'); + await takePostRequest('getUserInfo'); + await takePostRequest('activityContent'); + if($.hotFlag) return + if(!$.actorUuid){ + console.log('获取不到[actorUuid]退出执行,请重新执行') + return + } + if($.hasEnd === true || Date.now() > $.endTime){ + $.activityEnd = true + console.log('活动结束') + return + } + await takePostRequest('drawContent'); + await $.wait(1000) + $.openList = [] + $.allOpenCard = false + await takePostRequest('checkOpenCard'); + $.log("报名: " + $.signStatus) + if(!$.signStatus && !$.outFlag){ + await takePostRequest('报名'); + await $.wait(parseInt(Math.random() * 2000 + 1000, 10)) + } + // console.log($.actorUuid) + // return + if($.allOpenCard == false){ + console.log('开卡任务') + for(o of $.openList){ + $.openCard = false + if(o.openStatus == false){ + flag = true + $.joinVenderId = o.venderId + await joinShop() + await $.wait(parseInt(Math.random() * 2000 + 2000, 10)) + await takePostRequest('activityContent'); + await takePostRequest('drawContent'); + await takePostRequest('checkOpenCard'); + await $.wait(parseInt(Math.random() * 3000 + 2000, 10)) + } + } + }else{ + console.log('已全部开卡') + } + + console.log(`${$.score}值`) + $.runFalag = true + let count = parseInt($.score/100) + console.log(`抽奖次数为:${count}`) + for(m=1;count--;m++){ + console.log(`第${m}次抽奖`) + await takePostRequest('抽奖'); + if($.runFalag == false) break + if(Number(count) <= 0) break + if(m >= 10){ + console.log("抽奖太多次,多余的次数请再执行脚本") + break + } + await $.wait(parseInt(Math.random() * 2000 + 2000, 10)) + } + + await $.wait(parseInt(Math.random() * 1000 + 2000, 10)) + await takePostRequest('getDrawRecordHasCoupon'); + await takePostRequest('getShareRecord'); + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + console.log($.actorUuid) + console.log(`当前助力:${$.shareUuid}`) + if($.index == 1){ + $.shareUuid = $.actorUuid + console.log(`后面的号都会助力:${$.shareUuid}`) + } + await $.wait(parseInt(Math.random() * 1000 + 5000, 10)) + if(flag) await $.wait(parseInt(Math.random() * 1000 + 10000, 10)) + if($.index % 3 == 0) console.log('休息1分钟,别被黑ip了\n可持续发展') + if($.index % 3 == 0) await $.wait(parseInt(Math.random() * 5000 + 60000, 10)) + } catch (e) { + console.log(e) + } +} + +async function takePostRequest(type) { + if($.outFlag) return + let domain = 'https://lzdz1-isv.isvjcloud.com'; + let body = ``; + let method = 'POST' + let admJson = '' + switch (type) { + case 'isvObfuscator': + url = `https://api.m.jd.com/client.action?functionId=isvObfuscator`; + body = `body=%7B%22url%22%3A%22https%3A//lzdz1-isv.isvjcloud.com%22%2C%22id%22%3A%22%22%7D&uuid=7088d9018515b8cb0c88ace6e5479762af3e88f3&client=apple&clientVersion=10.1.4&st=1634343624086&sv=120&sign=8b9cea22c3a0d77026abda5d37d2b7e3`; + break; + case 'getSimpleActInfoVo': + url = `${domain}/dz/common/getSimpleActInfoVo`; + body = `activityId=${$.activityId}`; + break; + case 'getMyPing': + url = `${domain}/customer/getMyPing`; + body = `userId=${$.shopId || $.venderId || ''}&token=${$.Token}&fromType=APP`; + break; + case 'accessLogWithAD': + url = `${domain}/common/accessLogWithAD`; + let pageurl = `${domain}/drawCenter/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}` + body = `venderId=${$.shopId || $.venderId || ''}&code=99&pin=${encodeURIComponent($.Pin)}&activityId=${$.activityId}&pageUrl=${encodeURIComponent(pageurl)}&subType=app&adSource=` + break; + case 'getUserInfo': + url = `${domain}/wxActionCommon/getUserInfo`; + body = `pin=${encodeURIComponent($.Pin)}`; + break; + case 'activityContent': + url = `${domain}/dingzhi/bigname/memberday/activityContent`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&pinImg=${encodeURIComponent($.attrTouXiang)}&nick=${encodeURIComponent($.nickname)}&cjyxPin=&cjhyPin=&shareUuid=${$.shareUuid}` + break; + case 'drawContent': + url = `${domain}/dingzhi/taskact/common/drawContent`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case 'checkOpenCard': + url = `${domain}/dingzhi/bigname/memberday/initOpenCard`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&shareUuid=${$.shareUuid}` + break; + case '报名': + url = `${domain}/dingzhi/bigname/memberday/saveTask`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&taskType=0&taskValue=` + break; + case 'info': + url = `${domain}/dingzhi/linkgame/task/opencard/info`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case 'startDraw': + url = `${domain}/joint/order/draw`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&drawType=1` + break; + case 'followShop': + url = `${domain}/dingzhi/opencard/follow/shop`; + // url = `${domain}/dingzhi/dz/openCard/saveTask`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case 'sign': + case 'addCart': + case 'browseGoods': + url = `${domain}/dingzhi/linkgame/${type}`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + if(type == 'browseGoods') body += `&value=${$.visitSkuValue}` + break; + case '邀请': + case '助力': + if(type == '助力'){ + url = `${domain}/dingzhi/linkgame/assist`; + }else{ + url = `${domain}/dingzhi/linkgame/assist/status`; + } + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&shareUuid=${$.shareUuid}` + break; + case 'viewVideo': + case 'visitSku': + case 'toShop': + case 'addSku': + url = `${domain}/dingzhi/opencard/${type}`; + let taskType = '' + let taskValue = '' + if(type == 'viewVideo'){ + taskType = 31 + taskValue = 31 + }else if(type == 'visitSku'){ + taskType = 5 + taskValue = $.visitSkuValue || 5 + }else if(type == 'toShop'){ + taskType = 14 + taskValue = $.toShopValue || 14 + }else if(type == 'addSku'){ + taskType = 2 + taskValue = $.addSkuValue || 2 + }else if(type == 'toMainActive'){ + taskType = 12 + taskValue = 3 + } + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&taskType=${taskType}&taskValue=${taskValue}&shareUuid=${$.shareUuid}` + break; + case 'getDrawRecordHasCoupon': + url = `${domain}/dingzhi/taskact/common/getDrawRecordHasCoupon`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case 'getShareRecord': + url = `${domain}/dingzhi/taskact/common/getShareRecord`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case 'getRule': + url = `${domain}/dingzhi/bigname/memberday/getRule`; + body = `activityId=${$.activityId}` + break; + case '抽奖': + url = `${domain}/dingzhi/opencard/draw`; + body = `activityId=${$.activityId}&actorUuid=${$.actorUuid}&pin=${encodeURIComponent($.Pin)}` + break; + default: + console.log(`错误${type}`); + } + let myRequest = getPostRequest(url, body, method); + return new Promise(async resolve => { + $.post(myRequest, (err, resp, data) => { + try { + setActivityCookie(resp) + if (err) { + if(resp && typeof resp.statusCode != 'undefined'){ + if(resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + } + console.log(`${$.toStr(err,err)}`) + console.log(`${type} API请求失败,请检查网路重试`) + } else { + dealReturn(type, data); + } + } catch (e) { + console.log(e, resp) + } finally { + resolve(); + } + }) + }) + } + +async function dealReturn(type, data) { + let res = '' + try { + if(type != 'accessLogWithAD' || type != 'drawContent'){ + if(data){ + res = JSON.parse(data); + } + } + } catch (e) { + console.log(`${type} 执行任务异常`); + console.log(data); + $.runFalag = false; + } + try { + switch (type) { + case 'isvObfuscator': + if(typeof res == 'object'){ + if(res.errcode == 0){ + if(typeof res.token != 'undefined') $.Token = res.token + }else if(res.message){ + console.log(`isvObfuscator ${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + break; + case 'getSimpleActInfoVo': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(typeof res.data.shopId != 'undefined') $.shopId = res.data.shopId + if(typeof res.data.venderId != 'undefined') $.venderId = res.data.venderId + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getMyPing': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(res.data && typeof res.data.secretPin != 'undefined') $.Pin = res.data.secretPin + if(res.data && typeof res.data.nickname != 'undefined') $.nickname = res.data.nickname + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getUserInfo': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(res.data && typeof res.data.yunMidImageUrl != 'undefined') $.attrTouXiang = res.data.yunMidImageUrl || "https://img10.360buyimg.com/imgzone/jfs/t1/7020/27/13511/6142/5c5138d8E4df2e764/5a1216a3a5043c5d.png" + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'activityContent': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + $.endTime = res.data.endTime || (res.data.activityVo && res.data.activityVo.endTime) || res.data.activity.endTime || 0 + $.hasEnd = res.data.hasEnd || false + $.score = res.data.assistCount || 0 + $.actorUuid = res.data.actorUuid || '' + $.followShop = res.data.followShopStatus || '' + $.signStatus = res.data.signStatus || false + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'info': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + $.addCart = res.data.addCart || false + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'checkOpenCard': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + let cardList1 = res.data.cardList1 || [] + let cardList2 = res.data.cardList2 || [] + let cardList = res.data.cardList || [] + let openCardList = res.data.openCardList || [] + let openInfo = res.data.openInfo || [] + $.openList = [...cardList,...cardList1,...cardList2,...openCardList,...openInfo] + $.allOpenCard = res.data.allOpenCard || res.data.isOpenCardStatus || false + $.openCardScore1 = res.data.score1 || 0 + $.openCardScore2 = res.data.score2 || 0 + $.drawScore = res.data.drawScore || 0 + if(res.data.beans || res.data.addBeanNum) console.log(`开卡获得:${res.data.beans || res.data.addBeanNum}豆`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'startDraw': + case 'followShop': + case 'viewVideo': + case 'visitSku': + case 'toShop': + case 'addSku': + case 'sign': + case 'addCart': + case 'browseGoods': + case 'toMainActive': + case '抽奖': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(typeof res.data == 'object'){ + let msg = '' + let title = '抽奖' + if(res.data.addBeanNum || res.data.taskbeanNum){ + msg = `${res.data.addBeanNum || res.data.taskbeanNum}京豆` + } + if(res.data.addPoint){ + msg += ` ${res.data.addPoint}游戏机会` + } + if(type == 'followShop'){ + title = '关注' + if(res.data.beanNumMember && res.data.assistSendStatus){ + msg += ` 额外获得:${res.data.beanNumMember}京豆` + } + }else if(type == 'addSku' || type == 'addCart'){ + title = '加购' + }else if(type == 'viewVideo'){ + title = '热门文章' + }else if(type == 'toShop'){ + title = '浏览店铺' + }else if(type == 'visitSku' || type == 'browseGoods'){ + title = '浏览商品' + }else if(type == 'sign'){ + title = '签到' + }else if(type == 'toMainActive'){ + title = '逛会场' + }else{ + msg = res.data.drawOk == true && (res.data.drawInfoType == 6 && res.data.name || '') || res.data.wdsrvo.drawOk == true && (res.data.wdsrvo.drawInfoType == 6 && res.data.wdsrvo.name || '') || '空气💨' + } + if(!msg){ + msg = '空气💨' + } + console.log(`${title}获得:${msg || data}`) + }else{ + console.log(`${type} ${data}`) + } + }else if(res.errorMessage){ + $.runFalag = false; + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getDrawRecordHasCoupon': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + console.log(`我的奖品:`) + let num = 0 + let value = 0 + let typeArr = { + "dayShareBeans":"邀请", + "dayBeSharedBeans":"被邀请", + "openCardBeans":"开卡", + "saveTaskBeans23":"关注", + "saveTaskBeans12":"逛会场", + } + for(let i in res.data){ + let item = res.data[i] + if(item.drawId == 'dayShareBeans'){ + num++ + value = item.infoName.replace('京豆','') + }else{ + console.log(`${item.infoType != 10 && item.drawId && (typeArr[item.drawId] || item.drawId)+':' || item.value && item.value +':' || ''}${item.infoName}`) + } + } + if(num > 0) console.log(`邀请好友(${num}):${num*parseInt(value, 10) || 30}京豆`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getShareRecord': + if(typeof res == 'object'){ + if(res.result && res.result === true && res.data){ + $.ShareCount = res.data.length + $.log(`=========== 你邀请了:${$.ShareCount}个`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case '邀请': + case '助力': + if(typeof res == 'object'){ + if(res.data.status == 200){ + if(type == '助力'){ + console.log('助力成功') + }else{ + $.yaoqing = true + } + }else if(res.data.status == 105){ + console.log('已经助力过') + }else if(res.data.status == 104){ + console.log('已经助力其他人') + }else if(res.data.status == 101){ + // console.log('已经助力过') + }else{ + console.log(data) + } + }else{ + console.log(`${type} ${data}`) + } + + case 'accessLogWithAD': + case 'drawContent': + break; + default: + console.log(`${type}-> ${data}`); + } + if(typeof res == 'object'){ + if(res.errorMessage){ + if(res.errorMessage.indexOf('火爆') >-1 ){ + $.hotFlag = true + } + } + } + } catch (e) { + console.log(e) + } +} + +function getPostRequest(url, body, method="POST") { + let headers = { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Content-Type": "application/x-www-form-urlencoded", + "Cookie": cookie, + "User-Agent": $.UA, + "X-Requested-With": "XMLHttpRequest" + } + if(url.indexOf('https://lzdz1-isv.isvjcloud.com') > -1){ + headers["Referer"] = `https://lzdz1-isv.isvjcloud.com/dingzhi/bigname/memberday/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}` + headers["Cookie"] = `${lz_jdpin_token_cookie && lz_jdpin_token_cookie || ''}${$.Pin && "AUTH_C_USER=" + $.Pin + ";" || ""}${activityCookie}` + } + // console.log(headers) + // console.log(headers.Cookie) + return {url: url, method: method, headers: headers, body: body, timeout:30000}; +} + +function getCk() { + return new Promise(resolve => { + let get = { + url:`https://lzdz1-isv.isvjcloud.com/dingzhi/bigname/memberday/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}`, + followRedirect:false, + headers: { + "User-Agent": $.UA, + }, + timeout:30000 + } + $.get(get, async(err, resp, data) => { + try { + if (err) { + if(resp && typeof resp.statusCode != 'undefined'){ + if(resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + } + console.log(`${$.toStr(err)}`) + console.log(`${$.name} cookie API请求失败,请检查网路重试`) + } else { + let end = data.match(/(活动已经结束)/) && data.match(/(活动已经结束)/)[1] || '' + if(end){ + $.activityEnd = true + console.log('活动已结束') + } + setActivityCookie(resp) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function setActivityCookie(resp){ + let LZ_TOKEN_KEY = '' + let LZ_TOKEN_VALUE = '' + let lz_jdpin_token = '' + let setcookies = resp && resp['headers'] && (resp['headers']['set-cookie'] || resp['headers']['Set-Cookie'] || '') || '' + let setcookie = '' + if(setcookies){ + if(typeof setcookies != 'object'){ + setcookie = setcookies.split(',') + }else setcookie = setcookies + for (let ck of setcookie) { + let name = ck.split(";")[0].trim() + if(name.split("=")[1]){ + // console.log(name.replace(/ /g,'')) + if(name.indexOf('LZ_TOKEN_KEY=')>-1) LZ_TOKEN_KEY = name.replace(/ /g,'')+';' + if(name.indexOf('LZ_TOKEN_VALUE=')>-1) LZ_TOKEN_VALUE = name.replace(/ /g,'')+';' + if(name.indexOf('lz_jdpin_token=')>-1) lz_jdpin_token = ''+name.replace(/ /g,'')+';' + } + } + } + if(LZ_TOKEN_KEY && LZ_TOKEN_VALUE) activityCookie = `${LZ_TOKEN_KEY} ${LZ_TOKEN_VALUE}` + if(lz_jdpin_token) lz_jdpin_token_cookie = lz_jdpin_token +} + +async function getUA(){ + $.UA = `jdapp;iPhone;10.1.4;13.1.2;${randomString(40)};network/wifi;model/iPhone8,1;addressid/2308460611;appBuild/167814;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_1_2 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 joinShop() { + if(!$.joinVenderId) return + return new Promise(async resolve => { + $.shopactivityId = '' + await $.wait(1000) + await getshopactivityId() + let activityId = `` + if($.shopactivityId) activityId = `,"activityId":${$.shopactivityId}` + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body={"venderId":"${$.joinVenderId}","shopId":"${$.joinVenderId}","bindByVerifyCodeFlag":1,"registerExtend":{},"writeChildFlag":0${activityId},"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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + // console.log(data) + let res = $.toObj(data,data); + if(typeof res == 'object'){ + if(res.success === true){ + console.log(res.message) + if(res.result && res.result.giftInfo){ + for(let i of res.result.giftInfo.giftList){ + console.log(`入会获得:${i.discountString}${i.prizeName}${i.secondLineDesc}`) + } + } + }else if(typeof res == 'object' && res.message){ + console.log(`${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function getshopactivityId() { + return new Promise(resolve => { + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body=%7B%22venderId%22%3A%22${$.joinVenderId}%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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + let res = $.toObj(data,data); + if(typeof res == 'object'){ + if(res.success == true){ + // console.log($.toStr(res.result)) + console.log(`入会:${res.result.shopMemberCardInfo.venderCardName || ''}`) + $.shopactivityId = res.result.interestsRuleList && res.result.interestsRuleList[0] && res.result.interestsRuleList[0].interestsInfo && res.result.interestsRuleList[0].interestsInfo.activityId || '' + } + }else{ + console.log(data) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} + + +// 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)} + diff --git a/activity/jd_opencardL47.js b/activity/jd_opencardL47.js new file mode 100644 index 0000000..4a0f213 --- /dev/null +++ b/activity/jd_opencardL47.js @@ -0,0 +1,543 @@ +/* +1.15~1.25 联合开卡 +新增开卡脚本,一次性脚本 + +第一个账号助力作者 其他依次助力CK1 +第一个CK失效会退出脚本 + +———————————————— +入口:[ 1.15~1.25 联合开卡 (https://jinggengjcq-isv.isvjcloud.com/fronth5/#/pages/unitedCardNew20220115/unitedCardNew20220115?actId=d32a6b5678c64ac2b_22011501)] + +请求太频繁会被黑ip +过10分钟再执行 + + +cron:6 6,16 15-25/2 1 * +============Quantumultx=============== +[task_local] +#1.15~1.25 联合开卡 +6 6,16 15-25/2 1 * jd_opencardL47.js, tag=1.15~1.25 联合开卡, enabled=true + +*/ + +const $ = new Env('1.15~1.25 联合开卡'); +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const notify = $.isNode() ? require('./sendNotify') : ''; + +//IOS等用户直接用NobyDa的jd cookie +let cookiesArr = [], + cookie = ''; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} + +allMessage = "" +message = "" +$.hotFlag = false +$.outFlag = false +$.activityEnd = false +let lz_jdpin_token_cookie ='' +let activityCookie ='' +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', { + "open-url": "https://bean.m.jd.com/" + }); + return; + } + // return + $.appkey = '51B59BB805903DA4CE513D29EC448375' + $.userId = '10299171' + $.actId = 'd32a6b5678c64ac2b_22011501' + $.MixNicks = '' + $.inviteNick = 'k1Nobb+P0er+C2sysxnx/P2KELO9izRVpwCyqu0eqVZ5aW7RHzlMobrzJ/e9r/uf' + console.log(`活动地址:https://jinggengjcq-isv.isvjcloud.com/fronth5/#/pages/unitedCardNew20220115/unitedCardNew20220115?actId=d32a6b5678c64ac2b_22011501`) + console.log(`请自行测试有水无水。`) + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i]; + if (cookie) { + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + message = "" + $.bean = 0 + $.hotFlag = false + $.nickName = ''; + console.log(`\n\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + await getUA() + await run(); + if(i == 0 && !$.MixNick) break + if($.outFlag || $.activityEnd) break + } + } + if($.outFlag) { + let msg = '此ip已被限制,请过10分钟后再执行脚本' + $.msg($.name, ``, `${msg}`); + if ($.isNode()) await notify.sendNotify(`${$.name}`, `${msg}`); + } +})() + .catch((e) => $.logErr(e)) + .finally(() => $.done()) + + +async function run() { + try { + $.hasEnd = true + $.endTime = 0 + lz_jdpin_token_cookie = '' + $.Token = '' + $.Pin = '' + $.MixNick = '' + let flag = false + if($.activityEnd) return + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + await takePostRequest('isvObfuscator'); + if($.Token == ''){ + console.log('获取[token]失败!') + return + } + await takePostRequest('activity_load'); + if($.hotFlag) return + if(Date.now() > $.endTime){ + $.MixNick = '' + $.activityEnd = true + console.log('活动结束') + return + } + if ($.MixNick == '') { + console.log(`获取cookie失败`); return; + } + // console.log($.MixNick) + // return + $.toBind = 0 + $.openList = [] + await takePostRequest('绑定'); + await takePostRequest('shopList'); + if($.activityEnd) return + for(o of $.openList){ + $.missionType = 'openCard' + if(o.open != true && o.openCardUrl){ + if($.activityEnd) return + $.openCard = false + $.joinVenderId = o.userId + await takePostRequest('mission'); + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + if($.openCard == true){ + await joinShop() + await takePostRequest('activity_load'); + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + // break + } + $.joinVenderId = '' + } + } + $.joinVenderId = '' + if($.hasCollectShop === 0){ + // 关注 + $.missionType = 'uniteCollectShop' + await takePostRequest('mission'); + await $.wait(parseInt(Math.random() * 2000 + 3000, 10)) + }else{ + console.log('已经关注') + } + $.missionType = 'uniteAddCart' + + await takePostRequest('mission'); + await $.wait(parseInt(Math.random() * 2000 + 3000, 10)) + await takePostRequest('activity_load'); + $.runFalag = true + let count = parseInt($.usedChance, 10) + console.log(`抽奖次数为:${count}`) + for(m=1;count--;m++){ + console.log(`第${m}次抽奖`) + await takePostRequest('抽奖'); + if($.runFalag == false) break + if(Number(count) <= 0) break + if(m >= 10){ + console.log("抽奖太多次,多余的次数请再执行脚本") + break + } + await $.wait(parseInt(Math.random() * 2000 + 2000, 10)) + } + await takePostRequest('myAward'); + await takePostRequest('missionInviteList'); + console.log($.MixNick) + console.log(`当前助力:${$.inviteNick}`) + if($.index == 1){ + $.inviteNick = $.MixNick + console.log(`后面的号都会助力:${$.inviteNick}`) + } + await $.wait(parseInt(Math.random() * 1000 + 5000, 10)) + if(flag) await $.wait(parseInt(Math.random() * 1000 + 10000, 10)) + if($.index % 3 == 0) console.log('休息1分钟,别被黑ip了\n可持续发展') + if($.index % 3 == 0) await $.wait(parseInt(Math.random() * 5000 + 60000, 10)) + } catch (e) { + console.log(e) + } +} + +async function takePostRequest(type) { + if($.outFlag) return + let domain = 'https://jinggengjcq-isv.isvjcloud.com'; + let body = ``; + let method = 'POST' + let admJson = '' + switch (type) { + case 'isvObfuscator': + url = `https://api.m.jd.com/client.action?functionId=isvObfuscator`; + body = `body=%7B%22url%22%3A%22https%3A//jinggengjcq-isv.isvjcloud.com/fronth5/%3Flng%3D0%26lat%3D0%26sid%3D49687cd64aca2ae93aa43748a04e8f6w%26un_area%3D16_1315_1316_53522%23/pages/unitedCardNew20211010-ka/unitedCardNew20211010-ka%3FactId%3D9150e1d16b9d40_10101%22%2C%22id%22%3A%22%22%7D&uuid=b9b4ce69d42dacb64084279d51cdee764d7781fa&client=apple&clientVersion=10.1.4&st=1634100732991&sv=111&sign=67e254ffbcb13be9e12a9782c9cdf398`; + break; + case 'activity_load': + url = `${domain}/dm/front/openCardNew/activity_load?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"jdToken": $.Token, "source": "01", "inviteNick":($.inviteNick || "")} + if($.joinVenderId) admJson = {...admJson, "shopId": `${$.joinVenderId}`} + body = taskPostUrl("/openCardNew/activity_load", admJson); + break; + case 'shopList': + url = `${domain}/dm/front/openCardNew/shopList?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {} + body = taskPostUrl("/openCardNew/shopList", admJson); + break; + case '绑定': + url = `${domain}/dm/front/openCardNew/complete/mission?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"missionType": "relationBind", "inviterNick":($.inviteNick || "")} + body = taskPostUrl("/openCardNew/complete/mission", admJson); + break; + case 'mission': + url = `${domain}/dm/front/openCardNew/complete/mission?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"missionType": $.missionType} + if($.joinVenderId) admJson = {...admJson, "shopId": $.joinVenderId} + body = taskPostUrl("/openCardNew/complete/mission", admJson); + break; + case '抽奖': + url = `${domain}/dm/front/openCardNew/draw/post?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"dataType": "draw", "usedGameNum": "2"} + body = taskPostUrl("/openCardNew/draw/post", admJson); + break; + case 'followShop': + url = `${domain}/dm/front/openCardNew/followShop?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"actId": $.actId, "missionType": "collectShop"} + body = taskPostUrl("/openCardNew/followShop", admJson); + break; + case 'addCart': + url = `${domain}/dm/front/openCardNew/addCart?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"actId": $.actId, "missionType": "addCart"} + body = taskPostUrl("/openCardNew/addCart", admJson); + break; + case 'myAward': + url = `${domain}/dm/front/openCardNew/myAwards?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"pageNo": 1,"pageSize":9999} + body = taskPostUrl("/openCardNew/myAwards", admJson); + break; + case 'missionInviteList': + url = `${domain}/dm/front/openCardNew/missionInviteList?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"inviteListRequest":{"actId":$.actId,"userId":10299171,"missionType":"shareAct","inviteType": 1,"buyerNick":($.MixNick || '')}} + body = taskPostUrl("/openCardNew/missionInviteList", admJson); + break; + default: + console.log(`错误${type}`); + } + let myRequest = getPostRequest(url, body, method); + return new Promise(async resolve => { + $.post(myRequest, (err, resp, data) => { + try { + if (err) { + if(resp && resp.statusCode && resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + console.log(`${$.toStr(err,err)}`) + console.log(`${type} API请求失败,请检查网路重试`) + } else { + dealReturn(type, data); + } + } catch (e) { + // console.log(data); + console.log(e, resp) + } finally { + resolve(); + } + }) + }) + } + +async function dealReturn(type, data) { + let res = '' + try { + if(type != 'accessLogWithAD' || type != 'drawContent'){ + if(data){ + res = JSON.parse(data); + } + } + } catch (e) { + console.log(`${type} 执行任务异常`); + console.log(data); + $.runFalag = false; + } + try { + let title = '' + switch (type) { + case 'isvObfuscator': + if(typeof res == 'object'){ + if(res.errcode == 0){ + if(typeof res.token != 'undefined') $.Token = res.token + }else if(res.message){ + console.log(`${type} ${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + break; + case 'accessLogWithAD': + case 'drawContent': + break; + case 'activity_load': + case 'mission': + case 'shopList': + case 'loadUniteOpenCard': + case 'setMixNick': + case 'uniteOpenCardOne': + case 'checkOpenCard': + case 'followShop': + case 'addCart': + case 'myAward': + case 'missionInviteList': + case '抽奖': + title = '' + if(type == "followShop") title = '关注' + if(type == "addCart") title = '加购' + if(typeof res == 'object'){ + if(res.success && res.success === true && res.data){ + if(res.data.status && res.data.status == 200){ + res = res.data + if(type != "setMixNick" && (res.msg || res.data.isOpenCard || res.data.remark)) console.log(`${title && title+":" || ""}${res.msg || res.data.isOpenCard || res.data.remark || ''}`) + if(type == "activity_load"){ + if(res.msg || res.data.isOpenCard) { + if((res.msg || res.data.isOpenCard || '').indexOf('绑定成功') > -1) $.toBind = 1 + } + if(res.data){ + $.endTime = res.data.cusActivity.endTime || 0 + $.MixNick = res.data.buyerNick || "" + $.usedChance = res.data.missionCustomer.usedChance || 0 + $.hasCollectShop = res.data.missionCustomer.hasCollectShop || 0 + } + }else if(type == "shopList"){ + $.openList = res.data.cusShops || [] + }else if(type == "mission"){ + if(res.data.remark.indexOf('不是会员') > -1){ + $.openCard = true + }else{ + $.openCard = false + } + }else if(type == "uniteOpenCardOne"){ + $.uniteOpenCar = res.msg || res.data.msg || '' + }else if(type == "myAward"){ + console.log(`我的奖品:`) + let num = 0 + let value = 0 + for(let i in res.data.list || []){ + let item = res.data.list[i] + value += Number(item.awardDes) + } + if(value > 0) console.log(`共获得${value}京豆\n无法判断奖励是否为邀请奖励,所以直接显示获得多少豆\n`) + }else if(type == "missionInviteList"){ + console.log(`邀请人数(${res.data.invitedLogList.total})`) + } + }else if(res.data.msg){ + if(res.errorMessage.indexOf('活动未开始') >-1 ){ + $.activityEnd = true + } + console.log(`${title || type} ${res.data.msg || ''}`) + }else if(res.errorMessage){ + if(res.errorMessage.indexOf('火爆') >-1 ){ + $.hotFlag = true + } + console.log(`${title || type} ${res.errorMessage || ''}`) + }else{ + console.log(`${title || type} ${data}`) + } + }else if(res.errorMessage){ + console.log(`${title || type} ${res.errorMessage || ''}`) + }else{ + console.log(`${title || type} ${data}`) + } + }else{ + console.log(`${title || type} ${data}`) + } + break; + default: + console.log(`${title || type}-> ${data}`); + } + if(typeof res == 'object'){ + if(res.errorMessage){ + if(res.errorMessage.indexOf('火爆') >-1 ){ + $.hotFlag = true + } + } + } + } catch (e) { + console.log(e) + } +} + +function getPostRequest(url, body, method="POST") { + let headers = { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Content-Type": "application/x-www-form-urlencoded", + "Cookie": cookie, + "User-Agent": $.UA, + "X-Requested-With": "XMLHttpRequest" + } + if(url.indexOf('https://jinggengjcq-isv.isvjcloud.com') > -1){ + headers["Origin"] = `https://jinggengjcq-isv.isvjcloud.com` + headers["Content-Type"] = `application/json; charset=utf-8` + delete headers["Cookie"] + } + // console.log(headers) + // console.log(headers.Cookie) + return {url: url, method: method, headers: headers, body: body, timeout:60000}; +} + + +function taskPostUrl(url, t) { + + const b = { + "jsonRpc": "2.0", + "params": { + "commonParameter": { + "appkey": $.appkey, + "m": "POST", + "timestamp": Date.now(), + "userId": $.userId + }, + "admJson": { + "actId": $.actId, + "userId": $.userId, + ...t, + "method": url, + "buyerNick": ($.MixNick || ''), + } + }, + } + if(url.indexOf('missionInviteList') > -1){ + delete b.params.admJson.actId + } + return $.toStr(b,b) +} +async function getUA(){ + $.UA = `jdapp;iPhone;10.1.4;13.1.2;${randomString(40)};network/wifi;model/iPhone8,1;addressid/2308460611;appBuild/167814;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_1_2 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 jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} + +function joinShop() { + if(!$.joinVenderId) return + return new Promise(async resolve => { + $.shopactivityId = '' + await $.wait(1000) + await getshopactivityId() + let activityId = `` + if($.shopactivityId) activityId = `,"activityId":${$.shopactivityId}` + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body={"venderId":"${$.joinVenderId}","shopId":"${$.joinVenderId}","bindByVerifyCodeFlag":1,"registerExtend":{},"writeChildFlag":0${activityId},"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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + // console.log(data) + let res = $.toObj(data); + if(typeof res == 'object'){ + if(res.success === true){ + console.log(res.message) + if(res.result && res.result.giftInfo){ + for(let i of res.result.giftInfo.giftList){ + console.log(`入会获得:${i.discountString}${i.prizeName}${i.secondLineDesc}`) + } + } + }else if(typeof res == 'object' && res.message){ + console.log(`${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function getshopactivityId() { + return new Promise(resolve => { + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body=%7B%22venderId%22%3A%22${$.joinVenderId}%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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + let res = $.toObj(data); + if(res.success == true){ + // console.log($.toStr(res.result)) + console.log(`入会:${res.result.shopMemberCardInfo.venderCardName || ''}`) + $.shopactivityId = res.result.interestsRuleList && res.result.interestsRuleList[0] && res.result.interestsRuleList[0].interestsInfo && res.result.interestsRuleList[0].interestsInfo.activityId || '' + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +// 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)} + diff --git a/activity/jd_opencardL48.js b/activity/jd_opencardL48.js new file mode 100644 index 0000000..3a36510 --- /dev/null +++ b/activity/jd_opencardL48.js @@ -0,0 +1,543 @@ +/* +1.17~1.23 联合开卡 +新增开卡脚本,一次性脚本 + +第一个账号助力作者 其他依次助力CK1 +第一个CK失效会退出脚本 + +———————————————— +入口:[ 1.17~1.23 联合开卡 (https://jinggengjcq-isv.isvjcloud.com/fronth5/#/pages/unitedCardNew20220117/unitedCardNew20220117?actId=897353f1fe1a4958a48_220117)] + +请求太频繁会被黑ip +过10分钟再执行 + + +cron:6 2,16 17-23 1 * +============Quantumultx=============== +[task_local] +#1.17~1.23 联合开卡 +6 2,16 15-25/2 1 * jd_opencardL48.js, tag=1.17~1.23 联合开卡, enabled=true + +*/ + +const $ = new Env('1.17~1.23 联合开卡'); +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const notify = $.isNode() ? require('./sendNotify') : ''; + +//IOS等用户直接用NobyDa的jd cookie +let cookiesArr = [], + cookie = ''; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} + +allMessage = "" +message = "" +$.hotFlag = false +$.outFlag = false +$.activityEnd = false +let lz_jdpin_token_cookie ='' +let activityCookie ='' +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', { + "open-url": "https://bean.m.jd.com/" + }); + return; + } + // return + $.appkey = '51B59BB805903DA4CE513D29EC448375' + $.userId = '10299171' + $.actId = '897353f1fe1a4958a48_220117' + $.MixNicks = '' + $.inviteNick = 'k1Nobb+P0er+C2sysxnx/P2KELO9izRVpwCyqu0eqVZ5aW7RHzlMobrzJ/e9r/uf' + console.log(`活动地址:https://jinggengjcq-isv.isvjcloud.com/fronth5/#/pages/unitedCardNew20220117/unitedCardNew20220117?actId=897353f1fe1a4958a48_220117`) + console.log(`请自行测试有水无水。`) + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i]; + if (cookie) { + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + message = "" + $.bean = 0 + $.hotFlag = false + $.nickName = ''; + console.log(`\n\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + await getUA() + await run(); + if(i == 0 && !$.MixNick) break + if($.outFlag || $.activityEnd) break + } + } + if($.outFlag) { + let msg = '此ip已被限制,请过10分钟后再执行脚本' + $.msg($.name, ``, `${msg}`); + if ($.isNode()) await notify.sendNotify(`${$.name}`, `${msg}`); + } +})() + .catch((e) => $.logErr(e)) + .finally(() => $.done()) + + +async function run() { + try { + $.hasEnd = true + $.endTime = 0 + lz_jdpin_token_cookie = '' + $.Token = '' + $.Pin = '' + $.MixNick = '' + let flag = false + if($.activityEnd) return + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + await takePostRequest('isvObfuscator'); + if($.Token == ''){ + console.log('获取[token]失败!') + return + } + await takePostRequest('activity_load'); + if($.hotFlag) return + if(Date.now() > $.endTime){ + $.MixNick = '' + $.activityEnd = true + console.log('活动结束') + return + } + if ($.MixNick == '') { + console.log(`获取cookie失败`); return; + } + // console.log($.MixNick) + // return + $.toBind = 0 + $.openList = [] + await takePostRequest('绑定'); + await takePostRequest('shopList'); + if($.activityEnd) return + for(o of $.openList){ + $.missionType = 'openCard' + if(o.open != true && o.openCardUrl){ + if($.activityEnd) return + $.openCard = false + $.joinVenderId = o.userId + await takePostRequest('mission'); + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + if($.openCard == true){ + await joinShop() + await takePostRequest('activity_load'); + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + // break + } + $.joinVenderId = '' + } + } + $.joinVenderId = '' + if($.hasCollectShop === 0){ + // 关注 + $.missionType = 'uniteCollectShop' + await takePostRequest('mission'); + await $.wait(parseInt(Math.random() * 2000 + 3000, 10)) + }else{ + console.log('已经关注') + } + $.missionType = 'uniteAddCart' + + await takePostRequest('mission'); + await $.wait(parseInt(Math.random() * 2000 + 3000, 10)) + await takePostRequest('activity_load'); + $.runFalag = true + let count = parseInt($.usedChance, 10) + console.log(`抽奖次数为:${count}`) + for(m=1;count--;m++){ + console.log(`第${m}次抽奖`) + await takePostRequest('抽奖'); + if($.runFalag == false) break + if(Number(count) <= 0) break + if(m >= 10){ + console.log("抽奖太多次,多余的次数请再执行脚本") + break + } + await $.wait(parseInt(Math.random() * 2000 + 2000, 10)) + } + await takePostRequest('myAward'); + await takePostRequest('missionInviteList'); + console.log($.MixNick) + console.log(`当前助力:${$.inviteNick}`) + if($.index == 1){ + $.inviteNick = $.MixNick + console.log(`后面的号都会助力:${$.inviteNick}`) + } + await $.wait(parseInt(Math.random() * 1000 + 5000, 10)) + if(flag) await $.wait(parseInt(Math.random() * 1000 + 10000, 10)) + if($.index % 3 == 0) console.log('休息1分钟,别被黑ip了\n可持续发展') + if($.index % 3 == 0) await $.wait(parseInt(Math.random() * 5000 + 60000, 10)) + } catch (e) { + console.log(e) + } +} + +async function takePostRequest(type) { + if($.outFlag) return + let domain = 'https://jinggengjcq-isv.isvjcloud.com'; + let body = ``; + let method = 'POST' + let admJson = '' + switch (type) { + case 'isvObfuscator': + url = `https://api.m.jd.com/client.action?functionId=isvObfuscator`; + body = `body=%7B%22url%22%3A%22https%3A//jinggengjcq-isv.isvjcloud.com/fronth5/%3Flng%3D0%26lat%3D0%26sid%3D49687cd64aca2ae93aa43748a04e8f6w%26un_area%3D16_1315_1316_53522%23/pages/unitedCardNew20211010-ka/unitedCardNew20211010-ka%3FactId%3D9150e1d16b9d40_10101%22%2C%22id%22%3A%22%22%7D&uuid=b9b4ce69d42dacb64084279d51cdee764d7781fa&client=apple&clientVersion=10.1.4&st=1634100732991&sv=111&sign=67e254ffbcb13be9e12a9782c9cdf398`; + break; + case 'activity_load': + url = `${domain}/dm/front/openCardNew/activity_load?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"jdToken": $.Token, "source": "01", "inviteNick":($.inviteNick || "")} + if($.joinVenderId) admJson = {...admJson, "shopId": `${$.joinVenderId}`} + body = taskPostUrl("/openCardNew/activity_load", admJson); + break; + case 'shopList': + url = `${domain}/dm/front/openCardNew/shopList?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {} + body = taskPostUrl("/openCardNew/shopList", admJson); + break; + case '绑定': + url = `${domain}/dm/front/openCardNew/complete/mission?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"missionType": "relationBind", "inviterNick":($.inviteNick || "")} + body = taskPostUrl("/openCardNew/complete/mission", admJson); + break; + case 'mission': + url = `${domain}/dm/front/openCardNew/complete/mission?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"missionType": $.missionType} + if($.joinVenderId) admJson = {...admJson, "shopId": $.joinVenderId} + body = taskPostUrl("/openCardNew/complete/mission", admJson); + break; + case '抽奖': + url = `${domain}/dm/front/openCardNew/draw/post?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"dataType": "draw", "usedGameNum": "2"} + body = taskPostUrl("/openCardNew/draw/post", admJson); + break; + case 'followShop': + url = `${domain}/dm/front/openCardNew/followShop?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"actId": $.actId, "missionType": "collectShop"} + body = taskPostUrl("/openCardNew/followShop", admJson); + break; + case 'addCart': + url = `${domain}/dm/front/openCardNew/addCart?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"actId": $.actId, "missionType": "addCart"} + body = taskPostUrl("/openCardNew/addCart", admJson); + break; + case 'myAward': + url = `${domain}/dm/front/openCardNew/myAwards?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"pageNo": 1,"pageSize":9999} + body = taskPostUrl("/openCardNew/myAwards", admJson); + break; + case 'missionInviteList': + url = `${domain}/dm/front/openCardNew/missionInviteList?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"inviteListRequest":{"actId":$.actId,"userId":10299171,"missionType":"shareAct","inviteType": 1,"buyerNick":($.MixNick || '')}} + body = taskPostUrl("/openCardNew/missionInviteList", admJson); + break; + default: + console.log(`错误${type}`); + } + let myRequest = getPostRequest(url, body, method); + return new Promise(async resolve => { + $.post(myRequest, (err, resp, data) => { + try { + if (err) { + if(resp && resp.statusCode && resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + console.log(`${$.toStr(err,err)}`) + console.log(`${type} API请求失败,请检查网路重试`) + } else { + dealReturn(type, data); + } + } catch (e) { + // console.log(data); + console.log(e, resp) + } finally { + resolve(); + } + }) + }) + } + +async function dealReturn(type, data) { + let res = '' + try { + if(type != 'accessLogWithAD' || type != 'drawContent'){ + if(data){ + res = JSON.parse(data); + } + } + } catch (e) { + console.log(`${type} 执行任务异常`); + console.log(data); + $.runFalag = false; + } + try { + let title = '' + switch (type) { + case 'isvObfuscator': + if(typeof res == 'object'){ + if(res.errcode == 0){ + if(typeof res.token != 'undefined') $.Token = res.token + }else if(res.message){ + console.log(`${type} ${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + break; + case 'accessLogWithAD': + case 'drawContent': + break; + case 'activity_load': + case 'mission': + case 'shopList': + case 'loadUniteOpenCard': + case 'setMixNick': + case 'uniteOpenCardOne': + case 'checkOpenCard': + case 'followShop': + case 'addCart': + case 'myAward': + case 'missionInviteList': + case '抽奖': + title = '' + if(type == "followShop") title = '关注' + if(type == "addCart") title = '加购' + if(typeof res == 'object'){ + if(res.success && res.success === true && res.data){ + if(res.data.status && res.data.status == 200){ + res = res.data + if(type != "setMixNick" && (res.msg || res.data.isOpenCard || res.data.remark)) console.log(`${title && title+":" || ""}${res.msg || res.data.isOpenCard || res.data.remark || ''}`) + if(type == "activity_load"){ + if(res.msg || res.data.isOpenCard) { + if((res.msg || res.data.isOpenCard || '').indexOf('绑定成功') > -1) $.toBind = 1 + } + if(res.data){ + $.endTime = res.data.cusActivity.endTime || 0 + $.MixNick = res.data.buyerNick || "" + $.usedChance = res.data.missionCustomer.usedChance || 0 + $.hasCollectShop = res.data.missionCustomer.hasCollectShop || 0 + } + }else if(type == "shopList"){ + $.openList = res.data.cusShops || [] + }else if(type == "mission"){ + if(res.data.remark.indexOf('不是会员') > -1){ + $.openCard = true + }else{ + $.openCard = false + } + }else if(type == "uniteOpenCardOne"){ + $.uniteOpenCar = res.msg || res.data.msg || '' + }else if(type == "myAward"){ + console.log(`我的奖品:`) + let num = 0 + let value = 0 + for(let i in res.data.list || []){ + let item = res.data.list[i] + value += Number(item.awardDes) + } + if(value > 0) console.log(`共获得${value}京豆\n无法判断奖励是否为邀请奖励,所以直接显示获得多少豆\n`) + }else if(type == "missionInviteList"){ + console.log(`邀请人数(${res.data.invitedLogList.total})`) + } + }else if(res.data.msg){ + if(res.errorMessage.indexOf('活动未开始') >-1 ){ + $.activityEnd = true + } + console.log(`${title || type} ${res.data.msg || ''}`) + }else if(res.errorMessage){ + if(res.errorMessage.indexOf('火爆') >-1 ){ + $.hotFlag = true + } + console.log(`${title || type} ${res.errorMessage || ''}`) + }else{ + console.log(`${title || type} ${data}`) + } + }else if(res.errorMessage){ + console.log(`${title || type} ${res.errorMessage || ''}`) + }else{ + console.log(`${title || type} ${data}`) + } + }else{ + console.log(`${title || type} ${data}`) + } + break; + default: + console.log(`${title || type}-> ${data}`); + } + if(typeof res == 'object'){ + if(res.errorMessage){ + if(res.errorMessage.indexOf('火爆') >-1 ){ + $.hotFlag = true + } + } + } + } catch (e) { + console.log(e) + } +} + +function getPostRequest(url, body, method="POST") { + let headers = { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Content-Type": "application/x-www-form-urlencoded", + "Cookie": cookie, + "User-Agent": $.UA, + "X-Requested-With": "XMLHttpRequest" + } + if(url.indexOf('https://jinggengjcq-isv.isvjcloud.com') > -1){ + headers["Origin"] = `https://jinggengjcq-isv.isvjcloud.com` + headers["Content-Type"] = `application/json; charset=utf-8` + delete headers["Cookie"] + } + // console.log(headers) + // console.log(headers.Cookie) + return {url: url, method: method, headers: headers, body: body, timeout:60000}; +} + + +function taskPostUrl(url, t) { + + const b = { + "jsonRpc": "2.0", + "params": { + "commonParameter": { + "appkey": $.appkey, + "m": "POST", + "timestamp": Date.now(), + "userId": $.userId + }, + "admJson": { + "actId": $.actId, + "userId": $.userId, + ...t, + "method": url, + "buyerNick": ($.MixNick || ''), + } + }, + } + if(url.indexOf('missionInviteList') > -1){ + delete b.params.admJson.actId + } + return $.toStr(b,b) +} +async function getUA(){ + $.UA = `jdapp;iPhone;10.1.4;13.1.2;${randomString(40)};network/wifi;model/iPhone8,1;addressid/2308460611;appBuild/167814;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_1_2 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 jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} + +function joinShop() { + if(!$.joinVenderId) return + return new Promise(async resolve => { + $.shopactivityId = '' + await $.wait(1000) + await getshopactivityId() + let activityId = `` + if($.shopactivityId) activityId = `,"activityId":${$.shopactivityId}` + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body={"venderId":"${$.joinVenderId}","shopId":"${$.joinVenderId}","bindByVerifyCodeFlag":1,"registerExtend":{},"writeChildFlag":0${activityId},"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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + // console.log(data) + let res = $.toObj(data); + if(typeof res == 'object'){ + if(res.success === true){ + console.log(res.message) + if(res.result && res.result.giftInfo){ + for(let i of res.result.giftInfo.giftList){ + console.log(`入会获得:${i.discountString}${i.prizeName}${i.secondLineDesc}`) + } + } + }else if(typeof res == 'object' && res.message){ + console.log(`${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function getshopactivityId() { + return new Promise(resolve => { + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body=%7B%22venderId%22%3A%22${$.joinVenderId}%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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + let res = $.toObj(data); + if(res.success == true){ + // console.log($.toStr(res.result)) + console.log(`入会:${res.result.shopMemberCardInfo.venderCardName || ''}`) + $.shopactivityId = res.result.interestsRuleList && res.result.interestsRuleList[0] && res.result.interestsRuleList[0].interestsInfo && res.result.interestsRuleList[0].interestsInfo.activityId || '' + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +// 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)} + diff --git a/activity/jd_opencardL49.js b/activity/jd_opencardL49.js new file mode 100644 index 0000000..566e41e --- /dev/null +++ b/activity/jd_opencardL49.js @@ -0,0 +1,801 @@ +/* +1.15~1.22 飞鹤大牌秒杀日 +只做邀请任务,集卡 + +第一个账号助力作者 其他依次助力CK1 +第一个CK失效会退出脚本 + +———————————————— +入口:[ 1.15~1.22 飞鹤大牌秒杀日 (https://lzdz1-isv.isvjcloud.com/dingzhi/flyCrane/collect/activity?activityId=dz2112100001448501&shareUuid=7c19ea8bacf74fbf83a87b6897a0002d)] + +请求太频繁会被黑ip +过10分钟再执行 + +cron:11 6 15-22 1 * +============Quantumultx=============== +[task_local] +#1.15~1.22 飞鹤大牌秒杀日 +11 6 15-22 1 * jd_opencardL49.js, tag=1.15~1.22 飞鹤大牌秒杀日, enabled=true + +*/ + +const $ = new Env('1.15~1.22 飞鹤大牌秒杀日'); +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const notify = $.isNode() ? require('./sendNotify') : ''; +//IOS等用户直接用NobyDa的jd cookie + +let cookiesArr = [], + cookie = ''; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} + +allMessage = "" +message = "" +$.hotFlag = false +$.outFlag = false +$.activityEnd = false +let lz_jdpin_token_cookie ='' +let activityCookie ='' +!(async () => { + + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', { + "open-url": "https://bean.m.jd.com/" + }); + return; + } + $.activityId = "dz2201100000356801" + $.shareUuid = "7c19ea8bacf74fbf83a87b6897a0002d" + console.log(`入口:\nhttps://lzdz1-isv.isvjcloud.com/dingzhi/flyCrane/collect/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}`) + let shareUuidArr = [$.shareUuid,"82609696607c46878da51772cecb7a21","450e6b0af93541c39b489a0a7c920e5d"] + let s = Math.floor((Math.random()*10)) + let n = 0 + if(s >= 1 && s<= 3) n = Math.floor((Math.random()*shareUuidArr.length)) + $.shareUuid = shareUuidArr[n] ? shareUuidArr[n] : $.shareUuid + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i]; + if (cookie) { + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + message = "" + $.bean = 0 + $.hotFlag = false + $.nickName = ''; + console.log(`\n\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + await getUA() + await run(); + if(i == 0 && !$.actorUuid) break + if($.outFlag || $.activityEnd) break + } + } + if($.outFlag) { + let msg = '此ip已被限制,请过10分钟后再执行脚本' + $.msg($.name, ``, `${msg}`); + if ($.isNode()) await notify.sendNotify(`${$.name}`, `${msg}`); + } +})() + .catch((e) => $.logErr(e)) + .finally(() => $.done()) + + +async function run() { + try { + $.hasEnd = true + $.endTime = 0 + lz_jdpin_token_cookie = '' + $.Token = '' + $.Pin = '' + let flag = false + await takePostRequest('isvObfuscator'); + if($.Token == ''){ + console.log('获取[token]失败!') + return + } + await getCk() + if (activityCookie == '') { + console.log(`获取cookie失败`); return; + } + if($.activityEnd === true){ + console.log('活动结束') + return + } + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + await takePostRequest('getSimpleActInfoVo'); + await takePostRequest('getMyPing'); + if(!$.Pin){ + console.log('获取[Pin]失败!') + return + } + await takePostRequest('accessLogWithAD'); + await takePostRequest('getUserInfo'); + await takePostRequest('activityContent'); + if($.hotFlag) return + if(!$.actorUuid){ + console.log('获取不到[actorUuid]退出执行,请重新执行') + return + } + if($.hasEnd === true || Date.now() > $.endTime){ + $.activityEnd = true + console.log('活动结束') + return + } + await takePostRequest('drawContent'); + await $.wait(1000) + $.openList = [] + $.allOpenCard = false + //await takePostRequest('checkOpenCard'); + // console.log($.actorUuid) + // return + if($.allOpenCard == false){ + console.log('开卡任务') + for(o of $.openList){ + $.openCard = false + if(o.openStatus == false){ + flag = true + $.joinVenderId = o.venderId + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + await joinShop() + await $.wait(parseInt(Math.random() * 1000 + 1000, 10)) + await takePostRequest('activityContent'); + await takePostRequest('drawContent'); + await takePostRequest('checkOpenCard'); + await $.wait(parseInt(Math.random() * 3000 + 2000, 10)) + } + } + }else{ + console.log('已全部开卡') + } + + $.log("关注: " + $.followShop) + if(!$.followShop && !$.outFlag){ + flag = true + await takePostRequest('followShop'); + await $.wait(parseInt(Math.random() * 2000 + 2000, 10)) + } + $.runFalag = true + if(flag){ + await takePostRequest('activityContent'); + } + $.runFalag = true + let count = parseInt($.score/1) + console.log(`抽奖次数为:${count}`) + for(m=1;count--;m++){ + console.log(`第${m}次抽奖`) + await takePostRequest('抽奖'); + if($.runFalag == false) break + if(Number(count) <= 0) break + if(m >= 10){ + console.log("抽奖太多次,多余的次数请再执行脚本") + break + } + await $.wait(parseInt(Math.random() * 2000 + 2000, 10)) + } + + await $.wait(parseInt(Math.random() * 1000 + 2000, 10)) + await takePostRequest('getDrawRecordHasCoupon'); + await takePostRequest('getShareRecord'); + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + console.log($.actorUuid) + console.log(`当前助力:${$.shareUuid}`) + if($.index == 1){ + $.shareUuid = $.actorUuid + console.log(`后面的号都会助力:${$.shareUuid}`) + } + await $.wait(parseInt(Math.random() * 1000 + 5000, 10)) + if(flag) await $.wait(parseInt(Math.random() * 1000 + 10000, 10)) + if($.index % 3 == 0) console.log('休息1分钟,别被黑ip了\n可持续发展') + if($.index % 3 == 0) await $.wait(parseInt(Math.random() * 5000 + 60000, 10)) + } catch (e) { + console.log(e) + } +} + +async function takePostRequest(type) { + if($.outFlag) return + let domain = 'https://lzdz1-isv.isvjcloud.com'; + let body = ``; + let method = 'POST' + let admJson = '' + switch (type) { + case 'isvObfuscator': + url = `https://api.m.jd.com/client.action?functionId=isvObfuscator`; + body = `body=%7B%22url%22%3A%22https%3A//lzdz1-isv.isvjcloud.com%22%2C%22id%22%3A%22%22%7D&uuid=7088d9018515b8cb0c88ace6e5479762af3e88f3&client=apple&clientVersion=10.1.4&st=1634343624086&sv=120&sign=8b9cea22c3a0d77026abda5d37d2b7e3`; + break; + case 'getSimpleActInfoVo': + url = `${domain}/dz/common/getSimpleActInfoVo`; + body = `activityId=${$.activityId}`; + break; + case 'getMyPing': + url = `${domain}/customer/getMyPing`; + body = `userId=${$.shopId || $.venderId || ''}&token=${$.Token}&fromType=APP`; + break; + case 'accessLogWithAD': + url = `${domain}/common/accessLogWithAD`; + let pageurl = `${domain}/drawCenter/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}` + body = `venderId=${$.shopId || $.venderId || ''}&code=99&pin=${encodeURIComponent($.Pin)}&activityId=${$.activityId}&pageUrl=${encodeURIComponent(pageurl)}&subType=app&adSource=` + break; + case 'getUserInfo': + url = `${domain}/wxActionCommon/getUserInfo`; + body = `pin=${encodeURIComponent($.Pin)}`; + break; + case 'activityContent': + url = `${domain}/dingzhi/flyCrane/collect/activityContent`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&pinImg=${encodeURIComponent($.attrTouXiang)}&nick=${encodeURIComponent($.nickname)}&cjyxPin=&cjhyPin=&shareUuid=${$.shareUuid}` + break; + case 'drawContent': + url = `${domain}/dingzhi/taskact/common/drawContent`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case 'checkOpenCard': + url = `${domain}/dingzhi/flyCrane/collect/initOpenCard`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&shareUuid=${$.shareUuid}` + break; + case 'info': + url = `${domain}/dingzhi/linkgame/task/opencard/info`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case 'startDraw': + url = `${domain}/joint/order/draw`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&drawType=1` + break; + case 'followShop': + url = `${domain}/dingzhi/flyCrane/collect/saveTask`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&taskType=23&taskValue=1&shareUuid=${$.shareUuid}` + break; + case 'sign': + case 'addCart': + case 'browseGoods': + url = `${domain}/dingzhi/linkgame/${type}`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + if(type == 'browseGoods') body += `&value=${$.visitSkuValue}` + break; + case '邀请': + case '助力': + if(type == '助力'){ + url = `${domain}/dingzhi/linkgame/assist`; + }else{ + url = `${domain}/dingzhi/linkgame/assist/status`; + } + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&shareUuid=${$.shareUuid}` + break; + case 'viewVideo': + case 'visitSku': + case 'toShop': + case 'addSku': + case 'toMainActive': + url = `${domain}/dingzhi/flyCrane/collect/saveTask`; + let taskType = '' + let taskValue = '' + if(type == 'viewVideo'){ + taskType = 31 + taskValue = 31 + }else if(type == 'visitSku'){ + taskType = 5 + taskValue = $.visitSkuValue || 5 + }else if(type == 'toShop'){ + taskType = 14 + taskValue = $.toShopValue || 14 + }else if(type == 'addSku'){ + taskType = 2 + taskValue = $.addSkuValue || 2 + }else if(type == 'toMainActive'){ + taskType = 12 + taskValue = 3 + } + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&taskType=${taskType}&taskValue=${taskValue}&shareUuid=${$.shareUuid}` + break; + case 'getDrawRecordHasCoupon': + url = `${domain}/dingzhi/taskact/common/getDrawRecordHasCoupon`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case 'getShareRecord': + url = `${domain}/dingzhi/taskact/common/getShareRecord`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case 'getRule': + url = `${domain}/dingzhi/flyCrane/collect/getRule`; + body = `activityId=${$.activityId}` + break; + case '抽奖': + url = `${domain}/dingzhi/flyCrane/collect/startDraw`; + body = `activityId=${$.activityId}&actorUuid=${$.actorUuid}&pin=${encodeURIComponent($.Pin)}` + break; + default: + console.log(`错误${type}`); + } + let myRequest = getPostRequest(url, body, method); + return new Promise(async resolve => { + $.post(myRequest, (err, resp, data) => { + try { + setActivityCookie(resp) + if (err) { + if(resp && typeof resp.statusCode != 'undefined'){ + if(resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + } + console.log(`${$.toStr(err,err)}`) + console.log(`${type} API请求失败,请检查网路重试`) + } else { + dealReturn(type, data); + } + } catch (e) { + console.log(e, resp) + } finally { + resolve(); + } + }) + }) + } + +async function dealReturn(type, data) { + let res = '' + try { + if(type != 'accessLogWithAD' || type != 'drawContent'){ + if(data){ + res = JSON.parse(data); + } + } + } catch (e) { + console.log(`${type} 执行任务异常`); + console.log(data); + $.runFalag = false; + } + try { + switch (type) { + case 'isvObfuscator': + if(typeof res == 'object'){ + if(res.errcode == 0){ + if(typeof res.token != 'undefined') $.Token = res.token + }else if(res.message){ + console.log(`isvObfuscator ${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + break; + case 'getSimpleActInfoVo': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(typeof res.data.shopId != 'undefined') $.shopId = res.data.shopId + if(typeof res.data.venderId != 'undefined') $.venderId = res.data.venderId + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getMyPing': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(res.data && typeof res.data.secretPin != 'undefined') $.Pin = res.data.secretPin + if(res.data && typeof res.data.nickname != 'undefined') $.nickname = res.data.nickname + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getUserInfo': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(res.data && typeof res.data.yunMidImageUrl != 'undefined') $.attrTouXiang = res.data.yunMidImageUrl || "https://img10.360buyimg.com/imgzone/jfs/t1/7020/27/13511/6142/5c5138d8E4df2e764/5a1216a3a5043c5d.png" + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'activityContent': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + $.endTime = res.data.endTime || (res.data.activityVo && res.data.activityVo.endTime) || res.data.activity.endTime || 0 + $.hasEnd = res.data.isEnd || false + $.drawCount = res.data.drawCount || (res.data.actor && res.data.actor.drawCount) || 0 + $.point = res.data.point || (res.data.actor && res.data.actor.point) || 0 + $.score = res.data.score || (res.data.actor && res.data.actor.score) || 0 + $.actorUuid = res.data.actorUuid || (res.data.actor && res.data.actor.actorUuid) || '' + $.followShop = res.data.followShop || (res.data.actor && res.data.actor.followShopStatus) || '' + $.toMainActive = res.data.toMainActive || '' + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'info': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + $.addCart = res.data.addCart || false + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'checkOpenCard': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + let cardList1 = res.data.cardList1 || [] + let cardList2 = res.data.cardList2 || [] + let cardList = res.data.cardList || [] + let openInfo = res.data.openInfo || [] + let openCardList = res.data.openCardList || [] + $.openList = [...cardList,...cardList1,...cardList2,...openCardList,...openInfo] + $.allOpenCard = res.data.allOpenCard || res.data.isOpenCardStatus || false + $.openCardScore1 = res.data.score1 || 0 + $.openCardScore2 = res.data.score2 || 0 + $.drawScore = res.data.drawScore || 0 + if(res.data.beans) console.log(`获得:${res.data.beans}豆`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'startDraw': + case 'followShop': + case 'viewVideo': + case 'visitSku': + case 'toShop': + case 'addSku': + case 'sign': + case 'addCart': + case 'browseGoods': + case 'toMainActive': + case '抽奖': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(typeof res.data == 'object'){ + let msg = '' + let title = '抽奖' + if(res.data.addBeanNum || res.data.taskbeanNum){ + msg = `${res.data.addBeanNum || res.data.taskbeanNum}京豆` + } + if(res.data.addPoint){ + msg += ` ${res.data.addPoint}游戏机会` + } + if(type == 'followShop'){ + title = '关注' + if(res.data.beanNumMember && res.data.assistSendStatus){ + msg += ` 额外获得:${res.data.beanNumMember}京豆` + } + }else if(type == 'addSku' || type == 'addCart'){ + title = '加购' + }else if(type == 'viewVideo'){ + title = '热门文章' + }else if(type == 'toShop'){ + title = '浏览店铺' + }else if(type == 'visitSku' || type == 'browseGoods'){ + title = '浏览商品' + }else if(type == 'sign'){ + title = '签到' + }else if(type == 'toMainActive'){ + title = '逛会场' + }else{ + msg = res.data.drawOk == true && (res.data.drawInfoType == 6 && res.data.name || '') || res.data.wdsrvo.drawOk == true && (res.data.wdsrvo.drawInfoType == 6 && res.data.wdsrvo.name || '') || '空气💨' + } + if(!msg){ + msg = '空气💨' + } + console.log(`${title}获得:${msg || data}`) + }else{ + console.log(`${type} ${data}`) + } + }else if(res.errorMessage){ + $.runFalag = false; + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getDrawRecordHasCoupon': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + console.log(`我的奖品:`) + let num = 0 + let value = 0 + let typeArr = { + "dayShareBeans":"邀请", + "dayBeSharedBeans":"被邀请", + "openCardBeans":"开卡", + "saveTaskBeans23":"关注", + "saveTaskBeans12":"逛会场", + } + for(let i in res.data){ + let item = res.data[i] + if(item.drawId == 'dayShareBeans'){ + num++ + value = item.infoName.replace('京豆','') + }else{ + console.log(`${item.infoType != 10 && item.drawId && (typeArr[item.drawId] || item.drawId)+':' || item.value && item.value +':' || ''}${item.infoName}`) + } + } + if(num > 0) console.log(`邀请好友(${num}):${num*parseInt(value, 10) || 30}京豆`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getShareRecord': + if(typeof res == 'object'){ + if(res.result && res.result === true && res.data){ + $.ShareCount = res.data.length + $.log(`=========== 你邀请了:${res.data.length}个`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case '邀请': + case '助力': + if(typeof res == 'object'){ + if(res.data.status == 200){ + if(type == '助力'){ + console.log('助力成功') + }else{ + $.yaoqing = true + } + }else if(res.data.status == 105){ + console.log('已经助力过') + }else if(res.data.status == 104){ + console.log('已经助力其他人') + }else if(res.data.status == 101){ + // console.log('已经助力过') + }else{ + console.log(data) + } + }else{ + console.log(`${type} ${data}`) + } + + case 'accessLogWithAD': + case 'drawContent': + break; + default: + console.log(`${type}-> ${data}`); + } + if(typeof res == 'object'){ + if(res.errorMessage){ + if(res.errorMessage.indexOf('火爆') >-1 ){ + $.hotFlag = true + } + } + } + } catch (e) { + console.log(e) + } +} + +function getPostRequest(url, body, method="POST") { + let headers = { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Content-Type": "application/x-www-form-urlencoded", + "Cookie": cookie, + "User-Agent": $.UA, + "X-Requested-With": "XMLHttpRequest" + } + if(url.indexOf('https://lzdz1-isv.isvjcloud.com') > -1){ + headers["Referer"] = `https://lzdz1-isv.isvjcloud.com/dingzhi/flyCrane/collect/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}` + headers["Cookie"] = `${lz_jdpin_token_cookie && lz_jdpin_token_cookie || ''}${$.Pin && "AUTH_C_USER=" + $.Pin + ";" || ""}${activityCookie}` + } + // console.log(headers) + // console.log(headers.Cookie) + return {url: url, method: method, headers: headers, body: body, timeout:30000}; +} + +function getCk() { + return new Promise(resolve => { + let get = { + url:`https://lzdz1-isv.isvjcloud.com/dingzhi/flyCrane/collect/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}`, + followRedirect:false, + headers: { + "User-Agent": $.UA, + }, + timeout:30000 + } + $.get(get, async(err, resp, data) => { + try { + if (err) { + if(resp && typeof resp.statusCode != 'undefined'){ + if(resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + } + console.log(`${$.toStr(err)}`) + console.log(`${$.name} cookie API请求失败,请检查网路重试`) + } else { + let end = data.match(/(活动已经结束)/) && data.match(/(活动已经结束)/)[1] || '' + if(end){ + $.activityEnd = true + console.log('活动已结束') + } + setActivityCookie(resp) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function setActivityCookie(resp){ + let LZ_TOKEN_KEY = '' + let LZ_TOKEN_VALUE = '' + let lz_jdpin_token = '' + let setcookies = resp && resp['headers'] && (resp['headers']['set-cookie'] || resp['headers']['Set-Cookie'] || '') || '' + let setcookie = '' + if(setcookies){ + if(typeof setcookies != 'object'){ + setcookie = setcookies.split(',') + }else setcookie = setcookies + for (let ck of setcookie) { + let name = ck.split(";")[0].trim() + if(name.split("=")[1]){ + // console.log(name.replace(/ /g,'')) + if(name.indexOf('LZ_TOKEN_KEY=')>-1) LZ_TOKEN_KEY = name.replace(/ /g,'')+';' + if(name.indexOf('LZ_TOKEN_VALUE=')>-1) LZ_TOKEN_VALUE = name.replace(/ /g,'')+';' + if(name.indexOf('lz_jdpin_token=')>-1) lz_jdpin_token = ''+name.replace(/ /g,'')+';' + } + } + } + if(LZ_TOKEN_KEY && LZ_TOKEN_VALUE) activityCookie = `${LZ_TOKEN_KEY} ${LZ_TOKEN_VALUE}` + if(lz_jdpin_token) lz_jdpin_token_cookie = lz_jdpin_token +} + +async function getUA(){ + $.UA = `jdapp;iPhone;10.1.4;13.1.2;${randomString(40)};network/wifi;model/iPhone8,1;addressid/2308460611;appBuild/167814;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_1_2 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 joinShop() { + if(!$.joinVenderId) return + return new Promise(async resolve => { + $.shopactivityId = '' + await $.wait(1000) + await getshopactivityId() + let activityId = `` + if($.shopactivityId) activityId = `,"activityId":${$.shopactivityId}` + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body={"venderId":"${$.joinVenderId}","shopId":"${$.joinVenderId}","bindByVerifyCodeFlag":1,"registerExtend":{},"writeChildFlag":0${activityId},"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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + // console.log(data) + let res = $.toObj(data); + if(typeof res == 'object'){ + if(res.success === true){ + console.log(res.message) + if(res.result && res.result.giftInfo){ + for(let i of res.result.giftInfo.giftList){ + console.log(`入会获得:${i.discountString}${i.prizeName}${i.secondLineDesc}`) + } + } + }else if(typeof res == 'object' && res.message){ + console.log(`${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function getshopactivityId() { + return new Promise(resolve => { + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body=%7B%22venderId%22%3A%22${$.joinVenderId}%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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + let res = $.toObj(data); + if(res.success == true){ + // console.log($.toStr(res.result)) + console.log(`入会:${res.result.shopMemberCardInfo.venderCardName || ''}`) + $.shopactivityId = res.result.interestsRuleList && res.result.interestsRuleList[0] && res.result.interestsRuleList[0].interestsInfo && res.result.interestsRuleList[0].interestsInfo.activityId || '' + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} + + +// 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)} + diff --git a/activity/jd_opencardL50.js b/activity/jd_opencardL50.js new file mode 100644 index 0000000..7decc47 --- /dev/null +++ b/activity/jd_opencardL50.js @@ -0,0 +1,554 @@ +/* +/* +1.18~1.24 婴乐家会员日 +新增开卡脚本,一次性脚本 + +前20人邀请一人20 +开卡一个20 + +第一个账号助力作者 其他依次助力CK1 +第一个CK失效会退出脚本 + +———————————————— +入口:[ 1.18~1.24 婴乐家会员日 (https://prodev.m.jd.com/mall/active/W1JeR6TyFJiEt2FobvSgBXSt7Q4/index.html)] + +请求太频繁会被黑ip +过10分钟再执行 + + +cron:6 14 18-24 1 * +============Quantumultx=============== +[task_local] +#1.18~1.24 婴乐家会员日 +6 14 18-24 1 * jd_opencardL50.js, tag=1.18~1.24 婴乐家会员日, enabled=true + +*/ + +const $ = new Env("1.18~1.24 婴乐家会员日"); +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const notify = $.isNode() ? require('./sendNotify') : ''; +let cookiesArr = [], cookie = '', message = ''; +let ownCode = null; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => { }; +} else { + let cookiesData = $.getdata('CookiesJD') || "[]"; + cookiesData = JSON.parse(cookiesData); + cookiesArr = cookiesData.map(item => item.cookie); + cookiesArr.reverse(); + cookiesArr.push(...[$.getdata('CookieJD2'), $.getdata('CookieJD')]); + cookiesArr.reverse(); + cookiesArr = cookiesArr.filter(item => !!item); +} +!(async () => { + console.log(`活动地址:https://prodev.m.jd.com/mall/active/W1JeR6TyFJiEt2FobvSgBXSt7Q4/index.html`) + console.log(`请自行测试有水无水。`) + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', { "open-url": "https://bean.m.jd.com/bean/signIndex.action" }); + return; + } + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i] + originCookie = cookiesArr[i] + newCookie = '' + $.UserName = decodeURIComponent(cookie.match(/pt_pin=(.+?);/) && cookie.match(/pt_pin=(.+?);/)[1]) + $.index = i + 1; + $.isLogin = true; + $.nickName = ''; + await checkCookie(); + console.log(`\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + if (!$.isLogin) { + $.msg($.name, `【提示】cookie已失效`, `京东账号${$.index} ${$.nickName || $.UserName}\n请重新登录获取\nhttps://bean.m.jd.com/bean/signIndex.action`, { "open-url": "https://bean.m.jd.com/bean/signIndex.action" }); + if ($.isNode()) { + } + continue + } + $.bean = 0; + $.ADID = getUUID('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', 1); + $.UUID = getUUID('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'); + authorCodeList = ['k1Nobb+P0er+C2sysxnx/P2KELO9izRVpwCyqu0eqVZ5aW7RHzlMobrzJ/e9r/uf'] + $.appkey = "51B59BB805903DA4CE513D29EC448375" + $.userId = "10299171" + $.actId = "4bf393119c_788" + $.authorCode = ownCode ? ownCode : authorCodeList[random(0, authorCodeList.length)] + console.log('去助力 -> '+$.authorCode); + await openCardNew(); + if ($.bean > 0) { + message += `\n【京东账号${$.index}】${$.nickName || $.UserName} \n └ 获得 ${$.bean} 京豆。` + } + } + } + if (message !== '') { + if ($.isNode()) { + await notify.sendNotify($.name, message, '', `\n`); + } else { + $.msg($.name, '有点儿收获', message); + } + } +})() + .catch((e) => { + $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') + }) + .finally(() => { + $.done(); + }) + + +async function openCardNew() { + $.token = null; + $.buyerNick = null; + $.activityInfo = null; + await getToken(); + if ($.token) { + await task('activity_load', { + "actId": $.actId, + "inviteNick": $.authorCode, + "jdToken": $.token, + "source": "01", + }) + if ($.buyerNick) { + console.log('1.助力码 -> '+$.buyerNick) + if ($.index === 1) { + ownCode = $.buyerNick + console.log("后面的将给这个助力码助力 -> "+ownCode) + } + console.log('2.绑定助力 ->') + await task('complete/mission', { + "actId": $.actId, + "missionType": "relationBind", + "inviterNick": $.authorCode, + }) + await task('shopList', { + "actId": $.actId, + }) + console.log('3.关注店铺 ->') + await task('complete/mission', { + "actId": $.actId, + "missionType": "uniteCollectShop", + }) + console.log('4.抽奖 ->') + await task('draw/post', { + "actId": $.actId, + "usedGameNum": "2", + "dataType": "draw", + }) + console.log('5.加入会员 ->') + if ($.shopList) { + console.log('会员卡数量 -> '+$.shopList.length) + for (const vo of $.shopList) { + $.log(`${vo.userId}`) + if (!vo.open) { + $.log("开通会员") + await getShopOpenCardInfo(vo.userId) + await bindWithVender(vo.userId) + await task('complete/mission', { + "actId": $.actId, + "shopId": vo.userId, + "missionType": "openCard", + }) + await $.wait(3000) + } else { + $.log("已经是会员了") + } + await $.wait(500) + } + } + console.log('6.加入购物车 ->') + await task('complete/mission', { + "actId": $.actId, + "missionType": "uniteAddCart", + }) + } else { + $.log("没有成功获取到用户信息") + } + } else { + $.log("没有成功获取到用户鉴权信息") + } +} + +function task(function_id, preParams) { + body = { + "jsonRpc": "2.0", + "params": { + "commonParameter": { + "appkey": $.appkey, + "m": "POST", + "timestamp": new Date(), + "userId": $.userId + }, + "admJson": { + "method": `/openCardNew/${function_id}`, + "userId": $.userId, + "buyerNick": $.buyerNick ? $.buyerNick : "" + } + } + } + Object.assign(body.params.admJson, preParams) + return new Promise(resolve => { + $.post(taskUrl(function_id, body), async (err, resp, data) => { + try { + if (err) { + $.log(err) + } else { + + if (data) { + data = JSON.parse(data); + if (data.success) { + if (data.data.status === 200) { + switch (function_id) { + case 'activity_load': + $.buyerNick = data.data.data.buyerNick; + console.log("[ "+data.data.data.cusActivity.actName+" ]"); + break; + case 'shopList': + $.shopList = data.data.data.cusShops; + break; + case 'complete/mission': + console.log(data.data.data.remark); + break; + case 'draw/post': + console.log(data.data.data.awardSetting.awardName); + break; + default: + break; + } + } + } + + } else { + $.log("京东没有返回数据") + } + } + } catch (error) { + $.log(error) + } finally { + resolve(); + } + }) + }) +} +function getShopOpenCardInfo(venderId) { + let opt = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body=${encodeURIComponent(JSON.stringify({ venderId: venderId, channel: 401 }))}&client=H5&clientVersion=9.2.0&uuid=88888`, + headers: { + Host: 'api.m.jd.com', + Accept: '*/*', + Connection: 'keep-alive', + Cookie: cookie, + 'User-Agent': `jdapp;iPhone;9.5.4;13.6;${$.UUID};network/wifi;ADID/${$.ADID};model/iPhone10,3;addressid/0;appBuild/167668;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1`, + 'Accept-Language': 'zh-cn', + Referer: `https://shopmember.m.jd.com/shopcard/?venderId=${venderId}}&channel=401&returnUrl=${encodeURIComponent('https://jinggengjcq-isv.isvjcloud.com/fronth5')}`, + 'Accept-Encoding': 'gzip, deflate, br' + } + } + return new Promise(resolve => { + $.get(opt, (err, resp, data) => { + try { + if (err) { + console.log(err) + } else { + res = JSON.parse(data) + if (res.success) { + if (res.result.interestsRuleList) { + $.openCardActivityId = res.result.interestsRuleList[0].interestsInfo.activityId; + } + } + } + } catch (error) { + console.log(error) + } finally { + resolve(); + } + }) + + }) +} +function bindWithVender(venderId) { + let opt = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body=${encodeURIComponent(JSON.stringify({ "venderId": venderId, "bindByVerifyCodeFlag": 1, "registerExtend": {}, "writeChildFlag": 0, "channel": 401 }))}&client=H5&clientVersion=9.2.0&uuid=88888`, + headers: { + Host: 'api.m.jd.com', + Accept: '*/*', + Connection: 'keep-alive', + Cookie: cookie, + 'User-Agent': `jdapp;iPhone;9.5.4;13.6;${$.UUID};network/wifi;ADID/${$.ADID};model/iPhone10,3;addressid/0;appBuild/167668;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1`, + 'Accept-Language': 'zh-cn', + Referer: `https://shopmember.m.jd.com/shopcard/?venderId=${venderId}}&channel=401&returnUrl=${encodeURIComponent('https://jinggengjcq-isv.isvjcloud.com/fronth5')}`, + 'Accept-Encoding': 'gzip, deflate, br' + } + } + return new Promise(resolve => { + $.get(opt, (err, resp, data) => { + try { + if (err) { + console.log(err) + } else { + res = JSON.parse(data) + if (res.success) { + console.log("开卡成功") + } + } + } catch (error) { + console.log(error) + } finally { + resolve(); + } + }) + + }) +} +function taskUrl(function_id, body) { + return { + url: `https://jinggengjcq-isv.isvjcloud.com/dm/front/openCardNew/${function_id}?&mix_nick=${$.buyerNick ? $.buyerNick : ""}`, + headers: { + Host: 'jinggengjcq-isv.isvjcloud.com', + Accept: 'application/json', + 'X-Requested-With': 'XMLHttpRequest', + 'Accept-Language': 'zh-cn', + 'Accept-Encoding': 'gzip, deflate, br', + 'Content-Type': 'application/json; charset=utf-8', + Origin: 'https://jinggengjcq-isv.isvjcloud.com', + 'User-Agent': `jdapp;iPhone;9.5.4;13.6;${$.UUID};network/wifi;ADID/${$.ADID};model/iPhone10,3;addressid/0;appBuild/167668;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1`, + Connection: 'keep-alive', + Referer: 'https://jinggengjcq-isv.isvjcloud.com/fronth5/', + Cookie: cookie + }, + body: JSON.stringify(body) + + } +} + +function getMyPing() { + let opt = { + url: `https://lzdz1-isv.isvjcloud.com/customer/getMyPing`, + headers: { + Host: 'lzdz1-isv.isvjcloud.com', + Accept: 'application/json', + 'X-Requested-With': 'XMLHttpRequest', + 'Accept-Language': 'zh-cn', + 'Accept-Encoding': 'gzip, deflate, br', + 'Content-Type': 'application/x-www-form-urlencoded', + Origin: 'https://lzdz1-isv.isvjcloud.com', + 'User-Agent': `jdapp;iPhone;9.5.4;13.6;${$.UUID};network/wifi;ADID/${$.ADID};model/iPhone10,3;addressid/0;appBuild/167668;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1`, + Connection: 'keep-alive', + Referer: $.activityUrl, + Cookie: cookie, + }, + body: `userId=${$.activityShopId}&token=${$.token}&fromType=APP&riskType=1` + } + return new Promise(resolve => { + $.post(opt, (err, resp, data) => { + try { + if (err) { + $.log(err) + } else { + if (resp['headers']['set-cookie']) { + cookie = `${originCookie}` + if ($.isNode()) { + for (let sk of resp['headers']['set-cookie']) { + cookie = `${cookie}${sk.split(";")[0]};` + } + } else { + for (let ck of resp['headers']['Set-Cookie'].split(',')) { + cookie = `${cookie}${ck.split(";")[0]};` + } + } + } + if (resp['headers']['Set-Cookie']) { + cookie = `${originCookie}` + if ($.isNode()) { + for (let sk of resp['headers']['set-cookie']) { + cookie = `${cookie}${sk.split(";")[0]};` + } + } else { + for (let ck of resp['headers']['Set-Cookie'].split(',')) { + cookie = `${cookie}${ck.split(";")[0]};` + } + } + } + if (data) { + data = JSON.parse(data) + if (data.result) { + $.log(`你好:${data.data.nickname}`) + $.pin = data.data.nickname; + $.secretPin = data.data.secretPin; + cookie = `${cookie};AUTH_C_USER=${data.data.secretPin}` + } else { + $.log(data.errorMessage) + } + } + } + } catch (error) { + $.log(error) + } finally { + resolve(); + } + + }) + }) +} +function getFirstLZCK() { + return new Promise(resolve => { + $.get({ url: $.activityUrl }, (err, resp, data) => { + try { + if (err) { + console.log(err) + } else { + if (resp['headers']['set-cookie']) { + cookie = `${originCookie}` + if ($.isNode()) { + for (let sk of resp['headers']['set-cookie']) { + cookie = `${cookie}${sk.split(";")[0]};` + } + } else { + for (let ck of resp['headers']['Set-Cookie'].split(',')) { + cookie = `${cookie}${ck.split(";")[0]};` + } + } + } + if (resp['headers']['Set-Cookie']) { + cookie = `${originCookie}` + if ($.isNode()) { + for (let sk of resp['headers']['set-cookie']) { + cookie = `${cookie}${sk.split(";")[0]};` + } + } else { + for (let ck of resp['headers']['Set-Cookie'].split(',')) { + cookie = `${cookie}${ck.split(";")[0]};` + } + } + } + } + } catch (error) { + console.log(error) + } finally { + resolve(); + } + }) + }) +} +function getAuthorCodeList(url) { + return new Promise(resolve => { + const options = { + url: `${url}?${new Date()}`, "timeout": 10000, headers: { + "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1 Edg/87.0.4280.88" + } + }; + $.get(options, async (err, resp, data) => { + try { + if (err) { + $.log(err) + } else { + if (data) data = JSON.parse(data) + } + } catch (e) { + $.logErr(e, resp) + data = null; + } finally { + resolve(data); + } + }) + }) +} +function getToken() { + let opt = { + url: `https://api.m.jd.com/client.action?functionId=isvObfuscator`, + headers: { + Host: 'api.m.jd.com', + 'Content-Type': 'application/x-www-form-urlencoded', + Accept: '*/*', + Connection: 'keep-alive', + Cookie: cookie, + 'User-Agent': 'JD4iPhone/167650 (iPhone; iOS 13.7; Scale/3.00)', + 'Accept-Language': 'zh-Hans-CN;q=1', + 'Accept-Encoding': 'gzip, deflate, br', + }, + body: `body=%7B%22url%22%3A%20%22https%3A//lzkj-isv.isvjcloud.com%22%2C%20%22id%22%3A%20%22%22%7D&uuid=hjudwgohxzVu96krv&client=apple&clientVersion=9.4.0&st=1620476162000&sv=111&sign=f9d1b7e3b943b6a136d54fe4f892af05` + } + return new Promise(resolve => { + $.post(opt, (err, resp, data) => { + try { + if (err) { + $.log(err) + } else { + if (data) { + data = JSON.parse(data); + if (data.code === "0") { + $.token = data.token + } + } else { + $.log("京东返回了空数据") + } + } + } catch (error) { + $.log(error) + } finally { + resolve(); + } + }) + }) +} +function random(min, max) { + + return Math.floor(Math.random() * (max - min)) + min; + +} +function getUUID(format = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', UpperCase = 0) { + return format.replace(/[xy]/g, function (c) { + var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8); + if (UpperCase) { + uuid = v.toString(36).toUpperCase(); + } else { + uuid = v.toString(36) + } + return uuid; + }); +} +function checkCookie() { + const options = { + url: "https://me-api.jd.com/user_new/info/GetJDUserInfoUnion", + headers: { + "Host": "me-api.jd.com", + "Accept": "*/*", + "Connection": "keep-alive", + "Cookie": cookie, + "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.2 Mobile/15E148 Safari/604.1", + "Accept-Language": "zh-cn", + "Referer": "https://home.m.jd.com/myJd/newhome.action?sceneval=2&ufc=&", + "Accept-Encoding": "gzip, deflate, br", + } + }; + return new Promise(resolve => { + $.get(options, (err, resp, data) => { + try { + if (err) { + $.logErr(err) + } else { + if (data) { + data = JSON.parse(data); + if (data.retcode === "1001") { + $.isLogin = false; //cookie过期 + return; + } + if (data.retcode === "0" && data.data.hasOwnProperty("userInfo")) { + $.nickName = data.data.userInfo.baseInfo.nickname; + } + } else { + $.log('京东返回了空数据'); + } + } + } catch (e) { + $.logErr(e) + } finally { + resolve(); + } + }) + }) +} +// prettier-ignore +!function (n) { "use strict"; function t(n, t) { var r = (65535 & n) + (65535 & t); return (n >> 16) + (t >> 16) + (r >> 16) << 16 | 65535 & r } function r(n, t) { return n << t | n >>> 32 - t } function e(n, e, o, u, c, f) { return t(r(t(t(e, n), t(u, f)), c), o) } function o(n, t, r, o, u, c, f) { return e(t & r | ~t & o, n, t, u, c, f) } function u(n, t, r, o, u, c, f) { return e(t & o | r & ~o, n, t, u, c, f) } function c(n, t, r, o, u, c, f) { return e(t ^ r ^ o, n, t, u, c, f) } function f(n, t, r, o, u, c, f) { return e(r ^ (t | ~o), n, t, u, c, f) } function i(n, r) { n[r >> 5] |= 128 << r % 32, n[14 + (r + 64 >>> 9 << 4)] = r; var e, i, a, d, h, l = 1732584193, g = -271733879, v = -1732584194, m = 271733878; for (e = 0; e < n.length; e += 16)i = l, a = g, d = v, h = m, g = f(g = f(g = f(g = f(g = c(g = c(g = c(g = c(g = u(g = u(g = u(g = u(g = o(g = o(g = o(g = o(g, v = o(v, m = o(m, l = o(l, g, v, m, n[e], 7, -680876936), g, v, n[e + 1], 12, -389564586), l, g, n[e + 2], 17, 606105819), m, l, n[e + 3], 22, -1044525330), v = o(v, m = o(m, l = o(l, g, v, m, n[e + 4], 7, -176418897), g, v, n[e + 5], 12, 1200080426), l, g, n[e + 6], 17, -1473231341), m, l, n[e + 7], 22, -45705983), v = o(v, m = o(m, l = o(l, g, v, m, n[e + 8], 7, 1770035416), g, v, n[e + 9], 12, -1958414417), l, g, n[e + 10], 17, -42063), m, l, n[e + 11], 22, -1990404162), v = o(v, m = o(m, l = o(l, g, v, m, n[e + 12], 7, 1804603682), g, v, n[e + 13], 12, -40341101), l, g, n[e + 14], 17, -1502002290), m, l, n[e + 15], 22, 1236535329), v = u(v, m = u(m, l = u(l, g, v, m, n[e + 1], 5, -165796510), g, v, n[e + 6], 9, -1069501632), l, g, n[e + 11], 14, 643717713), m, l, n[e], 20, -373897302), v = u(v, m = u(m, l = u(l, g, v, m, n[e + 5], 5, -701558691), g, v, n[e + 10], 9, 38016083), l, g, n[e + 15], 14, -660478335), m, l, n[e + 4], 20, -405537848), v = u(v, m = u(m, l = u(l, g, v, m, n[e + 9], 5, 568446438), g, v, n[e + 14], 9, -1019803690), l, g, n[e + 3], 14, -187363961), m, l, n[e + 8], 20, 1163531501), v = u(v, m = u(m, l = u(l, g, v, m, n[e + 13], 5, -1444681467), g, v, n[e + 2], 9, -51403784), l, g, n[e + 7], 14, 1735328473), m, l, n[e + 12], 20, -1926607734), v = c(v, m = c(m, l = c(l, g, v, m, n[e + 5], 4, -378558), g, v, n[e + 8], 11, -2022574463), l, g, n[e + 11], 16, 1839030562), m, l, n[e + 14], 23, -35309556), v = c(v, m = c(m, l = c(l, g, v, m, n[e + 1], 4, -1530992060), g, v, n[e + 4], 11, 1272893353), l, g, n[e + 7], 16, -155497632), m, l, n[e + 10], 23, -1094730640), v = c(v, m = c(m, l = c(l, g, v, m, n[e + 13], 4, 681279174), g, v, n[e], 11, -358537222), l, g, n[e + 3], 16, -722521979), m, l, n[e + 6], 23, 76029189), v = c(v, m = c(m, l = c(l, g, v, m, n[e + 9], 4, -640364487), g, v, n[e + 12], 11, -421815835), l, g, n[e + 15], 16, 530742520), m, l, n[e + 2], 23, -995338651), v = f(v, m = f(m, l = f(l, g, v, m, n[e], 6, -198630844), g, v, n[e + 7], 10, 1126891415), l, g, n[e + 14], 15, -1416354905), m, l, n[e + 5], 21, -57434055), v = f(v, m = f(m, l = f(l, g, v, m, n[e + 12], 6, 1700485571), g, v, n[e + 3], 10, -1894986606), l, g, n[e + 10], 15, -1051523), m, l, n[e + 1], 21, -2054922799), v = f(v, m = f(m, l = f(l, g, v, m, n[e + 8], 6, 1873313359), g, v, n[e + 15], 10, -30611744), l, g, n[e + 6], 15, -1560198380), m, l, n[e + 13], 21, 1309151649), v = f(v, m = f(m, l = f(l, g, v, m, n[e + 4], 6, -145523070), g, v, n[e + 11], 10, -1120210379), l, g, n[e + 2], 15, 718787259), m, l, n[e + 9], 21, -343485551), l = t(l, i), g = t(g, a), v = t(v, d), m = t(m, h); return [l, g, v, m] } function a(n) { var t, r = "", e = 32 * n.length; for (t = 0; t < e; t += 8)r += String.fromCharCode(n[t >> 5] >>> t % 32 & 255); return r } function d(n) { var t, r = []; for (r[(n.length >> 2) - 1] = void 0, t = 0; t < r.length; t += 1)r[t] = 0; var e = 8 * n.length; for (t = 0; t < e; t += 8)r[t >> 5] |= (255 & n.charCodeAt(t / 8)) << t % 32; return r } function h(n) { return a(i(d(n), 8 * n.length)) } function l(n, t) { var r, e, o = d(n), u = [], c = []; for (u[15] = c[15] = void 0, o.length > 16 && (o = i(o, 8 * n.length)), r = 0; r < 16; r += 1)u[r] = 909522486 ^ o[r], c[r] = 1549556828 ^ o[r]; return e = i(u.concat(d(t)), 512 + 8 * t.length), a(i(c.concat(e), 640)) } function g(n) { var t, r, e = ""; for (r = 0; r < n.length; r += 1)t = n.charCodeAt(r), e += "0123456789abcdef".charAt(t >>> 4 & 15) + "0123456789abcdef".charAt(15 & t); return e } function v(n) { return unescape(encodeURIComponent(n)) } function m(n) { return h(v(n)) } function p(n) { return g(m(n)) } function s(n, t) { return l(v(n), v(t)) } function C(n, t) { return g(s(n, t)) } function A(n, t, r) { return t ? r ? s(t, n) : C(t, n) : r ? m(n) : p(n) } $.md5 = A }(this); +function Env(t, e) { "undefined" != typeof process && JSON.stringify(process.env).indexOf("GITHUB") > -1 && process.exit(0); class s { constructor(t) { this.env = t } send(t, e = "GET") { t = "string" == typeof t ? { url: t } : t; let s = this.get; return "POST" === e && (s = this.post), new Promise((e, i) => { s.call(this, t, (t, s, r) => { t ? i(t) : e(s) }) }) } get(t) { return this.send.call(this.env, t) } post(t) { return this.send.call(this.env, t, "POST") } } return new class { constructor(t, e) { this.name = t, this.http = new s(this), this.data = null, this.dataFile = "box.dat", this.logs = [], this.isMute = !1, this.isNeedRewrite = !1, this.logSeparator = "\n", this.startTime = (new Date).getTime(), Object.assign(this, e), this.log("", `🔔${this.name}, 开始!`) } isNode() { return "undefined" != typeof module && !!module.exports } isQuanX() { return "undefined" != typeof $task } isSurge() { return "undefined" != typeof $httpClient && "undefined" == typeof $loon } isLoon() { return "undefined" != typeof $loon } toObj(t, e = null) { try { return JSON.parse(t) } catch { return e } } toStr(t, e = null) { try { return JSON.stringify(t) } catch { return e } } getjson(t, e) { let s = e; const i = this.getdata(t); if (i) try { s = JSON.parse(this.getdata(t)) } catch { } return s } setjson(t, e) { try { return this.setdata(JSON.stringify(t), e) } catch { return !1 } } getScript(t) { return new Promise(e => { this.get({ url: t }, (t, s, i) => e(i)) }) } runScript(t, e) { return new Promise(s => { let i = this.getdata("@chavy_boxjs_userCfgs.httpapi"); i = i ? i.replace(/\n/g, "").trim() : i; let r = this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout"); r = r ? 1 * r : 20, r = e && e.timeout ? e.timeout : r; const [o, h] = i.split("@"), n = { url: `http://${h}/v1/scripting/evaluate`, body: { script_text: t, mock_type: "cron", timeout: r }, headers: { "X-Key": o, Accept: "*/*" } }; this.post(n, (t, e, i) => s(i)) }).catch(t => this.logErr(t)) } loaddata() { if (!this.isNode()) return {}; { this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path"); const t = this.path.resolve(this.dataFile), e = this.path.resolve(process.cwd(), this.dataFile), s = this.fs.existsSync(t), i = !s && this.fs.existsSync(e); if (!s && !i) return {}; { const i = s ? t : e; try { return JSON.parse(this.fs.readFileSync(i)) } catch (t) { return {} } } } } writedata() { if (this.isNode()) { this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path"); const t = this.path.resolve(this.dataFile), e = this.path.resolve(process.cwd(), this.dataFile), s = this.fs.existsSync(t), i = !s && this.fs.existsSync(e), r = JSON.stringify(this.data); s ? this.fs.writeFileSync(t, r) : i ? this.fs.writeFileSync(e, r) : this.fs.writeFileSync(t, r) } } lodash_get(t, e, s) { const i = e.replace(/\[(\d+)\]/g, ".$1").split("."); let r = t; for (const t of i) if (r = Object(r)[t], void 0 === r) return s; return r } lodash_set(t, e, s) { return Object(t) !== t ? t : (Array.isArray(e) || (e = e.toString().match(/[^.[\]]+/g) || []), e.slice(0, -1).reduce((t, s, i) => Object(t[s]) === t[s] ? t[s] : t[s] = Math.abs(e[i + 1]) >> 0 == +e[i + 1] ? [] : {}, t)[e[e.length - 1]] = s, t) } getdata(t) { let e = this.getval(t); if (/^@/.test(t)) { const [, s, i] = /^@(.*?)\.(.*?)$/.exec(t), r = s ? this.getval(s) : ""; if (r) try { const t = JSON.parse(r); e = t ? this.lodash_get(t, i, "") : e } catch (t) { e = "" } } return e } setdata(t, e) { let s = !1; if (/^@/.test(e)) { const [, i, r] = /^@(.*?)\.(.*?)$/.exec(e), o = this.getval(i), h = i ? "null" === o ? null : o || "{}" : "{}"; try { const e = JSON.parse(h); this.lodash_set(e, r, t), s = this.setval(JSON.stringify(e), i) } catch (e) { const o = {}; this.lodash_set(o, r, t), s = this.setval(JSON.stringify(o), i) } } else s = this.setval(t, e); return s } getval(t) { return this.isSurge() || this.isLoon() ? $persistentStore.read(t) : this.isQuanX() ? $prefs.valueForKey(t) : this.isNode() ? (this.data = this.loaddata(), this.data[t]) : this.data && this.data[t] || null } setval(t, e) { return this.isSurge() || this.isLoon() ? $persistentStore.write(t, e) : this.isQuanX() ? $prefs.setValueForKey(t, e) : this.isNode() ? (this.data = this.loaddata(), this.data[e] = t, this.writedata(), !0) : this.data && this.data[e] || null } initGotEnv(t) { this.got = this.got ? this.got : require("got"), this.cktough = this.cktough ? this.cktough : require("tough-cookie"), this.ckjar = this.ckjar ? this.ckjar : new this.cktough.CookieJar, t && (t.headers = t.headers ? t.headers : {}, void 0 === t.headers.Cookie && void 0 === t.cookieJar && (t.cookieJar = this.ckjar)) } get(t, e = (() => { })) { t.headers && (delete t.headers["Content-Type"], delete t.headers["Content-Length"]), this.isSurge() || this.isLoon() ? (this.isSurge() && this.isNeedRewrite && (t.headers = t.headers || {}, Object.assign(t.headers, { "X-Surge-Skip-Scripting": !1 })), $httpClient.get(t, (t, s, i) => { !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i) })) : this.isQuanX() ? (this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, { hints: !1 })), $task.fetch(t).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => e(t))) : this.isNode() && (this.initGotEnv(t), this.got(t).on("redirect", (t, e) => { try { if (t.headers["set-cookie"]) { const s = t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString(); s && this.ckjar.setCookieSync(s, null), e.cookieJar = this.ckjar } } catch (t) { this.logErr(t) } }).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => { const { message: s, response: i } = t; e(s, i, i && i.body) })) } post(t, e = (() => { })) { if (t.body && t.headers && !t.headers["Content-Type"] && (t.headers["Content-Type"] = "application/x-www-form-urlencoded"), t.headers && delete t.headers["Content-Length"], this.isSurge() || this.isLoon()) this.isSurge() && this.isNeedRewrite && (t.headers = t.headers || {}, Object.assign(t.headers, { "X-Surge-Skip-Scripting": !1 })), $httpClient.post(t, (t, s, i) => { !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i) }); else if (this.isQuanX()) t.method = "POST", this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, { hints: !1 })), $task.fetch(t).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => e(t)); else if (this.isNode()) { this.initGotEnv(t); const { url: s, ...i } = t; this.got.post(s, i).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => { const { message: s, response: i } = t; e(s, i, i && i.body) }) } } time(t, e = null) { const s = e ? new Date(e) : new Date; let i = { "M+": s.getMonth() + 1, "d+": s.getDate(), "H+": s.getHours(), "m+": s.getMinutes(), "s+": s.getSeconds(), "q+": Math.floor((s.getMonth() + 3) / 3), S: s.getMilliseconds() }; /(y+)/.test(t) && (t = t.replace(RegExp.$1, (s.getFullYear() + "").substr(4 - RegExp.$1.length))); for (let e in i) new RegExp("(" + e + ")").test(t) && (t = t.replace(RegExp.$1, 1 == RegExp.$1.length ? i[e] : ("00" + i[e]).substr(("" + i[e]).length))); return t } msg(e = t, s = "", i = "", r) { const o = t => { if (!t) return t; if ("string" == typeof t) return this.isLoon() ? t : this.isQuanX() ? { "open-url": t } : this.isSurge() ? { url: t } : void 0; if ("object" == typeof t) { if (this.isLoon()) { let e = t.openUrl || t.url || t["open-url"], s = t.mediaUrl || t["media-url"]; return { openUrl: e, mediaUrl: s } } if (this.isQuanX()) { let e = t["open-url"] || t.url || t.openUrl, s = t["media-url"] || t.mediaUrl; return { "open-url": e, "media-url": s } } if (this.isSurge()) { let e = t.url || t.openUrl || t["open-url"]; return { url: e } } } }; if (this.isMute || (this.isSurge() || this.isLoon() ? $notification.post(e, s, i, o(r)) : this.isQuanX() && $notify(e, s, i, o(r))), !this.isMuteLog) { let t = ["", "==============📣系统通知📣=============="]; t.push(e), s && t.push(s), i && t.push(i), console.log(t.join("\n")), this.logs = this.logs.concat(t) } } log(...t) { t.length > 0 && (this.logs = [...this.logs, ...t]), console.log(t.join(this.logSeparator)) } logErr(t, e) { const s = !this.isSurge() && !this.isQuanX() && !this.isLoon(); s ? this.log("", `❗️${this.name}, 错误!`, t.stack) : this.log("", `❗️${this.name}, 错误!`, t) } wait(t) { return new Promise(e => setTimeout(e, t)) } done(t = {}) { const e = (new Date).getTime(), s = (e - this.startTime) / 1e3; this.log("", `🔔${this.name}, 结束! 🕛 ${s} 秒`), this.log(), (this.isSurge() || this.isQuanX() || this.isLoon()) && $done(t) } }(t, e) } \ No newline at end of file diff --git a/activity/jd_opencardL51.js b/activity/jd_opencardL51.js new file mode 100644 index 0000000..a14d71b --- /dev/null +++ b/activity/jd_opencardL51.js @@ -0,0 +1,821 @@ +/* +2022.1.18-1.24 会员联合盛典 瓜分百万京豆 + + +第一个账号助力作者 其他依次助力CK1 +第一个CK失效会退出脚本 + +———————————————— +入口:https://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=dzlhkklblzms20220108&shareUuid=3f2e798615e14640b1760672731bea6f + +请求太频繁会被黑ip +过10分钟再执行 + + +cron:1 4,19 18-24 1 * +============Quantumultx=============== +[task_local] +#2022.1.18-1.24 会员联合盛典 瓜分百万京豆 +1 4,19 18-24 1 * https://raw.githubusercontent.com/KingRan/JDJB/main/jd_opencardL51.js, tag=2022.1.18-1.24 会员联合盛典 瓜分百万京豆, enabled=true + +*/ +const $ = new Env("2022.1.18-1.24 会员联合盛典 瓜分百万京豆"); +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const notify = $.isNode() ? require('./sendNotify') : ''; +//IOS等用户直接用NobyDa的jd cookie + +let cookiesArr = [], + cookie = ''; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} +allMessage = "" +message = "" +$.hotFlag = false +$.outFlag = false +$.activityEnd = false +let lz_jdpin_token_cookie ='' +let activityCookie ='' +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', { + "open-url": "https://bean.m.jd.com/" + }); + return; + } + $.activityId = "dzlhkklblsifkpeq0118" + $.shareUuid = "3f2e798615e14640b1760672731bea6f" + console.log(`入口:\nhttps://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}`) + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i]; + if (cookie) { + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + message = "" + $.bean = 0 + $.hotFlag = false + $.nickName = ''; + console.log(`\n\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + await getUA() + await run(); + if(i == 0 && !$.actorUuid) break + if($.outFlag || $.activityEnd) break + } + } + if($.outFlag) { + let msg = '此ip已被限制,请过10分钟后再执行脚本' + $.msg($.name, ``, `${msg}`); + if ($.isNode()) await notify.sendNotify(`${$.name}`, `${msg}`); + } +})() + .catch((e) => $.logErr(e)) + .finally(() => $.done()) + + +async function run() { + try { + $.hasEnd = true + $.endTime = 0 + lz_jdpin_token_cookie = '' + $.Token = '' + $.Pin = '' + let flag = false + await takePostRequest('isvObfuscator'); + if($.Token == ''){ + console.log('获取[token]失败!') + return + } + await getCk() + if (activityCookie == '') { + console.log(`获取cookie失败`); return; + } + if($.activityEnd === true){ + console.log('活动结束') + return + } + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + await takePostRequest('getSimpleActInfoVo'); + await takePostRequest('getMyPing'); + if(!$.Pin){ + console.log('获取[Pin]失败!') + return + } + await takePostRequest('accessLogWithAD'); + await takePostRequest('getUserInfo'); + await takePostRequest('activityContent'); + if($.hotFlag) return + if(!$.actorUuid){ + console.log('获取不到[actorUuid]退出执行,请重新执行') + return + } + // console.log($.actorUuid) + // return + if($.hasEnd === true || Date.now() > $.endTime){ + $.activityEnd = true + console.log('活动结束') + return + } + await takePostRequest('drawContent'); + await $.wait(1000) + $.openList = [] + $.allOpenCard = false + await takePostRequest('info'); + await takePostRequest('checkOpenCard'); + if($.allOpenCard == false){ + console.log('开卡任务') + for(o of $.openList){ + $.openCard = false + if(o.status == 0){ + flag = true + $.joinVenderId = o.venderId + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + await joinShop() + await $.wait(parseInt(Math.random() * 1000 + 1000, 10)) + await takePostRequest('activityContent'); + await takePostRequest('drawContent'); + await takePostRequest('checkOpenCard'); + await $.wait(parseInt(Math.random() * 3000 + 2000, 10)) + } + } + }else{ + console.log('已全部开卡') + } + + $.log("关注: " + $.followShop) + if(!$.followShop && !$.outFlag){ + flag = true + await takePostRequest('followShop'); + await $.wait(parseInt(Math.random() * 2000 + 3000, 10)) + } + $.yaoqing = false + await takePostRequest('邀请'); + if($.yaoqing){ + await takePostRequest('助力'); + } + $.log("加购: " + $.addCart) + if(!$.addCart && !$.outFlag){ + flag = true + await takePostRequest('addCart'); + await $.wait(parseInt(Math.random() * 2000 + 4000, 10)) + } + $.runFalag = true + $.log("浏览商品: " + $.visitSku) + if(!$.visitSku && !$.outFlag){ + flag = true + for(let v of $.visitSkuList || []){ + if($.runFalag == false) break + if(v.goodsCode && v.status === 0){ + $.visitSkuValue = v.goodsCode + await takePostRequest('browseGoods'); + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + } + } + } + $.runFalag = true + let count = parseInt($.drawCount, 10) + console.log(`抽奖次数为:${count}`) + for(m=1;count--;m++){ + console.log(`第${m}次抽奖`) + await takePostRequest('startDraw'); + if($.runFalag == false) break + if(Number(count) <= 0) break + if(m >= 30){ + console.log("抽奖太多次,多余的次数请再执行脚本") + break + } + await $.wait(parseInt(Math.random() * 2000 + 2000, 10)) + } + if(flag){ + await takePostRequest('activityContent'); + } + console.log(`${$.score}值 游戏:${$.point}`) + $.runFalag = true + count = parseInt($.score/100) + console.log(`抽奖次数为:${count}`) + for(m=1;count--;m++){ + console.log(`第${m}次抽奖`) + await takePostRequest('抽奖'); + if($.runFalag == false) break + if(Number(count) <= 0) break + if(m >= 10){ + console.log("抽奖太多次,多余的次数请再执行脚本") + break + } + await $.wait(parseInt(Math.random() * 2000 + 2000, 10)) + } + + await $.wait(parseInt(Math.random() * 1000 + 2000, 10)) + await takePostRequest('getDrawRecordHasCoupon'); + await takePostRequest('getShareRecord'); + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + console.log($.actorUuid) + console.log(`当前助力:${$.shareUuid}`) + if($.index == 1){ + $.shareUuid = $.actorUuid + console.log(`后面的号都会助力:${$.shareUuid}`) + } + await $.wait(parseInt(Math.random() * 1000 + 5000, 10)) + if(flag) await $.wait(parseInt(Math.random() * 1000 + 10000, 10)) + + if($.index % 3 == 0) console.log('休息1分钟,别被黑ip了\n可持续发展') + if($.index % 3 == 0) await $.wait(parseInt(Math.random() * 5000 + 60000, 10)) + + } catch (e) { + console.log(e) + } +} + +async function takePostRequest(type) { + if($.outFlag) return + let domain = 'https://lzdz1-isv.isvjcloud.com'; + let body = ``; + let method = 'POST' + let admJson = '' + switch (type) { + case 'isvObfuscator': + url = `https://api.m.jd.com/client.action?functionId=isvObfuscator`; + body = `body=%7B%22url%22%3A%22https%3A//lzdz1-isv.isvjcloud.com%22%2C%22id%22%3A%22%22%7D&uuid=7088d9018515b8cb0c88ace6e5479762af3e88f3&client=apple&clientVersion=10.1.4&st=1634343624086&sv=120&sign=8b9cea22c3a0d77026abda5d37d2b7e3`; + break; + case 'getSimpleActInfoVo': + url = `${domain}/dz/common/getSimpleActInfoVo`; + body = `activityId=${$.activityId}`; + break; + case 'getMyPing': + url = `${domain}/customer/getMyPing`; + body = `userId=${$.shopId || $.venderId || ''}&token=${$.Token}&fromType=APP`; + break; + case 'accessLogWithAD': + url = `${domain}/common/accessLogWithAD`; + let pageurl = `${domain}/drawCenter/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}` + body = `venderId=${$.shopId || $.venderId || ''}&code=99&pin=${encodeURIComponent($.Pin)}&activityId=${$.activityId}&pageUrl=${encodeURIComponent(pageurl)}&subType=app&adSource=` + break; + case 'getUserInfo': + url = `${domain}/wxActionCommon/getUserInfo`; + body = `pin=${encodeURIComponent($.Pin)}`; + break; + case 'activityContent': + url = `${domain}/dingzhi/linkgame/activity/content`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&pinImg=${encodeURIComponent($.attrTouXiang)}&nick=${encodeURIComponent($.nickname)}&cjyxPin=&cjhyPin=&shareUuid=${$.shareUuid}` + break; + case 'drawContent': + url = `${domain}/dingzhi/taskact/common/drawContent`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case 'checkOpenCard': + url = `${domain}/dingzhi/linkgame/checkOpenCard`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case 'info': + url = `${domain}/dingzhi/linkgame/task/info`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case 'startDraw': + url = `${domain}/dingzhi/linkgame/draw/bean`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case 'followShop': + url = `${domain}/dingzhi/linkgame/follow/shop`; + // url = `${domain}/dingzhi/dz/openCard/saveTask`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case 'sign': + case 'addCart': + case 'browseGoods': + url = `${domain}/dingzhi/linkgame/${type}`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + if(type == 'browseGoods') body += `&value=${$.visitSkuValue}` + break; + case '邀请': + case '助力': + if(type == '助力'){ + url = `${domain}/dingzhi/linkgame/assist`; + }else{ + url = `${domain}/dingzhi/linkgame/assist/status`; + } + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&shareUuid=${$.shareUuid}` + break; + case 'viewVideo': + case 'visitSku': + case 'toShop': + case 'addSku': + url = `${domain}/dingzhi/dz/openCard/saveTask`; + let taskType = '' + let taskValue = '' + if(type == 'viewVideo'){ + taskType = 31 + taskValue = 31 + }else if(type == 'visitSku'){ + taskType = 5 + taskValue = $.visitSkuValue || 5 + }else if(type == 'toShop'){ + taskType = 14 + taskValue = $.toShopValue || 14 + }else if(type == 'addSku'){ + taskType = 2 + taskValue = $.addSkuValue || 2 + } + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&taskType=${taskType}&taskValue=${taskValue}` + break; + case 'getDrawRecordHasCoupon': + url = `${domain}/dingzhi/linkgame/draw/record`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case 'getShareRecord': + url = `${domain}/dingzhi/linkgame/help/list`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case '抽奖': + url = `${domain}/dingzhi/linkgame/draw`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + default: + console.log(`错误${type}`); + } + let myRequest = getPostRequest(url, body, method); + // console.log(myRequest) + return new Promise(async resolve => { + $.post(myRequest, (err, resp, data) => { + try { + setActivityCookie(resp) + if (err) { + if(resp && typeof resp.statusCode != 'undefined'){ + if(resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + } + console.log(`${$.toStr(err,err)}`) + console.log(`${type} API请求失败,请检查网路重试`) + } else { + dealReturn(type, data); + } + } catch (e) { + // console.log(data); + console.log(e, resp) + } finally { + resolve(); + } + }) + }) + } + +async function dealReturn(type, data) { + let res = '' + try { + if(type != 'accessLogWithAD' || type != 'drawContent'){ + if(data){ + res = JSON.parse(data); + } + } + } catch (e) { + console.log(`${type} 执行任务异常`); + console.log(data); + $.runFalag = false; + } + try { + switch (type) { + case 'isvObfuscator': + if(typeof res == 'object'){ + if(res.errcode == 0){ + if(typeof res.token != 'undefined') $.Token = res.token + }else if(res.message){ + console.log(`isvObfuscator ${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + break; + case 'getSimpleActInfoVo': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(typeof res.data.shopId != 'undefined') $.shopId = res.data.shopId + if(typeof res.data.venderId != 'undefined') $.venderId = res.data.venderId + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getMyPing': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(res.data && typeof res.data.secretPin != 'undefined') $.Pin = res.data.secretPin + if(res.data && typeof res.data.nickname != 'undefined') $.nickname = res.data.nickname + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getUserInfo': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(res.data && typeof res.data.yunMidImageUrl != 'undefined') $.attrTouXiang = res.data.yunMidImageUrl || "https://img10.360buyimg.com/imgzone/jfs/t1/7020/27/13511/6142/5c5138d8E4df2e764/5a1216a3a5043c5d.png" + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'activityContent': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + $.endTime = res.data.endTime || res.data.activity.endTime || 0 + $.hasEnd = res.data.isEnd || false + $.drawCount = res.data.actor.drawCount || 0 + $.point = res.data.actor.point || 0 + $.score = res.data.actor.score || 0 + $.actorUuid = res.data.actor.actorUuid || '' + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'info': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + // $.drawCount = res.data.drawCount || 0 + $.addCart = res.data.addCart || false + $.followShop = res.data.followShop || false + $.sign = res.data.sign || false + $.visitSku = res.data.visitSku || false + $.visitSkuList = res.data.visitSkuList || [] + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'checkOpenCard': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + let cardList1 = res.data.cardList1 || [] + let cardList2 = res.data.cardList2 || [] + let cardList = res.data.cardList || [] + let openCardList = res.data.openCardList || [] + $.openList = [...cardList,...cardList1,...cardList2,...openCardList] + $.allOpenCard = res.data.allOpenCard || false + $.openCardScore1 = res.data.score1 || 0 + $.openCardScore2 = res.data.score2 || 0 + $.drawScore = res.data.drawScore || 0 + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'startDraw': + case 'followShop': + case 'viewVideo': + case 'visitSku': + case 'toShop': + case 'addSku': + case 'sign': + case 'addCart': + case 'browseGoods': + case '抽奖': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(typeof res.data == 'object'){ + let msg = '' + let title = '抽奖' + if(res.data.addBeanNum){ + msg = `${res.data.addBeanNum}京豆` + } + if(res.data.addPoint){ + msg += ` ${res.data.addPoint}游戏机会` + } + if(type == 'followShop'){ + title = '关注' + if(res.data.beanNumMember && res.data.assistSendStatus){ + msg += ` 额外获得:${res.data.beanNumMember}京豆` + } + }else if(type == 'addSku' || type == 'addCart'){ + title = '加购' + }else if(type == 'viewVideo'){ + title = '热门文章' + }else if(type == 'toShop'){ + title = '浏览店铺' + }else if(type == 'visitSku' || type == 'browseGoods'){ + title = '浏览商品' + }else if(type == 'sign'){ + title = '签到' + }else{ + msg = res.data.drawOk == true && (res.data.drawInfoType == 6 && res.data.name || '') || '空气💨' + } + if(!msg){ + msg = '空气💨' + } + console.log(`${title}获得:${msg || data}`) + }else{ + console.log(`${type} ${data}`) + } + }else if(res.errorMessage){ + $.runFalag = false; + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getDrawRecordHasCoupon': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + console.log(`我的奖品:`) + let num = 0 + let value = 0 + for(let i in res.data.recordList){ + let item = res.data.recordList[i] + if(item.infoName == '20京豆'){ + num++ + value = item.infoName.replace('京豆','') + }else{ + console.log(`${item.infoType != 10 && item.value && item.value +':' || ''}${item.infoName}`) + } + } + if(num > 0) console.log(`邀请好友(${num}):${num*parseInt(value, 10) || 30}京豆`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getShareRecord': + if(typeof res == 'object'){ + if(res.result && res.result === true && res.data){ + $.ShareCount = res.data.shareList.length + $.log(`=========== 你邀请了:${res.data.shareList.length}个`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case '邀请': + case '助力': + // console.log(data) + if(typeof res == 'object'){ + if(res.data.status == 200){ + if(type == '助力'){ + console.log('助力成功') + }else{ + $.yaoqing = true + } + }else if(res.data.status == 105){ + console.log('已经助力过') + }else if(res.data.status == 104){ + console.log('已经助力其他人') + }else if(res.data.status == 101){ + // console.log('已经助力过') + }else{ + console.log(data) + } + }else{ + console.log(`${type} ${data}`) + } + + case 'accessLogWithAD': + case 'drawContent': + break; + default: + console.log(`${type}-> ${data}`); + } + if(typeof res == 'object'){ + if(res.errorMessage){ + if(res.errorMessage.indexOf('火爆') >-1 ){ + $.hotFlag = true + } + } + } + } catch (e) { + console.log(e) + } +} + +function getPostRequest(url, body, method="POST") { + let headers = { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Content-Type": "application/x-www-form-urlencoded", + "Cookie": cookie, + "User-Agent": $.UA, + "X-Requested-With": "XMLHttpRequest" + } + if(url.indexOf('https://lzdz1-isv.isvjcloud.com') > -1){ + headers["Referer"] = `https://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}` + headers["Cookie"] = `${lz_jdpin_token_cookie && lz_jdpin_token_cookie || ''}${$.Pin && "AUTH_C_USER=" + $.Pin + ";" || ""}${activityCookie}` + } + // console.log(headers) + // console.log(headers.Cookie) + return {url: url, method: method, headers: headers, body: body, timeout:30000}; +} + +function getCk() { + return new Promise(resolve => { + let get = { + url:`https://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}`, + followRedirect:false, + headers: { + "User-Agent": $.UA, + }, + timeout:30000 + } + $.get(get, async(err, resp, data) => { + try { + if (err) { + if(resp && typeof resp.statusCode != 'undefined'){ + if(resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + } + console.log(`${$.toStr(err)}`) + console.log(`${$.name} cookie API请求失败,请检查网路重试`) + } else { + let end = data.match(/(活动已经结束)/) && data.match(/(活动已经结束)/)[1] || '' + if(end){ + $.activityEnd = true + console.log('活动已结束') + } + setActivityCookie(resp) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function setActivityCookie(resp){ + let LZ_TOKEN_KEY = '' + let LZ_TOKEN_VALUE = '' + let lz_jdpin_token = '' + let setcookies = resp && resp['headers'] && (resp['headers']['set-cookie'] || resp['headers']['Set-Cookie'] || '') || '' + let setcookie = '' + if(setcookies){ + if(typeof setcookies != 'object'){ + setcookie = setcookies.split(',') + }else setcookie = setcookies + for (let ck of setcookie) { + let name = ck.split(";")[0].trim() + if(name.split("=")[1]){ + // console.log(name.replace(/ /g,'')) + if(name.indexOf('LZ_TOKEN_KEY=')>-1) LZ_TOKEN_KEY = name.replace(/ /g,'')+';' + if(name.indexOf('LZ_TOKEN_VALUE=')>-1) LZ_TOKEN_VALUE = name.replace(/ /g,'')+';' + if(name.indexOf('lz_jdpin_token=')>-1) lz_jdpin_token = ''+name.replace(/ /g,'')+';' + } + } + } + if(LZ_TOKEN_KEY && LZ_TOKEN_VALUE) activityCookie = `${LZ_TOKEN_KEY} ${LZ_TOKEN_VALUE}` + if(lz_jdpin_token) lz_jdpin_token_cookie = lz_jdpin_token +} + +async function getUA(){ + $.UA = `jdapp;iPhone;10.1.4;13.1.2;${randomString(40)};network/wifi;model/iPhone8,1;addressid/2308460611;appBuild/167814;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_1_2 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 joinShop() { + if(!$.joinVenderId) return + return new Promise(async resolve => { + $.shopactivityId = '' + await $.wait(1000) + await getshopactivityId() + let activityId = `` + if($.shopactivityId) activityId = `,"activityId":${$.shopactivityId}` + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body={"venderId":"${$.joinVenderId}","shopId":"${$.joinVenderId}","bindByVerifyCodeFlag":1,"registerExtend":{},"writeChildFlag":0${activityId},"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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + // console.log(data) + let res = $.toObj(data); + if(typeof res == 'object'){ + if(res.success === true){ + console.log(res.message) + if(res.result && res.result.giftInfo){ + for(let i of res.result.giftInfo.giftList){ + console.log(`入会获得:${i.discountString}${i.prizeName}${i.secondLineDesc}`) + } + } + }else if(typeof res == 'object' && res.message){ + console.log(`${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function getshopactivityId() { + return new Promise(resolve => { + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body=%7B%22venderId%22%3A%22${$.joinVenderId}%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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + let res = $.toObj(data); + if(res.success == true){ + // console.log($.toStr(res.result)) + console.log(`入会:${res.result.shopMemberCardInfo.venderCardName || ''}`) + $.shopactivityId = res.result.interestsRuleList && res.result.interestsRuleList[0] && res.result.interestsRuleList[0].interestsInfo && res.result.interestsRuleList[0].interestsInfo.activityId || '' + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} + + +// 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)} diff --git a/activity/jd_opencardL53.js b/activity/jd_opencardL53.js new file mode 100644 index 0000000..078cc2a --- /dev/null +++ b/activity/jd_opencardL53.js @@ -0,0 +1,547 @@ +/* +1.20~1.26 联合开卡 瓜分千万京豆 +新增开卡脚本,一次性脚本 + +第一个账号助力作者 其他依次助力CK1 +第一个CK失效会退出脚本 + +———————————————— +入口:[ 1.20~1.26 联合开卡 瓜分千万京豆 (https://jinggengjcq-isv.isvjcloud.com/fronth5/#/pages/unitedCardNew2022012003/unitedCardNew2022012003?actId=3aa3722371d5433a9cf9_22012001)] + +请求太频繁会被黑ip +过10分钟再执行 + + +cron:1 0,14 20-26 1 * +============Quantumultx=============== +[task_local] +#1.20~1.26 联合开卡 瓜分千万京豆 +1 0,14 20-26 1 * jd_opencardL53.js, tag=1.20~1.26 联合开卡 瓜分千万京豆, enabled=true + +*/ + +const $ = new Env('1.20~1.26 联合开卡 瓜分千万京豆'); +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const notify = $.isNode() ? require('./sendNotify') : ''; + +//IOS等用户直接用NobyDa的jd cookie +let cookiesArr = [], + cookie = ''; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} + +allMessage = "" +message = "" +$.hotFlag = false +$.outFlag = false +$.activityEnd = false +let lz_jdpin_token_cookie ='' +let activityCookie ='' +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', { + "open-url": "https://bean.m.jd.com/" + }); + return; + } + // return + $.appkey = '51B59BB805903DA4CE513D29EC448375' + $.userId = '10299171' + $.actId = '3aa3722371d5433a9cf9_22012001' + $.MixNicks = '' + $.inviteNick = 'k1Nobb+P0er+C2sysxnx/P2KELO9izRVpwCyqu0eqVZ5aW7RHzlMobrzJ/e9r/uf' + console.log(`活动地址:https://jinggengjcq-isv.isvjcloud.com/fronth5/#/pages/unitedCardNew2022012003/unitedCardNew2022012003?actId=3aa3722371d5433a9cf9_22012001`) + console.log(`请自行测试有水无水。`) + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i]; + if (cookie) { + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + message = "" + $.bean = 0 + $.hotFlag = false + $.nickName = ''; + console.log(`\n\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + await getUA() + await run(); + if(i == 0 && !$.MixNick) break + if($.outFlag || $.activityEnd) break + } + } + if($.outFlag) { + let msg = '此ip已被限制,请过10分钟后再执行脚本' + $.msg($.name, ``, `${msg}`); + if ($.isNode()) await notify.sendNotify(`${$.name}`, `${msg}`); + } +})() + .catch((e) => $.logErr(e)) + .finally(() => $.done()) + + +async function run() { + try { + $.hasEnd = true + $.endTime = 0 + lz_jdpin_token_cookie = '' + $.Token = '' + $.Pin = '' + $.MixNick = '' + let flag = false + if($.activityEnd) return + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + await takePostRequest('isvObfuscator'); + if($.Token == ''){ + console.log('获取[token]失败!') + return + } + await takePostRequest('activity_load'); + if($.hotFlag) return + if(Date.now() > $.endTime){ + $.MixNick = '' + $.activityEnd = true + console.log('活动结束') + return + } + if ($.MixNick == '') { + console.log(`获取cookie失败`); return; + } + // console.log($.MixNick) + // return + $.toBind = 0 + $.openList = [] + await takePostRequest('绑定'); + await takePostRequest('shopList'); + if($.activityEnd) return + for(o of $.openList){ + $.missionType = 'openCard' + if(o.open != true && o.openCardUrl){ + if($.activityEnd) return + $.openCard = false + $.joinVenderId = o.userId + await takePostRequest('mission'); + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + if($.openCard == true){ + await joinShop() + await takePostRequest('activity_load'); + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + // break + } + $.joinVenderId = '' + } + } + $.joinVenderId = '' + if($.hasCollectShop === 0){ + // 关注 + $.missionType = 'uniteCollectShop' + await takePostRequest('mission'); + await $.wait(parseInt(Math.random() * 2000 + 3000, 10)) + }else{ + console.log('已经关注') + } + $.missionType = 'uniteAddCart' + + await takePostRequest('mission'); + await $.wait(parseInt(Math.random() * 2000 + 3000, 10)) + await takePostRequest('activity_load'); + $.runFalag = true + let count = parseInt($.usedChance, 10) + console.log(`抽奖次数为:${count}`) + for(m=1;count--;m++){ + console.log(`第${m}次抽奖`) + await takePostRequest('抽奖'); + if($.runFalag == false) break + if(Number(count) <= 0) break + if(m >= 10){ + console.log("抽奖太多次,多余的次数请再执行脚本") + break + } + await $.wait(parseInt(Math.random() * 2000 + 2000, 10)) + } + await takePostRequest('myAward'); + await takePostRequest('missionInviteList'); + console.log($.MixNick) + console.log(`当前助力:${$.inviteNick}`) + if($.index == 1){ + $.inviteNick = $.MixNick + console.log(`后面的号都会助力:${$.inviteNick}`) + } + await $.wait(parseInt(Math.random() * 1000 + 5000, 10)) + if(flag) await $.wait(parseInt(Math.random() * 1000 + 10000, 10)) + if($.index % 3 == 0) console.log('休息1分钟,别被黑ip了\n可持续发展') + if($.index % 3 == 0) await $.wait(parseInt(Math.random() * 5000 + 60000, 10)) + } catch (e) { + console.log(e) + } +} + +async function takePostRequest(type) { + if($.outFlag) return + let domain = 'https://jinggengjcq-isv.isvjcloud.com'; + let body = ``; + let method = 'POST' + let admJson = '' + switch (type) { + case 'isvObfuscator': + url = `https://api.m.jd.com/client.action?functionId=isvObfuscator`; + body = `body=%7B%22url%22%3A%22https%3A//jinggengjcq-isv.isvjcloud.com/fronth5/%3Flng%3D0%26lat%3D0%26sid%3D49687cd64aca2ae93aa43748a04e8f6w%26un_area%3D16_1315_1316_53522%23/pages/unitedCardNew20211010-ka/unitedCardNew20211010-ka%3FactId%3D9150e1d16b9d40_10101%22%2C%22id%22%3A%22%22%7D&uuid=b9b4ce69d42dacb64084279d51cdee764d7781fa&client=apple&clientVersion=10.1.4&st=1634100732991&sv=111&sign=67e254ffbcb13be9e12a9782c9cdf398`; + break; + case 'activity_load': + url = `${domain}/dm/front/openCardNew/activity_load?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"jdToken": $.Token, "source": "01", "inviteNick":($.inviteNick || "")} + if($.joinVenderId) admJson = {...admJson, "shopId": `${$.joinVenderId}`} + body = taskPostUrl("/openCardNew/activity_load", admJson); + break; + case 'shopList': + url = `${domain}/dm/front/openCardNew/shopList?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {} + body = taskPostUrl("/openCardNew/shopList", admJson); + break; + case '绑定': + url = `${domain}/dm/front/openCardNew/complete/mission?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"missionType": "relationBind", "inviterNick":($.inviteNick || "")} + body = taskPostUrl("/openCardNew/complete/mission", admJson); + break; + case 'mission': + url = `${domain}/dm/front/openCardNew/complete/mission?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"missionType": $.missionType} + if($.joinVenderId) admJson = {...admJson, "shopId": $.joinVenderId} + body = taskPostUrl("/openCardNew/complete/mission", admJson); + break; + case '抽奖': + url = `${domain}/dm/front/openCardNew/draw/post?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"dataType": "draw", "usedGameNum": "2"} + body = taskPostUrl("/openCardNew/draw/post", admJson); + break; + case 'followShop': + url = `${domain}/dm/front/openCardNew/followShop?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"actId": $.actId, "missionType": "collectShop"} + body = taskPostUrl("/openCardNew/followShop", admJson); + break; + case 'addCart': + url = `${domain}/dm/front/openCardNew/addCart?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"actId": $.actId, "missionType": "addCart"} + body = taskPostUrl("/openCardNew/addCart", admJson); + break; + case 'myAward': + url = `${domain}/dm/front/openCardNew/myAwards?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"pageNo": 1,"pageSize":9999} + body = taskPostUrl("/openCardNew/myAwards", admJson); + break; + case 'missionInviteList': + url = `${domain}/dm/front/openCardNew/missionInviteList?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"inviteListRequest":{"actId":$.actId,"userId":10299171,"missionType":"shareAct","inviteType": 1,"buyerNick":($.MixNick || '')}} + body = taskPostUrl("/openCardNew/missionInviteList", admJson); + break; + default: + console.log(`错误${type}`); + } + let myRequest = getPostRequest(url, body, method); + return new Promise(async resolve => { + $.post(myRequest, (err, resp, data) => { + try { + if (err) { + if(resp && resp.statusCode && resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + console.log(`${$.toStr(err,err)}`) + console.log(`${type} API请求失败,请检查网路重试`) + } else { + dealReturn(type, data); + } + } catch (e) { + // console.log(data); + console.log(e, resp) + } finally { + resolve(); + } + }) + }) + } + +async function dealReturn(type, data) { + let res = '' + try { + if(type != 'accessLogWithAD' || type != 'drawContent'){ + if(data){ + res = JSON.parse(data); + } + } + } catch (e) { + console.log(`${type} 执行任务异常`); + console.log(data); + $.runFalag = false; + } + try { + let title = '' + switch (type) { + case 'isvObfuscator': + if(typeof res == 'object'){ + if(res.errcode == 0){ + if(typeof res.token != 'undefined') $.Token = res.token + }else if(res.message){ + console.log(`${type} ${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + break; + case 'accessLogWithAD': + case 'drawContent': + break; + case 'activity_load': + case 'mission': + case 'shopList': + case 'loadUniteOpenCard': + case 'setMixNick': + case 'uniteOpenCardOne': + case 'checkOpenCard': + case 'followShop': + case 'addCart': + case 'myAward': + case 'missionInviteList': + case '抽奖': + title = '' + if(type == "followShop") title = '关注' + if(type == "addCart") title = '加购' + if(typeof res == 'object'){ + if(res.success && res.success === true && res.data){ + if(res.data.status && res.data.status == 200){ + res = res.data + if(type != "setMixNick" && (res.msg || res.data.isOpenCard || res.data.remark)) console.log(`${title && title+":" || ""}${res.msg || res.data.isOpenCard || res.data.remark || ''}`) + if(type == "activity_load"){ + if(res.msg || res.data.isOpenCard) { + if((res.msg || res.data.isOpenCard || '').indexOf('绑定成功') > -1) $.toBind = 1 + } + if(res.data){ + $.endTime = res.data.cusActivity.endTime || 0 + $.MixNick = res.data.buyerNick || "" + $.usedChance = res.data.missionCustomer.usedChance || 0 + $.hasCollectShop = res.data.missionCustomer.hasCollectShop || 0 + } + }else if(type == "shopList"){ + $.openList = res.data.cusShops || [] + }else if(type == "mission"){ + if(res.data.remark.indexOf('不是会员') > -1){ + $.openCard = true + }else{ + $.openCard = false + } + }else if(type == "uniteOpenCardOne"){ + $.uniteOpenCar = res.msg || res.data.msg || '' + }else if(type == "myAward"){ + console.log(`我的奖品:`) + let num = 0 + let value = 0 + for(let i in res.data.list || []){ + let item = res.data.list[i] + value += Number(item.awardDes) + } + if(value > 0) console.log(`共获得${value}京豆\n无法判断奖励是否为邀请奖励,所以直接显示获得多少豆\n`) + }else if(type == "missionInviteList"){ + console.log(`邀请人数(${res.data.invitedLogList.total})`) + } + }else if(res.data.msg){ + if(res.errorMessage.indexOf('活动未开始') >-1 ){ + $.activityEnd = true + } + console.log(`${title || type} ${res.data.msg || ''}`) + }else if(res.errorMessage){ + if(res.errorMessage.indexOf('火爆') >-1 ){ + $.hotFlag = true + } + console.log(`${title || type} ${res.errorMessage || ''}`) + }else{ + console.log(`${title || type} ${data}`) + } + }else if(res.errorMessage){ + console.log(`${title || type} ${res.errorMessage || ''}`) + }else{ + console.log(`${title || type} ${data}`) + } + }else{ + console.log(`${title || type} ${data}`) + } + break; + default: + console.log(`${title || type}-> ${data}`); + } + if(typeof res == 'object'){ + if(res.errorMessage){ + if(res.errorMessage.indexOf('火爆') >-1 ){ + $.hotFlag = true + } + } + } + } catch (e) { + console.log(e) + } +} + +function getPostRequest(url, body, method="POST") { + let headers = { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Content-Type": "application/x-www-form-urlencoded", + "Cookie": cookie, + "User-Agent": $.UA, + "X-Requested-With": "XMLHttpRequest" + } + if(url.indexOf('https://jinggengjcq-isv.isvjcloud.com') > -1){ + headers["Origin"] = `https://jinggengjcq-isv.isvjcloud.com` + headers["Content-Type"] = `application/json; charset=utf-8` + delete headers["Cookie"] + } + // console.log(headers) + // console.log(headers.Cookie) + return {url: url, method: method, headers: headers, body: body, timeout:60000}; +} + + +function taskPostUrl(url, t) { + + const b = { + "jsonRpc": "2.0", + "params": { + "commonParameter": { + "appkey": $.appkey, + "m": "POST", + "timestamp": Date.now(), + "userId": $.userId + }, + "admJson": { + "actId": $.actId, + "userId": $.userId, + ...t, + "method": url, + "buyerNick": ($.MixNick || ''), + } + }, + } + if(url.indexOf('missionInviteList') > -1){ + delete b.params.admJson.actId + } + return $.toStr(b,b) +} +async function getUA(){ + $.UA = `jdapp;iPhone;10.1.4;13.1.2;${randomString(40)};network/wifi;model/iPhone8,1;addressid/2308460611;appBuild/167814;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_1_2 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 jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} + +function joinShop() { + if(!$.joinVenderId) return + return new Promise(async resolve => { + $.shopactivityId = '' + await $.wait(1000) + await getshopactivityId() + let activityId = `` + if($.shopactivityId) activityId = `,"activityId":${$.shopactivityId}` + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body={"venderId":"${$.joinVenderId}","shopId":"${$.joinVenderId}","bindByVerifyCodeFlag":1,"registerExtend":{},"writeChildFlag":0${activityId},"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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + // console.log(data) + let res = $.toObj(data,data); + if(typeof res == 'object'){ + if(res.success === true){ + console.log(res.message) + if(res.result && res.result.giftInfo){ + for(let i of res.result.giftInfo.giftList){ + console.log(`入会获得:${i.discountString}${i.prizeName}${i.secondLineDesc}`) + } + } + }else if(typeof res == 'object' && res.message){ + console.log(`${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function getshopactivityId() { + return new Promise(resolve => { + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body=%7B%22venderId%22%3A%22${$.joinVenderId}%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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + let res = $.toObj(data,data); + if(typeof res == 'object'){ + if(res.success == true){ + // console.log($.toStr(res.result)) + console.log(`入会:${res.result.shopMemberCardInfo.venderCardName || ''}`) + $.shopactivityId = res.result.interestsRuleList && res.result.interestsRuleList[0] && res.result.interestsRuleList[0].interestsInfo && res.result.interestsRuleList[0].interestsInfo.activityId || '' + } + }else{ + console.log(data) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +// 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)} + diff --git a/activity/jd_opencardL54.js b/activity/jd_opencardL54.js new file mode 100644 index 0000000..efe8ee6 --- /dev/null +++ b/activity/jd_opencardL54.js @@ -0,0 +1,547 @@ +/* +1.20~1.26 大牌联合 瓜分千万京豆 +新增开卡脚本,一次性脚本 + +第一个账号助力作者 其他依次助力CK1 +第一个CK失效会退出脚本 + +———————————————— +入口:[ 1.20~1.26 大牌联合 瓜分千万京豆 (https://jinggengjcq-isv.isvjcloud.com/fronth5/#/pages/unitedCardNew2022012002/unitedCardNew2022012002?actId=329e27c899d34933a13d0514eb3e_22012003)] + +请求太频繁会被黑ip +过10分钟再执行 + + +cron:26 3,16 20-26 1 * +============Quantumultx=============== +[task_local] +#1.20~1.26 大牌联合 瓜分千万京豆 +26 3,16 20-26 1 * jd_opencardL53.js, tag=1.20~1.26 大牌联合 瓜分千万京豆, enabled=true + +*/ + +const $ = new Env('1.20~1.30 联合开卡'); +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const notify = $.isNode() ? require('./sendNotify') : ''; + +//IOS等用户直接用NobyDa的jd cookie +let cookiesArr = [], + cookie = ''; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} + +allMessage = "" +message = "" +$.hotFlag = false +$.outFlag = false +$.activityEnd = false +let lz_jdpin_token_cookie ='' +let activityCookie ='' +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', { + "open-url": "https://bean.m.jd.com/" + }); + return; + } + // return + $.appkey = '51B59BB805903DA4CE513D29EC448375' + $.userId = '10299171' + $.actId = '329e27c899d34933a13d0514eb3e_22012003' + $.MixNicks = '' + $.inviteNick = 'k1Nobb+P0er+C2sysxnx/P2KELO9izRVpwCyqu0eqVZ5aW7RHzlMobrzJ/e9r/uf' + console.log(`活动地址:https://jinggengjcq-isv.isvjcloud.com/fronth5/#/pages/unitedCardNew2022012002/unitedCardNew2022012002?actId=329e27c899d34933a13d0514eb3e_22012003`) + console.log(`请自行测试有水无水。`) + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i]; + if (cookie) { + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + message = "" + $.bean = 0 + $.hotFlag = false + $.nickName = ''; + console.log(`\n\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + await getUA() + await run(); + if(i == 0 && !$.MixNick) break + if($.outFlag || $.activityEnd) break + } + } + if($.outFlag) { + let msg = '此ip已被限制,请过10分钟后再执行脚本' + $.msg($.name, ``, `${msg}`); + if ($.isNode()) await notify.sendNotify(`${$.name}`, `${msg}`); + } +})() + .catch((e) => $.logErr(e)) + .finally(() => $.done()) + + +async function run() { + try { + $.hasEnd = true + $.endTime = 0 + lz_jdpin_token_cookie = '' + $.Token = '' + $.Pin = '' + $.MixNick = '' + let flag = false + if($.activityEnd) return + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + await takePostRequest('isvObfuscator'); + if($.Token == ''){ + console.log('获取[token]失败!') + return + } + await takePostRequest('activity_load'); + if($.hotFlag) return + if(Date.now() > $.endTime){ + $.MixNick = '' + $.activityEnd = true + console.log('活动结束') + return + } + if ($.MixNick == '') { + console.log(`获取cookie失败`); return; + } + // console.log($.MixNick) + // return + $.toBind = 0 + $.openList = [] + await takePostRequest('绑定'); + await takePostRequest('shopList'); + if($.activityEnd) return + for(o of $.openList){ + $.missionType = 'openCard' + if(o.open != true && o.openCardUrl){ + if($.activityEnd) return + $.openCard = false + $.joinVenderId = o.userId + await takePostRequest('mission'); + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + if($.openCard == true){ + await joinShop() + await takePostRequest('activity_load'); + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + // break + } + $.joinVenderId = '' + } + } + $.joinVenderId = '' + if($.hasCollectShop === 0){ + // 关注 + $.missionType = 'uniteCollectShop' + await takePostRequest('mission'); + await $.wait(parseInt(Math.random() * 2000 + 3000, 10)) + }else{ + console.log('已经关注') + } + $.missionType = 'uniteAddCart' + + await takePostRequest('mission'); + await $.wait(parseInt(Math.random() * 2000 + 3000, 10)) + await takePostRequest('activity_load'); + $.runFalag = true + let count = parseInt($.usedChance, 10) + console.log(`抽奖次数为:${count}`) + for(m=1;count--;m++){ + console.log(`第${m}次抽奖`) + await takePostRequest('抽奖'); + if($.runFalag == false) break + if(Number(count) <= 0) break + if(m >= 10){ + console.log("抽奖太多次,多余的次数请再执行脚本") + break + } + await $.wait(parseInt(Math.random() * 2000 + 2000, 10)) + } + await takePostRequest('myAward'); + await takePostRequest('missionInviteList'); + console.log($.MixNick) + console.log(`当前助力:${$.inviteNick}`) + if($.index == 1){ + $.inviteNick = $.MixNick + console.log(`后面的号都会助力:${$.inviteNick}`) + } + await $.wait(parseInt(Math.random() * 1000 + 5000, 10)) + if(flag) await $.wait(parseInt(Math.random() * 1000 + 10000, 10)) + if($.index % 3 == 0) console.log('休息1分钟,别被黑ip了\n可持续发展') + if($.index % 3 == 0) await $.wait(parseInt(Math.random() * 5000 + 60000, 10)) + } catch (e) { + console.log(e) + } +} + +async function takePostRequest(type) { + if($.outFlag) return + let domain = 'https://jinggengjcq-isv.isvjcloud.com'; + let body = ``; + let method = 'POST' + let admJson = '' + switch (type) { + case 'isvObfuscator': + url = `https://api.m.jd.com/client.action?functionId=isvObfuscator`; + body = `body=%7B%22url%22%3A%22https%3A//jinggengjcq-isv.isvjcloud.com/fronth5/%3Flng%3D0%26lat%3D0%26sid%3D49687cd64aca2ae93aa43748a04e8f6w%26un_area%3D16_1315_1316_53522%23/pages/unitedCardNew20211010-ka/unitedCardNew20211010-ka%3FactId%3D9150e1d16b9d40_10101%22%2C%22id%22%3A%22%22%7D&uuid=b9b4ce69d42dacb64084279d51cdee764d7781fa&client=apple&clientVersion=10.1.4&st=1634100732991&sv=111&sign=67e254ffbcb13be9e12a9782c9cdf398`; + break; + case 'activity_load': + url = `${domain}/dm/front/openCardNew/activity_load?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"jdToken": $.Token, "source": "01", "inviteNick":($.inviteNick || "")} + if($.joinVenderId) admJson = {...admJson, "shopId": `${$.joinVenderId}`} + body = taskPostUrl("/openCardNew/activity_load", admJson); + break; + case 'shopList': + url = `${domain}/dm/front/openCardNew/shopList?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {} + body = taskPostUrl("/openCardNew/shopList", admJson); + break; + case '绑定': + url = `${domain}/dm/front/openCardNew/complete/mission?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"missionType": "relationBind", "inviterNick":($.inviteNick || "")} + body = taskPostUrl("/openCardNew/complete/mission", admJson); + break; + case 'mission': + url = `${domain}/dm/front/openCardNew/complete/mission?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"missionType": $.missionType} + if($.joinVenderId) admJson = {...admJson, "shopId": $.joinVenderId} + body = taskPostUrl("/openCardNew/complete/mission", admJson); + break; + case '抽奖': + url = `${domain}/dm/front/openCardNew/draw/post?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"dataType": "draw", "usedGameNum": "2"} + body = taskPostUrl("/openCardNew/draw/post", admJson); + break; + case 'followShop': + url = `${domain}/dm/front/openCardNew/followShop?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"actId": $.actId, "missionType": "collectShop"} + body = taskPostUrl("/openCardNew/followShop", admJson); + break; + case 'addCart': + url = `${domain}/dm/front/openCardNew/addCart?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"actId": $.actId, "missionType": "addCart"} + body = taskPostUrl("/openCardNew/addCart", admJson); + break; + case 'myAward': + url = `${domain}/dm/front/openCardNew/myAwards?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"pageNo": 1,"pageSize":9999} + body = taskPostUrl("/openCardNew/myAwards", admJson); + break; + case 'missionInviteList': + url = `${domain}/dm/front/openCardNew/missionInviteList?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"inviteListRequest":{"actId":$.actId,"userId":10299171,"missionType":"shareAct","inviteType": 1,"buyerNick":($.MixNick || '')}} + body = taskPostUrl("/openCardNew/missionInviteList", admJson); + break; + default: + console.log(`错误${type}`); + } + let myRequest = getPostRequest(url, body, method); + return new Promise(async resolve => { + $.post(myRequest, (err, resp, data) => { + try { + if (err) { + if(resp && resp.statusCode && resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + console.log(`${$.toStr(err,err)}`) + console.log(`${type} API请求失败,请检查网路重试`) + } else { + dealReturn(type, data); + } + } catch (e) { + // console.log(data); + console.log(e, resp) + } finally { + resolve(); + } + }) + }) + } + +async function dealReturn(type, data) { + let res = '' + try { + if(type != 'accessLogWithAD' || type != 'drawContent'){ + if(data){ + res = JSON.parse(data); + } + } + } catch (e) { + console.log(`${type} 执行任务异常`); + console.log(data); + $.runFalag = false; + } + try { + let title = '' + switch (type) { + case 'isvObfuscator': + if(typeof res == 'object'){ + if(res.errcode == 0){ + if(typeof res.token != 'undefined') $.Token = res.token + }else if(res.message){ + console.log(`${type} ${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + break; + case 'accessLogWithAD': + case 'drawContent': + break; + case 'activity_load': + case 'mission': + case 'shopList': + case 'loadUniteOpenCard': + case 'setMixNick': + case 'uniteOpenCardOne': + case 'checkOpenCard': + case 'followShop': + case 'addCart': + case 'myAward': + case 'missionInviteList': + case '抽奖': + title = '' + if(type == "followShop") title = '关注' + if(type == "addCart") title = '加购' + if(typeof res == 'object'){ + if(res.success && res.success === true && res.data){ + if(res.data.status && res.data.status == 200){ + res = res.data + if(type != "setMixNick" && (res.msg || res.data.isOpenCard || res.data.remark)) console.log(`${title && title+":" || ""}${res.msg || res.data.isOpenCard || res.data.remark || ''}`) + if(type == "activity_load"){ + if(res.msg || res.data.isOpenCard) { + if((res.msg || res.data.isOpenCard || '').indexOf('绑定成功') > -1) $.toBind = 1 + } + if(res.data){ + $.endTime = res.data.cusActivity.endTime || 0 + $.MixNick = res.data.buyerNick || "" + $.usedChance = res.data.missionCustomer.usedChance || 0 + $.hasCollectShop = res.data.missionCustomer.hasCollectShop || 0 + } + }else if(type == "shopList"){ + $.openList = res.data.cusShops || [] + }else if(type == "mission"){ + if(res.data.remark.indexOf('不是会员') > -1){ + $.openCard = true + }else{ + $.openCard = false + } + }else if(type == "uniteOpenCardOne"){ + $.uniteOpenCar = res.msg || res.data.msg || '' + }else if(type == "myAward"){ + console.log(`我的奖品:`) + let num = 0 + let value = 0 + for(let i in res.data.list || []){ + let item = res.data.list[i] + value += Number(item.awardDes) + } + if(value > 0) console.log(`共获得${value}京豆\n无法判断奖励是否为邀请奖励,所以直接显示获得多少豆\n`) + }else if(type == "missionInviteList"){ + console.log(`邀请人数(${res.data.invitedLogList.total})`) + } + }else if(res.data.msg){ + if(res.errorMessage.indexOf('活动未开始') >-1 ){ + $.activityEnd = true + } + console.log(`${title || type} ${res.data.msg || ''}`) + }else if(res.errorMessage){ + if(res.errorMessage.indexOf('火爆') >-1 ){ + $.hotFlag = true + } + console.log(`${title || type} ${res.errorMessage || ''}`) + }else{ + console.log(`${title || type} ${data}`) + } + }else if(res.errorMessage){ + console.log(`${title || type} ${res.errorMessage || ''}`) + }else{ + console.log(`${title || type} ${data}`) + } + }else{ + console.log(`${title || type} ${data}`) + } + break; + default: + console.log(`${title || type}-> ${data}`); + } + if(typeof res == 'object'){ + if(res.errorMessage){ + if(res.errorMessage.indexOf('火爆') >-1 ){ + $.hotFlag = true + } + } + } + } catch (e) { + console.log(e) + } +} + +function getPostRequest(url, body, method="POST") { + let headers = { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Content-Type": "application/x-www-form-urlencoded", + "Cookie": cookie, + "User-Agent": $.UA, + "X-Requested-With": "XMLHttpRequest" + } + if(url.indexOf('https://jinggengjcq-isv.isvjcloud.com') > -1){ + headers["Origin"] = `https://jinggengjcq-isv.isvjcloud.com` + headers["Content-Type"] = `application/json; charset=utf-8` + delete headers["Cookie"] + } + // console.log(headers) + // console.log(headers.Cookie) + return {url: url, method: method, headers: headers, body: body, timeout:60000}; +} + + +function taskPostUrl(url, t) { + + const b = { + "jsonRpc": "2.0", + "params": { + "commonParameter": { + "appkey": $.appkey, + "m": "POST", + "timestamp": Date.now(), + "userId": $.userId + }, + "admJson": { + "actId": $.actId, + "userId": $.userId, + ...t, + "method": url, + "buyerNick": ($.MixNick || ''), + } + }, + } + if(url.indexOf('missionInviteList') > -1){ + delete b.params.admJson.actId + } + return $.toStr(b,b) +} +async function getUA(){ + $.UA = `jdapp;iPhone;10.1.4;13.1.2;${randomString(40)};network/wifi;model/iPhone8,1;addressid/2308460611;appBuild/167814;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_1_2 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 jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} + +function joinShop() { + if(!$.joinVenderId) return + return new Promise(async resolve => { + $.shopactivityId = '' + await $.wait(1000) + await getshopactivityId() + let activityId = `` + if($.shopactivityId) activityId = `,"activityId":${$.shopactivityId}` + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body={"venderId":"${$.joinVenderId}","shopId":"${$.joinVenderId}","bindByVerifyCodeFlag":1,"registerExtend":{},"writeChildFlag":0${activityId},"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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + // console.log(data) + let res = $.toObj(data,data); + if(typeof res == 'object'){ + if(res.success === true){ + console.log(res.message) + if(res.result && res.result.giftInfo){ + for(let i of res.result.giftInfo.giftList){ + console.log(`入会获得:${i.discountString}${i.prizeName}${i.secondLineDesc}`) + } + } + }else if(typeof res == 'object' && res.message){ + console.log(`${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function getshopactivityId() { + return new Promise(resolve => { + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body=%7B%22venderId%22%3A%22${$.joinVenderId}%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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + let res = $.toObj(data,data); + if(typeof res == 'object'){ + if(res.success == true){ + // console.log($.toStr(res.result)) + console.log(`入会:${res.result.shopMemberCardInfo.venderCardName || ''}`) + $.shopactivityId = res.result.interestsRuleList && res.result.interestsRuleList[0] && res.result.interestsRuleList[0].interestsInfo && res.result.interestsRuleList[0].interestsInfo.activityId || '' + } + }else{ + console.log(data) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +// 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)} + diff --git a/activity/jd_opencardL55.js b/activity/jd_opencardL55.js new file mode 100644 index 0000000..784acbe --- /dev/null +++ b/activity/jd_opencardL55.js @@ -0,0 +1,547 @@ +/* +1.15~1.25 联合开卡 +新增开卡脚本,一次性脚本 + +第一个账号助力作者 其他依次助力CK1 +第一个CK失效会退出脚本 + +———————————————— +入口:[ 1.15~1.25 联合开卡 (https://jinggengjcq-isv.isvjcloud.com/fronth5/#/pages/unitedCardNew2022011502/unitedCardNew2022011502?actId=ed19a355a96649ff8e2af691aa_22011502)] + +请求太频繁会被黑ip +过10分钟再执行 + + +cron:6 11 15-25 1 * +============Quantumultx=============== +[task_local] +#1.15~1.25 联合开卡 +6 11 15-25 1 * jd_opencardL55.js, tag=1.15~1.25 联合开卡, enabled=true + +*/ + +const $ = new Env('1.15~1.25 联合开卡'); +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const notify = $.isNode() ? require('./sendNotify') : ''; + +//IOS等用户直接用NobyDa的jd cookie +let cookiesArr = [], + cookie = ''; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} + +allMessage = "" +message = "" +$.hotFlag = false +$.outFlag = false +$.activityEnd = false +let lz_jdpin_token_cookie ='' +let activityCookie ='' +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', { + "open-url": "https://bean.m.jd.com/" + }); + return; + } + // return + $.appkey = '51B59BB805903DA4CE513D29EC448375' + $.userId = '10299171' + $.actId = 'ed19a355a96649ff8e2af691aa_22011502' + $.MixNicks = '' + $.inviteNick = 'k1Nobb+P0er+C2sysxnx/P2KELO9izRVpwCyqu0eqVZ5aW7RHzlMobrzJ/e9r/uf' + console.log(`活动地址:https://jinggengjcq-isv.isvjcloud.com/fronth5/#/pages/unitedCardNew2022011502/unitedCardNew2022011502?actId=ed19a355a96649ff8e2af691aa_22011502`) + console.log(`请自行测试有水无水。`) + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i]; + if (cookie) { + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + message = "" + $.bean = 0 + $.hotFlag = false + $.nickName = ''; + console.log(`\n\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + await getUA() + await run(); + if(i == 0 && !$.MixNick) break + if($.outFlag || $.activityEnd) break + } + } + if($.outFlag) { + let msg = '此ip已被限制,请过10分钟后再执行脚本' + $.msg($.name, ``, `${msg}`); + if ($.isNode()) await notify.sendNotify(`${$.name}`, `${msg}`); + } +})() + .catch((e) => $.logErr(e)) + .finally(() => $.done()) + + +async function run() { + try { + $.hasEnd = true + $.endTime = 0 + lz_jdpin_token_cookie = '' + $.Token = '' + $.Pin = '' + $.MixNick = '' + let flag = false + if($.activityEnd) return + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + await takePostRequest('isvObfuscator'); + if($.Token == ''){ + console.log('获取[token]失败!') + return + } + await takePostRequest('activity_load'); + if($.hotFlag) return + if(Date.now() > $.endTime){ + $.MixNick = '' + $.activityEnd = true + console.log('活动结束') + return + } + if ($.MixNick == '') { + console.log(`获取cookie失败`); return; + } + // console.log($.MixNick) + // return + $.toBind = 0 + $.openList = [] + await takePostRequest('绑定'); + await takePostRequest('shopList'); + if($.activityEnd) return + for(o of $.openList){ + $.missionType = 'openCard' + if(o.open != true && o.openCardUrl){ + if($.activityEnd) return + $.openCard = false + $.joinVenderId = o.userId + await takePostRequest('mission'); + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + if($.openCard == true){ + await joinShop() + await takePostRequest('activity_load'); + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + // break + } + $.joinVenderId = '' + } + } + $.joinVenderId = '' + if($.hasCollectShop === 0){ + // 关注 + $.missionType = 'uniteCollectShop' + await takePostRequest('mission'); + await $.wait(parseInt(Math.random() * 2000 + 3000, 10)) + }else{ + console.log('已经关注') + } + $.missionType = 'uniteAddCart' + + await takePostRequest('mission'); + await $.wait(parseInt(Math.random() * 2000 + 3000, 10)) + await takePostRequest('activity_load'); + $.runFalag = true + let count = parseInt($.usedChance, 10) + console.log(`抽奖次数为:${count}`) + for(m=1;count--;m++){ + console.log(`第${m}次抽奖`) + await takePostRequest('抽奖'); + if($.runFalag == false) break + if(Number(count) <= 0) break + if(m >= 10){ + console.log("抽奖太多次,多余的次数请再执行脚本") + break + } + await $.wait(parseInt(Math.random() * 2000 + 2000, 10)) + } + await takePostRequest('myAward'); + await takePostRequest('missionInviteList'); + console.log($.MixNick) + console.log(`当前助力:${$.inviteNick}`) + if($.index == 1){ + $.inviteNick = $.MixNick + console.log(`后面的号都会助力:${$.inviteNick}`) + } + await $.wait(parseInt(Math.random() * 1000 + 5000, 10)) + if(flag) await $.wait(parseInt(Math.random() * 1000 + 10000, 10)) + if($.index % 3 == 0) console.log('休息1分钟,别被黑ip了\n可持续发展') + if($.index % 3 == 0) await $.wait(parseInt(Math.random() * 5000 + 60000, 10)) + } catch (e) { + console.log(e) + } +} + +async function takePostRequest(type) { + if($.outFlag) return + let domain = 'https://jinggengjcq-isv.isvjcloud.com'; + let body = ``; + let method = 'POST' + let admJson = '' + switch (type) { + case 'isvObfuscator': + url = `https://api.m.jd.com/client.action?functionId=isvObfuscator`; + body = `body=%7B%22url%22%3A%22https%3A//jinggengjcq-isv.isvjcloud.com/fronth5/%3Flng%3D0%26lat%3D0%26sid%3D49687cd64aca2ae93aa43748a04e8f6w%26un_area%3D16_1315_1316_53522%23/pages/unitedCardNew20211010-ka/unitedCardNew20211010-ka%3FactId%3D9150e1d16b9d40_10101%22%2C%22id%22%3A%22%22%7D&uuid=b9b4ce69d42dacb64084279d51cdee764d7781fa&client=apple&clientVersion=10.1.4&st=1634100732991&sv=111&sign=67e254ffbcb13be9e12a9782c9cdf398`; + break; + case 'activity_load': + url = `${domain}/dm/front/openCardNew/activity_load?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"jdToken": $.Token, "source": "01", "inviteNick":($.inviteNick || "")} + if($.joinVenderId) admJson = {...admJson, "shopId": `${$.joinVenderId}`} + body = taskPostUrl("/openCardNew/activity_load", admJson); + break; + case 'shopList': + url = `${domain}/dm/front/openCardNew/shopList?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {} + body = taskPostUrl("/openCardNew/shopList", admJson); + break; + case '绑定': + url = `${domain}/dm/front/openCardNew/complete/mission?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"missionType": "relationBind", "inviterNick":($.inviteNick || "")} + body = taskPostUrl("/openCardNew/complete/mission", admJson); + break; + case 'mission': + url = `${domain}/dm/front/openCardNew/complete/mission?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"missionType": $.missionType} + if($.joinVenderId) admJson = {...admJson, "shopId": $.joinVenderId} + body = taskPostUrl("/openCardNew/complete/mission", admJson); + break; + case '抽奖': + url = `${domain}/dm/front/openCardNew/draw/post?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"dataType": "draw", "usedGameNum": "2"} + body = taskPostUrl("/openCardNew/draw/post", admJson); + break; + case 'followShop': + url = `${domain}/dm/front/openCardNew/followShop?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"actId": $.actId, "missionType": "collectShop"} + body = taskPostUrl("/openCardNew/followShop", admJson); + break; + case 'addCart': + url = `${domain}/dm/front/openCardNew/addCart?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"actId": $.actId, "missionType": "addCart"} + body = taskPostUrl("/openCardNew/addCart", admJson); + break; + case 'myAward': + url = `${domain}/dm/front/openCardNew/myAwards?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"pageNo": 1,"pageSize":9999} + body = taskPostUrl("/openCardNew/myAwards", admJson); + break; + case 'missionInviteList': + url = `${domain}/dm/front/openCardNew/missionInviteList?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"inviteListRequest":{"actId":$.actId,"userId":10299171,"missionType":"shareAct","inviteType": 1,"buyerNick":($.MixNick || '')}} + body = taskPostUrl("/openCardNew/missionInviteList", admJson); + break; + default: + console.log(`错误${type}`); + } + let myRequest = getPostRequest(url, body, method); + return new Promise(async resolve => { + $.post(myRequest, (err, resp, data) => { + try { + if (err) { + if(resp && resp.statusCode && resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + console.log(`${$.toStr(err,err)}`) + console.log(`${type} API请求失败,请检查网路重试`) + } else { + dealReturn(type, data); + } + } catch (e) { + // console.log(data); + console.log(e, resp) + } finally { + resolve(); + } + }) + }) + } + +async function dealReturn(type, data) { + let res = '' + try { + if(type != 'accessLogWithAD' || type != 'drawContent'){ + if(data){ + res = JSON.parse(data); + } + } + } catch (e) { + console.log(`${type} 执行任务异常`); + console.log(data); + $.runFalag = false; + } + try { + let title = '' + switch (type) { + case 'isvObfuscator': + if(typeof res == 'object'){ + if(res.errcode == 0){ + if(typeof res.token != 'undefined') $.Token = res.token + }else if(res.message){ + console.log(`${type} ${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + break; + case 'accessLogWithAD': + case 'drawContent': + break; + case 'activity_load': + case 'mission': + case 'shopList': + case 'loadUniteOpenCard': + case 'setMixNick': + case 'uniteOpenCardOne': + case 'checkOpenCard': + case 'followShop': + case 'addCart': + case 'myAward': + case 'missionInviteList': + case '抽奖': + title = '' + if(type == "followShop") title = '关注' + if(type == "addCart") title = '加购' + if(typeof res == 'object'){ + if(res.success && res.success === true && res.data){ + if(res.data.status && res.data.status == 200){ + res = res.data + if(type != "setMixNick" && (res.msg || res.data.isOpenCard || res.data.remark)) console.log(`${title && title+":" || ""}${res.msg || res.data.isOpenCard || res.data.remark || ''}`) + if(type == "activity_load"){ + if(res.msg || res.data.isOpenCard) { + if((res.msg || res.data.isOpenCard || '').indexOf('绑定成功') > -1) $.toBind = 1 + } + if(res.data){ + $.endTime = res.data.cusActivity.endTime || 0 + $.MixNick = res.data.buyerNick || "" + $.usedChance = res.data.missionCustomer.usedChance || 0 + $.hasCollectShop = res.data.missionCustomer.hasCollectShop || 0 + } + }else if(type == "shopList"){ + $.openList = res.data.cusShops || [] + }else if(type == "mission"){ + if(res.data.remark.indexOf('不是会员') > -1){ + $.openCard = true + }else{ + $.openCard = false + } + }else if(type == "uniteOpenCardOne"){ + $.uniteOpenCar = res.msg || res.data.msg || '' + }else if(type == "myAward"){ + console.log(`我的奖品:`) + let num = 0 + let value = 0 + for(let i in res.data.list || []){ + let item = res.data.list[i] + value += Number(item.awardDes) + } + if(value > 0) console.log(`共获得${value}京豆\n无法判断奖励是否为邀请奖励,所以直接显示获得多少豆\n`) + }else if(type == "missionInviteList"){ + console.log(`邀请人数(${res.data.invitedLogList.total})`) + } + }else if(res.data.msg){ + if(res.errorMessage.indexOf('活动未开始') >-1 ){ + $.activityEnd = true + } + console.log(`${title || type} ${res.data.msg || ''}`) + }else if(res.errorMessage){ + if(res.errorMessage.indexOf('火爆') >-1 ){ + $.hotFlag = true + } + console.log(`${title || type} ${res.errorMessage || ''}`) + }else{ + console.log(`${title || type} ${data}`) + } + }else if(res.errorMessage){ + console.log(`${title || type} ${res.errorMessage || ''}`) + }else{ + console.log(`${title || type} ${data}`) + } + }else{ + console.log(`${title || type} ${data}`) + } + break; + default: + console.log(`${title || type}-> ${data}`); + } + if(typeof res == 'object'){ + if(res.errorMessage){ + if(res.errorMessage.indexOf('火爆') >-1 ){ + $.hotFlag = true + } + } + } + } catch (e) { + console.log(e) + } +} + +function getPostRequest(url, body, method="POST") { + let headers = { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Content-Type": "application/x-www-form-urlencoded", + "Cookie": cookie, + "User-Agent": $.UA, + "X-Requested-With": "XMLHttpRequest" + } + if(url.indexOf('https://jinggengjcq-isv.isvjcloud.com') > -1){ + headers["Origin"] = `https://jinggengjcq-isv.isvjcloud.com` + headers["Content-Type"] = `application/json; charset=utf-8` + delete headers["Cookie"] + } + // console.log(headers) + // console.log(headers.Cookie) + return {url: url, method: method, headers: headers, body: body, timeout:60000}; +} + + +function taskPostUrl(url, t) { + + const b = { + "jsonRpc": "2.0", + "params": { + "commonParameter": { + "appkey": $.appkey, + "m": "POST", + "timestamp": Date.now(), + "userId": $.userId + }, + "admJson": { + "actId": $.actId, + "userId": $.userId, + ...t, + "method": url, + "buyerNick": ($.MixNick || ''), + } + }, + } + if(url.indexOf('missionInviteList') > -1){ + delete b.params.admJson.actId + } + return $.toStr(b,b) +} +async function getUA(){ + $.UA = `jdapp;iPhone;10.1.4;13.1.2;${randomString(40)};network/wifi;model/iPhone8,1;addressid/2308460611;appBuild/167814;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_1_2 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 jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} + +function joinShop() { + if(!$.joinVenderId) return + return new Promise(async resolve => { + $.shopactivityId = '' + await $.wait(1000) + await getshopactivityId() + let activityId = `` + if($.shopactivityId) activityId = `,"activityId":${$.shopactivityId}` + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body={"venderId":"${$.joinVenderId}","shopId":"${$.joinVenderId}","bindByVerifyCodeFlag":1,"registerExtend":{},"writeChildFlag":0${activityId},"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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + // console.log(data) + let res = $.toObj(data,data); + if(typeof res == 'object'){ + if(res.success === true){ + console.log(res.message) + if(res.result && res.result.giftInfo){ + for(let i of res.result.giftInfo.giftList){ + console.log(`入会获得:${i.discountString}${i.prizeName}${i.secondLineDesc}`) + } + } + }else if(typeof res == 'object' && res.message){ + console.log(`${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function getshopactivityId() { + return new Promise(resolve => { + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body=%7B%22venderId%22%3A%22${$.joinVenderId}%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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + let res = $.toObj(data,data); + if(typeof res == 'object'){ + if(res.success == true){ + // console.log($.toStr(res.result)) + console.log(`入会:${res.result.shopMemberCardInfo.venderCardName || ''}`) + $.shopactivityId = res.result.interestsRuleList && res.result.interestsRuleList[0] && res.result.interestsRuleList[0].interestsInfo && res.result.interestsRuleList[0].interestsInfo.activityId || '' + } + }else{ + console.log(data) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +// 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)} + diff --git a/activity/jd_opencardL56.js b/activity/jd_opencardL56.js new file mode 100644 index 0000000..47e4dd6 --- /dev/null +++ b/activity/jd_opencardL56.js @@ -0,0 +1,825 @@ +/* +2022.1.21-1.29 大牌好礼带回家 + + +第一个账号助力作者 其他依次助力CK1 +第一个CK失效会退出脚本 + +———————————————— +入口:https://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=dzlhkkkbblnt20220121&shareUuid=3036775666b84a2b9a3936efbe9bf94b + +请求太频繁会被黑ip +过10分钟再执行 + + +cron:21 0,17 21-29 1 * +============Quantumultx=============== +[task_local] +#2022.1.21-1.29 大牌好礼带回家 +21 0,17 21-29 1 * https://raw.githubusercontent.com/KingRan/JDJB/main/jd_opencardL56.js, tag=2022.1.21-1.29 大牌好礼带回家, enabled=true + +*/ +const $ = new Env("2022.1.21-1.29 大牌好礼带回家"); +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const notify = $.isNode() ? require('./sendNotify') : ''; +//IOS等用户直接用NobyDa的jd cookie + +let cookiesArr = [], + cookie = ''; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} +allMessage = "" +message = "" +$.hotFlag = false +$.outFlag = false +$.activityEnd = false +let lz_jdpin_token_cookie ='' +let activityCookie ='' +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', { + "open-url": "https://bean.m.jd.com/" + }); + return; + } + $.activityId = "dzlhkkkbblnt20220121" + $.shareUuid = "3036775666b84a2b9a3936efbe9bf94b" + console.log(`入口:\nhttps://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}`) + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i]; + if (cookie) { + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + message = "" + $.bean = 0 + $.hotFlag = false + $.nickName = ''; + console.log(`\n\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + await getUA() + await run(); + if(i == 0 && !$.actorUuid) break + if($.outFlag || $.activityEnd) break + } + } + if($.outFlag) { + let msg = '此ip已被限制,请过10分钟后再执行脚本' + $.msg($.name, ``, `${msg}`); + if ($.isNode()) await notify.sendNotify(`${$.name}`, `${msg}`); + } +})() + .catch((e) => $.logErr(e)) + .finally(() => $.done()) + + +async function run() { + try { + $.hasEnd = true + $.endTime = 0 + lz_jdpin_token_cookie = '' + $.Token = '' + $.Pin = '' + let flag = false + await takePostRequest('isvObfuscator'); + if($.Token == ''){ + console.log('获取[token]失败!') + return + } + await getCk() + if (activityCookie == '') { + console.log(`获取cookie失败`); return; + } + if($.activityEnd === true){ + console.log('活动结束') + return + } + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + await takePostRequest('getSimpleActInfoVo'); + await takePostRequest('getMyPing'); + if(!$.Pin){ + console.log('获取[Pin]失败!') + return + } + await takePostRequest('accessLogWithAD'); + await takePostRequest('getUserInfo'); + await takePostRequest('activityContent'); + if($.hotFlag) return + if(!$.actorUuid){ + console.log('获取不到[actorUuid]退出执行,请重新执行') + return + } + // console.log($.actorUuid) + // return + if($.hasEnd === true || Date.now() > $.endTime){ + $.activityEnd = true + console.log('活动结束') + return + } + await takePostRequest('drawContent'); + await $.wait(1000) + $.openList = [] + $.allOpenCard = false + await takePostRequest('info'); + await takePostRequest('checkOpenCard'); + if($.allOpenCard == false){ + console.log('开卡任务') + for(o of $.openList){ + $.openCard = false + if(o.status == 0){ + flag = true + $.joinVenderId = o.venderId + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + await joinShop() + await $.wait(parseInt(Math.random() * 1000 + 1000, 10)) + await takePostRequest('activityContent'); + await takePostRequest('drawContent'); + await takePostRequest('checkOpenCard'); + await $.wait(parseInt(Math.random() * 3000 + 2000, 10)) + } + } + }else{ + console.log('已全部开卡') + } + + $.log("关注: " + $.followShop) + if(!$.followShop && !$.outFlag){ + flag = true + await takePostRequest('followShop'); + await $.wait(parseInt(Math.random() * 2000 + 3000, 10)) + } + $.yaoqing = false + await takePostRequest('邀请'); + if($.yaoqing){ + await takePostRequest('助力'); + } + $.log("加购: " + $.addCart) + if(!$.addCart && !$.outFlag){ + flag = true + await takePostRequest('addCart'); + await $.wait(parseInt(Math.random() * 2000 + 4000, 10)) + } + $.runFalag = true + $.log("浏览商品: " + $.visitSku) + if(!$.visitSku && !$.outFlag){ + flag = true + for(let v of $.visitSkuList || []){ + if($.runFalag == false) break + if(v.goodsCode && v.status === 0){ + $.visitSkuValue = v.goodsCode + await takePostRequest('browseGoods'); + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + } + } + } + $.runFalag = true + let count = parseInt($.drawCount, 10) + console.log(`抽奖次数为:${count}`) + for(m=1;count--;m++){ + console.log(`第${m}次抽奖`) + await takePostRequest('startDraw'); + if($.runFalag == false) break + if(Number(count) <= 0) break + if(m >= 30){ + console.log("抽奖太多次,多余的次数请再执行脚本") + break + } + await $.wait(parseInt(Math.random() * 2000 + 2000, 10)) + } + if(flag){ + await takePostRequest('activityContent'); + } + console.log(`${$.score}值 游戏:${$.point}`) + $.runFalag = true + count = parseInt($.score/100) + console.log(`抽奖次数为:${count}`) + for(m=1;count--;m++){ + console.log(`第${m}次抽奖`) + await takePostRequest('抽奖'); + if($.runFalag == false) break + if(Number(count) <= 0) break + if(m >= 10){ + console.log("抽奖太多次,多余的次数请再执行脚本") + break + } + await $.wait(parseInt(Math.random() * 2000 + 2000, 10)) + } + + await $.wait(parseInt(Math.random() * 1000 + 2000, 10)) + await takePostRequest('getDrawRecordHasCoupon'); + await takePostRequest('getShareRecord'); + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + console.log($.actorUuid) + console.log(`当前助力:${$.shareUuid}`) + if($.index == 1){ + $.shareUuid = $.actorUuid + console.log(`后面的号都会助力:${$.shareUuid}`) + } + await $.wait(parseInt(Math.random() * 1000 + 5000, 10)) + if(flag) await $.wait(parseInt(Math.random() * 1000 + 10000, 10)) + + if($.index % 3 == 0) console.log('休息1分钟,别被黑ip了\n可持续发展') + if($.index % 3 == 0) await $.wait(parseInt(Math.random() * 5000 + 60000, 10)) + + } catch (e) { + console.log(e) + } +} + +async function takePostRequest(type) { + if($.outFlag) return + let domain = 'https://lzdz1-isv.isvjcloud.com'; + let body = ``; + let method = 'POST' + let admJson = '' + switch (type) { + case 'isvObfuscator': + url = `https://api.m.jd.com/client.action?functionId=isvObfuscator`; + body = `body=%7B%22url%22%3A%22https%3A//lzdz1-isv.isvjcloud.com%22%2C%22id%22%3A%22%22%7D&uuid=7088d9018515b8cb0c88ace6e5479762af3e88f3&client=apple&clientVersion=10.1.4&st=1634343624086&sv=120&sign=8b9cea22c3a0d77026abda5d37d2b7e3`; + break; + case 'getSimpleActInfoVo': + url = `${domain}/dz/common/getSimpleActInfoVo`; + body = `activityId=${$.activityId}`; + break; + case 'getMyPing': + url = `${domain}/customer/getMyPing`; + body = `userId=${$.shopId || $.venderId || ''}&token=${$.Token}&fromType=APP`; + break; + case 'accessLogWithAD': + url = `${domain}/common/accessLogWithAD`; + let pageurl = `${domain}/drawCenter/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}` + body = `venderId=${$.shopId || $.venderId || ''}&code=99&pin=${encodeURIComponent($.Pin)}&activityId=${$.activityId}&pageUrl=${encodeURIComponent(pageurl)}&subType=app&adSource=` + break; + case 'getUserInfo': + url = `${domain}/wxActionCommon/getUserInfo`; + body = `pin=${encodeURIComponent($.Pin)}`; + break; + case 'activityContent': + url = `${domain}/dingzhi/linkgame/activity/content`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&pinImg=${encodeURIComponent($.attrTouXiang)}&nick=${encodeURIComponent($.nickname)}&cjyxPin=&cjhyPin=&shareUuid=${$.shareUuid}` + break; + case 'drawContent': + url = `${domain}/dingzhi/taskact/common/drawContent`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case 'checkOpenCard': + url = `${domain}/dingzhi/linkgame/checkOpenCard`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case 'info': + url = `${domain}/dingzhi/linkgame/task/info`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case 'startDraw': + url = `${domain}/dingzhi/linkgame/draw/bean`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case 'followShop': + url = `${domain}/dingzhi/linkgame/follow/shop`; + // url = `${domain}/dingzhi/dz/openCard/saveTask`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case 'sign': + case 'addCart': + case 'browseGoods': + url = `${domain}/dingzhi/linkgame/${type}`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + if(type == 'browseGoods') body += `&value=${$.visitSkuValue}` + break; + case '邀请': + case '助力': + if(type == '助力'){ + url = `${domain}/dingzhi/linkgame/assist`; + }else{ + url = `${domain}/dingzhi/linkgame/assist/status`; + } + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&shareUuid=${$.shareUuid}` + break; + case 'viewVideo': + case 'visitSku': + case 'toShop': + case 'addSku': + url = `${domain}/dingzhi/dz/openCard/saveTask`; + let taskType = '' + let taskValue = '' + if(type == 'viewVideo'){ + taskType = 31 + taskValue = 31 + }else if(type == 'visitSku'){ + taskType = 5 + taskValue = $.visitSkuValue || 5 + }else if(type == 'toShop'){ + taskType = 14 + taskValue = $.toShopValue || 14 + }else if(type == 'addSku'){ + taskType = 2 + taskValue = $.addSkuValue || 2 + } + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&taskType=${taskType}&taskValue=${taskValue}` + break; + case 'getDrawRecordHasCoupon': + url = `${domain}/dingzhi/linkgame/draw/record`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case 'getShareRecord': + url = `${domain}/dingzhi/linkgame/help/list`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case '抽奖': + url = `${domain}/dingzhi/linkgame/draw`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + default: + console.log(`错误${type}`); + } + let myRequest = getPostRequest(url, body, method); + // console.log(myRequest) + return new Promise(async resolve => { + $.post(myRequest, (err, resp, data) => { + try { + setActivityCookie(resp) + if (err) { + if(resp && typeof resp.statusCode != 'undefined'){ + if(resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + } + console.log(`${$.toStr(err,err)}`) + console.log(`${type} API请求失败,请检查网路重试`) + } else { + dealReturn(type, data); + } + } catch (e) { + // console.log(data); + console.log(e, resp) + } finally { + resolve(); + } + }) + }) + } + +async function dealReturn(type, data) { + let res = '' + try { + if(type != 'accessLogWithAD' || type != 'drawContent'){ + if(data){ + res = JSON.parse(data); + } + } + } catch (e) { + console.log(`${type} 执行任务异常`); + console.log(data); + $.runFalag = false; + } + try { + switch (type) { + case 'isvObfuscator': + if(typeof res == 'object'){ + if(res.errcode == 0){ + if(typeof res.token != 'undefined') $.Token = res.token + }else if(res.message){ + console.log(`isvObfuscator ${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + break; + case 'getSimpleActInfoVo': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(typeof res.data.shopId != 'undefined') $.shopId = res.data.shopId + if(typeof res.data.venderId != 'undefined') $.venderId = res.data.venderId + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getMyPing': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(res.data && typeof res.data.secretPin != 'undefined') $.Pin = res.data.secretPin + if(res.data && typeof res.data.nickname != 'undefined') $.nickname = res.data.nickname + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getUserInfo': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(res.data && typeof res.data.yunMidImageUrl != 'undefined') $.attrTouXiang = res.data.yunMidImageUrl || "https://img10.360buyimg.com/imgzone/jfs/t1/7020/27/13511/6142/5c5138d8E4df2e764/5a1216a3a5043c5d.png" + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'activityContent': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + $.endTime = res.data.endTime || res.data.activity.endTime || 0 + $.hasEnd = res.data.isEnd || false + $.drawCount = res.data.actor.drawCount || 0 + $.point = res.data.actor.point || 0 + $.score = res.data.actor.score || 0 + $.actorUuid = res.data.actor.actorUuid || '' + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'info': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + // $.drawCount = res.data.drawCount || 0 + $.addCart = res.data.addCart || false + $.followShop = res.data.followShop || false + $.sign = res.data.sign || false + $.visitSku = res.data.visitSku || false + $.visitSkuList = res.data.visitSkuList || [] + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'checkOpenCard': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + let cardList1 = res.data.cardList1 || [] + let cardList2 = res.data.cardList2 || [] + let cardList = res.data.cardList || [] + let openCardList = res.data.openCardList || [] + $.openList = [...cardList,...cardList1,...cardList2,...openCardList] + $.allOpenCard = res.data.allOpenCard || false + $.openCardScore1 = res.data.score1 || 0 + $.openCardScore2 = res.data.score2 || 0 + $.drawScore = res.data.drawScore || 0 + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'startDraw': + case 'followShop': + case 'viewVideo': + case 'visitSku': + case 'toShop': + case 'addSku': + case 'sign': + case 'addCart': + case 'browseGoods': + case '抽奖': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(typeof res.data == 'object'){ + let msg = '' + let title = '抽奖' + if(res.data.addBeanNum){ + msg = `${res.data.addBeanNum}京豆` + } + if(res.data.addPoint){ + msg += ` ${res.data.addPoint}游戏机会` + } + if(type == 'followShop'){ + title = '关注' + if(res.data.beanNumMember && res.data.assistSendStatus){ + msg += ` 额外获得:${res.data.beanNumMember}京豆` + } + }else if(type == 'addSku' || type == 'addCart'){ + title = '加购' + }else if(type == 'viewVideo'){ + title = '热门文章' + }else if(type == 'toShop'){ + title = '浏览店铺' + }else if(type == 'visitSku' || type == 'browseGoods'){ + title = '浏览商品' + }else if(type == 'sign'){ + title = '签到' + }else{ + msg = res.data.drawOk == true && (res.data.drawInfoType == 6 && res.data.name || '') || '空气💨' + } + if(!msg){ + msg = '空气💨' + } + console.log(`${title}获得:${msg || data}`) + }else{ + console.log(`${type} ${data}`) + } + }else if(res.errorMessage){ + $.runFalag = false; + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getDrawRecordHasCoupon': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + console.log(`我的奖品:`) + let num = 0 + let value = 0 + for(let i in res.data.recordList){ + let item = res.data.recordList[i] + if(item.infoName == '20京豆'){ + num++ + value = item.infoName.replace('京豆','') + }else{ + console.log(`${item.infoType != 10 && item.value && item.value +':' || ''}${item.infoName}`) + } + } + if(num > 0) console.log(`邀请好友(${num}):${num*parseInt(value, 10) || 30}京豆`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getShareRecord': + if(typeof res == 'object'){ + if(res.result && res.result === true && res.data){ + $.ShareCount = res.data.shareList.length + $.log(`=========== 你邀请了:${res.data.shareList.length}个`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case '邀请': + case '助力': + // console.log(data) + if(typeof res == 'object'){ + if(res.data.status == 200){ + if(type == '助力'){ + console.log('助力成功') + }else{ + $.yaoqing = true + } + }else if(res.data.status == 105){ + console.log('已经助力过') + }else if(res.data.status == 104){ + console.log('已经助力其他人') + }else if(res.data.status == 101){ + // console.log('已经助力过') + }else{ + console.log(data) + } + }else{ + console.log(`${type} ${data}`) + } + + case 'accessLogWithAD': + case 'drawContent': + break; + default: + console.log(`${type}-> ${data}`); + } + if(typeof res == 'object'){ + if(res.errorMessage){ + if(res.errorMessage.indexOf('火爆') >-1 ){ + $.hotFlag = true + } + } + } + } catch (e) { + console.log(e) + } +} + +function getPostRequest(url, body, method="POST") { + let headers = { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Content-Type": "application/x-www-form-urlencoded", + "Cookie": cookie, + "User-Agent": $.UA, + "X-Requested-With": "XMLHttpRequest" + } + if(url.indexOf('https://lzdz1-isv.isvjcloud.com') > -1){ + headers["Referer"] = `https://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}` + headers["Cookie"] = `${lz_jdpin_token_cookie && lz_jdpin_token_cookie || ''}${$.Pin && "AUTH_C_USER=" + $.Pin + ";" || ""}${activityCookie}` + } + // console.log(headers) + // console.log(headers.Cookie) + return {url: url, method: method, headers: headers, body: body, timeout:30000}; +} + +function getCk() { + return new Promise(resolve => { + let get = { + url:`https://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}`, + followRedirect:false, + headers: { + "User-Agent": $.UA, + }, + timeout:30000 + } + $.get(get, async(err, resp, data) => { + try { + if (err) { + if(resp && typeof resp.statusCode != 'undefined'){ + if(resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + } + console.log(`${$.toStr(err)}`) + console.log(`${$.name} cookie API请求失败,请检查网路重试`) + } else { + let end = data.match(/(活动已经结束)/) && data.match(/(活动已经结束)/)[1] || '' + if(end){ + $.activityEnd = true + console.log('活动已结束') + } + setActivityCookie(resp) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function setActivityCookie(resp){ + let LZ_TOKEN_KEY = '' + let LZ_TOKEN_VALUE = '' + let lz_jdpin_token = '' + let setcookies = resp && resp['headers'] && (resp['headers']['set-cookie'] || resp['headers']['Set-Cookie'] || '') || '' + let setcookie = '' + if(setcookies){ + if(typeof setcookies != 'object'){ + setcookie = setcookies.split(',') + }else setcookie = setcookies + for (let ck of setcookie) { + let name = ck.split(";")[0].trim() + if(name.split("=")[1]){ + // console.log(name.replace(/ /g,'')) + if(name.indexOf('LZ_TOKEN_KEY=')>-1) LZ_TOKEN_KEY = name.replace(/ /g,'')+';' + if(name.indexOf('LZ_TOKEN_VALUE=')>-1) LZ_TOKEN_VALUE = name.replace(/ /g,'')+';' + if(name.indexOf('lz_jdpin_token=')>-1) lz_jdpin_token = ''+name.replace(/ /g,'')+';' + } + } + } + if(LZ_TOKEN_KEY && LZ_TOKEN_VALUE) activityCookie = `${LZ_TOKEN_KEY} ${LZ_TOKEN_VALUE}` + if(lz_jdpin_token) lz_jdpin_token_cookie = lz_jdpin_token +} + +async function getUA(){ + $.UA = `jdapp;iPhone;10.1.4;13.1.2;${randomString(40)};network/wifi;model/iPhone8,1;addressid/2308460611;appBuild/167814;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_1_2 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 joinShop() { + if(!$.joinVenderId) return + return new Promise(async resolve => { + $.shopactivityId = '' + await $.wait(1000) + await getshopactivityId() + let activityId = `` + if($.shopactivityId) activityId = `,"activityId":${$.shopactivityId}` + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body={"venderId":"${$.joinVenderId}","shopId":"${$.joinVenderId}","bindByVerifyCodeFlag":1,"registerExtend":{},"writeChildFlag":0${activityId},"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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + // console.log(data) + let res = $.toObj(data,data); + if(typeof res == 'object'){ + if(res.success === true){ + console.log(res.message) + if(res.result && res.result.giftInfo){ + for(let i of res.result.giftInfo.giftList){ + console.log(`入会获得:${i.discountString}${i.prizeName}${i.secondLineDesc}`) + } + } + }else if(typeof res == 'object' && res.message){ + console.log(`${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function getshopactivityId() { + return new Promise(resolve => { + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body=%7B%22venderId%22%3A%22${$.joinVenderId}%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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + let res = $.toObj(data,data); + if(typeof res == 'object'){ + if(res.success == true){ + // console.log($.toStr(res.result)) + console.log(`入会:${res.result.shopMemberCardInfo.venderCardName || ''}`) + $.shopactivityId = res.result.interestsRuleList && res.result.interestsRuleList[0] && res.result.interestsRuleList[0].interestsInfo && res.result.interestsRuleList[0].interestsInfo.activityId || '' + } + }else{ + console.log(data) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} + + +// 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)} diff --git a/activity/jd_opencardL57.js b/activity/jd_opencardL57.js new file mode 100644 index 0000000..9e5c0ca --- /dev/null +++ b/activity/jd_opencardL57.js @@ -0,0 +1,825 @@ +/* +2022.1.21-1.28 年货不打烊 好物带回家 + + +第一个账号助力作者 其他依次助力CK1 +第一个CK失效会退出脚本 + +———————————————— +入口:https://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=dzlhkkkbblnt20220121A&shareUuid=be5bf0a866124301898d7457c05a8894 + +请求太频繁会被黑ip +过10分钟再执行 + + +cron:21 4,10 21-28 1 * +============Quantumultx=============== +[task_local] +#2022.1.21-1.28 年货不打烊 好物带回家 +21 4,10 21-28 1 * https://raw.githubusercontent.com/KingRan/JDJB/main/jd_opencardL57.js, tag=2022.1.21-1.28 年货不打烊 好物带回家, enabled=true + +*/ +const $ = new Env("2022.1.21-1.28 年货不打烊 好物带回家"); +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const notify = $.isNode() ? require('./sendNotify') : ''; +//IOS等用户直接用NobyDa的jd cookie + +let cookiesArr = [], + cookie = ''; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} +allMessage = "" +message = "" +$.hotFlag = false +$.outFlag = false +$.activityEnd = false +let lz_jdpin_token_cookie ='' +let activityCookie ='' +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', { + "open-url": "https://bean.m.jd.com/" + }); + return; + } + $.activityId = "dzlhkkkbblnt20220121A" + $.shareUuid = "be5bf0a866124301898d7457c05a8894" + console.log(`入口:\nhttps://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}`) + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i]; + if (cookie) { + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + message = "" + $.bean = 0 + $.hotFlag = false + $.nickName = ''; + console.log(`\n\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + await getUA() + await run(); + if(i == 0 && !$.actorUuid) break + if($.outFlag || $.activityEnd) break + } + } + if($.outFlag) { + let msg = '此ip已被限制,请过10分钟后再执行脚本' + $.msg($.name, ``, `${msg}`); + if ($.isNode()) await notify.sendNotify(`${$.name}`, `${msg}`); + } +})() + .catch((e) => $.logErr(e)) + .finally(() => $.done()) + + +async function run() { + try { + $.hasEnd = true + $.endTime = 0 + lz_jdpin_token_cookie = '' + $.Token = '' + $.Pin = '' + let flag = false + await takePostRequest('isvObfuscator'); + if($.Token == ''){ + console.log('获取[token]失败!') + return + } + await getCk() + if (activityCookie == '') { + console.log(`获取cookie失败`); return; + } + if($.activityEnd === true){ + console.log('活动结束') + return + } + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + await takePostRequest('getSimpleActInfoVo'); + await takePostRequest('getMyPing'); + if(!$.Pin){ + console.log('获取[Pin]失败!') + return + } + await takePostRequest('accessLogWithAD'); + await takePostRequest('getUserInfo'); + await takePostRequest('activityContent'); + if($.hotFlag) return + if(!$.actorUuid){ + console.log('获取不到[actorUuid]退出执行,请重新执行') + return + } + // console.log($.actorUuid) + // return + if($.hasEnd === true || Date.now() > $.endTime){ + $.activityEnd = true + console.log('活动结束') + return + } + await takePostRequest('drawContent'); + await $.wait(1000) + $.openList = [] + $.allOpenCard = false + await takePostRequest('info'); + await takePostRequest('checkOpenCard'); + if($.allOpenCard == false){ + console.log('开卡任务') + for(o of $.openList){ + $.openCard = false + if(o.status == 0){ + flag = true + $.joinVenderId = o.venderId + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + await joinShop() + await $.wait(parseInt(Math.random() * 1000 + 1000, 10)) + await takePostRequest('activityContent'); + await takePostRequest('drawContent'); + await takePostRequest('checkOpenCard'); + await $.wait(parseInt(Math.random() * 3000 + 2000, 10)) + } + } + }else{ + console.log('已全部开卡') + } + + $.log("关注: " + $.followShop) + if(!$.followShop && !$.outFlag){ + flag = true + await takePostRequest('followShop'); + await $.wait(parseInt(Math.random() * 2000 + 3000, 10)) + } + $.yaoqing = false + await takePostRequest('邀请'); + if($.yaoqing){ + await takePostRequest('助力'); + } + $.log("加购: " + $.addCart) + if(!$.addCart && !$.outFlag){ + flag = true + await takePostRequest('addCart'); + await $.wait(parseInt(Math.random() * 2000 + 4000, 10)) + } + $.runFalag = true + $.log("浏览商品: " + $.visitSku) + if(!$.visitSku && !$.outFlag){ + flag = true + for(let v of $.visitSkuList || []){ + if($.runFalag == false) break + if(v.goodsCode && v.status === 0){ + $.visitSkuValue = v.goodsCode + await takePostRequest('browseGoods'); + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + } + } + } + $.runFalag = true + let count = parseInt($.drawCount, 10) + console.log(`抽奖次数为:${count}`) + for(m=1;count--;m++){ + console.log(`第${m}次抽奖`) + await takePostRequest('startDraw'); + if($.runFalag == false) break + if(Number(count) <= 0) break + if(m >= 30){ + console.log("抽奖太多次,多余的次数请再执行脚本") + break + } + await $.wait(parseInt(Math.random() * 2000 + 2000, 10)) + } + if(flag){ + await takePostRequest('activityContent'); + } + console.log(`${$.score}值 游戏:${$.point}`) + $.runFalag = true + count = parseInt($.score/100) + console.log(`抽奖次数为:${count}`) + for(m=1;count--;m++){ + console.log(`第${m}次抽奖`) + await takePostRequest('抽奖'); + if($.runFalag == false) break + if(Number(count) <= 0) break + if(m >= 10){ + console.log("抽奖太多次,多余的次数请再执行脚本") + break + } + await $.wait(parseInt(Math.random() * 2000 + 2000, 10)) + } + + await $.wait(parseInt(Math.random() * 1000 + 2000, 10)) + await takePostRequest('getDrawRecordHasCoupon'); + await takePostRequest('getShareRecord'); + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + console.log($.actorUuid) + console.log(`当前助力:${$.shareUuid}`) + if($.index == 1){ + $.shareUuid = $.actorUuid + console.log(`后面的号都会助力:${$.shareUuid}`) + } + await $.wait(parseInt(Math.random() * 1000 + 5000, 10)) + if(flag) await $.wait(parseInt(Math.random() * 1000 + 10000, 10)) + + if($.index % 3 == 0) console.log('休息1分钟,别被黑ip了\n可持续发展') + if($.index % 3 == 0) await $.wait(parseInt(Math.random() * 5000 + 60000, 10)) + + } catch (e) { + console.log(e) + } +} + +async function takePostRequest(type) { + if($.outFlag) return + let domain = 'https://lzdz1-isv.isvjcloud.com'; + let body = ``; + let method = 'POST' + let admJson = '' + switch (type) { + case 'isvObfuscator': + url = `https://api.m.jd.com/client.action?functionId=isvObfuscator`; + body = `body=%7B%22url%22%3A%22https%3A//lzdz1-isv.isvjcloud.com%22%2C%22id%22%3A%22%22%7D&uuid=7088d9018515b8cb0c88ace6e5479762af3e88f3&client=apple&clientVersion=10.1.4&st=1634343624086&sv=120&sign=8b9cea22c3a0d77026abda5d37d2b7e3`; + break; + case 'getSimpleActInfoVo': + url = `${domain}/dz/common/getSimpleActInfoVo`; + body = `activityId=${$.activityId}`; + break; + case 'getMyPing': + url = `${domain}/customer/getMyPing`; + body = `userId=${$.shopId || $.venderId || ''}&token=${$.Token}&fromType=APP`; + break; + case 'accessLogWithAD': + url = `${domain}/common/accessLogWithAD`; + let pageurl = `${domain}/drawCenter/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}` + body = `venderId=${$.shopId || $.venderId || ''}&code=99&pin=${encodeURIComponent($.Pin)}&activityId=${$.activityId}&pageUrl=${encodeURIComponent(pageurl)}&subType=app&adSource=` + break; + case 'getUserInfo': + url = `${domain}/wxActionCommon/getUserInfo`; + body = `pin=${encodeURIComponent($.Pin)}`; + break; + case 'activityContent': + url = `${domain}/dingzhi/linkgame/activity/content`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&pinImg=${encodeURIComponent($.attrTouXiang)}&nick=${encodeURIComponent($.nickname)}&cjyxPin=&cjhyPin=&shareUuid=${$.shareUuid}` + break; + case 'drawContent': + url = `${domain}/dingzhi/taskact/common/drawContent`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case 'checkOpenCard': + url = `${domain}/dingzhi/linkgame/checkOpenCard`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case 'info': + url = `${domain}/dingzhi/linkgame/task/info`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case 'startDraw': + url = `${domain}/dingzhi/linkgame/draw/bean`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case 'followShop': + url = `${domain}/dingzhi/linkgame/follow/shop`; + // url = `${domain}/dingzhi/dz/openCard/saveTask`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case 'sign': + case 'addCart': + case 'browseGoods': + url = `${domain}/dingzhi/linkgame/${type}`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + if(type == 'browseGoods') body += `&value=${$.visitSkuValue}` + break; + case '邀请': + case '助力': + if(type == '助力'){ + url = `${domain}/dingzhi/linkgame/assist`; + }else{ + url = `${domain}/dingzhi/linkgame/assist/status`; + } + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&shareUuid=${$.shareUuid}` + break; + case 'viewVideo': + case 'visitSku': + case 'toShop': + case 'addSku': + url = `${domain}/dingzhi/dz/openCard/saveTask`; + let taskType = '' + let taskValue = '' + if(type == 'viewVideo'){ + taskType = 31 + taskValue = 31 + }else if(type == 'visitSku'){ + taskType = 5 + taskValue = $.visitSkuValue || 5 + }else if(type == 'toShop'){ + taskType = 14 + taskValue = $.toShopValue || 14 + }else if(type == 'addSku'){ + taskType = 2 + taskValue = $.addSkuValue || 2 + } + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&taskType=${taskType}&taskValue=${taskValue}` + break; + case 'getDrawRecordHasCoupon': + url = `${domain}/dingzhi/linkgame/draw/record`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case 'getShareRecord': + url = `${domain}/dingzhi/linkgame/help/list`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case '抽奖': + url = `${domain}/dingzhi/linkgame/draw`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + default: + console.log(`错误${type}`); + } + let myRequest = getPostRequest(url, body, method); + // console.log(myRequest) + return new Promise(async resolve => { + $.post(myRequest, (err, resp, data) => { + try { + setActivityCookie(resp) + if (err) { + if(resp && typeof resp.statusCode != 'undefined'){ + if(resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + } + console.log(`${$.toStr(err,err)}`) + console.log(`${type} API请求失败,请检查网路重试`) + } else { + dealReturn(type, data); + } + } catch (e) { + // console.log(data); + console.log(e, resp) + } finally { + resolve(); + } + }) + }) + } + +async function dealReturn(type, data) { + let res = '' + try { + if(type != 'accessLogWithAD' || type != 'drawContent'){ + if(data){ + res = JSON.parse(data); + } + } + } catch (e) { + console.log(`${type} 执行任务异常`); + console.log(data); + $.runFalag = false; + } + try { + switch (type) { + case 'isvObfuscator': + if(typeof res == 'object'){ + if(res.errcode == 0){ + if(typeof res.token != 'undefined') $.Token = res.token + }else if(res.message){ + console.log(`isvObfuscator ${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + break; + case 'getSimpleActInfoVo': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(typeof res.data.shopId != 'undefined') $.shopId = res.data.shopId + if(typeof res.data.venderId != 'undefined') $.venderId = res.data.venderId + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getMyPing': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(res.data && typeof res.data.secretPin != 'undefined') $.Pin = res.data.secretPin + if(res.data && typeof res.data.nickname != 'undefined') $.nickname = res.data.nickname + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getUserInfo': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(res.data && typeof res.data.yunMidImageUrl != 'undefined') $.attrTouXiang = res.data.yunMidImageUrl || "https://img10.360buyimg.com/imgzone/jfs/t1/7020/27/13511/6142/5c5138d8E4df2e764/5a1216a3a5043c5d.png" + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'activityContent': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + $.endTime = res.data.endTime || res.data.activity.endTime || 0 + $.hasEnd = res.data.isEnd || false + $.drawCount = res.data.actor.drawCount || 0 + $.point = res.data.actor.point || 0 + $.score = res.data.actor.score || 0 + $.actorUuid = res.data.actor.actorUuid || '' + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'info': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + // $.drawCount = res.data.drawCount || 0 + $.addCart = res.data.addCart || false + $.followShop = res.data.followShop || false + $.sign = res.data.sign || false + $.visitSku = res.data.visitSku || false + $.visitSkuList = res.data.visitSkuList || [] + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'checkOpenCard': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + let cardList1 = res.data.cardList1 || [] + let cardList2 = res.data.cardList2 || [] + let cardList = res.data.cardList || [] + let openCardList = res.data.openCardList || [] + $.openList = [...cardList,...cardList1,...cardList2,...openCardList] + $.allOpenCard = res.data.allOpenCard || false + $.openCardScore1 = res.data.score1 || 0 + $.openCardScore2 = res.data.score2 || 0 + $.drawScore = res.data.drawScore || 0 + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'startDraw': + case 'followShop': + case 'viewVideo': + case 'visitSku': + case 'toShop': + case 'addSku': + case 'sign': + case 'addCart': + case 'browseGoods': + case '抽奖': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(typeof res.data == 'object'){ + let msg = '' + let title = '抽奖' + if(res.data.addBeanNum){ + msg = `${res.data.addBeanNum}京豆` + } + if(res.data.addPoint){ + msg += ` ${res.data.addPoint}游戏机会` + } + if(type == 'followShop'){ + title = '关注' + if(res.data.beanNumMember && res.data.assistSendStatus){ + msg += ` 额外获得:${res.data.beanNumMember}京豆` + } + }else if(type == 'addSku' || type == 'addCart'){ + title = '加购' + }else if(type == 'viewVideo'){ + title = '热门文章' + }else if(type == 'toShop'){ + title = '浏览店铺' + }else if(type == 'visitSku' || type == 'browseGoods'){ + title = '浏览商品' + }else if(type == 'sign'){ + title = '签到' + }else{ + msg = res.data.drawOk == true && (res.data.drawInfoType == 6 && res.data.name || '') || '空气💨' + } + if(!msg){ + msg = '空气💨' + } + console.log(`${title}获得:${msg || data}`) + }else{ + console.log(`${type} ${data}`) + } + }else if(res.errorMessage){ + $.runFalag = false; + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getDrawRecordHasCoupon': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + console.log(`我的奖品:`) + let num = 0 + let value = 0 + for(let i in res.data.recordList){ + let item = res.data.recordList[i] + if(item.infoName == '20京豆'){ + num++ + value = item.infoName.replace('京豆','') + }else{ + console.log(`${item.infoType != 10 && item.value && item.value +':' || ''}${item.infoName}`) + } + } + if(num > 0) console.log(`邀请好友(${num}):${num*parseInt(value, 10) || 30}京豆`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getShareRecord': + if(typeof res == 'object'){ + if(res.result && res.result === true && res.data){ + $.ShareCount = res.data.shareList.length + $.log(`=========== 你邀请了:${res.data.shareList.length}个`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case '邀请': + case '助力': + // console.log(data) + if(typeof res == 'object'){ + if(res.data.status == 200){ + if(type == '助力'){ + console.log('助力成功') + }else{ + $.yaoqing = true + } + }else if(res.data.status == 105){ + console.log('已经助力过') + }else if(res.data.status == 104){ + console.log('已经助力其他人') + }else if(res.data.status == 101){ + // console.log('已经助力过') + }else{ + console.log(data) + } + }else{ + console.log(`${type} ${data}`) + } + + case 'accessLogWithAD': + case 'drawContent': + break; + default: + console.log(`${type}-> ${data}`); + } + if(typeof res == 'object'){ + if(res.errorMessage){ + if(res.errorMessage.indexOf('火爆') >-1 ){ + $.hotFlag = true + } + } + } + } catch (e) { + console.log(e) + } +} + +function getPostRequest(url, body, method="POST") { + let headers = { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Content-Type": "application/x-www-form-urlencoded", + "Cookie": cookie, + "User-Agent": $.UA, + "X-Requested-With": "XMLHttpRequest" + } + if(url.indexOf('https://lzdz1-isv.isvjcloud.com') > -1){ + headers["Referer"] = `https://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}` + headers["Cookie"] = `${lz_jdpin_token_cookie && lz_jdpin_token_cookie || ''}${$.Pin && "AUTH_C_USER=" + $.Pin + ";" || ""}${activityCookie}` + } + // console.log(headers) + // console.log(headers.Cookie) + return {url: url, method: method, headers: headers, body: body, timeout:30000}; +} + +function getCk() { + return new Promise(resolve => { + let get = { + url:`https://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}`, + followRedirect:false, + headers: { + "User-Agent": $.UA, + }, + timeout:30000 + } + $.get(get, async(err, resp, data) => { + try { + if (err) { + if(resp && typeof resp.statusCode != 'undefined'){ + if(resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + } + console.log(`${$.toStr(err)}`) + console.log(`${$.name} cookie API请求失败,请检查网路重试`) + } else { + let end = data.match(/(活动已经结束)/) && data.match(/(活动已经结束)/)[1] || '' + if(end){ + $.activityEnd = true + console.log('活动已结束') + } + setActivityCookie(resp) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function setActivityCookie(resp){ + let LZ_TOKEN_KEY = '' + let LZ_TOKEN_VALUE = '' + let lz_jdpin_token = '' + let setcookies = resp && resp['headers'] && (resp['headers']['set-cookie'] || resp['headers']['Set-Cookie'] || '') || '' + let setcookie = '' + if(setcookies){ + if(typeof setcookies != 'object'){ + setcookie = setcookies.split(',') + }else setcookie = setcookies + for (let ck of setcookie) { + let name = ck.split(";")[0].trim() + if(name.split("=")[1]){ + // console.log(name.replace(/ /g,'')) + if(name.indexOf('LZ_TOKEN_KEY=')>-1) LZ_TOKEN_KEY = name.replace(/ /g,'')+';' + if(name.indexOf('LZ_TOKEN_VALUE=')>-1) LZ_TOKEN_VALUE = name.replace(/ /g,'')+';' + if(name.indexOf('lz_jdpin_token=')>-1) lz_jdpin_token = ''+name.replace(/ /g,'')+';' + } + } + } + if(LZ_TOKEN_KEY && LZ_TOKEN_VALUE) activityCookie = `${LZ_TOKEN_KEY} ${LZ_TOKEN_VALUE}` + if(lz_jdpin_token) lz_jdpin_token_cookie = lz_jdpin_token +} + +async function getUA(){ + $.UA = `jdapp;iPhone;10.1.4;13.1.2;${randomString(40)};network/wifi;model/iPhone8,1;addressid/2308460611;appBuild/167814;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_1_2 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 joinShop() { + if(!$.joinVenderId) return + return new Promise(async resolve => { + $.shopactivityId = '' + await $.wait(1000) + await getshopactivityId() + let activityId = `` + if($.shopactivityId) activityId = `,"activityId":${$.shopactivityId}` + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body={"venderId":"${$.joinVenderId}","shopId":"${$.joinVenderId}","bindByVerifyCodeFlag":1,"registerExtend":{},"writeChildFlag":0${activityId},"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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + // console.log(data) + let res = $.toObj(data,data); + if(typeof res == 'object'){ + if(res.success === true){ + console.log(res.message) + if(res.result && res.result.giftInfo){ + for(let i of res.result.giftInfo.giftList){ + console.log(`入会获得:${i.discountString}${i.prizeName}${i.secondLineDesc}`) + } + } + }else if(typeof res == 'object' && res.message){ + console.log(`${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function getshopactivityId() { + return new Promise(resolve => { + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body=%7B%22venderId%22%3A%22${$.joinVenderId}%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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + let res = $.toObj(data,data); + if(typeof res == 'object'){ + if(res.success == true){ + // console.log($.toStr(res.result)) + console.log(`入会:${res.result.shopMemberCardInfo.venderCardName || ''}`) + $.shopactivityId = res.result.interestsRuleList && res.result.interestsRuleList[0] && res.result.interestsRuleList[0].interestsInfo && res.result.interestsRuleList[0].interestsInfo.activityId || '' + } + }else{ + console.log(data) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} + + +// 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)} diff --git a/activity/jd_opencardL58.js b/activity/jd_opencardL58.js new file mode 100644 index 0000000..00ff7f9 --- /dev/null +++ b/activity/jd_opencardL58.js @@ -0,0 +1,611 @@ +/* +1.21 - 1.26 大牌集结 玩转年货节 +新增开卡脚本 +一次性脚本 + +第一个账号助力作者 其他依次助力CK1 +第一个CK失效会退出脚本 + +———————————————— +入口:[ 1.21 - 1.26 大牌集结 玩转年货节 (https://lzdz1-isv.isvjcloud.com/dingzhi/dz/openCard/activity?activityId=14e6bdc3ee7a496f87b89eee902a370e&shareUuid=3004fd71aceb4100a0fc36c0344b0c4e)] + +请求太频繁会被黑ip +过10分钟再执行 + +cron:37 14 21-26 1 * +============Quantumultx=============== +[task_local] +#1.21 - 1.26 大牌集结 玩转年货节 +37 14 21-26 1 * jd_opencardL58.js, tag=1.21 - 1.26 大牌集结 玩转年货节, enabled=true + +*/ +const $ = new Env("1.21 - 1.26 大牌集结,玩转年货节"); +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const notify = $.isNode() ? require('./sendNotify') : ''; +let cookiesArr = [], cookie = '', message = ''; +let ownCode = null; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => { }; +} else { + let cookiesData = $.getdata('CookiesJD') || "[]"; + cookiesData = JSON.parse(cookiesData); + cookiesArr = cookiesData.map(item => item.cookie); + cookiesArr.reverse(); + cookiesArr.push(...[$.getdata('CookieJD2'), $.getdata('CookieJD')]); + cookiesArr.reverse(); + cookiesArr = cookiesArr.filter(item => !!item); +} +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', { "open-url": "https://bean.m.jd.com/bean/signIndex.action" }); + return; + } + authorCodeList = [ + '3004fd71aceb4100a0fc36c0344b0c4e', + ] + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i] + originCookie = cookiesArr[i] + newCookie = '' + $.UserName = decodeURIComponent(cookie.match(/pt_pin=(.+?);/) && cookie.match(/pt_pin=(.+?);/)[1]) + $.index = i + 1; + $.isLogin = true; + $.nickName = ''; + await checkCookie(); + console.log(`\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + if (!$.isLogin) { + $.msg($.name, `【提示】cookie已失效`, `京东账号${$.index} ${$.nickName || $.UserName}\n请重新登录获取\nhttps://bean.m.jd.com/bean/signIndex.action`, { "open-url": "https://bean.m.jd.com/bean/signIndex.action" }); + if ($.isNode()) { + await notify.sendNotify(`${$.name}cookie已失效 - ${$.UserName}`, `京东账号${$.index} ${$.UserName}\n请重新登录获取cookie`); + } + continue + } + $.bean = 0; + $.ADID = getUUID('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', 1); + $.UUID = getUUID('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'); + // $.authorCode = authorCodeList[random(0, authorCodeList.length)] + $.authorCode = ownCode ? ownCode : authorCodeList[random(0, authorCodeList.length)] + $.authorNum = `${random(1000000, 9999999)}` + $.randomCode = random(1000000, 9999999) + $.activityId = '14e6bdc3ee7a496f87b89eee902a370e' + $.activityShopId = '1000013169' + $.activityUrl = `https://lzdz1-isv.isvjd.com/dingzhi/dz/openCard/activity/${$.authorNum}?activityId=${$.activityId}&shareUuid=${encodeURIComponent($.authorCode)}&adsource=null&shareuserid4minipg=null&shopid=${$.activityShopId}&lng=00.000000&lat=00.000000&sid=&un_area=` + await marry(); + await $.wait(3000) + if ($.bean > 0) { + message += `\n【京东账号${$.index}】${$.nickName || $.UserName} \n └ 获得 ${$.bean} 京豆。` + } + } + } + if (message !== '') { + if ($.isNode()) { + await notify.sendNotify($.name, message, '', `\n`); + } else { + $.msg($.name, '有点儿收获', message); + } + } +})() + .catch((e) => { + $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') + }) + .finally(() => { + $.done(); + }) + + +async function marry() { + $.log('那就开始吧。') + $.token = null; + $.secretPin = null; + $.openCardActivityId = null + await getFirstLZCK() + await getToken(); + if ($.token) { + await getMyPing(); + if ($.secretPin) { + console.log("去助力 -> "+$.authorCode) + await task('common/accessLogWithAD', `venderId=${$.activityShopId}&code=99&pin=${encodeURIComponent($.secretPin)}&activityId=${$.activityId}&pageUrl=${$.activityUrl}&subType=app&adSource=null`, 1); + await task('wxActionCommon/getUserInfo', `pin=${encodeURIComponent($.secretPin)}`, 1) + if ($.index === 1) { + await task('dz/openCard/activityContent', `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}&pinImg=&nick=${encodeURIComponent($.pin)}&cjyxPin=&cjhyPin=&shareUuid=${encodeURIComponent($.authorCode)}`, 0, 1) + } else { + await task('dz/openCard/activityContent', `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}&pinImg=&nick=${encodeURIComponent($.pin)}&cjyxPin=&cjhyPin=&shareUuid=${encodeURIComponent($.authorCode)}`) + } + await task('dz/openCard/checkOpenCard', `activityId=${$.activityId}&actorUuid=${$.actorUuid}&shareUuid=${$.authorCode}&pin=${encodeURIComponent($.secretPin)}`) + $.log("->关注店铺") + if ($.shopTask) { + if (!$.shopTask.allStatus) { + await task('dz/openCard/followShop', `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}&actorUuid=${encodeURIComponent($.actorUuid)}&taskType=23&taskValue=1000002520`) + } else { + $.log(" >>>已经关注过了\n") + await $.wait(2000) + // return + } + } else { + $.log("没有获取到对应的任务。\n") + } + $.log("->->->> 加入店铺会员") + if ($.openCardStatus) { + $.log("模拟上报访问记录") + for (let i = 0; i < ($.openCardStatus.cardList1.length + $.openCardStatus.cardList2.length); i++) { + await task('crm/pageVisit/insertCrmPageVisit', `venderId=1000221763&pageId=dz2021101420000sjleowq&elementId=${encodeURIComponent(`去开卡${i}`)}&pin=${encodeURIComponent($.secretPin)}`, 1) + await $.wait(2000) + } + t1TaskList = [] + $.openCardStatus.cardList1.filter((x) => { if (x.status === 0) { t1TaskList.push(x) } }) + t2TaskList = [] + $.openCardStatus.cardList2.filter((x) => { if (x.status === 0) { t2TaskList.push(x) } }) + t3TaskList = [] + $.openCardStatus.cardList3.filter((x) => { if (x.status === 0) { t1TaskList.push(x) } }) + t4TaskList = [] + $.openCardStatus.cardList4.filter((x) => { if (x.status === 0) { t2TaskList.push(x) } }) + if (t1TaskList.length < 1) { + console.log(" >>>已经完成入会任务") + + } else { + for (const vo of t1TaskList) { + $.log(` >>>去加入${vo.name}`) + await getShopOpenCardInfo({ "venderId": `${vo.value}`, "channel": "401" }, vo.value) + await bindWithVender({ "venderId": `${vo.value}`, "bindByVerifyCodeFlag": 1, "registerExtend": {}, "writeChildFlag": 0, "activityId": $.openCardActivityId, "channel": 401 }, vo.value) + await $.wait(2000) + } + for (const vo of t2TaskList) { + $.log(` >>>${vo.name}`) + await getShopOpenCardInfo({ "venderId": `${vo.value}`, "channel": "401" }) + await bindWithVender({ "venderId": `${vo.value}`, "bindByVerifyCodeFlag": 1, "registerExtend": {}, "writeChildFlag": 0, "activityId": $.openCardActivityId, "channel": 401 }, vo.value) + await $.wait(2000) + } + for (const vo of t3TaskList) { + $.log(` >>>${vo.name}`) + await getShopOpenCardInfo({ "venderId": `${vo.value}`, "channel": "401" }) + await bindWithVender({ "venderId": `${vo.value}`, "bindByVerifyCodeFlag": 1, "registerExtend": {}, "writeChildFlag": 0, "activityId": $.openCardActivityId, "channel": 401 }, vo.value) + await $.wait(2000) + } + for (const vo of t4TaskList) { + $.log(` >>>${vo.name}`) + await getShopOpenCardInfo({ "venderId": `${vo.value}`, "channel": "401" }) + await bindWithVender({ "venderId": `${vo.value}`, "bindByVerifyCodeFlag": 1, "registerExtend": {}, "writeChildFlag": 0, "activityId": $.openCardActivityId, "channel": 401 }, vo.value) + await $.wait(2000) + } + } + + await task("taskact/openCardcommon/drawContent", `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}`) + await $.wait(2000) + await task('dz/openCard/checkOpenCard', `activityId=${$.activityId}&actorUuid=${$.actorUuid}&shareUuid=${$.authorCode}&pin=${encodeURIComponent($.secretPin)}`) + await $.wait(2000) + await task("dz/openCard/startDraw", `activityId=${$.activityId}&actorUuid=${$.actorUuid}&type=2&pin=${encodeURIComponent($.secretPin)}`) + await $.wait(2000) + await task("dz/openCard/saveTask", `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}&actorUuid=${$.actorUuid}&taskType=2&taskValue=100024065130`) + + } else { + $.log("没有获取到对应的任务。\n") + } + $.log("->->->> 加购物车") + await task("dz/openCard/saveTask", `activityId=${$.activityId}&pin=${encodeURIComponent($.secretPin)}&actorUuid=${$.actorUuid}&type=2&taskValue=10036669682406`) + } + } +} + +function task(function_id, body, isCommon = 0, own = 0) { + return new Promise(resolve => { + $.post(taskUrl(function_id, body, isCommon), async (err, resp, data) => { + try { + if (err) { + $.log(err) + } else { + + if (data) { + data = JSON.parse(data); + if (data.result) { + switch (function_id) { + case 'wxActionCommon/getUserInfo': + break; + case 'dz/openCard/activityContent': + if (!data.data.hasEnd) { + $.log(`开启【${data.data.activityName}】活动`) + $.log("-------------------") + if ($.index === 1) { + ownCode = data.data.actorUuid + console.log(ownCode) + } + $.actorUuid = data.data.actorUuid; + $.skuTask = data.data.addSku; + $.shopTask = data.data.followShop; + } else { + $.log("活动已经结束"); + } + break; + case 'dz/openCard/checkOpenCard': + $.openCardStatus = data.data; + break; + case 'dz/openCard/saveTask': + console.log(data.data.addBeanNum) + break; + case 'dz/openCard/saveTask': + if (data.data) { + if (data.data.addBeanNum) { + $.bean += data.data.addBeanNum; + $.log(`==>获得【${data.data.addBeanNum}】京豆\n`) + } + } + break; + case 'dz/openCard/startDraw': + if (data.data.drawOk) { + switch (data.data.drawInfo.type) { + case 6: + $.bean += data.data.drawInfo.beanNum; + $.log(`==>获得【${data.data.drawInfo.beanNum}】京豆\n`) + break; + default: + if ($.isNode()) { + await notify.sendNotify("中奖了", `中奖信息:${JSON.stringify(data.data.drawInfo)}\n活动链接:${$.activityUrl}`) + } else { + $.msg("中奖了", `获得${data.data.drawInfo.name}`, `中奖信息:${JSON.stringify(data.data.drawInfo)}\n活动链接:${$.activityUrl}`) + } + break; + } + } + break; + case 'crm/pageVisit/insertCrmPageVisit': + $.log("==> 上报成功") + break; + case 'dz/openCard/followShop': + if (data.data) { + if (data.data.addBeanNum) { + $.bean += data.data.addBeanNum; + $.log(`==>获得【${data.data.addBeanNum}】京豆\n`) + } + } + break; + default: + $.log(JSON.stringify(data)) + break; + } + } else { + $.log(JSON.stringify(data)) + } + } else { + // $.log("京东没有返回数据") + } + } + } catch (error) { + $.log(error) + } finally { + resolve(); + } + }) + }) +} +function getShopOpenCardInfo(body, venderId) { + let opt = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body=${encodeURIComponent(JSON.stringify(body))}&client=H5&clientVersion=9.2.0&uuid=88888`, + headers: { + Host: 'api.m.jd.com', + Accept: '*/*', + Connection: 'keep-alive', + Cookie: cookie, + 'User-Agent': `jdapp;iPhone;9.5.4;13.6;${$.UUID};network/wifi;ADID/${$.ADID};model/iPhone10,3;addressid/0;appBuild/167668;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1`, + 'Accept-Language': 'zh-cn', + Referer: `https://shopmember.m.jd.com/shopcard/?venderId=${venderId}}&channel=801&returnUrl=${encodeURIComponent($.activityUrl)}`, + 'Accept-Encoding': 'gzip, deflate, br' + } + } + return new Promise(resolve => { + $.get(opt, (err, resp, data) => { + try { + if (err) { + console.log(err) + } else { + res = JSON.parse(data) + if (res.success) { + if (res.result.interestsRuleList) { + $.openCardActivityId = res.result.interestsRuleList[0].interestsInfo.activityId; + } + } + } + } catch (error) { + console.log(error) + } finally { + resolve(); + } + }) + + }) +} +function bindWithVender(body, venderId) { + let opt = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body=${encodeURIComponent(JSON.stringify(body))}&client=H5&clientVersion=9.2.0&uuid=88888`, + headers: { + Host: 'api.m.jd.com', + Accept: '*/*', + Connection: 'keep-alive', + Cookie: cookie, + 'User-Agent': `jdapp;iPhone;9.5.4;13.6;${$.UUID};network/wifi;ADID/${$.ADID};model/iPhone10,3;addressid/0;appBuild/167668;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1`, + 'Accept-Language': 'zh-cn', + Referer: `https://shopmember.m.jd.com/shopcard/?venderId=${venderId}}&channel=401&returnUrl=${encodeURIComponent($.activityUrl)}`, + 'Accept-Encoding': 'gzip, deflate, br' + } + } + return new Promise(resolve => { + $.get(opt, (err, resp, data) => { + try { + if (err) { + console.log(err) + } else { + res = JSON.parse(data) + if (res.success) { + if (res.result.giftInfo && res.result.giftInfo.giftList) { + for (const vo of res.result.giftInfo.giftList) { + if (vo.prizeType === 4) { + $.log(`==>获得【${vo.quantity}】京豆`) + $.bean += vo.quantity + } + } + } + } + } + } catch (error) { + console.log(error) + } finally { + resolve(); + } + }) + + }) +} +function taskUrl(function_id, body, isCommon) { + return { + url: isCommon ? `https://lzdz1-isv.isvjd.com/${function_id}` : `https://lzdz1-isv.isvjd.com/dingzhi/${function_id}`, + headers: { + Host: 'lzdz1-isv.isvjd.com', + Accept: 'application/json', + 'X-Requested-With': 'XMLHttpRequest', + 'Accept-Language': 'zh-cn', + 'Accept-Encoding': 'gzip, deflate, br', + 'Content-Type': 'application/x-www-form-urlencoded', + Origin: 'https://lzdz1-isv.isvjd.com', + 'User-Agent': `jdapp;iPhone;9.5.4;13.6;${$.UUID};network/wifi;ADID/${$.ADID};model/iPhone10,3;addressid/0;appBuild/167668;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1`, + Connection: 'keep-alive', + Referer: $.activityUrl, + Cookie: cookie + }, + body: body + + } +} +function getAuthorCodeList(url) { + return new Promise(resolve => { + const options = { + url: `${url}?${new Date()}`, "timeout": 10000, headers: { + "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1 Edg/87.0.4280.88" + } + }; + $.get(options, async (err, resp, data) => { + try { + if (err) { + $.log(err) + } else { + if (data) data = JSON.parse(data) + } + } catch (e) { + $.logErr(e, resp) + data = null; + } finally { + resolve(data); + } + }) + }) +} +function getMyPing() { + let opt = { + url: `https://lzdz1-isv.isvjd.com/customer/getMyPing`, + headers: { + Host: 'lzdz1-isv.isvjd.com', + Accept: 'application/json', + 'X-Requested-With': 'XMLHttpRequest', + 'Accept-Language': 'zh-cn', + 'Accept-Encoding': 'gzip, deflate, br', + 'Content-Type': 'application/x-www-form-urlencoded', + Origin: 'https://lzdz1-isv.isvjd.com', + 'User-Agent': `jdapp;iPhone;9.5.4;13.6;${$.UUID};network/wifi;ADID/${$.ADID};model/iPhone10,3;addressid/0;appBuild/167668;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1`, + Connection: 'keep-alive', + Referer: $.activityUrl, + Cookie: cookie, + }, + body: `userId=${$.activityShopId}&token=${$.token}&fromType=APP&riskType=1` + } + return new Promise(resolve => { + $.post(opt, (err, resp, data) => { + try { + if (err) { + $.log(err) + } else { + if (resp['headers']['set-cookie']) { + cookie = `${originCookie}` + if ($.isNode()) { + for (let sk of resp['headers']['set-cookie']) { + cookie = `${cookie}${sk.split(";")[0]};` + } + } else { + for (let ck of resp['headers']['Set-Cookie'].split(',')) { + cookie = `${cookie}${ck.split(";")[0]};` + } + } + } + if (resp['headers']['Set-Cookie']) { + cookie = `${originCookie}` + if ($.isNode()) { + for (let sk of resp['headers']['set-cookie']) { + cookie = `${cookie}${sk.split(";")[0]};` + } + } else { + for (let ck of resp['headers']['Set-Cookie'].split(',')) { + cookie = `${cookie}${ck.split(";")[0]};` + } + } + } + if (data) { + data = JSON.parse(data) + if (data.result) { + $.log(`你好:${data.data.nickname}`) + $.pin = data.data.nickname; + $.secretPin = data.data.secretPin; + cookie = `${cookie};AUTH_C_USER=${data.data.secretPin}` + } else { + $.log(data.errorMessage) + } + } else { + // $.log("京东返回了空数据") + } + } + } catch (error) { + $.log(error) + } finally { + resolve(); + } + + }) + }) +} +function getFirstLZCK() { + return new Promise(resolve => { + $.get({ url: $.activityUrl }, (err, resp, data) => { + try { + if (err) { + console.log(err) + } else { + if (resp['headers']['set-cookie']) { + cookie = `${originCookie}` + if ($.isNode()) { + for (let sk of resp['headers']['set-cookie']) { + cookie = `${cookie}${sk.split(";")[0]};` + } + } else { + for (let ck of resp['headers']['Set-Cookie'].split(',')) { + cookie = `${cookie}${ck.split(";")[0]};` + } + } + } + if (resp['headers']['Set-Cookie']) { + cookie = `${originCookie}` + if ($.isNode()) { + for (let sk of resp['headers']['set-cookie']) { + cookie = `${cookie}${sk.split(";")[0]};` + } + } else { + for (let ck of resp['headers']['Set-Cookie'].split(',')) { + cookie = `${cookie}${ck.split(";")[0]};` + } + } + } + } + } catch (error) { + console.log(error) + } finally { + resolve(); + } + }) + }) +} +function getToken() { + let opt = { + url: `https://api.m.jd.com/client.action?functionId=isvObfuscator`, + headers: { + Host: 'api.m.jd.com', + 'Content-Type': 'application/x-www-form-urlencoded', + Accept: '*/*', + Connection: 'keep-alive', + Cookie: cookie, + 'User-Agent': 'JD4iPhone/167650 (iPhone; iOS 13.7; Scale/3.00)', + 'Accept-Language': 'zh-Hans-CN;q=1', + 'Accept-Encoding': 'gzip, deflate, br', + }, + body: `body=%7B%22url%22%3A%20%22https%3A//lzkj-isv.isvjcloud.com%22%2C%20%22id%22%3A%20%22%22%7D&uuid=hjudwgohxzVu96krv&client=apple&clientVersion=9.4.0&st=1620476162000&sv=111&sign=f9d1b7e3b943b6a136d54fe4f892af05` + } + return new Promise(resolve => { + $.post(opt, (err, resp, data) => { + try { + if (err) { + $.log(err) + } else { + if (data) { + data = JSON.parse(data); + if (data.code === "0") { + $.token = data.token + } + } else { + $.log("京东返回了空数据") + } + } + } catch (error) { + $.log(error) + } finally { + resolve(); + } + }) + }) +} +function random(min, max) { + + return Math.floor(Math.random() * (max - min)) + min; + +} +function getUUID(format = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', UpperCase = 0) { + return format.replace(/[xy]/g, function (c) { + var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8); + if (UpperCase) { + uuid = v.toString(36).toUpperCase(); + } else { + uuid = v.toString(36) + } + return uuid; + }); +} +function checkCookie() { + const options = { + url: "https://me-api.jd.com/user_new/info/GetJDUserInfoUnion", + headers: { + "Host": "me-api.jd.com", + "Accept": "*/*", + "Connection": "keep-alive", + "Cookie": cookie, + "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.2 Mobile/15E148 Safari/604.1", + "Accept-Language": "zh-cn", + "Referer": "https://home.m.jd.com/myJd/newhome.action?sceneval=2&ufc=&", + "Accept-Encoding": "gzip, deflate, br", + } + }; + return new Promise(resolve => { + $.get(options, (err, resp, data) => { + try { + if (err) { + $.logErr(err) + } else { + if (data) { + data = JSON.parse(data); + if (data.retcode === "1001") { + $.isLogin = false; //cookie过期 + return; + } + if (data.retcode === "0" && data.data.hasOwnProperty("userInfo")) { + $.nickName = data.data.userInfo.baseInfo.nickname; + } + } else { + $.log('京东返回了空数据'); + } + } + } catch (e) { + $.logErr(e) + } finally { + resolve(); + } + }) + }) +} +// prettier-ignore +!function (n) { "use strict"; function t(n, t) { var r = (65535 & n) + (65535 & t); return (n >> 16) + (t >> 16) + (r >> 16) << 16 | 65535 & r } function r(n, t) { return n << t | n >>> 32 - t } function e(n, e, o, u, c, f) { return t(r(t(t(e, n), t(u, f)), c), o) } function o(n, t, r, o, u, c, f) { return e(t & r | ~t & o, n, t, u, c, f) } function u(n, t, r, o, u, c, f) { return e(t & o | r & ~o, n, t, u, c, f) } function c(n, t, r, o, u, c, f) { return e(t ^ r ^ o, n, t, u, c, f) } function f(n, t, r, o, u, c, f) { return e(r ^ (t | ~o), n, t, u, c, f) } function i(n, r) { n[r >> 5] |= 128 << r % 32, n[14 + (r + 64 >>> 9 << 4)] = r; var e, i, a, d, h, l = 1732584193, g = -271733879, v = -1732584194, m = 271733878; for (e = 0; e < n.length; e += 16)i = l, a = g, d = v, h = m, g = f(g = f(g = f(g = f(g = c(g = c(g = c(g = c(g = u(g = u(g = u(g = u(g = o(g = o(g = o(g = o(g, v = o(v, m = o(m, l = o(l, g, v, m, n[e], 7, -680876936), g, v, n[e + 1], 12, -389564586), l, g, n[e + 2], 17, 606105819), m, l, n[e + 3], 22, -1044525330), v = o(v, m = o(m, l = o(l, g, v, m, n[e + 4], 7, -176418897), g, v, n[e + 5], 12, 1200080426), l, g, n[e + 6], 17, -1473231341), m, l, n[e + 7], 22, -45705983), v = o(v, m = o(m, l = o(l, g, v, m, n[e + 8], 7, 1770035416), g, v, n[e + 9], 12, -1958414417), l, g, n[e + 10], 17, -42063), m, l, n[e + 11], 22, -1990404162), v = o(v, m = o(m, l = o(l, g, v, m, n[e + 12], 7, 1804603682), g, v, n[e + 13], 12, -40341101), l, g, n[e + 14], 17, -1502002290), m, l, n[e + 15], 22, 1236535329), v = u(v, m = u(m, l = u(l, g, v, m, n[e + 1], 5, -165796510), g, v, n[e + 6], 9, -1069501632), l, g, n[e + 11], 14, 643717713), m, l, n[e], 20, -373897302), v = u(v, m = u(m, l = u(l, g, v, m, n[e + 5], 5, -701558691), g, v, n[e + 10], 9, 38016083), l, g, n[e + 15], 14, -660478335), m, l, n[e + 4], 20, -405537848), v = u(v, m = u(m, l = u(l, g, v, m, n[e + 9], 5, 568446438), g, v, n[e + 14], 9, -1019803690), l, g, n[e + 3], 14, -187363961), m, l, n[e + 8], 20, 1163531501), v = u(v, m = u(m, l = u(l, g, v, m, n[e + 13], 5, -1444681467), g, v, n[e + 2], 9, -51403784), l, g, n[e + 7], 14, 1735328473), m, l, n[e + 12], 20, -1926607734), v = c(v, m = c(m, l = c(l, g, v, m, n[e + 5], 4, -378558), g, v, n[e + 8], 11, -2022574463), l, g, n[e + 11], 16, 1839030562), m, l, n[e + 14], 23, -35309556), v = c(v, m = c(m, l = c(l, g, v, m, n[e + 1], 4, -1530992060), g, v, n[e + 4], 11, 1272893353), l, g, n[e + 7], 16, -155497632), m, l, n[e + 10], 23, -1094730640), v = c(v, m = c(m, l = c(l, g, v, m, n[e + 13], 4, 681279174), g, v, n[e], 11, -358537222), l, g, n[e + 3], 16, -722521979), m, l, n[e + 6], 23, 76029189), v = c(v, m = c(m, l = c(l, g, v, m, n[e + 9], 4, -640364487), g, v, n[e + 12], 11, -421815835), l, g, n[e + 15], 16, 530742520), m, l, n[e + 2], 23, -995338651), v = f(v, m = f(m, l = f(l, g, v, m, n[e], 6, -198630844), g, v, n[e + 7], 10, 1126891415), l, g, n[e + 14], 15, -1416354905), m, l, n[e + 5], 21, -57434055), v = f(v, m = f(m, l = f(l, g, v, m, n[e + 12], 6, 1700485571), g, v, n[e + 3], 10, -1894986606), l, g, n[e + 10], 15, -1051523), m, l, n[e + 1], 21, -2054922799), v = f(v, m = f(m, l = f(l, g, v, m, n[e + 8], 6, 1873313359), g, v, n[e + 15], 10, -30611744), l, g, n[e + 6], 15, -1560198380), m, l, n[e + 13], 21, 1309151649), v = f(v, m = f(m, l = f(l, g, v, m, n[e + 4], 6, -145523070), g, v, n[e + 11], 10, -1120210379), l, g, n[e + 2], 15, 718787259), m, l, n[e + 9], 21, -343485551), l = t(l, i), g = t(g, a), v = t(v, d), m = t(m, h); return [l, g, v, m] } function a(n) { var t, r = "", e = 32 * n.length; for (t = 0; t < e; t += 8)r += String.fromCharCode(n[t >> 5] >>> t % 32 & 255); return r } function d(n) { var t, r = []; for (r[(n.length >> 2) - 1] = void 0, t = 0; t < r.length; t += 1)r[t] = 0; var e = 8 * n.length; for (t = 0; t < e; t += 8)r[t >> 5] |= (255 & n.charCodeAt(t / 8)) << t % 32; return r } function h(n) { return a(i(d(n), 8 * n.length)) } function l(n, t) { var r, e, o = d(n), u = [], c = []; for (u[15] = c[15] = void 0, o.length > 16 && (o = i(o, 8 * n.length)), r = 0; r < 16; r += 1)u[r] = 909522486 ^ o[r], c[r] = 1549556828 ^ o[r]; return e = i(u.concat(d(t)), 512 + 8 * t.length), a(i(c.concat(e), 640)) } function g(n) { var t, r, e = ""; for (r = 0; r < n.length; r += 1)t = n.charCodeAt(r), e += "0123456789abcdef".charAt(t >>> 4 & 15) + "0123456789abcdef".charAt(15 & t); return e } function v(n) { return unescape(encodeURIComponent(n)) } function m(n) { return h(v(n)) } function p(n) { return g(m(n)) } function s(n, t) { return l(v(n), v(t)) } function C(n, t) { return g(s(n, t)) } function A(n, t, r) { return t ? r ? s(t, n) : C(t, n) : r ? m(n) : p(n) } $.md5 = A }(this); +function Env(t, e) { "undefined" != typeof process && JSON.stringify(process.env).indexOf("GITHUB") > -1 && process.exit(0); class s { constructor(t) { this.env = t } send(t, e = "GET") { t = "string" == typeof t ? { url: t } : t; let s = this.get; return "POST" === e && (s = this.post), new Promise((e, i) => { s.call(this, t, (t, s, r) => { t ? i(t) : e(s) }) }) } get(t) { return this.send.call(this.env, t) } post(t) { return this.send.call(this.env, t, "POST") } } return new class { constructor(t, e) { this.name = t, this.http = new s(this), this.data = null, this.dataFile = "box.dat", this.logs = [], this.isMute = !1, this.isNeedRewrite = !1, this.logSeparator = "\n", this.startTime = (new Date).getTime(), Object.assign(this, e), this.log("", `🔔${this.name}, 开始!`) } isNode() { return "undefined" != typeof module && !!module.exports } isQuanX() { return "undefined" != typeof $task } isSurge() { return "undefined" != typeof $httpClient && "undefined" == typeof $loon } isLoon() { return "undefined" != typeof $loon } toObj(t, e = null) { try { return JSON.parse(t) } catch { return e } } toStr(t, e = null) { try { return JSON.stringify(t) } catch { return e } } getjson(t, e) { let s = e; const i = this.getdata(t); if (i) try { s = JSON.parse(this.getdata(t)) } catch { } return s } setjson(t, e) { try { return this.setdata(JSON.stringify(t), e) } catch { return !1 } } getScript(t) { return new Promise(e => { this.get({ url: t }, (t, s, i) => e(i)) }) } runScript(t, e) { return new Promise(s => { let i = this.getdata("@chavy_boxjs_userCfgs.httpapi"); i = i ? i.replace(/\n/g, "").trim() : i; let r = this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout"); r = r ? 1 * r : 20, r = e && e.timeout ? e.timeout : r; const [o, h] = i.split("@"), n = { url: `http://${h}/v1/scripting/evaluate`, body: { script_text: t, mock_type: "cron", timeout: r }, headers: { "X-Key": o, Accept: "*/*" } }; this.post(n, (t, e, i) => s(i)) }).catch(t => this.logErr(t)) } loaddata() { if (!this.isNode()) return {}; { this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path"); const t = this.path.resolve(this.dataFile), e = this.path.resolve(process.cwd(), this.dataFile), s = this.fs.existsSync(t), i = !s && this.fs.existsSync(e); if (!s && !i) return {}; { const i = s ? t : e; try { return JSON.parse(this.fs.readFileSync(i)) } catch (t) { return {} } } } } writedata() { if (this.isNode()) { this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path"); const t = this.path.resolve(this.dataFile), e = this.path.resolve(process.cwd(), this.dataFile), s = this.fs.existsSync(t), i = !s && this.fs.existsSync(e), r = JSON.stringify(this.data); s ? this.fs.writeFileSync(t, r) : i ? this.fs.writeFileSync(e, r) : this.fs.writeFileSync(t, r) } } lodash_get(t, e, s) { const i = e.replace(/\[(\d+)\]/g, ".$1").split("."); let r = t; for (const t of i) if (r = Object(r)[t], void 0 === r) return s; return r } lodash_set(t, e, s) { return Object(t) !== t ? t : (Array.isArray(e) || (e = e.toString().match(/[^.[\]]+/g) || []), e.slice(0, -1).reduce((t, s, i) => Object(t[s]) === t[s] ? t[s] : t[s] = Math.abs(e[i + 1]) >> 0 == +e[i + 1] ? [] : {}, t)[e[e.length - 1]] = s, t) } getdata(t) { let e = this.getval(t); if (/^@/.test(t)) { const [, s, i] = /^@(.*?)\.(.*?)$/.exec(t), r = s ? this.getval(s) : ""; if (r) try { const t = JSON.parse(r); e = t ? this.lodash_get(t, i, "") : e } catch (t) { e = "" } } return e } setdata(t, e) { let s = !1; if (/^@/.test(e)) { const [, i, r] = /^@(.*?)\.(.*?)$/.exec(e), o = this.getval(i), h = i ? "null" === o ? null : o || "{}" : "{}"; try { const e = JSON.parse(h); this.lodash_set(e, r, t), s = this.setval(JSON.stringify(e), i) } catch (e) { const o = {}; this.lodash_set(o, r, t), s = this.setval(JSON.stringify(o), i) } } else s = this.setval(t, e); return s } getval(t) { return this.isSurge() || this.isLoon() ? $persistentStore.read(t) : this.isQuanX() ? $prefs.valueForKey(t) : this.isNode() ? (this.data = this.loaddata(), this.data[t]) : this.data && this.data[t] || null } setval(t, e) { return this.isSurge() || this.isLoon() ? $persistentStore.write(t, e) : this.isQuanX() ? $prefs.setValueForKey(t, e) : this.isNode() ? (this.data = this.loaddata(), this.data[e] = t, this.writedata(), !0) : this.data && this.data[e] || null } initGotEnv(t) { this.got = this.got ? this.got : require("got"), this.cktough = this.cktough ? this.cktough : require("tough-cookie"), this.ckjar = this.ckjar ? this.ckjar : new this.cktough.CookieJar, t && (t.headers = t.headers ? t.headers : {}, void 0 === t.headers.Cookie && void 0 === t.cookieJar && (t.cookieJar = this.ckjar)) } get(t, e = (() => { })) { t.headers && (delete t.headers["Content-Type"], delete t.headers["Content-Length"]), this.isSurge() || this.isLoon() ? (this.isSurge() && this.isNeedRewrite && (t.headers = t.headers || {}, Object.assign(t.headers, { "X-Surge-Skip-Scripting": !1 })), $httpClient.get(t, (t, s, i) => { !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i) })) : this.isQuanX() ? (this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, { hints: !1 })), $task.fetch(t).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => e(t))) : this.isNode() && (this.initGotEnv(t), this.got(t).on("redirect", (t, e) => { try { if (t.headers["set-cookie"]) { const s = t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString(); s && this.ckjar.setCookieSync(s, null), e.cookieJar = this.ckjar } } catch (t) { this.logErr(t) } }).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => { const { message: s, response: i } = t; e(s, i, i && i.body) })) } post(t, e = (() => { })) { if (t.body && t.headers && !t.headers["Content-Type"] && (t.headers["Content-Type"] = "application/x-www-form-urlencoded"), t.headers && delete t.headers["Content-Length"], this.isSurge() || this.isLoon()) this.isSurge() && this.isNeedRewrite && (t.headers = t.headers || {}, Object.assign(t.headers, { "X-Surge-Skip-Scripting": !1 })), $httpClient.post(t, (t, s, i) => { !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i) }); else if (this.isQuanX()) t.method = "POST", this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, { hints: !1 })), $task.fetch(t).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => e(t)); else if (this.isNode()) { this.initGotEnv(t); const { url: s, ...i } = t; this.got.post(s, i).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => { const { message: s, response: i } = t; e(s, i, i && i.body) }) } } time(t, e = null) { const s = e ? new Date(e) : new Date; let i = { "M+": s.getMonth() + 1, "d+": s.getDate(), "H+": s.getHours(), "m+": s.getMinutes(), "s+": s.getSeconds(), "q+": Math.floor((s.getMonth() + 3) / 3), S: s.getMilliseconds() }; /(y+)/.test(t) && (t = t.replace(RegExp.$1, (s.getFullYear() + "").substr(4 - RegExp.$1.length))); for (let e in i) new RegExp("(" + e + ")").test(t) && (t = t.replace(RegExp.$1, 1 == RegExp.$1.length ? i[e] : ("00" + i[e]).substr(("" + i[e]).length))); return t } msg(e = t, s = "", i = "", r) { const o = t => { if (!t) return t; if ("string" == typeof t) return this.isLoon() ? t : this.isQuanX() ? { "open-url": t } : this.isSurge() ? { url: t } : void 0; if ("object" == typeof t) { if (this.isLoon()) { let e = t.openUrl || t.url || t["open-url"], s = t.mediaUrl || t["media-url"]; return { openUrl: e, mediaUrl: s } } if (this.isQuanX()) { let e = t["open-url"] || t.url || t.openUrl, s = t["media-url"] || t.mediaUrl; return { "open-url": e, "media-url": s } } if (this.isSurge()) { let e = t.url || t.openUrl || t["open-url"]; return { url: e } } } }; if (this.isMute || (this.isSurge() || this.isLoon() ? $notification.post(e, s, i, o(r)) : this.isQuanX() && $notify(e, s, i, o(r))), !this.isMuteLog) { let t = ["", "==============📣系统通知📣=============="]; t.push(e), s && t.push(s), i && t.push(i), console.log(t.join("\n")), this.logs = this.logs.concat(t) } } log(...t) { t.length > 0 && (this.logs = [...this.logs, ...t]), console.log(t.join(this.logSeparator)) } logErr(t, e) { const s = !this.isSurge() && !this.isQuanX() && !this.isLoon(); s ? this.log("", `❗️${this.name}, 错误!`, t.stack) : this.log("", `❗️${this.name}, 错误!`, t) } wait(t) { return new Promise(e => setTimeout(e, t)) } done(t = {}) { const e = (new Date).getTime(), s = (e - this.startTime) / 1e3; this.log("", `🔔${this.name}, 结束! 🕛 ${s} 秒`), this.log(), (this.isSurge() || this.isQuanX() || this.isLoon()) && $done(t) } }(t, e) } diff --git a/activity/jd_opencardL59.js b/activity/jd_opencardL59.js new file mode 100644 index 0000000..a2a933f --- /dev/null +++ b/activity/jd_opencardL59.js @@ -0,0 +1,817 @@ +/* +2022.1.21-1.27 南北年货 新意回家 + + +第一个账号助力作者 其他依次助力CK1 +第一个CK失效会退出脚本 + +———————————————— +入口:https://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=dzlhkkpoutnkskl20220121&shareUuid=fe63d6d8051c402f928ccc53b8db398d + +请求太频繁会被黑ip +过10分钟再执行 + + +cron:21 21 21-27 1 * +============Quantumultx=============== +[task_local] +#2022.1.21-1.27 南北年货 新意回家 +21 21 21-27 1 * https://raw.githubusercontent.com/KingRan/JDJB/main/jd_opencardL59.js, tag=2022.1.21-1.27 南北年货 新意回家, enabled=true + +*/ +const $ = new Env("2022.1.21-1.27 南北年货 新意回家"); +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const notify = $.isNode() ? require('./sendNotify') : ''; +//IOS等用户直接用NobyDa的jd cookie + +let cookiesArr = [], + cookie = ''; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} +allMessage = "" +message = "" +$.hotFlag = false +$.outFlag = false +$.activityEnd = false +let lz_jdpin_token_cookie ='' +let activityCookie ='' +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', { + "open-url": "https://bean.m.jd.com/" + }); + return; + } + $.activityId = "dzlhkkpoutnkskl20220121" + $.shareUuid = "fe63d6d8051c402f928ccc53b8db398d" + console.log(`入口:\nhttps://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}`) + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i]; + if (cookie) { + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + message = "" + $.bean = 0 + $.hotFlag = false + $.nickName = ''; + console.log(`\n\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + await getUA() + await run(); + if(i == 0 && !$.actorUuid) break + if($.outFlag || $.activityEnd) break + } + } + if($.outFlag) { + let msg = '此ip已被限制,请过10分钟后再执行脚本' + $.msg($.name, ``, `${msg}`); + if ($.isNode()) await notify.sendNotify(`${$.name}`, `${msg}`); + } +})() + .catch((e) => $.logErr(e)) + .finally(() => $.done()) + + +async function run() { + try { + $.hasEnd = true + $.endTime = 0 + lz_jdpin_token_cookie = '' + $.Token = '' + $.Pin = '' + let flag = false + await takePostRequest('isvObfuscator'); + if($.Token == ''){ + console.log('获取[token]失败!') + return + } + await getCk() + if (activityCookie == '') { + console.log(`获取cookie失败`); return; + } + if($.activityEnd === true){ + console.log('活动结束') + return + } + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + await takePostRequest('getSimpleActInfoVo'); + await takePostRequest('getMyPing'); + if(!$.Pin){ + console.log('获取[Pin]失败!') + return + } + await takePostRequest('accessLogWithAD'); + await takePostRequest('getUserInfo'); + await takePostRequest('activityContent'); + if($.hotFlag) return + if(!$.actorUuid){ + console.log('获取不到[actorUuid]退出执行,请重新执行') + return + } + // console.log($.actorUuid) + // return + if($.hasEnd === true || Date.now() > $.endTime){ + $.activityEnd = true + console.log('活动结束') + return + } + await takePostRequest('drawContent'); + await $.wait(1000) + $.openList = [] + $.allOpenCard = false + await takePostRequest('info'); + await takePostRequest('checkOpenCard'); + if($.allOpenCard == false){ + console.log('开卡任务') + for(o of $.openList){ + $.openCard = false + if(o.status == 0){ + flag = true + $.joinVenderId = o.venderId + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + await joinShop() + await $.wait(parseInt(Math.random() * 1000 + 1000, 10)) + await takePostRequest('activityContent'); + await takePostRequest('drawContent'); + await takePostRequest('checkOpenCard'); + await $.wait(parseInt(Math.random() * 3000 + 2000, 10)) + } + } + }else{ + console.log('已全部开卡') + } + + $.log("关注: " + $.followShop) + if(!$.followShop && !$.outFlag){ + flag = true + await takePostRequest('followShop'); + await $.wait(parseInt(Math.random() * 2000 + 3000, 10)) + } + $.yaoqing = false + await takePostRequest('邀请'); + if($.yaoqing){ + await takePostRequest('助力'); + } + $.runFalag = true + $.log("浏览商品: " + $.visitSku) + if(!$.visitSku && !$.outFlag){ + flag = true + for(let v of $.visitSkuList || []){ + if($.runFalag == false) break + if(v.goodsCode && v.status === 0){ + $.visitSkuValue = v.goodsCode + await takePostRequest('browseGoods'); + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + } + } + } + $.runFalag = true + let count = parseInt($.drawCount, 10) + console.log(`抽奖次数为:${count}`) + for(m=1;count--;m++){ + console.log(`第${m}次抽奖`) + await takePostRequest('startDraw'); + if($.runFalag == false) break + if(Number(count) <= 0) break + if(m >= 30){ + console.log("抽奖太多次,多余的次数请再执行脚本") + break + } + await $.wait(parseInt(Math.random() * 2000 + 2000, 10)) + } + if(flag){ + await takePostRequest('activityContent'); + } + console.log(`${$.score}值 游戏:${$.point}`) + $.runFalag = true + count = parseInt($.score/50) + console.log(`抽奖次数为:${count}`) + for(m=1;count--;m++){ + console.log(`第${m}次抽奖`) + await takePostRequest('抽奖'); + if($.runFalag == false) break + if(Number(count) <= 0) break + if(m >= 5){ + console.log("抽奖太多次,多余的次数请再执行脚本") + break + } + await $.wait(parseInt(Math.random() * 2000 + 2000, 10)) + } + await $.wait(parseInt(Math.random() * 1000 + 2000, 10)) + await takePostRequest('getDrawRecordHasCoupon'); + await takePostRequest('getShareRecord'); + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + console.log($.actorUuid) + console.log(`当前助力:${$.shareUuid}`) + if($.index == 1){ + $.shareUuid = $.actorUuid + console.log(`后面的号都会助力:${$.shareUuid}`) + } + await $.wait(parseInt(Math.random() * 1000 + 5000, 10)) + if(flag) await $.wait(parseInt(Math.random() * 1000 + 10000, 10)) + if($.index % 3 == 0) console.log('休息1分钟,别被黑ip了\n可持续发展') + if($.index % 3 == 0) await $.wait(parseInt(Math.random() * 5000 + 60000, 10)) + + } catch (e) { + console.log(e) + } +} + +async function takePostRequest(type) { + if($.outFlag) return + let domain = 'https://lzdz1-isv.isvjcloud.com'; + let body = ``; + let method = 'POST' + let admJson = '' + switch (type) { + case 'isvObfuscator': + url = `https://api.m.jd.com/client.action?functionId=isvObfuscator`; + body = `body=%7B%22url%22%3A%22https%3A//lzdz1-isv.isvjcloud.com%22%2C%22id%22%3A%22%22%7D&uuid=7088d9018515b8cb0c88ace6e5479762af3e88f3&client=apple&clientVersion=10.1.4&st=1634343624086&sv=120&sign=8b9cea22c3a0d77026abda5d37d2b7e3`; + break; + case 'getSimpleActInfoVo': + url = `${domain}/dz/common/getSimpleActInfoVo`; + body = `activityId=${$.activityId}`; + break; + case 'getMyPing': + url = `${domain}/customer/getMyPing`; + body = `userId=${$.shopId || $.venderId || ''}&token=${$.Token}&fromType=APP`; + break; + case 'accessLogWithAD': + url = `${domain}/common/accessLogWithAD`; + let pageurl = `${domain}/drawCenter/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}` + body = `venderId=${$.shopId || $.venderId || ''}&code=99&pin=${encodeURIComponent($.Pin)}&activityId=${$.activityId}&pageUrl=${encodeURIComponent(pageurl)}&subType=app&adSource=` + break; + case 'getUserInfo': + url = `${domain}/wxActionCommon/getUserInfo`; + body = `pin=${encodeURIComponent($.Pin)}`; + break; + case 'activityContent': + url = `${domain}/dingzhi/linkgame/activity/content`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&pinImg=${encodeURIComponent($.attrTouXiang)}&nick=${encodeURIComponent($.nickname)}&cjyxPin=&cjhyPin=&shareUuid=${$.shareUuid}` + break; + case 'drawContent': + url = `${domain}/dingzhi/taskact/common/drawContent`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case 'checkOpenCard': + url = `${domain}/dingzhi/opencard/checkOpenCard`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&shareUuid=${$.shareUuid}` + break; + case 'info': + url = `${domain}/dingzhi/linkgame/task/info`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case 'startDraw': + url = `${domain}/dingzhi/linkgame/draw/bean`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case 'followShop': + url = `${domain}/dingzhi/linkgame/follow/shop`; + // url = `${domain}/dingzhi/dz/openCard/saveTask`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case 'sign': + case 'addCart': + case 'browseGoods': + url = `${domain}/dingzhi/linkgame/${type}`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + if(type == 'browseGoods') body += `&value=${$.visitSkuValue}` + break; + case '邀请': + case '助力': + if(type == '助力'){ + url = `${domain}/dingzhi/opencard/assist`; + }else{ + url = `${domain}/dingzhi/opencard/assist/status`; + } + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&shareUuid=${$.shareUuid}` + break; + case 'viewVideo': + case 'visitSku': + case 'toShop': + case 'addSku': + url = `${domain}/dingzhi/dz/openCard/saveTask`; + let taskType = '' + let taskValue = '' + if(type == 'viewVideo'){ + taskType = 31 + taskValue = 31 + }else if(type == 'visitSku'){ + taskType = 5 + taskValue = $.visitSkuValue || 5 + }else if(type == 'toShop'){ + taskType = 14 + taskValue = $.toShopValue || 14 + }else if(type == 'addSku'){ + taskType = 2 + taskValue = $.addSkuValue || 2 + } + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&taskType=${taskType}&taskValue=${taskValue}` + break; + case 'getDrawRecordHasCoupon': + url = `${domain}/dingzhi/linkgame/draw/record`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case 'getShareRecord': + url = `${domain}/dingzhi/linkgame/help/list`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case '抽奖': + url = `${domain}/dingzhi/linkgame/draw`; + body = `activityId=${$.activityId}&actorUuid=${$.actorUuid}&pin=${encodeURIComponent($.Pin)}` + break; + default: + console.log(`错误${type}`); + } + let myRequest = getPostRequest(url, body, method); + // console.log(myRequest) + return new Promise(async resolve => { + $.post(myRequest, (err, resp, data) => { + try { + setActivityCookie(resp) + if (err) { + if(resp && typeof resp.statusCode != 'undefined'){ + if(resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + } + console.log(`${$.toStr(err,err)}`) + console.log(`${type} API请求失败,请检查网路重试`) + } else { + dealReturn(type, data); + } + } catch (e) { + // console.log(data); + console.log(e, resp) + } finally { + resolve(); + } + }) + }) + } + +async function dealReturn(type, data) { + let res = '' + try { + if(type != 'accessLogWithAD' || type != 'drawContent'){ + if(data){ + res = JSON.parse(data); + } + } + } catch (e) { + console.log(`${type} 执行任务异常`); + console.log(data); + $.runFalag = false; + } + try { + switch (type) { + case 'isvObfuscator': + if(typeof res == 'object'){ + if(res.errcode == 0){ + if(typeof res.token != 'undefined') $.Token = res.token + }else if(res.message){ + console.log(`isvObfuscator ${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + break; + case 'getSimpleActInfoVo': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(typeof res.data.shopId != 'undefined') $.shopId = res.data.shopId + if(typeof res.data.venderId != 'undefined') $.venderId = res.data.venderId + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getMyPing': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(res.data && typeof res.data.secretPin != 'undefined') $.Pin = res.data.secretPin + if(res.data && typeof res.data.nickname != 'undefined') $.nickname = res.data.nickname + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getUserInfo': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(res.data && typeof res.data.yunMidImageUrl != 'undefined') $.attrTouXiang = res.data.yunMidImageUrl || "https://img10.360buyimg.com/imgzone/jfs/t1/7020/27/13511/6142/5c5138d8E4df2e764/5a1216a3a5043c5d.png" + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'activityContent': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + $.endTime = res.data.endTime || res.data.activity.endTime || 0 + $.hasEnd = res.data.isEnd || false + $.drawCount = res.data.actor.drawCount || 0 + $.point = res.data.actor.point || 0 + $.score = res.data.actor.score || 0 + $.actorUuid = res.data.actor.actorUuid || '' + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'info': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + // $.drawCount = res.data.drawCount || 0 + $.addCart = res.data.addCart || false + $.followShop = res.data.followShop || false + $.sign = res.data.sign || false + $.visitSku = res.data.visitSku || false + $.visitSkuList = res.data.visitSkuList || [] + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'checkOpenCard': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + let cardList1 = res.data.cardList1 || [] + let cardList2 = res.data.cardList2 || [] + let cardList = res.data.cardList || [] + let openCardList = res.data.openCardList || [] + $.openList = [...cardList,...cardList1,...cardList2,...openCardList] + $.allOpenCard = res.data.allOpenCard || false + $.openCardScore1 = res.data.score1 || 0 + $.openCardScore2 = res.data.score2 || 0 + $.drawScore = res.data.drawScore || 0 + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'startDraw': + case 'followShop': + case 'viewVideo': + case 'visitSku': + case 'toShop': + case 'addSku': + case 'sign': + case 'addCart': + case 'browseGoods': + case '抽奖': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(typeof res.data == 'object'){ + let msg = '' + let title = '抽奖' + if(res.data.addBeanNum){ + msg = `${res.data.addBeanNum}京豆` + } + if(res.data.addPoint){ + msg += ` ${res.data.addPoint}游戏机会` + } + if(type == 'followShop'){ + title = '关注' + if(res.data.beanNumMember && res.data.assistSendStatus){ + msg += ` 额外获得:${res.data.beanNumMember}京豆` + } + }else if(type == 'addSku' || type == 'addCart'){ + title = '加购' + }else if(type == 'viewVideo'){ + title = '热门文章' + }else if(type == 'toShop'){ + title = '浏览店铺' + }else if(type == 'visitSku' || type == 'browseGoods'){ + title = '浏览商品' + }else if(type == 'sign'){ + title = '签到' + }else{ + msg = res.data.drawOk == true && (res.data.drawInfoType == 6 && res.data.name || '') || '空气💨' + } + if(!msg){ + msg = '空气💨' + } + console.log(`${title}获得:${msg || data}`) + }else{ + console.log(`${type} ${data}`) + } + }else if(res.errorMessage){ + $.runFalag = false; + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getDrawRecordHasCoupon': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + console.log(`我的奖品:`) + let num = 0 + let value = 0 + for(let i in res.data.recordList){ + let item = res.data.recordList[i] + if(item.infoName == '20京豆'){ + num++ + value = item.infoName.replace('京豆','') + }else{ + console.log(`${item.infoType != 10 && item.value && item.value +':' || ''}${item.infoName}`) + } + } + if(num > 0) console.log(`邀请好友(${num}):${num*parseInt(value, 10) || 30}京豆`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getShareRecord': + if(typeof res == 'object'){ + if(res.result && res.result === true && res.data){ + $.ShareCount = res.data.shareList.length + $.log(`=========== 你邀请了:${res.data.shareList.length}个`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case '邀请': + case '助力': + // console.log(data) + if(typeof res == 'object'){ + if(res.data.status == 200){ + if(type == '助力'){ + console.log('助力成功') + }else{ + $.yaoqing = true + } + }else if(res.data.status == 105){ + console.log('已经助力过') + }else if(res.data.status == 104){ + console.log('已经助力其他人') + }else if(res.data.status == 101){ + // console.log('已经助力过') + }else{ + console.log(data) + } + }else{ + console.log(`${type} ${data}`) + } + + case 'accessLogWithAD': + case 'drawContent': + break; + default: + console.log(`${type}-> ${data}`); + } + if(typeof res == 'object'){ + if(res.errorMessage){ + if(res.errorMessage.indexOf('火爆') >-1 ){ + $.hotFlag = true + } + } + } + } catch (e) { + console.log(e) + } +} + +function getPostRequest(url, body, method="POST") { + let headers = { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Content-Type": "application/x-www-form-urlencoded", + "Cookie": cookie, + "User-Agent": $.UA, + "X-Requested-With": "XMLHttpRequest" + } + if(url.indexOf('https://lzdz1-isv.isvjcloud.com') > -1){ + headers["Referer"] = `https://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}` + headers["Cookie"] = `${lz_jdpin_token_cookie && lz_jdpin_token_cookie || ''}${$.Pin && "AUTH_C_USER=" + $.Pin + ";" || ""}${activityCookie}` + } + // console.log(headers) + // console.log(headers.Cookie) + return {url: url, method: method, headers: headers, body: body, timeout:30000}; +} + +function getCk() { + return new Promise(resolve => { + let get = { + url:`https://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}`, + followRedirect:false, + headers: { + "User-Agent": $.UA, + }, + timeout:30000 + } + $.get(get, async(err, resp, data) => { + try { + if (err) { + if(resp && typeof resp.statusCode != 'undefined'){ + if(resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + } + console.log(`${$.toStr(err)}`) + console.log(`${$.name} cookie API请求失败,请检查网路重试`) + } else { + let end = data.match(/(活动已经结束)/) && data.match(/(活动已经结束)/)[1] || '' + if(end){ + $.activityEnd = true + console.log('活动已结束') + } + setActivityCookie(resp) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function setActivityCookie(resp){ + let LZ_TOKEN_KEY = '' + let LZ_TOKEN_VALUE = '' + let lz_jdpin_token = '' + let setcookies = resp && resp['headers'] && (resp['headers']['set-cookie'] || resp['headers']['Set-Cookie'] || '') || '' + let setcookie = '' + if(setcookies){ + if(typeof setcookies != 'object'){ + setcookie = setcookies.split(',') + }else setcookie = setcookies + for (let ck of setcookie) { + let name = ck.split(";")[0].trim() + if(name.split("=")[1]){ + // console.log(name.replace(/ /g,'')) + if(name.indexOf('LZ_TOKEN_KEY=')>-1) LZ_TOKEN_KEY = name.replace(/ /g,'')+';' + if(name.indexOf('LZ_TOKEN_VALUE=')>-1) LZ_TOKEN_VALUE = name.replace(/ /g,'')+';' + if(name.indexOf('lz_jdpin_token=')>-1) lz_jdpin_token = ''+name.replace(/ /g,'')+';' + } + } + } + if(LZ_TOKEN_KEY && LZ_TOKEN_VALUE) activityCookie = `${LZ_TOKEN_KEY} ${LZ_TOKEN_VALUE}` + if(lz_jdpin_token) lz_jdpin_token_cookie = lz_jdpin_token +} + +async function getUA(){ + $.UA = `jdapp;iPhone;10.1.4;13.1.2;${randomString(40)};network/wifi;model/iPhone8,1;addressid/2308460611;appBuild/167814;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_1_2 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 joinShop() { + if(!$.joinVenderId) return + return new Promise(async resolve => { + $.shopactivityId = '' + await $.wait(1000) + await getshopactivityId() + let activityId = `` + if($.shopactivityId) activityId = `,"activityId":${$.shopactivityId}` + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body={"venderId":"${$.joinVenderId}","shopId":"${$.joinVenderId}","bindByVerifyCodeFlag":1,"registerExtend":{},"writeChildFlag":0${activityId},"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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + // console.log(data) + let res = $.toObj(data,data); + if(typeof res == 'object'){ + if(res.success === true){ + console.log(res.message) + if(res.result && res.result.giftInfo){ + for(let i of res.result.giftInfo.giftList){ + console.log(`入会获得:${i.discountString}${i.prizeName}${i.secondLineDesc}`) + } + } + }else if(typeof res == 'object' && res.message){ + console.log(`${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function getshopactivityId() { + return new Promise(resolve => { + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body=%7B%22venderId%22%3A%22${$.joinVenderId}%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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + let res = $.toObj(data,data); + if(typeof res == 'object'){ + if(res.success == true){ + // console.log($.toStr(res.result)) + console.log(`入会:${res.result.shopMemberCardInfo.venderCardName || ''}`) + $.shopactivityId = res.result.interestsRuleList && res.result.interestsRuleList[0] && res.result.interestsRuleList[0].interestsInfo && res.result.interestsRuleList[0].interestsInfo.activityId || '' + } + }else{ + console.log(data) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} + + +// 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)} diff --git a/activity/jd_opencardL60.js b/activity/jd_opencardL60.js new file mode 100644 index 0000000..213e452 --- /dev/null +++ b/activity/jd_opencardL60.js @@ -0,0 +1,742 @@ +/* +1.17~2.15 大牌服饰盛典 +新增开卡脚本 +一次性脚本 + +第一个账号助力作者 其他依次助力CK1 +第一个CK失效会退出脚本 + +———————————————— +入口:[ 1.17~2.15 大牌服饰盛典 (https://lzdz1-isv.isvjcloud.com/dingzhi/dz/openCard/activity?activityId=67ba2ad44b8041c9925bf0e72febbdb2&shareUuid=29d4e8a845b641caa2ee83bf1fdc96d2)] + +请求太频繁会被黑ip +过10分钟再执行 + +cron:57 12 17-31,1-15 1,2 * +============Quantumultx=============== +[task_local] +#1.17~2.15 大牌服饰盛典 +57 12 17-31,1-15 1,2 * jd_opencardL60.js, tag=1.17~2.15 大牌服饰盛典, enabled=true + +*/ + + +const $ = new Env('1.17~2.15 大牌服饰盛典'); +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const notify = $.isNode() ? require('./sendNotify') : ''; + +//IOS等用户直接用NobyDa的jd cookie + +let cookiesArr = [], + cookie = ''; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} + +allMessage = "" +message = "" +$.hotFlag = false +$.outFlag = false +$.activityEnd = false +let lz_jdpin_token_cookie ='' +let activityCookie ='' +!(async () => { + + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', { + "open-url": "https://bean.m.jd.com/" + }); + return; + } + $.activityId = "67ba2ad44b8041c9925bf0e72febbdb2" + $.shareUuid = "04a46ee060c24207a2be84d14798840e" + console.log(`入口:\nhttps://lzdz1-isv.isvjcloud.com/dingzhi/dz/openCard/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}`) + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i]; + if (cookie) { + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + message = "" + $.bean = 0 + $.hotFlag = false + $.nickName = ''; + console.log(`\n\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + await getUA() + await run(); + if(i == 0 && !$.actorUuid) break + if($.outFlag || $.activityEnd) break + } + } + if($.outFlag) { + let msg = '此ip已被限制,请过10分钟后再执行脚本' + $.msg($.name, ``, `${msg}`); + if ($.isNode()) await notify.sendNotify(`${$.name}`, `${msg}`); + } +})() + .catch((e) => $.logErr(e)) + .finally(() => $.done()) + + +async function run() { + try { + $.hasEnd = true + $.endTime = 0 + lz_jdpin_token_cookie = '' + $.Token = '' + $.Pin = '' + let flag = false + await takePostRequest('isvObfuscator'); + if($.Token == ''){ + console.log('获取[token]失败!') + return + } + await getCk() + if (activityCookie == '') { + console.log(`获取cookie失败`); return; + } + if($.activityEnd === true){ + console.log('活动结束') + return + } + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + await takePostRequest('getSimpleActInfoVo'); + await takePostRequest('getMyPing'); + if(!$.Pin){ + console.log('获取[Pin]失败!') + return + } + await takePostRequest('accessLogWithAD'); + await takePostRequest('getUserInfo'); + await takePostRequest('activityContent'); + if($.hotFlag) return + if(!$.actorUuid){ + console.log('获取不到[actorUuid]退出执行,请重新执行') + return + } + if($.hasEnd === true || Date.now() > $.endTime){ + $.activityEnd = true + console.log('活动结束') + return + } + await takePostRequest('drawContent'); + await $.wait(1000) + $.openList = [] + $.allOpenCard = false + await takePostRequest('checkOpenCard'); + if($.allOpenCard == false){ + console.log('开卡任务') + for(o of $.openList){ + $.openCard = false + if(o.status == 0){ + flag = true + $.joinVenderId = o.value + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + await joinShop() + await $.wait(parseInt(Math.random() * 1000 + 1000, 10)) + await takePostRequest('drawContent'); + await takePostRequest('checkOpenCard'); + await $.wait(parseInt(Math.random() * 3000 + 2000, 10)) + } + } + await takePostRequest('activityContent'); + }else{ + console.log('已全部开卡') + } + if($.openCardScore1 == 1 && !$.outFlag){ + $.startDraw = 1 + flag = true + await takePostRequest('startDraw'); + await $.wait(parseInt(Math.random() * 1000 + 3000, 10)) + } + if($.openCardScore2 == 1 && !$.outFlag){ + $.startDraw = 2 + flag = true + await takePostRequest('startDraw'); + await $.wait(parseInt(Math.random() * 1000 + 3000, 10)) + } + + $.log("关注: " + $.followShop) + if(!$.followShop && !$.outFlag){ + flag = true + await takePostRequest('followShop'); + await $.wait(parseInt(Math.random() * 1000 + 5000, 10)) + } + $.log("加购: " + $.addSku) + if(!$.addSku && !$.outFlag){ + flag = true + await takePostRequest('addSku'); + await $.wait(parseInt(Math.random() * 1000 + 5000, 10)) + } + $.runFalag = true + $.log("浏览店铺: " + $.toShop) + if(!$.toShop && !$.outFlag){ + flag = true + for(let v of $.toShopList || []){ + if($.runFalag == false) break + if(v.value && v.status === 0){ + $.toShopValue = v.value + await takePostRequest('toShop'); + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + } + } + } + $.runFalag = true + $.log("浏览商品: " + $.visitSku) + if(!$.visitSku && !$.outFlag){ + flag = true + for(let v of $.visitSkuList || []){ + if($.runFalag == false) break + if(v.value && v.status === 0){ + $.visitSkuValue = v.value + await takePostRequest('visitSku'); + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + } + } + } + if(flag){ + await takePostRequest('activityContent'); + } + await $.wait(parseInt(Math.random() * 1000 + 2000, 10)) + //await takePostRequest('getDrawRecordHasCoupon'); + //await takePostRequest('getShareRecord'); + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + console.log($.actorUuid) + console.log(`当前助力:${$.shareUuid}`) + if($.index == 1){ + $.shareUuid = $.actorUuid + console.log(`后面的号都会助力:${$.shareUuid}`) + } + await $.wait(parseInt(Math.random() * 1000 + 5000, 10)) + if(flag) await $.wait(parseInt(Math.random() * 1000 + 10000, 10)) + if($.index % 3 == 0) console.log('休息1分钟,别被黑ip了\n可持续发展') + if($.index % 3 == 0) await $.wait(parseInt(Math.random() * 5000 + 60000, 10)) + } catch (e) { + console.log(e) + } +} + +async function takePostRequest(type) { + if($.outFlag) return + let domain = 'https://lzdz1-isv.isvjcloud.com'; + let body = ``; + let method = 'POST' + let admJson = '' + switch (type) { + case 'isvObfuscator': + url = `https://api.m.jd.com/client.action?functionId=isvObfuscator`; + body = `body=%7B%22url%22%3A%22https%3A//lzdz1-isv.isvjcloud.com%22%2C%22id%22%3A%22%22%7D&uuid=0846724fe8d803b8e84ebd14b3ba7fac6df80e7a&client=apple&clientVersion=10.1.4&st=1634616247215&sv=120&sign=91a16ae2feb0bd0e1ea48d99e7953c58`; + break; + case 'getSimpleActInfoVo': + url = `${domain}/dz/common/getSimpleActInfoVo`; + body = `activityId=${$.activityId}`; + break; + case 'getMyPing': + url = `${domain}/customer/getMyPing`; + body = `userId=${$.shopId || $.venderId || ''}&token=${$.Token}&fromType=APP`; + break; + case 'accessLogWithAD': + url = `${domain}/common/accessLogWithAD`; + let pageurl = `${domain}/drawCenter/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}` + body = `venderId=${$.shopId || $.venderId || ''}&code=99&pin=${encodeURIComponent($.Pin)}&activityId=${$.activityId}&pageUrl=${encodeURIComponent(pageurl)}&subType=app&adSource=` + break; + case 'getUserInfo': + url = `${domain}/wxActionCommon/getUserInfo`; + body = `pin=${encodeURIComponent($.Pin)}`; + break; + case 'activityContent': + url = `${domain}/dingzhi/dz/openCard/activityContent`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&pinImg=${encodeURIComponent($.attrTouXiang)}&nick=${encodeURIComponent($.nickname)}&cjyxPin=&cjhyPin=&shareUuid=${$.shareUuid}` + break; + case 'drawContent': + url = `${domain}/dingzhi/taskact/openCardcommon/drawContent`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case 'checkOpenCard': + url = `${domain}/dingzhi/dz/openCard/checkOpenCard`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&shareUuid=${$.shareUuid}` + break; + case 'startDraw': + url = `${domain}/dingzhi/dz/openCard/startDraw`; + body = `activityId=${$.activityId}&actorUuid=${$.actorUuid}&pin=${encodeURIComponent($.Pin)}${$.startDraw && '&type='+$.startDraw || ''}` + break; + case 'followShop': + url = `${domain}/dingzhi/dz/openCard/followShop`; + // url = `${domain}/dingzhi/dz/openCard/saveTask`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&shareUuid=${$.shareUuid}&taskType=23&taskValue=${$.followShopValue}` + break; + case 'viewVideo': + case 'visitSku': + case 'toShop': + case 'addSku': + url = `${domain}/dingzhi/dz/openCard/saveTask`; + let taskType = '' + let taskValue = '' + if(type == 'viewVideo'){ + taskType = 31 + taskValue = 31 + }else if(type == 'visitSku'){ + taskType = 5 + taskValue = $.visitSkuValue || 5 + }else if(type == 'toShop'){ + taskType = 14 + taskValue = $.toShopValue || 14 + }else if(type == 'addSku'){ + taskType = 2 + taskValue = $.addSkuValue || 2 + } + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&taskType=${taskType}&taskValue=${taskValue}` + break; + case 'getDrawRecordHasCoupon': + url = `${domain}/dingzhi/taskact/openCardcommon/getDrawRecordHasCoupon`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case 'getShareRecord': + url = `${domain}/dingzhi/taskact/openCardcommon/getShareRecord`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + default: + console.log(`错误${type}`); + } + let myRequest = getPostRequest(url, body, method); + // console.log(myRequest) + return new Promise(async resolve => { + $.post(myRequest, (err, resp, data) => { + try { + setActivityCookie(resp) + if (err) { + if(resp && typeof resp.statusCode != 'undefined'){ + if(resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + } + console.log(`${$.toStr(err,err)}`) + console.log(`${type} API请求失败,请检查网路重试`) + } else { + dealReturn(type, data); + } + } catch (e) { + // console.log(data); + console.log(e, resp) + } finally { + resolve(); + } + }) + }) + } + +async function dealReturn(type, data) { + let res = '' + try { + if(type != 'accessLogWithAD' || type != 'drawContent'){ + if(data){ + res = JSON.parse(data); + } + } + } catch (e) { + console.log(`${type} 执行任务异常`); + console.log(data); + $.runFalag = false; + } + try { + switch (type) { + case 'isvObfuscator': + if(typeof res == 'object'){ + if(res.errcode == 0){ + if(typeof res.token != 'undefined') $.Token = res.token + }else if(res.message){ + console.log(`isvObfuscator ${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + break; + case 'getSimpleActInfoVo': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(typeof res.data.shopId != 'undefined') $.shopId = res.data.shopId + if(typeof res.data.venderId != 'undefined') $.venderId = res.data.venderId + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getMyPing': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(res.data && typeof res.data.secretPin != 'undefined') $.Pin = res.data.secretPin + if(res.data && typeof res.data.nickname != 'undefined') $.nickname = res.data.nickname + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getUserInfo': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(res.data && typeof res.data.yunMidImageUrl != 'undefined') $.attrTouXiang = res.data.yunMidImageUrl || "https://img10.360buyimg.com/imgzone/jfs/t1/7020/27/13511/6142/5c5138d8E4df2e764/5a1216a3a5043c5d.png" + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'activityContent': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + $.endTime = res.data.endTime || 0 + $.hasEnd = res.data.hasEnd || false + $.actorUuid = res.data.actorUuid || '' + $.followShop = res.data.followShop.allStatus || false + $.addSku = res.data.addSku.allStatus || false + if(res.data.followShop && res.data.followShop.settings && res.data.followShop.settings[0]){ + $.followShopValue = res.data.followShop.settings[0].value || 1 + } + if(res.data.addSku && res.data.addSku.settings && res.data.addSku.settings[0]){ + $.addSkuValue = res.data.addSku.settings[0].value || 2 + } + $.toShop = res.data.toShop.allStatus || false + $.toShopList = res.data.toShop.settings || [] + $.visitSku = res.data.visitSku.allStatus || false + $.visitSkuList = res.data.visitSku.settings || [] + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'checkOpenCard': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + let cardList1 = res.data.cardList1 || [] + let cardList2 = res.data.cardList2 || [] + let cardList = res.data.cardList || [] + $.openList = [...cardList,...cardList1,...cardList2] + $.allOpenCard = res.data.allOpenCard || false + $.openCardScore1 = res.data.score1 || 0 + $.openCardScore2 = res.data.score2 || 0 + $.drawScore = res.data.drawScore || 0 + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'startDraw': + case 'followShop': + case 'viewVideo': + case 'visitSku': + case 'toShop': + case 'addSku': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(typeof res.data == 'object'){ + let msg = '' + let title = '抽奖' + if(res.data.addBeanNum && res.data.sendStatus){ + msg = `${res.data.addBeanNum}京豆` + } + if(type == 'followShop'){ + title = '关注' + if(res.data.beanNumMember && res.data.assistSendStatus){ + msg += ` 额外获得:${res.data.beanNumMember}京豆` + } + }else if(type == 'addSku'){ + title = '加购' + }else if(type == 'viewVideo'){ + title = '热门文章' + }else if(type == 'toShop'){ + title = '浏览店铺' + }else if(type == 'visitSku'){ + title = '浏览商品' + }else{ + msg = res.data.drawOk == true && (res.data.drawInfoType == 6 && res.data.name || '') || '空气💨' + } + if(!msg){ + msg = '空气💨' + } + console.log(`${title}获得:${msg || data}`) + }else{ + console.log(`${type} ${data}`) + } + }else if(res.errorMessage){ + $.runFalag = false; + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getDrawRecordHasCoupon': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + console.log(`我的奖品:`) + let num = 0 + let value = 0 + for(let i in res.data){ + let item = res.data[i] + if(item.value == '邀请好友') num++; + if(item.value == '邀请好友') value = item.infoName.replace('京豆',''); + if(item.value != '邀请好友') console.log(`${item.infoType != 10 && item.value +':' || ''}${item.infoName}`) + } + if(num > 0) console.log(`邀请好友(${num}):${num*parseInt(value, 10) || 30}京豆`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getShareRecord': + if(typeof res == 'object'){ + if(res.result && res.result === true && res.data){ + $.ShareCount = res.data.length + $.log(`=========== 你邀请了:${res.data.length}个`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'accessLogWithAD': + case 'drawContent': + break; + default: + console.log(`${type}-> ${data}`); + } + if(typeof res == 'object'){ + if(res.errorMessage){ + if(res.errorMessage.indexOf('火爆') >-1 ){ + $.hotFlag = true + } + } + } + } catch (e) { + console.log(e) + } +} + +function getPostRequest(url, body, method="POST") { + let headers = { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Content-Type": "application/x-www-form-urlencoded", + "Cookie": cookie, + "User-Agent": $.UA, + "X-Requested-With": "XMLHttpRequest" + } + if(url.indexOf('https://lzdz1-isv.isvjcloud.com') > -1){ + headers["Referer"] = `https://lzdz1-isv.isvjcloud.com/dingzhi/dz/openCard/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}` + headers["Cookie"] = `${lz_jdpin_token_cookie && lz_jdpin_token_cookie || ''}${$.Pin && "AUTH_C_USER=" + $.Pin + ";" || ""}${activityCookie}` + } + // console.log(headers) + // console.log(headers.Cookie) + return {url: url, method: method, headers: headers, body: body, timeout:30000}; +} + +function getCk() { + return new Promise(resolve => { + let get = { + url:`https://lzdz1-isv.isvjcloud.com/dingzhi/dz/openCard/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}`, + followRedirect:false, + headers: { + "User-Agent": $.UA, + }, + timeout:30000 + } + $.get(get, async(err, resp, data) => { + try { + if (err) { + if(resp && typeof resp.statusCode != 'undefined'){ + if(resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + } + console.log(`${$.toStr(err)}`) + console.log(`${$.name} cookie API请求失败,请检查网路重试`) + } else { + let end = data.match(/(活动已经结束)/) && data.match(/(活动已经结束)/)[1] || '' + if(end){ + $.activityEnd = true + console.log('活动已结束') + } + setActivityCookie(resp) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function setActivityCookie(resp){ + let LZ_TOKEN_KEY = '' + let LZ_TOKEN_VALUE = '' + let lz_jdpin_token = '' + let setcookies = resp && resp['headers'] && (resp['headers']['set-cookie'] || resp['headers']['Set-Cookie'] || '') || '' + let setcookie = '' + if(setcookies){ + if(typeof setcookies != 'object'){ + setcookie = setcookies.split(',') + }else setcookie = setcookies + for (let ck of setcookie) { + let name = ck.split(";")[0].trim() + if(name.split("=")[1]){ + // console.log(name.replace(/ /g,'')) + if(name.indexOf('LZ_TOKEN_KEY=')>-1) LZ_TOKEN_KEY = name.replace(/ /g,'')+';' + if(name.indexOf('LZ_TOKEN_VALUE=')>-1) LZ_TOKEN_VALUE = name.replace(/ /g,'')+';' + if(name.indexOf('lz_jdpin_token=')>-1) lz_jdpin_token = ''+name.replace(/ /g,'')+';' + } + } + } + if(LZ_TOKEN_KEY && LZ_TOKEN_VALUE) activityCookie = `${LZ_TOKEN_KEY} ${LZ_TOKEN_VALUE}` + if(lz_jdpin_token) lz_jdpin_token_cookie = lz_jdpin_token +} + +async function getUA(){ + $.UA = `jdapp;iPhone;10.1.4;13.1.2;${randomString(40)};network/wifi;model/iPhone8,1;addressid/2308460611;appBuild/167814;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_1_2 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 joinShop() { + if(!$.joinVenderId) return + return new Promise(async resolve => { + $.shopactivityId = '' + await $.wait(1000) + await getshopactivityId() + let activityId = `` + if($.shopactivityId) activityId = `,"activityId":${$.shopactivityId}` + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body={"venderId":"${$.joinVenderId}","shopId":"${$.joinVenderId}","bindByVerifyCodeFlag":1,"registerExtend":{},"writeChildFlag":0${activityId},"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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + // console.log(data) + let res = $.toObj(data); + if(typeof res == 'object'){ + if(res.success === true){ + console.log(res.message) + if(res.result && res.result.giftInfo){ + for(let i of res.result.giftInfo.giftList){ + console.log(`入会获得:${i.discountString}${i.prizeName}${i.secondLineDesc}`) + } + } + }else if(typeof res == 'object' && res.message){ + console.log(`${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function getshopactivityId() { + return new Promise(resolve => { + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body=%7B%22venderId%22%3A%22${$.joinVenderId}%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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + let res = $.toObj(data); + if(res.success == true){ + // console.log($.toStr(res.result)) + console.log(`入会:${res.result.shopMemberCardInfo.venderCardName || ''}`) + $.shopactivityId = res.result.interestsRuleList && res.result.interestsRuleList[0] && res.result.interestsRuleList[0].interestsInfo && res.result.interestsRuleList[0].interestsInfo.activityId || '' + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} + + +// 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)} + diff --git a/activity/jd_opencardL61.js b/activity/jd_opencardL61.js new file mode 100644 index 0000000..115b32b --- /dev/null +++ b/activity/jd_opencardL61.js @@ -0,0 +1,547 @@ +/* +1.23~1.28 联合开卡 +新增开卡脚本,一次性脚本 + +第一个账号助力作者 其他依次助力CK1 +第一个CK失效会退出脚本 + +———————————————— +入口:[ 1.23~1.28 联合开卡 (https://jinggengjcq-isv.isvjcloud.com/fronth5/#/pages/unitedCardNew20220123/unitedCardNew20220123?actId=b2d6a99babf64595aac5_220123)] + +请求太频繁会被黑ip +过10分钟再执行 + + +cron:44 0,11 23-28 1 * +============Quantumultx=============== +[task_local] +#1.23~1.28 联合开卡 +44 0,11 23-28 1 * jd_opencardL61.js, tag=1.23~1.28 联合开卡, enabled=true + +*/ + +const $ = new Env('1.23~1.28 联合开卡'); +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const notify = $.isNode() ? require('./sendNotify') : ''; + +//IOS等用户直接用NobyDa的jd cookie +let cookiesArr = [], + cookie = ''; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} + +allMessage = "" +message = "" +$.hotFlag = false +$.outFlag = false +$.activityEnd = false +let lz_jdpin_token_cookie ='' +let activityCookie ='' +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', { + "open-url": "https://bean.m.jd.com/" + }); + return; + } + // return + $.appkey = '51B59BB805903DA4CE513D29EC448375' + $.userId = '10299171' + $.actId = 'b2d6a99babf64595aac5_220123' + $.MixNicks = '' + $.inviteNick = 'k1Nobb+P0er+C2sysxnx/P2KELO9izRVpwCyqu0eqVZ5aW7RHzlMobrzJ/e9r/uf' + console.log(`活动地址:https://jinggengjcq-isv.isvjcloud.com/fronth5/#/pages/unitedCardNew20220123/unitedCardNew20220123?actId=b2d6a99babf64595aac5_220123`) + console.log(`请自行测试有水无水。`) + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i]; + if (cookie) { + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + message = "" + $.bean = 0 + $.hotFlag = false + $.nickName = ''; + console.log(`\n\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + await getUA() + await run(); + if(i == 0 && !$.MixNick) break + if($.outFlag || $.activityEnd) break + } + } + if($.outFlag) { + let msg = '此ip已被限制,请过10分钟后再执行脚本' + $.msg($.name, ``, `${msg}`); + if ($.isNode()) await notify.sendNotify(`${$.name}`, `${msg}`); + } +})() + .catch((e) => $.logErr(e)) + .finally(() => $.done()) + + +async function run() { + try { + $.hasEnd = true + $.endTime = 0 + lz_jdpin_token_cookie = '' + $.Token = '' + $.Pin = '' + $.MixNick = '' + let flag = false + if($.activityEnd) return + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + await takePostRequest('isvObfuscator'); + if($.Token == ''){ + console.log('获取[token]失败!') + return + } + await takePostRequest('activity_load'); + if($.hotFlag) return + if(Date.now() > $.endTime){ + $.MixNick = '' + $.activityEnd = true + console.log('活动结束') + return + } + if ($.MixNick == '') { + console.log(`获取cookie失败`); return; + } + // console.log($.MixNick) + // return + $.toBind = 0 + $.openList = [] + await takePostRequest('绑定'); + await takePostRequest('shopList'); + if($.activityEnd) return + for(o of $.openList){ + $.missionType = 'openCard' + if(o.open != true && o.openCardUrl){ + if($.activityEnd) return + $.openCard = false + $.joinVenderId = o.userId + await takePostRequest('mission'); + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + if($.openCard == true){ + await joinShop() + await takePostRequest('activity_load'); + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + // break + } + $.joinVenderId = '' + } + } + $.joinVenderId = '' + if($.hasCollectShop === 0){ + // 关注 + $.missionType = 'uniteCollectShop' + await takePostRequest('mission'); + await $.wait(parseInt(Math.random() * 2000 + 3000, 10)) + }else{ + console.log('已经关注') + } + $.missionType = 'uniteAddCart' + + await takePostRequest('mission'); + await $.wait(parseInt(Math.random() * 2000 + 3000, 10)) + await takePostRequest('activity_load'); + $.runFalag = true + let count = parseInt($.usedChance, 10) + console.log(`抽奖次数为:${count}`) + for(m=1;count--;m++){ + console.log(`第${m}次抽奖`) + await takePostRequest('抽奖'); + if($.runFalag == false) break + if(Number(count) <= 0) break + if(m >= 10){ + console.log("抽奖太多次,多余的次数请再执行脚本") + break + } + await $.wait(parseInt(Math.random() * 2000 + 2000, 10)) + } + await takePostRequest('myAward'); + await takePostRequest('missionInviteList'); + console.log($.MixNick) + console.log(`当前助力:${$.inviteNick}`) + if($.index == 1){ + $.inviteNick = $.MixNick + console.log(`后面的号都会助力:${$.inviteNick}`) + } + await $.wait(parseInt(Math.random() * 1000 + 5000, 10)) + if(flag) await $.wait(parseInt(Math.random() * 1000 + 10000, 10)) + if($.index % 3 == 0) console.log('休息1分钟,别被黑ip了\n可持续发展') + if($.index % 3 == 0) await $.wait(parseInt(Math.random() * 5000 + 60000, 10)) + } catch (e) { + console.log(e) + } +} + +async function takePostRequest(type) { + if($.outFlag) return + let domain = 'https://jinggengjcq-isv.isvjcloud.com'; + let body = ``; + let method = 'POST' + let admJson = '' + switch (type) { + case 'isvObfuscator': + url = `https://api.m.jd.com/client.action?functionId=isvObfuscator`; + body = `body=%7B%22url%22%3A%22https%3A//jinggengjcq-isv.isvjcloud.com/fronth5/%3Flng%3D0%26lat%3D0%26sid%3D49687cd64aca2ae93aa43748a04e8f6w%26un_area%3D16_1315_1316_53522%23/pages/unitedCardNew20211010-ka/unitedCardNew20211010-ka%3FactId%3D9150e1d16b9d40_10101%22%2C%22id%22%3A%22%22%7D&uuid=b9b4ce69d42dacb64084279d51cdee764d7781fa&client=apple&clientVersion=10.1.4&st=1634100732991&sv=111&sign=67e254ffbcb13be9e12a9782c9cdf398`; + break; + case 'activity_load': + url = `${domain}/dm/front/openCardNew/activity_load?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"jdToken": $.Token, "source": "01", "inviteNick":($.inviteNick || "")} + if($.joinVenderId) admJson = {...admJson, "shopId": `${$.joinVenderId}`} + body = taskPostUrl("/openCardNew/activity_load", admJson); + break; + case 'shopList': + url = `${domain}/dm/front/openCardNew/shopList?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {} + body = taskPostUrl("/openCardNew/shopList", admJson); + break; + case '绑定': + url = `${domain}/dm/front/openCardNew/complete/mission?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"missionType": "relationBind", "inviterNick":($.inviteNick || "")} + body = taskPostUrl("/openCardNew/complete/mission", admJson); + break; + case 'mission': + url = `${domain}/dm/front/openCardNew/complete/mission?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"missionType": $.missionType} + if($.joinVenderId) admJson = {...admJson, "shopId": $.joinVenderId} + body = taskPostUrl("/openCardNew/complete/mission", admJson); + break; + case '抽奖': + url = `${domain}/dm/front/openCardNew/draw/post?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"dataType": "draw", "usedGameNum": "2"} + body = taskPostUrl("/openCardNew/draw/post", admJson); + break; + case 'followShop': + url = `${domain}/dm/front/openCardNew/followShop?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"actId": $.actId, "missionType": "collectShop"} + body = taskPostUrl("/openCardNew/followShop", admJson); + break; + case 'addCart': + url = `${domain}/dm/front/openCardNew/addCart?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"actId": $.actId, "missionType": "addCart"} + body = taskPostUrl("/openCardNew/addCart", admJson); + break; + case 'myAward': + url = `${domain}/dm/front/openCardNew/myAwards?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"pageNo": 1,"pageSize":9999} + body = taskPostUrl("/openCardNew/myAwards", admJson); + break; + case 'missionInviteList': + url = `${domain}/dm/front/openCardNew/missionInviteList?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"inviteListRequest":{"actId":$.actId,"userId":10299171,"missionType":"shareAct","inviteType": 1,"buyerNick":($.MixNick || '')}} + body = taskPostUrl("/openCardNew/missionInviteList", admJson); + break; + default: + console.log(`错误${type}`); + } + let myRequest = getPostRequest(url, body, method); + return new Promise(async resolve => { + $.post(myRequest, (err, resp, data) => { + try { + if (err) { + if(resp && resp.statusCode && resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + console.log(`${$.toStr(err,err)}`) + console.log(`${type} API请求失败,请检查网路重试`) + } else { + dealReturn(type, data); + } + } catch (e) { + // console.log(data); + console.log(e, resp) + } finally { + resolve(); + } + }) + }) + } + +async function dealReturn(type, data) { + let res = '' + try { + if(type != 'accessLogWithAD' || type != 'drawContent'){ + if(data){ + res = JSON.parse(data); + } + } + } catch (e) { + console.log(`${type} 执行任务异常`); + console.log(data); + $.runFalag = false; + } + try { + let title = '' + switch (type) { + case 'isvObfuscator': + if(typeof res == 'object'){ + if(res.errcode == 0){ + if(typeof res.token != 'undefined') $.Token = res.token + }else if(res.message){ + console.log(`${type} ${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + break; + case 'accessLogWithAD': + case 'drawContent': + break; + case 'activity_load': + case 'mission': + case 'shopList': + case 'loadUniteOpenCard': + case 'setMixNick': + case 'uniteOpenCardOne': + case 'checkOpenCard': + case 'followShop': + case 'addCart': + case 'myAward': + case 'missionInviteList': + case '抽奖': + title = '' + if(type == "followShop") title = '关注' + if(type == "addCart") title = '加购' + if(typeof res == 'object'){ + if(res.success && res.success === true && res.data){ + if(res.data.status && res.data.status == 200){ + res = res.data + if(type != "setMixNick" && (res.msg || res.data.isOpenCard || res.data.remark)) console.log(`${title && title+":" || ""}${res.msg || res.data.isOpenCard || res.data.remark || ''}`) + if(type == "activity_load"){ + if(res.msg || res.data.isOpenCard) { + if((res.msg || res.data.isOpenCard || '').indexOf('绑定成功') > -1) $.toBind = 1 + } + if(res.data){ + $.endTime = res.data.cusActivity.endTime || 0 + $.MixNick = res.data.buyerNick || "" + $.usedChance = res.data.missionCustomer.usedChance || 0 + $.hasCollectShop = res.data.missionCustomer.hasCollectShop || 0 + } + }else if(type == "shopList"){ + $.openList = res.data.cusShops || [] + }else if(type == "mission"){ + if(res.data.remark.indexOf('不是会员') > -1){ + $.openCard = true + }else{ + $.openCard = false + } + }else if(type == "uniteOpenCardOne"){ + $.uniteOpenCar = res.msg || res.data.msg || '' + }else if(type == "myAward"){ + console.log(`我的奖品:`) + let num = 0 + let value = 0 + for(let i in res.data.list || []){ + let item = res.data.list[i] + value += Number(item.awardDes) + } + if(value > 0) console.log(`共获得${value}京豆\n无法判断奖励是否为邀请奖励,所以直接显示获得多少豆\n`) + }else if(type == "missionInviteList"){ + console.log(`邀请人数(${res.data.invitedLogList.total})`) + } + }else if(res.data.msg){ + if(res.errorMessage.indexOf('活动未开始') >-1 ){ + $.activityEnd = true + } + console.log(`${title || type} ${res.data.msg || ''}`) + }else if(res.errorMessage){ + if(res.errorMessage.indexOf('火爆') >-1 ){ + $.hotFlag = true + } + console.log(`${title || type} ${res.errorMessage || ''}`) + }else{ + console.log(`${title || type} ${data}`) + } + }else if(res.errorMessage){ + console.log(`${title || type} ${res.errorMessage || ''}`) + }else{ + console.log(`${title || type} ${data}`) + } + }else{ + console.log(`${title || type} ${data}`) + } + break; + default: + console.log(`${title || type}-> ${data}`); + } + if(typeof res == 'object'){ + if(res.errorMessage){ + if(res.errorMessage.indexOf('火爆') >-1 ){ + $.hotFlag = true + } + } + } + } catch (e) { + console.log(e) + } +} + +function getPostRequest(url, body, method="POST") { + let headers = { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Content-Type": "application/x-www-form-urlencoded", + "Cookie": cookie, + "User-Agent": $.UA, + "X-Requested-With": "XMLHttpRequest" + } + if(url.indexOf('https://jinggengjcq-isv.isvjcloud.com') > -1){ + headers["Origin"] = `https://jinggengjcq-isv.isvjcloud.com` + headers["Content-Type"] = `application/json; charset=utf-8` + delete headers["Cookie"] + } + // console.log(headers) + // console.log(headers.Cookie) + return {url: url, method: method, headers: headers, body: body, timeout:60000}; +} + + +function taskPostUrl(url, t) { + + const b = { + "jsonRpc": "2.0", + "params": { + "commonParameter": { + "appkey": $.appkey, + "m": "POST", + "timestamp": Date.now(), + "userId": $.userId + }, + "admJson": { + "actId": $.actId, + "userId": $.userId, + ...t, + "method": url, + "buyerNick": ($.MixNick || ''), + } + }, + } + if(url.indexOf('missionInviteList') > -1){ + delete b.params.admJson.actId + } + return $.toStr(b,b) +} +async function getUA(){ + $.UA = `jdapp;iPhone;10.1.4;13.1.2;${randomString(40)};network/wifi;model/iPhone8,1;addressid/2308460611;appBuild/167814;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_1_2 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 jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} + +function joinShop() { + if(!$.joinVenderId) return + return new Promise(async resolve => { + $.shopactivityId = '' + await $.wait(1000) + await getshopactivityId() + let activityId = `` + if($.shopactivityId) activityId = `,"activityId":${$.shopactivityId}` + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body={"venderId":"${$.joinVenderId}","shopId":"${$.joinVenderId}","bindByVerifyCodeFlag":1,"registerExtend":{},"writeChildFlag":0${activityId},"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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + // console.log(data) + let res = $.toObj(data,data); + if(typeof res == 'object'){ + if(res.success === true){ + console.log(res.message) + if(res.result && res.result.giftInfo){ + for(let i of res.result.giftInfo.giftList){ + console.log(`入会获得:${i.discountString}${i.prizeName}${i.secondLineDesc}`) + } + } + }else if(typeof res == 'object' && res.message){ + console.log(`${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function getshopactivityId() { + return new Promise(resolve => { + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body=%7B%22venderId%22%3A%22${$.joinVenderId}%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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + let res = $.toObj(data,data); + if(typeof res == 'object'){ + if(res.success == true){ + // console.log($.toStr(res.result)) + console.log(`入会:${res.result.shopMemberCardInfo.venderCardName || ''}`) + $.shopactivityId = res.result.interestsRuleList && res.result.interestsRuleList[0] && res.result.interestsRuleList[0].interestsInfo && res.result.interestsRuleList[0].interestsInfo.activityId || '' + } + }else{ + console.log(data) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +// 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)} + diff --git a/activity/jd_opencardL62.js b/activity/jd_opencardL62.js new file mode 100644 index 0000000..5e3c898 --- /dev/null +++ b/activity/jd_opencardL62.js @@ -0,0 +1,544 @@ +/* +1.24~2.14 联合开卡 +新增开卡脚本,一次性脚本 + +第一个账号助力作者 其他依次助力CK1 +第一个CK失效会退出脚本 + +———————————————— +入口:[ 1.24~2.14 联合开卡 (https://jinggengjcq-isv.isvjcloud.com/fronth5/#/pages/unitedCardNew20220124/unitedCardNew20220124?actId=29c257bced_220124)] + +请求太频繁会被黑ip +过10分钟再执行 + + +cron:42 0,11 24-31,1-14 1,2 * +============Quantumultx=============== +[task_local] +#1.24~2.14 联合开卡 +42 0,11 24-31,1-14 1,2 * jd_opencardL62.js, tag=1.24~2.14 联合开卡, enabled=true + +*/ + +const $ = new Env('1.24~2.14 联合开卡'); +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const notify = $.isNode() ? require('./sendNotify') : ''; + +//IOS等用户直接用NobyDa的jd cookie +let cookiesArr = [], + cookie = ''; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} + +allMessage = "" +message = "" +$.hotFlag = false +$.outFlag = false +$.activityEnd = false +let lz_jdpin_token_cookie ='' +let activityCookie ='' +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', { + "open-url": "https://bean.m.jd.com/" + }); + return; + } + // return + $.appkey = '51B59BB805903DA4CE513D29EC448375' + $.userId = '10299171' + $.actId = '29c257bced_220124' + $.MixNicks = '' + $.inviteNick = 'k1Nobb+P0er+C2sysxnx/P2KELO9izRVpwCyqu0eqVZ5aW7RHzlMobrzJ/e9r/uf' + console.log(`活动地址:https://jinggengjcq-isv.isvjcloud.com/fronth5/#/pages/unitedCardNew20220124/unitedCardNew20220124?actId=29c257bced_220124`) + console.log(`请自行测试有水无水。`) + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i]; + if (cookie) { + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + message = "" + $.bean = 0 + $.hotFlag = false + $.nickName = ''; + console.log(`\n\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + await getUA() + await run(); + if(i == 0 && !$.MixNick) break + if($.outFlag || $.activityEnd) break + } + } + if($.outFlag) { + let msg = '此ip已被限制,请过10分钟后再执行脚本' + $.msg($.name, ``, `${msg}`); + if ($.isNode()) await notify.sendNotify(`${$.name}`, `${msg}`); + } +})() + .catch((e) => $.logErr(e)) + .finally(() => $.done()) + + +async function run() { + try { + $.hasEnd = true + $.endTime = 0 + lz_jdpin_token_cookie = '' + $.Token = '' + $.Pin = '' + $.MixNick = '' + let flag = false + if($.activityEnd) return + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + await takePostRequest('isvObfuscator'); + if($.Token == ''){ + console.log('获取[token]失败!') + return + } + await takePostRequest('activity_load'); + if($.hotFlag) return + if(Date.now() > $.endTime){ + $.MixNick = '' + $.activityEnd = true + console.log('活动结束') + return + } + if ($.MixNick == '') { + console.log(`获取cookie失败`); return; + } + // console.log($.MixNick) + // return + $.toBind = 0 + $.openList = [] + await takePostRequest('绑定'); + await takePostRequest('shopList'); + if($.activityEnd) return + for(o of $.openList){ + $.missionType = 'openCard' + if(o.open != true && o.openCardUrl){ + if($.activityEnd) return + $.openCard = false + $.joinVenderId = o.userId + await takePostRequest('mission'); + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + if($.openCard == true){ + await joinShop() + await takePostRequest('activity_load'); + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + // break + } + $.joinVenderId = '' + } + } + $.joinVenderId = '' + if($.hasCollectShop === 0){ + // 关注 + $.missionType = 'uniteCollectShop' + await takePostRequest('mission'); + await $.wait(parseInt(Math.random() * 2000 + 3000, 10)) + }else{ + console.log('已经关注') + } + $.missionType = 'uniteAddCart' + + await takePostRequest('mission'); + await $.wait(parseInt(Math.random() * 2000 + 3000, 10)) + await takePostRequest('activity_load'); + $.runFalag = true + let count = parseInt($.usedChance, 10) + console.log(`抽奖次数为:${count}`) + for(m=1;count--;m++){ + console.log(`第${m}次抽奖`) + await takePostRequest('抽奖'); + if($.runFalag == false) break + if(Number(count) <= 0) break + if(m >= 10){ + console.log("抽奖太多次,多余的次数请再执行脚本") + break + } + await $.wait(parseInt(Math.random() * 2000 + 2000, 10)) + } + await takePostRequest('myAward'); + await takePostRequest('missionInviteList'); + console.log($.MixNick) + console.log(`当前助力:${$.inviteNick}`) + if($.index == 1){ + $.inviteNick = $.MixNick + console.log(`后面的号都会助力:${$.inviteNick}`) + } + await $.wait(parseInt(Math.random() * 1000 + 5000, 10)) + } catch (e) { + console.log(e) + } +} + +async function takePostRequest(type) { + if($.outFlag) return + let domain = 'https://jinggengjcq-isv.isvjcloud.com'; + let body = ``; + let method = 'POST' + let admJson = '' + switch (type) { + case 'isvObfuscator': + url = `https://api.m.jd.com/client.action?functionId=isvObfuscator`; + body = `body=%7B%22url%22%3A%22https%3A//jinggengjcq-isv.isvjcloud.com/fronth5/%3Flng%3D0%26lat%3D0%26sid%3D49687cd64aca2ae93aa43748a04e8f6w%26un_area%3D16_1315_1316_53522%23/pages/unitedCardNew20211010-ka/unitedCardNew20211010-ka%3FactId%3D9150e1d16b9d40_10101%22%2C%22id%22%3A%22%22%7D&uuid=b9b4ce69d42dacb64084279d51cdee764d7781fa&client=apple&clientVersion=10.1.4&st=1634100732991&sv=111&sign=67e254ffbcb13be9e12a9782c9cdf398`; + break; + case 'activity_load': + url = `${domain}/dm/front/openCardNew/activity_load?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"jdToken": $.Token, "source": "01", "inviteNick":($.inviteNick || "")} + if($.joinVenderId) admJson = {...admJson, "shopId": `${$.joinVenderId}`} + body = taskPostUrl("/openCardNew/activity_load", admJson); + break; + case 'shopList': + url = `${domain}/dm/front/openCardNew/shopList?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {} + body = taskPostUrl("/openCardNew/shopList", admJson); + break; + case '绑定': + url = `${domain}/dm/front/openCardNew/complete/mission?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"missionType": "relationBind", "inviterNick":($.inviteNick || "")} + body = taskPostUrl("/openCardNew/complete/mission", admJson); + break; + case 'mission': + url = `${domain}/dm/front/openCardNew/complete/mission?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"missionType": $.missionType} + if($.joinVenderId) admJson = {...admJson, "shopId": $.joinVenderId} + body = taskPostUrl("/openCardNew/complete/mission", admJson); + break; + case '抽奖': + url = `${domain}/dm/front/openCardNew/draw/post?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"dataType": "draw", "usedGameNum": "2"} + body = taskPostUrl("/openCardNew/draw/post", admJson); + break; + case 'followShop': + url = `${domain}/dm/front/openCardNew/followShop?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"actId": $.actId, "missionType": "collectShop"} + body = taskPostUrl("/openCardNew/followShop", admJson); + break; + case 'addCart': + url = `${domain}/dm/front/openCardNew/addCart?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"actId": $.actId, "missionType": "addCart"} + body = taskPostUrl("/openCardNew/addCart", admJson); + break; + case 'myAward': + url = `${domain}/dm/front/openCardNew/myAwards?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"pageNo": 1,"pageSize":9999} + body = taskPostUrl("/openCardNew/myAwards", admJson); + break; + case 'missionInviteList': + url = `${domain}/dm/front/openCardNew/missionInviteList?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"inviteListRequest":{"actId":$.actId,"userId":10299171,"missionType":"shareAct","inviteType": 1,"buyerNick":($.MixNick || '')}} + body = taskPostUrl("/openCardNew/missionInviteList", admJson); + break; + default: + console.log(`错误${type}`); + } + let myRequest = getPostRequest(url, body, method); + return new Promise(async resolve => { + $.post(myRequest, (err, resp, data) => { + try { + if (err) { + if(resp && resp.statusCode && resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + console.log(`${$.toStr(err,err)}`) + console.log(`${type} API请求失败,请检查网路重试`) + } else { + dealReturn(type, data); + } + } catch (e) { + // console.log(data); + console.log(e, resp) + } finally { + resolve(); + } + }) + }) + } + +async function dealReturn(type, data) { + let res = '' + try { + if(type != 'accessLogWithAD' || type != 'drawContent'){ + if(data){ + res = JSON.parse(data); + } + } + } catch (e) { + console.log(`${type} 执行任务异常`); + console.log(data); + $.runFalag = false; + } + try { + let title = '' + switch (type) { + case 'isvObfuscator': + if(typeof res == 'object'){ + if(res.errcode == 0){ + if(typeof res.token != 'undefined') $.Token = res.token + }else if(res.message){ + console.log(`${type} ${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + break; + case 'accessLogWithAD': + case 'drawContent': + break; + case 'activity_load': + case 'mission': + case 'shopList': + case 'loadUniteOpenCard': + case 'setMixNick': + case 'uniteOpenCardOne': + case 'checkOpenCard': + case 'followShop': + case 'addCart': + case 'myAward': + case 'missionInviteList': + case '抽奖': + title = '' + if(type == "followShop") title = '关注' + if(type == "addCart") title = '加购' + if(typeof res == 'object'){ + if(res.success && res.success === true && res.data){ + if(res.data.status && res.data.status == 200){ + res = res.data + if(type != "setMixNick" && (res.msg || res.data.isOpenCard || res.data.remark)) console.log(`${title && title+":" || ""}${res.msg || res.data.isOpenCard || res.data.remark || ''}`) + if(type == "activity_load"){ + if(res.msg || res.data.isOpenCard) { + if((res.msg || res.data.isOpenCard || '').indexOf('绑定成功') > -1) $.toBind = 1 + } + if(res.data){ + $.endTime = res.data.cusActivity.endTime || 0 + $.MixNick = res.data.buyerNick || "" + $.usedChance = res.data.missionCustomer.usedChance || 0 + $.hasCollectShop = res.data.missionCustomer.hasCollectShop || 0 + } + }else if(type == "shopList"){ + $.openList = res.data.cusShops || [] + }else if(type == "mission"){ + if(res.data.remark.indexOf('不是会员') > -1){ + $.openCard = true + }else{ + $.openCard = false + } + }else if(type == "uniteOpenCardOne"){ + $.uniteOpenCar = res.msg || res.data.msg || '' + }else if(type == "myAward"){ + console.log(`我的奖品:`) + let num = 0 + let value = 0 + for(let i in res.data.list || []){ + let item = res.data.list[i] + value += Number(item.awardDes) + } + if(value > 0) console.log(`共获得${value}京豆\n无法判断奖励是否为邀请奖励,所以直接显示获得多少豆\n`) + }else if(type == "missionInviteList"){ + console.log(`邀请人数(${res.data.invitedLogList.total})`) + } + }else if(res.data.msg){ + if(res.errorMessage.indexOf('活动未开始') >-1 ){ + $.activityEnd = true + } + console.log(`${title || type} ${res.data.msg || ''}`) + }else if(res.errorMessage){ + if(res.errorMessage.indexOf('火爆') >-1 ){ + $.hotFlag = true + } + console.log(`${title || type} ${res.errorMessage || ''}`) + }else{ + console.log(`${title || type} ${data}`) + } + }else if(res.errorMessage){ + console.log(`${title || type} ${res.errorMessage || ''}`) + }else{ + console.log(`${title || type} ${data}`) + } + }else{ + console.log(`${title || type} ${data}`) + } + break; + default: + console.log(`${title || type}-> ${data}`); + } + if(typeof res == 'object'){ + if(res.errorMessage){ + if(res.errorMessage.indexOf('火爆') >-1 ){ + $.hotFlag = true + } + } + } + } catch (e) { + console.log(e) + } +} + +function getPostRequest(url, body, method="POST") { + let headers = { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Content-Type": "application/x-www-form-urlencoded", + "Cookie": cookie, + "User-Agent": $.UA, + "X-Requested-With": "XMLHttpRequest" + } + if(url.indexOf('https://jinggengjcq-isv.isvjcloud.com') > -1){ + headers["Origin"] = `https://jinggengjcq-isv.isvjcloud.com` + headers["Content-Type"] = `application/json; charset=utf-8` + delete headers["Cookie"] + } + // console.log(headers) + // console.log(headers.Cookie) + return {url: url, method: method, headers: headers, body: body, timeout:60000}; +} + + +function taskPostUrl(url, t) { + + const b = { + "jsonRpc": "2.0", + "params": { + "commonParameter": { + "appkey": $.appkey, + "m": "POST", + "timestamp": Date.now(), + "userId": $.userId + }, + "admJson": { + "actId": $.actId, + "userId": $.userId, + ...t, + "method": url, + "buyerNick": ($.MixNick || ''), + } + }, + } + if(url.indexOf('missionInviteList') > -1){ + delete b.params.admJson.actId + } + return $.toStr(b,b) +} +async function getUA(){ + $.UA = `jdapp;iPhone;10.1.4;13.1.2;${randomString(40)};network/wifi;model/iPhone8,1;addressid/2308460611;appBuild/167814;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_1_2 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 jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} + +function joinShop() { + if(!$.joinVenderId) return + return new Promise(async resolve => { + $.shopactivityId = '' + await $.wait(1000) + await getshopactivityId() + let activityId = `` + if($.shopactivityId) activityId = `,"activityId":${$.shopactivityId}` + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body={"venderId":"${$.joinVenderId}","shopId":"${$.joinVenderId}","bindByVerifyCodeFlag":1,"registerExtend":{},"writeChildFlag":0${activityId},"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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + // console.log(data) + let res = $.toObj(data,data); + if(typeof res == 'object'){ + if(res.success === true){ + console.log(res.message) + if(res.result && res.result.giftInfo){ + for(let i of res.result.giftInfo.giftList){ + console.log(`入会获得:${i.discountString}${i.prizeName}${i.secondLineDesc}`) + } + } + }else if(typeof res == 'object' && res.message){ + console.log(`${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function getshopactivityId() { + return new Promise(resolve => { + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body=%7B%22venderId%22%3A%22${$.joinVenderId}%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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + let res = $.toObj(data,data); + if(typeof res == 'object'){ + if(res.success == true){ + // console.log($.toStr(res.result)) + console.log(`入会:${res.result.shopMemberCardInfo.venderCardName || ''}`) + $.shopactivityId = res.result.interestsRuleList && res.result.interestsRuleList[0] && res.result.interestsRuleList[0].interestsInfo && res.result.interestsRuleList[0].interestsInfo.activityId || '' + } + }else{ + console.log(data) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +// 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)} + diff --git a/activity/jd_opencardL63.js b/activity/jd_opencardL63.js new file mode 100644 index 0000000..ed6d367 --- /dev/null +++ b/activity/jd_opencardL63.js @@ -0,0 +1,524 @@ +/* +2022.1.21-2022.1.30 联合关注 +新增开卡脚本 一次性脚本 + +第一个账号助力作者 其他依次助力CK1 +第一个CK失效会退出脚本 + +———————————————— +入口:[ 2022.1.21-2022.1.30 联合关注 (https://lzdz-isv.isvjcloud.com/welfare/unite/activity?activityId=1eca438e9a484de0960115fc7088a7c6&shareUuid=779f8e318f27406daed6fe1e8e9b1565)] + +请求太频繁会被黑ip +过10分钟再执行 + +============Quantumultx=============== +[task_local] +#2022.1.21-2022.1.30 联合关注 +20 17 * * * jd_opencardL63.js, tag=2022.1.21-2022.1.30 联合关注, enabled=true + +*/ +let guaunknownTask_addSku = "true" +let guaopenwait = "0" + +const $ = new Env('2022.1.21-2022.1.30 联合关注'); +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const notify = $.isNode() ? require('./sendNotify') : ''; +//IOS等用户直接用NobyDa的jd cookie + +let cookiesArr = [], + cookie = ''; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} +allMessage = "" +message = "" +$.hotFlag = false +$.outFlag = false +$.activityEnd = false +let lz_jdpin_token_cookie ='' +let activityCookie ='' +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', { + "open-url": "https://bean.m.jd.com/" + }); + return; + } + $.activityId = "0e7eb2b10c29433293867bd626383361" + $.shareUuid = "779f8e318f27406daed6fe1e8e9b1565" + $.venderIds = "1000095981" + console.log(`入口:\nhttps://lzdz-isv.isvjcloud.com/welfare/unite/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}`) + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i]; + if (cookie) { + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + message = "" + $.bean = 0 + $.hotFlag = false + $.nickName = ''; + console.log(`\n\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + await getUA() + await run(); + if(i == 0 && !$.actorUuid) break + if($.outFlag || $.activityEnd) break + } + } + if($.outFlag) { + let msg = '此ip已被限制,请过10分钟后再执行脚本' + $.msg($.name, ``, `${msg}`); + if ($.isNode()) await notify.sendNotify(`${$.name}`, `${msg}`); + } +})() + .catch((e) => $.logErr(e)) + .finally(() => $.done()) + + +async function run() { + try { + $.hasEnd = true + $.endTime = 0 + lz_jdpin_token_cookie = '' + $.Token = '' + $.Pin = '' + let flag = false + await takePostRequest('isvObfuscator'); + if($.Token == ''){ + console.log('获取[token]失败!') + return + } + await getCk() + if (activityCookie == '') { + console.log(`获取cookie失败`); return; + } + if($.activityEnd === true){ + console.log('活动结束') + return + } + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + await takePostRequest('getMyPing'); + if(!$.Pin){ + console.log('获取[Pin]失败!') + return + } + await takePostRequest('accessLogWithAD'); + await takePostRequest('getUserInfo'); + await takePostRequest('activityContent'); + if(!$.actorUuid){ + console.log('获取不到[actorUuid]退出执行,请重新执行') + return + } + if($.hasEnd === true || Date.now() > $.endTime){ + $.activityEnd = true + console.log('活动结束') + return + } + await takePostRequest('drawContent'); + await $.wait(1000) + if($.taskData.followShop){ + $.log("关注: " + $.taskData.followShop.allStatus) + if(!$.taskData.followShop.allStatus && !$.outFlag){ + flag = true + $.taskType = 23 + await takePostRequest('关注'); + await $.wait(parseInt(Math.random() * 2000 + 3000, 10)) + } + } + if($.taskData.followSku){ + $.log("关注: " + $.taskData.followSku.allStatus) + if(!$.taskData.followSku.allStatus && !$.outFlag){ + flag = true + $.taskType = 22 + await takePostRequest('关注'); + await $.wait(parseInt(Math.random() * 2000 + 3000, 10)) + } + } + if($.taskData.addSku){ + $.log("加购: " + $.taskData.addSku.allStatus) + if(!$.taskData.addSku.allStatus && !$.outFlag){ + flag = true + $.taskType = 21 + await takePostRequest('加购'); + await $.wait(parseInt(Math.random() * 2000 + 3000, 10)) + } + } + + await $.wait(parseInt(Math.random() * 1000 + 2000, 10)) + await takePostRequest('getShareRecord'); + if($.totalCount > 0){ + let m = $.totalCount + do{ + await takePostRequest('领取奖励'); + await $.wait(parseInt(Math.random() * 1000 + 2000, 10)) + m--; + }while (m > 0) + } + await takePostRequest('getDrawRecordHasCoupon'); + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + console.log($.actorUuid) + console.log(`当前助力:${$.shareUuid}`) + if($.index == 1){ + $.shareUuid = $.actorUuid + console.log(`后面的号都会助力:${$.shareUuid}`) + } + return + await $.wait(parseInt(Math.random() * 1000 + 5000, 10)) + if(flag) await $.wait(parseInt(Math.random() * 1000 + 10000, 10)) + if($.index % 3 == 0) console.log('休息1分钟,别被黑ip了\n可持续发展') + if($.index % 3 == 0) await $.wait(parseInt(Math.random() * 5000 + 60000, 10)) + + } catch (e) { + console.log(e) + } +} + +async function takePostRequest(type) { + if($.outFlag) return + let url = 'https://lzdz-isv.isvjcloud.com'; + let body = ``; + let method = 'POST' + let admJson = '' + switch (type) { + case 'isvObfuscator': + url = `https://api.m.jd.com/client.action?functionId=isvObfuscator`; + body = `body=%7B%22url%22%3A%22https%3A//lzdz-isv.isvjcloud.com%22%2C%22id%22%3A%22%22%7D&uuid=f37a4d8b094434f55b3d8b97f53aa659e649fe06&client=apple&clientVersion=10.1.4&st=1634180373571&sv=120&sign=ec39c5ee3223426f01f88b843f898db1`; + break; + case 'getMyPing': + url = `${url}/customer/getMyPing`; + body = `userId=${$.shopId || $.venderId || $.venderIds || ''}&token=${$.Token}&fromType=APP`; + break; + case 'accessLogWithAD': + let pageurl = `${url}/drawCenter/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}` + url = `${url}/common/accessLogWithAD`; + body = `venderId=${$.shopId || $.venderId || $.venderIds || ''}&code=99&pin=${encodeURIComponent($.Pin)}&activityId=${$.activityId}&pageUrl=${encodeURIComponent(pageurl)}&subType=app&adSource=` + break; + case 'getUserInfo': + url = `${url}/wxActionCommon/getUserInfo`; + body = `pin=${encodeURIComponent($.Pin)}`; + break; + case 'activityContent': + url = `${url}/welfare/unite/activityContent`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&pinImg=${encodeURIComponent($.attrTouXiang)}&nick=${encodeURIComponent($.nickname)}&cjyxPin=&cjhyPin=&shareUuid=${$.shareUuid}` + break; + case 'drawContent': + url = `${url}/dingzhi/taskact/openCardcommon/drawContent`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case '关注': + case '加购': + url = `${url}/welfare/unite/saveTask`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&taskType=${$.taskType}&shareUuid=${$.shareUuid}` + break; + case '领取奖励': + url = `${url}/welfare/unite/getInfo`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case 'getDrawRecordHasCoupon': + url = `${url}/dingzhi/taskact/common/getDrawRecordHasCoupon`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case 'getShareRecord': + url = `${url}/welfare/unite/getAssistInfo`; + body = `activityId=${$.activityId}&actorUuid=${$.actorUuid}&sortStatus=1` + break; + default: + console.log(`错误${type}`); + } + let myRequest = getPostRequest(url, body, method); + // console.log(myRequest) + return new Promise(async resolve => { + $.post(myRequest, (err, resp, data) => { + try { + setActivityCookie(resp) + if (err) { + if(resp && typeof resp.statusCode != 'undefined'){ + if(resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + } + console.log(`${$.toStr(err,err)}`) + console.log(`${type} API请求失败,请检查网路重试`) + } else { + dealReturn(type, data); + } + } catch (e) { + // console.log(data); + console.log(e, resp) + } finally { + resolve(); + } + }) + }) + } + +async function dealReturn(type, data) { + let res = '' + try { + if(type != 'accessLogWithAD' || type != 'drawContent'){ + if(data){ + res = JSON.parse(data); + } + } + } catch (e) { + console.log(`${type} 执行任务异常`); + console.log(data); + $.runFalag = false; + } + try { + switch (type) { + case 'isvObfuscator': + if(typeof res == 'object'){ + if(res.errcode == 0){ + if(typeof res.token != 'undefined') $.Token = res.token + }else if(res.message){ + console.log(`isvObfuscator ${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + break; + case 'getMyPing': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(res.data && typeof res.data.secretPin != 'undefined') $.Pin = res.data.secretPin + if(res.data && typeof res.data.nickname != 'undefined') $.nickname = res.data.nickname + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getUserInfo': + $.attrTouXiang = "https://img10.360buyimg.com/imgzone/jfs/t1/7020/27/13511/6142/5c5138d8E4df2e764/5a1216a3a5043c5d.png" + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(res.data && typeof res.data.yunMidImageUrl != 'undefined') $.attrTouXiang = res.data.yunMidImageUrl || $.attrTouXiang + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'activityContent': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + $.endTime = res.data.endTime || res.data.activity.endTime || 0 + $.hasEnd = res.data.hasEnd || false + $.taskData = res.data.taskData || {} + $.actorUuid = res.data.actorUuid || '' + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case '抽奖': + case '关注': + case '加购': + case '领取奖励': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(typeof res.data == 'object'){ + let msg = '' + let title = type + if(res.data.drawResult){ + msg += (res.data.drawResult.drawOk == true && res.data.drawResult.value+'京豆') || '空气💨' + } + if(res.data.addPoint){ + msg += ` ${res.data.addPoint}游戏机会` + } + console.log(`${title}获得:${msg || data}`) + }else{ + console.log(`${type} ${data}`) + } + }else if(res.errorMessage){ + $.runFalag = false; + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getDrawRecordHasCoupon': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + let value = 0 + for(let i in res.data){ + let item = res.data[i] + if(item.infoName.indexOf('京豆') > -1){ + value += Number(item.infoName.replace('京豆','')) || 0 + } + } + if(value > 0) console.log(`共获得${parseInt(value, 10) || 0}京豆`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getShareRecord': + if(typeof res == 'object'){ + if(res.result && res.result === true && res.data){ + console.log(`领取机会(${res.data.hasDrawTimes}/10) 可领取奖励${res.data.totalCount}次`) + $.totalCount = res.data.totalCount + $.log(`=========== 你邀请了:${res.data.shareRecord.length}个`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'accessLogWithAD': + case 'drawContent': + break; + default: + console.log(`${type}-> ${data}`); + } + if(typeof res == 'object'){ + if(res.errorMessage){ + if(res.errorMessage.indexOf('火爆') >-1 ){ + $.hotFlag = true + } + } + } + } catch (e) { + console.log(e) + } +} + +function getPostRequest(url, body, method="POST") { + let headers = { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Content-Type": "application/x-www-form-urlencoded", + "Cookie": cookie, + "User-Agent": $.UA, + "X-Requested-With": "XMLHttpRequest" + } + if(url.indexOf('https://lzdz-isv.isvjcloud.com') > -1){ + headers["Referer"] = `https://lzdz-isv.isvjcloud.com/welfare/unite/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}` + headers["Origin"] = `https://lzdz-isv.isvjcloud.com` + headers["Cookie"] = `${lz_jdpin_token_cookie && lz_jdpin_token_cookie || ''}${$.Pin && "AUTH_C_USER=" + $.Pin + ";" || ""}${activityCookie}` + } + return {url: url, method: method, headers: headers, body: body, timeout:30000}; +} + +function getCk() { + return new Promise(resolve => { + let get = { + url:`https://lzdz-isv.isvjcloud.com/welfare/unite/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}`, + headers: { + "User-Agent": $.UA, + }, + timeout:30000 + } + $.get(get, async(err, resp, data) => { + try { + if (err) { + if(resp && typeof resp.statusCode != 'undefined'){ + if(resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + } + console.log(`${$.toStr(err)}`) + console.log(`${$.name} cookie API请求失败,请检查网路重试`) + } else { + let end = data.match(/(活动已经结束)/) && data.match(/(活动已经结束)/)[1] || '' + if(end){ + $.activityEnd = true + console.log('活动已结束') + } + setActivityCookie(resp) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function setActivityCookie(resp){ + let LZ_TOKEN_KEY = '' + let LZ_TOKEN_VALUE = '' + let lz_jdpin_token = '' + let setcookies = resp && resp['headers'] && (resp['headers']['set-cookie'] || resp['headers']['Set-Cookie'] || '') || '' + let setcookie = '' + if(setcookies){ + if(typeof setcookies != 'object'){ + setcookie = setcookies.split(',') + }else setcookie = setcookies + for (let ck of setcookie) { + let name = ck.split(";")[0].trim() + if(name.split("=")[1]){ + // console.log(name.replace(/ /g,'')) + if(name.indexOf('LZ_TOKEN_KEY=')>-1) LZ_TOKEN_KEY = name.replace(/ /g,'')+';' + if(name.indexOf('LZ_TOKEN_VALUE=')>-1) LZ_TOKEN_VALUE = name.replace(/ /g,'')+';' + if(name.indexOf('lz_jdpin_token=')>-1) lz_jdpin_token = ''+name.replace(/ /g,'')+';' + } + } + } + if(LZ_TOKEN_KEY && LZ_TOKEN_VALUE) activityCookie = `${LZ_TOKEN_KEY} ${LZ_TOKEN_VALUE}` + if(lz_jdpin_token) lz_jdpin_token_cookie = lz_jdpin_token +} + +async function getUA(){ + $.UA = `jdapp;iPhone;10.1.4;13.1.2;${randomString(40)};network/wifi;model/iPhone8,1;addressid/2308460611;appBuild/167814;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_1_2 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 jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} + + +// 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)} diff --git a/activity/jd_opencardL64.js b/activity/jd_opencardL64.js new file mode 100644 index 0000000..39b90bc --- /dev/null +++ b/activity/jd_opencardL64.js @@ -0,0 +1,544 @@ +/* +1.25~1.30 联合开卡 +新增开卡脚本,一次性脚本 + +第一个账号助力作者 其他依次助力CK1 +第一个CK失效会退出脚本 + +———————————————— +入口:[ 1.25~1.30 联合开卡 (https://jinggengjcq-isv.isvjcloud.com/fronth5/#/pages/unitedCardNew20220125/unitedCardNew20220125?actId=mdccccye6ty52yygi_220125)] + +请求太频繁会被黑ip +过10分钟再执行 + + +cron:40 0,15 26-30 1 * +============Quantumultx=============== +[task_local] +#1.25~1.30 联合开卡 +40 0,15 26-30 1 * jd_opencardL64.js, tag=1.25~1.30 联合开卡, enabled=true + +*/ + +const $ = new Env('1.25~1.30 联合开卡'); +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const notify = $.isNode() ? require('./sendNotify') : ''; + +//IOS等用户直接用NobyDa的jd cookie +let cookiesArr = [], + cookie = ''; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} + +allMessage = "" +message = "" +$.hotFlag = false +$.outFlag = false +$.activityEnd = false +let lz_jdpin_token_cookie ='' +let activityCookie ='' +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', { + "open-url": "https://bean.m.jd.com/" + }); + return; + } + // return + $.appkey = '51B59BB805903DA4CE513D29EC448375' + $.userId = '10299171' + $.actId = 'mdccccye6ty52yygi_220125' + $.MixNicks = '' + $.inviteNick = 'k1Nobb+P0er+C2sysxnx/P2KELO9izRVpwCyqu0eqVZ5aW7RHzlMobrzJ/e9r/uf' + console.log(`活动地址:https://jinggengjcq-isv.isvjcloud.com/fronth5/#/pages/unitedCardNew20220125/unitedCardNew20220125?actId=mdccccye6ty52yygi_220125`) + console.log(`请自行测试有水无水。`) + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i]; + if (cookie) { + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + message = "" + $.bean = 0 + $.hotFlag = false + $.nickName = ''; + console.log(`\n\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + await getUA() + await run(); + if(i == 0 && !$.MixNick) break + if($.outFlag || $.activityEnd) break + } + } + if($.outFlag) { + let msg = '此ip已被限制,请过10分钟后再执行脚本' + $.msg($.name, ``, `${msg}`); + if ($.isNode()) await notify.sendNotify(`${$.name}`, `${msg}`); + } +})() + .catch((e) => $.logErr(e)) + .finally(() => $.done()) + + +async function run() { + try { + $.hasEnd = true + $.endTime = 0 + lz_jdpin_token_cookie = '' + $.Token = '' + $.Pin = '' + $.MixNick = '' + let flag = false + if($.activityEnd) return + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + await takePostRequest('isvObfuscator'); + if($.Token == ''){ + console.log('获取[token]失败!') + return + } + await takePostRequest('activity_load'); + if($.hotFlag) return + if(Date.now() > $.endTime){ + $.MixNick = '' + $.activityEnd = true + console.log('活动结束') + return + } + if ($.MixNick == '') { + console.log(`获取cookie失败`); return; + } + // console.log($.MixNick) + // return + $.toBind = 0 + $.openList = [] + await takePostRequest('绑定'); + await takePostRequest('shopList'); + if($.activityEnd) return + for(o of $.openList){ + $.missionType = 'openCard' + if(o.open != true && o.openCardUrl){ + if($.activityEnd) return + $.openCard = false + $.joinVenderId = o.userId + await takePostRequest('mission'); + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + if($.openCard == true){ + await joinShop() + await takePostRequest('activity_load'); + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + // break + } + $.joinVenderId = '' + } + } + $.joinVenderId = '' + if($.hasCollectShop === 0){ + // 关注 + $.missionType = 'uniteCollectShop' + await takePostRequest('mission'); + await $.wait(parseInt(Math.random() * 2000 + 3000, 10)) + }else{ + console.log('已经关注') + } + $.missionType = 'uniteAddCart' + + await takePostRequest('mission'); + await $.wait(parseInt(Math.random() * 2000 + 3000, 10)) + await takePostRequest('activity_load'); + $.runFalag = true + let count = parseInt($.usedChance, 10) + console.log(`抽奖次数为:${count}`) + for(m=1;count--;m++){ + console.log(`第${m}次抽奖`) + await takePostRequest('抽奖'); + if($.runFalag == false) break + if(Number(count) <= 0) break + if(m >= 10){ + console.log("抽奖太多次,多余的次数请再执行脚本") + break + } + await $.wait(parseInt(Math.random() * 2000 + 2000, 10)) + } + await takePostRequest('myAward'); + await takePostRequest('missionInviteList'); + console.log($.MixNick) + console.log(`当前助力:${$.inviteNick}`) + if($.index == 1){ + $.inviteNick = $.MixNick + console.log(`后面的号都会助力:${$.inviteNick}`) + } + await $.wait(parseInt(Math.random() * 1000 + 5000, 10)) + } catch (e) { + console.log(e) + } +} + +async function takePostRequest(type) { + if($.outFlag) return + let domain = 'https://jinggengjcq-isv.isvjcloud.com'; + let body = ``; + let method = 'POST' + let admJson = '' + switch (type) { + case 'isvObfuscator': + url = `https://api.m.jd.com/client.action?functionId=isvObfuscator`; + body = `body=%7B%22url%22%3A%22https%3A//jinggengjcq-isv.isvjcloud.com/fronth5/%3Flng%3D0%26lat%3D0%26sid%3D49687cd64aca2ae93aa43748a04e8f6w%26un_area%3D16_1315_1316_53522%23/pages/unitedCardNew20211010-ka/unitedCardNew20211010-ka%3FactId%3D9150e1d16b9d40_10101%22%2C%22id%22%3A%22%22%7D&uuid=b9b4ce69d42dacb64084279d51cdee764d7781fa&client=apple&clientVersion=10.1.4&st=1634100732991&sv=111&sign=67e254ffbcb13be9e12a9782c9cdf398`; + break; + case 'activity_load': + url = `${domain}/dm/front/openCardNew/activity_load?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"jdToken": $.Token, "source": "01", "inviteNick":($.inviteNick || "")} + if($.joinVenderId) admJson = {...admJson, "shopId": `${$.joinVenderId}`} + body = taskPostUrl("/openCardNew/activity_load", admJson); + break; + case 'shopList': + url = `${domain}/dm/front/openCardNew/shopList?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {} + body = taskPostUrl("/openCardNew/shopList", admJson); + break; + case '绑定': + url = `${domain}/dm/front/openCardNew/complete/mission?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"missionType": "relationBind", "inviterNick":($.inviteNick || "")} + body = taskPostUrl("/openCardNew/complete/mission", admJson); + break; + case 'mission': + url = `${domain}/dm/front/openCardNew/complete/mission?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"missionType": $.missionType} + if($.joinVenderId) admJson = {...admJson, "shopId": $.joinVenderId} + body = taskPostUrl("/openCardNew/complete/mission", admJson); + break; + case '抽奖': + url = `${domain}/dm/front/openCardNew/draw/post?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"dataType": "draw", "usedGameNum": "2"} + body = taskPostUrl("/openCardNew/draw/post", admJson); + break; + case 'followShop': + url = `${domain}/dm/front/openCardNew/followShop?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"actId": $.actId, "missionType": "collectShop"} + body = taskPostUrl("/openCardNew/followShop", admJson); + break; + case 'addCart': + url = `${domain}/dm/front/openCardNew/addCart?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"actId": $.actId, "missionType": "addCart"} + body = taskPostUrl("/openCardNew/addCart", admJson); + break; + case 'myAward': + url = `${domain}/dm/front/openCardNew/myAwards?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"pageNo": 1,"pageSize":9999} + body = taskPostUrl("/openCardNew/myAwards", admJson); + break; + case 'missionInviteList': + url = `${domain}/dm/front/openCardNew/missionInviteList?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"inviteListRequest":{"actId":$.actId,"userId":10299171,"missionType":"shareAct","inviteType": 1,"buyerNick":($.MixNick || '')}} + body = taskPostUrl("/openCardNew/missionInviteList", admJson); + break; + default: + console.log(`错误${type}`); + } + let myRequest = getPostRequest(url, body, method); + return new Promise(async resolve => { + $.post(myRequest, (err, resp, data) => { + try { + if (err) { + if(resp && resp.statusCode && resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + console.log(`${$.toStr(err,err)}`) + console.log(`${type} API请求失败,请检查网路重试`) + } else { + dealReturn(type, data); + } + } catch (e) { + // console.log(data); + console.log(e, resp) + } finally { + resolve(); + } + }) + }) + } + +async function dealReturn(type, data) { + let res = '' + try { + if(type != 'accessLogWithAD' || type != 'drawContent'){ + if(data){ + res = JSON.parse(data); + } + } + } catch (e) { + console.log(`${type} 执行任务异常`); + console.log(data); + $.runFalag = false; + } + try { + let title = '' + switch (type) { + case 'isvObfuscator': + if(typeof res == 'object'){ + if(res.errcode == 0){ + if(typeof res.token != 'undefined') $.Token = res.token + }else if(res.message){ + console.log(`${type} ${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + break; + case 'accessLogWithAD': + case 'drawContent': + break; + case 'activity_load': + case 'mission': + case 'shopList': + case 'loadUniteOpenCard': + case 'setMixNick': + case 'uniteOpenCardOne': + case 'checkOpenCard': + case 'followShop': + case 'addCart': + case 'myAward': + case 'missionInviteList': + case '抽奖': + title = '' + if(type == "followShop") title = '关注' + if(type == "addCart") title = '加购' + if(typeof res == 'object'){ + if(res.success && res.success === true && res.data){ + if(res.data.status && res.data.status == 200){ + res = res.data + if(type != "setMixNick" && (res.msg || res.data.isOpenCard || res.data.remark)) console.log(`${title && title+":" || ""}${res.msg || res.data.isOpenCard || res.data.remark || ''}`) + if(type == "activity_load"){ + if(res.msg || res.data.isOpenCard) { + if((res.msg || res.data.isOpenCard || '').indexOf('绑定成功') > -1) $.toBind = 1 + } + if(res.data){ + $.endTime = res.data.cusActivity.endTime || 0 + $.MixNick = res.data.buyerNick || "" + $.usedChance = res.data.missionCustomer.usedChance || 0 + $.hasCollectShop = res.data.missionCustomer.hasCollectShop || 0 + } + }else if(type == "shopList"){ + $.openList = res.data.cusShops || [] + }else if(type == "mission"){ + if(res.data.remark.indexOf('不是会员') > -1){ + $.openCard = true + }else{ + $.openCard = false + } + }else if(type == "uniteOpenCardOne"){ + $.uniteOpenCar = res.msg || res.data.msg || '' + }else if(type == "myAward"){ + console.log(`我的奖品:`) + let num = 0 + let value = 0 + for(let i in res.data.list || []){ + let item = res.data.list[i] + value += Number(item.awardDes) + } + if(value > 0) console.log(`共获得${value}京豆\n无法判断奖励是否为邀请奖励,所以直接显示获得多少豆\n`) + }else if(type == "missionInviteList"){ + console.log(`邀请人数(${res.data.invitedLogList.total})`) + } + }else if(res.data.msg){ + if(res.errorMessage.indexOf('活动未开始') >-1 ){ + $.activityEnd = true + } + console.log(`${title || type} ${res.data.msg || ''}`) + }else if(res.errorMessage){ + if(res.errorMessage.indexOf('火爆') >-1 ){ + $.hotFlag = true + } + console.log(`${title || type} ${res.errorMessage || ''}`) + }else{ + console.log(`${title || type} ${data}`) + } + }else if(res.errorMessage){ + console.log(`${title || type} ${res.errorMessage || ''}`) + }else{ + console.log(`${title || type} ${data}`) + } + }else{ + console.log(`${title || type} ${data}`) + } + break; + default: + console.log(`${title || type}-> ${data}`); + } + if(typeof res == 'object'){ + if(res.errorMessage){ + if(res.errorMessage.indexOf('火爆') >-1 ){ + $.hotFlag = true + } + } + } + } catch (e) { + console.log(e) + } +} + +function getPostRequest(url, body, method="POST") { + let headers = { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Content-Type": "application/x-www-form-urlencoded", + "Cookie": cookie, + "User-Agent": $.UA, + "X-Requested-With": "XMLHttpRequest" + } + if(url.indexOf('https://jinggengjcq-isv.isvjcloud.com') > -1){ + headers["Origin"] = `https://jinggengjcq-isv.isvjcloud.com` + headers["Content-Type"] = `application/json; charset=utf-8` + delete headers["Cookie"] + } + // console.log(headers) + // console.log(headers.Cookie) + return {url: url, method: method, headers: headers, body: body, timeout:60000}; +} + + +function taskPostUrl(url, t) { + + const b = { + "jsonRpc": "2.0", + "params": { + "commonParameter": { + "appkey": $.appkey, + "m": "POST", + "timestamp": Date.now(), + "userId": $.userId + }, + "admJson": { + "actId": $.actId, + "userId": $.userId, + ...t, + "method": url, + "buyerNick": ($.MixNick || ''), + } + }, + } + if(url.indexOf('missionInviteList') > -1){ + delete b.params.admJson.actId + } + return $.toStr(b,b) +} +async function getUA(){ + $.UA = `jdapp;iPhone;10.1.4;13.1.2;${randomString(40)};network/wifi;model/iPhone8,1;addressid/2308460611;appBuild/167814;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_1_2 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 jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} + +function joinShop() { + if(!$.joinVenderId) return + return new Promise(async resolve => { + $.shopactivityId = '' + await $.wait(1000) + await getshopactivityId() + let activityId = `` + if($.shopactivityId) activityId = `,"activityId":${$.shopactivityId}` + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body={"venderId":"${$.joinVenderId}","shopId":"${$.joinVenderId}","bindByVerifyCodeFlag":1,"registerExtend":{},"writeChildFlag":0${activityId},"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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + // console.log(data) + let res = $.toObj(data,data); + if(typeof res == 'object'){ + if(res.success === true){ + console.log(res.message) + if(res.result && res.result.giftInfo){ + for(let i of res.result.giftInfo.giftList){ + console.log(`入会获得:${i.discountString}${i.prizeName}${i.secondLineDesc}`) + } + } + }else if(typeof res == 'object' && res.message){ + console.log(`${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function getshopactivityId() { + return new Promise(resolve => { + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body=%7B%22venderId%22%3A%22${$.joinVenderId}%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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + let res = $.toObj(data,data); + if(typeof res == 'object'){ + if(res.success == true){ + // console.log($.toStr(res.result)) + console.log(`入会:${res.result.shopMemberCardInfo.venderCardName || ''}`) + $.shopactivityId = res.result.interestsRuleList && res.result.interestsRuleList[0] && res.result.interestsRuleList[0].interestsInfo && res.result.interestsRuleList[0].interestsInfo.activityId || '' + } + }else{ + console.log(data) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +// 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)} + diff --git a/activity/jd_opencardL65.js b/activity/jd_opencardL65.js new file mode 100644 index 0000000..e3d4cac --- /dev/null +++ b/activity/jd_opencardL65.js @@ -0,0 +1,544 @@ +/* +1.26~2.2 联合开卡 +新增开卡脚本,一次性脚本 + +第一个账号助力作者 其他依次助力CK1 +第一个CK失效会退出脚本 + +———————————————— +入口:[ 1.26~2.2 联合开卡 ()] + +请求太频繁会被黑ip +过10分钟再执行 + + +cron:10 0,12 27-31,1-2 1,2 * +============Quantumultx=============== +[task_local] +#1.26~2.2 联合开卡 +10 0,12 27-31,1-2 1,2 * jd_opencardL65.js, tag=1.26~2.2 联合开卡, enabled=true + +*/ + +const $ = new Env('1.26~2.2 联合开卡'); +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const notify = $.isNode() ? require('./sendNotify') : ''; + +//IOS等用户直接用NobyDa的jd cookie +let cookiesArr = [], + cookie = ''; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} + +allMessage = "" +message = "" +$.hotFlag = false +$.outFlag = false +$.activityEnd = false +let lz_jdpin_token_cookie ='' +let activityCookie ='' +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', { + "open-url": "https://bean.m.jd.com/" + }); + return; + } + // return + $.appkey = '51B59BB805903DA4CE513D29EC448375' + $.userId = '10299171' + $.actId = '06b95e48198044_220126' + $.MixNicks = '' + $.inviteNick = 'k1Nobb+P0er+C2sysxnx/P2KELO9izRVpwCyqu0eqVZ5aW7RHzlMobrzJ/e9r/uf' + console.log(`活动地址:`) + console.log(`请自行测试有水无水。`) + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i]; + if (cookie) { + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + message = "" + $.bean = 0 + $.hotFlag = false + $.nickName = ''; + console.log(`\n\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + await getUA() + await run(); + if(i == 0 && !$.MixNick) break + if($.outFlag || $.activityEnd) break + } + } + if($.outFlag) { + let msg = '此ip已被限制,请过10分钟后再执行脚本' + $.msg($.name, ``, `${msg}`); + if ($.isNode()) await notify.sendNotify(`${$.name}`, `${msg}`); + } +})() + .catch((e) => $.logErr(e)) + .finally(() => $.done()) + + +async function run() { + try { + $.hasEnd = true + $.endTime = 0 + lz_jdpin_token_cookie = '' + $.Token = '' + $.Pin = '' + $.MixNick = '' + let flag = false + if($.activityEnd) return + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + await takePostRequest('isvObfuscator'); + if($.Token == ''){ + console.log('获取[token]失败!') + return + } + await takePostRequest('activity_load'); + if($.hotFlag) return + if(Date.now() > $.endTime){ + $.MixNick = '' + $.activityEnd = true + console.log('活动结束') + return + } + if ($.MixNick == '') { + console.log(`获取cookie失败`); return; + } + // console.log($.MixNick) + // return + $.toBind = 0 + $.openList = [] + await takePostRequest('绑定'); + await takePostRequest('shopList'); + if($.activityEnd) return + for(o of $.openList){ + $.missionType = 'openCard' + if(o.open != true && o.openCardUrl){ + if($.activityEnd) return + $.openCard = false + $.joinVenderId = o.userId + await takePostRequest('mission'); + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + if($.openCard == true){ + await joinShop() + await takePostRequest('activity_load'); + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + // break + } + $.joinVenderId = '' + } + } + $.joinVenderId = '' + if($.hasCollectShop === 0){ + // 关注 + $.missionType = 'uniteCollectShop' + await takePostRequest('mission'); + await $.wait(parseInt(Math.random() * 2000 + 3000, 10)) + }else{ + console.log('已经关注') + } + $.missionType = 'uniteAddCart' + + await takePostRequest('mission'); + await $.wait(parseInt(Math.random() * 2000 + 3000, 10)) + await takePostRequest('activity_load'); + $.runFalag = true + let count = parseInt($.usedChance, 10) + console.log(`抽奖次数为:${count}`) + for(m=1;count--;m++){ + console.log(`第${m}次抽奖`) + await takePostRequest('抽奖'); + if($.runFalag == false) break + if(Number(count) <= 0) break + if(m >= 10){ + console.log("抽奖太多次,多余的次数请再执行脚本") + break + } + await $.wait(parseInt(Math.random() * 2000 + 2000, 10)) + } + await takePostRequest('myAward'); + await takePostRequest('missionInviteList'); + console.log($.MixNick) + console.log(`当前助力:${$.inviteNick}`) + if($.index == 1){ + $.inviteNick = $.MixNick + console.log(`后面的号都会助力:${$.inviteNick}`) + } + await $.wait(parseInt(Math.random() * 1000 + 5000, 10)) + } catch (e) { + console.log(e) + } +} + +async function takePostRequest(type) { + if($.outFlag) return + let domain = 'https://jinggengjcq-isv.isvjcloud.com'; + let body = ``; + let method = 'POST' + let admJson = '' + switch (type) { + case 'isvObfuscator': + url = `https://api.m.jd.com/client.action?functionId=isvObfuscator`; + body = `body=%7B%22url%22%3A%22https%3A//jinggengjcq-isv.isvjcloud.com/fronth5/%3Flng%3D0%26lat%3D0%26sid%3D49687cd64aca2ae93aa43748a04e8f6w%26un_area%3D16_1315_1316_53522%23/pages/unitedCardNew20211010-ka/unitedCardNew20211010-ka%3FactId%3D9150e1d16b9d40_10101%22%2C%22id%22%3A%22%22%7D&uuid=b9b4ce69d42dacb64084279d51cdee764d7781fa&client=apple&clientVersion=10.1.4&st=1634100732991&sv=111&sign=67e254ffbcb13be9e12a9782c9cdf398`; + break; + case 'activity_load': + url = `${domain}/dm/front/openCardNew/activity_load?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"jdToken": $.Token, "source": "01", "inviteNick":($.inviteNick || "")} + if($.joinVenderId) admJson = {...admJson, "shopId": `${$.joinVenderId}`} + body = taskPostUrl("/openCardNew/activity_load", admJson); + break; + case 'shopList': + url = `${domain}/dm/front/openCardNew/shopList?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {} + body = taskPostUrl("/openCardNew/shopList", admJson); + break; + case '绑定': + url = `${domain}/dm/front/openCardNew/complete/mission?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"missionType": "relationBind", "inviterNick":($.inviteNick || "")} + body = taskPostUrl("/openCardNew/complete/mission", admJson); + break; + case 'mission': + url = `${domain}/dm/front/openCardNew/complete/mission?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"missionType": $.missionType} + if($.joinVenderId) admJson = {...admJson, "shopId": $.joinVenderId} + body = taskPostUrl("/openCardNew/complete/mission", admJson); + break; + case '抽奖': + url = `${domain}/dm/front/openCardNew/draw/post?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"dataType": "draw", "usedGameNum": "2"} + body = taskPostUrl("/openCardNew/draw/post", admJson); + break; + case 'followShop': + url = `${domain}/dm/front/openCardNew/followShop?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"actId": $.actId, "missionType": "collectShop"} + body = taskPostUrl("/openCardNew/followShop", admJson); + break; + case 'addCart': + url = `${domain}/dm/front/openCardNew/addCart?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"actId": $.actId, "missionType": "addCart"} + body = taskPostUrl("/openCardNew/addCart", admJson); + break; + case 'myAward': + url = `${domain}/dm/front/openCardNew/myAwards?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"pageNo": 1,"pageSize":9999} + body = taskPostUrl("/openCardNew/myAwards", admJson); + break; + case 'missionInviteList': + url = `${domain}/dm/front/openCardNew/missionInviteList?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"inviteListRequest":{"actId":$.actId,"userId":10299171,"missionType":"shareAct","inviteType": 1,"buyerNick":($.MixNick || '')}} + body = taskPostUrl("/openCardNew/missionInviteList", admJson); + break; + default: + console.log(`错误${type}`); + } + let myRequest = getPostRequest(url, body, method); + return new Promise(async resolve => { + $.post(myRequest, (err, resp, data) => { + try { + if (err) { + if(resp && resp.statusCode && resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + console.log(`${$.toStr(err,err)}`) + console.log(`${type} API请求失败,请检查网路重试`) + } else { + dealReturn(type, data); + } + } catch (e) { + // console.log(data); + console.log(e, resp) + } finally { + resolve(); + } + }) + }) + } + +async function dealReturn(type, data) { + let res = '' + try { + if(type != 'accessLogWithAD' || type != 'drawContent'){ + if(data){ + res = JSON.parse(data); + } + } + } catch (e) { + console.log(`${type} 执行任务异常`); + console.log(data); + $.runFalag = false; + } + try { + let title = '' + switch (type) { + case 'isvObfuscator': + if(typeof res == 'object'){ + if(res.errcode == 0){ + if(typeof res.token != 'undefined') $.Token = res.token + }else if(res.message){ + console.log(`${type} ${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + break; + case 'accessLogWithAD': + case 'drawContent': + break; + case 'activity_load': + case 'mission': + case 'shopList': + case 'loadUniteOpenCard': + case 'setMixNick': + case 'uniteOpenCardOne': + case 'checkOpenCard': + case 'followShop': + case 'addCart': + case 'myAward': + case 'missionInviteList': + case '抽奖': + title = '' + if(type == "followShop") title = '关注' + if(type == "addCart") title = '加购' + if(typeof res == 'object'){ + if(res.success && res.success === true && res.data){ + if(res.data.status && res.data.status == 200){ + res = res.data + if(type != "setMixNick" && (res.msg || res.data.isOpenCard || res.data.remark)) console.log(`${title && title+":" || ""}${res.msg || res.data.isOpenCard || res.data.remark || ''}`) + if(type == "activity_load"){ + if(res.msg || res.data.isOpenCard) { + if((res.msg || res.data.isOpenCard || '').indexOf('绑定成功') > -1) $.toBind = 1 + } + if(res.data){ + $.endTime = res.data.cusActivity.endTime || 0 + $.MixNick = res.data.buyerNick || "" + $.usedChance = res.data.missionCustomer.usedChance || 0 + $.hasCollectShop = res.data.missionCustomer.hasCollectShop || 0 + } + }else if(type == "shopList"){ + $.openList = res.data.cusShops || [] + }else if(type == "mission"){ + if(res.data.remark.indexOf('不是会员') > -1){ + $.openCard = true + }else{ + $.openCard = false + } + }else if(type == "uniteOpenCardOne"){ + $.uniteOpenCar = res.msg || res.data.msg || '' + }else if(type == "myAward"){ + console.log(`我的奖品:`) + let num = 0 + let value = 0 + for(let i in res.data.list || []){ + let item = res.data.list[i] + value += Number(item.awardDes) + } + if(value > 0) console.log(`共获得${value}京豆\n无法判断奖励是否为邀请奖励,所以直接显示获得多少豆\n`) + }else if(type == "missionInviteList"){ + console.log(`邀请人数(${res.data.invitedLogList.total})`) + } + }else if(res.data.msg){ + if(res.errorMessage.indexOf('活动未开始') >-1 ){ + $.activityEnd = true + } + console.log(`${title || type} ${res.data.msg || ''}`) + }else if(res.errorMessage){ + if(res.errorMessage.indexOf('火爆') >-1 ){ + $.hotFlag = true + } + console.log(`${title || type} ${res.errorMessage || ''}`) + }else{ + console.log(`${title || type} ${data}`) + } + }else if(res.errorMessage){ + console.log(`${title || type} ${res.errorMessage || ''}`) + }else{ + console.log(`${title || type} ${data}`) + } + }else{ + console.log(`${title || type} ${data}`) + } + break; + default: + console.log(`${title || type}-> ${data}`); + } + if(typeof res == 'object'){ + if(res.errorMessage){ + if(res.errorMessage.indexOf('火爆') >-1 ){ + $.hotFlag = true + } + } + } + } catch (e) { + console.log(e) + } +} + +function getPostRequest(url, body, method="POST") { + let headers = { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Content-Type": "application/x-www-form-urlencoded", + "Cookie": cookie, + "User-Agent": $.UA, + "X-Requested-With": "XMLHttpRequest" + } + if(url.indexOf('https://jinggengjcq-isv.isvjcloud.com') > -1){ + headers["Origin"] = `https://jinggengjcq-isv.isvjcloud.com` + headers["Content-Type"] = `application/json; charset=utf-8` + delete headers["Cookie"] + } + // console.log(headers) + // console.log(headers.Cookie) + return {url: url, method: method, headers: headers, body: body, timeout:60000}; +} + + +function taskPostUrl(url, t) { + + const b = { + "jsonRpc": "2.0", + "params": { + "commonParameter": { + "appkey": $.appkey, + "m": "POST", + "timestamp": Date.now(), + "userId": $.userId + }, + "admJson": { + "actId": $.actId, + "userId": $.userId, + ...t, + "method": url, + "buyerNick": ($.MixNick || ''), + } + }, + } + if(url.indexOf('missionInviteList') > -1){ + delete b.params.admJson.actId + } + return $.toStr(b,b) +} +async function getUA(){ + $.UA = `jdapp;iPhone;10.1.4;13.1.2;${randomString(40)};network/wifi;model/iPhone8,1;addressid/2308460611;appBuild/167814;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_1_2 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 jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} + +function joinShop() { + if(!$.joinVenderId) return + return new Promise(async resolve => { + $.shopactivityId = '' + await $.wait(1000) + await getshopactivityId() + let activityId = `` + if($.shopactivityId) activityId = `,"activityId":${$.shopactivityId}` + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body={"venderId":"${$.joinVenderId}","shopId":"${$.joinVenderId}","bindByVerifyCodeFlag":1,"registerExtend":{},"writeChildFlag":0${activityId},"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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + // console.log(data) + let res = $.toObj(data,data); + if(typeof res == 'object'){ + if(res.success === true){ + console.log(res.message) + if(res.result && res.result.giftInfo){ + for(let i of res.result.giftInfo.giftList){ + console.log(`入会获得:${i.discountString}${i.prizeName}${i.secondLineDesc}`) + } + } + }else if(typeof res == 'object' && res.message){ + console.log(`${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function getshopactivityId() { + return new Promise(resolve => { + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body=%7B%22venderId%22%3A%22${$.joinVenderId}%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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + let res = $.toObj(data,data); + if(typeof res == 'object'){ + if(res.success == true){ + // console.log($.toStr(res.result)) + console.log(`入会:${res.result.shopMemberCardInfo.venderCardName || ''}`) + $.shopactivityId = res.result.interestsRuleList && res.result.interestsRuleList[0] && res.result.interestsRuleList[0].interestsInfo && res.result.interestsRuleList[0].interestsInfo.activityId || '' + } + }else{ + console.log(data) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +// 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)} + diff --git a/activity/jd_opencardL66.js b/activity/jd_opencardL66.js new file mode 100644 index 0000000..531c3c3 --- /dev/null +++ b/activity/jd_opencardL66.js @@ -0,0 +1,704 @@ +/* +1.29~2.15 京东粉丝联盟福利社 入会赢专享好礼 +新增开卡脚本,一次性脚本 + + +第一个账号助力作者 其他依次助力CK1 +第一个CK失效会退出脚本 + +———————————————— +入口:[ 1.29~2.15 京东粉丝联盟福利社 入会赢专享好礼 (https://lzdz1-isv.isvjcloud.com/dingzhi/shop/league/activity?activityId=dz220107100001616201shop&shareUuid=488be07602b444ba9b2b4825aec09d81)] + +请求太频繁会被黑ip +过10分钟再执行 + +cron:30 1,14 29-31,1-15 1,2 * +============Quantumultx=============== +[task_local] +#1.29~2.15 京东粉丝联盟福利社 入会赢专享好礼 +30 1,14 29-31,1-15 1,2 * jd_opencardL66.js, tag=1.29~2.15 京东粉丝联盟福利社 入会赢专享好礼, enabled=true + +*/ +const $ = new Env('1.29~2.15 京东粉丝联盟福利社 入会赢专享好礼'); +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const notify = $.isNode() ? require('./sendNotify') : ''; +//IOS等用户直接用NobyDa的jd cookie + +let cookiesArr = [], + cookie = ''; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} +allMessage = "" +message = "" +$.hotFlag = false +$.outFlag = false +$.activityEnd = false +let lz_jdpin_token_cookie ='' +let activityCookie ='' +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', { + "open-url": "https://bean.m.jd.com/" + }); + return; + } + $.activityId = "dz220208100001616201shop" + $.shareUuid = "3f64a3a527fc4419bf64bea33fdcab4d" + console.log(`入口:\nhttps://lzdz1-isv.isvjcloud.com/dingzhi/shop/league/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}`) + + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i]; + if (cookie) { + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + message = "" + $.bean = 0 + $.hotFlag = false + $.nickName = ''; + console.log(`\n\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + await getUA() + await run(); + if(i == 0 && !$.actorUuid) break + if($.outFlag || $.activityEnd) break + } + } + if($.outFlag) { + let msg = '此ip已被限制,请过10分钟后再执行脚本' + $.msg($.name, ``, `${msg}`); + if ($.isNode()) await notify.sendNotify(`${$.name}`, `${msg}`); + } +})() + .catch((e) => $.logErr(e)) + .finally(() => $.done()) + + +async function run() { + try { + $.hasEnd = true + $.endTime = 0 + lz_jdpin_token_cookie = '' + $.Token = '' + $.Pin = '' + let flag = false + await takePostRequest('isvObfuscator'); + if($.Token == ''){ + console.log('获取[token]失败!') + return + } + await getCk() + if (activityCookie == '') { + console.log(`获取cookie失败`); return; + } + if($.activityEnd === true){ + console.log('活动结束') + return + } + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + await takePostRequest('getSimpleActInfoVo'); + await takePostRequest('getMyPing'); + if(!$.Pin){ + console.log('获取[Pin]失败!') + return + } + await takePostRequest('accessLogWithAD'); + await takePostRequest('getUserInfo'); + await takePostRequest('activityContent'); + if($.hotFlag) return + if(!$.actorUuid){ + console.log('获取不到[actorUuid]退出执行,请重新执行') + return + } + if($.hasEnd === true || Date.now() > $.endTime){ + $.activityEnd = true + console.log('活动结束') + return + } + await takePostRequest('drawContent'); + await $.wait(1000) + $.openList = [] + $.allOpenCard = false + await takePostRequest('checkOpenCard'); + // console.log($.actorUuid) + // return + if($.allOpenCard == false){ + console.log('开卡任务') + for(o of $.openList){ + $.openCard = false + if(o.status == 0){ + flag = true + $.joinVenderId = o.value + await joinShop() + await $.wait(parseInt(Math.random() * 2000 + 3000, 10)) + await takePostRequest('drawContent'); + await takePostRequest('checkOpenCard'); + await $.wait(parseInt(Math.random() * 3000 + 2000, 10)) + } + } + await takePostRequest('activityContent'); + }else{ + console.log('已全部开卡') + } + $.log("关注: " + $.followShop) + if(!$.followShop && !$.outFlag){ + flag = true + $.followShopValue = 1 + await takePostRequest('followShop'); + await $.wait(parseInt(Math.random() * 1000 + 5000, 10)) + } + $.log("加购: " + $.addSku) + if(!$.addSku && !$.outFlag){ + flag = true + $.followShopValue = 2 + await takePostRequest('addSku'); + await $.wait(parseInt(Math.random() * 1000 + 5000, 10)) + } + $.runFalag = true + if(flag){ + await takePostRequest('activityContent'); + } + await $.wait(parseInt(Math.random() * 1000 + 2000, 10)) + await takePostRequest('getDrawRecordHasCoupon'); + await takePostRequest('getShareRecord'); + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + console.log($.actorUuid) + console.log(`当前助力:${$.shareUuid}`) + if($.index == 1){ + $.shareUuid = $.actorUuid + console.log(`后面的号都会助力:${$.shareUuid}`) + } + await $.wait(parseInt(Math.random() * 1000 + 5000, 10)) + if(flag) await $.wait(parseInt(Math.random() * 1000 + 10000, 10)) + if($.index % 3 == 0) console.log('休息1分钟,别被黑ip了\n可持续发展') + if($.index % 3 == 0) await $.wait(parseInt(Math.random() * 5000 + 60000, 10)) + } catch (e) { + console.log(e) + } +} + +async function takePostRequest(type) { + if($.outFlag) return + let domain = 'https://lzdz1-isv.isvjcloud.com'; + let body = ``; + let method = 'POST' + let admJson = '' + switch (type) { + case 'isvObfuscator': + url = `https://api.m.jd.com/client.action?functionId=isvObfuscator`; + body = `body=%7B%22url%22%3A%22https%3A//lzdz1-isv.isvjcloud.com%22%2C%22id%22%3A%22%22%7D&uuid=0846724fe8d803b8e84ebd14b3ba7fac6df80e7a&client=apple&clientVersion=10.1.4&st=1634616247215&sv=120&sign=91a16ae2feb0bd0e1ea48d99e7953c58`; + break; + case 'getSimpleActInfoVo': + url = `${domain}/dz/common/getSimpleActInfoVo`; + body = `activityId=${$.activityId}`; + break; + case 'getMyPing': + url = `${domain}/customer/getMyPing`; + body = `userId=${$.shopId || $.venderId || ''}&token=${$.Token}&fromType=APP`; + break; + case 'accessLogWithAD': + url = `${domain}/common/accessLogWithAD`; + let pageurl = `${domain}/drawCenter/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}` + body = `venderId=${$.shopId || $.venderId || ''}&code=99&pin=${encodeURIComponent($.Pin)}&activityId=${$.activityId}&pageUrl=${encodeURIComponent(pageurl)}&subType=app&adSource=` + break; + case 'getUserInfo': + url = `${domain}/wxActionCommon/getUserInfo`; + body = `pin=${encodeURIComponent($.Pin)}`; + break; + case 'activityContent': + url = `${domain}/dingzhi/shop/league/activityContent`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&pinImg=${encodeURIComponent($.attrTouXiang)}&nick=${encodeURIComponent($.nickname)}&cjyxPin=&cjhyPin=&shareUuid=${$.shareUuid}` + break; + case 'drawContent': + url = `${domain}/dingzhi/taskact/openCardcommon/drawContent`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case 'checkOpenCard': + url = `${domain}/dingzhi/shop/league/checkOpenCard`; + body = `activityId=${$.activityId}&actorUuid=${$.actorUuid}&pin=${encodeURIComponent($.Pin)}&shareUuid=${$.shareUuid}` + break; + case 'startDraw': + url = `${domain}/dingzhi/shop/league/startDraw`; + body = `activityId=${$.activityId}&actorUuid=${$.actorUuid}&pin=${encodeURIComponent($.Pin)}${$.startDraw && '&type='+$.startDraw || ''}` + break; + case 'followShop': + url = `${domain}/dingzhi/shop/league/saveTask`; + // url = `${domain}/dingzhi/dz/openCard/saveTask`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&shareUuid=${$.shareUuid}&taskType=1&taskValue=${$.followShopValue}` + break; + case 'viewVideo': + case 'visitSku': + case 'toShop': + case 'addSku': + url = `${domain}/dingzhi/shop/league/saveTask`; + let taskType = '' + let taskValue = '' + if(type == 'viewVideo'){ + taskType = 31 + taskValue = 31 + }else if(type == 'visitSku'){ + taskType = 5 + taskValue = $.visitSkuValue || 5 + }else if(type == 'toShop'){ + taskType = 14 + taskValue = $.toShopValue || 14 + }else if(type == 'addSku'){ + taskType = 2 + taskValue = $.addSkuValue || 2 + } + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&taskType=${taskType}&taskValue=${taskValue}` + break; + case 'getDrawRecordHasCoupon': + url = `${domain}/dingzhi/taskact/common/getDrawRecordHasCoupon`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case 'getShareRecord': + url = `${domain}/dingzhi/taskact/common/getShareRecord`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + default: + console.log(`错误${type}`); + } + let myRequest = getPostRequest(url, body, method); + // console.log(myRequest) + return new Promise(async resolve => { + $.post(myRequest, (err, resp, data) => { + try { + setActivityCookie(resp) + if (err) { + if(resp && typeof resp.statusCode != 'undefined'){ + if(resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + } + console.log(`${$.toStr(err,err)}`) + console.log(`${type} API请求失败,请检查网路重试`) + } else { + dealReturn(type, data); + } + } catch (e) { + // console.log(data); + console.log(e, resp) + } finally { + resolve(); + } + }) + }) + } + +async function dealReturn(type, data) { + let res = '' + try { + if(type != 'accessLogWithAD' || type != 'drawContent'){ + if(data){ + res = JSON.parse(data); + } + } + } catch (e) { + console.log(`${type} 执行任务异常`); + console.log(data); + $.runFalag = false; + } + try { + switch (type) { + case 'isvObfuscator': + if(typeof res == 'object'){ + if(res.errcode == 0){ + if(typeof res.token != 'undefined') $.Token = res.token + }else if(res.message){ + console.log(`isvObfuscator ${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + break; + case 'getSimpleActInfoVo': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(typeof res.data.shopId != 'undefined') $.shopId = res.data.shopId + if(typeof res.data.venderId != 'undefined') $.venderId = res.data.venderId + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getMyPing': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(res.data && typeof res.data.secretPin != 'undefined') $.Pin = res.data.secretPin + if(res.data && typeof res.data.nickname != 'undefined') $.nickname = res.data.nickname + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getUserInfo': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(res.data && typeof res.data.yunMidImageUrl != 'undefined') $.attrTouXiang = res.data.yunMidImageUrl || "https://img10.360buyimg.com/imgzone/jfs/t1/7020/27/13511/6142/5c5138d8E4df2e764/5a1216a3a5043c5d.png" + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'activityContent': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + $.endTime = res.data.endTime || 0 + $.hasEnd = res.data.hasEnd || false + $.actorUuid = res.data.actorUuid || '' + $.followShop = res.data.followShop.allStatus || false + $.addSku = res.data.addSku.allStatus || false + if(res.data.followShop && res.data.followShop.settings && res.data.followShop.settings[0]){ + $.followShopValue = res.data.followShop.settings[0].value || 1 + } + if(res.data.addSku && res.data.addSku.settings && res.data.addSku.settings[0]){ + $.addSkuValue = res.data.addSku.settings[0].value || 2 + } + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'checkOpenCard': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + let cardList1 = res.data.cardList1 || [] + let cardList2 = res.data.cardList2 || [] + let cardList = res.data.cardList || [] + $.openList = [...cardList,...cardList1,...cardList2] + $.allOpenCard = res.data.allOpenCard || false + $.openCardScore1 = res.data.score1 || res.data.drawScore1 || 0 + $.openCardScore2 = res.data.score2 || res.data.drawScore2 || 0 + $.openCardScore3 = res.data.score3 || res.data.drawScore3 || 0 + $.drawScore = res.data.drawScore || 0 + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'startDraw': + case 'followShop': + case 'viewVideo': + case 'visitSku': + case 'toShop': + case 'addSku': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(typeof res.data == 'object'){ + let msg = '' + let title = '抽奖' + if(res.data.addBeanNum && res.data.sendStatus){ + msg = `${res.data.addBeanNum}京豆` + } + if(type == 'followShop'){ + title = '关注' + if(res.data.beanNumMember && res.data.assistSendStatus){ + msg += ` 额外获得:${res.data.beanNumMember}京豆` + } + }else if(type == 'addSku'){ + title = '加购' + }else if(type == 'viewVideo'){ + title = '热门文章' + }else if(type == 'toShop'){ + title = '浏览店铺' + }else if(type == 'visitSku'){ + title = '浏览商品' + }else{ + msg = res.data.drawOk == true && (res.data.drawInfoType == 6 && res.data.name || '') || '空气💨' + } + if(!msg){ + msg = '空气💨' + } + console.log(`${title}获得:${msg || data}`) + }else{ + console.log(`${type} ${data}`) + } + }else if(res.errorMessage){ + $.runFalag = false; + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getDrawRecordHasCoupon': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + console.log(`我的奖品:`) + let num = 0 + let value = 0 + for(let i in res.data){ + let item = res.data[i] + if(item.value == '邀请好友') num++; + if(item.value == '邀请好友') value = item.infoName.replace('京豆',''); + if(item.value != '邀请好友') console.log(`${item.infoType != 10 && item.value +':' || ''}${item.infoName}`) + } + if(num > 0) console.log(`邀请好友(${num}):${num*parseInt(value, 10) || 30}京豆`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getShareRecord': + if(typeof res == 'object'){ + if(res.result && res.result === true && res.data){ + $.ShareCount = res.data.length + $.log(`=========== 你邀请了:${res.data.length}个`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'accessLogWithAD': + case 'drawContent': + break; + default: + console.log(`${type}-> ${data}`); + } + if(typeof res == 'object'){ + if(res.errorMessage){ + if(res.errorMessage.indexOf('火爆') >-1 ){ + $.hotFlag = true + } + } + } + } catch (e) { + console.log(e) + } +} + +function getPostRequest(url, body, method="POST") { + let headers = { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Content-Type": "application/x-www-form-urlencoded", + "Cookie": cookie, + "User-Agent": $.UA, + "X-Requested-With": "XMLHttpRequest" + } + if(url.indexOf('https://lzdz1-isv.isvjcloud.com') > -1){ + headers["Referer"] = `https://lzdz1-isv.isvjcloud.com/dingzhi/shop/league/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}` + headers["Cookie"] = `${lz_jdpin_token_cookie && lz_jdpin_token_cookie || ''}${$.Pin && "AUTH_C_USER=" + $.Pin + ";" || ""}${activityCookie}` + } + // console.log(headers) + // console.log(headers.Cookie) + return {url: url, method: method, headers: headers, body: body, timeout:30000}; +} + +function getCk() { + return new Promise(resolve => { + let get = { + url:`https://lzdz1-isv.isvjcloud.com/dingzhi/shop/league/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}`, + followRedirect:false, + headers: { + "User-Agent": $.UA, + }, + timeout:30000 + } + $.get(get, async(err, resp, data) => { + try { + if (err) { + if(resp && typeof resp.statusCode != 'undefined'){ + if(resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + } + console.log(`${$.toStr(err)}`) + console.log(`${$.name} cookie API请求失败,请检查网路重试`) + } else { + let end = data.match(/(活动已经结束)/) && data.match(/(活动已经结束)/)[1] || '' + if(end){ + $.activityEnd = true + console.log('活动已结束') + } + setActivityCookie(resp) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function setActivityCookie(resp){ + let LZ_TOKEN_KEY = '' + let LZ_TOKEN_VALUE = '' + let lz_jdpin_token = '' + let setcookies = resp && resp['headers'] && (resp['headers']['set-cookie'] || resp['headers']['Set-Cookie'] || '') || '' + let setcookie = '' + if(setcookies){ + if(typeof setcookies != 'object'){ + setcookie = setcookies.split(',') + }else setcookie = setcookies + for (let ck of setcookie) { + let name = ck.split(";")[0].trim() + if(name.split("=")[1]){ + // console.log(name.replace(/ /g,'')) + if(name.indexOf('LZ_TOKEN_KEY=')>-1) LZ_TOKEN_KEY = name.replace(/ /g,'')+';' + if(name.indexOf('LZ_TOKEN_VALUE=')>-1) LZ_TOKEN_VALUE = name.replace(/ /g,'')+';' + if(name.indexOf('lz_jdpin_token=')>-1) lz_jdpin_token = ''+name.replace(/ /g,'')+';' + } + } + } + if(LZ_TOKEN_KEY && LZ_TOKEN_VALUE) activityCookie = `${LZ_TOKEN_KEY} ${LZ_TOKEN_VALUE}` + if(lz_jdpin_token) lz_jdpin_token_cookie = lz_jdpin_token +} + +async function getUA(){ + $.UA = `jdapp;iPhone;10.1.4;13.1.2;${randomString(40)};network/wifi;model/iPhone8,1;addressid/2308460611;appBuild/167814;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_1_2 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 joinShop() { + if(!$.joinVenderId) return + return new Promise(async resolve => { + $.shopactivityId = '' + await $.wait(1000) + await getshopactivityId() + let activityId = `` + if($.shopactivityId) activityId = `,"activityId":${$.shopactivityId}` + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body={"venderId":"${$.joinVenderId}","shopId":"${$.joinVenderId}","bindByVerifyCodeFlag":1,"registerExtend":{},"writeChildFlag":0${activityId},"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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + // console.log(data) + let res = $.toObj(data,data); + if(typeof res == 'object'){ + if(res.success === true){ + console.log(res.message) + if(res.result && res.result.giftInfo){ + for(let i of res.result.giftInfo.giftList){ + console.log(`入会获得:${i.discountString}${i.prizeName}${i.secondLineDesc}`) + } + } + }else if(typeof res == 'object' && res.message){ + console.log(`${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function getshopactivityId() { + return new Promise(resolve => { + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body=%7B%22venderId%22%3A%22${$.joinVenderId}%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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + let res = $.toObj(data,data); + if(typeof res == 'object'){ + if(res.success == true){ + // console.log($.toStr(res.result)) + console.log(`入会:${res.result.shopMemberCardInfo.venderCardName || ''}`) + $.shopactivityId = res.result.interestsRuleList && res.result.interestsRuleList[0] && res.result.interestsRuleList[0].interestsInfo && res.result.interestsRuleList[0].interestsInfo.activityId || '' + } + }else{ + console.log(data) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} + + +// 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)} + diff --git a/activity/jd_opencardL67.js b/activity/jd_opencardL67.js new file mode 100644 index 0000000..5d120e2 --- /dev/null +++ b/activity/jd_opencardL67.js @@ -0,0 +1,505 @@ +/* + +情人节活动 +一次性脚本 +入口:https://prodev.m.jd.com/mall/active/2xkw8NY53wVwSqw3CMtAmanw9y5X/index.html +============Quantumultx=============== +[task_local] +#情人节活动 +35 10 * * * https://raw.githubusercontent.com/KingRan/JDJB/main/jd_opencardL67.js, tag=情人节活动, img-url=https://raw.githubusercontent.com/Orz-3/mini/master/Color/jd.png, enabled=true + +================Loon============== +[Script] +cron "35 10 * * *" script-path=https://raw.githubusercontent.com/KingRan/JDJB/main/jd_opencardL67.js,tag=情人节活动 + +===============Surge================= +情人节活动 = type=cron,cronexp="35 10 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/KingRan/JDJB/main/jd_opencardL67.js + +============小火箭========= +情人节活动 = type=cron,script-path=https://raw.githubusercontent.com/KingRan/JDJB/main/jd_opencardL67.js, cronexpr="35 10 * * *", timeout=3600, enable=true + + +*/ +const $ = new Env('情人节活动'); +const Faker=require('./sign_graphics_validate.js') +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const notify = $.isNode() ? require('./sendNotify') : ''; +//IOS等用户直接用NobyDa的jd cookie +let cookiesArr = [], + cookie = ''; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} +message = "" +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', { + "open-url": "https://bean.m.jd.com/" + }); + return; + } + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i]; + if (cookie) { + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + $.bean = 0 + await getUA() + $.nickName = ''; + console.log(`\n\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + await run(); + if($.bean > 0) message += `【京东账号${$.index}】获得${$.bean}京豆\n` + } + } + if(message){ + $.msg($.name, ``, `${message}\n获得到的京豆不一定到账`); + if ($.isNode()){ + await notify.sendNotify(`${$.name}`, `${message}\n获得到的京豆不一定到账`); + } + } +})() + .catch((e) => $.logErr(e)) + .finally(() => $.done()) + + +async function run() { + try { + await getHtml(); + await $.wait(parseInt(Math.random() * 1000 + 2000, 10)) + if(!$.fp || !$.eid){ + $.log("获取活动信息失败!") + return + } + let config = [ + {configCode:'7b0c39fc30c94676a1549223eecb03b1',configName:'情人节活动2'}, + ] + for(let i in config){ + $.hotFlag = false + let item = config[i] + $.task = '' + $.taskList = [] + $.taskInfo = '' + let q = 5 + for(m=1;q--;m++){ + if($.task == '') await getActivity(item.configCode,item.configName,0) + if($.task || $.hotFlag) break + } + if($.hotFlag) continue; + if($.task.showOrder){ + console.log(`\n[${item.configName}] ${$.task.showOrder == 2 && '日常任务' || $.task.showOrder == 1 && '开卡' || '未知活动类型'} ${($.taskInfo.rewardStatus == 2) && '全部完成' || ''}`) + if($.taskInfo.rewardStatus == 2) continue; + $.taskList = $.task.memberList || $.task.taskList || [] + $.oneTask = '' + for (let i = 0; i < $.taskList.length; i++) { + $.oneTask = $.taskList[i]; + if($.task.showOrder == 1){ + if($.oneTask.cardName.indexOf('马克华') > -1) continue + console.log(`${$.oneTask.cardName} ${0 == $.oneTask.result ? "开卡得" + $.oneTask.rewardQuantity + "京豆" : 1 == $.oneTask.result ? "领取" + $.oneTask.rewardQuantity + "京豆" : 3 == $.oneTask.result ? "其他渠道入会" : "已入会"}`) + if($.oneTask.result == 0) await statistic(`{"activityType":"module_task","groupType":7,"configCode":"${item.configCode}","itemId":${$.oneTask.cardId}}`) + if($.oneTask.result == 0) await join($.oneTask.venderId) + await $.wait(parseInt(Math.random() * 1000 + 500, 10)) + if($.oneTask.result == 1 || $.oneTask.result == 0) await getReward(`{"configCode":"${item.configCode}","groupType":7,"itemId":${$.oneTask.cardId},"eid":"${$.eid}","fp":"${$.fp}"}`) + }else if($.task.showOrder == 2){ + $.cacheNum = 0 + $.doTask = false + $.outActivity = false + let name = `${1 == $.oneTask.groupType ? "关注并浏览店铺" : 2 == $.oneTask.groupType ? "加购并浏览商品" : 3 == $.oneTask.groupType ? "关注并浏览频道" : 6 == $.oneTask.groupType ? "浏览会场" : "未知"}` + let msg = `(${$.oneTask.finishCount}/${$.oneTask.taskCount})` + let status = `${$.oneTask.finishCount >= $.oneTask.taskCount && '已完成' || "去" + (1 == $.oneTask.groupType ? "关注" : 2 == $.oneTask.groupType ? "加购" : 3 == $.oneTask.groupType ? "关注" : 6 == $.oneTask.groupType ? "浏览" : "做任务")}` + console.log(`${name}${msg} ${status}`) + if($.oneTask.finishCount < $.oneTask.taskCount){ + await doTask(`{"configCode":"${item.configCode}","groupType":${$.oneTask.groupType},"itemId":"${$.oneTask.item.itemId}","eid":"${$.eid}","fp":"${$.fp}"}`) + let c = $.oneTask.taskCount - $.oneTask.finishCount - 1 + for(n=2;c-- && !$.outActivity;n++){ + if($.outActivity) break + console.log(`第${n}次`) + await getActivity(item.configCode,item.configName,$.oneTask.groupType) + $.oneTasks = '' + let q = 3 + for(m=1;q--;m++){ + if($.oneTasks == '') await getActivity(item.configCode,item.configName,$.oneTask.groupType) + if($.oneTasks) break + } + if($.oneTasks){ + c = $.oneTasks.taskCount - $.oneTasks.finishCount + if($.oneTasks.item.itemId == $.oneTask.item.itemId){ + n--; + console.log(`数据缓存中`) + $.cacheNum++; + if($.cacheNum > 3) console.log('请重新执行脚本,数据缓存问题'); + if($.cacheNum > 3) break; + await getUA() + await $.wait(parseInt(Math.random() * 1000 + 3000, 10)) + await getHtml(); + }else{ + $.cacheNum = 0 + } + if($.oneTasks.item.itemId != $.oneTask.item.itemId && $.oneTasks.finishCount < $.oneTasks.taskCount) await doTask(`{"configCode":"${item.configCode}","groupType":${$.oneTasks.groupType},"itemId":"${$.oneTasks.item.itemId}","eid":"${$.eid}","fp":"${$.fp}"}`) + await $.wait(parseInt(Math.random() * 1000 + 1000, 10)) + }else{ + n--; + } + } + } + }else{ + console.log('未知活动类型') + } + } + if($.task.showOrder == 2){ + if($.doTask){ + $.taskInfo = '' + let q = 5 + for(m=1;q--;m++){ + if($.taskInfo == '') await getActivity(item.configCode,item.configName,-1) + if($.taskInfo) break + } + } + if($.taskInfo.rewardStatus == 1) await getReward(`{"configCode":"${item.configCode}","groupType":5,"itemId":1,"eid":"${$.eid}","fp":"${$.fp}"}`,1) + } + } + await $.wait(parseInt(Math.random() * 1000 + 1000, 10)) + } + + } catch (e) { + console.log(e) + } +} +function getActivity(code,name,flag) { + return new Promise(async resolve => { + $.get({ + url: `https://jdjoy.jd.com/module/task/v2/getActivity?configCode=${code}&eid=${$.eid}&fp=${$.fp}`, + headers: { + 'Accept': 'application/json, text/plain, */*', + 'Content-Type':'application/json;charset=utf-8', + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + 'Cookie': cookie, + 'User-Agent': $.UA, + } + }, async (err, resp, data) => { + try { + if (err) { + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + // console.log(data) + res = $.toObj(data) + if(typeof res == 'object'){ + if(res.success == true && res.data.pass == true){ + if(flag == 0){ + $.task = res.data.memberTask || res.data.dailyTask || [] + $.taskInfo = res.data.moduleBaseInfo || res.data.moduleBaseInfo || [] + }else if(flag == -1){ + $.taskInfo = res.data.moduleBaseInfo || res.data.moduleBaseInfo || {} + }else if(flag == 1 || flag == 2){ + for(let i of res.data.dailyTask.taskList){ + if(i.groupType == flag){ + $.oneTasks = i + break + } + } + }else{ + console.log('活动-未知类型') + } + }else if(res.data.pass == false){ + console.log(`活动[${name}]活动太火爆了,请稍后再试~`) + $.hotFlag = true + }else{ + console.log(`活动[${name}]获取失败\n${data}`) + if(flag > 0) await getHtml(); + await $.wait(parseInt(Math.random() * 1000 + 2000, 10)) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function doTask(body) { + return new Promise(async resolve => { + $.post({ + url: `https://jdjoy.jd.com/module/task/v2/doTask`, + body, + headers: { + 'Accept': 'application/json, text/plain, */*', + "Accept-Encoding": "gzip, deflate, br", + 'Content-Type':'application/json;charset=UTF-8', + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + 'Cookie': cookie, + 'User-Agent': $.UA, + } + }, async (err, resp, data) => { + $.doTask = true + try { + if (err) { + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + await $.wait(parseInt(Math.random() * 1000 + 500, 10)) + // console.log(data) + res = $.toObj(data) + if(typeof res == 'object'){ + if(res.success == true){ + console.log(`领奖成功:${$.oneTask.rewardQuantity}京豆`) + $.bean += Number($.oneTask.rewardQuantity) + }else if(res.errorMessage){ + if(res.errorMessage.indexOf('活动已结束') > -1) $.outActivity = true + console.log(`${res.errorMessage}`) + }else{ + console.log(data) + } + } + + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} +function getReward(body, flag = 0) { + return new Promise(async resolve => { + $.post({ + url: `https://jdjoy.jd.com/module/task/v2/getReward`, + body, + headers: { + 'Accept': 'application/json, text/plain, */*', + "Accept-Encoding": "gzip, deflate, br", + 'Content-Type':'application/json;charset=UTF-8', + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + 'Cookie': cookie, + 'User-Agent': $.UA, + } + }, async (err, resp, data) => { + try { + if (err) { + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + // console.log(data) + res = $.toObj(data) + if(typeof res == 'object'){ + if(res.success == true){ + console.log(`领奖成功:${flag == 1 && $.taskInfo.rewardFinish || $.oneTask.rewardQuantity}京豆`) + $.bean += Number($.oneTask.rewardQuantity) + }else{ + console.log(`${res.errorMessage}`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +function statistic(body) { + return new Promise(async resolve => { + $.post({ + url: `https://jdjoy.jd.com/module/task/data/statistic`, + body, + headers: { + 'Accept': 'application/json, text/plain, */*', + "Accept-Encoding": "gzip, deflate, br", + 'Content-Type':'application/json;charset=UTF-8', + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + 'Cookie': cookie, + 'User-Agent': $.UA, + } + }, async (err, resp, data) => { + try { + if (err) { + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + // console.log(data) + + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} +function join(venderId) { + return new Promise(async resolve => { + $.shopactivityId = '' + await $.wait(1000) + await getshopactivityId(venderId) + $.get(ruhui(`${venderId}`), async (err, resp, data) => { + try { + // console.log(data) + data = JSON.parse(data); + if(data.success == true){ + $.log(data.message) + if(data.result && data.result.giftInfo){ + for(let i of data.result.giftInfo.giftList){ + console.log(`入会获得:${i.discountString}${i.prizeName}${i.secondLineDesc}`) + } + } + }else if(data.success == false){ + $.log(data.message) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} +function ruhui(functionId) { + let activityId = `` + if($.shopactivityId) activityId = `,"activityId":${$.shopactivityId}` + return { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body={"venderId":"${functionId}","shopId":"${functionId}","bindByVerifyCodeFlag":1,"registerExtend":{},"writeChildFlag":0${activityId},"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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Referer': `https://shopmember.m.jd.com/shopcard/?venderId=${functionId}&shopId=${functionId}&venderType=5&channel=401&returnUrl=https://lzdz1-isv.isvjcloud.com/dingzhi/dz/openCard/activity/832865?activityId=c225ad5922cf4ac8b4a68fd37f486088&shareUuid=${$.shareUuid}`, + 'Cookie': cookie + } + } +} + +function getshopactivityId(venderId) { + return new Promise(resolve => { + $.get(shopactivityId(`${venderId}`), async (err, resp, data) => { + try { + data = JSON.parse(data); + if(data.success == true){ + console.log(`入会:${data.result.shopMemberCardInfo.venderCardName || ''}`) + $.shopactivityId = data.result.interestsRuleList && data.result.interestsRuleList[0] && data.result.interestsRuleList[0].interestsInfo && data.result.interestsRuleList[0].interestsInfo.activityId || '' + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function shopactivityId(functionId) { + return { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body=%7B%22venderId%22%3A%22${functionId}%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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Referer': `https://shopmember.m.jd.com/shopcard/?venderId=${functionId}&shopId=${functionId}&venderType=5&channel=401&returnUrl=https://lzdz1-isv.isvjcloud.com/dingzhi/dz/openCard/activity/832865?activityId=c225ad5922cf4ac8b4a68fd37f486088&shareUuid=${$.shareUuid}`, + 'Cookie': cookie + } + } +} +function getHtml() { + return new Promise(resolve => { + $.get({ + url: `https://prodev.m.jd.com/mall/active/3q7yrbh3qCJvHsu3LhojdgxNuWQT/index.html`, + headers: { + "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + 'Cookie': cookie, + 'User-Agent': $.UA, + } + }, async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +function getEid(arr) { + return new Promise(resolve => { + const options = { + url: `https://gia.jd.com/fcf.html?a=${arr.a}`, + body: `d=${arr.d}`, + headers: { + "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8", + "User-Agent": $.UA + } + } + $.post(options, async (err, resp, data) => { + try { + if (err) { + console.log(`\n${turnTableId[i].name} 登录: API查询请求失败 ‼️‼️`) + throw new Error(err); + } else { + if (data.indexOf("*_*") > 0) { + data = data.split("*_*", 2); + data = JSON.parse(data[1]); + $.eid = data.eid + } else { + console.log(`京豆api返回数据为空,请检查自身原因`) + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }) +} + + + +async 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` + let arr = await Faker.getBody($.UA,'https://prodev.m.jd.com/mall/active/3q7yrbh3qCJvHsu3LhojdgxNuWQT/index.html') + $.fp = arr.fp + await getEid(arr) +} +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 jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} +// 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)} diff --git a/activity/jd_opencardL68.js b/activity/jd_opencardL68.js new file mode 100644 index 0000000..1974c61 --- /dev/null +++ b/activity/jd_opencardL68.js @@ -0,0 +1,821 @@ +/* +2.8~2.15 臻宠会员,甜蜜告白 +新增开卡脚本,一次性脚本 + + +第一个账号助力作者 其他依次助力CK1 +第一个CK失效会退出脚本 + +———————————————— +入口:[ 2.8~2.15 臻宠会员,甜蜜告白 (https://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=dzlhkkkbblnt20220208&shareUuid=a46d3616cfa54b7aa403a111c7a9c533)] + +请求太频繁会被黑ip +过10分钟再执行 + +cron:30 0,10 8-15 2 * +============Quantumultx=============== +[task_local] +#2.8~2.15 臻宠会员,甜蜜告白 +30 0,10 8-15 2 * jd_opencard98.js, tag=2.8~2.15 臻宠会员,甜蜜告白, enabled=true + +*/ +const $ = new Env("2.8~2.15 臻宠会员,甜蜜告白"); +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const notify = $.isNode() ? require('./sendNotify') : ''; +//IOS等用户直接用NobyDa的jd cookie + +let cookiesArr = [], + cookie = ''; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} +allMessage = "" +message = "" +$.hotFlag = false +$.outFlag = false +$.activityEnd = false +let lz_jdpin_token_cookie ='' +let activityCookie ='' +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', { + "open-url": "https://bean.m.jd.com/" + }); + return; + } + $.activityId = "dzlhkkkbblnt20220208" + $.shareUuid = "96d9a6e179c8438184a21c1e38c2915e" + console.log(`入口:\nhttps://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}`) + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i]; + if (cookie) { + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + message = "" + $.bean = 0 + $.hotFlag = false + $.nickName = ''; + console.log(`\n\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + await getUA() + await run(); + if(i == 0 && !$.actorUuid) break + if($.outFlag || $.activityEnd) break + } + } + if($.outFlag) { + let msg = '此ip已被限制,请过10分钟后再执行脚本' + $.msg($.name, ``, `${msg}`); + if ($.isNode()) await notify.sendNotify(`${$.name}`, `${msg}`); + } +})() + .catch((e) => $.logErr(e)) + .finally(() => $.done()) + + +async function run() { + try { + $.hasEnd = true + $.endTime = 0 + lz_jdpin_token_cookie = '' + $.Token = '' + $.Pin = '' + let flag = false + await takePostRequest('isvObfuscator'); + if($.Token == ''){ + console.log('获取[token]失败!') + return + } + await getCk() + if (activityCookie == '') { + console.log(`获取cookie失败`); return; + } + if($.activityEnd === true){ + console.log('活动结束') + return + } + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + await takePostRequest('getSimpleActInfoVo'); + await takePostRequest('getMyPing'); + if(!$.Pin){ + console.log('获取[Pin]失败!') + return + } + await takePostRequest('accessLogWithAD'); + await takePostRequest('getUserInfo'); + await takePostRequest('activityContent'); + if($.hotFlag) return + if(!$.actorUuid){ + console.log('获取不到[actorUuid]退出执行,请重新执行') + return + } + // console.log($.actorUuid) + // return + if($.hasEnd === true || Date.now() > $.endTime){ + $.activityEnd = true + console.log('活动结束') + return + } + await takePostRequest('drawContent'); + await $.wait(1000) + $.openList = [] + $.allOpenCard = false + await takePostRequest('info'); + await takePostRequest('checkOpenCard'); + if($.allOpenCard == false){ + console.log('开卡任务') + for(o of $.openList){ + $.openCard = false + if(o.status == 0){ + flag = true + $.joinVenderId = o.venderId + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + await joinShop() + await $.wait(parseInt(Math.random() * 1000 + 1000, 10)) + await takePostRequest('activityContent'); + await takePostRequest('drawContent'); + await takePostRequest('checkOpenCard'); + await $.wait(parseInt(Math.random() * 3000 + 2000, 10)) + } + } + }else{ + console.log('已全部开卡') + } + + $.log("关注: " + $.followShop) + if(!$.followShop && !$.outFlag){ + flag = true + await takePostRequest('followShop'); + await $.wait(parseInt(Math.random() * 2000 + 3000, 10)) + } + $.yaoqing = false + await takePostRequest('邀请'); + if($.yaoqing){ + await takePostRequest('助力'); + } + $.log("加购: " + $.addCart) + if(!$.addCart && !$.outFlag){ + flag = true + await takePostRequest('addCart'); + await $.wait(parseInt(Math.random() * 2000 + 4000, 10)) + } + $.runFalag = true + $.log("浏览商品: " + $.visitSku) + if(!$.visitSku && !$.outFlag){ + flag = true + for(let v of $.visitSkuList || []){ + if($.runFalag == false) break + if(v.goodsCode && v.status === 0){ + $.visitSkuValue = v.goodsCode + await takePostRequest('browseGoods'); + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + } + } + } + $.runFalag = true + let count = parseInt($.drawCount, 10) + console.log(`抽奖次数为:${count}`) + for(m=1;count--;m++){ + console.log(`第${m}次抽奖`) + await takePostRequest('startDraw'); + if($.runFalag == false) break + if(Number(count) <= 0) break + if(m >= 30){ + console.log("抽奖太多次,多余的次数请再执行脚本") + break + } + await $.wait(parseInt(Math.random() * 2000 + 2000, 10)) + } + if(flag){ + await takePostRequest('activityContent'); + } + console.log(`${$.score}值 游戏:${$.point}`) + $.runFalag = true + count = parseInt($.score/1000) + console.log(`抽奖次数为:${count}`) + for(m=1;count--;m++){ + console.log(`第${m}次抽奖`) + await takePostRequest('抽奖'); + if($.runFalag == false) break + if(Number(count) <= 0) break + if(m >= 10){ + console.log("抽奖太多次,多余的次数请再执行脚本") + break + } + await $.wait(parseInt(Math.random() * 2000 + 2000, 10)) + } + + await $.wait(parseInt(Math.random() * 1000 + 2000, 10)) + await takePostRequest('getDrawRecordHasCoupon'); + await takePostRequest('getShareRecord'); + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + console.log($.actorUuid) + console.log(`当前助力:${$.shareUuid}`) + if($.index == 1){ + $.shareUuid = $.actorUuid + console.log(`后面的号都会助力:${$.shareUuid}`) + } + await $.wait(parseInt(Math.random() * 1000 + 5000, 10)) + if(flag) await $.wait(parseInt(Math.random() * 1000 + 10000, 10)) + + if($.index % 3 == 0) console.log('休息1分钟,别被黑ip了\n可持续发展') + if($.index % 3 == 0) await $.wait(parseInt(Math.random() * 5000 + 60000, 10)) + + } catch (e) { + console.log(e) + } +} + +async function takePostRequest(type) { + if($.outFlag) return + let domain = 'https://lzdz1-isv.isvjcloud.com'; + let body = ``; + let method = 'POST' + let admJson = '' + switch (type) { + case 'isvObfuscator': + url = `https://api.m.jd.com/client.action?functionId=isvObfuscator`; + body = `body=%7B%22url%22%3A%22https%3A//lzdz1-isv.isvjcloud.com%22%2C%22id%22%3A%22%22%7D&uuid=7088d9018515b8cb0c88ace6e5479762af3e88f3&client=apple&clientVersion=10.1.4&st=1634343624086&sv=120&sign=8b9cea22c3a0d77026abda5d37d2b7e3`; + break; + case 'getSimpleActInfoVo': + url = `${domain}/dz/common/getSimpleActInfoVo`; + body = `activityId=${$.activityId}`; + break; + case 'getMyPing': + url = `${domain}/customer/getMyPing`; + body = `userId=${$.shopId || $.venderId || ''}&token=${$.Token}&fromType=APP`; + break; + case 'accessLogWithAD': + url = `${domain}/common/accessLogWithAD`; + let pageurl = `${domain}/drawCenter/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}` + body = `venderId=${$.shopId || $.venderId || ''}&code=99&pin=${encodeURIComponent($.Pin)}&activityId=${$.activityId}&pageUrl=${encodeURIComponent(pageurl)}&subType=app&adSource=` + break; + case 'getUserInfo': + url = `${domain}/wxActionCommon/getUserInfo`; + body = `pin=${encodeURIComponent($.Pin)}`; + break; + case 'activityContent': + url = `${domain}/dingzhi/linkgame/activity/content`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&pinImg=${encodeURIComponent($.attrTouXiang)}&nick=${encodeURIComponent($.nickname)}&cjyxPin=&cjhyPin=&shareUuid=${$.shareUuid}` + break; + case 'drawContent': + url = `${domain}/dingzhi/taskact/common/drawContent`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case 'checkOpenCard': + url = `${domain}/dingzhi/linkgame/checkOpenCard`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case 'info': + url = `${domain}/dingzhi/linkgame/task/info`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case 'startDraw': + url = `${domain}/dingzhi/linkgame/draw/bean`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case 'followShop': + url = `${domain}/dingzhi/linkgame/follow/shop`; + // url = `${domain}/dingzhi/dz/openCard/saveTask`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case 'sign': + case 'addCart': + case 'browseGoods': + url = `${domain}/dingzhi/linkgame/${type}`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + if(type == 'browseGoods') body += `&value=${$.visitSkuValue}` + break; + case '邀请': + case '助力': + if(type == '助力'){ + url = `${domain}/dingzhi/linkgame/assist`; + }else{ + url = `${domain}/dingzhi/linkgame/assist/status`; + } + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&shareUuid=${$.shareUuid}` + break; + case 'viewVideo': + case 'visitSku': + case 'toShop': + case 'addSku': + url = `${domain}/dingzhi/dz/openCard/saveTask`; + let taskType = '' + let taskValue = '' + if(type == 'viewVideo'){ + taskType = 31 + taskValue = 31 + }else if(type == 'visitSku'){ + taskType = 5 + taskValue = $.visitSkuValue || 5 + }else if(type == 'toShop'){ + taskType = 14 + taskValue = $.toShopValue || 14 + }else if(type == 'addSku'){ + taskType = 2 + taskValue = $.addSkuValue || 2 + } + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&taskType=${taskType}&taskValue=${taskValue}` + break; + case 'getDrawRecordHasCoupon': + url = `${domain}/dingzhi/linkgame/draw/record`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case 'getShareRecord': + url = `${domain}/dingzhi/linkgame/help/list`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case '抽奖': + url = `${domain}/dingzhi/linkgame/draw`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + default: + console.log(`错误${type}`); + } + let myRequest = getPostRequest(url, body, method); + // console.log(myRequest) + return new Promise(async resolve => { + $.post(myRequest, (err, resp, data) => { + try { + setActivityCookie(resp) + if (err) { + if(resp && typeof resp.statusCode != 'undefined'){ + if(resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + } + console.log(`${$.toStr(err,err)}`) + console.log(`${type} API请求失败,请检查网路重试`) + } else { + dealReturn(type, data); + } + } catch (e) { + // console.log(data); + console.log(e, resp) + } finally { + resolve(); + } + }) + }) + } + +async function dealReturn(type, data) { + let res = '' + try { + if(type != 'accessLogWithAD' || type != 'drawContent'){ + if(data){ + res = JSON.parse(data); + } + } + } catch (e) { + console.log(`${type} 执行任务异常`); + console.log(data); + $.runFalag = false; + } + try { + switch (type) { + case 'isvObfuscator': + if(typeof res == 'object'){ + if(res.errcode == 0){ + if(typeof res.token != 'undefined') $.Token = res.token + }else if(res.message){ + console.log(`isvObfuscator ${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + break; + case 'getSimpleActInfoVo': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(typeof res.data.shopId != 'undefined') $.shopId = res.data.shopId + if(typeof res.data.venderId != 'undefined') $.venderId = res.data.venderId + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getMyPing': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(res.data && typeof res.data.secretPin != 'undefined') $.Pin = res.data.secretPin + if(res.data && typeof res.data.nickname != 'undefined') $.nickname = res.data.nickname + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getUserInfo': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(res.data && typeof res.data.yunMidImageUrl != 'undefined') $.attrTouXiang = res.data.yunMidImageUrl || "https://img10.360buyimg.com/imgzone/jfs/t1/7020/27/13511/6142/5c5138d8E4df2e764/5a1216a3a5043c5d.png" + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'activityContent': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + $.endTime = res.data.endTime || res.data.activity.endTime || 0 + $.hasEnd = res.data.isEnd || false + $.drawCount = res.data.actor.drawCount || 0 + $.point = res.data.actor.point || 0 + $.score = res.data.actor.score || 0 + $.actorUuid = res.data.actor.actorUuid || '' + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'info': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + // $.drawCount = res.data.drawCount || 0 + $.addCart = res.data.addCart || false + $.followShop = res.data.followShop || false + $.sign = res.data.sign || false + $.visitSku = res.data.visitSku || false + $.visitSkuList = res.data.visitSkuList || [] + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'checkOpenCard': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + let cardList1 = res.data.cardList1 || [] + let cardList2 = res.data.cardList2 || [] + let cardList = res.data.cardList || [] + let openCardList = res.data.openCardList || [] + $.openList = [...cardList,...cardList1,...cardList2,...openCardList] + $.allOpenCard = res.data.allOpenCard || false + $.openCardScore1 = res.data.score1 || 0 + $.openCardScore2 = res.data.score2 || 0 + $.drawScore = res.data.drawScore || 0 + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'startDraw': + case 'followShop': + case 'viewVideo': + case 'visitSku': + case 'toShop': + case 'addSku': + case 'sign': + case 'addCart': + case 'browseGoods': + case '抽奖': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(typeof res.data == 'object'){ + let msg = '' + let title = '抽奖' + if(res.data.addBeanNum){ + msg = `${res.data.addBeanNum}京豆` + } + if(res.data.addPoint){ + msg += ` ${res.data.addPoint}游戏机会` + } + if(type == 'followShop'){ + title = '关注' + if(res.data.beanNumMember && res.data.assistSendStatus){ + msg += ` 额外获得:${res.data.beanNumMember}京豆` + } + }else if(type == 'addSku' || type == 'addCart'){ + title = '加购' + }else if(type == 'viewVideo'){ + title = '热门文章' + }else if(type == 'toShop'){ + title = '浏览店铺' + }else if(type == 'visitSku' || type == 'browseGoods'){ + title = '浏览商品' + }else if(type == 'sign'){ + title = '签到' + }else{ + msg = res.data.drawOk == true && (res.data.drawInfoType == 6 && res.data.name || '') || '空气💨' + } + if(!msg){ + msg = '空气💨' + } + console.log(`${title}获得:${msg || data}`) + }else{ + console.log(`${type} ${data}`) + } + }else if(res.errorMessage){ + $.runFalag = false; + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getDrawRecordHasCoupon': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + console.log(`我的奖品:`) + let num = 0 + let value = 0 + for(let i in res.data.recordList){ + let item = res.data.recordList[i] + if(item.infoName == '20京豆'){ + num++ + value = item.infoName.replace('京豆','') + }else{ + console.log(`${item.infoType != 10 && item.value && item.value +':' || ''}${item.infoName}`) + } + } + if(num > 0) console.log(`邀请好友(${num}):${num*parseInt(value, 10) || 30}京豆`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getShareRecord': + if(typeof res == 'object'){ + if(res.result && res.result === true && res.data){ + $.ShareCount = res.data.shareList.length + $.log(`=========== 你邀请了:${res.data.shareList.length}个`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case '邀请': + case '助力': + // console.log(data) + if(typeof res == 'object'){ + if(res.data.status == 200){ + if(type == '助力'){ + console.log('助力成功') + }else{ + $.yaoqing = true + } + }else if(res.data.status == 105){ + console.log('已经助力过') + }else if(res.data.status == 104){ + console.log('已经助力其他人') + }else if(res.data.status == 101){ + // console.log('已经助力过') + }else{ + console.log(data) + } + }else{ + console.log(`${type} ${data}`) + } + + case 'accessLogWithAD': + case 'drawContent': + break; + default: + console.log(`${type}-> ${data}`); + } + if(typeof res == 'object'){ + if(res.errorMessage){ + if(res.errorMessage.indexOf('火爆') >-1 ){ + $.hotFlag = true + } + } + } + } catch (e) { + console.log(e) + } +} + +function getPostRequest(url, body, method="POST") { + let headers = { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Content-Type": "application/x-www-form-urlencoded", + "Cookie": cookie, + "User-Agent": $.UA, + "X-Requested-With": "XMLHttpRequest" + } + if(url.indexOf('https://lzdz1-isv.isvjcloud.com') > -1){ + headers["Referer"] = `https://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}` + headers["Cookie"] = `${lz_jdpin_token_cookie && lz_jdpin_token_cookie || ''}${$.Pin && "AUTH_C_USER=" + $.Pin + ";" || ""}${activityCookie}` + } + // console.log(headers) + // console.log(headers.Cookie) + return {url: url, method: method, headers: headers, body: body, timeout:30000}; +} + +function getCk() { + return new Promise(resolve => { + let get = { + url:`https://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}`, + followRedirect:false, + headers: { + "User-Agent": $.UA, + }, + timeout:30000 + } + $.get(get, async(err, resp, data) => { + try { + if (err) { + if(resp && typeof resp.statusCode != 'undefined'){ + if(resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + } + console.log(`${$.toStr(err)}`) + console.log(`${$.name} cookie API请求失败,请检查网路重试`) + } else { + let end = data.match(/(活动已经结束)/) && data.match(/(活动已经结束)/)[1] || '' + if(end){ + $.activityEnd = true + console.log('活动已结束') + } + setActivityCookie(resp) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function setActivityCookie(resp){ + let LZ_TOKEN_KEY = '' + let LZ_TOKEN_VALUE = '' + let lz_jdpin_token = '' + let setcookies = resp && resp['headers'] && (resp['headers']['set-cookie'] || resp['headers']['Set-Cookie'] || '') || '' + let setcookie = '' + if(setcookies){ + if(typeof setcookies != 'object'){ + setcookie = setcookies.split(',') + }else setcookie = setcookies + for (let ck of setcookie) { + let name = ck.split(";")[0].trim() + if(name.split("=")[1]){ + // console.log(name.replace(/ /g,'')) + if(name.indexOf('LZ_TOKEN_KEY=')>-1) LZ_TOKEN_KEY = name.replace(/ /g,'')+';' + if(name.indexOf('LZ_TOKEN_VALUE=')>-1) LZ_TOKEN_VALUE = name.replace(/ /g,'')+';' + if(name.indexOf('lz_jdpin_token=')>-1) lz_jdpin_token = ''+name.replace(/ /g,'')+';' + } + } + } + if(LZ_TOKEN_KEY && LZ_TOKEN_VALUE) activityCookie = `${LZ_TOKEN_KEY} ${LZ_TOKEN_VALUE}` + if(lz_jdpin_token) lz_jdpin_token_cookie = lz_jdpin_token +} + +async function getUA(){ + $.UA = `jdapp;iPhone;10.1.4;13.1.2;${randomString(40)};network/wifi;model/iPhone8,1;addressid/2308460611;appBuild/167814;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_1_2 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 joinShop() { + if(!$.joinVenderId) return + return new Promise(async resolve => { + $.shopactivityId = '' + await $.wait(1000) + await getshopactivityId() + let activityId = `` + if($.shopactivityId) activityId = `,"activityId":${$.shopactivityId}` + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body={"venderId":"${$.joinVenderId}","shopId":"${$.joinVenderId}","bindByVerifyCodeFlag":1,"registerExtend":{},"writeChildFlag":0${activityId},"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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + // console.log(data) + let res = $.toObj(data); + if(typeof res == 'object'){ + if(res.success === true){ + console.log(res.message) + if(res.result && res.result.giftInfo){ + for(let i of res.result.giftInfo.giftList){ + console.log(`入会获得:${i.discountString}${i.prizeName}${i.secondLineDesc}`) + } + } + }else if(typeof res == 'object' && res.message){ + console.log(`${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function getshopactivityId() { + return new Promise(resolve => { + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body=%7B%22venderId%22%3A%22${$.joinVenderId}%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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + let res = $.toObj(data); + if(res.success == true){ + // console.log($.toStr(res.result)) + console.log(`入会:${res.result.shopMemberCardInfo.venderCardName || ''}`) + $.shopactivityId = res.result.interestsRuleList && res.result.interestsRuleList[0] && res.result.interestsRuleList[0].interestsInfo && res.result.interestsRuleList[0].interestsInfo.activityId || '' + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} + + +// 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)} diff --git a/activity/jd_opencardL71.js b/activity/jd_opencardL71.js new file mode 100644 index 0000000..a073ae3 --- /dev/null +++ b/activity/jd_opencardL71.js @@ -0,0 +1,544 @@ +/* +2.13~2.19 联合开卡 +新增开卡脚本,一次性脚本 + +第一个账号助力作者 其他依次助力CK1 +第一个CK失效会退出脚本 + +———————————————— +入口:[ 2.13~2.19 联合开卡] + +请求太频繁会被黑ip +过10分钟再执行 + + +cron:35 1,18 13-19 2 * +============Quantumultx=============== +[task_local] +#2.13~2.19 联合开卡 +35 1,18 13-19 2 * jd_opencardL71.js, tag=2.13~2.19 联合开卡, enabled=true + +*/ + +const $ = new Env('2.13~2.19 联合开卡'); +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const notify = $.isNode() ? require('./sendNotify') : ''; + +//IOS等用户直接用NobyDa的jd cookie +let cookiesArr = [], + cookie = ''; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} + +allMessage = "" +message = "" +$.hotFlag = false +$.outFlag = false +$.activityEnd = false +let lz_jdpin_token_cookie ='' +let activityCookie ='' +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', { + "open-url": "https://bean.m.jd.com/" + }); + return; + } + // return + $.appkey = '51B59BB805903DA4CE513D29EC448375' + $.userId = '10299171' + $.actId = '98a976e9f0_22021301' + $.MixNicks = '' + $.inviteNick = 'e4aHW8SbTt6Rgyvpai2f5ls/ye9oluZX4nOTK56TeMXbR7I2OlzZch4hTs22oCUS' + console.log(`活动地址:`) + console.log(`请自行测试有水无水。`) + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i]; + if (cookie) { + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + message = "" + $.bean = 0 + $.hotFlag = false + $.nickName = ''; + console.log(`\n\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + await getUA() + await run(); + if(i == 0 && !$.MixNick) break + if($.outFlag || $.activityEnd) break + } + } + if($.outFlag) { + let msg = '此ip已被限制,请过10分钟后再执行脚本' + $.msg($.name, ``, `${msg}`); + if ($.isNode()) await notify.sendNotify(`${$.name}`, `${msg}`); + } +})() + .catch((e) => $.logErr(e)) + .finally(() => $.done()) + + +async function run() { + try { + $.hasEnd = true + $.endTime = 0 + lz_jdpin_token_cookie = '' + $.Token = '' + $.Pin = '' + $.MixNick = '' + let flag = false + if($.activityEnd) return + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + await takePostRequest('isvObfuscator'); + if($.Token == ''){ + console.log('获取[token]失败!') + return + } + await takePostRequest('activity_load'); + if($.hotFlag) return + if(Date.now() > $.endTime){ + $.MixNick = '' + $.activityEnd = true + console.log('活动结束') + return + } + if ($.MixNick == '') { + console.log(`获取cookie失败`); return; + } + // console.log($.MixNick) + // return + $.toBind = 0 + $.openList = [] + await takePostRequest('绑定'); + await takePostRequest('shopList'); + if($.activityEnd) return + for(o of $.openList){ + $.missionType = 'openCard' + if(o.open != true && o.openCardUrl){ + if($.activityEnd) return + $.openCard = false + $.joinVenderId = o.userId + await takePostRequest('mission'); + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + if($.openCard == true){ + await joinShop() + await takePostRequest('activity_load'); + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + // break + } + $.joinVenderId = '' + } + } + $.joinVenderId = '' + if($.hasCollectShop === 0){ + // 关注 + $.missionType = 'uniteCollectShop' + await takePostRequest('mission'); + await $.wait(parseInt(Math.random() * 2000 + 3000, 10)) + }else{ + console.log('已经关注') + } + $.missionType = 'uniteAddCart' + + await takePostRequest('mission'); + await $.wait(parseInt(Math.random() * 2000 + 3000, 10)) + await takePostRequest('activity_load'); + $.runFalag = true + let count = parseInt($.usedChance, 10) + console.log(`抽奖次数为:${count}`) + for(m=1;count--;m++){ + console.log(`第${m}次抽奖`) + await takePostRequest('抽奖'); + if($.runFalag == false) break + if(Number(count) <= 0) break + if(m >= 10){ + console.log("抽奖太多次,多余的次数请再执行脚本") + break + } + await $.wait(parseInt(Math.random() * 2000 + 2000, 10)) + } + await takePostRequest('myAward'); + await takePostRequest('missionInviteList'); + console.log($.MixNick) + console.log(`当前助力:${$.inviteNick}`) + if($.index == 1){ + $.inviteNick = $.MixNick + console.log(`后面的号都会助力:${$.inviteNick}`) + } + await $.wait(parseInt(Math.random() * 1000 + 5000, 10)) + } catch (e) { + console.log(e) + } +} + +async function takePostRequest(type) { + if($.outFlag) return + let domain = 'https://jinggengjcq-isv.isvjcloud.com'; + let body = ``; + let method = 'POST' + let admJson = '' + switch (type) { + case 'isvObfuscator': + url = `https://api.m.jd.com/client.action?functionId=isvObfuscator`; + body = `body=%7B%22url%22%3A%22https%3A//jinggengjcq-isv.isvjcloud.com/fronth5/%3Flng%3D0%26lat%3D0%26sid%3D49687cd64aca2ae93aa43748a04e8f6w%26un_area%3D16_1315_1316_53522%23/pages/unitedCardNew20211010-ka/unitedCardNew20211010-ka%3FactId%3D9150e1d16b9d40_10101%22%2C%22id%22%3A%22%22%7D&uuid=b9b4ce69d42dacb64084279d51cdee764d7781fa&client=apple&clientVersion=10.1.4&st=1634100732991&sv=111&sign=67e254ffbcb13be9e12a9782c9cdf398`; + break; + case 'activity_load': + url = `${domain}/dm/front/openCardNew/activity_load?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"jdToken": $.Token, "source": "01", "inviteNick":($.inviteNick || "")} + if($.joinVenderId) admJson = {...admJson, "shopId": `${$.joinVenderId}`} + body = taskPostUrl("/openCardNew/activity_load", admJson); + break; + case 'shopList': + url = `${domain}/dm/front/openCardNew/shopList?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {} + body = taskPostUrl("/openCardNew/shopList", admJson); + break; + case '绑定': + url = `${domain}/dm/front/openCardNew/complete/mission?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"missionType": "relationBind", "inviterNick":($.inviteNick || "")} + body = taskPostUrl("/openCardNew/complete/mission", admJson); + break; + case 'mission': + url = `${domain}/dm/front/openCardNew/complete/mission?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"missionType": $.missionType} + if($.joinVenderId) admJson = {...admJson, "shopId": $.joinVenderId} + body = taskPostUrl("/openCardNew/complete/mission", admJson); + break; + case '抽奖': + url = `${domain}/dm/front/openCardNew/draw/post?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"dataType": "draw", "usedGameNum": "2"} + body = taskPostUrl("/openCardNew/draw/post", admJson); + break; + case 'followShop': + url = `${domain}/dm/front/openCardNew/followShop?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"actId": $.actId, "missionType": "collectShop"} + body = taskPostUrl("/openCardNew/followShop", admJson); + break; + case 'addCart': + url = `${domain}/dm/front/openCardNew/addCart?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"actId": $.actId, "missionType": "addCart"} + body = taskPostUrl("/openCardNew/addCart", admJson); + break; + case 'myAward': + url = `${domain}/dm/front/openCardNew/myAwards?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"pageNo": 1,"pageSize":9999} + body = taskPostUrl("/openCardNew/myAwards", admJson); + break; + case 'missionInviteList': + url = `${domain}/dm/front/openCardNew/missionInviteList?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"inviteListRequest":{"actId":$.actId,"userId":10299171,"missionType":"shareAct","inviteType": 1,"buyerNick":($.MixNick || '')}} + body = taskPostUrl("/openCardNew/missionInviteList", admJson); + break; + default: + console.log(`错误${type}`); + } + let myRequest = getPostRequest(url, body, method); + return new Promise(async resolve => { + $.post(myRequest, (err, resp, data) => { + try { + if (err) { + if(resp && resp.statusCode && resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + console.log(`${$.toStr(err,err)}`) + console.log(`${type} API请求失败,请检查网路重试`) + } else { + dealReturn(type, data); + } + } catch (e) { + // console.log(data); + console.log(e, resp) + } finally { + resolve(); + } + }) + }) + } + +async function dealReturn(type, data) { + let res = '' + try { + if(type != 'accessLogWithAD' || type != 'drawContent'){ + if(data){ + res = JSON.parse(data); + } + } + } catch (e) { + console.log(`${type} 执行任务异常`); + console.log(data); + $.runFalag = false; + } + try { + let title = '' + switch (type) { + case 'isvObfuscator': + if(typeof res == 'object'){ + if(res.errcode == 0){ + if(typeof res.token != 'undefined') $.Token = res.token + }else if(res.message){ + console.log(`${type} ${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + break; + case 'accessLogWithAD': + case 'drawContent': + break; + case 'activity_load': + case 'mission': + case 'shopList': + case 'loadUniteOpenCard': + case 'setMixNick': + case 'uniteOpenCardOne': + case 'checkOpenCard': + case 'followShop': + case 'addCart': + case 'myAward': + case 'missionInviteList': + case '抽奖': + title = '' + if(type == "followShop") title = '关注' + if(type == "addCart") title = '加购' + if(typeof res == 'object'){ + if(res.success && res.success === true && res.data){ + if(res.data.status && res.data.status == 200){ + res = res.data + if(type != "setMixNick" && (res.msg || res.data.isOpenCard || res.data.remark)) console.log(`${title && title+":" || ""}${res.msg || res.data.isOpenCard || res.data.remark || ''}`) + if(type == "activity_load"){ + if(res.msg || res.data.isOpenCard) { + if((res.msg || res.data.isOpenCard || '').indexOf('绑定成功') > -1) $.toBind = 1 + } + if(res.data){ + $.endTime = res.data.cusActivity.endTime || 0 + $.MixNick = res.data.buyerNick || "" + $.usedChance = res.data.missionCustomer.usedChance || 0 + $.hasCollectShop = res.data.missionCustomer.hasCollectShop || 0 + } + }else if(type == "shopList"){ + $.openList = res.data.cusShops || [] + }else if(type == "mission"){ + if(res.data.remark.indexOf('不是会员') > -1){ + $.openCard = true + }else{ + $.openCard = false + } + }else if(type == "uniteOpenCardOne"){ + $.uniteOpenCar = res.msg || res.data.msg || '' + }else if(type == "myAward"){ + console.log(`我的奖品:`) + let num = 0 + let value = 0 + for(let i in res.data.list || []){ + let item = res.data.list[i] + value += Number(item.awardDes) + } + if(value > 0) console.log(`共获得${value}京豆\n无法判断奖励是否为邀请奖励,所以直接显示获得多少豆\n`) + }else if(type == "missionInviteList"){ + console.log(`邀请人数(${res.data.invitedLogList.total})`) + } + }else if(res.data.msg){ + if(res.errorMessage.indexOf('活动未开始') >-1 ){ + $.activityEnd = true + } + console.log(`${title || type} ${res.data.msg || ''}`) + }else if(res.errorMessage){ + if(res.errorMessage.indexOf('火爆') >-1 ){ + $.hotFlag = true + } + console.log(`${title || type} ${res.errorMessage || ''}`) + }else{ + console.log(`${title || type} ${data}`) + } + }else if(res.errorMessage){ + console.log(`${title || type} ${res.errorMessage || ''}`) + }else{ + console.log(`${title || type} ${data}`) + } + }else{ + console.log(`${title || type} ${data}`) + } + break; + default: + console.log(`${title || type}-> ${data}`); + } + if(typeof res == 'object'){ + if(res.errorMessage){ + if(res.errorMessage.indexOf('火爆') >-1 ){ + $.hotFlag = true + } + } + } + } catch (e) { + console.log(e) + } +} + +function getPostRequest(url, body, method="POST") { + let headers = { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Content-Type": "application/x-www-form-urlencoded", + "Cookie": cookie, + "User-Agent": $.UA, + "X-Requested-With": "XMLHttpRequest" + } + if(url.indexOf('https://jinggengjcq-isv.isvjcloud.com') > -1){ + headers["Origin"] = `https://jinggengjcq-isv.isvjcloud.com` + headers["Content-Type"] = `application/json; charset=utf-8` + delete headers["Cookie"] + } + // console.log(headers) + // console.log(headers.Cookie) + return {url: url, method: method, headers: headers, body: body, timeout:60000}; +} + + +function taskPostUrl(url, t) { + + const b = { + "jsonRpc": "2.0", + "params": { + "commonParameter": { + "appkey": $.appkey, + "m": "POST", + "timestamp": Date.now(), + "userId": $.userId + }, + "admJson": { + "actId": $.actId, + "userId": $.userId, + ...t, + "method": url, + "buyerNick": ($.MixNick || ''), + } + }, + } + if(url.indexOf('missionInviteList') > -1){ + delete b.params.admJson.actId + } + return $.toStr(b,b) +} +async function getUA(){ + $.UA = `jdapp;iPhone;10.1.4;13.1.2;${randomString(40)};network/wifi;model/iPhone8,1;addressid/2308460611;appBuild/167814;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_1_2 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 jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} + +function joinShop() { + if(!$.joinVenderId) return + return new Promise(async resolve => { + $.shopactivityId = '' + await $.wait(1000) + await getshopactivityId() + let activityId = `` + if($.shopactivityId) activityId = `,"activityId":${$.shopactivityId}` + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body={"venderId":"${$.joinVenderId}","shopId":"${$.joinVenderId}","bindByVerifyCodeFlag":1,"registerExtend":{},"writeChildFlag":0${activityId},"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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + // console.log(data) + let res = $.toObj(data,data); + if(typeof res == 'object'){ + if(res.success === true){ + console.log(res.message) + if(res.result && res.result.giftInfo){ + for(let i of res.result.giftInfo.giftList){ + console.log(`入会获得:${i.discountString}${i.prizeName}${i.secondLineDesc}`) + } + } + }else if(typeof res == 'object' && res.message){ + console.log(`${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function getshopactivityId() { + return new Promise(resolve => { + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body=%7B%22venderId%22%3A%22${$.joinVenderId}%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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + let res = $.toObj(data,data); + if(typeof res == 'object'){ + if(res.success == true){ + // console.log($.toStr(res.result)) + console.log(`入会:${res.result.shopMemberCardInfo.venderCardName || ''}`) + $.shopactivityId = res.result.interestsRuleList && res.result.interestsRuleList[0] && res.result.interestsRuleList[0].interestsInfo && res.result.interestsRuleList[0].interestsInfo.activityId || '' + } + }else{ + console.log(data) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +// 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)} + diff --git a/activity/jd_opencardL72.js b/activity/jd_opencardL72.js new file mode 100644 index 0000000..ca386ae --- /dev/null +++ b/activity/jd_opencardL72.js @@ -0,0 +1,544 @@ +/* +2.10~2.16 联合开卡 +新增开卡脚本,一次性脚本 + +第一个账号助力作者 其他依次助力CK1 +第一个CK失效会退出脚本 + +———————————————— +入口:[ 2.10~2.16 联合开卡(https://jinggengjcq-isv.isvjcloud.com/fronth5/#/pages/unitedCardNew20220210/unitedCardNew20220210?actId=b802b95813e14b41ae_22021001)] + +请求太频繁会被黑ip +过10分钟再执行 + + +cron:55 0,19 10-16 2 * +============Quantumultx=============== +[task_local] +#2.10~2.16 联合开卡 +55 0,19 10-16 2 * jd_opencardL72.js, tag=2.10~2.16 联合开卡, enabled=true + +*/ + +const $ = new Env('2.10~2.16 联合开卡'); +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const notify = $.isNode() ? require('./sendNotify') : ''; + +//IOS等用户直接用NobyDa的jd cookie +let cookiesArr = [], + cookie = ''; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} + +allMessage = "" +message = "" +$.hotFlag = false +$.outFlag = false +$.activityEnd = false +let lz_jdpin_token_cookie ='' +let activityCookie ='' +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', { + "open-url": "https://bean.m.jd.com/" + }); + return; + } + // return + $.appkey = '51B59BB805903DA4CE513D29EC448375' + $.userId = '10299171' + $.actId = 'b802b95813e14b41ae_22021001' + $.MixNicks = '' + $.inviteNick = 'e4aHW8SbTt6Rgyvpai2f5ls/ye9oluZX4nOTK56TeMXbR7I2OlzZch4hTs22oCUS' + console.log(`活动地址:https://jinggengjcq-isv.isvjcloud.com/fronth5/#/pages/unitedCardNew20220210/unitedCardNew20220210?actId=b802b95813e14b41ae_22021001`) + console.log(`请自行测试有水无水。`) + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i]; + if (cookie) { + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + message = "" + $.bean = 0 + $.hotFlag = false + $.nickName = ''; + console.log(`\n\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + await getUA() + await run(); + if(i == 0 && !$.MixNick) break + if($.outFlag || $.activityEnd) break + } + } + if($.outFlag) { + let msg = '此ip已被限制,请过10分钟后再执行脚本' + $.msg($.name, ``, `${msg}`); + if ($.isNode()) await notify.sendNotify(`${$.name}`, `${msg}`); + } +})() + .catch((e) => $.logErr(e)) + .finally(() => $.done()) + + +async function run() { + try { + $.hasEnd = true + $.endTime = 0 + lz_jdpin_token_cookie = '' + $.Token = '' + $.Pin = '' + $.MixNick = '' + let flag = false + if($.activityEnd) return + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + await takePostRequest('isvObfuscator'); + if($.Token == ''){ + console.log('获取[token]失败!') + return + } + await takePostRequest('activity_load'); + if($.hotFlag) return + if(Date.now() > $.endTime){ + $.MixNick = '' + $.activityEnd = true + console.log('活动结束') + return + } + if ($.MixNick == '') { + console.log(`获取cookie失败`); return; + } + // console.log($.MixNick) + // return + $.toBind = 0 + $.openList = [] + await takePostRequest('绑定'); + await takePostRequest('shopList'); + if($.activityEnd) return + for(o of $.openList){ + $.missionType = 'openCard' + if(o.open != true && o.openCardUrl){ + if($.activityEnd) return + $.openCard = false + $.joinVenderId = o.userId + await takePostRequest('mission'); + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + if($.openCard == true){ + await joinShop() + await takePostRequest('activity_load'); + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + // break + } + $.joinVenderId = '' + } + } + $.joinVenderId = '' + if($.hasCollectShop === 0){ + // 关注 + $.missionType = 'uniteCollectShop' + await takePostRequest('mission'); + await $.wait(parseInt(Math.random() * 2000 + 3000, 10)) + }else{ + console.log('已经关注') + } + $.missionType = 'uniteAddCart' + + await takePostRequest('mission'); + await $.wait(parseInt(Math.random() * 2000 + 3000, 10)) + await takePostRequest('activity_load'); + $.runFalag = true + let count = parseInt($.usedChance, 10) + console.log(`抽奖次数为:${count}`) + for(m=1;count--;m++){ + console.log(`第${m}次抽奖`) + await takePostRequest('抽奖'); + if($.runFalag == false) break + if(Number(count) <= 0) break + if(m >= 10){ + console.log("抽奖太多次,多余的次数请再执行脚本") + break + } + await $.wait(parseInt(Math.random() * 2000 + 2000, 10)) + } + await takePostRequest('myAward'); + await takePostRequest('missionInviteList'); + console.log($.MixNick) + console.log(`当前助力:${$.inviteNick}`) + if($.index == 1){ + $.inviteNick = $.MixNick + console.log(`后面的号都会助力:${$.inviteNick}`) + } + await $.wait(parseInt(Math.random() * 1000 + 5000, 10)) + } catch (e) { + console.log(e) + } +} + +async function takePostRequest(type) { + if($.outFlag) return + let domain = 'https://jinggengjcq-isv.isvjcloud.com'; + let body = ``; + let method = 'POST' + let admJson = '' + switch (type) { + case 'isvObfuscator': + url = `https://api.m.jd.com/client.action?functionId=isvObfuscator`; + body = `body=%7B%22url%22%3A%22https%3A//jinggengjcq-isv.isvjcloud.com/fronth5/%3Flng%3D0%26lat%3D0%26sid%3D49687cd64aca2ae93aa43748a04e8f6w%26un_area%3D16_1315_1316_53522%23/pages/unitedCardNew20211010-ka/unitedCardNew20211010-ka%3FactId%3D9150e1d16b9d40_10101%22%2C%22id%22%3A%22%22%7D&uuid=b9b4ce69d42dacb64084279d51cdee764d7781fa&client=apple&clientVersion=10.1.4&st=1634100732991&sv=111&sign=67e254ffbcb13be9e12a9782c9cdf398`; + break; + case 'activity_load': + url = `${domain}/dm/front/openCardNew/activity_load?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"jdToken": $.Token, "source": "01", "inviteNick":($.inviteNick || "")} + if($.joinVenderId) admJson = {...admJson, "shopId": `${$.joinVenderId}`} + body = taskPostUrl("/openCardNew/activity_load", admJson); + break; + case 'shopList': + url = `${domain}/dm/front/openCardNew/shopList?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {} + body = taskPostUrl("/openCardNew/shopList", admJson); + break; + case '绑定': + url = `${domain}/dm/front/openCardNew/complete/mission?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"missionType": "relationBind", "inviterNick":($.inviteNick || "")} + body = taskPostUrl("/openCardNew/complete/mission", admJson); + break; + case 'mission': + url = `${domain}/dm/front/openCardNew/complete/mission?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"missionType": $.missionType} + if($.joinVenderId) admJson = {...admJson, "shopId": $.joinVenderId} + body = taskPostUrl("/openCardNew/complete/mission", admJson); + break; + case '抽奖': + url = `${domain}/dm/front/openCardNew/draw/post?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"dataType": "draw", "usedGameNum": "2"} + body = taskPostUrl("/openCardNew/draw/post", admJson); + break; + case 'followShop': + url = `${domain}/dm/front/openCardNew/followShop?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"actId": $.actId, "missionType": "collectShop"} + body = taskPostUrl("/openCardNew/followShop", admJson); + break; + case 'addCart': + url = `${domain}/dm/front/openCardNew/addCart?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"actId": $.actId, "missionType": "addCart"} + body = taskPostUrl("/openCardNew/addCart", admJson); + break; + case 'myAward': + url = `${domain}/dm/front/openCardNew/myAwards?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"pageNo": 1,"pageSize":9999} + body = taskPostUrl("/openCardNew/myAwards", admJson); + break; + case 'missionInviteList': + url = `${domain}/dm/front/openCardNew/missionInviteList?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"inviteListRequest":{"actId":$.actId,"userId":10299171,"missionType":"shareAct","inviteType": 1,"buyerNick":($.MixNick || '')}} + body = taskPostUrl("/openCardNew/missionInviteList", admJson); + break; + default: + console.log(`错误${type}`); + } + let myRequest = getPostRequest(url, body, method); + return new Promise(async resolve => { + $.post(myRequest, (err, resp, data) => { + try { + if (err) { + if(resp && resp.statusCode && resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + console.log(`${$.toStr(err,err)}`) + console.log(`${type} API请求失败,请检查网路重试`) + } else { + dealReturn(type, data); + } + } catch (e) { + // console.log(data); + console.log(e, resp) + } finally { + resolve(); + } + }) + }) + } + +async function dealReturn(type, data) { + let res = '' + try { + if(type != 'accessLogWithAD' || type != 'drawContent'){ + if(data){ + res = JSON.parse(data); + } + } + } catch (e) { + console.log(`${type} 执行任务异常`); + console.log(data); + $.runFalag = false; + } + try { + let title = '' + switch (type) { + case 'isvObfuscator': + if(typeof res == 'object'){ + if(res.errcode == 0){ + if(typeof res.token != 'undefined') $.Token = res.token + }else if(res.message){ + console.log(`${type} ${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + break; + case 'accessLogWithAD': + case 'drawContent': + break; + case 'activity_load': + case 'mission': + case 'shopList': + case 'loadUniteOpenCard': + case 'setMixNick': + case 'uniteOpenCardOne': + case 'checkOpenCard': + case 'followShop': + case 'addCart': + case 'myAward': + case 'missionInviteList': + case '抽奖': + title = '' + if(type == "followShop") title = '关注' + if(type == "addCart") title = '加购' + if(typeof res == 'object'){ + if(res.success && res.success === true && res.data){ + if(res.data.status && res.data.status == 200){ + res = res.data + if(type != "setMixNick" && (res.msg || res.data.isOpenCard || res.data.remark)) console.log(`${title && title+":" || ""}${res.msg || res.data.isOpenCard || res.data.remark || ''}`) + if(type == "activity_load"){ + if(res.msg || res.data.isOpenCard) { + if((res.msg || res.data.isOpenCard || '').indexOf('绑定成功') > -1) $.toBind = 1 + } + if(res.data){ + $.endTime = res.data.cusActivity.endTime || 0 + $.MixNick = res.data.buyerNick || "" + $.usedChance = res.data.missionCustomer.usedChance || 0 + $.hasCollectShop = res.data.missionCustomer.hasCollectShop || 0 + } + }else if(type == "shopList"){ + $.openList = res.data.cusShops || [] + }else if(type == "mission"){ + if(res.data.remark.indexOf('不是会员') > -1){ + $.openCard = true + }else{ + $.openCard = false + } + }else if(type == "uniteOpenCardOne"){ + $.uniteOpenCar = res.msg || res.data.msg || '' + }else if(type == "myAward"){ + console.log(`我的奖品:`) + let num = 0 + let value = 0 + for(let i in res.data.list || []){ + let item = res.data.list[i] + value += Number(item.awardDes) + } + if(value > 0) console.log(`共获得${value}京豆\n无法判断奖励是否为邀请奖励,所以直接显示获得多少豆\n`) + }else if(type == "missionInviteList"){ + console.log(`邀请人数(${res.data.invitedLogList.total})`) + } + }else if(res.data.msg){ + if(res.errorMessage.indexOf('活动未开始') >-1 ){ + $.activityEnd = true + } + console.log(`${title || type} ${res.data.msg || ''}`) + }else if(res.errorMessage){ + if(res.errorMessage.indexOf('火爆') >-1 ){ + $.hotFlag = true + } + console.log(`${title || type} ${res.errorMessage || ''}`) + }else{ + console.log(`${title || type} ${data}`) + } + }else if(res.errorMessage){ + console.log(`${title || type} ${res.errorMessage || ''}`) + }else{ + console.log(`${title || type} ${data}`) + } + }else{ + console.log(`${title || type} ${data}`) + } + break; + default: + console.log(`${title || type}-> ${data}`); + } + if(typeof res == 'object'){ + if(res.errorMessage){ + if(res.errorMessage.indexOf('火爆') >-1 ){ + $.hotFlag = true + } + } + } + } catch (e) { + console.log(e) + } +} + +function getPostRequest(url, body, method="POST") { + let headers = { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Content-Type": "application/x-www-form-urlencoded", + "Cookie": cookie, + "User-Agent": $.UA, + "X-Requested-With": "XMLHttpRequest" + } + if(url.indexOf('https://jinggengjcq-isv.isvjcloud.com') > -1){ + headers["Origin"] = `https://jinggengjcq-isv.isvjcloud.com` + headers["Content-Type"] = `application/json; charset=utf-8` + delete headers["Cookie"] + } + // console.log(headers) + // console.log(headers.Cookie) + return {url: url, method: method, headers: headers, body: body, timeout:60000}; +} + + +function taskPostUrl(url, t) { + + const b = { + "jsonRpc": "2.0", + "params": { + "commonParameter": { + "appkey": $.appkey, + "m": "POST", + "timestamp": Date.now(), + "userId": $.userId + }, + "admJson": { + "actId": $.actId, + "userId": $.userId, + ...t, + "method": url, + "buyerNick": ($.MixNick || ''), + } + }, + } + if(url.indexOf('missionInviteList') > -1){ + delete b.params.admJson.actId + } + return $.toStr(b,b) +} +async function getUA(){ + $.UA = `jdapp;iPhone;10.1.4;13.1.2;${randomString(40)};network/wifi;model/iPhone8,1;addressid/2308460611;appBuild/167814;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_1_2 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 jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} + +function joinShop() { + if(!$.joinVenderId) return + return new Promise(async resolve => { + $.shopactivityId = '' + await $.wait(1000) + await getshopactivityId() + let activityId = `` + if($.shopactivityId) activityId = `,"activityId":${$.shopactivityId}` + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body={"venderId":"${$.joinVenderId}","shopId":"${$.joinVenderId}","bindByVerifyCodeFlag":1,"registerExtend":{},"writeChildFlag":0${activityId},"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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + // console.log(data) + let res = $.toObj(data,data); + if(typeof res == 'object'){ + if(res.success === true){ + console.log(res.message) + if(res.result && res.result.giftInfo){ + for(let i of res.result.giftInfo.giftList){ + console.log(`入会获得:${i.discountString}${i.prizeName}${i.secondLineDesc}`) + } + } + }else if(typeof res == 'object' && res.message){ + console.log(`${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function getshopactivityId() { + return new Promise(resolve => { + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body=%7B%22venderId%22%3A%22${$.joinVenderId}%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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + let res = $.toObj(data,data); + if(typeof res == 'object'){ + if(res.success == true){ + // console.log($.toStr(res.result)) + console.log(`入会:${res.result.shopMemberCardInfo.venderCardName || ''}`) + $.shopactivityId = res.result.interestsRuleList && res.result.interestsRuleList[0] && res.result.interestsRuleList[0].interestsInfo && res.result.interestsRuleList[0].interestsInfo.activityId || '' + } + }else{ + console.log(data) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +// 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)} + diff --git a/activity/jd_opencardL77.js b/activity/jd_opencardL77.js new file mode 100644 index 0000000..1246456 --- /dev/null +++ b/activity/jd_opencardL77.js @@ -0,0 +1,524 @@ +/* +2.18-2.28 联合关注 +新增开卡脚本 一次性脚本 + +第一个账号助力作者 其他依次助力CK1 +第一个CK失效会退出脚本 + +———————————————— +入口:[ 2.18-2.28 联合关注 (https://lzdz-isv.isvjcloud.com/welfare/unite/activity?activityId=1eca438e9a484de0960115fc7088a7c6&shareUuid=05ee99c9babc4cb6a8132d3383d26f69)] + +请求太频繁会被黑ip +过10分钟再执行 + +============Quantumultx=============== +[task_local] +#2.18-2.28 联合关注 +40 11 * * * jd_opencardL77.js, tag=2.18-2.28 联合关注, enabled=true + +*/ +let guaunknownTask_addSku = "true" +let guaopenwait = "0" + +const $ = new Env('2.18-2.28 联合关注'); +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const notify = $.isNode() ? require('./sendNotify') : ''; +//IOS等用户直接用NobyDa的jd cookie + +let cookiesArr = [], + cookie = ''; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} +allMessage = "" +message = "" +$.hotFlag = false +$.outFlag = false +$.activityEnd = false +let lz_jdpin_token_cookie ='' +let activityCookie ='' +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', { + "open-url": "https://bean.m.jd.com/" + }); + return; + } + $.activityId = "4e54fef7014a4651bdad42ec33a51816" + $.shareUuid = "4c913f89a6014e27a5daf158ee7c3491" + $.venderIds = "1000398820" + console.log(`入口:\nhttps://lzdz-isv.isvjcloud.com/welfare/unite/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}`) + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i]; + if (cookie) { + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + message = "" + $.bean = 0 + $.hotFlag = false + $.nickName = ''; + console.log(`\n\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + await getUA() + await run(); + if(i == 0 && !$.actorUuid) break + if($.outFlag || $.activityEnd) break + } + } + if($.outFlag) { + let msg = '此ip已被限制,请过10分钟后再执行脚本' + $.msg($.name, ``, `${msg}`); + if ($.isNode()) await notify.sendNotify(`${$.name}`, `${msg}`); + } +})() + .catch((e) => $.logErr(e)) + .finally(() => $.done()) + + +async function run() { + try { + $.hasEnd = true + $.endTime = 0 + lz_jdpin_token_cookie = '' + $.Token = '' + $.Pin = '' + let flag = false + await takePostRequest('isvObfuscator'); + if($.Token == ''){ + console.log('获取[token]失败!') + return + } + await getCk() + if (activityCookie == '') { + console.log(`获取cookie失败`); return; + } + if($.activityEnd === true){ + console.log('活动结束') + return + } + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + await takePostRequest('getMyPing'); + if(!$.Pin){ + console.log('获取[Pin]失败!') + return + } + await takePostRequest('accessLogWithAD'); + await takePostRequest('getUserInfo'); + await takePostRequest('activityContent'); + if(!$.actorUuid){ + console.log('获取不到[actorUuid]退出执行,请重新执行') + return + } + if($.hasEnd === true || Date.now() > $.endTime){ + $.activityEnd = true + console.log('活动结束') + return + } + await takePostRequest('drawContent'); + await $.wait(1000) + if($.taskData.followShop){ + $.log("关注: " + $.taskData.followShop.allStatus) + if(!$.taskData.followShop.allStatus && !$.outFlag){ + flag = true + $.taskType = 23 + await takePostRequest('关注'); + await $.wait(parseInt(Math.random() * 2000 + 3000, 10)) + } + } + if($.taskData.followSku){ + $.log("关注: " + $.taskData.followSku.allStatus) + if(!$.taskData.followSku.allStatus && !$.outFlag){ + flag = true + $.taskType = 22 + await takePostRequest('关注'); + await $.wait(parseInt(Math.random() * 2000 + 3000, 10)) + } + } + if($.taskData.addSku){ + $.log("加购: " + $.taskData.addSku.allStatus) + if(!$.taskData.addSku.allStatus && !$.outFlag){ + flag = true + $.taskType = 21 + await takePostRequest('加购'); + await $.wait(parseInt(Math.random() * 2000 + 3000, 10)) + } + } + + await $.wait(parseInt(Math.random() * 1000 + 2000, 10)) + await takePostRequest('getShareRecord'); + if($.totalCount > 0){ + let m = $.totalCount + do{ + await takePostRequest('领取奖励'); + await $.wait(parseInt(Math.random() * 1000 + 2000, 10)) + m--; + }while (m > 0) + } + await takePostRequest('getDrawRecordHasCoupon'); + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + console.log($.actorUuid) + console.log(`当前助力:${$.shareUuid}`) + if($.index == 1){ + $.shareUuid = $.actorUuid + console.log(`后面的号都会助力:${$.shareUuid}`) + } + return + await $.wait(parseInt(Math.random() * 1000 + 5000, 10)) + if(flag) await $.wait(parseInt(Math.random() * 1000 + 10000, 10)) + if($.index % 3 == 0) console.log('休息1分钟,别被黑ip了\n可持续发展') + if($.index % 3 == 0) await $.wait(parseInt(Math.random() * 5000 + 60000, 10)) + + } catch (e) { + console.log(e) + } +} + +async function takePostRequest(type) { + if($.outFlag) return + let url = 'https://lzdz-isv.isvjcloud.com'; + let body = ``; + let method = 'POST' + let admJson = '' + switch (type) { + case 'isvObfuscator': + url = `https://api.m.jd.com/client.action?functionId=isvObfuscator`; + body = `body=%7B%22url%22%3A%22https%3A//lzdz-isv.isvjcloud.com%22%2C%22id%22%3A%22%22%7D&uuid=f37a4d8b094434f55b3d8b97f53aa659e649fe06&client=apple&clientVersion=10.1.4&st=1634180373571&sv=120&sign=ec39c5ee3223426f01f88b843f898db1`; + break; + case 'getMyPing': + url = `${url}/customer/getMyPing`; + body = `userId=${$.shopId || $.venderId || $.venderIds || ''}&token=${$.Token}&fromType=APP`; + break; + case 'accessLogWithAD': + let pageurl = `${url}/drawCenter/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}` + url = `${url}/common/accessLogWithAD`; + body = `venderId=${$.shopId || $.venderId || $.venderIds || ''}&code=99&pin=${encodeURIComponent($.Pin)}&activityId=${$.activityId}&pageUrl=${encodeURIComponent(pageurl)}&subType=app&adSource=` + break; + case 'getUserInfo': + url = `${url}/wxActionCommon/getUserInfo`; + body = `pin=${encodeURIComponent($.Pin)}`; + break; + case 'activityContent': + url = `${url}/welfare/unite/activityContent`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&pinImg=${encodeURIComponent($.attrTouXiang)}&nick=${encodeURIComponent($.nickname)}&shareUuid=${$.shareUuid}` + break; + case 'drawContent': + url = `${url}/dingzhi/taskact/openCardcommon/drawContent`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case '关注': + case '加购': + url = `${url}/welfare/unite/saveTask`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&taskType=${$.taskType}&shareUuid=${$.shareUuid}` + break; + case '领取奖励': + url = `${url}/welfare/unite/getInfo`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case 'getDrawRecordHasCoupon': + url = `${url}/dingzhi/taskact/common/getDrawRecordHasCoupon`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case 'getShareRecord': + url = `${url}/welfare/unite/getAssistInfo`; + body = `activityId=${$.activityId}&actorUuid=${$.actorUuid}&sortStatus=1` + break; + default: + console.log(`错误${type}`); + } + let myRequest = getPostRequest(url, body, method); + // console.log(myRequest) + return new Promise(async resolve => { + $.post(myRequest, (err, resp, data) => { + try { + setActivityCookie(resp) + if (err) { + if(resp && typeof resp.statusCode != 'undefined'){ + if(resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + } + console.log(`${$.toStr(err,err)}`) + console.log(`${type} API请求失败,请检查网路重试`) + } else { + dealReturn(type, data); + } + } catch (e) { + // console.log(data); + console.log(e, resp) + } finally { + resolve(); + } + }) + }) + } + +async function dealReturn(type, data) { + let res = '' + try { + if(type != 'accessLogWithAD' || type != 'drawContent'){ + if(data){ + res = JSON.parse(data); + } + } + } catch (e) { + console.log(`${type} 执行任务异常`); + console.log(data); + $.runFalag = false; + } + try { + switch (type) { + case 'isvObfuscator': + if(typeof res == 'object'){ + if(res.errcode == 0){ + if(typeof res.token != 'undefined') $.Token = res.token + }else if(res.message){ + console.log(`isvObfuscator ${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + break; + case 'getMyPing': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(res.data && typeof res.data.secretPin != 'undefined') $.Pin = res.data.secretPin + if(res.data && typeof res.data.nickname != 'undefined') $.nickname = res.data.nickname + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getUserInfo': + $.attrTouXiang = "https://img10.360buyimg.com/imgzone/jfs/t1/7020/27/13511/6142/5c5138d8E4df2e764/5a1216a3a5043c5d.png" + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(res.data && typeof res.data.yunMidImageUrl != 'undefined') $.attrTouXiang = res.data.yunMidImageUrl || $.attrTouXiang + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'activityContent': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + $.endTime = res.data.endTime || res.data.activity.endTime || 0 + $.hasEnd = res.data.hasEnd || false + $.taskData = res.data.taskData || {} + $.actorUuid = res.data.actorUuid || '' + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case '抽奖': + case '关注': + case '加购': + case '领取奖励': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(typeof res.data == 'object'){ + let msg = '' + let title = type + if(res.data.drawResult){ + msg += (res.data.drawResult.drawOk == true && res.data.drawResult.value+'京豆') || '空气💨' + } + if(res.data.addPoint){ + msg += ` ${res.data.addPoint}游戏机会` + } + console.log(`${title}获得:${msg || data}`) + }else{ + console.log(`${type} ${data}`) + } + }else if(res.errorMessage){ + $.runFalag = false; + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getDrawRecordHasCoupon': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + let value = 0 + for(let i in res.data){ + let item = res.data[i] + if(item.infoName.indexOf('京豆') > -1){ + value += Number(item.infoName.replace('京豆','')) || 0 + } + } + if(value > 0) console.log(`共获得${parseInt(value, 10) || 0}京豆`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getShareRecord': + if(typeof res == 'object'){ + if(res.result && res.result === true && res.data){ + console.log(`领取机会(${res.data.hasDrawTimes}/10) 可领取奖励${res.data.totalCount}次`) + $.totalCount = res.data.totalCount + $.log(`=========== 你邀请了:${res.data.shareRecord.length}个`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'accessLogWithAD': + case 'drawContent': + break; + default: + console.log(`${type}-> ${data}`); + } + if(typeof res == 'object'){ + if(res.errorMessage){ + if(res.errorMessage.indexOf('火爆') >-1 ){ + $.hotFlag = true + } + } + } + } catch (e) { + console.log(e) + } +} + +function getPostRequest(url, body, method="POST") { + let headers = { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Content-Type": "application/x-www-form-urlencoded", + "Cookie": cookie, + "User-Agent": $.UA, + "X-Requested-With": "XMLHttpRequest" + } + if(url.indexOf('https://lzdz-isv.isvjcloud.com') > -1){ + headers["Referer"] = `https://lzdz-isv.isvjcloud.com/welfare/unite/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}` + headers["Origin"] = `https://lzdz-isv.isvjcloud.com` + headers["Cookie"] = `${lz_jdpin_token_cookie && lz_jdpin_token_cookie || ''}${$.Pin && "AUTH_C_USER=" + $.Pin + ";" || ""}${activityCookie}` + } + return {url: url, method: method, headers: headers, body: body, timeout:30000}; +} + +function getCk() { + return new Promise(resolve => { + let get = { + url:`https://lzdz-isv.isvjcloud.com/welfare/unite/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}`, + headers: { + "User-Agent": $.UA, + }, + timeout:30000 + } + $.get(get, async(err, resp, data) => { + try { + if (err) { + if(resp && typeof resp.statusCode != 'undefined'){ + if(resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + } + console.log(`${$.toStr(err)}`) + console.log(`${$.name} cookie API请求失败,请检查网路重试`) + } else { + let end = data.match(/(活动已经结束)/) && data.match(/(活动已经结束)/)[1] || '' + if(end){ + $.activityEnd = true + console.log('活动已结束') + } + setActivityCookie(resp) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function setActivityCookie(resp){ + let LZ_TOKEN_KEY = '' + let LZ_TOKEN_VALUE = '' + let lz_jdpin_token = '' + let setcookies = resp && resp['headers'] && (resp['headers']['set-cookie'] || resp['headers']['Set-Cookie'] || '') || '' + let setcookie = '' + if(setcookies){ + if(typeof setcookies != 'object'){ + setcookie = setcookies.split(',') + }else setcookie = setcookies + for (let ck of setcookie) { + let name = ck.split(";")[0].trim() + if(name.split("=")[1]){ + // console.log(name.replace(/ /g,'')) + if(name.indexOf('LZ_TOKEN_KEY=')>-1) LZ_TOKEN_KEY = name.replace(/ /g,'')+';' + if(name.indexOf('LZ_TOKEN_VALUE=')>-1) LZ_TOKEN_VALUE = name.replace(/ /g,'')+';' + if(name.indexOf('lz_jdpin_token=')>-1) lz_jdpin_token = ''+name.replace(/ /g,'')+';' + } + } + } + if(LZ_TOKEN_KEY && LZ_TOKEN_VALUE) activityCookie = `${LZ_TOKEN_KEY} ${LZ_TOKEN_VALUE}` + if(lz_jdpin_token) lz_jdpin_token_cookie = lz_jdpin_token +} + +async function getUA(){ + $.UA = `jdapp;iPhone;10.1.4;13.1.2;${randomString(40)};network/wifi;model/iPhone8,1;addressid/2308460611;appBuild/167814;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_1_2 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 jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} + + +// 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)} diff --git a/activity/jd_opencardLH29.js b/activity/jd_opencardLH29.js new file mode 100644 index 0000000..cdf2f48 --- /dev/null +++ b/activity/jd_opencardLH29.js @@ -0,0 +1,750 @@ +/* +12.12~12.20 狂欢购 [jd_opencardLH29.js] +新增开卡脚本 +一次性脚本 + +1.邀请一人10豆 +2.开2组(共9张) 成功开1组 获得1次抽奖 + 抽奖可获得30豆 +3.关注10豆 +4.加购5京豆 +5.浏览店铺1豆/个 +6.浏览商品1豆/个 + +第一个账号助力作者 其他依次助力CK1 +第一个CK失效会退出脚本 + +———————————————— +入口:[ 12.12~12.20 狂欢购 (https://lzdz1-isv.isvjcloud.com/dingzhi/dz/openCard/activity?activityId=dzcjlhkk20211212&shareUuid=051bbdf4a0494e96a101de2d628e57b3)] + +请求太频繁会被黑ip +过10分钟再执行 + +cron:57 3,20 12-20 12 * +============Quantumultx=============== +[task_local] +#12.12~12.20 狂欢购 +57 3,20 12-20 12 * https://raw.githubusercontent.com/KingRan/JDJB/main/jd_opencardLH29.js, tag=12.12~12.20 狂欢购, enabled=true + +*/ + + +const $ = new Env('12.12~12.20 狂欢购'); +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const notify = $.isNode() ? require('./sendNotify') : ''; + +//IOS等用户直接用NobyDa的jd cookie + +let cookiesArr = [], + cookie = ''; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} + +allMessage = "" +message = "" +$.hotFlag = false +$.outFlag = false +$.activityEnd = false +let lz_jdpin_token_cookie ='' +let activityCookie ='' +!(async () => { + + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', { + "open-url": "https://bean.m.jd.com/" + }); + return; + } + $.activityId = "dzcjlhkk20211212" + $.shareUuid = "051bbdf4a0494e96a101de2d628e57b3" + console.log(`入口:\nhttps://lzdz1-isv.isvjcloud.com/dingzhi/dz/openCard/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}`) + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i]; + if (cookie) { + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + message = "" + $.bean = 0 + $.hotFlag = false + $.nickName = ''; + console.log(`\n\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + await getUA() + await run(); + if(i == 0 && !$.actorUuid) break + if($.outFlag || $.activityEnd) break + } + } + if($.outFlag) { + let msg = '此ip已被限制,请过10分钟后再执行脚本' + $.msg($.name, ``, `${msg}`); + if ($.isNode()) await notify.sendNotify(`${$.name}`, `${msg}`); + } +})() + .catch((e) => $.logErr(e)) + .finally(() => $.done()) + + +async function run() { + try { + $.hasEnd = true + $.endTime = 0 + lz_jdpin_token_cookie = '' + $.Token = '' + $.Pin = '' + let flag = false + await takePostRequest('isvObfuscator'); + if($.Token == ''){ + console.log('获取[token]失败!') + return + } + await getCk() + if (activityCookie == '') { + console.log(`获取cookie失败`); return; + } + if($.activityEnd === true){ + console.log('活动结束') + return + } + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + await takePostRequest('getSimpleActInfoVo'); + await takePostRequest('getMyPing'); + if(!$.Pin){ + console.log('获取[Pin]失败!') + return + } + await takePostRequest('accessLogWithAD'); + await takePostRequest('getUserInfo'); + await takePostRequest('activityContent'); + if($.hotFlag) return + if(!$.actorUuid){ + console.log('获取不到[actorUuid]退出执行,请重新执行') + return + } + if($.hasEnd === true || Date.now() > $.endTime){ + $.activityEnd = true + console.log('活动结束') + return + } + await takePostRequest('drawContent'); + await $.wait(1000) + $.openList = [] + $.allOpenCard = false + await takePostRequest('checkOpenCard'); + if($.allOpenCard == false){ + console.log('开卡任务') + for(o of $.openList){ + $.openCard = false + if(o.status == 0){ + flag = true + $.joinVenderId = o.value + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + await joinShop() + await $.wait(parseInt(Math.random() * 1000 + 1000, 10)) + await takePostRequest('drawContent'); + await takePostRequest('checkOpenCard'); + await $.wait(parseInt(Math.random() * 3000 + 2000, 10)) + } + } + await takePostRequest('activityContent'); + }else{ + console.log('已全部开卡') + } + if($.openCardScore1 == 1 && !$.outFlag){ + $.startDraw = 1 + flag = true + await takePostRequest('startDraw'); + await $.wait(parseInt(Math.random() * 1000 + 3000, 10)) + } + if($.openCardScore2 == 1 && !$.outFlag){ + $.startDraw = 2 + flag = true + await takePostRequest('startDraw'); + await $.wait(parseInt(Math.random() * 1000 + 3000, 10)) + } + + $.log("关注: " + $.followShop) + if(!$.followShop && !$.outFlag){ + flag = true + await takePostRequest('followShop'); + await $.wait(parseInt(Math.random() * 1000 + 5000, 10)) + } + $.log("加购: " + $.addSku) + if(!$.addSku && !$.outFlag){ + flag = true + await takePostRequest('addSku'); + await $.wait(parseInt(Math.random() * 1000 + 5000, 10)) + } + $.runFalag = true + $.log("浏览店铺: " + $.toShop) + if(!$.toShop && !$.outFlag){ + flag = true + for(let v of $.toShopList || []){ + if($.runFalag == false) break + if(v.value && v.status === 0){ + $.toShopValue = v.value + await takePostRequest('toShop'); + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + } + } + } + $.runFalag = true + $.log("浏览商品: " + $.visitSku) + if(!$.visitSku && !$.outFlag){ + flag = true + for(let v of $.visitSkuList || []){ + if($.runFalag == false) break + if(v.value && v.status === 0){ + $.visitSkuValue = v.value + await takePostRequest('visitSku'); + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + } + } + } + if(flag){ + await takePostRequest('activityContent'); + } + await $.wait(parseInt(Math.random() * 1000 + 2000, 10)) + //await takePostRequest('getDrawRecordHasCoupon'); + //await takePostRequest('getShareRecord'); + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + console.log($.actorUuid) + console.log(`当前助力:${$.shareUuid}`) + if($.index == 1){ + $.shareUuid = $.actorUuid + console.log(`后面的号都会助力:${$.shareUuid}`) + } + await $.wait(parseInt(Math.random() * 1000 + 5000, 10)) + if(flag) await $.wait(parseInt(Math.random() * 1000 + 10000, 10)) + if($.index % 3 == 0) console.log('休息1分钟,别被黑ip了\n可持续发展') + if($.index % 3 == 0) await $.wait(parseInt(Math.random() * 5000 + 60000, 10)) + } catch (e) { + console.log(e) + } +} + +async function takePostRequest(type) { + if($.outFlag) return + let domain = 'https://lzdz1-isv.isvjcloud.com'; + let body = ``; + let method = 'POST' + let admJson = '' + switch (type) { + case 'isvObfuscator': + url = `https://api.m.jd.com/client.action?functionId=isvObfuscator`; + body = `body=%7B%22url%22%3A%22https%3A//lzdz1-isv.isvjcloud.com%22%2C%22id%22%3A%22%22%7D&uuid=0846724fe8d803b8e84ebd14b3ba7fac6df80e7a&client=apple&clientVersion=10.1.4&st=1634616247215&sv=120&sign=91a16ae2feb0bd0e1ea48d99e7953c58`; + break; + case 'getSimpleActInfoVo': + url = `${domain}/dz/common/getSimpleActInfoVo`; + body = `activityId=${$.activityId}`; + break; + case 'getMyPing': + url = `${domain}/customer/getMyPing`; + body = `userId=${$.shopId || $.venderId || ''}&token=${$.Token}&fromType=APP`; + break; + case 'accessLogWithAD': + url = `${domain}/common/accessLogWithAD`; + let pageurl = `${domain}/drawCenter/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}` + body = `venderId=${$.shopId || $.venderId || ''}&code=99&pin=${encodeURIComponent($.Pin)}&activityId=${$.activityId}&pageUrl=${encodeURIComponent(pageurl)}&subType=app&adSource=` + break; + case 'getUserInfo': + url = `${domain}/wxActionCommon/getUserInfo`; + body = `pin=${encodeURIComponent($.Pin)}`; + break; + case 'activityContent': + url = `${domain}/dingzhi/dz/openCard/activityContent`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&pinImg=${encodeURIComponent($.attrTouXiang)}&nick=${encodeURIComponent($.nickname)}&cjyxPin=&cjhyPin=&shareUuid=${$.shareUuid}` + break; + case 'drawContent': + url = `${domain}/dingzhi/taskact/openCardcommon/drawContent`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case 'checkOpenCard': + url = `${domain}/dingzhi/dz/openCard/checkOpenCard`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&shareUuid=${$.shareUuid}` + break; + case 'startDraw': + url = `${domain}/dingzhi/dz/openCard/startDraw`; + body = `activityId=${$.activityId}&actorUuid=${$.actorUuid}&pin=${encodeURIComponent($.Pin)}${$.startDraw && '&type='+$.startDraw || ''}` + break; + case 'followShop': + url = `${domain}/dingzhi/dz/openCard/followShop`; + // url = `${domain}/dingzhi/dz/openCard/saveTask`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&shareUuid=${$.shareUuid}&taskType=23&taskValue=${$.followShopValue}` + break; + case 'viewVideo': + case 'visitSku': + case 'toShop': + case 'addSku': + url = `${domain}/dingzhi/dz/openCard/saveTask`; + let taskType = '' + let taskValue = '' + if(type == 'viewVideo'){ + taskType = 31 + taskValue = 31 + }else if(type == 'visitSku'){ + taskType = 5 + taskValue = $.visitSkuValue || 5 + }else if(type == 'toShop'){ + taskType = 14 + taskValue = $.toShopValue || 14 + }else if(type == 'addSku'){ + taskType = 2 + taskValue = $.addSkuValue || 2 + } + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&taskType=${taskType}&taskValue=${taskValue}` + break; + case 'getDrawRecordHasCoupon': + url = `${domain}/dingzhi/taskact/openCardcommon/getDrawRecordHasCoupon`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case 'getShareRecord': + url = `${domain}/dingzhi/taskact/openCardcommon/getShareRecord`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + default: + console.log(`错误${type}`); + } + let myRequest = getPostRequest(url, body, method); + // console.log(myRequest) + return new Promise(async resolve => { + $.post(myRequest, (err, resp, data) => { + try { + setActivityCookie(resp) + if (err) { + if(resp && typeof resp.statusCode != 'undefined'){ + if(resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + } + console.log(`${$.toStr(err,err)}`) + console.log(`${type} API请求失败,请检查网路重试`) + } else { + dealReturn(type, data); + } + } catch (e) { + // console.log(data); + console.log(e, resp) + } finally { + resolve(); + } + }) + }) + } + +async function dealReturn(type, data) { + let res = '' + try { + if(type != 'accessLogWithAD' || type != 'drawContent'){ + if(data){ + res = JSON.parse(data); + } + } + } catch (e) { + console.log(`${type} 执行任务异常`); + console.log(data); + $.runFalag = false; + } + try { + switch (type) { + case 'isvObfuscator': + if(typeof res == 'object'){ + if(res.errcode == 0){ + if(typeof res.token != 'undefined') $.Token = res.token + }else if(res.message){ + console.log(`isvObfuscator ${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + break; + case 'getSimpleActInfoVo': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(typeof res.data.shopId != 'undefined') $.shopId = res.data.shopId + if(typeof res.data.venderId != 'undefined') $.venderId = res.data.venderId + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getMyPing': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(res.data && typeof res.data.secretPin != 'undefined') $.Pin = res.data.secretPin + if(res.data && typeof res.data.nickname != 'undefined') $.nickname = res.data.nickname + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getUserInfo': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(res.data && typeof res.data.yunMidImageUrl != 'undefined') $.attrTouXiang = res.data.yunMidImageUrl || "https://img10.360buyimg.com/imgzone/jfs/t1/7020/27/13511/6142/5c5138d8E4df2e764/5a1216a3a5043c5d.png" + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'activityContent': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + $.endTime = res.data.endTime || 0 + $.hasEnd = res.data.hasEnd || false + $.actorUuid = res.data.actorUuid || '' + $.followShop = res.data.followShop.allStatus || false + $.addSku = res.data.addSku.allStatus || false + if(res.data.followShop && res.data.followShop.settings && res.data.followShop.settings[0]){ + $.followShopValue = res.data.followShop.settings[0].value || 1 + } + if(res.data.addSku && res.data.addSku.settings && res.data.addSku.settings[0]){ + $.addSkuValue = res.data.addSku.settings[0].value || 2 + } + $.toShop = res.data.toShop.allStatus || false + $.toShopList = res.data.toShop.settings || [] + $.visitSku = res.data.visitSku.allStatus || false + $.visitSkuList = res.data.visitSku.settings || [] + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'checkOpenCard': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + let cardList1 = res.data.cardList1 || [] + let cardList2 = res.data.cardList2 || [] + let cardList = res.data.cardList || [] + $.openList = [...cardList,...cardList1,...cardList2] + $.allOpenCard = res.data.allOpenCard || false + $.openCardScore1 = res.data.score1 || 0 + $.openCardScore2 = res.data.score2 || 0 + $.drawScore = res.data.drawScore || 0 + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'startDraw': + case 'followShop': + case 'viewVideo': + case 'visitSku': + case 'toShop': + case 'addSku': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(typeof res.data == 'object'){ + let msg = '' + let title = '抽奖' + if(res.data.addBeanNum && res.data.sendStatus){ + msg = `${res.data.addBeanNum}京豆` + } + if(type == 'followShop'){ + title = '关注' + if(res.data.beanNumMember && res.data.assistSendStatus){ + msg += ` 额外获得:${res.data.beanNumMember}京豆` + } + }else if(type == 'addSku'){ + title = '加购' + }else if(type == 'viewVideo'){ + title = '热门文章' + }else if(type == 'toShop'){ + title = '浏览店铺' + }else if(type == 'visitSku'){ + title = '浏览商品' + }else{ + msg = res.data.drawOk == true && (res.data.drawInfoType == 6 && res.data.name || '') || '空气💨' + } + if(!msg){ + msg = '空气💨' + } + console.log(`${title}获得:${msg || data}`) + }else{ + console.log(`${type} ${data}`) + } + }else if(res.errorMessage){ + $.runFalag = false; + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getDrawRecordHasCoupon': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + console.log(`我的奖品:`) + let num = 0 + let value = 0 + for(let i in res.data){ + let item = res.data[i] + if(item.value == '邀请好友') num++; + if(item.value == '邀请好友') value = item.infoName.replace('京豆',''); + if(item.value != '邀请好友') console.log(`${item.infoType != 10 && item.value +':' || ''}${item.infoName}`) + } + if(num > 0) console.log(`邀请好友(${num}):${num*parseInt(value, 10) || 30}京豆`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getShareRecord': + if(typeof res == 'object'){ + if(res.result && res.result === true && res.data){ + $.ShareCount = res.data.length + $.log(`=========== 你邀请了:${res.data.length}个`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'accessLogWithAD': + case 'drawContent': + break; + default: + console.log(`${type}-> ${data}`); + } + if(typeof res == 'object'){ + if(res.errorMessage){ + if(res.errorMessage.indexOf('火爆') >-1 ){ + $.hotFlag = true + } + } + } + } catch (e) { + console.log(e) + } +} + +function getPostRequest(url, body, method="POST") { + let headers = { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Content-Type": "application/x-www-form-urlencoded", + "Cookie": cookie, + "User-Agent": $.UA, + "X-Requested-With": "XMLHttpRequest" + } + if(url.indexOf('https://lzdz1-isv.isvjcloud.com') > -1){ + headers["Referer"] = `https://lzdz1-isv.isvjcloud.com/dingzhi/dz/openCard/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}` + headers["Cookie"] = `${lz_jdpin_token_cookie && lz_jdpin_token_cookie || ''}${$.Pin && "AUTH_C_USER=" + $.Pin + ";" || ""}${activityCookie}` + } + // console.log(headers) + // console.log(headers.Cookie) + return {url: url, method: method, headers: headers, body: body, timeout:30000}; +} + +function getCk() { + return new Promise(resolve => { + let get = { + url:`https://lzdz1-isv.isvjcloud.com/dingzhi/dz/openCard/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}`, + followRedirect:false, + headers: { + "User-Agent": $.UA, + }, + timeout:30000 + } + $.get(get, async(err, resp, data) => { + try { + if (err) { + if(resp && typeof resp.statusCode != 'undefined'){ + if(resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + } + console.log(`${$.toStr(err)}`) + console.log(`${$.name} cookie API请求失败,请检查网路重试`) + } else { + let end = data.match(/(活动已经结束)/) && data.match(/(活动已经结束)/)[1] || '' + if(end){ + $.activityEnd = true + console.log('活动已结束') + } + setActivityCookie(resp) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function setActivityCookie(resp){ + let LZ_TOKEN_KEY = '' + let LZ_TOKEN_VALUE = '' + let lz_jdpin_token = '' + let setcookies = resp && resp['headers'] && (resp['headers']['set-cookie'] || resp['headers']['Set-Cookie'] || '') || '' + let setcookie = '' + if(setcookies){ + if(typeof setcookies != 'object'){ + setcookie = setcookies.split(',') + }else setcookie = setcookies + for (let ck of setcookie) { + let name = ck.split(";")[0].trim() + if(name.split("=")[1]){ + // console.log(name.replace(/ /g,'')) + if(name.indexOf('LZ_TOKEN_KEY=')>-1) LZ_TOKEN_KEY = name.replace(/ /g,'')+';' + if(name.indexOf('LZ_TOKEN_VALUE=')>-1) LZ_TOKEN_VALUE = name.replace(/ /g,'')+';' + if(name.indexOf('lz_jdpin_token=')>-1) lz_jdpin_token = ''+name.replace(/ /g,'')+';' + } + } + } + if(LZ_TOKEN_KEY && LZ_TOKEN_VALUE) activityCookie = `${LZ_TOKEN_KEY} ${LZ_TOKEN_VALUE}` + if(lz_jdpin_token) lz_jdpin_token_cookie = lz_jdpin_token +} + +async function getUA(){ + $.UA = `jdapp;iPhone;10.1.4;13.1.2;${randomString(40)};network/wifi;model/iPhone8,1;addressid/2308460611;appBuild/167814;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_1_2 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 joinShop() { + if(!$.joinVenderId) return + return new Promise(async resolve => { + $.shopactivityId = '' + await $.wait(1000) + await getshopactivityId() + let activityId = `` + if($.shopactivityId) activityId = `,"activityId":${$.shopactivityId}` + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body={"venderId":"${$.joinVenderId}","shopId":"${$.joinVenderId}","bindByVerifyCodeFlag":1,"registerExtend":{},"writeChildFlag":0${activityId},"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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + // console.log(data) + let res = $.toObj(data); + if(typeof res == 'object'){ + if(res.success === true){ + console.log(res.message) + if(res.result && res.result.giftInfo){ + for(let i of res.result.giftInfo.giftList){ + console.log(`入会获得:${i.discountString}${i.prizeName}${i.secondLineDesc}`) + } + } + }else if(typeof res == 'object' && res.message){ + console.log(`${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function getshopactivityId() { + return new Promise(resolve => { + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body=%7B%22venderId%22%3A%22${$.joinVenderId}%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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + let res = $.toObj(data); + if(res.success == true){ + // console.log($.toStr(res.result)) + console.log(`入会:${res.result.shopMemberCardInfo.venderCardName || ''}`) + $.shopactivityId = res.result.interestsRuleList && res.result.interestsRuleList[0] && res.result.interestsRuleList[0].interestsInfo && res.result.interestsRuleList[0].interestsInfo.activityId || '' + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} + + +// 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)} + diff --git a/activity/jd_opencardLH30.js b/activity/jd_opencardLH30.js new file mode 100644 index 0000000..7211665 --- /dev/null +++ b/activity/jd_opencardLH30.js @@ -0,0 +1,797 @@ +/* +12.17~1.3 双旦寻宝 玩转大富翁 [jd_opencardLH30.js] +开卡脚本,一次性脚本 + +1.邀请一人5豆 +2.开9张卡 成功开1张 获得10豆 + 开通所有可抽奖1次 可能获得5/10/888京豆 +3.关注5豆 +4.抽奖 + +第一个账号助力作者 其他依次助力CK1 +第一个CK失效会退出脚本 +———————————————— +入口:[ 12.17~1.3 双旦寻宝 玩转大富翁 (https://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=dfw202112nw2thjcb1rl48x88v&shareUuid=766b93afd0284cd3b85eb78493736a71)] + +请求太频繁会被黑ip +过10分钟再执行 + +cron:30 0,9 18-31,1-3 12,1 * +============Quantumultx=============== +[task_local] +#12.17~1.3 双旦寻宝 玩转大富翁 +30 0,9 18-31,1-3 12,1 * https://raw.githubusercontent.com/KingRan/JDJB/main/jd_opencardLH30.js, tag=12.17~1.3 双旦寻宝 玩转大富翁, enabled=true + +*/ + +const $ = new Env('12.17~1.3 双旦寻宝 玩转大富翁'); +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const notify = $.isNode() ? require('./sendNotify') : ''; +//IOS等用户直接用NobyDa的jd cookie + +let cookiesArr = [], + cookie = ''; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} + +allMessage = "" +message = "" +$.hotFlag = false +$.outFlag = false +$.activityEnd = false +let lz_jdpin_token_cookie ='' +let activityCookie ='' +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', { + "open-url": "https://bean.m.jd.com/" + }); + return; + } + $.activityId = "dfw202112nw2thjcb1rl48x88v" + $.shareUuid = "766b93afd0284cd3b85eb78493736a71" + console.log(`入口:\nhttps://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}`) + + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i]; + if (cookie) { + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + message = "" + $.bean = 0 + $.hotFlag = false + $.nickName = ''; + console.log(`\n\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + await getUA() + await run(); + if(i == 0 && !$.actorUuid) break + if($.outFlag || $.activityEnd) break + } + } + if($.outFlag) { + let msg = '此ip已被限制,请过10分钟后再执行脚本' + $.msg($.name, ``, `${msg}`); + if ($.isNode()) await notify.sendNotify(`${$.name}`, `${msg}`); + } +})() + .catch((e) => $.logErr(e)) + .finally(() => $.done()) + + +async function run() { + try { + $.hasEnd = true + $.endTime = 0 + lz_jdpin_token_cookie = '' + $.Token = '' + $.Pin = '' + let flag = false + await takePostRequest('isvObfuscator'); + if($.Token == ''){ + console.log('获取[token]失败!') + return + } + await getCk() + if (activityCookie == '') { + console.log(`获取cookie失败`); return; + } + if($.activityEnd === true){ + console.log('活动结束') + return + } + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + await takePostRequest('getSimpleActInfoVo'); + await takePostRequest('getMyPing'); + if(!$.Pin){ + console.log('获取[Pin]失败!') + return + } + await takePostRequest('accessLogWithAD'); + await takePostRequest('getUserInfo'); + await takePostRequest('activityContent'); + if($.hotFlag) return + if(!$.actorUuid){ + console.log('获取不到[actorUuid]退出执行,请重新执行') + return + } + if($.hasEnd === true || Date.now() > $.endTime){ + $.activityEnd = true + console.log('活动结束') + return + } + await takePostRequest('drawContent'); + await $.wait(1000) + $.openList = [] + $.allOpenCard = false + await takePostRequest('checkOpenCard'); + // console.log($.actorUuid) + // return + if($.allOpenCard == false){ + console.log('开卡任务') + for(o of $.openList){ + $.openCard = false + if(o.status == 0){ + flag = true + $.joinVenderId = o.venderId + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + await joinShop() + await $.wait(parseInt(Math.random() * 1000 + 1000, 10)) + await takePostRequest('activityContent'); + await takePostRequest('drawContent'); + await takePostRequest('checkOpenCard'); + await $.wait(parseInt(Math.random() * 3000 + 2000, 10)) + } + } + }else{ + console.log('已全部开卡') + } + + $.log("关注: " + $.followShop) + if(!$.followShop && !$.outFlag){ + flag = true + await takePostRequest('followShop'); + await $.wait(parseInt(Math.random() * 2000 + 3000, 10)) + } + $.yaoqing = false + await takePostRequest('助力'); + if($.yaoqing){ + await takePostRequest('邀请'); + } + await takePostRequest('startDraw'); + + if(flag){ + await takePostRequest('activityContent'); + } + console.log(`${$.score}值 游戏:${$.point}`) + $.runFalag = true + let count = parseInt($.score/1000) + console.log(`抽奖次数为:${count}`) + for(m=1;count--;m++){ + console.log(`第${m}次抽奖`) + await takePostRequest('抽奖'); + if($.runFalag == false) break + if(Number(count) <= 0) break + if(m >= 10){ + console.log("抽奖太多次,多余的次数请再执行脚本") + break + } + await $.wait(parseInt(Math.random() * 2000 + 2000, 10)) + } + + await $.wait(parseInt(Math.random() * 1000 + 2000, 10)) + await takePostRequest('getDrawRecordHasCoupon'); + await takePostRequest('getShareRecord'); + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + console.log($.actorUuid) + console.log(`当前助力:${$.shareUuid}`) + if($.index == 1){ + $.shareUuid = $.actorUuid + console.log(`后面的号都会助力:${$.shareUuid}`) + } + await $.wait(parseInt(Math.random() * 1000 + 5000, 10)) + if(flag) await $.wait(parseInt(Math.random() * 1000 + 10000, 10)) + + if($.index % 3 == 0) console.log('休息1分钟,别被黑ip了\n可持续发展') + if($.index % 3 == 0) await $.wait(parseInt(Math.random() * 5000 + 60000, 10)) + + } catch (e) { + console.log(e) + } +} + +async function takePostRequest(type) { + if($.outFlag) return + let domain = 'https://lzdz1-isv.isvjcloud.com'; + let body = ``; + let method = 'POST' + let admJson = '' + switch (type) { + case 'isvObfuscator': + url = `https://api.m.jd.com/client.action?functionId=isvObfuscator`; + body = `body=%7B%22url%22%3A%22https%3A//lzdz1-isv.isvjcloud.com%22%2C%22id%22%3A%22%22%7D&uuid=7088d9018515b8cb0c88ace6e5479762af3e88f3&client=apple&clientVersion=10.1.4&st=1634343624086&sv=120&sign=8b9cea22c3a0d77026abda5d37d2b7e3`; + break; + case 'getSimpleActInfoVo': + url = `${domain}/dz/common/getSimpleActInfoVo`; + body = `activityId=${$.activityId}`; + break; + case 'getMyPing': + url = `${domain}/customer/getMyPing`; + body = `userId=${$.shopId || $.venderId || ''}&token=${$.Token}&fromType=APP`; + break; + case 'accessLogWithAD': + url = `${domain}/common/accessLogWithAD`; + let pageurl = `${domain}/drawCenter/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}` + body = `venderId=${$.shopId || $.venderId || ''}&code=99&pin=${encodeURIComponent($.Pin)}&activityId=${$.activityId}&pageUrl=${encodeURIComponent(pageurl)}&subType=app&adSource=` + break; + case 'getUserInfo': + url = `${domain}/wxActionCommon/getUserInfo`; + body = `pin=${encodeURIComponent($.Pin)}`; + break; + case 'activityContent': + url = `${domain}/play/monopoly/getContent`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&pinImg=${encodeURIComponent($.attrTouXiang)}&nick=${encodeURIComponent($.nickname)}&cjyxPin=&cjhyPin=&shareUuid=${$.shareUuid}` + break; + case 'drawContent': + url = `${domain}/dingzhi/taskact/common/drawContent`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case 'checkOpenCard': + url = `${domain}/play/monopoly/checkOpenCard`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case 'info': + url = `${domain}/play/monopoly/getTaskList`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case 'startDraw': + url = `${domain}/play/monopoly/activeDraw`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&drawType=1` + break; + case 'followShop': + url = `${domain}/play/monopoly/doTasks`; + // url = `${domain}/dingzhi/dz/openCard/saveTask`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&taskType=1` + break; + case 'sign': + case 'addCart': + case 'browseGoods': + url = `${domain}/dingzhi/linkgame/${type}`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + if(type == 'browseGoods') body += `&value=${$.visitSkuValue}` + break; + case '邀请': + case '助力': + if(type == '助力'){ + url = `${domain}/play/monopoly/getAssistStatus`; + }else{ + url = `${domain}/play/monopoly/assist`; + } + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&shareUuid=${$.shareUuid}&actorUuid=${$.actorUuid}` + break; + case 'viewVideo': + case 'visitSku': + case 'toShop': + case 'addSku': + url = `${domain}/dingzhi/dz/openCard/saveTask`; + let taskType = '' + let taskValue = '' + if(type == 'viewVideo'){ + taskType = 31 + taskValue = 31 + }else if(type == 'visitSku'){ + taskType = 5 + taskValue = $.visitSkuValue || 5 + }else if(type == 'toShop'){ + taskType = 14 + taskValue = $.toShopValue || 14 + }else if(type == 'addSku'){ + taskType = 2 + taskValue = $.addSkuValue || 2 + } + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&taskType=${taskType}&taskValue=${taskValue}` + break; + case 'getDrawRecordHasCoupon': + url = `${domain}/play/monopoly/getPrizeList`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case 'getShareRecord': + url = `${domain}/play/monopoly/getHelpList`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case '抽奖': + url = `${domain}/play/monopoly/activeDraw`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&drawType=2` + break; + default: + console.log(`错误${type}`); + } + let myRequest = getPostRequest(url, body, method); + // console.log(myRequest) + return new Promise(async resolve => { + $.post(myRequest, (err, resp, data) => { + try { + setActivityCookie(resp) + if (err) { + if(resp && typeof resp.statusCode != 'undefined'){ + if(resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + } + console.log(`${$.toStr(err,err)}`) + console.log(`${type} API请求失败,请检查网路重试`) + } else { + dealReturn(type, data); + } + } catch (e) { + // console.log(data); + console.log(e, resp) + } finally { + resolve(); + } + }) + }) + } + +async function dealReturn(type, data) { + let res = '' + try { + if(type != 'accessLogWithAD' || type != 'drawContent'){ + if(data){ + res = JSON.parse(data); + } + } + } catch (e) { + console.log(`${type} 执行任务异常`); + console.log(data); + $.runFalag = false; + } + try { + switch (type) { + case 'isvObfuscator': + if(typeof res == 'object'){ + if(res.errcode == 0){ + if(typeof res.token != 'undefined') $.Token = res.token + }else if(res.message){ + console.log(`isvObfuscator ${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + break; + case 'getSimpleActInfoVo': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(typeof res.data.shopId != 'undefined') $.shopId = res.data.shopId + if(typeof res.data.venderId != 'undefined') $.venderId = res.data.venderId + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getMyPing': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(res.data && typeof res.data.secretPin != 'undefined') $.Pin = res.data.secretPin + if(res.data && typeof res.data.nickname != 'undefined') $.nickname = res.data.nickname + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getUserInfo': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(res.data && typeof res.data.yunMidImageUrl != 'undefined') $.attrTouXiang = res.data.yunMidImageUrl || "https://img10.360buyimg.com/imgzone/jfs/t1/7020/27/13511/6142/5c5138d8E4df2e764/5a1216a3a5043c5d.png" + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'activityContent': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + $.endTime = res.data.endTime || (res.data.activityVo && res.data.activityVo.endTime) || res.data.activity.endTime || 0 + $.hasEnd = res.data.isEnd || false + $.drawCount = res.data.actorVo.drawCount || 0 + $.point = res.data.actorVo.point || 0 + $.score = res.data.actorVo.score || 0 + $.actorUuid = res.data.actorVo.actorUuid || '' + $.followShop = res.data.actorVo.followShopStatus || '' + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'info': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + // $.drawCount = res.data.drawCount || 0 + $.addCart = res.data.addCart || false + $.followShop = res.data.followShop || false + $.sign = res.data.isSignStatus || false + $.visitSku = res.data.visitSku || false + $.visitSkuList = res.data.visitSkuList || [] + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'checkOpenCard': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + let cardList1 = res.data.cardList1 || [] + let cardList2 = res.data.cardList2 || [] + let cardList = res.data.cardList || [] + let openCardList = res.data.openCardList || [] + $.openList = [...cardList,...cardList1,...cardList2,...openCardList] + $.allOpenCard = res.data.allOpenCard || res.data.isOpenCardStatus || false + $.openCardScore1 = res.data.score1 || 0 + $.openCardScore2 = res.data.score2 || 0 + $.drawScore = res.data.drawScore || 0 + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'startDraw': + case 'followShop': + case 'viewVideo': + case 'visitSku': + case 'toShop': + case 'addSku': + case 'sign': + case 'addCart': + case 'browseGoods': + case '抽奖': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(typeof res.data == 'object'){ + let msg = '' + let title = '抽奖' + if(res.data.addBeanNum){ + msg = `${res.data.addBeanNum}京豆` + } + if(res.data.addPoint){ + msg += ` ${res.data.addPoint}游戏机会` + } + if(type == 'followShop'){ + title = '关注' + if(res.data.beanNumMember && res.data.assistSendStatus){ + msg += ` 额外获得:${res.data.beanNumMember}京豆` + } + }else if(type == 'addSku' || type == 'addCart'){ + title = '加购' + }else if(type == 'viewVideo'){ + title = '热门文章' + }else if(type == 'toShop'){ + title = '浏览店铺' + }else if(type == 'visitSku' || type == 'browseGoods'){ + title = '浏览商品' + }else if(type == 'sign'){ + title = '签到' + }else{ + msg = res.data.drawOk == true && (res.data.drawInfoType == 6 && res.data.name || '') || '空气💨' + } + if(!msg){ + msg = '空气💨' + } + console.log(`${title}获得:${msg || data}`) + }else{ + console.log(`${type} ${data}`) + } + }else if(res.errorMessage){ + $.runFalag = false; + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getDrawRecordHasCoupon': + // console.log(data) + if(typeof res == 'object'){ + if(res.result && res.result === true){ + console.log(`我的奖品:`) + let num = 0 + let value = 0 + for(let i in res.data){ + let item = res.data[i] + if(item.drawId == 'assist'){ + num++ + value = item.infoName.replace('京豆','') + }else{ + console.log(`${item.infoType != 10 && item.drawId && item.drawId +':' || ''}${item.infoName}`) + } + } + if(num > 0) console.log(`邀请好友(${num}):${num*parseInt(value, 10) || 30}京豆`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getShareRecord': + if(typeof res == 'object'){ + if(res.result && res.result === true && res.data){ + $.ShareCount = res.data.length + $.log(`=========== 你邀请了:${res.data.length}个`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case '邀请': + case '助力': + // console.log(data) + if(typeof res == 'object'){ + if(res.data == 200){ + if(type == '助力'){ + console.log('助力成功') + $.yaoqing = true + } + }else if(res.data == 105){ + console.log('已经助力过') + }else if(res.data == 104){ + console.log('已经助力其他人') + }else if(res.data == 101){ + // console.log('已经助力过') + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + + case 'accessLogWithAD': + case 'drawContent': + break; + default: + console.log(`${type}-> ${data}`); + } + if(typeof res == 'object'){ + if(res.errorMessage){ + if(res.errorMessage.indexOf('火爆') >-1 ){ + $.hotFlag = true + } + } + } + } catch (e) { + console.log(e) + } +} + +function getPostRequest(url, body, method="POST") { + let headers = { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Content-Type": "application/x-www-form-urlencoded", + "Cookie": cookie, + "User-Agent": $.UA, + "X-Requested-With": "XMLHttpRequest" + } + if(url.indexOf('https://lzdz1-isv.isvjcloud.com') > -1){ + headers["Referer"] = `https://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}` + headers["Cookie"] = `${lz_jdpin_token_cookie && lz_jdpin_token_cookie || ''}${$.Pin && "AUTH_C_USER=" + $.Pin + ";" || ""}${activityCookie}` + } + // console.log(headers) + // console.log(headers.Cookie) + return {url: url, method: method, headers: headers, body: body, timeout:30000}; +} + +function getCk() { + return new Promise(resolve => { + let get = { + url:`https://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}`, + followRedirect:false, + headers: { + "User-Agent": $.UA, + }, + timeout:30000 + } + $.get(get, async(err, resp, data) => { + try { + if (err) { + if(resp && typeof resp.statusCode != 'undefined'){ + if(resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + } + console.log(`${$.toStr(err)}`) + console.log(`${$.name} cookie API请求失败,请检查网路重试`) + } else { + let end = data.match(/(活动已经结束)/) && data.match(/(活动已经结束)/)[1] || '' + if(end){ + $.activityEnd = true + console.log('活动已结束') + } + setActivityCookie(resp) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function setActivityCookie(resp){ + let LZ_TOKEN_KEY = '' + let LZ_TOKEN_VALUE = '' + let lz_jdpin_token = '' + let setcookies = resp && resp['headers'] && (resp['headers']['set-cookie'] || resp['headers']['Set-Cookie'] || '') || '' + let setcookie = '' + if(setcookies){ + if(typeof setcookies != 'object'){ + setcookie = setcookies.split(',') + }else setcookie = setcookies + for (let ck of setcookie) { + let name = ck.split(";")[0].trim() + if(name.split("=")[1]){ + // console.log(name.replace(/ /g,'')) + if(name.indexOf('LZ_TOKEN_KEY=')>-1) LZ_TOKEN_KEY = name.replace(/ /g,'')+';' + if(name.indexOf('LZ_TOKEN_VALUE=')>-1) LZ_TOKEN_VALUE = name.replace(/ /g,'')+';' + if(name.indexOf('lz_jdpin_token=')>-1) lz_jdpin_token = ''+name.replace(/ /g,'')+';' + } + } + } + if(LZ_TOKEN_KEY && LZ_TOKEN_VALUE) activityCookie = `${LZ_TOKEN_KEY} ${LZ_TOKEN_VALUE}` + if(lz_jdpin_token) lz_jdpin_token_cookie = lz_jdpin_token +} + +async function getUA(){ + $.UA = `jdapp;iPhone;10.1.4;13.1.2;${randomString(40)};network/wifi;model/iPhone8,1;addressid/2308460611;appBuild/167814;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_1_2 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 joinShop() { + if(!$.joinVenderId) return + return new Promise(async resolve => { + $.shopactivityId = '' + await $.wait(1000) + await getshopactivityId() + let activityId = `` + if($.shopactivityId) activityId = `,"activityId":${$.shopactivityId}` + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body={"venderId":"${$.joinVenderId}","shopId":"${$.joinVenderId}","bindByVerifyCodeFlag":1,"registerExtend":{},"writeChildFlag":0${activityId},"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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + // console.log(data) + let res = $.toObj(data); + if(typeof res == 'object'){ + if(res.success === true){ + console.log(res.message) + if(res.result && res.result.giftInfo){ + for(let i of res.result.giftInfo.giftList){ + console.log(`入会获得:${i.discountString}${i.prizeName}${i.secondLineDesc}`) + } + } + }else if(typeof res == 'object' && res.message){ + console.log(`${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function getshopactivityId() { + return new Promise(resolve => { + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body=%7B%22venderId%22%3A%22${$.joinVenderId}%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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + let res = $.toObj(data); + if(res.success == true){ + // console.log($.toStr(res.result)) + console.log(`入会:${res.result.shopMemberCardInfo.venderCardName || ''}`) + $.shopactivityId = res.result.interestsRuleList && res.result.interestsRuleList[0] && res.result.interestsRuleList[0].interestsInfo && res.result.interestsRuleList[0].interestsInfo.activityId || '' + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} + + +// 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)} diff --git a/activity/jd_opencardLH31.js b/activity/jd_opencardLH31.js new file mode 100644 index 0000000..895b01a --- /dev/null +++ b/activity/jd_opencardLH31.js @@ -0,0 +1,797 @@ +/* +12.20~1.5 双旦寻宝 玩转大富翁 [jd_opencardLH31.js] +开卡脚本,一次性脚本 + +1.邀请一人5豆 +2.开9张卡 成功开1张 获得10豆 + 开通所有可抽奖1次 可能获得5/10/888京豆 +3.关注5豆 +4.抽奖 + +第一个账号助力作者 其他依次助力CK1 +第一个CK失效会退出脚本 +———————————————— +入口:[ 12.20~1.5 双旦寻宝 玩转大富翁 (https://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=dfw2021121701vrb6n1c0ilo0uw&shareUuid=3f379c1bc2a74c57aeb84ca42d6dba47)] + +请求太频繁会被黑ip +过10分钟再执行 + +cron:30 2,16 21-31,1-5 12,1 * +============Quantumultx=============== +[task_local] +#12.20~1.5 双旦寻宝 玩转大富翁 +30 2,16 21-31,1-5 12,1 * https://raw.githubusercontent.com/KingRan/JDJB/main/jd_opencardLH31.js, tag=12.20~1.5 双旦寻宝 玩转大富翁, enabled=true + +*/ + +const $ = new Env('12.20~1.5 双旦寻宝 玩转大富翁-2'); +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const notify = $.isNode() ? require('./sendNotify') : ''; +//IOS等用户直接用NobyDa的jd cookie + +let cookiesArr = [], + cookie = ''; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} + +allMessage = "" +message = "" +$.hotFlag = false +$.outFlag = false +$.activityEnd = false +let lz_jdpin_token_cookie ='' +let activityCookie ='' +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', { + "open-url": "https://bean.m.jd.com/" + }); + return; + } + $.activityId = "dfw2021121701vrb6n1c0ilo0uw" + $.shareUuid = "3f379c1bc2a74c57aeb84ca42d6dba47" + console.log(`入口:\nhttps://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}`) + + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i]; + if (cookie) { + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + message = "" + $.bean = 0 + $.hotFlag = false + $.nickName = ''; + console.log(`\n\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + await getUA() + await run(); + if(i == 0 && !$.actorUuid) break + if($.outFlag || $.activityEnd) break + } + } + if($.outFlag) { + let msg = '此ip已被限制,请过10分钟后再执行脚本' + $.msg($.name, ``, `${msg}`); + if ($.isNode()) await notify.sendNotify(`${$.name}`, `${msg}`); + } +})() + .catch((e) => $.logErr(e)) + .finally(() => $.done()) + + +async function run() { + try { + $.hasEnd = true + $.endTime = 0 + lz_jdpin_token_cookie = '' + $.Token = '' + $.Pin = '' + let flag = false + await takePostRequest('isvObfuscator'); + if($.Token == ''){ + console.log('获取[token]失败!') + return + } + await getCk() + if (activityCookie == '') { + console.log(`获取cookie失败`); return; + } + if($.activityEnd === true){ + console.log('活动结束') + return + } + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + await takePostRequest('getSimpleActInfoVo'); + await takePostRequest('getMyPing'); + if(!$.Pin){ + console.log('获取[Pin]失败!') + return + } + await takePostRequest('accessLogWithAD'); + await takePostRequest('getUserInfo'); + await takePostRequest('activityContent'); + if($.hotFlag) return + if(!$.actorUuid){ + console.log('获取不到[actorUuid]退出执行,请重新执行') + return + } + if($.hasEnd === true || Date.now() > $.endTime){ + $.activityEnd = true + console.log('活动结束') + return + } + await takePostRequest('drawContent'); + await $.wait(1000) + $.openList = [] + $.allOpenCard = false + await takePostRequest('checkOpenCard'); + // console.log($.actorUuid) + // return + if($.allOpenCard == false){ + console.log('开卡任务') + for(o of $.openList){ + $.openCard = false + if(o.status == 0){ + flag = true + $.joinVenderId = o.venderId + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + await joinShop() + await $.wait(parseInt(Math.random() * 1000 + 1000, 10)) + await takePostRequest('activityContent'); + await takePostRequest('drawContent'); + await takePostRequest('checkOpenCard'); + await $.wait(parseInt(Math.random() * 3000 + 2000, 10)) + } + } + }else{ + console.log('已全部开卡') + } + + $.log("关注: " + $.followShop) + if(!$.followShop && !$.outFlag){ + flag = true + await takePostRequest('followShop'); + await $.wait(parseInt(Math.random() * 2000 + 3000, 10)) + } + $.yaoqing = false + await takePostRequest('助力'); + if($.yaoqing){ + await takePostRequest('邀请'); + } + await takePostRequest('startDraw'); + + if(flag){ + await takePostRequest('activityContent'); + } + console.log(`${$.score}值 游戏:${$.point}`) + $.runFalag = true + let count = parseInt($.score/1000) + console.log(`抽奖次数为:${count}`) + for(m=1;count--;m++){ + console.log(`第${m}次抽奖`) + await takePostRequest('抽奖'); + if($.runFalag == false) break + if(Number(count) <= 0) break + if(m >= 10){ + console.log("抽奖太多次,多余的次数请再执行脚本") + break + } + await $.wait(parseInt(Math.random() * 2000 + 2000, 10)) + } + + await $.wait(parseInt(Math.random() * 1000 + 2000, 10)) + await takePostRequest('getDrawRecordHasCoupon'); + await takePostRequest('getShareRecord'); + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + console.log($.actorUuid) + console.log(`当前助力:${$.shareUuid}`) + if($.index == 1){ + $.shareUuid = $.actorUuid + console.log(`后面的号都会助力:${$.shareUuid}`) + } + await $.wait(parseInt(Math.random() * 1000 + 5000, 10)) + if(flag) await $.wait(parseInt(Math.random() * 1000 + 10000, 10)) + + if($.index % 3 == 0) console.log('休息1分钟,别被黑ip了\n可持续发展') + if($.index % 3 == 0) await $.wait(parseInt(Math.random() * 5000 + 60000, 10)) + + } catch (e) { + console.log(e) + } +} + +async function takePostRequest(type) { + if($.outFlag) return + let domain = 'https://lzdz1-isv.isvjcloud.com'; + let body = ``; + let method = 'POST' + let admJson = '' + switch (type) { + case 'isvObfuscator': + url = `https://api.m.jd.com/client.action?functionId=isvObfuscator`; + body = `body=%7B%22url%22%3A%22https%3A//lzdz1-isv.isvjcloud.com%22%2C%22id%22%3A%22%22%7D&uuid=7088d9018515b8cb0c88ace6e5479762af3e88f3&client=apple&clientVersion=10.1.4&st=1634343624086&sv=120&sign=8b9cea22c3a0d77026abda5d37d2b7e3`; + break; + case 'getSimpleActInfoVo': + url = `${domain}/dz/common/getSimpleActInfoVo`; + body = `activityId=${$.activityId}`; + break; + case 'getMyPing': + url = `${domain}/customer/getMyPing`; + body = `userId=${$.shopId || $.venderId || ''}&token=${$.Token}&fromType=APP`; + break; + case 'accessLogWithAD': + url = `${domain}/common/accessLogWithAD`; + let pageurl = `${domain}/drawCenter/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}` + body = `venderId=${$.shopId || $.venderId || ''}&code=99&pin=${encodeURIComponent($.Pin)}&activityId=${$.activityId}&pageUrl=${encodeURIComponent(pageurl)}&subType=app&adSource=` + break; + case 'getUserInfo': + url = `${domain}/wxActionCommon/getUserInfo`; + body = `pin=${encodeURIComponent($.Pin)}`; + break; + case 'activityContent': + url = `${domain}/play/monopoly/getContent`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&pinImg=${encodeURIComponent($.attrTouXiang)}&nick=${encodeURIComponent($.nickname)}&cjyxPin=&cjhyPin=&shareUuid=${$.shareUuid}` + break; + case 'drawContent': + url = `${domain}/dingzhi/taskact/common/drawContent`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case 'checkOpenCard': + url = `${domain}/play/monopoly/checkOpenCard`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case 'info': + url = `${domain}/play/monopoly/getTaskList`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case 'startDraw': + url = `${domain}/play/monopoly/activeDraw`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&drawType=1` + break; + case 'followShop': + url = `${domain}/play/monopoly/doTasks`; + // url = `${domain}/dingzhi/dz/openCard/saveTask`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&taskType=1` + break; + case 'sign': + case 'addCart': + case 'browseGoods': + url = `${domain}/dingzhi/linkgame/${type}`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + if(type == 'browseGoods') body += `&value=${$.visitSkuValue}` + break; + case '邀请': + case '助力': + if(type == '助力'){ + url = `${domain}/play/monopoly/getAssistStatus`; + }else{ + url = `${domain}/play/monopoly/assist`; + } + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&shareUuid=${$.shareUuid}&actorUuid=${$.actorUuid}` + break; + case 'viewVideo': + case 'visitSku': + case 'toShop': + case 'addSku': + url = `${domain}/dingzhi/dz/openCard/saveTask`; + let taskType = '' + let taskValue = '' + if(type == 'viewVideo'){ + taskType = 31 + taskValue = 31 + }else if(type == 'visitSku'){ + taskType = 5 + taskValue = $.visitSkuValue || 5 + }else if(type == 'toShop'){ + taskType = 14 + taskValue = $.toShopValue || 14 + }else if(type == 'addSku'){ + taskType = 2 + taskValue = $.addSkuValue || 2 + } + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&taskType=${taskType}&taskValue=${taskValue}` + break; + case 'getDrawRecordHasCoupon': + url = `${domain}/play/monopoly/getPrizeList`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case 'getShareRecord': + url = `${domain}/play/monopoly/getHelpList`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case '抽奖': + url = `${domain}/play/monopoly/activeDraw`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&drawType=2` + break; + default: + console.log(`错误${type}`); + } + let myRequest = getPostRequest(url, body, method); + // console.log(myRequest) + return new Promise(async resolve => { + $.post(myRequest, (err, resp, data) => { + try { + setActivityCookie(resp) + if (err) { + if(resp && typeof resp.statusCode != 'undefined'){ + if(resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + } + console.log(`${$.toStr(err,err)}`) + console.log(`${type} API请求失败,请检查网路重试`) + } else { + dealReturn(type, data); + } + } catch (e) { + // console.log(data); + console.log(e, resp) + } finally { + resolve(); + } + }) + }) + } + +async function dealReturn(type, data) { + let res = '' + try { + if(type != 'accessLogWithAD' || type != 'drawContent'){ + if(data){ + res = JSON.parse(data); + } + } + } catch (e) { + console.log(`${type} 执行任务异常`); + console.log(data); + $.runFalag = false; + } + try { + switch (type) { + case 'isvObfuscator': + if(typeof res == 'object'){ + if(res.errcode == 0){ + if(typeof res.token != 'undefined') $.Token = res.token + }else if(res.message){ + console.log(`isvObfuscator ${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + break; + case 'getSimpleActInfoVo': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(typeof res.data.shopId != 'undefined') $.shopId = res.data.shopId + if(typeof res.data.venderId != 'undefined') $.venderId = res.data.venderId + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getMyPing': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(res.data && typeof res.data.secretPin != 'undefined') $.Pin = res.data.secretPin + if(res.data && typeof res.data.nickname != 'undefined') $.nickname = res.data.nickname + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getUserInfo': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(res.data && typeof res.data.yunMidImageUrl != 'undefined') $.attrTouXiang = res.data.yunMidImageUrl || "https://img10.360buyimg.com/imgzone/jfs/t1/7020/27/13511/6142/5c5138d8E4df2e764/5a1216a3a5043c5d.png" + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'activityContent': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + $.endTime = res.data.endTime || (res.data.activityVo && res.data.activityVo.endTime) || res.data.activity.endTime || 0 + $.hasEnd = res.data.isEnd || false + $.drawCount = res.data.actorVo.drawCount || 0 + $.point = res.data.actorVo.point || 0 + $.score = res.data.actorVo.score || 0 + $.actorUuid = res.data.actorVo.actorUuid || '' + $.followShop = res.data.actorVo.followShopStatus || '' + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'info': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + // $.drawCount = res.data.drawCount || 0 + $.addCart = res.data.addCart || false + $.followShop = res.data.followShop || false + $.sign = res.data.isSignStatus || false + $.visitSku = res.data.visitSku || false + $.visitSkuList = res.data.visitSkuList || [] + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'checkOpenCard': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + let cardList1 = res.data.cardList1 || [] + let cardList2 = res.data.cardList2 || [] + let cardList = res.data.cardList || [] + let openCardList = res.data.openCardList || [] + $.openList = [...cardList,...cardList1,...cardList2,...openCardList] + $.allOpenCard = res.data.allOpenCard || res.data.isOpenCardStatus || false + $.openCardScore1 = res.data.score1 || 0 + $.openCardScore2 = res.data.score2 || 0 + $.drawScore = res.data.drawScore || 0 + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'startDraw': + case 'followShop': + case 'viewVideo': + case 'visitSku': + case 'toShop': + case 'addSku': + case 'sign': + case 'addCart': + case 'browseGoods': + case '抽奖': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(typeof res.data == 'object'){ + let msg = '' + let title = '抽奖' + if(res.data.addBeanNum){ + msg = `${res.data.addBeanNum}京豆` + } + if(res.data.addPoint){ + msg += ` ${res.data.addPoint}游戏机会` + } + if(type == 'followShop'){ + title = '关注' + if(res.data.beanNumMember && res.data.assistSendStatus){ + msg += ` 额外获得:${res.data.beanNumMember}京豆` + } + }else if(type == 'addSku' || type == 'addCart'){ + title = '加购' + }else if(type == 'viewVideo'){ + title = '热门文章' + }else if(type == 'toShop'){ + title = '浏览店铺' + }else if(type == 'visitSku' || type == 'browseGoods'){ + title = '浏览商品' + }else if(type == 'sign'){ + title = '签到' + }else{ + msg = res.data.drawOk == true && (res.data.drawInfoType == 6 && res.data.name || '') || '空气💨' + } + if(!msg){ + msg = '空气💨' + } + console.log(`${title}获得:${msg || data}`) + }else{ + console.log(`${type} ${data}`) + } + }else if(res.errorMessage){ + $.runFalag = false; + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getDrawRecordHasCoupon': + // console.log(data) + if(typeof res == 'object'){ + if(res.result && res.result === true){ + console.log(`我的奖品:`) + let num = 0 + let value = 0 + for(let i in res.data){ + let item = res.data[i] + if(item.drawId == 'assist'){ + num++ + value = item.infoName.replace('京豆','') + }else{ + console.log(`${item.infoType != 10 && item.drawId && item.drawId +':' || ''}${item.infoName}`) + } + } + if(num > 0) console.log(`邀请好友(${num}):${num*parseInt(value, 10) || 30}京豆`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getShareRecord': + if(typeof res == 'object'){ + if(res.result && res.result === true && res.data){ + $.ShareCount = res.data.length + $.log(`=========== 你邀请了:${res.data.length}个`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case '邀请': + case '助力': + // console.log(data) + if(typeof res == 'object'){ + if(res.data == 200){ + if(type == '助力'){ + console.log('助力成功') + $.yaoqing = true + } + }else if(res.data == 105){ + console.log('已经助力过') + }else if(res.data == 104){ + console.log('已经助力其他人') + }else if(res.data == 101){ + // console.log('已经助力过') + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + + case 'accessLogWithAD': + case 'drawContent': + break; + default: + console.log(`${type}-> ${data}`); + } + if(typeof res == 'object'){ + if(res.errorMessage){ + if(res.errorMessage.indexOf('火爆') >-1 ){ + $.hotFlag = true + } + } + } + } catch (e) { + console.log(e) + } +} + +function getPostRequest(url, body, method="POST") { + let headers = { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Content-Type": "application/x-www-form-urlencoded", + "Cookie": cookie, + "User-Agent": $.UA, + "X-Requested-With": "XMLHttpRequest" + } + if(url.indexOf('https://lzdz1-isv.isvjcloud.com') > -1){ + headers["Referer"] = `https://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}` + headers["Cookie"] = `${lz_jdpin_token_cookie && lz_jdpin_token_cookie || ''}${$.Pin && "AUTH_C_USER=" + $.Pin + ";" || ""}${activityCookie}` + } + // console.log(headers) + // console.log(headers.Cookie) + return {url: url, method: method, headers: headers, body: body, timeout:30000}; +} + +function getCk() { + return new Promise(resolve => { + let get = { + url:`https://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}`, + followRedirect:false, + headers: { + "User-Agent": $.UA, + }, + timeout:30000 + } + $.get(get, async(err, resp, data) => { + try { + if (err) { + if(resp && typeof resp.statusCode != 'undefined'){ + if(resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + } + console.log(`${$.toStr(err)}`) + console.log(`${$.name} cookie API请求失败,请检查网路重试`) + } else { + let end = data.match(/(活动已经结束)/) && data.match(/(活动已经结束)/)[1] || '' + if(end){ + $.activityEnd = true + console.log('活动已结束') + } + setActivityCookie(resp) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function setActivityCookie(resp){ + let LZ_TOKEN_KEY = '' + let LZ_TOKEN_VALUE = '' + let lz_jdpin_token = '' + let setcookies = resp && resp['headers'] && (resp['headers']['set-cookie'] || resp['headers']['Set-Cookie'] || '') || '' + let setcookie = '' + if(setcookies){ + if(typeof setcookies != 'object'){ + setcookie = setcookies.split(',') + }else setcookie = setcookies + for (let ck of setcookie) { + let name = ck.split(";")[0].trim() + if(name.split("=")[1]){ + // console.log(name.replace(/ /g,'')) + if(name.indexOf('LZ_TOKEN_KEY=')>-1) LZ_TOKEN_KEY = name.replace(/ /g,'')+';' + if(name.indexOf('LZ_TOKEN_VALUE=')>-1) LZ_TOKEN_VALUE = name.replace(/ /g,'')+';' + if(name.indexOf('lz_jdpin_token=')>-1) lz_jdpin_token = ''+name.replace(/ /g,'')+';' + } + } + } + if(LZ_TOKEN_KEY && LZ_TOKEN_VALUE) activityCookie = `${LZ_TOKEN_KEY} ${LZ_TOKEN_VALUE}` + if(lz_jdpin_token) lz_jdpin_token_cookie = lz_jdpin_token +} + +async function getUA(){ + $.UA = `jdapp;iPhone;10.1.4;13.1.2;${randomString(40)};network/wifi;model/iPhone8,1;addressid/2308460611;appBuild/167814;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_1_2 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 joinShop() { + if(!$.joinVenderId) return + return new Promise(async resolve => { + $.shopactivityId = '' + await $.wait(1000) + await getshopactivityId() + let activityId = `` + if($.shopactivityId) activityId = `,"activityId":${$.shopactivityId}` + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body={"venderId":"${$.joinVenderId}","shopId":"${$.joinVenderId}","bindByVerifyCodeFlag":1,"registerExtend":{},"writeChildFlag":0${activityId},"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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + // console.log(data) + let res = $.toObj(data); + if(typeof res == 'object'){ + if(res.success === true){ + console.log(res.message) + if(res.result && res.result.giftInfo){ + for(let i of res.result.giftInfo.giftList){ + console.log(`入会获得:${i.discountString}${i.prizeName}${i.secondLineDesc}`) + } + } + }else if(typeof res == 'object' && res.message){ + console.log(`${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function getshopactivityId() { + return new Promise(resolve => { + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body=%7B%22venderId%22%3A%22${$.joinVenderId}%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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + let res = $.toObj(data); + if(res.success == true){ + // console.log($.toStr(res.result)) + console.log(`入会:${res.result.shopMemberCardInfo.venderCardName || ''}`) + $.shopactivityId = res.result.interestsRuleList && res.result.interestsRuleList[0] && res.result.interestsRuleList[0].interestsInfo && res.result.interestsRuleList[0].interestsInfo.activityId || '' + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} + + +// 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)} diff --git a/activity/jd_opencardLH32.js b/activity/jd_opencardLH32.js new file mode 100644 index 0000000..d6f9652 --- /dev/null +++ b/activity/jd_opencardLH32.js @@ -0,0 +1,797 @@ +/* +12.20~1.5 双旦寻宝 玩转大富翁 [jd_opencardLH32.js] +开卡脚本,一次性脚本 + +1.邀请一人5豆 +2.开9张卡 成功开1张 获得10豆 + 开通所有可抽奖1次 可能获得5/10/888京豆 +3.关注5豆 +4.抽奖 + +第一个账号助力作者 其他依次助力CK1 +第一个CK失效会退出脚本 +———————————————— +入口:[ 12.20~1.5 双旦寻宝 玩转大富翁 (https://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=dfw2021121702rics9xrkw5mpka&shareUuid=610ce07c9b244613ae01ac105dd4038a)] + +请求太频繁会被黑ip +过10分钟再执行 + +cron:30 0,18 21-31,1-5 12,1 * +============Quantumultx=============== +[task_local] +#12.20~1.5 双旦寻宝 玩转大富翁 +30 0,18 21-31,1-5 12,1 * https://raw.githubusercontent.com/KingRan/JDJB/main/jd_opencardLH32.js, tag=12.20~1.5 双旦寻宝 玩转大富翁, enabled=true + +*/ + +const $ = new Env('12.20~1.5 双旦寻宝 玩转大富翁-1'); +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const notify = $.isNode() ? require('./sendNotify') : ''; +//IOS等用户直接用NobyDa的jd cookie + +let cookiesArr = [], + cookie = ''; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} + +allMessage = "" +message = "" +$.hotFlag = false +$.outFlag = false +$.activityEnd = false +let lz_jdpin_token_cookie ='' +let activityCookie ='' +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', { + "open-url": "https://bean.m.jd.com/" + }); + return; + } + $.activityId = "dfw2021121702rics9xrkw5mpka" + $.shareUuid = "610ce07c9b244613ae01ac105dd4038a" + console.log(`入口:\nhttps://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}`) + + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i]; + if (cookie) { + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + message = "" + $.bean = 0 + $.hotFlag = false + $.nickName = ''; + console.log(`\n\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + await getUA() + await run(); + if(i == 0 && !$.actorUuid) break + if($.outFlag || $.activityEnd) break + } + } + if($.outFlag) { + let msg = '此ip已被限制,请过10分钟后再执行脚本' + $.msg($.name, ``, `${msg}`); + if ($.isNode()) await notify.sendNotify(`${$.name}`, `${msg}`); + } +})() + .catch((e) => $.logErr(e)) + .finally(() => $.done()) + + +async function run() { + try { + $.hasEnd = true + $.endTime = 0 + lz_jdpin_token_cookie = '' + $.Token = '' + $.Pin = '' + let flag = false + await takePostRequest('isvObfuscator'); + if($.Token == ''){ + console.log('获取[token]失败!') + return + } + await getCk() + if (activityCookie == '') { + console.log(`获取cookie失败`); return; + } + if($.activityEnd === true){ + console.log('活动结束') + return + } + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + await takePostRequest('getSimpleActInfoVo'); + await takePostRequest('getMyPing'); + if(!$.Pin){ + console.log('获取[Pin]失败!') + return + } + await takePostRequest('accessLogWithAD'); + await takePostRequest('getUserInfo'); + await takePostRequest('activityContent'); + if($.hotFlag) return + if(!$.actorUuid){ + console.log('获取不到[actorUuid]退出执行,请重新执行') + return + } + if($.hasEnd === true || Date.now() > $.endTime){ + $.activityEnd = true + console.log('活动结束') + return + } + await takePostRequest('drawContent'); + await $.wait(1000) + $.openList = [] + $.allOpenCard = false + await takePostRequest('checkOpenCard'); + // console.log($.actorUuid) + // return + if($.allOpenCard == false){ + console.log('开卡任务') + for(o of $.openList){ + $.openCard = false + if(o.status == 0){ + flag = true + $.joinVenderId = o.venderId + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + await joinShop() + await $.wait(parseInt(Math.random() * 1000 + 1000, 10)) + await takePostRequest('activityContent'); + await takePostRequest('drawContent'); + await takePostRequest('checkOpenCard'); + await $.wait(parseInt(Math.random() * 3000 + 2000, 10)) + } + } + }else{ + console.log('已全部开卡') + } + + $.log("关注: " + $.followShop) + if(!$.followShop && !$.outFlag){ + flag = true + await takePostRequest('followShop'); + await $.wait(parseInt(Math.random() * 2000 + 3000, 10)) + } + $.yaoqing = false + await takePostRequest('助力'); + if($.yaoqing){ + await takePostRequest('邀请'); + } + await takePostRequest('startDraw'); + + if(flag){ + await takePostRequest('activityContent'); + } + console.log(`${$.score}值 游戏:${$.point}`) + $.runFalag = true + let count = parseInt($.score/1000) + console.log(`抽奖次数为:${count}`) + for(m=1;count--;m++){ + console.log(`第${m}次抽奖`) + await takePostRequest('抽奖'); + if($.runFalag == false) break + if(Number(count) <= 0) break + if(m >= 10){ + console.log("抽奖太多次,多余的次数请再执行脚本") + break + } + await $.wait(parseInt(Math.random() * 2000 + 2000, 10)) + } + + await $.wait(parseInt(Math.random() * 1000 + 2000, 10)) + await takePostRequest('getDrawRecordHasCoupon'); + await takePostRequest('getShareRecord'); + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + console.log($.actorUuid) + console.log(`当前助力:${$.shareUuid}`) + if($.index == 1){ + $.shareUuid = $.actorUuid + console.log(`后面的号都会助力:${$.shareUuid}`) + } + await $.wait(parseInt(Math.random() * 1000 + 5000, 10)) + if(flag) await $.wait(parseInt(Math.random() * 1000 + 10000, 10)) + + if($.index % 3 == 0) console.log('休息1分钟,别被黑ip了\n可持续发展') + if($.index % 3 == 0) await $.wait(parseInt(Math.random() * 5000 + 60000, 10)) + + } catch (e) { + console.log(e) + } +} + +async function takePostRequest(type) { + if($.outFlag) return + let domain = 'https://lzdz1-isv.isvjcloud.com'; + let body = ``; + let method = 'POST' + let admJson = '' + switch (type) { + case 'isvObfuscator': + url = `https://api.m.jd.com/client.action?functionId=isvObfuscator`; + body = `body=%7B%22url%22%3A%22https%3A//lzdz1-isv.isvjcloud.com%22%2C%22id%22%3A%22%22%7D&uuid=7088d9018515b8cb0c88ace6e5479762af3e88f3&client=apple&clientVersion=10.1.4&st=1634343624086&sv=120&sign=8b9cea22c3a0d77026abda5d37d2b7e3`; + break; + case 'getSimpleActInfoVo': + url = `${domain}/dz/common/getSimpleActInfoVo`; + body = `activityId=${$.activityId}`; + break; + case 'getMyPing': + url = `${domain}/customer/getMyPing`; + body = `userId=${$.shopId || $.venderId || ''}&token=${$.Token}&fromType=APP`; + break; + case 'accessLogWithAD': + url = `${domain}/common/accessLogWithAD`; + let pageurl = `${domain}/drawCenter/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}` + body = `venderId=${$.shopId || $.venderId || ''}&code=99&pin=${encodeURIComponent($.Pin)}&activityId=${$.activityId}&pageUrl=${encodeURIComponent(pageurl)}&subType=app&adSource=` + break; + case 'getUserInfo': + url = `${domain}/wxActionCommon/getUserInfo`; + body = `pin=${encodeURIComponent($.Pin)}`; + break; + case 'activityContent': + url = `${domain}/play/monopoly/getContent`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&pinImg=${encodeURIComponent($.attrTouXiang)}&nick=${encodeURIComponent($.nickname)}&cjyxPin=&cjhyPin=&shareUuid=${$.shareUuid}` + break; + case 'drawContent': + url = `${domain}/dingzhi/taskact/common/drawContent`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case 'checkOpenCard': + url = `${domain}/play/monopoly/checkOpenCard`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case 'info': + url = `${domain}/play/monopoly/getTaskList`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case 'startDraw': + url = `${domain}/play/monopoly/activeDraw`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&drawType=1` + break; + case 'followShop': + url = `${domain}/play/monopoly/doTasks`; + // url = `${domain}/dingzhi/dz/openCard/saveTask`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&taskType=1` + break; + case 'sign': + case 'addCart': + case 'browseGoods': + url = `${domain}/dingzhi/linkgame/${type}`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + if(type == 'browseGoods') body += `&value=${$.visitSkuValue}` + break; + case '邀请': + case '助力': + if(type == '助力'){ + url = `${domain}/play/monopoly/getAssistStatus`; + }else{ + url = `${domain}/play/monopoly/assist`; + } + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&shareUuid=${$.shareUuid}&actorUuid=${$.actorUuid}` + break; + case 'viewVideo': + case 'visitSku': + case 'toShop': + case 'addSku': + url = `${domain}/dingzhi/dz/openCard/saveTask`; + let taskType = '' + let taskValue = '' + if(type == 'viewVideo'){ + taskType = 31 + taskValue = 31 + }else if(type == 'visitSku'){ + taskType = 5 + taskValue = $.visitSkuValue || 5 + }else if(type == 'toShop'){ + taskType = 14 + taskValue = $.toShopValue || 14 + }else if(type == 'addSku'){ + taskType = 2 + taskValue = $.addSkuValue || 2 + } + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&taskType=${taskType}&taskValue=${taskValue}` + break; + case 'getDrawRecordHasCoupon': + url = `${domain}/play/monopoly/getPrizeList`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case 'getShareRecord': + url = `${domain}/play/monopoly/getHelpList`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case '抽奖': + url = `${domain}/play/monopoly/activeDraw`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&drawType=2` + break; + default: + console.log(`错误${type}`); + } + let myRequest = getPostRequest(url, body, method); + // console.log(myRequest) + return new Promise(async resolve => { + $.post(myRequest, (err, resp, data) => { + try { + setActivityCookie(resp) + if (err) { + if(resp && typeof resp.statusCode != 'undefined'){ + if(resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + } + console.log(`${$.toStr(err,err)}`) + console.log(`${type} API请求失败,请检查网路重试`) + } else { + dealReturn(type, data); + } + } catch (e) { + // console.log(data); + console.log(e, resp) + } finally { + resolve(); + } + }) + }) + } + +async function dealReturn(type, data) { + let res = '' + try { + if(type != 'accessLogWithAD' || type != 'drawContent'){ + if(data){ + res = JSON.parse(data); + } + } + } catch (e) { + console.log(`${type} 执行任务异常`); + console.log(data); + $.runFalag = false; + } + try { + switch (type) { + case 'isvObfuscator': + if(typeof res == 'object'){ + if(res.errcode == 0){ + if(typeof res.token != 'undefined') $.Token = res.token + }else if(res.message){ + console.log(`isvObfuscator ${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + break; + case 'getSimpleActInfoVo': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(typeof res.data.shopId != 'undefined') $.shopId = res.data.shopId + if(typeof res.data.venderId != 'undefined') $.venderId = res.data.venderId + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getMyPing': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(res.data && typeof res.data.secretPin != 'undefined') $.Pin = res.data.secretPin + if(res.data && typeof res.data.nickname != 'undefined') $.nickname = res.data.nickname + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getUserInfo': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(res.data && typeof res.data.yunMidImageUrl != 'undefined') $.attrTouXiang = res.data.yunMidImageUrl || "https://img10.360buyimg.com/imgzone/jfs/t1/7020/27/13511/6142/5c5138d8E4df2e764/5a1216a3a5043c5d.png" + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'activityContent': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + $.endTime = res.data.endTime || (res.data.activityVo && res.data.activityVo.endTime) || res.data.activity.endTime || 0 + $.hasEnd = res.data.isEnd || false + $.drawCount = res.data.actorVo.drawCount || 0 + $.point = res.data.actorVo.point || 0 + $.score = res.data.actorVo.score || 0 + $.actorUuid = res.data.actorVo.actorUuid || '' + $.followShop = res.data.actorVo.followShopStatus || '' + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'info': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + // $.drawCount = res.data.drawCount || 0 + $.addCart = res.data.addCart || false + $.followShop = res.data.followShop || false + $.sign = res.data.isSignStatus || false + $.visitSku = res.data.visitSku || false + $.visitSkuList = res.data.visitSkuList || [] + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'checkOpenCard': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + let cardList1 = res.data.cardList1 || [] + let cardList2 = res.data.cardList2 || [] + let cardList = res.data.cardList || [] + let openCardList = res.data.openCardList || [] + $.openList = [...cardList,...cardList1,...cardList2,...openCardList] + $.allOpenCard = res.data.allOpenCard || res.data.isOpenCardStatus || false + $.openCardScore1 = res.data.score1 || 0 + $.openCardScore2 = res.data.score2 || 0 + $.drawScore = res.data.drawScore || 0 + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'startDraw': + case 'followShop': + case 'viewVideo': + case 'visitSku': + case 'toShop': + case 'addSku': + case 'sign': + case 'addCart': + case 'browseGoods': + case '抽奖': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(typeof res.data == 'object'){ + let msg = '' + let title = '抽奖' + if(res.data.addBeanNum){ + msg = `${res.data.addBeanNum}京豆` + } + if(res.data.addPoint){ + msg += ` ${res.data.addPoint}游戏机会` + } + if(type == 'followShop'){ + title = '关注' + if(res.data.beanNumMember && res.data.assistSendStatus){ + msg += ` 额外获得:${res.data.beanNumMember}京豆` + } + }else if(type == 'addSku' || type == 'addCart'){ + title = '加购' + }else if(type == 'viewVideo'){ + title = '热门文章' + }else if(type == 'toShop'){ + title = '浏览店铺' + }else if(type == 'visitSku' || type == 'browseGoods'){ + title = '浏览商品' + }else if(type == 'sign'){ + title = '签到' + }else{ + msg = res.data.drawOk == true && (res.data.drawInfoType == 6 && res.data.name || '') || '空气💨' + } + if(!msg){ + msg = '空气💨' + } + console.log(`${title}获得:${msg || data}`) + }else{ + console.log(`${type} ${data}`) + } + }else if(res.errorMessage){ + $.runFalag = false; + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getDrawRecordHasCoupon': + // console.log(data) + if(typeof res == 'object'){ + if(res.result && res.result === true){ + console.log(`我的奖品:`) + let num = 0 + let value = 0 + for(let i in res.data){ + let item = res.data[i] + if(item.drawId == 'assist'){ + num++ + value = item.infoName.replace('京豆','') + }else{ + console.log(`${item.infoType != 10 && item.drawId && item.drawId +':' || ''}${item.infoName}`) + } + } + if(num > 0) console.log(`邀请好友(${num}):${num*parseInt(value, 10) || 30}京豆`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getShareRecord': + if(typeof res == 'object'){ + if(res.result && res.result === true && res.data){ + $.ShareCount = res.data.length + $.log(`=========== 你邀请了:${res.data.length}个`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case '邀请': + case '助力': + // console.log(data) + if(typeof res == 'object'){ + if(res.data == 200){ + if(type == '助力'){ + console.log('助力成功') + $.yaoqing = true + } + }else if(res.data == 105){ + console.log('已经助力过') + }else if(res.data == 104){ + console.log('已经助力其他人') + }else if(res.data == 101){ + // console.log('已经助力过') + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + + case 'accessLogWithAD': + case 'drawContent': + break; + default: + console.log(`${type}-> ${data}`); + } + if(typeof res == 'object'){ + if(res.errorMessage){ + if(res.errorMessage.indexOf('火爆') >-1 ){ + $.hotFlag = true + } + } + } + } catch (e) { + console.log(e) + } +} + +function getPostRequest(url, body, method="POST") { + let headers = { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Content-Type": "application/x-www-form-urlencoded", + "Cookie": cookie, + "User-Agent": $.UA, + "X-Requested-With": "XMLHttpRequest" + } + if(url.indexOf('https://lzdz1-isv.isvjcloud.com') > -1){ + headers["Referer"] = `https://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}` + headers["Cookie"] = `${lz_jdpin_token_cookie && lz_jdpin_token_cookie || ''}${$.Pin && "AUTH_C_USER=" + $.Pin + ";" || ""}${activityCookie}` + } + // console.log(headers) + // console.log(headers.Cookie) + return {url: url, method: method, headers: headers, body: body, timeout:30000}; +} + +function getCk() { + return new Promise(resolve => { + let get = { + url:`https://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}`, + followRedirect:false, + headers: { + "User-Agent": $.UA, + }, + timeout:30000 + } + $.get(get, async(err, resp, data) => { + try { + if (err) { + if(resp && typeof resp.statusCode != 'undefined'){ + if(resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + } + console.log(`${$.toStr(err)}`) + console.log(`${$.name} cookie API请求失败,请检查网路重试`) + } else { + let end = data.match(/(活动已经结束)/) && data.match(/(活动已经结束)/)[1] || '' + if(end){ + $.activityEnd = true + console.log('活动已结束') + } + setActivityCookie(resp) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function setActivityCookie(resp){ + let LZ_TOKEN_KEY = '' + let LZ_TOKEN_VALUE = '' + let lz_jdpin_token = '' + let setcookies = resp && resp['headers'] && (resp['headers']['set-cookie'] || resp['headers']['Set-Cookie'] || '') || '' + let setcookie = '' + if(setcookies){ + if(typeof setcookies != 'object'){ + setcookie = setcookies.split(',') + }else setcookie = setcookies + for (let ck of setcookie) { + let name = ck.split(";")[0].trim() + if(name.split("=")[1]){ + // console.log(name.replace(/ /g,'')) + if(name.indexOf('LZ_TOKEN_KEY=')>-1) LZ_TOKEN_KEY = name.replace(/ /g,'')+';' + if(name.indexOf('LZ_TOKEN_VALUE=')>-1) LZ_TOKEN_VALUE = name.replace(/ /g,'')+';' + if(name.indexOf('lz_jdpin_token=')>-1) lz_jdpin_token = ''+name.replace(/ /g,'')+';' + } + } + } + if(LZ_TOKEN_KEY && LZ_TOKEN_VALUE) activityCookie = `${LZ_TOKEN_KEY} ${LZ_TOKEN_VALUE}` + if(lz_jdpin_token) lz_jdpin_token_cookie = lz_jdpin_token +} + +async function getUA(){ + $.UA = `jdapp;iPhone;10.1.4;13.1.2;${randomString(40)};network/wifi;model/iPhone8,1;addressid/2308460611;appBuild/167814;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_1_2 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 joinShop() { + if(!$.joinVenderId) return + return new Promise(async resolve => { + $.shopactivityId = '' + await $.wait(1000) + await getshopactivityId() + let activityId = `` + if($.shopactivityId) activityId = `,"activityId":${$.shopactivityId}` + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body={"venderId":"${$.joinVenderId}","shopId":"${$.joinVenderId}","bindByVerifyCodeFlag":1,"registerExtend":{},"writeChildFlag":0${activityId},"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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + // console.log(data) + let res = $.toObj(data); + if(typeof res == 'object'){ + if(res.success === true){ + console.log(res.message) + if(res.result && res.result.giftInfo){ + for(let i of res.result.giftInfo.giftList){ + console.log(`入会获得:${i.discountString}${i.prizeName}${i.secondLineDesc}`) + } + } + }else if(typeof res == 'object' && res.message){ + console.log(`${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function getshopactivityId() { + return new Promise(resolve => { + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body=%7B%22venderId%22%3A%22${$.joinVenderId}%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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + let res = $.toObj(data); + if(res.success == true){ + // console.log($.toStr(res.result)) + console.log(`入会:${res.result.shopMemberCardInfo.venderCardName || ''}`) + $.shopactivityId = res.result.interestsRuleList && res.result.interestsRuleList[0] && res.result.interestsRuleList[0].interestsInfo && res.result.interestsRuleList[0].interestsInfo.activityId || '' + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} + + +// 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)} diff --git a/activity/jd_opencardLH34.js b/activity/jd_opencardLH34.js new file mode 100644 index 0000000..34660b1 --- /dev/null +++ b/activity/jd_opencardLH34.js @@ -0,0 +1,546 @@ +/* +12.21~12.30 联合开卡 [jd_opencardLH34.js] +开卡脚本,一次性脚本 + +1.邀请一人20豆(有可能没有豆 +2.开14张 成功开1张 可能获得5京豆 + 全部开完获得1次抽奖 +3.关注10京豆 获得1次抽奖 +4.加购5京豆 获得1次抽奖 + + +第一个账号助力作者 其他依次助力CK1 +第一个CK失效会退出脚本 + +请求太频繁会被黑ip +过10分钟再执行 + + +cron:50 0,16 22-30/2 12 * +============Quantumultx=============== +[task_local] +#12.21~12.30 联合开卡 +50 0,16 22-30/2 12 * https://raw.githubusercontent.com/KingRan/JDJB/main/jd_opencardLH34.js, tag=12.21~12.30 联合开卡, enabled=true + +*/ +const $ = new Env('12.21~12.30 联合开卡'); +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const notify = $.isNode() ? require('./sendNotify') : ''; +//IOS等用户直接用NobyDa的jd cookie +let cookiesArr = [], + cookie = ''; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} + +allMessage = "" +message = "" +$.hotFlag = false +$.outFlag = false +$.activityEnd = false +let lz_jdpin_token_cookie ='' +let activityCookie ='' +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', { + "open-url": "https://bean.m.jd.com/" + }); + return; + } + // return + $.appkey = '51B59BB805903DA4CE513D29EC448375' + $.userId = '10299171' + $.actId = 'f05b3521f8374693b010ba8da_1221' + $.MixNicks = '' + $.inviteNick = 'k1Nobb+P0er+C2sysxnx/P2KELO9izRVpwCyqu0eqVZ5aW7RHzlMobrzJ/e9r/uf' + console.log(`活动地址:https://3.cn/1-03Mebc9`) + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i]; + if (cookie) { + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + message = "" + $.bean = 0 + $.hotFlag = false + $.nickName = ''; + console.log(`\n\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + await getUA() + await run(); + if(i == 0 && !$.MixNick) break + if($.outFlag || $.activityEnd) break + } + } + if($.outFlag) { + let msg = '此ip已被限制,请过10分钟后再执行脚本' + $.msg($.name, ``, `${msg}`); + if ($.isNode()) await notify.sendNotify(`${$.name}`, `${msg}`); + } +})() + .catch((e) => $.logErr(e)) + .finally(() => $.done()) + + +async function run() { + try { + $.hasEnd = true + $.endTime = 0 + lz_jdpin_token_cookie = '' + $.Token = '' + $.Pin = '' + $.MixNick = '' + let flag = false + if($.activityEnd) return + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + await takePostRequest('isvObfuscator'); + if($.Token == ''){ + console.log('获取[token]失败!') + return + } + await takePostRequest('activity_load'); + if($.hotFlag) return + if(Date.now() > $.endTime){ + $.MixNick = '' + $.activityEnd = true + console.log('活动结束') + return + } + if ($.MixNick == '') { + console.log(`获取cookie失败`); return; + } + // console.log($.MixNick) + // return + $.toBind = 0 + $.openList = [] + await takePostRequest('绑定'); + await takePostRequest('shopList'); + for(o of $.openList){ + $.missionType = 'openCard' + if(o.open != true && o.openCardUrl){ + $.openCard = false + $.joinVenderId = o.userId + await takePostRequest('mission'); + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + if($.openCard == true){ + await joinShop() + await takePostRequest('activity_load'); + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + // break + } + $.joinVenderId = '' + } + } + $.joinVenderId = '' + if($.hasCollectShop === 0){ + // 关注 + $.missionType = 'uniteCollectShop' + await takePostRequest('mission'); + await $.wait(parseInt(Math.random() * 2000 + 3000, 10)) + }else{ + console.log('已经关注') + } + $.missionType = 'uniteAddCart' + await takePostRequest('mission'); + await $.wait(parseInt(Math.random() * 2000 + 3000, 10)) + + await takePostRequest('activity_load'); + $.runFalag = true + let count = parseInt($.usedChance, 10) + console.log(`抽奖次数为:${count}`) + for(m=1;count--;m++){ + console.log(`第${m}次抽奖`) + await takePostRequest('抽奖'); + if($.runFalag == false) break + if(Number(count) <= 0) break + if(m >= 10){ + console.log("抽奖太多次,多余的次数请再执行脚本") + break + } + await $.wait(parseInt(Math.random() * 2000 + 2000, 10)) + } + await takePostRequest('myAward'); + await takePostRequest('missionInviteList'); + console.log($.MixNick) + console.log(`当前助力:${$.inviteNick}`) + if($.index == 1){ + $.inviteNick = $.MixNick + console.log(`后面的号都会助力:${$.inviteNick}`) + } + await $.wait(parseInt(Math.random() * 1000 + 5000, 10)) + if(flag) await $.wait(parseInt(Math.random() * 1000 + 10000, 10)) + + if($.index % 3 == 0) console.log('休息1分钟,别被黑ip了\n可持续发展') + if($.index % 3 == 0) await $.wait(parseInt(Math.random() * 5000 + 60000, 10)) + + } catch (e) { + console.log(e) + } +} + +async function takePostRequest(type) { + if($.outFlag) return + let domain = 'https://jinggengjcq-isv.isvjcloud.com'; + let body = ``; + let method = 'POST' + let admJson = '' + switch (type) { + case 'isvObfuscator': + url = `https://api.m.jd.com/client.action?functionId=isvObfuscator`; + body = `body=%7B%22url%22%3A%22https%3A//jinggengjcq-isv.isvjcloud.com/fronth5/%3Flng%3D0%26lat%3D0%26sid%3D49687cd64aca2ae93aa43748a04e8f6w%26un_area%3D16_1315_1316_53522%23/pages/unitedCardNew20211010-ka/unitedCardNew20211010-ka%3FactId%3D9150e1d16b9d40_10101%22%2C%22id%22%3A%22%22%7D&uuid=b9b4ce69d42dacb64084279d51cdee764d7781fa&client=apple&clientVersion=10.1.4&st=1634100732991&sv=111&sign=67e254ffbcb13be9e12a9782c9cdf398`; + break; + case 'activity_load': + url = `${domain}/dm/front/openCardNew/activity_load?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"jdToken": $.Token, "source": "01", "inviteNick":($.inviteNick || "")} + if($.joinVenderId) admJson = {...admJson, "shopId": `${$.joinVenderId}`} + body = taskPostUrl("/openCardNew/activity_load", admJson); + break; + case 'shopList': + url = `${domain}/dm/front/openCardNew/shopList?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {} + body = taskPostUrl("/openCardNew/shopList", admJson); + break; + case '绑定': + url = `${domain}/dm/front/openCardNew/complete/mission?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"missionType": "relationBind", "inviterNick":($.inviteNick || "")} + body = taskPostUrl("/openCardNew/complete/mission", admJson); + break; + case 'mission': + url = `${domain}/dm/front/openCardNew/complete/mission?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"missionType": $.missionType} + if($.joinVenderId) admJson = {...admJson, "shopId": $.joinVenderId} + body = taskPostUrl("/openCardNew/complete/mission", admJson); + break; + case '抽奖': + url = `${domain}/dm/front/openCardNew/draw/post?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"dataType": "draw", "usedGameNum": "2"} + body = taskPostUrl("/openCardNew/draw/post", admJson); + break; + case 'followShop': + url = `${domain}/dm/front/openCardNew/followShop?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"actId": $.actId, "missionType": "collectShop"} + body = taskPostUrl("/openCardNew/followShop", admJson); + break; + case 'addCart': + url = `${domain}/dm/front/openCardNew/addCart?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"actId": $.actId, "missionType": "addCart"} + body = taskPostUrl("/openCardNew/addCart", admJson); + break; + case 'myAward': + url = `${domain}/dm/front/openCardNew/myAwards?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"pageNo": 1,"pageSize":9999} + body = taskPostUrl("/openCardNew/myAwards", admJson); + break; + case 'missionInviteList': + url = `${domain}/dm/front/openCardNew/missionInviteList?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"inviteListRequest":{"actId":$.actId,"userId":10299171,"missionType":"shareAct","inviteType": 1,"buyerNick":($.MixNick || '')}} + body = taskPostUrl("/openCardNew/missionInviteList", admJson); + break; + default: + console.log(`错误${type}`); + } + let myRequest = getPostRequest(url, body, method); + return new Promise(async resolve => { + $.post(myRequest, (err, resp, data) => { + try { + if (err) { + if(resp && resp.statusCode && resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + console.log(`${$.toStr(err,err)}`) + console.log(`${type} API请求失败,请检查网路重试`) + } else { + dealReturn(type, data); + } + } catch (e) { + // console.log(data); + console.log(e, resp) + } finally { + resolve(); + } + }) + }) + } + +async function dealReturn(type, data) { + let res = '' + try { + if(type != 'accessLogWithAD' || type != 'drawContent'){ + if(data){ + res = JSON.parse(data); + } + } + } catch (e) { + console.log(`${type} 执行任务异常`); + console.log(data); + $.runFalag = false; + } + try { + let title = '' + switch (type) { + case 'isvObfuscator': + if(typeof res == 'object'){ + if(res.errcode == 0){ + if(typeof res.token != 'undefined') $.Token = res.token + }else if(res.message){ + console.log(`${type} ${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + break; + case 'accessLogWithAD': + case 'drawContent': + break; + case 'activity_load': + case 'mission': + case 'shopList': + case 'loadUniteOpenCard': + case 'setMixNick': + case 'uniteOpenCardOne': + case 'checkOpenCard': + case 'followShop': + case 'addCart': + case 'myAward': + case 'missionInviteList': + case '抽奖': + title = '' + if(type == "followShop") title = '关注' + if(type == "addCart") title = '加购' + if(typeof res == 'object'){ + if(res.success && res.success === true && res.data){ + if(res.data.status && res.data.status == 200){ + res = res.data + if(type != "setMixNick" && (res.msg || res.data.isOpenCard || res.data.remark)) console.log(`${title && title+":" || ""}${res.msg || res.data.isOpenCard || res.data.remark || ''}`) + if(type == "activity_load"){ + if(res.msg || res.data.isOpenCard) { + if((res.msg || res.data.isOpenCard || '').indexOf('绑定成功') > -1) $.toBind = 1 + } + if(res.data){ + $.endTime = res.data.cusActivity.endTime || 0 + $.MixNick = res.data.buyerNick || "" + $.usedChance = res.data.missionCustomer.usedChance || 0 + $.hasCollectShop = res.data.missionCustomer.hasCollectShop || 0 + } + }else if(type == "shopList"){ + $.openList = res.data.cusShops || [] + }else if(type == "mission"){ + if(res.data.remark.indexOf('不是会员') > -1){ + $.openCard = true + }else{ + $.openCard = false + } + }else if(type == "uniteOpenCardOne"){ + $.uniteOpenCar = res.msg || res.data.msg || '' + }else if(type == "myAward"){ + console.log(`我的奖品:`) + let num = 0 + let value = 0 + for(let i in res.data.list || []){ + let item = res.data.list[i] + if(item.awardDes == '20'){ + num++ + value = item.awardDes + }else{ + console.log(`${item.awardName}`) + } + } + if(num > 0) console.log(`邀请好友(${num}):${num*parseInt(value, 10) || 30}京豆`) + }else if(type == "missionInviteList"){ + console.log(`邀请人数(${res.data.invitedLogList.total})`) + } + }else if(res.data.msg){ + console.log(`${title || type} ${res.data.msg || ''}`) + }else if(res.errorMessage){ + if(res.errorMessage.indexOf('火爆') >-1 ){ + $.hotFlag = true + } + console.log(`${title || type} ${res.errorMessage || ''}`) + }else{ + console.log(`${title || type} ${data}`) + } + }else if(res.errorMessage){ + console.log(`${title || type} ${res.errorMessage || ''}`) + }else{ + console.log(`${title || type} ${data}`) + } + }else{ + console.log(`${title || type} ${data}`) + } + break; + default: + console.log(`${title || type}-> ${data}`); + } + if(typeof res == 'object'){ + if(res.errorMessage){ + if(res.errorMessage.indexOf('火爆') >-1 ){ + $.hotFlag = true + } + } + } + } catch (e) { + console.log(e) + } +} + +function getPostRequest(url, body, method="POST") { + let headers = { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Content-Type": "application/x-www-form-urlencoded", + "Cookie": cookie, + "User-Agent": $.UA, + "X-Requested-With": "XMLHttpRequest" + } + if(url.indexOf('https://jinggengjcq-isv.isvjcloud.com') > -1){ + headers["Origin"] = `https://jinggengjcq-isv.isvjcloud.com` + headers["Content-Type"] = `application/json; charset=utf-8` + delete headers["Cookie"] + } + // console.log(headers) + // console.log(headers.Cookie) + return {url: url, method: method, headers: headers, body: body, timeout:30000}; +} + + +function taskPostUrl(url, t) { + + const b = { + "jsonRpc": "2.0", + "params": { + "commonParameter": { + "appkey": $.appkey, + "m": "POST", + "timestamp": Date.now(), + "userId": $.userId + }, + "admJson": { + "actId": $.actId, + "userId": $.userId, + ...t, + "method": url, + "buyerNick": ($.MixNick || ''), + } + }, + } + if(url.indexOf('missionInviteList') > -1){ + delete b.params.admJson.actId + } + return $.toStr(b,b) +} +async function getUA(){ + $.UA = `jdapp;iPhone;10.1.4;13.1.2;${randomString(40)};network/wifi;model/iPhone8,1;addressid/2308460611;appBuild/167814;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_1_2 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 jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} + +function joinShop() { + if(!$.joinVenderId) return + return new Promise(async resolve => { + $.shopactivityId = '' + await $.wait(1000) + await getshopactivityId() + let activityId = `` + if($.shopactivityId) activityId = `,"activityId":${$.shopactivityId}` + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body={"venderId":"${$.joinVenderId}","shopId":"${$.joinVenderId}","bindByVerifyCodeFlag":1,"registerExtend":{},"writeChildFlag":0${activityId},"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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + // console.log(data) + let res = $.toObj(data); + if(typeof res == 'object'){ + if(res.success === true){ + console.log(res.message) + if(res.result && res.result.giftInfo){ + for(let i of res.result.giftInfo.giftList){ + console.log(`入会获得:${i.discountString}${i.prizeName}${i.secondLineDesc}`) + } + } + }else if(typeof res == 'object' && res.message){ + console.log(`${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function getshopactivityId() { + return new Promise(resolve => { + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body=%7B%22venderId%22%3A%22${$.joinVenderId}%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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + let res = $.toObj(data); + if(res.success == true){ + // console.log($.toStr(res.result)) + console.log(`入会:${res.result.shopMemberCardInfo.venderCardName || ''}`) + $.shopactivityId = res.result.interestsRuleList && res.result.interestsRuleList[0] && res.result.interestsRuleList[0].interestsInfo && res.result.interestsRuleList[0].interestsInfo.activityId || '' + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +// 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)} + diff --git a/activity/jd_opencardLH35.js b/activity/jd_opencardLH35.js new file mode 100644 index 0000000..fb8a402 --- /dev/null +++ b/activity/jd_opencardLH35.js @@ -0,0 +1,546 @@ +/* +12.23~1.2 联合开卡 [jd_opencardLH35.js] +新增开卡脚本,一次性脚本 + +1.邀请一人20豆(有可能没有豆 +2.开10张 成功开1张 可能获得5京豆 + 全部开完获得1次抽奖 +3.关注10京豆 获得1次抽奖 +4.加购5京豆 获得1次抽奖 +5.抽奖 + +第一个账号助力作者 其他依次助力CK1 +第一个CK失效会退出脚本 + +———————————————— +入口:[ 12.23~1.2 联合开卡 (https://3.cn/103-Nmnge)] + +请求太频繁会被黑ip +过10分钟再执行 + + +cron:1 1,14 26-30/2,2 12,1 * +============Quantumultx=============== +[task_local] +#12.23~1.2 联合开卡 +1 1,14 26-30/2,2 12,1 * https://raw.githubusercontent.com/KingRan/JDJB/main/jd_opencardLH35.js, tag=12.23~1.2 联合开卡, enabled=true + +*/ + +const $ = new Env('12.23~1.2 联合开卡-90'); +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const notify = $.isNode() ? require('./sendNotify') : ''; +//IOS等用户直接用NobyDa的jd cookie +let cookiesArr = [], + cookie = ''; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} +allMessage = "" +message = "" +$.hotFlag = false +$.outFlag = false +$.activityEnd = false +let lz_jdpin_token_cookie ='' +let activityCookie ='' +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', { + "open-url": "https://bean.m.jd.com/" + }); + return; + } + // return + $.appkey = '51B59BB805903DA4CE513D29EC448375' + $.userId = '10299171' + $.actId = '58f75e450e7b4ac99871bd9f_1223' + $.MixNicks = '' + $.inviteNick = 'k1Nobb+P0er+C2sysxnx/P2KELO9izRVpwCyqu0eqVZ5aW7RHzlMobrzJ/e9r/uf' + console.log(`活动地址:https://3.cn/103-Nmnge`) + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i]; + if (cookie) { + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + message = "" + $.bean = 0 + $.hotFlag = false + $.nickName = ''; + console.log(`\n\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + await getUA() + await run(); + if(i == 0 && !$.MixNick) break + if($.outFlag || $.activityEnd) break + } + } + if($.outFlag) { + let msg = '此ip已被限制,请过10分钟后再执行脚本' + $.msg($.name, ``, `${msg}`); + if ($.isNode()) await notify.sendNotify(`${$.name}`, `${msg}`); + } +})() + .catch((e) => $.logErr(e)) + .finally(() => $.done()) + + +async function run() { + try { + $.hasEnd = true + $.endTime = 0 + lz_jdpin_token_cookie = '' + $.Token = '' + $.Pin = '' + $.MixNick = '' + let flag = false + if($.activityEnd) return + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + await takePostRequest('isvObfuscator'); + if($.Token == ''){ + console.log('获取[token]失败!') + return + } + await takePostRequest('activity_load'); + if($.hotFlag) return + if(Date.now() > $.endTime){ + $.MixNick = '' + $.activityEnd = true + console.log('活动结束') + return + } + if ($.MixNick == '') { + console.log(`获取cookie失败`); return; + } + // console.log($.MixNick) + // return + $.toBind = 0 + $.openList = [] + await takePostRequest('绑定'); + await takePostRequest('shopList'); + for(o of $.openList){ + $.missionType = 'openCard' + if(o.open != true && o.openCardUrl){ + $.openCard = false + $.joinVenderId = o.userId + await takePostRequest('mission'); + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + if($.openCard == true){ + await joinShop() + await takePostRequest('activity_load'); + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + // break + } + $.joinVenderId = '' + } + } + $.joinVenderId = '' + if($.hasCollectShop === 0){ + // 关注 + $.missionType = 'uniteCollectShop' + await takePostRequest('mission'); + await $.wait(parseInt(Math.random() * 2000 + 3000, 10)) + }else{ + console.log('已经关注') + } + $.missionType = 'uniteAddCart' + await takePostRequest('mission'); + await $.wait(parseInt(Math.random() * 2000 + 3000, 10)) + await takePostRequest('activity_load'); + $.runFalag = true + let count = parseInt($.usedChance, 10) + console.log(`抽奖次数为:${count}`) + for(m=1;count--;m++){ + console.log(`第${m}次抽奖`) + await takePostRequest('抽奖'); + if($.runFalag == false) break + if(Number(count) <= 0) break + if(m >= 10){ + console.log("抽奖太多次,多余的次数请再执行脚本") + break + } + await $.wait(parseInt(Math.random() * 2000 + 2000, 10)) + } + await takePostRequest('myAward'); + await takePostRequest('missionInviteList'); + console.log($.MixNick) + console.log(`当前助力:${$.inviteNick}`) + if($.index == 1){ + $.inviteNick = $.MixNick + console.log(`后面的号都会助力:${$.inviteNick}`) + } + await $.wait(parseInt(Math.random() * 1000 + 5000, 10)) + if(flag) await $.wait(parseInt(Math.random() * 1000 + 10000, 10)) + if($.index % 3 == 0) console.log('休息1分钟,别被黑ip了\n可持续发展') + if($.index % 3 == 0) await $.wait(parseInt(Math.random() * 5000 + 60000, 10)) + } catch (e) { + console.log(e) + } +} + +async function takePostRequest(type) { + if($.outFlag) return + let domain = 'https://jinggengjcq-isv.isvjcloud.com'; + let body = ``; + let method = 'POST' + let admJson = '' + switch (type) { + case 'isvObfuscator': + url = `https://api.m.jd.com/client.action?functionId=isvObfuscator`; + body = `body=%7B%22url%22%3A%22https%3A//jinggengjcq-isv.isvjcloud.com/fronth5/%3Flng%3D0%26lat%3D0%26sid%3D49687cd64aca2ae93aa43748a04e8f6w%26un_area%3D16_1315_1316_53522%23/pages/unitedCardNew20211010-ka/unitedCardNew20211010-ka%3FactId%3D9150e1d16b9d40_10101%22%2C%22id%22%3A%22%22%7D&uuid=b9b4ce69d42dacb64084279d51cdee764d7781fa&client=apple&clientVersion=10.1.4&st=1634100732991&sv=111&sign=67e254ffbcb13be9e12a9782c9cdf398`; + break; + case 'activity_load': + url = `${domain}/dm/front/openCardNew/activity_load?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"jdToken": $.Token, "source": "01", "inviteNick":($.inviteNick || "")} + if($.joinVenderId) admJson = {...admJson, "shopId": `${$.joinVenderId}`} + body = taskPostUrl("/openCardNew/activity_load", admJson); + break; + case 'shopList': + url = `${domain}/dm/front/openCardNew/shopList?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {} + body = taskPostUrl("/openCardNew/shopList", admJson); + break; + case '绑定': + url = `${domain}/dm/front/openCardNew/complete/mission?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"missionType": "relationBind", "inviterNick":($.inviteNick || "")} + body = taskPostUrl("/openCardNew/complete/mission", admJson); + break; + case 'mission': + url = `${domain}/dm/front/openCardNew/complete/mission?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"missionType": $.missionType} + if($.joinVenderId) admJson = {...admJson, "shopId": $.joinVenderId} + body = taskPostUrl("/openCardNew/complete/mission", admJson); + break; + case '抽奖': + url = `${domain}/dm/front/openCardNew/draw/post?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"dataType": "draw", "usedGameNum": "2"} + body = taskPostUrl("/openCardNew/draw/post", admJson); + break; + case 'followShop': + url = `${domain}/dm/front/openCardNew/followShop?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"actId": $.actId, "missionType": "collectShop"} + body = taskPostUrl("/openCardNew/followShop", admJson); + break; + case 'addCart': + url = `${domain}/dm/front/openCardNew/addCart?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"actId": $.actId, "missionType": "addCart"} + body = taskPostUrl("/openCardNew/addCart", admJson); + break; + case 'myAward': + url = `${domain}/dm/front/openCardNew/myAwards?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"pageNo": 1,"pageSize":9999} + body = taskPostUrl("/openCardNew/myAwards", admJson); + break; + case 'missionInviteList': + url = `${domain}/dm/front/openCardNew/missionInviteList?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"inviteListRequest":{"actId":$.actId,"userId":10299171,"missionType":"shareAct","inviteType": 1,"buyerNick":($.MixNick || '')}} + body = taskPostUrl("/openCardNew/missionInviteList", admJson); + break; + default: + console.log(`错误${type}`); + } + let myRequest = getPostRequest(url, body, method); + return new Promise(async resolve => { + $.post(myRequest, (err, resp, data) => { + try { + if (err) { + if(resp && resp.statusCode && resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + console.log(`${$.toStr(err,err)}`) + console.log(`${type} API请求失败,请检查网路重试`) + } else { + dealReturn(type, data); + } + } catch (e) { + // console.log(data); + console.log(e, resp) + } finally { + resolve(); + } + }) + }) + } + +async function dealReturn(type, data) { + let res = '' + try { + if(type != 'accessLogWithAD' || type != 'drawContent'){ + if(data){ + res = JSON.parse(data); + } + } + } catch (e) { + console.log(`${type} 执行任务异常`); + console.log(data); + $.runFalag = false; + } + try { + let title = '' + switch (type) { + case 'isvObfuscator': + if(typeof res == 'object'){ + if(res.errcode == 0){ + if(typeof res.token != 'undefined') $.Token = res.token + }else if(res.message){ + console.log(`${type} ${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + break; + case 'accessLogWithAD': + case 'drawContent': + break; + case 'activity_load': + case 'mission': + case 'shopList': + case 'loadUniteOpenCard': + case 'setMixNick': + case 'uniteOpenCardOne': + case 'checkOpenCard': + case 'followShop': + case 'addCart': + case 'myAward': + case 'missionInviteList': + case '抽奖': + title = '' + if(type == "followShop") title = '关注' + if(type == "addCart") title = '加购' + if(typeof res == 'object'){ + if(res.success && res.success === true && res.data){ + if(res.data.status && res.data.status == 200){ + res = res.data + if(type != "setMixNick" && (res.msg || res.data.isOpenCard || res.data.remark)) console.log(`${title && title+":" || ""}${res.msg || res.data.isOpenCard || res.data.remark || ''}`) + if(type == "activity_load"){ + if(res.msg || res.data.isOpenCard) { + if((res.msg || res.data.isOpenCard || '').indexOf('绑定成功') > -1) $.toBind = 1 + } + if(res.data){ + $.endTime = res.data.cusActivity.endTime || 0 + $.MixNick = res.data.buyerNick || "" + $.usedChance = res.data.missionCustomer.usedChance || 0 + $.hasCollectShop = res.data.missionCustomer.hasCollectShop || 0 + } + }else if(type == "shopList"){ + $.openList = res.data.cusShops || [] + }else if(type == "mission"){ + if(res.data.remark.indexOf('不是会员') > -1){ + $.openCard = true + }else{ + $.openCard = false + } + }else if(type == "uniteOpenCardOne"){ + $.uniteOpenCar = res.msg || res.data.msg || '' + }else if(type == "myAward"){ + console.log(`我的奖品:`) + let num = 0 + let value = 0 + for(let i in res.data.list || []){ + let item = res.data.list[i] + if(item.awardDes == '20'){ + num++ + value = item.awardDes + }else{ + console.log(`${item.awardName}`) + } + } + if(num > 0) console.log(`邀请好友(${num}):${num*parseInt(value, 10) || 30}京豆`) + }else if(type == "missionInviteList"){ + console.log(`邀请人数(${res.data.invitedLogList.total})`) + } + }else if(res.data.msg){ + console.log(`${title || type} ${res.data.msg || ''}`) + }else if(res.errorMessage){ + if(res.errorMessage.indexOf('火爆') >-1 ){ + $.hotFlag = true + } + console.log(`${title || type} ${res.errorMessage || ''}`) + }else{ + console.log(`${title || type} ${data}`) + } + }else if(res.errorMessage){ + console.log(`${title || type} ${res.errorMessage || ''}`) + }else{ + console.log(`${title || type} ${data}`) + } + }else{ + console.log(`${title || type} ${data}`) + } + break; + default: + console.log(`${title || type}-> ${data}`); + } + if(typeof res == 'object'){ + if(res.errorMessage){ + if(res.errorMessage.indexOf('火爆') >-1 ){ + $.hotFlag = true + } + } + } + } catch (e) { + console.log(e) + } +} + +function getPostRequest(url, body, method="POST") { + let headers = { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Content-Type": "application/x-www-form-urlencoded", + "Cookie": cookie, + "User-Agent": $.UA, + "X-Requested-With": "XMLHttpRequest" + } + if(url.indexOf('https://jinggengjcq-isv.isvjcloud.com') > -1){ + headers["Origin"] = `https://jinggengjcq-isv.isvjcloud.com` + headers["Content-Type"] = `application/json; charset=utf-8` + delete headers["Cookie"] + } + // console.log(headers) + // console.log(headers.Cookie) + return {url: url, method: method, headers: headers, body: body, timeout:60000}; +} + + +function taskPostUrl(url, t) { + + const b = { + "jsonRpc": "2.0", + "params": { + "commonParameter": { + "appkey": $.appkey, + "m": "POST", + "timestamp": Date.now(), + "userId": $.userId + }, + "admJson": { + "actId": $.actId, + "userId": $.userId, + ...t, + "method": url, + "buyerNick": ($.MixNick || ''), + } + }, + } + if(url.indexOf('missionInviteList') > -1){ + delete b.params.admJson.actId + } + return $.toStr(b,b) +} +async function getUA(){ + $.UA = `jdapp;iPhone;10.1.4;13.1.2;${randomString(40)};network/wifi;model/iPhone8,1;addressid/2308460611;appBuild/167814;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_1_2 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 jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} + +function joinShop() { + if(!$.joinVenderId) return + return new Promise(async resolve => { + $.shopactivityId = '' + await $.wait(1000) + await getshopactivityId() + let activityId = `` + if($.shopactivityId) activityId = `,"activityId":${$.shopactivityId}` + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body={"venderId":"${$.joinVenderId}","shopId":"${$.joinVenderId}","bindByVerifyCodeFlag":1,"registerExtend":{},"writeChildFlag":0${activityId},"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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + // console.log(data) + let res = $.toObj(data); + if(typeof res == 'object'){ + if(res.success === true){ + console.log(res.message) + if(res.result && res.result.giftInfo){ + for(let i of res.result.giftInfo.giftList){ + console.log(`入会获得:${i.discountString}${i.prizeName}${i.secondLineDesc}`) + } + } + }else if(typeof res == 'object' && res.message){ + console.log(`${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function getshopactivityId() { + return new Promise(resolve => { + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body=%7B%22venderId%22%3A%22${$.joinVenderId}%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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + let res = $.toObj(data); + if(res.success == true){ + // console.log($.toStr(res.result)) + console.log(`入会:${res.result.shopMemberCardInfo.venderCardName || ''}`) + $.shopactivityId = res.result.interestsRuleList && res.result.interestsRuleList[0] && res.result.interestsRuleList[0].interestsInfo && res.result.interestsRuleList[0].interestsInfo.activityId || '' + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +// 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)} + diff --git a/activity/jd_opencardLH36.js b/activity/jd_opencardLH36.js new file mode 100644 index 0000000..be56447 --- /dev/null +++ b/activity/jd_opencardLH36.js @@ -0,0 +1,547 @@ +/* +12.20~12.26 联合开卡 [jd_opencardLH36.js] +新增开卡脚本,一次性脚本 + +1.邀请一人20豆(有可能没有豆 +2.开11张 成功开1张 可能获得5京豆 + 全部开完获得1次抽奖 +3.关注10京豆 获得1次抽奖 +4.加购5京豆 +5.抽奖 + +第一个账号助力作者 其他依次助力CK1 +第一个CK失效会退出脚本 + +———————————————— +入口:[ 12.20~12.26 联合开卡 (https://3.cn/103-Mi73p)] + +请求太频繁会被黑ip +过10分钟再执行 + + +cron:30 5,19 24,25,26 12 * +============Quantumultx=============== +[task_local] +#12.20~12.26 联合开卡 +30 5,19 24,25,26 12 * https://raw.githubusercontent.com/KingRan/JDJB/main/jd_opencardLH36.js, tag=12.20~12.26 联合开卡, enabled=true + +*/ + +const $ = new Env('12.20~12.26 联合开卡'); +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const notify = $.isNode() ? require('./sendNotify') : ''; +//IOS等用户直接用NobyDa的jd cookie +let cookiesArr = [], + cookie = ''; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} +allMessage = "" +message = "" +$.hotFlag = false +$.outFlag = false +$.activityEnd = false +let lz_jdpin_token_cookie ='' +let activityCookie ='' +!(async () => { + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', { + "open-url": "https://bean.m.jd.com/" + }); + return; + } + // return + $.appkey = '51B59BB805903DA4CE513D29EC448375' + $.userId = '10299171' + $.actId = '82243a5746d04_1220' + $.MixNicks = '' + $.inviteNick = 'k1Nobb+P0er+C2sysxnx/P2KELO9izRVpwCyqu0eqVZ5aW7RHzlMobrzJ/e9r/uf' + console.log(`活动地址:https://3.cn/103-Mi73p`) + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i]; + if (cookie) { + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + message = "" + $.bean = 0 + $.hotFlag = false + $.nickName = ''; + console.log(`\n\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + await getUA() + await run(); + if(i == 0 && !$.MixNick) break + if($.outFlag || $.activityEnd) break + } + } + if($.outFlag) { + let msg = '此ip已被限制,请过10分钟后再执行脚本' + $.msg($.name, ``, `${msg}`); + if ($.isNode()) await notify.sendNotify(`${$.name}`, `${msg}`); + } +})() + .catch((e) => $.logErr(e)) + .finally(() => $.done()) + + +async function run() { + try { + $.hasEnd = true + $.endTime = 0 + lz_jdpin_token_cookie = '' + $.Token = '' + $.Pin = '' + $.MixNick = '' + let flag = false + if($.activityEnd) return + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + await takePostRequest('isvObfuscator'); + if($.Token == ''){ + console.log('获取[token]失败!') + return + } + await takePostRequest('activity_load'); + if($.hotFlag) return + if(Date.now() > $.endTime){ + $.MixNick = '' + $.activityEnd = true + console.log('活动结束') + return + } + if ($.MixNick == '') { + console.log(`获取cookie失败`); return; + } + // console.log($.MixNick) + // return + $.toBind = 0 + $.openList = [] + await takePostRequest('绑定'); + await takePostRequest('shopList'); + for(o of $.openList){ + $.missionType = 'openCard' + if(o.open != true && o.openCardUrl){ + $.openCard = false + $.joinVenderId = o.userId + await takePostRequest('mission'); + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + if($.openCard == true){ + await joinShop() + await takePostRequest('activity_load'); + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + // break + } + $.joinVenderId = '' + } + } + $.joinVenderId = '' + if($.hasCollectShop === 0){ + // 关注 + $.missionType = 'uniteCollectShop' + await takePostRequest('mission'); + await $.wait(parseInt(Math.random() * 2000 + 3000, 10)) + }else{ + console.log('已经关注') + } + $.missionType = 'uniteAddCart' + await takePostRequest('mission'); + await $.wait(parseInt(Math.random() * 2000 + 3000, 10)) + + await takePostRequest('activity_load'); + $.runFalag = true + let count = parseInt($.usedChance, 10) + console.log(`抽奖次数为:${count}`) + for(m=1;count--;m++){ + console.log(`第${m}次抽奖`) + await takePostRequest('抽奖'); + if($.runFalag == false) break + if(Number(count) <= 0) break + if(m >= 10){ + console.log("抽奖太多次,多余的次数请再执行脚本") + break + } + await $.wait(parseInt(Math.random() * 2000 + 2000, 10)) + } + await takePostRequest('myAward'); + await takePostRequest('missionInviteList'); + console.log($.MixNick) + console.log(`当前助力:${$.inviteNick}`) + if($.index == 1){ + $.inviteNick = $.MixNick + console.log(`后面的号都会助力:${$.inviteNick}`) + } + await $.wait(parseInt(Math.random() * 1000 + 5000, 10)) + if(flag) await $.wait(parseInt(Math.random() * 1000 + 10000, 10)) + if($.index % 3 == 0) console.log('休息1分钟,别被黑ip了\n可持续发展') + if($.index % 3 == 0) await $.wait(parseInt(Math.random() * 5000 + 60000, 10)) + } catch (e) { + console.log(e) + } +} + +async function takePostRequest(type) { + if($.outFlag) return + let domain = 'https://jinggengjcq-isv.isvjcloud.com'; + let body = ``; + let method = 'POST' + let admJson = '' + switch (type) { + case 'isvObfuscator': + url = `https://api.m.jd.com/client.action?functionId=isvObfuscator`; + body = `body=%7B%22url%22%3A%22https%3A//jinggengjcq-isv.isvjcloud.com/fronth5/%3Flng%3D0%26lat%3D0%26sid%3D49687cd64aca2ae93aa43748a04e8f6w%26un_area%3D16_1315_1316_53522%23/pages/unitedCardNew20211010-ka/unitedCardNew20211010-ka%3FactId%3D9150e1d16b9d40_10101%22%2C%22id%22%3A%22%22%7D&uuid=b9b4ce69d42dacb64084279d51cdee764d7781fa&client=apple&clientVersion=10.1.4&st=1634100732991&sv=111&sign=67e254ffbcb13be9e12a9782c9cdf398`; + break; + case 'activity_load': + url = `${domain}/dm/front/openCardNew/activity_load?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"jdToken": $.Token, "source": "01", "inviteNick":($.inviteNick || "")} + if($.joinVenderId) admJson = {...admJson, "shopId": `${$.joinVenderId}`} + body = taskPostUrl("/openCardNew/activity_load", admJson); + break; + case 'shopList': + url = `${domain}/dm/front/openCardNew/shopList?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {} + body = taskPostUrl("/openCardNew/shopList", admJson); + break; + case '绑定': + url = `${domain}/dm/front/openCardNew/complete/mission?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"missionType": "relationBind", "inviterNick":($.inviteNick || "")} + body = taskPostUrl("/openCardNew/complete/mission", admJson); + break; + case 'mission': + url = `${domain}/dm/front/openCardNew/complete/mission?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"missionType": $.missionType} + if($.joinVenderId) admJson = {...admJson, "shopId": $.joinVenderId} + body = taskPostUrl("/openCardNew/complete/mission", admJson); + break; + case '抽奖': + url = `${domain}/dm/front/openCardNew/draw/post?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"dataType": "draw", "usedGameNum": "2"} + body = taskPostUrl("/openCardNew/draw/post", admJson); + break; + case 'followShop': + url = `${domain}/dm/front/openCardNew/followShop?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"actId": $.actId, "missionType": "collectShop"} + body = taskPostUrl("/openCardNew/followShop", admJson); + break; + case 'addCart': + url = `${domain}/dm/front/openCardNew/addCart?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"actId": $.actId, "missionType": "addCart"} + body = taskPostUrl("/openCardNew/addCart", admJson); + break; + case 'myAward': + url = `${domain}/dm/front/openCardNew/myAwards?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"pageNo": 1,"pageSize":9999} + body = taskPostUrl("/openCardNew/myAwards", admJson); + break; + case 'missionInviteList': + url = `${domain}/dm/front/openCardNew/missionInviteList?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"inviteListRequest":{"actId":$.actId,"userId":10299171,"missionType":"shareAct","inviteType": 1,"buyerNick":($.MixNick || '')}} + body = taskPostUrl("/openCardNew/missionInviteList", admJson); + break; + default: + console.log(`错误${type}`); + } + let myRequest = getPostRequest(url, body, method); + return new Promise(async resolve => { + $.post(myRequest, (err, resp, data) => { + try { + if (err) { + if(resp && resp.statusCode && resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + console.log(`${$.toStr(err,err)}`) + console.log(`${type} API请求失败,请检查网路重试`) + } else { + dealReturn(type, data); + } + } catch (e) { + // console.log(data); + console.log(e, resp) + } finally { + resolve(); + } + }) + }) + } + +async function dealReturn(type, data) { + let res = '' + try { + if(type != 'accessLogWithAD' || type != 'drawContent'){ + if(data){ + res = JSON.parse(data); + } + } + } catch (e) { + console.log(`${type} 执行任务异常`); + console.log(data); + $.runFalag = false; + } + try { + let title = '' + switch (type) { + case 'isvObfuscator': + if(typeof res == 'object'){ + if(res.errcode == 0){ + if(typeof res.token != 'undefined') $.Token = res.token + }else if(res.message){ + console.log(`${type} ${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + break; + case 'accessLogWithAD': + case 'drawContent': + break; + case 'activity_load': + case 'mission': + case 'shopList': + case 'loadUniteOpenCard': + case 'setMixNick': + case 'uniteOpenCardOne': + case 'checkOpenCard': + case 'followShop': + case 'addCart': + case 'myAward': + case 'missionInviteList': + case '抽奖': + title = '' + if(type == "followShop") title = '关注' + if(type == "addCart") title = '加购' + if(typeof res == 'object'){ + if(res.success && res.success === true && res.data){ + if(res.data.status && res.data.status == 200){ + res = res.data + if(type != "setMixNick" && (res.msg || res.data.isOpenCard || res.data.remark)) console.log(`${title && title+":" || ""}${res.msg || res.data.isOpenCard || res.data.remark || ''}`) + if(type == "activity_load"){ + if(res.msg || res.data.isOpenCard) { + if((res.msg || res.data.isOpenCard || '').indexOf('绑定成功') > -1) $.toBind = 1 + } + if(res.data){ + $.endTime = res.data.cusActivity.endTime || 0 + $.MixNick = res.data.buyerNick || "" + $.usedChance = res.data.missionCustomer.usedChance || 0 + $.hasCollectShop = res.data.missionCustomer.hasCollectShop || 0 + } + }else if(type == "shopList"){ + $.openList = res.data.cusShops || [] + }else if(type == "mission"){ + if(res.data.remark.indexOf('不是会员') > -1){ + $.openCard = true + }else{ + $.openCard = false + } + }else if(type == "uniteOpenCardOne"){ + $.uniteOpenCar = res.msg || res.data.msg || '' + }else if(type == "myAward"){ + console.log(`我的奖品:`) + let num = 0 + let value = 0 + for(let i in res.data.list || []){ + let item = res.data.list[i] + if(item.awardDes == '20'){ + num++ + value = item.awardDes + }else{ + console.log(`${item.awardName}`) + } + } + if(num > 0) console.log(`邀请好友(${num}):${num*parseInt(value, 10) || 30}京豆`) + }else if(type == "missionInviteList"){ + console.log(`邀请人数(${res.data.invitedLogList.total})`) + } + }else if(res.data.msg){ + console.log(`${title || type} ${res.data.msg || ''}`) + }else if(res.errorMessage){ + if(res.errorMessage.indexOf('火爆') >-1 ){ + $.hotFlag = true + } + console.log(`${title || type} ${res.errorMessage || ''}`) + }else{ + console.log(`${title || type} ${data}`) + } + }else if(res.errorMessage){ + console.log(`${title || type} ${res.errorMessage || ''}`) + }else{ + console.log(`${title || type} ${data}`) + } + }else{ + console.log(`${title || type} ${data}`) + } + break; + default: + console.log(`${title || type}-> ${data}`); + } + if(typeof res == 'object'){ + if(res.errorMessage){ + if(res.errorMessage.indexOf('火爆') >-1 ){ + $.hotFlag = true + } + } + } + } catch (e) { + console.log(e) + } +} + +function getPostRequest(url, body, method="POST") { + let headers = { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Content-Type": "application/x-www-form-urlencoded", + "Cookie": cookie, + "User-Agent": $.UA, + "X-Requested-With": "XMLHttpRequest" + } + if(url.indexOf('https://jinggengjcq-isv.isvjcloud.com') > -1){ + headers["Origin"] = `https://jinggengjcq-isv.isvjcloud.com` + headers["Content-Type"] = `application/json; charset=utf-8` + delete headers["Cookie"] + } + // console.log(headers) + // console.log(headers.Cookie) + return {url: url, method: method, headers: headers, body: body, timeout:60000}; +} + + +function taskPostUrl(url, t) { + + const b = { + "jsonRpc": "2.0", + "params": { + "commonParameter": { + "appkey": $.appkey, + "m": "POST", + "timestamp": Date.now(), + "userId": $.userId + }, + "admJson": { + "actId": $.actId, + "userId": $.userId, + ...t, + "method": url, + "buyerNick": ($.MixNick || ''), + } + }, + } + if(url.indexOf('missionInviteList') > -1){ + delete b.params.admJson.actId + } + return $.toStr(b,b) +} +async function getUA(){ + $.UA = `jdapp;iPhone;10.1.4;13.1.2;${randomString(40)};network/wifi;model/iPhone8,1;addressid/2308460611;appBuild/167814;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_1_2 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 jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} + +function joinShop() { + if(!$.joinVenderId) return + return new Promise(async resolve => { + $.shopactivityId = '' + await $.wait(1000) + await getshopactivityId() + let activityId = `` + if($.shopactivityId) activityId = `,"activityId":${$.shopactivityId}` + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body={"venderId":"${$.joinVenderId}","shopId":"${$.joinVenderId}","bindByVerifyCodeFlag":1,"registerExtend":{},"writeChildFlag":0${activityId},"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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + // console.log(data) + let res = $.toObj(data); + if(typeof res == 'object'){ + if(res.success === true){ + console.log(res.message) + if(res.result && res.result.giftInfo){ + for(let i of res.result.giftInfo.giftList){ + console.log(`入会获得:${i.discountString}${i.prizeName}${i.secondLineDesc}`) + } + } + }else if(typeof res == 'object' && res.message){ + console.log(`${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function getshopactivityId() { + return new Promise(resolve => { + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body=%7B%22venderId%22%3A%22${$.joinVenderId}%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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + let res = $.toObj(data); + if(res.success == true){ + // console.log($.toStr(res.result)) + console.log(`入会:${res.result.shopMemberCardInfo.venderCardName || ''}`) + $.shopactivityId = res.result.interestsRuleList && res.result.interestsRuleList[0] && res.result.interestsRuleList[0].interestsInfo && res.result.interestsRuleList[0].interestsInfo.activityId || '' + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +// 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)} + diff --git a/activity/jd_opencardLH37.js b/activity/jd_opencardLH37.js new file mode 100644 index 0000000..6c0d271 --- /dev/null +++ b/activity/jd_opencardLH37.js @@ -0,0 +1,537 @@ +/* +1.6~1.14 联合开卡 [jd_opencardLH37.js] +开卡脚本,一次性脚本 + +第一个账号助力作者 其他依次助力CK1 +第一个CK失效会退出脚本 + + +cron:50 0,13 6-14 1 * +============Quantumultx=============== +[task_local] +#1.6~1.14 联合开卡 +50 0,13 6-14 1 * https://raw.githubusercontent.com/KingRan/JDJB/main/jd_opencardLH37.js, tag=1.6~1.14 联合开卡, enabled=true + +*/ +const $ = new Env('1.6~1.14 联合开卡'); +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const notify = $.isNode() ? require('./sendNotify') : ''; +//IOS等用户直接用NobyDa的jd cookie +let cookiesArr = [], + cookie = ''; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} + +allMessage = "" +message = "" +$.hotFlag = false +$.outFlag = false +$.activityEnd = false +let lz_jdpin_token_cookie ='' +let activityCookie ='' +!(async () => { + console.log(`\n没豆子就停止运行,自行测试`) + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', { + "open-url": "https://bean.m.jd.com/" + }); + return; + } + // return + $.appkey = '51B59BB805903DA4CE513D29EC448375' + $.userId = '10299171' + $.actId = 'c49b9bf1e3c3487dac8ab_22010601' + $.MixNicks = '' + $.inviteNick = 'k1Nobb+P0er+C2sysxnx/P2KELO9izRVpwCyqu0eqVZ5aW7RHzlMobrzJ/e9r/uf' + console.log(`\n活动地址:https://jinggengjcq-isv.isvjcloud.com/fronth5/#/pages/unitedCardNew20220106/unitedCardNew20220106?actId=c49b9bf1e3c3487dac8ab_22010601&bizExtString=c2hhcmVOaWNrOmsxTm9iYiUyQlAwZXIlMkJDMnN5c3hueCUyRlAyS0VMTzlpelJWcHdDeXF1MGVxVlo1YVc3Ukh6bE1vYnJ6SiUyRmU5ciUyRnVm`) + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i]; + if (cookie) { + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + message = "" + $.bean = 0 + $.hotFlag = false + $.nickName = ''; + console.log(`\n\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + await getUA() + await run(); + if(i == 0 && !$.MixNick) break + if($.outFlag || $.activityEnd) break + } + } + if($.outFlag) { + let msg = '此ip已被限制,请过10分钟后再执行脚本' + $.msg($.name, ``, `${msg}`); + if ($.isNode()) await notify.sendNotify(`${$.name}`, `${msg}`); + } +})() + .catch((e) => $.logErr(e)) + .finally(() => $.done()) + + +async function run() { + try { + $.hasEnd = true + $.endTime = 0 + lz_jdpin_token_cookie = '' + $.Token = '' + $.Pin = '' + $.MixNick = '' + let flag = false + if($.activityEnd) return + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + await takePostRequest('isvObfuscator'); + if($.Token == ''){ + console.log('获取[token]失败!') + return + } + await takePostRequest('activity_load'); + if($.hotFlag) return + if(Date.now() > $.endTime){ + $.MixNick = '' + $.activityEnd = true + console.log('活动结束') + return + } + if ($.MixNick == '') { + console.log(`获取cookie失败`); return; + } + // console.log($.MixNick) + // return + $.toBind = 0 + $.openList = [] + await takePostRequest('绑定'); + await takePostRequest('shopList'); + for(o of $.openList){ + $.missionType = 'openCard' + if(o.open != true && o.openCardUrl){ + $.openCard = false + $.joinVenderId = o.userId + await takePostRequest('mission'); + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + if($.openCard == true){ + await joinShop() + await takePostRequest('activity_load'); + await $.wait(parseInt(Math.random() * 3000 + 3000, 10)) + // break + } + $.joinVenderId = '' + } + } + $.joinVenderId = '' + if($.hasCollectShop === 0){ + // 关注 + $.missionType = 'uniteCollectShop' + await takePostRequest('mission'); + await $.wait(parseInt(Math.random() * 2000 + 3000, 10)) + }else{ + console.log('已经关注') + } + $.missionType = 'uniteAddCart' + await takePostRequest('mission'); + await $.wait(parseInt(Math.random() * 2000 + 3000, 10)) + + await takePostRequest('activity_load'); + $.runFalag = true + let count = parseInt($.usedChance, 10) + console.log(`抽奖次数为:${count}`) + for(m=1;count--;m++){ + console.log(`第${m}次抽奖`) + await takePostRequest('抽奖'); + if($.runFalag == false) break + if(Number(count) <= 0) break + if(m >= 10){ + console.log("抽奖太多次,多余的次数请再执行脚本") + break + } + await $.wait(parseInt(Math.random() * 2000 + 2000, 10)) + } + await takePostRequest('myAward'); + await takePostRequest('missionInviteList'); + console.log($.MixNick) + console.log(`当前助力:${$.inviteNick}`) + if($.index == 1){ + $.inviteNick = $.MixNick + console.log(`后面的号都会助力:${$.inviteNick}`) + } + await $.wait(parseInt(Math.random() * 1000 + 5000, 10)) + if(flag) await $.wait(parseInt(Math.random() * 1000 + 10000, 10)) + + if($.index % 3 == 0) console.log('休息1分钟,别被黑ip了\n可持续发展') + if($.index % 3 == 0) await $.wait(parseInt(Math.random() * 5000 + 60000, 10)) + + } catch (e) { + console.log(e) + } +} + +async function takePostRequest(type) { + if($.outFlag) return + let domain = 'https://jinggengjcq-isv.isvjcloud.com'; + let body = ``; + let method = 'POST' + let admJson = '' + switch (type) { + case 'isvObfuscator': + url = `https://api.m.jd.com/client.action?functionId=isvObfuscator`; + body = `body=%7B%22url%22%3A%22https%3A//jinggengjcq-isv.isvjcloud.com/fronth5/%3Flng%3D0%26lat%3D0%26sid%3D49687cd64aca2ae93aa43748a04e8f6w%26un_area%3D16_1315_1316_53522%23/pages/unitedCardNew20211010-ka/unitedCardNew20211010-ka%3FactId%3D9150e1d16b9d40_10101%22%2C%22id%22%3A%22%22%7D&uuid=b9b4ce69d42dacb64084279d51cdee764d7781fa&client=apple&clientVersion=10.1.4&st=1634100732991&sv=111&sign=67e254ffbcb13be9e12a9782c9cdf398`; + break; + case 'activity_load': + url = `${domain}/dm/front/openCardNew/activity_load?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"jdToken": $.Token, "source": "01", "inviteNick":($.inviteNick || "")} + if($.joinVenderId) admJson = {...admJson, "shopId": `${$.joinVenderId}`} + body = taskPostUrl("/openCardNew/activity_load", admJson); + break; + case 'shopList': + url = `${domain}/dm/front/openCardNew/shopList?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {} + body = taskPostUrl("/openCardNew/shopList", admJson); + break; + case '绑定': + url = `${domain}/dm/front/openCardNew/complete/mission?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"missionType": "relationBind", "inviterNick":($.inviteNick || "")} + body = taskPostUrl("/openCardNew/complete/mission", admJson); + break; + case 'mission': + url = `${domain}/dm/front/openCardNew/complete/mission?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"missionType": $.missionType} + if($.joinVenderId) admJson = {...admJson, "shopId": $.joinVenderId} + body = taskPostUrl("/openCardNew/complete/mission", admJson); + break; + case '抽奖': + url = `${domain}/dm/front/openCardNew/draw/post?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"dataType": "draw", "usedGameNum": "2"} + body = taskPostUrl("/openCardNew/draw/post", admJson); + break; + case 'followShop': + url = `${domain}/dm/front/openCardNew/followShop?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"actId": $.actId, "missionType": "collectShop"} + body = taskPostUrl("/openCardNew/followShop", admJson); + break; + case 'addCart': + url = `${domain}/dm/front/openCardNew/addCart?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"actId": $.actId, "missionType": "addCart"} + body = taskPostUrl("/openCardNew/addCart", admJson); + break; + case 'myAward': + url = `${domain}/dm/front/openCardNew/myAwards?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"pageNo": 1,"pageSize":9999} + body = taskPostUrl("/openCardNew/myAwards", admJson); + break; + case 'missionInviteList': + url = `${domain}/dm/front/openCardNew/missionInviteList?mix_nick=${$.MixNick || $.MixNicks || ""}`; + admJson = {"inviteListRequest":{"actId":$.actId,"userId":10299171,"missionType":"shareAct","inviteType": 1,"buyerNick":($.MixNick || '')}} + body = taskPostUrl("/openCardNew/missionInviteList", admJson); + break; + default: + console.log(`错误${type}`); + } + let myRequest = getPostRequest(url, body, method); + return new Promise(async resolve => { + $.post(myRequest, (err, resp, data) => { + try { + if (err) { + if(resp && resp.statusCode && resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + console.log(`${$.toStr(err,err)}`) + console.log(`${type} API请求失败,请检查网路重试`) + } else { + dealReturn(type, data); + } + } catch (e) { + // console.log(data); + console.log(e, resp) + } finally { + resolve(); + } + }) + }) + } + +async function dealReturn(type, data) { + let res = '' + try { + if(type != 'accessLogWithAD' || type != 'drawContent'){ + if(data){ + res = JSON.parse(data); + } + } + } catch (e) { + console.log(`${type} 执行任务异常`); + console.log(data); + $.runFalag = false; + } + try { + let title = '' + switch (type) { + case 'isvObfuscator': + if(typeof res == 'object'){ + if(res.errcode == 0){ + if(typeof res.token != 'undefined') $.Token = res.token + }else if(res.message){ + console.log(`${type} ${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + break; + case 'accessLogWithAD': + case 'drawContent': + break; + case 'activity_load': + case 'mission': + case 'shopList': + case 'loadUniteOpenCard': + case 'setMixNick': + case 'uniteOpenCardOne': + case 'checkOpenCard': + case 'followShop': + case 'addCart': + case 'myAward': + case 'missionInviteList': + case '抽奖': + title = '' + if(type == "followShop") title = '关注' + if(type == "addCart") title = '加购' + if(typeof res == 'object'){ + if(res.success && res.success === true && res.data){ + if(res.data.status && res.data.status == 200){ + res = res.data + if(type != "setMixNick" && (res.msg || res.data.isOpenCard || res.data.remark)) console.log(`${title && title+":" || ""}${res.msg || res.data.isOpenCard || res.data.remark || ''}`) + if(type == "activity_load"){ + if(res.msg || res.data.isOpenCard) { + if((res.msg || res.data.isOpenCard || '').indexOf('绑定成功') > -1) $.toBind = 1 + } + if(res.data){ + $.endTime = res.data.cusActivity.endTime || 0 + $.MixNick = res.data.buyerNick || "" + $.usedChance = res.data.missionCustomer.usedChance || 0 + $.hasCollectShop = res.data.missionCustomer.hasCollectShop || 0 + } + }else if(type == "shopList"){ + $.openList = res.data.cusShops || [] + }else if(type == "mission"){ + if(res.data.remark.indexOf('不是会员') > -1){ + $.openCard = true + }else{ + $.openCard = false + } + }else if(type == "uniteOpenCardOne"){ + $.uniteOpenCar = res.msg || res.data.msg || '' + }else if(type == "myAward"){ + console.log(`我的奖品:`) + let num = 0 + let value = 0 + for(let i in res.data.list || []){ + let item = res.data.list[i] + if(item.awardDes == '20'){ + num++ + value = item.awardDes + }else{ + console.log(`${item.awardName}`) + } + } + if(num > 0) console.log(`邀请好友(${num}):${num*parseInt(value, 10) || 30}京豆`) + }else if(type == "missionInviteList"){ + console.log(`邀请人数(${res.data.invitedLogList.total})`) + } + }else if(res.data.msg){ + console.log(`${title || type} ${res.data.msg || ''}`) + }else if(res.errorMessage){ + if(res.errorMessage.indexOf('火爆') >-1 ){ + $.hotFlag = true + } + console.log(`${title || type} ${res.errorMessage || ''}`) + }else{ + console.log(`${title || type} ${data}`) + } + }else if(res.errorMessage){ + console.log(`${title || type} ${res.errorMessage || ''}`) + }else{ + console.log(`${title || type} ${data}`) + } + }else{ + console.log(`${title || type} ${data}`) + } + break; + default: + console.log(`${title || type}-> ${data}`); + } + if(typeof res == 'object'){ + if(res.errorMessage){ + if(res.errorMessage.indexOf('火爆') >-1 ){ + $.hotFlag = true + } + } + } + } catch (e) { + console.log(e) + } +} + +function getPostRequest(url, body, method="POST") { + let headers = { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Content-Type": "application/x-www-form-urlencoded", + "Cookie": cookie, + "User-Agent": $.UA, + "X-Requested-With": "XMLHttpRequest" + } + if(url.indexOf('https://jinggengjcq-isv.isvjcloud.com') > -1){ + headers["Origin"] = `https://jinggengjcq-isv.isvjcloud.com` + headers["Content-Type"] = `application/json; charset=utf-8` + delete headers["Cookie"] + } + // console.log(headers) + // console.log(headers.Cookie) + return {url: url, method: method, headers: headers, body: body, timeout:30000}; +} + + +function taskPostUrl(url, t) { + + const b = { + "jsonRpc": "2.0", + "params": { + "commonParameter": { + "appkey": $.appkey, + "m": "POST", + "timestamp": Date.now(), + "userId": $.userId + }, + "admJson": { + "actId": $.actId, + "userId": $.userId, + ...t, + "method": url, + "buyerNick": ($.MixNick || ''), + } + }, + } + if(url.indexOf('missionInviteList') > -1){ + delete b.params.admJson.actId + } + return $.toStr(b,b) +} +async function getUA(){ + $.UA = `jdapp;iPhone;10.1.4;13.1.2;${randomString(40)};network/wifi;model/iPhone8,1;addressid/2308460611;appBuild/167814;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_1_2 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 jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} + +function joinShop() { + if(!$.joinVenderId) return + return new Promise(async resolve => { + $.shopactivityId = '' + await $.wait(1000) + await getshopactivityId() + let activityId = `` + if($.shopactivityId) activityId = `,"activityId":${$.shopactivityId}` + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body={"venderId":"${$.joinVenderId}","shopId":"${$.joinVenderId}","bindByVerifyCodeFlag":1,"registerExtend":{},"writeChildFlag":0${activityId},"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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + // console.log(data) + let res = $.toObj(data); + if(typeof res == 'object'){ + if(res.success === true){ + console.log(res.message) + if(res.result && res.result.giftInfo){ + for(let i of res.result.giftInfo.giftList){ + console.log(`入会获得:${i.discountString}${i.prizeName}${i.secondLineDesc}`) + } + } + }else if(typeof res == 'object' && res.message){ + console.log(`${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function getshopactivityId() { + return new Promise(resolve => { + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body=%7B%22venderId%22%3A%22${$.joinVenderId}%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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + let res = $.toObj(data); + if(res.success == true){ + // console.log($.toStr(res.result)) + console.log(`入会:${res.result.shopMemberCardInfo.venderCardName || ''}`) + $.shopactivityId = res.result.interestsRuleList && res.result.interestsRuleList[0] && res.result.interestsRuleList[0].interestsInfo && res.result.interestsRuleList[0].interestsInfo.activityId || '' + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +// 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)} + diff --git a/activity/jd_opencardjoyjd.js b/activity/jd_opencardjoyjd.js new file mode 100644 index 0000000..ae87212 --- /dev/null +++ b/activity/jd_opencardjoyjd.js @@ -0,0 +1,510 @@ +/* + +JoyJd任务脚本 +已支持IOS双京东账号,Node.js支持N个京东账号 +脚本兼容: QuantumultX, Surge, Loon, JSBox, Node.js +============Quantumultx=============== +[task_local] +#JoyJd任务脚本 +5 2,18 * * * https://raw.githubusercontent.com/KingRan/JDJB/main/jd_joyjd_open.js, tag=JoyJd任务脚本, img-url=https://raw.githubusercontent.com/Orz-3/mini/master/Color/jd.png, enabled=true + +================Loon============== +[Script] +cron "5 2,18 * * *" script-path=https://raw.githubusercontent.com/KingRan/JDJB/main/jd_joyjd_open.js,tag=JoyJd任务脚本 + +===============Surge================= +JoyJd任务脚本 = type=cron,cronexp="5 2,18 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/KingRan/JDJB/main/jd_joyjd_open.js + +============小火箭========= +JoyJd任务脚本 = type=cron,script-path=https://raw.githubusercontent.com/KingRan/JDJB/main/jd_joyjd_open.js, cronexpr="5 2,18 * * *", timeout=3600, enable=true + + +*/ +const $ = new Env('会员开卡赢京豆'); +const Faker=require('./sign_graphics_validate.js') +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const notify = $.isNode() ? require('./sendNotify') : ''; +//IOS等用户直接用NobyDa的jd cookie +let cookiesArr = [], + cookie = ''; +if ($.isNode()) { + Object.keys(jdCookieNode).forEach((item) => { + cookiesArr.push(jdCookieNode[item]) + }) + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +} else { + cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); +} +message = "" +!(async () => { + console.log('入口:https://prodev.m.jd.com/mall/active/3z1Vesrhx3GCCcBn2HgbFR4Jq68o/index.html') + console.log('开一张卡获得10豆') + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', { + "open-url": "https://bean.m.jd.com/" + }); + return; + } + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i]; + if (cookie) { + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + $.bean = 0 + await getUA() + $.nickName = ''; + console.log(`\n\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + await run(); + if($.bean > 0) message += `【京东账号${$.index}】获得${$.bean}京豆\n` + } + } + if(message){ + $.msg($.name, ``, `${message}\n获得到的京豆不一定到账`); + if ($.isNode()){ + await notify.sendNotify(`${$.name}`, `${message}\n获得到的京豆不一定到账`); + } + } +})() + .catch((e) => $.logErr(e)) + .finally(() => $.done()) + + +async function run() { + try { + await getHtml(); + await $.wait(parseInt(Math.random() * 1000 + 2000, 10)) + if(!$.fp || !$.eid){ + $.log("获取活动信息失败!") + return + } + let config = [ + {configCode:'469f588bbf0f45e1bf06c87c76df9db8',configName:'我爱520-1'}, + // {configCode:'761d289b16d74713bf6cee8462ca0e76',configName:'我爱520-2'}, + // {configCode:'3d83678471e74b84940b99d16d8848b5',configName:'我爱520-3'}, + //{configCode:'ce04c87546ea40cc8f601e85f2dda2a9',configName:'秋新资任务组件 组1'}, + ] + for(let i in config){ + $.hotFlag = false + let item = config[i] + $.task = '' + $.taskList = [] + $.taskInfo = '' + let q = 5 + for(m=1;q--;m++){ + if($.task == '') await getActivity(item.configCode,item.configName,0) + if($.task || $.hotFlag) break + } + if($.hotFlag) continue; + if($.task.showOrder){ + console.log(`\n[${item.configName}] ${$.task.showOrder == 2 && '日常任务' || $.task.showOrder == 1 && '开卡' || '未知活动类型'} ${($.taskInfo.rewardStatus == 2) && '全部完成' || ''}`) + if($.taskInfo.rewardStatus == 2) continue; + $.taskList = $.task.memberList || $.task.taskList || [] + $.oneTask = '' + for (let i = 0; i < $.taskList.length; i++) { + $.oneTask = $.taskList[i]; + if($.task.showOrder == 1){ + if($.oneTask.cardName.indexOf('马克华') > -1) continue + console.log(`${$.oneTask.cardName} ${0 == $.oneTask.result ? "开卡得" + $.oneTask.rewardQuantity + "京豆" : 1 == $.oneTask.result ? "领取" + $.oneTask.rewardQuantity + "京豆" : 3 == $.oneTask.result ? "其他渠道入会" : "已入会"}`) + if($.oneTask.result == 0) await statistic(`{"activityType":"module_task","groupType":7,"configCode":"${item.configCode}","itemId":${$.oneTask.cardId}}`) + if($.oneTask.result == 0) await join($.oneTask.venderId) + await $.wait(parseInt(Math.random() * 1000 + 500, 10)) + if($.oneTask.result == 1 || $.oneTask.result == 0) await getReward(`{"configCode":"${item.configCode}","groupType":7,"itemId":${$.oneTask.cardId},"eid":"${$.eid}","fp":"${$.fp}"}`) + }else if($.task.showOrder == 2){ + $.cacheNum = 0 + $.doTask = false + $.outActivity = false + let name = `${1 == $.oneTask.groupType ? "关注并浏览店铺" : 2 == $.oneTask.groupType ? "加购并浏览商品" : 3 == $.oneTask.groupType ? "关注并浏览频道" : 6 == $.oneTask.groupType ? "浏览会场" : "未知"}` + let msg = `(${$.oneTask.finishCount}/${$.oneTask.taskCount})` + let status = `${$.oneTask.finishCount >= $.oneTask.taskCount && '已完成' || "去" + (1 == $.oneTask.groupType ? "关注" : 2 == $.oneTask.groupType ? "加购" : 3 == $.oneTask.groupType ? "关注" : 6 == $.oneTask.groupType ? "浏览" : "做任务")}` + console.log(`${name}${msg} ${status}`) + if($.oneTask.finishCount < $.oneTask.taskCount){ + await doTask(`{"configCode":"${item.configCode}","groupType":${$.oneTask.groupType},"itemId":"${$.oneTask.item.itemId}","eid":"${$.eid}","fp":"${$.fp}"}`) + let c = $.oneTask.taskCount - $.oneTask.finishCount - 1 + for(n=2;c-- && !$.outActivity;n++){ + if($.outActivity) break + console.log(`第${n}次`) + await getActivity(item.configCode,item.configName,$.oneTask.groupType) + $.oneTasks = '' + let q = 3 + for(m=1;q--;m++){ + if($.oneTasks == '') await getActivity(item.configCode,item.configName,$.oneTask.groupType) + if($.oneTasks) break + } + if($.oneTasks){ + c = $.oneTasks.taskCount - $.oneTasks.finishCount + if($.oneTasks.item.itemId == $.oneTask.item.itemId){ + n--; + console.log(`数据缓存中`) + $.cacheNum++; + if($.cacheNum > 3) console.log('请重新执行脚本,数据缓存问题'); + if($.cacheNum > 3) break; + await getUA() + await $.wait(parseInt(Math.random() * 1000 + 3000, 10)) + await getHtml(); + }else{ + $.cacheNum = 0 + } + if($.oneTasks.item.itemId != $.oneTask.item.itemId && $.oneTasks.finishCount < $.oneTasks.taskCount) await doTask(`{"configCode":"${item.configCode}","groupType":${$.oneTasks.groupType},"itemId":"${$.oneTasks.item.itemId}","eid":"${$.eid}","fp":"${$.fp}"}`) + await $.wait(parseInt(Math.random() * 1000 + 1000, 10)) + }else{ + n--; + } + } + } + }else{ + console.log('未知活动类型') + } + } + if($.task.showOrder == 2){ + if($.doTask){ + $.taskInfo = '' + let q = 5 + for(m=1;q--;m++){ + if($.taskInfo == '') await getActivity(item.configCode,item.configName,-1) + if($.taskInfo) break + } + } + if($.taskInfo.rewardStatus == 1) await getReward(`{"configCode":"${item.configCode}","groupType":5,"itemId":1,"eid":"${$.eid}","fp":"${$.fp}"}`,1) + } + } + await $.wait(parseInt(Math.random() * 1000 + 1000, 10)) + } + + } catch (e) { + console.log(e) + } +} +function getActivity(code,name,flag) { + return new Promise(async resolve => { + $.get({ + url: `https://jdjoy.jd.com/module/task/v2/getActivity?configCode=${code}&eid=${$.eid}&fp=${$.fp}`, + headers: { + 'Accept': 'application/json, text/plain, */*', + 'Content-Type':'application/json;charset=utf-8', + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + 'Cookie': cookie, + 'User-Agent': $.UA, + } + }, async (err, resp, data) => { + try { + if (err) { + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + // console.log(data) + res = $.toObj(data) + if(typeof res == 'object'){ + if(res.success == true && res.data.pass == true){ + if(flag == 0){ + $.task = res.data.memberTask || res.data.dailyTask || [] + $.taskInfo = res.data.moduleBaseInfo || res.data.moduleBaseInfo || [] + }else if(flag == -1){ + $.taskInfo = res.data.moduleBaseInfo || res.data.moduleBaseInfo || {} + }else if(flag == 1 || flag == 2){ + for(let i of res.data.dailyTask.taskList){ + if(i.groupType == flag){ + $.oneTasks = i + break + } + } + }else{ + console.log('活动-未知类型') + } + }else if(res.data.pass == false){ + console.log(`活动[${name}]活动太火爆了,请稍后再试~`) + $.hotFlag = true + }else{ + console.log(`活动[${name}]获取失败\n${data}`) + if(flag > 0) await getHtml(); + await $.wait(parseInt(Math.random() * 1000 + 2000, 10)) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + +function doTask(body) { + return new Promise(async resolve => { + $.post({ + url: `https://jdjoy.jd.com/module/task/v2/doTask`, + body, + headers: { + 'Accept': 'application/json, text/plain, */*', + "Accept-Encoding": "gzip, deflate, br", + 'Content-Type':'application/json;charset=UTF-8', + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + 'Cookie': cookie, + 'User-Agent': $.UA, + } + }, async (err, resp, data) => { + $.doTask = true + try { + if (err) { + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + await $.wait(parseInt(Math.random() * 1000 + 500, 10)) + // console.log(data) + res = $.toObj(data) + if(typeof res == 'object'){ + if(res.success == true){ + console.log(`领奖成功:${$.oneTask.rewardQuantity}京豆`) + $.bean += Number($.oneTask.rewardQuantity) + }else if(res.errorMessage){ + if(res.errorMessage.indexOf('活动已结束') > -1) $.outActivity = true + console.log(`${res.errorMessage}`) + }else{ + console.log(data) + } + } + + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} +function getReward(body, flag = 0) { + return new Promise(async resolve => { + $.post({ + url: `https://jdjoy.jd.com/module/task/v2/getReward`, + body, + headers: { + 'Accept': 'application/json, text/plain, */*', + "Accept-Encoding": "gzip, deflate, br", + 'Content-Type':'application/json;charset=UTF-8', + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + 'Cookie': cookie, + 'User-Agent': $.UA, + } + }, async (err, resp, data) => { + try { + if (err) { + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + // console.log(data) + res = $.toObj(data) + if(typeof res == 'object'){ + if(res.success == true){ + console.log(`领奖成功:${flag == 1 && $.taskInfo.rewardFinish || $.oneTask.rewardQuantity}京豆`) + $.bean += Number($.oneTask.rewardQuantity) + }else{ + console.log(`${res.errorMessage}`) + } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +function statistic(body) { + return new Promise(async resolve => { + $.post({ + url: `https://jdjoy.jd.com/module/task/data/statistic`, + body, + headers: { + 'Accept': 'application/json, text/plain, */*', + "Accept-Encoding": "gzip, deflate, br", + 'Content-Type':'application/json;charset=UTF-8', + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + 'Cookie': cookie, + 'User-Agent': $.UA, + } + }, async (err, resp, data) => { + try { + if (err) { + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + // console.log(data) + + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} +function join(venderId) { + return new Promise(async resolve => { + $.shopactivityId = '' + await $.wait(1000) + await getshopactivityId(venderId) + $.get(ruhui(`${venderId}`), async (err, resp, data) => { + try { + // console.log(data) + data = JSON.parse(data); + if(data.success == true){ + $.log(data.message) + if(data.result && data.result.giftInfo){ + for(let i of data.result.giftInfo.giftList){ + console.log(`入会获得:${i.discountString}${i.prizeName}${i.secondLineDesc}`) + } + } + }else if(data.success == false){ + $.log(data.message) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} +function ruhui(functionId) { + let activityId = `` + if($.shopactivityId) activityId = `,"activityId":${$.shopactivityId}` + return { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body={"venderId":"${functionId}","shopId":"${functionId}","bindByVerifyCodeFlag":1,"registerExtend":{},"writeChildFlag":0${activityId},"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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Referer': `https://shopmember.m.jd.com/shopcard/?venderId=${functionId}&shopId=${functionId}&venderType=5&channel=401&returnUrl=https://lzdz1-isv.isvjcloud.com/dingzhi/dz/openCard/activity/832865?activityId=c225ad5922cf4ac8b4a68fd37f486088&shareUuid=${$.shareUuid}`, + 'Cookie': cookie + } + } +} + +function getshopactivityId(venderId) { + return new Promise(resolve => { + $.get(shopactivityId(`${venderId}`), async (err, resp, data) => { + try { + data = JSON.parse(data); + if(data.success == true){ + console.log(`入会:${data.result.shopMemberCardInfo.venderCardName || ''}`) + $.shopactivityId = data.result.interestsRuleList && data.result.interestsRuleList[0] && data.result.interestsRuleList[0].interestsInfo && data.result.interestsRuleList[0].interestsInfo.activityId || '' + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function shopactivityId(functionId) { + return { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body=%7B%22venderId%22%3A%22${functionId}%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': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Referer': `https://shopmember.m.jd.com/shopcard/?venderId=${functionId}&shopId=${functionId}&venderType=5&channel=401&returnUrl=https://lzdz1-isv.isvjcloud.com/dingzhi/dz/openCard/activity/832865?activityId=c225ad5922cf4ac8b4a68fd37f486088&shareUuid=${$.shareUuid}`, + 'Cookie': cookie + } + } +} +function getHtml() { + return new Promise(resolve => { + $.get({ + url: `https://prodev.m.jd.com/mall/active/3q7yrbh3qCJvHsu3LhojdgxNuWQT/index.html`, + headers: { + "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + 'Cookie': cookie, + 'User-Agent': $.UA, + } + }, async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(data); + } + }) + }) +} + +function getEid(arr) { + return new Promise(resolve => { + const options = { + url: `https://gia.jd.com/fcf.html?a=${arr.a}`, + body: `d=${arr.d}`, + headers: { + "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8", + "User-Agent": $.UA + } + } + $.post(options, async (err, resp, data) => { + try { + if (err) { + console.log(`\n${turnTableId[i].name} 登录: API查询请求失败 ‼️‼️`) + throw new Error(err); + } else { + if (data.indexOf("*_*") > 0) { + data = data.split("*_*", 2); + data = JSON.parse(data[1]); + $.eid = data.eid + } else { + console.log(`京豆api返回数据为空,请检查自身原因`) + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }) +} + + + +async 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` + let arr = await Faker.getBody($.UA,'https://prodev.m.jd.com/mall/active/3q7yrbh3qCJvHsu3LhojdgxNuWQT/index.html') + $.fp = arr.fp + await getEid(arr) +} +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 jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} +// 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)}