From f65254cf2004508d91dcfeec1213c729e47754ea 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:35:02 +0800 Subject: [PATCH] init --- .gitattributes | 3 + .gitignore | 9 + jdCookie.js | 100 ++ jd_opencardL69.js | 857 +++++++++++++ jd_opencardL70.js | 544 +++++++++ jd_opencardL73.js | 821 +++++++++++++ jd_opencardL74.js | 544 +++++++++ jd_opencardL75.js | 544 +++++++++ jd_opencardL76.js | 790 ++++++++++++ jd_opencardL78.js | 551 +++++++++ jd_opencardL79.js | 544 +++++++++ jd_opencardL80.js | 790 ++++++++++++ sendNotify.js | 2988 +++++++++++++++++++++++++++++++++++++++++++++ 13 files changed, 9085 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 jdCookie.js create mode 100644 jd_opencardL69.js create mode 100644 jd_opencardL70.js create mode 100644 jd_opencardL73.js create mode 100644 jd_opencardL74.js create mode 100644 jd_opencardL75.js create mode 100644 jd_opencardL76.js create mode 100644 jd_opencardL78.js create mode 100644 jd_opencardL79.js create mode 100644 jd_opencardL80.js create mode 100644 sendNotify.js diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..cc6505d --- /dev/null +++ b/.gitattributes @@ -0,0 +1,3 @@ +* text eol=lf +*.png -text +*.jpg -text \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a6855af --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +/node_modules/ +/yarn.lock +/.idea +/.history +/box.dat +/CookieSet.json +/logs +# /JD_DailyBonus.js +/result.txt \ No newline at end of file diff --git a/jdCookie.js b/jdCookie.js new file mode 100644 index 0000000..b8501a7 --- /dev/null +++ b/jdCookie.js @@ -0,0 +1,100 @@ +/* +================================================================================ +魔改自 https://github.com/shufflewzc/faker2/blob/main/jdCookie.js +修改内容:与task_before.sh配合,由task_before.sh设置要设置要做互助的活动的 ShareCodeConfigName 和 ShareCodeEnvName 环境变量, + 然后在这里实际解析/ql/log/.ShareCode中该活动对应的配置信息(由code.sh生成和维护),注入到nodejs的环境变量中 +修改原因:原先的task_before.sh直接将互助信息注入到shell的env中,在ck超过45以上时,互助码环境变量过大会导致调用一些系统命令 + (如date/cat)时报 Argument list too long,而在node中修改环境变量不会受这个限制,也不会影响外部shell环境,确保脚本可以正常运行 +魔改作者:风之凌殇 +================================================================================ + +此文件为Node.js专用。其他用户请忽略 + */ +//此处填写京东账号cookie。 +let CookieJDs = [ +] +// 判断环境变量里面是否有京东ck +if (process.env.JD_COOKIE) { + if (process.env.JD_COOKIE.indexOf('&') > -1) { + CookieJDs = process.env.JD_COOKIE.split('&'); + } else if (process.env.JD_COOKIE.indexOf('\n') > -1) { + CookieJDs = process.env.JD_COOKIE.split('\n'); + } else { + CookieJDs = [process.env.JD_COOKIE]; + } +} +if (JSON.stringify(process.env).indexOf('GITHUB')>-1) { + console.log(`请勿使用github action运行此脚本,无论你是从你自己的私库还是其他哪里拉取的源代码,都会导致我被封号\n`); + !(async () => { + await require('./sendNotify').sendNotify('提醒', `请勿使用github action、滥用github资源会封我仓库以及账号`) + await process.exit(0); + })() +} +CookieJDs = [...new Set(CookieJDs.filter(item => !!item))] +console.log(`\n====================共${CookieJDs.length}个京东账号Cookie=========\n`); +console.log(`==================脚本执行- 北京时间(UTC+8):${new Date(new Date().getTime() + new Date().getTimezoneOffset()*60*1000 + 8*60*60*1000).toLocaleString('zh', {hour12: false}).replace(' 24:',' 00:')}=====================\n`) +if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; +for (let i = 0; i < CookieJDs.length; i++) { + if (!CookieJDs[i].match(/pt_pin=(.+?);/) || !CookieJDs[i].match(/pt_key=(.+?);/)) console.log(`\n提示:京东cookie 【${CookieJDs[i]}】填写不规范,可能会影响部分脚本正常使用。正确格式为: pt_key=xxx;pt_pin=xxx;(分号;不可少)\n`); + const index = (i + 1 === 1) ? '' : (i + 1); + exports['CookieJD' + index] = CookieJDs[i].trim(); +} + +// 以下为注入互助码环境变量(仅nodejs内起效)的代码 +function SetShareCodesEnv(nameChinese = "", nameConfig = "", envName = "") { + let rawCodeConfig = {} + + // 读取互助码 + shareCodeLogPath = `${process.env.QL_DIR}/log/.ShareCode/${nameConfig}.log` + let fs = require('fs') + if (fs.existsSync(shareCodeLogPath)) { + // 因为faker2目前没有自带ini,改用已有的dotenv来解析 + // // 利用ini模块读取原始互助码和互助组信息 + // let ini = require('ini') + // rawCodeConfig = ini.parse(fs.readFileSync(shareCodeLogPath, 'utf-8')) + + // 使用env模块 + require('dotenv').config({path: shareCodeLogPath}) + rawCodeConfig = process.env + } + + // 解析每个用户的互助码 + codes = {} + Object.keys(rawCodeConfig).forEach(function (key) { + if (key.startsWith(`My${nameConfig}`)) { + codes[key] = rawCodeConfig[key] + } + }); + + // 解析每个用户要帮助的互助码组,将用户实际的互助码填充进去 + let helpOtherCodes = {} + Object.keys(rawCodeConfig).forEach(function (key) { + if (key.startsWith(`ForOther${nameConfig}`)) { + helpCode = rawCodeConfig[key] + for (const [codeEnv, codeVal] of Object.entries(codes)) { + helpCode = helpCode.replace("${" + codeEnv + "}", codeVal) + } + + helpOtherCodes[key] = helpCode + } + }); + + // 按顺序用&拼凑到一起,并放入环境变量,供目标脚本使用 + let shareCodes = [] + let totalCodeCount = Object.keys(helpOtherCodes).length + for (let idx = 1; idx <= totalCodeCount; idx++) { + shareCodes.push(helpOtherCodes[`ForOther${nameConfig}${idx}`]) + } + let shareCodesStr = shareCodes.join('&') + process.env[envName] = shareCodesStr + + console.info(`${nameChinese} 的 互助码环境变量 ${envName},共计 ${totalCodeCount} 组互助码,总大小为 ${shareCodesStr.length} 字节`) +} + +// 若在task_before.sh 中设置了要设置互助码环境变量的活动名称和环境变量名称信息,则在nodejs中处理,供活动使用 +let nameChinese = process.env.ShareCodeConfigChineseName +let nameConfig = process.env.ShareCodeConfigName +let envName = process.env.ShareCodeEnvName +if (nameChinese && nameConfig && envName) { + SetShareCodesEnv(nameChinese, nameConfig, envName) +} diff --git a/jd_opencardL69.js b/jd_opencardL69.js new file mode 100644 index 0000000..d54f330 --- /dev/null +++ b/jd_opencardL69.js @@ -0,0 +1,857 @@ +/* +2.11~2.22 遇见爱 遇见你 +新增开卡脚本,一次性脚本 + + +入口:[ 2.11~2.22 遇见爱 遇见你 (https://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=qrj20220211udn6m4p8pqh7lc2&shareUuid=7d629ef8f20c4136a2c1d28c8d2226e6)] + +请求太频繁会被黑ip +过10分钟再执行 + +cron:50 1,16 11-23 2 * +============Quantumultx=============== +[task_local] +#2.11~2.22 遇见爱 遇见你 +50 1,16 11-23 2 * jd_opencardL69.js, tag=2.11~2.22 遇见爱 遇见你, enabled=true + +*/ +const $ = new Env('2.11~2.22 遇见爱 遇见你'); +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 ='' +const activeEndTime = '2022/02/23 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 = "qrj20220211udn6m4p8pqh7lc2" + $.shareUuid = "4c913f89a6014e27a5daf158ee7c3491" + 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) && nowTime > new Date('2022/02/24 00:00:00+08:00').getTime()){ + $.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'); + } + $.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 takePostRequest('getCardInfo'); + if($.drawCardNum && $.compositeCard+"" == "true"){ + 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 >= 15){ + 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` + await takePostRequest('瓜分奖励'); + } + console.log(`${$.score}值 瓜分:${$.compositeCardFinishCount == 1 && "是" || "否"}`) + 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}/open/card/check`; + 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}/collect/card/getCardInfo`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case '瓜分奖励': + url = `${domain}/collect/card/carveUpPrize`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case '集卡': + url = `${domain}/collect/card/drawCard`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case '合卡': + url = `${domain}/collect/card/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}/assist/getStatus`; + }else{ + url = `${domain}/assist/go`; + } + 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 == "cardPrize" && "瓜分奖励") || 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.assistCount + $.log(`=========== 你邀请了:${$.ShareCount}个`) + }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,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/jd_opencardL70.js b/jd_opencardL70.js new file mode 100644 index 0000000..0735271 --- /dev/null +++ b/jd_opencardL70.js @@ -0,0 +1,544 @@ +/* +2.12~3.8 联合开卡 +新增开卡脚本,一次性脚本 + +第一个账号助力作者 其他依次助力CK1 +第一个CK失效会退出脚本 + +———————————————— +入口:[ 2.12~3.8 联合开卡 (https://mpdz3-isv.isvjcloud.com/fronth5/#/pages/unitedCardNew20220212/unitedCardNew20220212?actId=628b293b355c42e39d5fea6f583e_20220212)] + +请求太频繁会被黑ip +过10分钟再执行 + + +cron:40 0,12 12-28,1-8 2,3 * +============Quantumultx=============== +[task_local] +#2.12~3.8 联合开卡 +40 0,12 12-28,1-8 2,3 * jd_opencardL70.js, tag=2.12~3.8 联合开卡, enabled=true + +*/ + +const $ = new Env('2.12~3.8 联合开卡'); +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 = '628b293b355c42e39d5fea6f583e_20220212' + $.MixNicks = '' + $.inviteNick = 'e4aHW8SbTt6Rgyvpai2f5ls/ye9oluZX4nOTK56TeMXbR7I2OlzZch4hTs22oCUS' + console.log(`活动地址:https://mpdz3-isv.isvjcloud.com/fronth5/#/pages/unitedCardNew20220212/unitedCardNew20220212?actId=628b293b355c42e39d5fea6f583e_20220212`) + 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://mpdz3-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://mpdz3-isv.isvjcloud.com') > -1){ + headers["Origin"] = `https://mpdz3-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/jd_opencardL73.js b/jd_opencardL73.js new file mode 100644 index 0000000..8915e10 --- /dev/null +++ b/jd_opencardL73.js @@ -0,0 +1,821 @@ +/* +2.14~2.21 瓜分百万京豆,0元赢取甜蜜好礼 +新增开卡脚本,一次性脚本 + + +第一个账号助力作者 其他依次助力CK1 +第一个CK失效会退出脚本 + +———————————————— +入口:[ 2.14~2.21 瓜分百万京豆,0元赢取甜蜜好礼 (https://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=union235434985dzlhkk&shareUuid=26140a8c22e34c61b034a8cf98df4a65)] + +请求太频繁会被黑ip +过10分钟再执行 + +cron:30 1,12 14-21 2 * +============Quantumultx=============== +[task_local] +#2.14~2.21 瓜分百万京豆,0元赢取甜蜜好礼 +30 1,12 14-21 2 * jd_opencardL73.js, tag=2.14~2.21 瓜分百万京豆,0元赢取甜蜜好礼, enabled=true + +*/ +const $ = new Env("2.14~2.21 瓜分百万京豆,0元赢取甜蜜好礼"); +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 = "union235434985dzlhkk" + $.shareUuid = "4c913f89a6014e27a5daf158ee7c3491" + 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/opencard/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/jd_opencardL74.js b/jd_opencardL74.js new file mode 100644 index 0000000..38f4eef --- /dev/null +++ b/jd_opencardL74.js @@ -0,0 +1,544 @@ +/* +2.15~2.21 联合开卡 +新增开卡脚本,一次性脚本 + +第一个账号助力作者 其他依次助力CK1 +第一个CK失效会退出脚本 + +———————————————— +入口:[ 2.15~2.21 联合开卡 ] + +请求太频繁会被黑ip +过10分钟再执行 + + +cron:50 0,12 15-21 2 * +============Quantumultx=============== +[task_local] +#2.15~2.21 联合开卡 +50 0,12 15-21 2 * jd_opencardL74.js, tag=2.15~2.21 联合开卡, enabled=true + +*/ + +const $ = new Env('2.15~2.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; + } + // return + $.appkey = '51B59BB805903DA4CE513D29EC448375' + $.userId = '10299171' + $.actId = 'b134063c47974580a18d208412_22021501' + $.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/jd_opencardL75.js b/jd_opencardL75.js new file mode 100644 index 0000000..2d1afa0 --- /dev/null +++ b/jd_opencardL75.js @@ -0,0 +1,544 @@ +/* +2.18~2.23 联合开卡 +新增开卡脚本,一次性脚本 + +第一个账号助力作者 其他依次助力CK1 +第一个CK失效会退出脚本 + +———————————————— +入口:[ 2.18~2.23 联合开卡] + +请求太频繁会被黑ip +过10分钟再执行 + + +cron:35 0,14 18-23 2 * +============Quantumultx=============== +[task_local] +#2.18~2.23 联合开卡 +35 0,14 18-23 2 * jd_opencardL75.js, tag=2.18~2.23 联合开卡, enabled=true + +*/ + +const $ = new Env('2.18~2.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 = 'dd01d7abe65a4bac83967e94968_220218' + $.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/jd_opencardL76.js b/jd_opencardL76.js new file mode 100644 index 0000000..3f387b0 --- /dev/null +++ b/jd_opencardL76.js @@ -0,0 +1,790 @@ +/* +2.19-2.26 奢宠会员 瓜分百万京豆 +新增开卡脚本,一次性脚本 + +———————————————— +入口:[ 2.19-2.26 奢宠会员 瓜分百万京豆 (https://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=unionkbblnt20220218dzlhkk&shareUuid=48636db9b45f483f870865b682800797)] + + +cron:30 2,15 19-26 2 * +============Quantumultx=============== +[task_local] +#2.19-2.26 奢宠会员 瓜分百万京豆 +30 2,15 19-26 2 * jd_opencardL76.js, tag=2.19-2.26 奢宠会员 瓜分百万京豆, enabled=true + +*/ +const $ = new Env('2.19-2.26 奢宠会员 瓜分百万京豆'); +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 = "unionkbblnt20220218dzlhkk" + $.shareUuid = "b370e062d2994313855807507b58fb84" + 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('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 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('已全部开卡') + } + + $.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 + let goodsArr = [] + await takePostRequest('addCart'); + await $.wait(parseInt(Math.random() * 2000 + 4000, 10)) + } + if(flag){ + await takePostRequest('activityContent'); + } + $.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/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)}&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/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 + } + 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/opencard/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) || 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 || '' + $.followShop = res.data.actor.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 + 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': + 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京豆' && item.drawStatus == 0){ + 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}个\n`) + }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/jd_opencardL78.js b/jd_opencardL78.js new file mode 100644 index 0000000..ee7dc43 --- /dev/null +++ b/jd_opencardL78.js @@ -0,0 +1,551 @@ +/* +2.18~2.24 婴乐家会员日 +新增开卡脚本,一次性脚本 + + +第一个账号助力作者 其他依次助力CK1 +第一个CK失效会退出脚本 + +———————————————— +入口:[ 2.18~2.24 婴乐家会员日 (https://prodev.m.jd.com/mall/active/3AMYPfqw8UfDkuk2zZM5PsyMQk8R/index.html)] + +请求太频繁会被黑ip +过10分钟再执行 + + +cron:39 0,11 18-24 2 * +============Quantumultx=============== +[task_local] +#2.18~2.24 婴乐家会员日 +39 0,11 18-24 2 * jd_opencardL78.js, tag=2.18~2.24 婴乐家会员日, enabled=true + +*/ + +const $ = new Env("2.18~2.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/3AMYPfqw8UfDkuk2zZM5PsyMQk8R/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 = ['e4aHW8SbTt6Rgyvpai2f5ls/ye9oluZX4nOTK56TeMXbR7I2OlzZch4hTs22oCUS'] + $.appkey = "51B59BB805903DA4CE513D29EC448375" + $.userId = "10299171" + $.actId = "3f3e8af6b138460aa5ae_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/jd_opencardL79.js b/jd_opencardL79.js new file mode 100644 index 0000000..05df672 --- /dev/null +++ b/jd_opencardL79.js @@ -0,0 +1,544 @@ +/* +2.20~2.26 联合开卡 +新增开卡脚本,一次性脚本 + +第一个账号助力作者 其他依次助力CK1 +第一个CK失效会退出脚本 + +———————————————— +入口:[ 2.20~2.26 联合开卡 ] + +请求太频繁会被黑ip +过10分钟再执行 + + +cron:41 0,17 20-26 2 * +============Quantumultx=============== +[task_local] +#2.20~2.26 联合开卡 +41 0,17 20-26 2 * jd_opencardL79.js, tag=2.20~2.26 联合开卡, enabled=true + +*/ + +const $ = new Env('2.20~2.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 = '29a7e74b884d42adb90d8_22022001' + $.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/jd_opencardL80.js b/jd_opencardL80.js new file mode 100644 index 0000000..6328c0b --- /dev/null +++ b/jd_opencardL80.js @@ -0,0 +1,790 @@ +/* +2.21-2.28 大牌联合 宠爱有礼 +新增开卡脚本,一次性脚本 + +———————————————— +入口:[ 2.21-2.28 大牌联合 宠爱有礼 (https://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=unionkbblnt20220221dzlhkk&shareUuid=1e1c83189fb34c13afbdd37943241c17)] + + +cron:30 6,18 22-28 2 * enabled:false +============Quantumultx=============== +[task_local] +#2.21-2.28 大牌联合 宠爱有礼 +30 6,18 22-28 2 * jd_opencardL80.js, tag=2.21-2.28 大牌联合 宠爱有礼, enabled=false + +*/ +const $ = new Env('2.21-2.28 大牌联合 宠爱有礼'); +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 = "unionkbblnt20220221dzlhkk" + $.shareUuid = "b370e062d2994313855807507b58fb84" + 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('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 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('已全部开卡') + } + + $.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 + let goodsArr = [] + await takePostRequest('addCart'); + await $.wait(parseInt(Math.random() * 2000 + 4000, 10)) + } + if(flag){ + await takePostRequest('activityContent'); + } + $.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/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)}&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/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 + } + 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/opencard/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) || 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 || '' + $.followShop = res.data.actor.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 + 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': + 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京豆' && item.drawStatus == 0){ + 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}个\n`) + }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/sendNotify.js b/sendNotify.js new file mode 100644 index 0000000..1aec413 --- /dev/null +++ b/sendNotify.js @@ -0,0 +1,2988 @@ +/* + * sendNotify 推送通知功能 + * @param text 通知头 + * @param desp 通知体 + * @param params 某些推送通知方式点击弹窗可跳转, 例:{ url: 'https://abc.com' } + * @param author 作者仓库等信息 例:`本通知 By:https://github.com/whyour/qinglong` + 部分变量设置 +## 拆分通知 +export BEANCHANGE_PERSENT="10" +## 如果通知标题在此变量里面存在(&隔开),则用屏蔽不发送通知 +export NOTIFY_SKIP_LIST="京东CK检测&京东资产变动" +## 当接收到发送CK失效通知和Ninja 运行通知时候执行子线程任务 +export NOTIFY_CKTASK="jd_CheckCK.js" +## 如果此变量(&隔开)的关键字在通知内容里面存在,则屏蔽不发送通知. +export NOTIFY_SKIP_TEXT="忘了种植&异常" +## 屏蔽任务脚本的ck失效通知 +export NOTIFY_NOCKFALSE="true" +## 服务器空数据等错误不触发通知 +export CKNOWARNERROR="true" +## 屏蔽青龙登陆成功通知,登陆失败不屏蔽 +export NOTIFY_NOLOGINSUCCESS="true" +## 通知底部显示 +export NOTIFY_AUTHOR="来源于:http://biao.liunians.cn:1987/jd_script/script" +## 增加NOTIFY_AUTHOR_BLANK 环境变量,控制不显示底部信息 +export NOTIFY_AUTHOR_BLANK="true" +## 增加NOTIFY_AUTOCHECKCK为true才开启通知脚本内置的自动禁用过期ck +export NOTIFY_AUTOCHECKCK=“true” + */ +//详细说明参考 https://github.com/ccwav/QLScript2. +const querystring = require('querystring'); +const exec = require('child_process').exec; +const $ = new Env(); +const timeout = 15000; //超时时间(单位毫秒) +console.log("加载sendNotify,当前版本: 20220217"); +// =======================================go-cqhttp通知设置区域=========================================== +//gobot_url 填写请求地址http://127.0.0.1/send_private_msg +//gobot_token 填写在go-cqhttp文件设置的访问密钥 +//gobot_qq 填写推送到个人QQ或者QQ群号 +//go-cqhttp相关API https://docs.go-cqhttp.org/api +let GOBOT_URL = ''; // 推送到个人QQ: http://127.0.0.1/send_private_msg 群:http://127.0.0.1/send_group_msg +let GOBOT_TOKEN = ''; //访问密钥 +let GOBOT_QQ = ''; // 如果GOBOT_URL设置 /send_private_msg 则需要填入 user_id=个人QQ 相反如果是 /send_group_msg 则需要填入 group_id=QQ群 + +// =======================================微信server酱通知设置区域=========================================== +//此处填你申请的SCKEY. +//(环境变量名 PUSH_KEY) +let SCKEY = ''; + +// =======================================Bark App通知设置区域=========================================== +//此处填你BarkAPP的信息(IP/设备码,例如:https://api.day.app/XXXXXXXX) +let BARK_PUSH = ''; +//BARK app推送铃声,铃声列表去APP查看复制填写 +let BARK_SOUND = ''; +//BARK app推送消息的分组, 默认为"QingLong" +let BARK_GROUP = 'QingLong'; + +// =======================================telegram机器人通知设置区域=========================================== +//此处填你telegram bot 的Token,telegram机器人通知推送必填项.例如:1077xxx4424:AAFjv0FcqxxxxxxgEMGfi22B4yh15R5uw +//(环境变量名 TG_BOT_TOKEN) +let TG_BOT_TOKEN = ''; +//此处填你接收通知消息的telegram用户的id,telegram机器人通知推送必填项.例如:129xxx206 +//(环境变量名 TG_USER_ID) +let TG_USER_ID = ''; +//tg推送HTTP代理设置(不懂可忽略,telegram机器人通知推送功能中非必填) +let TG_PROXY_HOST = ''; //例如:127.0.0.1(环境变量名:TG_PROXY_HOST) +let TG_PROXY_PORT = ''; //例如:1080(环境变量名:TG_PROXY_PORT) +let TG_PROXY_AUTH = ''; //tg代理配置认证参数 +//Telegram api自建的反向代理地址(不懂可忽略,telegram机器人通知推送功能中非必填),默认tg官方api(环境变量名:TG_API_HOST) +let TG_API_HOST = 'api.telegram.org'; +// =======================================钉钉机器人通知设置区域=========================================== +//此处填你钉钉 bot 的webhook,例如:5a544165465465645d0f31dca676e7bd07415asdasd +//(环境变量名 DD_BOT_TOKEN) +let DD_BOT_TOKEN = ''; +//密钥,机器人安全设置页面,加签一栏下面显示的SEC开头的字符串 +let DD_BOT_SECRET = ''; + +// =======================================企业微信机器人通知设置区域=========================================== +//此处填你企业微信机器人的 webhook(详见文档 https://work.weixin.qq.com/api/doc/90000/90136/91770),例如:693a91f6-7xxx-4bc4-97a0-0ec2sifa5aaa +//(环境变量名 QYWX_KEY) +let QYWX_KEY = ''; + +// =======================================企业微信应用消息通知设置区域=========================================== +/* +此处填你企业微信应用消息的值(详见文档 https://work.weixin.qq.com/api/doc/90000/90135/90236) +环境变量名 QYWX_AM依次填入 corpid,corpsecret,touser(注:多个成员ID使用|隔开),agentid,消息类型(选填,不填默认文本消息类型) +注意用,号隔开(英文输入法的逗号),例如:wwcff56746d9adwers,B-791548lnzXBE6_BWfxdf3kSTMJr9vFEPKAbh6WERQ,mingcheng,1000001,2COXgjH2UIfERF2zxrtUOKgQ9XklUqMdGSWLBoW_lSDAdafat +可选推送消息类型(推荐使用图文消息(mpnews)): +- 文本卡片消息: 0 (数字零) +- 文本消息: 1 (数字一) +- 图文消息(mpnews): 素材库图片id, 可查看此教程(http://note.youdao.com/s/HMiudGkb)或者(https://note.youdao.com/ynoteshare1/index.html?id=1a0c8aff284ad28cbd011b29b3ad0191&type=note) + */ +let QYWX_AM = ''; + +// =======================================iGot聚合推送通知设置区域=========================================== +//此处填您iGot的信息(推送key,例如:https://push.hellyw.com/XXXXXXXX) +let IGOT_PUSH_KEY = ''; + +// =======================================push+设置区域======================================= +//官方文档:http://www.pushplus.plus/ +//PUSH_PLUS_TOKEN:微信扫码登录后一对一推送或一对多推送下面的token(您的Token),不提供PUSH_PLUS_USER则默认为一对一推送 +//PUSH_PLUS_USER: 一对多推送的“群组编码”(一对多推送下面->您的群组(如无则新建)->群组编码,如果您是创建群组人。也需点击“查看二维码”扫描绑定,否则不能接受群组消息推送) +let PUSH_PLUS_TOKEN = ''; +let PUSH_PLUS_USER = ''; +let PUSH_PLUS_TOKEN_hxtrip = ''; +let PUSH_PLUS_USER_hxtrip = ''; + +// ======================================= WxPusher 通知设置区域 =========================================== +// 此处填你申请的 appToken. 官方文档:https://wxpusher.zjiecode.com/docs +// WP_APP_TOKEN 可在管理台查看: https://wxpusher.zjiecode.com/admin/main/app/appToken +// WP_TOPICIDS 群发, 发送目标的 topicId, 以 ; 分隔! 使用 WP_UIDS 单发的时候, 可以不传 +// WP_UIDS 发送目标的 uid, 以 ; 分隔。注意 WP_UIDS 和 WP_TOPICIDS 可以同时填写, 也可以只填写一个。 +// WP_URL 原文链接, 可选参数 +let WP_APP_TOKEN = ""; +let WP_TOPICIDS = ""; +let WP_UIDS = ""; +let WP_URL = ""; + +let WP_APP_TOKEN_ONE = ""; +if (process.env.WP_APP_TOKEN_ONE) { + WP_APP_TOKEN_ONE = process.env.WP_APP_TOKEN_ONE; +} +let WP_UIDS_ONE = ""; + +// =======================================gotify通知设置区域============================================== +//gotify_url 填写gotify地址,如https://push.example.de:8080 +//gotify_token 填写gotify的消息应用token +//gotify_priority 填写推送消息优先级,默认为0 +let GOTIFY_URL = ''; +let GOTIFY_TOKEN = ''; +let GOTIFY_PRIORITY = 0; + +/** + * sendNotify 推送通知功能 + * @param text 通知头 + * @param desp 通知体 + * @param params 某些推送通知方式点击弹窗可跳转, 例:{ url: 'https://abc.com' } + * @param author 作者仓库等信息 例:`本通知 By:https://github.com/whyour/qinglong` + * @returns {Promise} + */ +let PushErrorTime = 0; +let strTitle = ""; +let ShowRemarkType = "1"; +let Notify_NoCKFalse = "false"; +let Notify_NoLoginSuccess = "false"; +let UseGroupNotify = 1; +const { + getEnvs, + DisableCk, + getEnvByPtPin +} = require('./ql'); +const fs = require('fs'); +let strCKFile = '/ql/scripts/CKName_cache.json'; +let Fileexists = fs.existsSync(strCKFile); +let TempCK = []; +if (Fileexists) { + console.log("检测到别名缓存文件CKName_cache.json,载入..."); + TempCK = fs.readFileSync(strCKFile, 'utf-8'); + if (TempCK) { + TempCK = TempCK.toString(); + TempCK = JSON.parse(TempCK); + } +} +let strUidFile = '/ql/scripts/CK_WxPusherUid.json'; +let UidFileexists = fs.existsSync(strUidFile); +let TempCKUid = []; +if (UidFileexists) { + console.log("检测到一对一Uid文件WxPusherUid.json,载入..."); + TempCKUid = fs.readFileSync(strUidFile, 'utf-8'); + if (TempCKUid) { + TempCKUid = TempCKUid.toString(); + TempCKUid = JSON.parse(TempCKUid); + } +} + +let tempAddCK = {}; +let boolneedUpdate = false; +let strCustom = ""; +let strCustomArr = []; +let strCustomTempArr = []; +let Notify_CKTask = ""; +let Notify_SkipText = []; +let isLogin = false; +if (process.env.NOTIFY_SHOWNAMETYPE) { + ShowRemarkType = process.env.NOTIFY_SHOWNAMETYPE; + if (ShowRemarkType == "2") + console.log("检测到显示备注名称,格式为: 京东别名(备注)"); + if (ShowRemarkType == "3") + console.log("检测到显示备注名称,格式为: 京东账号(备注)"); + if (ShowRemarkType == "4") + console.log("检测到显示备注名称,格式为: 备注"); +} +async function sendNotify(text, desp, params = {}, author = '\n\n本通知 By http://biao.liunians.cn:1987/jd_script/script', strsummary = "") { + console.log(`开始发送通知...`); + + if (process.env.NOTIFY_FILTERBYFILE) { + var no_notify = process.env.NOTIFY_FILTERBYFILE.split('&'); + if (module.parent.filename) { + const script_name = module.parent.filename.split('/').slice(-1)[0]; + if (no_notify.some(key_word => { + const flag = script_name.includes(key_word); + if (flag) { + console.log(`${script_name}含有关键字${key_word},不推送`); + } + return flag; + })) { + return; + } + } + } + try { + //Reset 变量 + UseGroupNotify = 1; + strTitle = ""; + GOBOT_URL = ''; + GOBOT_TOKEN = ''; + GOBOT_QQ = ''; + SCKEY = ''; + BARK_PUSH = ''; + BARK_SOUND = ''; + BARK_GROUP = 'QingLong'; + TG_BOT_TOKEN = ''; + TG_USER_ID = ''; + TG_PROXY_HOST = ''; + TG_PROXY_PORT = ''; + TG_PROXY_AUTH = ''; + TG_API_HOST = 'api.telegram.org'; + DD_BOT_TOKEN = ''; + DD_BOT_SECRET = ''; + QYWX_KEY = ''; + QYWX_AM = ''; + IGOT_PUSH_KEY = ''; + PUSH_PLUS_TOKEN = ''; + PUSH_PLUS_USER = ''; + PUSH_PLUS_TOKEN_hxtrip = ''; + PUSH_PLUS_USER_hxtrip = ''; + Notify_CKTask = ""; + Notify_SkipText = []; + + //变量开关 + var Use_serverNotify = true; + var Use_pushPlusNotify = true; + var Use_BarkNotify = true; + var Use_tgBotNotify = true; + var Use_ddBotNotify = true; + var Use_qywxBotNotify = true; + var Use_qywxamNotify = true; + var Use_iGotNotify = true; + var Use_gobotNotify = true; + var Use_pushPlushxtripNotify = true; + var Use_WxPusher = true; + var strtext = text; + var strdesp = desp; + if (process.env.NOTIFY_NOCKFALSE) { + Notify_NoCKFalse = process.env.NOTIFY_NOCKFALSE; + } + if (process.env.NOTIFY_NOLOGINSUCCESS) { + Notify_NoLoginSuccess = process.env.NOTIFY_NOLOGINSUCCESS; + } + if (process.env.NOTIFY_CKTASK) { + Notify_CKTask = process.env.NOTIFY_CKTASK; + } + + if (process.env.NOTIFY_SKIP_TEXT && desp) { + Notify_SkipText = process.env.NOTIFY_SKIP_TEXT.split('&'); + if (Notify_SkipText.length > 0) { + for (var Templ in Notify_SkipText) { + if (desp.indexOf(Notify_SkipText[Templ]) != -1) { + console.log("检测内容到内容存在屏蔽推送的关键字(" + Notify_SkipText[Templ] + "),将跳过推送..."); + return; + } + } + } + } + + if (text.indexOf("cookie已失效") != -1 || desp.indexOf("重新登录获取") != -1 || text == "Ninja 运行通知") { + + if (Notify_CKTask) { + console.log("触发CK脚本,开始执行...."); + Notify_CKTask = "task " + Notify_CKTask + " now"; + await exec(Notify_CKTask, function (error, stdout, stderr) { + console.log(error, stdout, stderr) + }); + } + } + if (process.env.NOTIFY_AUTOCHECKCK == "true") { + if (text.indexOf("cookie已失效") != -1 || desp.indexOf("重新登录获取") != -1) { + console.log(`捕获CK过期通知,开始尝试处理...`); + var strPtPin = await GetPtPin(text); + var strdecPtPin = decodeURIComponent(strPtPin); + var llHaderror = false; + + if (strPtPin) { + var temptest = await getEnvByPtPin(strdecPtPin); + if (temptest) { + if (temptest.status == 0) { + isLogin = true; + await isLoginByX1a0He(temptest.value); + if (!isLogin) { + var tempid = 0; + if (temptest._id) { + tempid = temptest._id; + } + if (temptest.id) { + tempid = temptest.id; + } + const DisableCkBody = await DisableCk(tempid); + strPtPin = temptest.value; + strPtPin = (strPtPin.match(/pt_pin=([^; ]+)(?=;?)/) && strPtPin.match(/pt_pin=([^; ]+)(?=;?)/)[1]); + var strAllNotify = ""; + var MessageUserGp2 = ""; + var MessageUserGp3 = ""; + var MessageUserGp4 = ""; + + var userIndex2 = -1; + var userIndex3 = -1; + var userIndex4 = -1; + + var strNotifyOneTemp = ""; + if ($.isNode() && process.env.BEANCHANGE_USERGP2) { + MessageUserGp2 = process.env.BEANCHANGE_USERGP2 ? process.env.BEANCHANGE_USERGP2.split('&') : []; + } + + if ($.isNode() && process.env.BEANCHANGE_USERGP3) { + MessageUserGp3 = process.env.BEANCHANGE_USERGP3 ? process.env.BEANCHANGE_USERGP3.split('&') : []; + } + + if ($.isNode() && process.env.BEANCHANGE_USERGP4) { + MessageUserGp4 = process.env.BEANCHANGE_USERGP4 ? process.env.BEANCHANGE_USERGP4.split('&') : []; + } + + if (MessageUserGp4) { + userIndex4 = MessageUserGp4.findIndex((item) => item === strPtPin); + + } + if (MessageUserGp2) { + userIndex2 = MessageUserGp2.findIndex((item) => item === strPtPin); + } + if (MessageUserGp3) { + userIndex3 = MessageUserGp3.findIndex((item) => item === strPtPin); + } + + if (userIndex2 != -1) { + console.log(`该账号属于分组2`); + text = "京东CK检测#2"; + } + if (userIndex3 != -1) { + console.log(`该账号属于分组3`); + text = "京东CK检测#3"; + } + if (userIndex4 != -1) { + console.log(`该账号属于分组4`); + text = "京东CK检测#4"; + } + if (userIndex4 == -1 && userIndex2 == -1 && userIndex3 == -1) { + text = "京东CK检测"; + } + if (process.env.CHECKCK_ALLNOTIFY) { + strAllNotify = process.env.CHECKCK_ALLNOTIFY; + /* if (strTempNotify.length > 0) { + for (var TempNotifyl in strTempNotify) { + strAllNotify += strTempNotify[TempNotifyl] + '\n'; + } + }*/ + console.log(`检测到设定了温馨提示,将在推送信息中置顶显示...`); + strAllNotify = `\n【✨✨✨✨温馨提示✨✨✨✨】\n` + strAllNotify; + console.log(strAllNotify); + } + + if (DisableCkBody.code == 200) { + console.log(`京东账号` + strdecPtPin + `已失效,自动禁用成功!\n`); + + strNotifyOneTemp = `京东账号: ` + strdecPtPin + ` 已失效,自动禁用成功!\n如果要继续挂机,请联系管理员重新登录账号,账号有效期为30天.`; + strNotifyOneTemp += "\n任务标题:" + strtext; + if (strAllNotify) + strNotifyOneTemp += `\n` + strAllNotify; + desp = strNotifyOneTemp; + if (WP_APP_TOKEN_ONE) { + await sendNotifybyWxPucher(`账号过期下线通知`, strNotifyOneTemp, strdecPtPin); + } + + } else { + console.log(`京东账号` + strPtPin + `已失效,自动禁用失败!\n`); + strNotifyOneTemp = `京东账号: ` + strdecPtPin + ` 已失效!\n如果要继续挂机,请联系管理员重新登录账号,账号有效期为30天.`; + strNotifyOneTemp += "\n任务标题:" + strtext; + if (strAllNotify) + strNotifyOneTemp += `\n` + strAllNotify; + desp = strNotifyOneTemp; + if (WP_APP_TOKEN_ONE) { + await sendNotifybyWxPucher(`账号过期下线通知`, strNotifyOneTemp, strdecPtPin); + } + } + } else { + console.log(`该CK已经检测没有有效,跳过通知...`); + llHaderror = true; + } + } else { + console.log(`该CK已经禁用不需要处理`); + llHaderror = true; + } + + } + + } else { + console.log(`CK过期通知处理失败...`); + } + if (llHaderror) + return; + } + } + if (strtext.indexOf("cookie已失效") != -1 || strdesp.indexOf("重新登录获取") != -1 || strtext == "Ninja 运行通知") { + if (Notify_NoCKFalse == "true" && text != "Ninja 运行通知") { + console.log(`检测到NOTIFY_NOCKFALSE变量为true,不发送ck失效通知...`); + return; + } + } + + //检查黑名单屏蔽通知 + const notifySkipList = process.env.NOTIFY_SKIP_LIST ? process.env.NOTIFY_SKIP_LIST.split('&') : []; + let titleIndex = notifySkipList.findIndex((item) => item === text); + + if (titleIndex !== -1) { + console.log(`${text} 在推送黑名单中,已跳过推送`); + return; + } + + if (text.indexOf("已可领取") != -1) { + if (text.indexOf("农场") != -1) { + strTitle = "东东农场领取"; + } else { + strTitle = "东东萌宠领取"; + } + } + if (text.indexOf("汪汪乐园养joy") != -1) { + strTitle = "汪汪乐园养joy领取"; + } + + if (text == "京喜工厂") { + if (desp.indexOf("元造进行兑换") != -1) { + strTitle = "京喜工厂领取"; + } + } + + if (text.indexOf("任务") != -1 && (text.indexOf("新增") != -1 || text.indexOf("删除") != -1)) { + strTitle = "脚本任务更新"; + } + if (strTitle) { + const notifyRemindList = process.env.NOTIFY_NOREMIND ? process.env.NOTIFY_NOREMIND.split('&') : []; + titleIndex = notifyRemindList.findIndex((item) => item === strTitle); + + if (titleIndex !== -1) { + console.log(`${text} 在领取信息黑名单中,已跳过推送`); + return; + } + + } else { + strTitle = text; + } + + if (Notify_NoLoginSuccess == "true") { + if (desp.indexOf("登陆成功") != -1) { + console.log(`登陆成功不推送`); + return; + } + } + + if (strTitle == "汪汪乐园养joy领取" && WP_APP_TOKEN_ONE) { + console.log(`捕获汪汪乐园养joy领取通知,开始尝试一对一推送...`); + var strPtPin = await GetPtPin(text); + var strdecPtPin = decodeURIComponent(strPtPin); + if (strPtPin) { + await sendNotifybyWxPucher("汪汪乐园领取通知", `【京东账号】${strdecPtPin}\n当前等级: 30\n已自动领取最高等级奖励\n请前往京东极速版APP查看使用优惠券\n活动入口:京东极速版APP->我的->优惠券->京券`, strdecPtPin); + } + } + + console.log("通知标题: " + strTitle); + + //检查脚本名称是否需要通知到Group2,Group2读取原环境配置的变量名后加2的值.例如: QYWX_AM2 + const notifyGroup2List = process.env.NOTIFY_GROUP2_LIST ? process.env.NOTIFY_GROUP2_LIST.split('&') : []; + const titleIndex2 = notifyGroup2List.findIndex((item) => item === strTitle); + const notifyGroup3List = process.env.NOTIFY_GROUP3_LIST ? process.env.NOTIFY_GROUP3_LIST.split('&') : []; + const titleIndexGp3 = notifyGroup3List.findIndex((item) => item === strTitle); + const notifyGroup4List = process.env.NOTIFY_GROUP4_LIST ? process.env.NOTIFY_GROUP4_LIST.split('&') : []; + const titleIndexGp4 = notifyGroup4List.findIndex((item) => item === strTitle); + const notifyGroup5List = process.env.NOTIFY_GROUP5_LIST ? process.env.NOTIFY_GROUP5_LIST.split('&') : []; + const titleIndexGp5 = notifyGroup5List.findIndex((item) => item === strTitle); + const notifyGroup6List = process.env.NOTIFY_GROUP6_LIST ? process.env.NOTIFY_GROUP6_LIST.split('&') : []; + const titleIndexGp6 = notifyGroup6List.findIndex((item) => item === strTitle); + const notifyGroup7List = process.env.NOTIFY_GROUP7_LIST ? process.env.NOTIFY_GROUP7_LIST.split('&') : []; + const titleIndexGp7 = notifyGroup7List.findIndex((item) => item === strTitle); + + if (titleIndex2 !== -1) { + console.log(`${strTitle} 在群组2推送名单中,初始化群组推送`); + UseGroupNotify = 2; + } + if (titleIndexGp3 !== -1) { + console.log(`${strTitle} 在群组3推送名单中,初始化群组推送`); + UseGroupNotify = 3; + } + if (titleIndexGp4 !== -1) { + console.log(`${strTitle} 在群组4推送名单中,初始化群组推送`); + UseGroupNotify = 4; + } + if (titleIndexGp5 !== -1) { + console.log(`${strTitle} 在群组5推送名单中,初始化群组推送`); + UseGroupNotify = 5; + } + if (titleIndexGp6 !== -1) { + console.log(`${strTitle} 在群组6推送名单中,初始化群组推送`); + UseGroupNotify = 6; + } + if (titleIndexGp7 !== -1) { + console.log(`${strTitle} 在群组7推送名单中,初始化群组推送`); + UseGroupNotify = 7; + } + if (process.env.NOTIFY_CUSTOMNOTIFY) { + strCustom = process.env.NOTIFY_CUSTOMNOTIFY; + } + if (strCustom) { + strCustomArr = strCustom.replace(/^\[|\]$/g, "").split(","); + strCustomTempArr = []; + for (var Tempj in strCustomArr) { + strCustomTempArr = strCustomArr[Tempj].split("&"); + if (strCustomTempArr.length > 1) { + if (strTitle == strCustomTempArr[0]) { + console.log("检测到自定义设定,开始执行配置..."); + if (strCustomTempArr[1] == "组1") { + console.log("自定义设定强制使用组1配置通知..."); + UseGroupNotify = 1; + } + if (strCustomTempArr[1] == "组2") { + console.log("自定义设定强制使用组2配置通知..."); + UseGroupNotify = 2; + } + if (strCustomTempArr[1] == "组3") { + console.log("自定义设定强制使用组3配置通知..."); + UseGroupNotify = 3; + } + if (strCustomTempArr[1] == "组4") { + console.log("自定义设定强制使用组4配置通知..."); + UseGroupNotify = 4; + } + if (strCustomTempArr[1] == "组5") { + console.log("自定义设定强制使用组5配置通知..."); + UseGroupNotify = 5; + } + if (strCustomTempArr[1] == "组6") { + console.log("自定义设定强制使用组6配置通知..."); + UseGroupNotify = 6; + } + if (strCustomTempArr[1] == "组7") { + console.log("自定义设定强制使用组6配置通知..."); + UseGroupNotify = 7; + } + if (strCustomTempArr.length > 2) { + console.log("关闭所有通知变量..."); + Use_serverNotify = false; + Use_pushPlusNotify = false; + Use_pushPlushxtripNotify = false; + Use_BarkNotify = false; + Use_tgBotNotify = false; + Use_ddBotNotify = false; + Use_qywxBotNotify = false; + Use_qywxamNotify = false; + Use_iGotNotify = false; + Use_gobotNotify = false; + + for (let Tempk = 2; Tempk < strCustomTempArr.length; Tempk++) { + var strTrmp = strCustomTempArr[Tempk]; + switch (strTrmp) { + case "Server酱": + Use_serverNotify = true; + console.log("自定义设定启用Server酱进行通知..."); + break; + case "pushplus": + Use_pushPlusNotify = true; + console.log("自定义设定启用pushplus(推送加)进行通知..."); + break; + case "pushplushxtrip": + Use_pushPlushxtripNotify = true; + console.log("自定义设定启用pushplus_hxtrip(推送加)进行通知..."); + break; + case "Bark": + Use_BarkNotify = true; + console.log("自定义设定启用Bark进行通知..."); + break; + case "TG机器人": + Use_tgBotNotify = true; + console.log("自定义设定启用telegram机器人进行通知..."); + break; + case "钉钉": + Use_ddBotNotify = true; + console.log("自定义设定启用钉钉机器人进行通知..."); + break; + case "企业微信机器人": + Use_qywxBotNotify = true; + console.log("自定义设定启用企业微信机器人进行通知..."); + break; + case "企业微信应用消息": + Use_qywxamNotify = true; + console.log("自定义设定启用企业微信应用消息进行通知..."); + break; + case "iGotNotify": + Use_iGotNotify = true; + console.log("自定义设定启用iGot进行通知..."); + break; + case "gobotNotify": + Use_gobotNotify = true; + console.log("自定义设定启用go-cqhttp进行通知..."); + break; + case "WxPusher": + Use_WxPusher = true; + console.log("自定义设定启用WxPusher进行通知..."); + break; + + } + } + + } + } + } + } + + } + + //console.log("UseGroup2 :"+UseGroup2); + //console.log("UseGroup3 :"+UseGroup3); + + + switch (UseGroupNotify) { + case 1: + if (process.env.GOBOT_URL && Use_gobotNotify) { + GOBOT_URL = process.env.GOBOT_URL; + } + if (process.env.GOBOT_TOKEN && Use_gobotNotify) { + GOBOT_TOKEN = process.env.GOBOT_TOKEN; + } + if (process.env.GOBOT_QQ && Use_gobotNotify) { + GOBOT_QQ = process.env.GOBOT_QQ; + } + + if (process.env.PUSH_KEY && Use_serverNotify) { + SCKEY = process.env.PUSH_KEY; + } + + if (process.env.WP_APP_TOKEN && Use_WxPusher) { + WP_APP_TOKEN = process.env.WP_APP_TOKEN; + } + + if (process.env.WP_TOPICIDS && Use_WxPusher) { + WP_TOPICIDS = process.env.WP_TOPICIDS; + } + + if (process.env.WP_UIDS && Use_WxPusher) { + WP_UIDS = process.env.WP_UIDS; + } + + if (process.env.WP_URL && Use_WxPusher) { + WP_URL = process.env.WP_URL; + } + if (process.env.BARK_PUSH && Use_BarkNotify) { + if (process.env.BARK_PUSH.indexOf('https') > -1 || process.env.BARK_PUSH.indexOf('http') > -1) { + //兼容BARK自建用户 + BARK_PUSH = process.env.BARK_PUSH; + } else { + BARK_PUSH = `https://api.day.app/${process.env.BARK_PUSH}`; + } + if (process.env.BARK_SOUND) { + BARK_SOUND = process.env.BARK_SOUND; + } + if (process.env.BARK_GROUP) { + BARK_GROUP = process.env.BARK_GROUP; + } + } else { + if (BARK_PUSH && BARK_PUSH.indexOf('https') === -1 && BARK_PUSH.indexOf('http') === -1 && Use_BarkNotify) { + //兼容BARK本地用户只填写设备码的情况 + BARK_PUSH = `https://api.day.app/${BARK_PUSH}`; + } + } + if (process.env.TG_BOT_TOKEN && Use_tgBotNotify) { + TG_BOT_TOKEN = process.env.TG_BOT_TOKEN; + } + if (process.env.TG_USER_ID && Use_tgBotNotify) { + TG_USER_ID = process.env.TG_USER_ID; + } + if (process.env.TG_PROXY_AUTH && Use_tgBotNotify) + TG_PROXY_AUTH = process.env.TG_PROXY_AUTH; + if (process.env.TG_PROXY_HOST && Use_tgBotNotify) + TG_PROXY_HOST = process.env.TG_PROXY_HOST; + if (process.env.TG_PROXY_PORT && Use_tgBotNotify) + TG_PROXY_PORT = process.env.TG_PROXY_PORT; + if (process.env.TG_API_HOST && Use_tgBotNotify) + TG_API_HOST = process.env.TG_API_HOST; + + if (process.env.DD_BOT_TOKEN && Use_ddBotNotify) { + DD_BOT_TOKEN = process.env.DD_BOT_TOKEN; + if (process.env.DD_BOT_SECRET) { + DD_BOT_SECRET = process.env.DD_BOT_SECRET; + } + } + + if (process.env.QYWX_KEY && Use_qywxBotNotify) { + QYWX_KEY = process.env.QYWX_KEY; + } + + if (process.env.QYWX_AM && Use_qywxamNotify) { + QYWX_AM = process.env.QYWX_AM; + } + + if (process.env.IGOT_PUSH_KEY && Use_iGotNotify) { + IGOT_PUSH_KEY = process.env.IGOT_PUSH_KEY; + } + + if (process.env.PUSH_PLUS_TOKEN && Use_pushPlusNotify) { + PUSH_PLUS_TOKEN = process.env.PUSH_PLUS_TOKEN; + } + if (process.env.PUSH_PLUS_USER && Use_pushPlusNotify) { + PUSH_PLUS_USER = process.env.PUSH_PLUS_USER; + } + + if (process.env.PUSH_PLUS_TOKEN_hxtrip && Use_pushPlushxtripNotify) { + PUSH_PLUS_TOKEN_hxtrip = process.env.PUSH_PLUS_TOKEN_hxtrip; + } + if (process.env.PUSH_PLUS_USER_hxtrip && Use_pushPlushxtripNotify) { + PUSH_PLUS_USER_hxtrip = process.env.PUSH_PLUS_USER_hxtrip; + } + if (process.env.GOTIFY_URL) { + GOTIFY_URL = process.env.GOTIFY_URL; + } + if (process.env.GOTIFY_TOKEN) { + GOTIFY_TOKEN = process.env.GOTIFY_TOKEN; + } + if (process.env.GOTIFY_PRIORITY) { + GOTIFY_PRIORITY = process.env.GOTIFY_PRIORITY; + } + + break; + + case 2: + //==========================第二套环境变量赋值========================= + + if (process.env.GOBOT_URL2 && Use_gobotNotify) { + GOBOT_URL = process.env.GOBOT_URL2; + } + if (process.env.GOBOT_TOKEN2 && Use_gobotNotify) { + GOBOT_TOKEN = process.env.GOBOT_TOKEN2; + } + if (process.env.GOBOT_QQ2 && Use_gobotNotify) { + GOBOT_QQ = process.env.GOBOT_QQ2; + } + + if (process.env.PUSH_KEY2 && Use_serverNotify) { + SCKEY = process.env.PUSH_KEY2; + } + + if (process.env.WP_APP_TOKEN2 && Use_WxPusher) { + WP_APP_TOKEN = process.env.WP_APP_TOKEN2; + } + + if (process.env.WP_TOPICIDS2 && Use_WxPusher) { + WP_TOPICIDS = process.env.WP_TOPICIDS2; + } + + if (process.env.WP_UIDS2 && Use_WxPusher) { + WP_UIDS = process.env.WP_UIDS2; + } + + if (process.env.WP_URL2 && Use_WxPusher) { + WP_URL = process.env.WP_URL2; + } + if (process.env.BARK_PUSH2 && Use_BarkNotify) { + if (process.env.BARK_PUSH2.indexOf('https') > -1 || process.env.BARK_PUSH2.indexOf('http') > -1) { + //兼容BARK自建用户 + BARK_PUSH = process.env.BARK_PUSH2; + } else { + BARK_PUSH = `https://api.day.app/${process.env.BARK_PUSH2}`; + } + if (process.env.BARK_SOUND2) { + BARK_SOUND = process.env.BARK_SOUND2; + } + if (process.env.BARK_GROUP2) { + BARK_GROUP = process.env.BARK_GROUP2; + } + } + if (process.env.TG_BOT_TOKEN2 && Use_tgBotNotify) { + TG_BOT_TOKEN = process.env.TG_BOT_TOKEN2; + } + if (process.env.TG_USER_ID2 && Use_tgBotNotify) { + TG_USER_ID = process.env.TG_USER_ID2; + } + if (process.env.TG_PROXY_AUTH2 && Use_tgBotNotify) + TG_PROXY_AUTH = process.env.TG_PROXY_AUTH2; + if (process.env.TG_PROXY_HOST2 && Use_tgBotNotify) + TG_PROXY_HOST = process.env.TG_PROXY_HOST2; + if (process.env.TG_PROXY_PORT2 && Use_tgBotNotify) + TG_PROXY_PORT = process.env.TG_PROXY_PORT2; + if (process.env.TG_API_HOST2 && Use_tgBotNotify) + TG_API_HOST = process.env.TG_API_HOST2; + + if (process.env.DD_BOT_TOKEN2 && Use_ddBotNotify) { + DD_BOT_TOKEN = process.env.DD_BOT_TOKEN2; + if (process.env.DD_BOT_SECRET2) { + DD_BOT_SECRET = process.env.DD_BOT_SECRET2; + } + } + + if (process.env.QYWX_KEY2 && Use_qywxBotNotify) { + QYWX_KEY = process.env.QYWX_KEY2; + } + + if (process.env.QYWX_AM2 && Use_qywxamNotify) { + QYWX_AM = process.env.QYWX_AM2; + } + + if (process.env.IGOT_PUSH_KEY2 && Use_iGotNotify) { + IGOT_PUSH_KEY = process.env.IGOT_PUSH_KEY2; + } + + if (process.env.PUSH_PLUS_TOKEN2 && Use_pushPlusNotify) { + PUSH_PLUS_TOKEN = process.env.PUSH_PLUS_TOKEN2; + } + if (process.env.PUSH_PLUS_USER2 && Use_pushPlusNotify) { + PUSH_PLUS_USER = process.env.PUSH_PLUS_USER2; + } + + if (process.env.PUSH_PLUS_TOKEN_hxtrip2 && Use_pushPlushxtripNotify) { + PUSH_PLUS_TOKEN_hxtrip = process.env.PUSH_PLUS_TOKEN_hxtrip2; + } + if (process.env.PUSH_PLUS_USER_hxtrip2 && Use_pushPlushxtripNotify) { + PUSH_PLUS_USER_hxtrip = process.env.PUSH_PLUS_USER_hxtrip2; + } + if (process.env.GOTIFY_URL2) { + GOTIFY_URL = process.env.GOTIFY_URL2; + } + if (process.env.GOTIFY_TOKEN2) { + GOTIFY_TOKEN = process.env.GOTIFY_TOKEN2; + } + if (process.env.GOTIFY_PRIORITY2) { + GOTIFY_PRIORITY = process.env.GOTIFY_PRIORITY2; + } + break; + + case 3: + //==========================第三套环境变量赋值========================= + + if (process.env.GOBOT_URL3 && Use_gobotNotify) { + GOBOT_URL = process.env.GOBOT_URL3; + } + if (process.env.GOBOT_TOKEN3 && Use_gobotNotify) { + GOBOT_TOKEN = process.env.GOBOT_TOKEN3; + } + if (process.env.GOBOT_QQ3 && Use_gobotNotify) { + GOBOT_QQ = process.env.GOBOT_QQ3; + } + + if (process.env.PUSH_KEY3 && Use_serverNotify) { + SCKEY = process.env.PUSH_KEY3; + } + + if (process.env.WP_APP_TOKEN3 && Use_WxPusher) { + WP_APP_TOKEN = process.env.WP_APP_TOKEN3; + } + + if (process.env.WP_TOPICIDS3 && Use_WxPusher) { + WP_TOPICIDS = process.env.WP_TOPICIDS3; + } + + if (process.env.WP_UIDS3 && Use_WxPusher) { + WP_UIDS = process.env.WP_UIDS3; + } + + if (process.env.WP_URL3 && Use_WxPusher) { + WP_URL = process.env.WP_URL3; + } + + if (process.env.BARK_PUSH3 && Use_BarkNotify) { + if (process.env.BARK_PUSH3.indexOf('https') > -1 || process.env.BARK_PUSH3.indexOf('http') > -1) { + //兼容BARK自建用户 + BARK_PUSH = process.env.BARK_PUSH3; + } else { + BARK_PUSH = `https://api.day.app/${process.env.BARK_PUSH3}`; + } + if (process.env.BARK_SOUND3) { + BARK_SOUND = process.env.BARK_SOUND3; + } + if (process.env.BARK_GROUP3) { + BARK_GROUP = process.env.BARK_GROUP3; + } + } + if (process.env.TG_BOT_TOKEN3 && Use_tgBotNotify) { + TG_BOT_TOKEN = process.env.TG_BOT_TOKEN3; + } + if (process.env.TG_USER_ID3 && Use_tgBotNotify) { + TG_USER_ID = process.env.TG_USER_ID3; + } + if (process.env.TG_PROXY_AUTH3 && Use_tgBotNotify) + TG_PROXY_AUTH = process.env.TG_PROXY_AUTH3; + if (process.env.TG_PROXY_HOST3 && Use_tgBotNotify) + TG_PROXY_HOST = process.env.TG_PROXY_HOST3; + if (process.env.TG_PROXY_PORT3 && Use_tgBotNotify) + TG_PROXY_PORT = process.env.TG_PROXY_PORT3; + if (process.env.TG_API_HOST3 && Use_tgBotNotify) + TG_API_HOST = process.env.TG_API_HOST3; + + if (process.env.DD_BOT_TOKEN3 && Use_ddBotNotify) { + DD_BOT_TOKEN = process.env.DD_BOT_TOKEN3; + if (process.env.DD_BOT_SECRET3) { + DD_BOT_SECRET = process.env.DD_BOT_SECRET3; + } + } + + if (process.env.QYWX_KEY3 && Use_qywxBotNotify) { + QYWX_KEY = process.env.QYWX_KEY3; + } + + if (process.env.QYWX_AM3 && Use_qywxamNotify) { + QYWX_AM = process.env.QYWX_AM3; + } + + if (process.env.IGOT_PUSH_KEY3 && Use_iGotNotify) { + IGOT_PUSH_KEY = process.env.IGOT_PUSH_KEY3; + } + + if (process.env.PUSH_PLUS_TOKEN3 && Use_pushPlusNotify) { + PUSH_PLUS_TOKEN = process.env.PUSH_PLUS_TOKEN3; + } + if (process.env.PUSH_PLUS_USER3 && Use_pushPlusNotify) { + PUSH_PLUS_USER = process.env.PUSH_PLUS_USER3; + } + + if (process.env.PUSH_PLUS_TOKEN_hxtrip3 && Use_pushPlushxtripNotify) { + PUSH_PLUS_TOKEN_hxtrip = process.env.PUSH_PLUS_TOKEN_hxtrip3; + } + if (process.env.PUSH_PLUS_USER_hxtrip3 && Use_pushPlushxtripNotify) { + PUSH_PLUS_USER_hxtrip = process.env.PUSH_PLUS_USER_hxtrip3; + } + if (process.env.GOTIFY_URL3) { + GOTIFY_URL = process.env.GOTIFY_URL3; + } + if (process.env.GOTIFY_TOKEN3) { + GOTIFY_TOKEN = process.env.GOTIFY_TOKEN3; + } + if (process.env.GOTIFY_PRIORITY3) { + GOTIFY_PRIORITY = process.env.GOTIFY_PRIORITY3; + } + break; + + case 4: + //==========================第四套环境变量赋值========================= + + if (process.env.GOBOT_URL4 && Use_gobotNotify) { + GOBOT_URL = process.env.GOBOT_URL4; + } + if (process.env.GOBOT_TOKEN4 && Use_gobotNotify) { + GOBOT_TOKEN = process.env.GOBOT_TOKEN4; + } + if (process.env.GOBOT_QQ4 && Use_gobotNotify) { + GOBOT_QQ = process.env.GOBOT_QQ4; + } + + if (process.env.PUSH_KEY4 && Use_serverNotify) { + SCKEY = process.env.PUSH_KEY4; + } + + if (process.env.WP_APP_TOKEN4 && Use_WxPusher) { + WP_APP_TOKEN = process.env.WP_APP_TOKEN4; + } + + if (process.env.WP_TOPICIDS4 && Use_WxPusher) { + WP_TOPICIDS = process.env.WP_TOPICIDS4; + } + + if (process.env.WP_UIDS4 && Use_WxPusher) { + WP_UIDS = process.env.WP_UIDS4; + } + + if (process.env.WP_URL4 && Use_WxPusher) { + WP_URL = process.env.WP_URL4; + } + + if (process.env.BARK_PUSH4 && Use_BarkNotify) { + if (process.env.BARK_PUSH4.indexOf('https') > -1 || process.env.BARK_PUSH4.indexOf('http') > -1) { + //兼容BARK自建用户 + BARK_PUSH = process.env.BARK_PUSH4; + } else { + BARK_PUSH = `https://api.day.app/${process.env.BARK_PUSH4}`; + } + if (process.env.BARK_SOUND4) { + BARK_SOUND = process.env.BARK_SOUND4; + } + if (process.env.BARK_GROUP4) { + BARK_GROUP = process.env.BARK_GROUP4; + } + } + if (process.env.TG_BOT_TOKEN4 && Use_tgBotNotify) { + TG_BOT_TOKEN = process.env.TG_BOT_TOKEN4; + } + if (process.env.TG_USER_ID4 && Use_tgBotNotify) { + TG_USER_ID = process.env.TG_USER_ID4; + } + if (process.env.TG_PROXY_AUTH4 && Use_tgBotNotify) + TG_PROXY_AUTH = process.env.TG_PROXY_AUTH4; + if (process.env.TG_PROXY_HOST4 && Use_tgBotNotify) + TG_PROXY_HOST = process.env.TG_PROXY_HOST4; + if (process.env.TG_PROXY_PORT4 && Use_tgBotNotify) + TG_PROXY_PORT = process.env.TG_PROXY_PORT4; + if (process.env.TG_API_HOST4 && Use_tgBotNotify) + TG_API_HOST = process.env.TG_API_HOST4; + + if (process.env.DD_BOT_TOKEN4 && Use_ddBotNotify) { + DD_BOT_TOKEN = process.env.DD_BOT_TOKEN4; + if (process.env.DD_BOT_SECRET4) { + DD_BOT_SECRET = process.env.DD_BOT_SECRET4; + } + } + + if (process.env.QYWX_KEY4 && Use_qywxBotNotify) { + QYWX_KEY = process.env.QYWX_KEY4; + } + + if (process.env.QYWX_AM4 && Use_qywxamNotify) { + QYWX_AM = process.env.QYWX_AM4; + } + + if (process.env.IGOT_PUSH_KEY4 && Use_iGotNotify) { + IGOT_PUSH_KEY = process.env.IGOT_PUSH_KEY4; + } + + if (process.env.PUSH_PLUS_TOKEN4 && Use_pushPlusNotify) { + PUSH_PLUS_TOKEN = process.env.PUSH_PLUS_TOKEN4; + } + if (process.env.PUSH_PLUS_USER4 && Use_pushPlusNotify) { + PUSH_PLUS_USER = process.env.PUSH_PLUS_USER4; + } + + if (process.env.PUSH_PLUS_TOKEN_hxtrip4 && Use_pushPlushxtripNotify) { + PUSH_PLUS_TOKEN_hxtrip = process.env.PUSH_PLUS_TOKEN_hxtrip4; + } + if (process.env.PUSH_PLUS_USER_hxtrip4 && Use_pushPlushxtripNotify) { + PUSH_PLUS_USER_hxtrip = process.env.PUSH_PLUS_USER_hxtrip4; + } + if (process.env.GOTIFY_URL4) { + GOTIFY_URL = process.env.GOTIFY_URL4; + } + if (process.env.GOTIFY_TOKEN4) { + GOTIFY_TOKEN = process.env.GOTIFY_TOKEN4; + } + if (process.env.GOTIFY_PRIORITY4) { + GOTIFY_PRIORITY = process.env.GOTIFY_PRIORITY4; + } + break; + + case 5: + //==========================第五套环境变量赋值========================= + + if (process.env.GOBOT_URL5 && Use_gobotNotify) { + GOBOT_URL = process.env.GOBOT_URL5; + } + if (process.env.GOBOT_TOKEN5 && Use_gobotNotify) { + GOBOT_TOKEN = process.env.GOBOT_TOKEN5; + } + if (process.env.GOBOT_QQ5 && Use_gobotNotify) { + GOBOT_QQ = process.env.GOBOT_QQ5; + } + + if (process.env.PUSH_KEY5 && Use_serverNotify) { + SCKEY = process.env.PUSH_KEY5; + } + + if (process.env.WP_APP_TOKEN5 && Use_WxPusher) { + WP_APP_TOKEN = process.env.WP_APP_TOKEN5; + } + + if (process.env.WP_TOPICIDS5 && Use_WxPusher) { + WP_TOPICIDS = process.env.WP_TOPICIDS5; + } + + if (process.env.WP_UIDS5 && Use_WxPusher) { + WP_UIDS = process.env.WP_UIDS5; + } + + if (process.env.WP_URL5 && Use_WxPusher) { + WP_URL = process.env.WP_URL5; + } + if (process.env.BARK_PUSH5 && Use_BarkNotify) { + if (process.env.BARK_PUSH5.indexOf('https') > -1 || process.env.BARK_PUSH5.indexOf('http') > -1) { + //兼容BARK自建用户 + BARK_PUSH = process.env.BARK_PUSH5; + } else { + BARK_PUSH = `https://api.day.app/${process.env.BARK_PUSH5}`; + } + if (process.env.BARK_SOUND5) { + BARK_SOUND = process.env.BARK_SOUND5; + } + if (process.env.BARK_GROUP5) { + BARK_GROUP = process.env.BARK_GROUP5; + } + } + if (process.env.TG_BOT_TOKEN5 && Use_tgBotNotify) { + TG_BOT_TOKEN = process.env.TG_BOT_TOKEN5; + } + if (process.env.TG_USER_ID5 && Use_tgBotNotify) { + TG_USER_ID = process.env.TG_USER_ID5; + } + if (process.env.TG_PROXY_AUTH5 && Use_tgBotNotify) + TG_PROXY_AUTH = process.env.TG_PROXY_AUTH5; + if (process.env.TG_PROXY_HOST5 && Use_tgBotNotify) + TG_PROXY_HOST = process.env.TG_PROXY_HOST5; + if (process.env.TG_PROXY_PORT5 && Use_tgBotNotify) + TG_PROXY_PORT = process.env.TG_PROXY_PORT5; + if (process.env.TG_API_HOST5 && Use_tgBotNotify) + TG_API_HOST = process.env.TG_API_HOST5; + + if (process.env.DD_BOT_TOKEN5 && Use_ddBotNotify) { + DD_BOT_TOKEN = process.env.DD_BOT_TOKEN5; + if (process.env.DD_BOT_SECRET5) { + DD_BOT_SECRET = process.env.DD_BOT_SECRET5; + } + } + + if (process.env.QYWX_KEY5 && Use_qywxBotNotify) { + QYWX_KEY = process.env.QYWX_KEY5; + } + + if (process.env.QYWX_AM5 && Use_qywxamNotify) { + QYWX_AM = process.env.QYWX_AM5; + } + + if (process.env.IGOT_PUSH_KEY5 && Use_iGotNotify) { + IGOT_PUSH_KEY = process.env.IGOT_PUSH_KEY5; + } + + if (process.env.PUSH_PLUS_TOKEN5 && Use_pushPlusNotify) { + PUSH_PLUS_TOKEN = process.env.PUSH_PLUS_TOKEN5; + } + if (process.env.PUSH_PLUS_USER5 && Use_pushPlusNotify) { + PUSH_PLUS_USER = process.env.PUSH_PLUS_USER5; + } + + if (process.env.PUSH_PLUS_TOKEN_hxtrip5 && Use_pushPlushxtripNotify) { + PUSH_PLUS_TOKEN_hxtrip = process.env.PUSH_PLUS_TOKEN_hxtrip5; + } + if (process.env.PUSH_PLUS_USER_hxtrip5 && Use_pushPlushxtripNotify) { + PUSH_PLUS_USER_hxtrip = process.env.PUSH_PLUS_USER_hxtrip5; + } + if (process.env.GOTIFY_URL5) { + GOTIFY_URL = process.env.GOTIFY_URL5; + } + if (process.env.GOTIFY_TOKEN5) { + GOTIFY_TOKEN = process.env.GOTIFY_TOKEN5; + } + if (process.env.GOTIFY_PRIORITY5) { + GOTIFY_PRIORITY = process.env.GOTIFY_PRIORITY5; + } + break; + + case 6: + //==========================第六套环境变量赋值========================= + + if (process.env.GOBOT_URL6 && Use_gobotNotify) { + GOBOT_URL = process.env.GOBOT_URL6; + } + if (process.env.GOBOT_TOKEN6 && Use_gobotNotify) { + GOBOT_TOKEN = process.env.GOBOT_TOKEN6; + } + if (process.env.GOBOT_QQ6 && Use_gobotNotify) { + GOBOT_QQ = process.env.GOBOT_QQ6; + } + + if (process.env.PUSH_KEY6 && Use_serverNotify) { + SCKEY = process.env.PUSH_KEY6; + } + + if (process.env.WP_APP_TOKEN6 && Use_WxPusher) { + WP_APP_TOKEN = process.env.WP_APP_TOKEN6; + } + + if (process.env.WP_TOPICIDS6 && Use_WxPusher) { + WP_TOPICIDS = process.env.WP_TOPICIDS6; + } + + if (process.env.WP_UIDS6 && Use_WxPusher) { + WP_UIDS = process.env.WP_UIDS6; + } + + if (process.env.WP_URL6 && Use_WxPusher) { + WP_URL = process.env.WP_URL6; + } + if (process.env.BARK_PUSH6 && Use_BarkNotify) { + if (process.env.BARK_PUSH6.indexOf('https') > -1 || process.env.BARK_PUSH6.indexOf('http') > -1) { + //兼容BARK自建用户 + BARK_PUSH = process.env.BARK_PUSH6; + } else { + BARK_PUSH = `https://api.day.app/${process.env.BARK_PUSH6}`; + } + if (process.env.BARK_SOUND6) { + BARK_SOUND = process.env.BARK_SOUND6; + } + if (process.env.BARK_GROUP6) { + BARK_GROUP = process.env.BARK_GROUP6; + } + } + if (process.env.TG_BOT_TOKEN6 && Use_tgBotNotify) { + TG_BOT_TOKEN = process.env.TG_BOT_TOKEN6; + } + if (process.env.TG_USER_ID6 && Use_tgBotNotify) { + TG_USER_ID = process.env.TG_USER_ID6; + } + if (process.env.TG_PROXY_AUTH6 && Use_tgBotNotify) + TG_PROXY_AUTH = process.env.TG_PROXY_AUTH6; + if (process.env.TG_PROXY_HOST6 && Use_tgBotNotify) + TG_PROXY_HOST = process.env.TG_PROXY_HOST6; + if (process.env.TG_PROXY_PORT6 && Use_tgBotNotify) + TG_PROXY_PORT = process.env.TG_PROXY_PORT6; + if (process.env.TG_API_HOST6 && Use_tgBotNotify) + TG_API_HOST = process.env.TG_API_HOST6; + + if (process.env.DD_BOT_TOKEN6 && Use_ddBotNotify) { + DD_BOT_TOKEN = process.env.DD_BOT_TOKEN6; + if (process.env.DD_BOT_SECRET6) { + DD_BOT_SECRET = process.env.DD_BOT_SECRET6; + } + } + + if (process.env.QYWX_KEY6 && Use_qywxBotNotify) { + QYWX_KEY = process.env.QYWX_KEY6; + } + + if (process.env.QYWX_AM6 && Use_qywxamNotify) { + QYWX_AM = process.env.QYWX_AM6; + } + + if (process.env.IGOT_PUSH_KEY6 && Use_iGotNotify) { + IGOT_PUSH_KEY = process.env.IGOT_PUSH_KEY6; + } + + if (process.env.PUSH_PLUS_TOKEN6 && Use_pushPlusNotify) { + PUSH_PLUS_TOKEN = process.env.PUSH_PLUS_TOKEN6; + } + if (process.env.PUSH_PLUS_USER6 && Use_pushPlusNotify) { + PUSH_PLUS_USER = process.env.PUSH_PLUS_USER6; + } + + if (process.env.PUSH_PLUS_TOKEN_hxtrip6 && Use_pushPlushxtripNotify) { + PUSH_PLUS_TOKEN_hxtrip = process.env.PUSH_PLUS_TOKEN_hxtrip6; + } + if (process.env.PUSH_PLUS_USER_hxtrip6 && Use_pushPlushxtripNotify) { + PUSH_PLUS_USER_hxtrip = process.env.PUSH_PLUS_USER_hxtrip6; + } + if (process.env.GOTIFY_URL6) { + GOTIFY_URL = process.env.GOTIFY_URL6; + } + if (process.env.GOTIFY_TOKEN6) { + GOTIFY_TOKEN = process.env.GOTIFY_TOKEN6; + } + if (process.env.GOTIFY_PRIORITY6) { + GOTIFY_PRIORITY = process.env.GOTIFY_PRIORITY6; + } + break; + + case 7: + //==========================第七套环境变量赋值========================= + + if (process.env.GOBOT_URL7 && Use_gobotNotify) { + GOBOT_URL = process.env.GOBOT_URL7; + } + if (process.env.GOBOT_TOKEN7 && Use_gobotNotify) { + GOBOT_TOKEN = process.env.GOBOT_TOKEN7; + } + if (process.env.GOBOT_QQ7 && Use_gobotNotify) { + GOBOT_QQ = process.env.GOBOT_QQ7; + } + + if (process.env.PUSH_KEY7 && Use_serverNotify) { + SCKEY = process.env.PUSH_KEY7; + } + + if (process.env.WP_APP_TOKEN7 && Use_WxPusher) { + WP_APP_TOKEN = process.env.WP_APP_TOKEN7; + } + + if (process.env.WP_TOPICIDS7 && Use_WxPusher) { + WP_TOPICIDS = process.env.WP_TOPICIDS7; + } + + if (process.env.WP_UIDS7 && Use_WxPusher) { + WP_UIDS = process.env.WP_UIDS7; + } + + if (process.env.WP_URL7 && Use_WxPusher) { + WP_URL = process.env.WP_URL7; + } + if (process.env.BARK_PUSH7 && Use_BarkNotify) { + if (process.env.BARK_PUSH7.indexOf('https') > -1 || process.env.BARK_PUSH7.indexOf('http') > -1) { + //兼容BARK自建用户 + BARK_PUSH = process.env.BARK_PUSH7; + } else { + BARK_PUSH = `https://api.day.app/${process.env.BARK_PUSH7}`; + } + if (process.env.BARK_SOUND7) { + BARK_SOUND = process.env.BARK_SOUND7; + } + if (process.env.BARK_GROUP7) { + BARK_GROUP = process.env.BARK_GROUP7; + } + } + if (process.env.TG_BOT_TOKEN7 && Use_tgBotNotify) { + TG_BOT_TOKEN = process.env.TG_BOT_TOKEN7; + } + if (process.env.TG_USER_ID7 && Use_tgBotNotify) { + TG_USER_ID = process.env.TG_USER_ID7; + } + if (process.env.TG_PROXY_AUTH7 && Use_tgBotNotify) + TG_PROXY_AUTH = process.env.TG_PROXY_AUTH7; + if (process.env.TG_PROXY_HOST7 && Use_tgBotNotify) + TG_PROXY_HOST = process.env.TG_PROXY_HOST7; + if (process.env.TG_PROXY_PORT7 && Use_tgBotNotify) + TG_PROXY_PORT = process.env.TG_PROXY_PORT7; + if (process.env.TG_API_HOST7 && Use_tgBotNotify) + TG_API_HOST = process.env.TG_API_HOST7; + + if (process.env.DD_BOT_TOKEN7 && Use_ddBotNotify) { + DD_BOT_TOKEN = process.env.DD_BOT_TOKEN7; + if (process.env.DD_BOT_SECRET7) { + DD_BOT_SECRET = process.env.DD_BOT_SECRET7; + } + } + + if (process.env.QYWX_KEY7 && Use_qywxBotNotify) { + QYWX_KEY = process.env.QYWX_KEY7; + } + + if (process.env.QYWX_AM7 && Use_qywxamNotify) { + QYWX_AM = process.env.QYWX_AM7; + } + + if (process.env.IGOT_PUSH_KEY7 && Use_iGotNotify) { + IGOT_PUSH_KEY = process.env.IGOT_PUSH_KEY7; + } + + if (process.env.PUSH_PLUS_TOKEN7 && Use_pushPlusNotify) { + PUSH_PLUS_TOKEN = process.env.PUSH_PLUS_TOKEN7; + } + if (process.env.PUSH_PLUS_USER7 && Use_pushPlusNotify) { + PUSH_PLUS_USER = process.env.PUSH_PLUS_USER7; + } + + if (process.env.PUSH_PLUS_TOKEN_hxtrip7 && Use_pushPlushxtripNotify) { + PUSH_PLUS_TOKEN_hxtrip = process.env.PUSH_PLUS_TOKEN_hxtrip7; + } + if (process.env.PUSH_PLUS_USER_hxtrip7 && Use_pushPlushxtripNotify) { + PUSH_PLUS_USER_hxtrip = process.env.PUSH_PLUS_USER_hxtrip7; + } + if (process.env.GOTIFY_URL7) { + GOTIFY_URL = process.env.GOTIFY_URL7; + } + if (process.env.GOTIFY_TOKEN7) { + GOTIFY_TOKEN = process.env.GOTIFY_TOKEN7; + } + if (process.env.GOTIFY_PRIORITY7) { + GOTIFY_PRIORITY = process.env.GOTIFY_PRIORITY7; + } + break; + } + + //检查是否在不使用Remark进行名称替换的名单 + const notifySkipRemarkList = process.env.NOTIFY_SKIP_NAMETYPELIST ? process.env.NOTIFY_SKIP_NAMETYPELIST.split('&') : []; + const titleIndex3 = notifySkipRemarkList.findIndex((item) => item === strTitle); + + if (text == "京东到家果园互助码:") { + ShowRemarkType = "1"; + if (desp) { + var arrTemp = desp.split(","); + var allCode = ""; + for (let k = 0; k < arrTemp.length; k++) { + if (arrTemp[k]) { + if (arrTemp[k].substring(0, 1) != "@") + allCode += arrTemp[k] + ","; + } + } + + if (allCode) { + desp += '\n' + '\n' + "格式化后的互助码:" + '\n' + allCode; + } + } + } + + if (ShowRemarkType != "1" && titleIndex3 == -1) { + console.log("sendNotify正在处理账号Remark....."); + //开始读取青龙变量列表 + const envs = await getEnvs(); + if (envs[0]) { + var strTempdesp = []; + var strAllNotify = ""; + if (text == "京东资产变动" || text == "京东资产变动#2" || text == "京东资产变动#3" || text == "京东资产变动#4") { + strTempdesp = desp.split('🎏🎏🎏🎏🎏🎏🎏🎏🎏🎏🎏🎏🎏'); + if (strTempdesp.length == 2) { + strAllNotify = strTempdesp[0]; + desp = strTempdesp[1]; + } + + } + + for (let i = 0; i < envs.length; i++) { + cookie = envs[i].value; + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]); + $.Remark = getRemark(envs[i].remarks); + $.nickName = ""; + $.FoundnickName = ""; + $.FoundPin = ""; + //判断有没有Remark,没有搞个屁,有的继续 + if ($.Remark) { + //先查找缓存文件中有没有这个账号,有的话直接读取别名 + if (envs[i].status == 0) { + if (TempCK) { + for (let j = 0; j < TempCK.length; j++) { + if (TempCK[j].pt_pin == $.UserName) { + $.FoundPin = TempCK[j].pt_pin; + $.nickName = TempCK[j].nickName; + } + } + } + if (!$.FoundPin) { + //缓存文件中有没有这个账号,调用京东接口获取别名,并更新缓存文件 + console.log($.UserName + "好像是新账号,尝试获取别名....."); + await GetnickName(); + if (!$.nickName) { + console.log("别名获取失败,尝试调用另一个接口获取别名....."); + await GetnickName2(); + } + if ($.nickName) { + console.log("好像是新账号,从接口获取别名" + $.nickName); + } else { + console.log($.UserName + "该账号没有别名....."); + } + tempAddCK = { + "pt_pin": $.UserName, + "nickName": $.nickName + }; + TempCK.push(tempAddCK); + //标识,需要更新缓存文件 + boolneedUpdate = true; + } + } + + $.nickName = $.nickName || $.UserName; + + //开始替换内容中的名字 + if (ShowRemarkType == "2") { + $.Remark = $.nickName + "(" + $.Remark + ")"; + } + if (ShowRemarkType == "3") { + $.Remark = $.UserName + "(" + $.Remark + ")"; + } + + try { + //额外处理1,nickName包含星号 + $.nickName = $.nickName.replace(new RegExp(`[*]`, 'gm'), "[*]"); + + text = text.replace(new RegExp(`${$.UserName}|${$.nickName}`, 'gm'), $.Remark); + + if (text == "京东资产变动" || text == "京东资产变动#2" || text == "京东资产变动#3" || text == "京东资产变动#4") { + var Tempinfo = getQLinfo(cookie, envs[i].created, envs[i].timestamp, envs[i].remarks); + if (Tempinfo) { + $.Remark += Tempinfo; + } + } + desp = desp.replace(new RegExp(`${$.UserName}|${$.nickName}`, 'gm'), $.Remark); + strsummary = strsummary.replace(new RegExp(`${$.UserName}|${$.nickName}`, 'gm'), $.Remark); + //额外处理2,nickName不包含星号,但是确实是手机号 + var tempname = $.UserName; + if (tempname.length == 13 && tempname.substring(8)) { + tempname = tempname.substring(0, 3) + "[*][*][*][*][*]" + tempname.substring(8); + //console.log("额外处理2:"+tempname); + text = text.replace(new RegExp(tempname, 'gm'), $.Remark); + desp = desp.replace(new RegExp(tempname, 'gm'), $.Remark); + strsummary = strsummary.replace(new RegExp(tempname, 'gm'), $.Remark); + } + + } catch (err) { + console.log("替换出错了"); + console.log("Debug Name1 :" + $.UserName); + console.log("Debug Name2 :" + $.nickName); + console.log("Debug Remark :" + $.Remark); + } + + //console.log($.nickName+$.Remark); + + } + + } + + } + console.log("处理完成,开始发送通知..."); + if (strAllNotify) { + desp = strAllNotify + "\n" + desp; + } + } + } catch (error) { + console.error(error); + } + + if (boolneedUpdate) { + var str = JSON.stringify(TempCK, null, 2); + fs.writeFile(strCKFile, str, function (err) { + if (err) { + console.log(err); + console.log("更新CKName_cache.json失败!"); + } else { + console.log("缓存文件CKName_cache.json更新成功!"); + } + }) + } + + //提供6种通知 + desp = buildLastDesp(desp, author) + + await serverNotify(text, desp); //微信server酱 + + if (PUSH_PLUS_TOKEN_hxtrip) { + console.log("hxtrip TOKEN :" + PUSH_PLUS_TOKEN_hxtrip); + } + if (PUSH_PLUS_USER_hxtrip) { + console.log("hxtrip USER :" + PUSH_PLUS_USER_hxtrip); + } + PushErrorTime = 0; + await pushPlusNotifyhxtrip(text, desp); //pushplushxtrip(推送加) + if (PushErrorTime > 0) { + console.log("等待1分钟后重试....."); + await $.wait(60000); + await pushPlusNotifyhxtrip(text, desp); + } + + if (PUSH_PLUS_TOKEN) { + console.log("PUSH_PLUS TOKEN :" + PUSH_PLUS_TOKEN); + } + if (PUSH_PLUS_USER) { + console.log("PUSH_PLUS USER :" + PUSH_PLUS_USER); + } + PushErrorTime = 0; + await pushPlusNotify(text, desp); //pushplus(推送加) + if (PushErrorTime > 0) { + console.log("等待1分钟后重试....."); + await $.wait(60000); + await pushPlusNotify(text, desp); //pushplus(推送加) + } + if (PushErrorTime > 0) { + console.log("等待1分钟后重试....."); + await $.wait(60000); + await pushPlusNotify(text, desp); //pushplus(推送加) + + } + + //由于上述两种微信通知需点击进去才能查看到详情,故text(标题内容)携带了账号序号以及昵称信息,方便不点击也可知道是哪个京东哪个活动 + text = text.match(/.*?(?=\s?-)/g) ? text.match(/.*?(?=\s?-)/g)[0] : text; + await Promise.all([ + BarkNotify(text, desp, params), //iOS Bark APP + tgBotNotify(text, desp), //telegram 机器人 + ddBotNotify(text, desp), //钉钉机器人 + qywxBotNotify(text, desp), //企业微信机器人 + qywxamNotify(text, desp, strsummary), //企业微信应用消息推送 + iGotNotify(text, desp, params), //iGot + gobotNotify(text, desp), //go-cqhttp + gotifyNotify(text, desp), //gotify + wxpusherNotify(text, desp) // wxpusher + ]); +} + +function getuuid(strRemark, PtPin) { + var strTempuuid = ""; + if (strRemark) { + var Tempindex = strRemark.indexOf("@@"); + if (Tempindex != -1) { + console.log(PtPin + ": 检测到NVJDC的一对一格式,瑞思拜~!"); + var TempRemarkList = strRemark.split("@@"); + for (let j = 1; j < TempRemarkList.length; j++) { + if (TempRemarkList[j]) { + if (TempRemarkList[j].length > 4) { + if (TempRemarkList[j].substring(0, 4) == "UID_") { + strTempuuid = TempRemarkList[j]; + break; + } + } + } + } + if (!strTempuuid) { + console.log("检索资料失败..."); + } + } + } + if (!strTempuuid && TempCKUid) { + console.log("正在从CK_WxPusherUid文件中检索资料..."); + for (let j = 0; j < TempCKUid.length; j++) { + if (PtPin == decodeURIComponent(TempCKUid[j].pt_pin)) { + strTempuuid = TempCKUid[j].Uid; + break; + } + } + } + return strTempuuid; +} + +function getQLinfo(strCK, intcreated, strTimestamp, strRemark) { + var strCheckCK = strCK.match(/pt_key=([^; ]+)(?=;?)/) && strCK.match(/pt_key=([^; ]+)(?=;?)/)[1]; + var strPtPin = decodeURIComponent(strCK.match(/pt_pin=([^; ]+)(?=;?)/) && strCK.match(/pt_pin=([^; ]+)(?=;?)/)[1]); + var strReturn = ""; + if (strCheckCK.substring(0, 4) == "AAJh") { + var DateCreated = new Date(intcreated); + var DateTimestamp = new Date(strTimestamp); + var DateToday = new Date(); + if (strRemark) { + var Tempindex = strRemark.indexOf("@@"); + if (Tempindex != -1) { + //console.log(strPtPin + ": 检测到NVJDC的备注格式,尝试获取登录时间,瑞思拜~!"); + var TempRemarkList = strRemark.split("@@"); + for (let j = 1; j < TempRemarkList.length; j++) { + if (TempRemarkList[j]) { + if (TempRemarkList[j].length == 13) { + DateTimestamp = new Date(parseInt(TempRemarkList[j])); + //console.log(strPtPin + ": 获取登录时间成功:" + GetDateTime(DateTimestamp)); + break; + } + } + } + } + } + + //过期时间 + var UseDay = Math.ceil((DateToday.getTime() - DateCreated.getTime()) / 86400000); + var LogoutDay = 30 - Math.ceil((DateToday.getTime() - DateTimestamp.getTime()) / 86400000); + if (LogoutDay < 1) { + strReturn = "\n【登录信息】总挂机" + UseDay + "天(账号即将到期,请重登续期)" + } else { + strReturn = "\n【登录信息】总挂机" + UseDay + "天(有效期约剩" + LogoutDay + "天)" + } + + } + + return strReturn +} + +function getRemark(strRemark) { + if (strRemark) { + var Tempindex = strRemark.indexOf("@@"); + if (Tempindex != -1) { + var TempRemarkList = strRemark.split("@@"); + return TempRemarkList[0].trim(); + } else { + //这是为了处理ninjia的remark格式 + strRemark = strRemark.replace("remark=", ""); + strRemark = strRemark.replace(";", ""); + return strRemark.trim(); + } + } else { + return ""; + } +} + +async function sendNotifybyWxPucher(text, desp, PtPin, author = '\n\n本通知 By ccwav Mod', strsummary = "") { + + try { + var Uid = ""; + var UserRemark = ""; + var strTempdesp = []; + var strAllNotify = ""; + if (text == "京东资产变动") { + strTempdesp = desp.split('🎏🎏🎏🎏🎏🎏🎏🎏🎏🎏🎏🎏🎏'); + if (strTempdesp.length == 2) { + strAllNotify = strTempdesp[0]; + desp = strTempdesp[1]; + } + + } + + if (WP_APP_TOKEN_ONE) { + var tempEnv = await getEnvByPtPin(PtPin); + if (tempEnv) { + cookie = tempEnv.value; + Uid = getuuid(tempEnv.remarks, PtPin); + UserRemark = getRemark(tempEnv.remarks); + + if (Uid) { + console.log("查询到Uid :" + Uid); + WP_UIDS_ONE = Uid; + console.log("正在发送一对一通知,请稍后..."); + + if (text == "京东资产变动") { + try { + $.nickName = ""; + $.FoundPin = ""; + $.UserName = PtPin; + if (tempEnv.status == 0) { + if (TempCK) { + for (let j = 0; j < TempCK.length; j++) { + if (TempCK[j].pt_pin == $.UserName) { + $.FoundPin = TempCK[j].pt_pin; + $.nickName = TempCK[j].nickName; + } + } + } + if (!$.FoundPin) { + //缓存文件中有没有这个账号,调用京东接口获取别名,并更新缓存文件 + console.log($.UserName + "好像是新账号,尝试获取别名....."); + await GetnickName(); + if (!$.nickName) { + console.log("别名获取失败,尝试调用另一个接口获取别名....."); + await GetnickName2(); + } + } + } + + $.nickName = $.nickName || $.UserName; + + //额外处理1,nickName包含星号 + $.nickName = $.nickName.replace(new RegExp(`[*]`, 'gm'), "[*]"); + + var Tempinfo = getQLinfo(cookie, tempEnv.created, tempEnv.timestamp, tempEnv.remarks); + if (Tempinfo) { + Tempinfo = $.nickName + Tempinfo; + desp = desp.replace(new RegExp(`${$.UserName}|${$.nickName}`, 'gm'), Tempinfo); + } + + //额外处理2,nickName不包含星号,但是确实是手机号 + var tempname = $.UserName; + if (tempname.length == 13 && tempname.substring(8)) { + tempname = tempname.substring(0, 3) + "[*][*][*][*][*]" + tempname.substring(8); + desp = desp.replace(new RegExp(tempname, 'gm'), $.Remark); + } + + } catch (err) { + console.log("替换出错了"); + console.log("Debug Name1 :" + $.UserName); + console.log("Debug Name2 :" + $.nickName); + console.log("Debug Remark :" + $.Remark); + } + } + if (UserRemark) { + text = text + " (" + UserRemark + ")"; + } + console.log("处理完成,开始发送通知..."); + desp = buildLastDesp(desp, author); + if (strAllNotify) { + desp = strAllNotify + "\n" + desp; + } + await wxpusherNotifyByOne(text, desp, strsummary); + } else { + console.log("未查询到用户的Uid,取消一对一通知发送..."); + } + } + } else { + console.log("变量WP_APP_TOKEN_ONE未配置WxPusher的appToken, 取消发送..."); + + } + } catch (error) { + console.error(error); + } + +} + +async function GetPtPin(text) { + try { + const TempList = text.split('- '); + if (TempList.length > 1) { + var strNickName = TempList[TempList.length - 1]; + var strPtPin = ""; + console.log(`捕获别名:` + strNickName); + if (TempCK) { + for (let j = 0; j < TempCK.length; j++) { + if (TempCK[j].nickName == strNickName) { + strPtPin = TempCK[j].pt_pin; + break; + } + if (TempCK[j].pt_pin == strNickName) { + strPtPin = TempCK[j].pt_pin; + break; + } + } + if (strPtPin) { + console.log(`反查PtPin成功:` + strPtPin); + return strPtPin; + } else { + console.log(`别名反查PtPin失败: 1.用户更改了别名 2.可能是新用户,别名缓存还没有。`); + return ""; + } + } + } else { + console.log(`标题格式无法捕获别名...`); + return ""; + } + } catch (error) { + console.error(error); + return ""; + } + +} + +async function isLoginByX1a0He(cookie) { + return new Promise((resolve) => { + const options = { + url: 'https://plogin.m.jd.com/cgi-bin/ml/islogin', + headers: { + "Cookie": cookie, + "referer": "https://h5.m.jd.com/", + "User-Agent": "jdapp;iPhone;10.1.2;15.0;network/wifi;Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1", + }, + } + $.get(options, (err, resp, data) => { + try { + if (data) { + data = JSON.parse(data); + if (data.islogin === "1") { + console.log(`使用X1a0He写的接口加强检测: Cookie有效\n`) + } else if (data.islogin === "0") { + isLogin = false; + console.log(`使用X1a0He写的接口加强检测: Cookie无效\n`) + } else { + console.log(`使用X1a0He写的接口加强检测: 未知返回,不作变更...\n`) + } + } + } catch (e) { + console.log(e); + } + finally { + resolve(); + } + }); + }); +} + +function gotifyNotify(text, desp) { + return new Promise((resolve) => { + if (GOTIFY_URL && GOTIFY_TOKEN) { + const options = { + url: `${GOTIFY_URL}/message?token=${GOTIFY_TOKEN}`, + body: `title=${encodeURIComponent(text)}&message=${encodeURIComponent(desp)}&priority=${GOTIFY_PRIORITY}`, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + } + }; + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log('gotify发送通知调用API失败!!\n'); + console.log(err); + } else { + data = JSON.parse(data); + if (data.id) { + console.log('gotify发送通知消息成功🎉\n'); + } else { + console.log(`${data.message}\n`); + } + } + } catch (e) { + $.logErr(e, resp); + } + finally { + resolve(); + } + }); + } else { + resolve(); + } + }); +} + +function gobotNotify(text, desp, time = 2100) { + return new Promise((resolve) => { + if (GOBOT_URL) { + const options = { + url: `${GOBOT_URL}?access_token=${GOBOT_TOKEN}&${GOBOT_QQ}`, + json: { + message: `${text}\n${desp}` + }, + headers: { + 'Content-Type': 'application/json', + }, + timeout, + }; + setTimeout(() => { + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log('发送go-cqhttp通知调用API失败!!\n'); + console.log(err); + } else { + data = JSON.parse(data); + if (data.retcode === 0) { + console.log('go-cqhttp发送通知消息成功🎉\n'); + } else if (data.retcode === 100) { + console.log(`go-cqhttp发送通知消息异常: ${data.errmsg}\n`); + } else { + console.log(`go-cqhttp发送通知消息异常\n${JSON.stringify(data)}`); + } + } + } catch (e) { + $.logErr(e, resp); + } + finally { + resolve(data); + } + }); + }, time); + } else { + resolve(); + } + }); +} + +function serverNotify(text, desp, time = 2100) { + return new Promise((resolve) => { + if (SCKEY) { + //微信server酱推送通知一个\n不会换行,需要两个\n才能换行,故做此替换 + desp = desp.replace(/[\n\r]/g, '\n\n'); + const options = { + url: SCKEY.includes('SCT') ? `https://sctapi.ftqq.com/${SCKEY}.send` : `https://sc.ftqq.com/${SCKEY}.send`, + body: `text=${text}&desp=${desp}`, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + }, + timeout, + }; + setTimeout(() => { + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log('发送通知调用API失败!!\n'); + console.log(err); + } else { + data = JSON.parse(data); + //server酱和Server酱·Turbo版的返回json格式不太一样 + if (data.errno === 0 || data.data.errno === 0) { + console.log('server酱发送通知消息成功🎉\n'); + } else if (data.errno === 1024) { + // 一分钟内发送相同的内容会触发 + console.log(`server酱发送通知消息异常: ${data.errmsg}\n`); + } else { + console.log(`server酱发送通知消息异常\n${JSON.stringify(data)}`); + } + } + } catch (e) { + $.logErr(e, resp); + } + finally { + resolve(data); + } + }); + }, time); + } else { + resolve(); + } + }); +} + +function BarkNotify(text, desp, params = {}) { + return new Promise((resolve) => { + if (BARK_PUSH) { + const options = { + url: `${BARK_PUSH}/${encodeURIComponent(text)}/${encodeURIComponent( + desp + )}?sound=${BARK_SOUND}&group=${BARK_GROUP}&${querystring.stringify(params)}`, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + }, + timeout, + }; + $.get(options, (err, resp, data) => { + try { + if (err) { + console.log('Bark APP发送通知调用API失败!!\n'); + console.log(err); + } else { + data = JSON.parse(data); + if (data.code === 200) { + console.log('Bark APP发送通知消息成功🎉\n'); + } else { + console.log(`${data.message}\n`); + } + } + } catch (e) { + $.logErr(e, resp); + } + finally { + resolve(); + } + }); + } else { + resolve(); + } + }); +} + +function tgBotNotify(text, desp) { + return new Promise((resolve) => { + if (TG_BOT_TOKEN && TG_USER_ID) { + const options = { + url: `https://${TG_API_HOST}/bot${TG_BOT_TOKEN}/sendMessage`, + body: `chat_id=${TG_USER_ID}&text=${text}\n\n${desp}&disable_web_page_preview=true`, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + }, + timeout, + }; + if (TG_PROXY_HOST && TG_PROXY_PORT) { + const tunnel = require('tunnel'); + const agent = { + https: tunnel.httpsOverHttp({ + proxy: { + host: TG_PROXY_HOST, + port: TG_PROXY_PORT * 1, + proxyAuth: TG_PROXY_AUTH, + }, + }), + }; + Object.assign(options, { + agent + }); + } + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log('telegram发送通知消息失败!!\n'); + console.log(err); + } else { + data = JSON.parse(data); + if (data.ok) { + console.log('Telegram发送通知消息成功🎉。\n'); + } else if (data.error_code === 400) { + console.log('请主动给bot发送一条消息并检查接收用户ID是否正确。\n'); + } else if (data.error_code === 401) { + console.log('Telegram bot token 填写错误。\n'); + } + } + } catch (e) { + $.logErr(e, resp); + } + finally { + resolve(data); + } + }); + } else { + resolve(); + } + }); +} + +function ddBotNotify(text, desp) { + return new Promise((resolve) => { + const options = { + url: `https://oapi.dingtalk.com/robot/send?access_token=${DD_BOT_TOKEN}`, + json: { + msgtype: 'text', + text: { + content: ` ${text}\n\n${desp}`, + }, + }, + headers: { + 'Content-Type': 'application/json', + }, + timeout, + }; + if (DD_BOT_TOKEN && DD_BOT_SECRET) { + const crypto = require('crypto'); + const dateNow = Date.now(); + const hmac = crypto.createHmac('sha256', DD_BOT_SECRET); + hmac.update(`${dateNow}\n${DD_BOT_SECRET}`); + const result = encodeURIComponent(hmac.digest('base64')); + options.url = `${options.url}×tamp=${dateNow}&sign=${result}`; + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log('钉钉发送通知消息失败!!\n'); + console.log(err); + } else { + data = JSON.parse(data); + if (data.errcode === 0) { + console.log('钉钉发送通知消息成功🎉。\n'); + } else { + console.log(`${data.errmsg}\n`); + } + } + } catch (e) { + $.logErr(e, resp); + } + finally { + resolve(data); + } + }); + } else if (DD_BOT_TOKEN) { + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log('钉钉发送通知消息失败!!\n'); + console.log(err); + } else { + data = JSON.parse(data); + if (data.errcode === 0) { + console.log('钉钉发送通知消息完成。\n'); + } else { + console.log(`${data.errmsg}\n`); + } + } + } catch (e) { + $.logErr(e, resp); + } + finally { + resolve(data); + } + }); + } else { + resolve(); + } + }); +} + +function qywxBotNotify(text, desp) { + return new Promise((resolve) => { + const options = { + url: `https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=${QYWX_KEY}`, + json: { + msgtype: 'text', + text: { + content: ` ${text}\n\n${desp}`, + }, + }, + headers: { + 'Content-Type': 'application/json', + }, + timeout, + }; + if (QYWX_KEY) { + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log('企业微信发送通知消息失败!!\n'); + console.log(err); + } else { + data = JSON.parse(data); + if (data.errcode === 0) { + console.log('企业微信发送通知消息成功🎉。\n'); + } else { + console.log(`${data.errmsg}\n`); + } + } + } catch (e) { + $.logErr(e, resp); + } + finally { + resolve(data); + } + }); + } else { + resolve(); + } + }); +} + +function buildLastDesp(desp, author = '') { + author = process.env.NOTIFY_AUTHOR || author; + if (process.env.NOTIFY_AUTHOR_BLANK || !author) { + return desp.trim(); + } else { + if (!author.match(/本通知 By/)) { + author = `\n\n本通知 By ${author}` + } + return desp.trim() + author + "\n通知时间: " + GetDateTime(new Date()); + } +} + +function ChangeUserId(desp) { + const QYWX_AM_AY = QYWX_AM.split(','); + if (QYWX_AM_AY[2]) { + const userIdTmp = QYWX_AM_AY[2].split('|'); + let userId = ''; + for (let i = 0; i < userIdTmp.length; i++) { + const count = '账号' + (i + 1); + const count2 = '签到号 ' + (i + 1); + if (desp.match(count2)) { + userId = userIdTmp[i]; + } + } + if (!userId) + userId = QYWX_AM_AY[2]; + return userId; + } else { + return '@all'; + } +} + +function qywxamNotify(text, desp, strsummary = "") { + return new Promise((resolve) => { + if (QYWX_AM) { + const QYWX_AM_AY = QYWX_AM.split(','); + const options_accesstoken = { + url: `https://qyapi.weixin.qq.com/cgi-bin/gettoken`, + json: { + corpid: `${QYWX_AM_AY[0]}`, + corpsecret: `${QYWX_AM_AY[1]}`, + }, + headers: { + 'Content-Type': 'application/json', + }, + timeout, + }; + $.post(options_accesstoken, (err, resp, data) => { + html = desp.replace(/\n/g, '
'); + html = `${html}`; + if (strsummary == "") { + strsummary = desp; + } + var json = JSON.parse(data); + accesstoken = json.access_token; + let options; + + switch (QYWX_AM_AY[4]) { + case '0': + options = { + msgtype: 'textcard', + textcard: { + title: `${text}`, + description: `${strsummary}`, + url: 'https://github.com/whyour/qinglong', + btntxt: '更多', + }, + }; + break; + + case '1': + options = { + msgtype: 'text', + text: { + content: `${text}\n\n${desp}`, + }, + }; + break; + + default: + options = { + msgtype: 'mpnews', + mpnews: { + articles: [{ + title: `${text}`, + thumb_media_id: `${QYWX_AM_AY[4]}`, + author: `智能助手`, + content_source_url: ``, + content: `${html}`, + digest: `${strsummary}`, + },], + }, + }; + } + if (!QYWX_AM_AY[4]) { + //如不提供第四个参数,则默认进行文本消息类型推送 + options = { + msgtype: 'text', + text: { + content: `${text}\n\n${desp}`, + }, + }; + } + options = { + url: `https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=${accesstoken}`, + json: { + touser: `${ChangeUserId(desp)}`, + agentid: `${QYWX_AM_AY[3]}`, + safe: '0', + ...options, + }, + headers: { + 'Content-Type': 'application/json', + }, + }; + + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log('成员ID:' + ChangeUserId(desp) + '企业微信应用消息发送通知消息失败!!\n'); + console.log(err); + } else { + data = JSON.parse(data); + if (data.errcode === 0) { + console.log('成员ID:' + ChangeUserId(desp) + '企业微信应用消息发送通知消息成功🎉。\n'); + } else { + console.log(`${data.errmsg}\n`); + } + } + } catch (e) { + $.logErr(e, resp); + } + finally { + resolve(data); + } + }); + }); + } else { + resolve(); + } + }); +} + +function iGotNotify(text, desp, params = {}) { + return new Promise((resolve) => { + if (IGOT_PUSH_KEY) { + // 校验传入的IGOT_PUSH_KEY是否有效 + const IGOT_PUSH_KEY_REGX = new RegExp('^[a-zA-Z0-9]{24}$'); + if (!IGOT_PUSH_KEY_REGX.test(IGOT_PUSH_KEY)) { + console.log('您所提供的IGOT_PUSH_KEY无效\n'); + resolve(); + return; + } + const options = { + url: `https://push.hellyw.com/${IGOT_PUSH_KEY.toLowerCase()}`, + body: `title=${text}&content=${desp}&${querystring.stringify(params)}`, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + }, + timeout, + }; + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log('发送通知调用API失败!!\n'); + console.log(err); + } else { + if (typeof data === 'string') + data = JSON.parse(data); + if (data.ret === 0) { + console.log('iGot发送通知消息成功🎉\n'); + } else { + console.log(`iGot发送通知消息失败:${data.errMsg}\n`); + } + } + } catch (e) { + $.logErr(e, resp); + } + finally { + resolve(data); + } + }); + } else { + resolve(); + } + }); +} +function pushPlusNotifyhxtrip(text, desp) { + return new Promise((resolve) => { + if (PUSH_PLUS_TOKEN_hxtrip) { + //desp = `${desp}`; + + desp = desp.replace(/[\n\r]/g, '
'); // 默认为html, 不支持plaintext + const body = { + token: `${PUSH_PLUS_TOKEN_hxtrip}`, + title: `${text}`, + content: `${desp}`, + topic: `${PUSH_PLUS_USER_hxtrip}`, + }; + const options = { + url: `http://pushplus.hxtrip.com/send`, + body: JSON.stringify(body), + headers: { + 'Content-Type': ' application/json', + }, + timeout, + }; + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log(`hxtrip push+发送${PUSH_PLUS_USER_hxtrip ? '一对多' : '一对一'}通知消息失败!!\n`); + PushErrorTime += 1; + console.log(err); + } else { + if (data.indexOf("200") > -1) { + console.log(`hxtrip push+发送${PUSH_PLUS_USER_hxtrip ? '一对多' : '一对一'}通知消息完成。\n`); + PushErrorTime = 0; + } else { + console.log(`hxtrip push+发送${PUSH_PLUS_USER_hxtrip ? '一对多' : '一对一'}通知消息失败:${data}\n`); + PushErrorTime += 1; + } + } + } catch (e) { + $.logErr(e, resp); + } + finally { + resolve(data); + } + }); + } else { + resolve(); + } + }); +} + +function pushPlusNotify(text, desp) { + return new Promise((resolve) => { + if (PUSH_PLUS_TOKEN) { + + //desp = `${desp}`; + + desp = desp.replace(/[\n\r]/g, '
'); // 默认为html, 不支持plaintext + const body = { + token: `${PUSH_PLUS_TOKEN}`, + title: `${text}`, + content: `${desp}`, + topic: `${PUSH_PLUS_USER}`, + }; + const options = { + url: `https://www.pushplus.plus/send`, + body: JSON.stringify(body), + headers: { + 'Content-Type': ' application/json', + }, + timeout, + }; + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log(`push+发送${PUSH_PLUS_USER ? '一对多' : '一对一'}通知消息失败!!\n`); + PushErrorTime += 1; + console.log(err); + } else { + data = JSON.parse(data); + if (data.code === 200) { + console.log(`push+发送${PUSH_PLUS_USER ? '一对多' : '一对一'}通知消息完成。\n`); + PushErrorTime = 0; + } else { + console.log(`push+发送${PUSH_PLUS_USER ? '一对多' : '一对一'}通知消息失败:${data.msg}\n`); + PushErrorTime += 1; + } + } + } catch (e) { + $.logErr(e, resp); + } + finally { + resolve(data); + } + }); + } else { + resolve(); + } + }); +} +function wxpusherNotifyByOne(text, desp, strsummary = "") { + return new Promise((resolve) => { + if (WP_APP_TOKEN_ONE) { + var WPURL = ""; + if (strsummary) { + strsummary = text + "\n" + strsummary; + } else { + strsummary = text + "\n" + desp; + } + + if (strsummary.length > 96) { + strsummary = strsummary.substring(0, 95) + "..."; + } + let uids = []; + for (let i of WP_UIDS_ONE.split(";")) { + if (i.length != 0) + uids.push(i); + }; + let topicIds = []; + + //desp = `${desp}`; + desp = desp.replace(/[\n\r]/g, '
'); // 默认为html, 不支持plaintext + desp = `
+
+
+

+ ${text} +

+
+
+
+
+

+ 📢 +

+
+
+
+
+
+

+ ${desp} +

+
+
+
`; + + const body = { + appToken: `${WP_APP_TOKEN_ONE}`, + content: `${desp}`, + summary: `${strsummary}`, + contentType: 2, + topicIds: topicIds, + uids: uids, + url: `${WPURL}`, + }; + const options = { + url: `http://wxpusher.zjiecode.com/api/send/message`, + body: JSON.stringify(body), + headers: { + "Content-Type": "application/json", + }, + timeout, + }; + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log("WxPusher 发送通知调用 API 失败!!\n"); + console.log(err); + } else { + data = JSON.parse(data); + if (data.code === 1000) { + console.log("WxPusher 发送通知消息成功!\n"); + } + } + } catch (e) { + $.logErr(e, resp); + } + finally { + resolve(data); + } + }); + } else { + resolve(); + } + }); +} + +function wxpusherNotify(text, desp) { + return new Promise((resolve) => { + if (WP_APP_TOKEN) { + let uids = []; + for (let i of WP_UIDS.split(";")) { + if (i.length != 0) + uids.push(i); + }; + let topicIds = []; + for (let i of WP_TOPICIDS.split(";")) { + if (i.length != 0) + topicIds.push(i); + }; + desp = `${text}\n\n${desp}`; + desp = desp.replace(/[\n\r]/g, '
'); // 默认为html, 不支持plaintext + const body = { + appToken: `${WP_APP_TOKEN}`, + content: `${text}\n\n${desp}`, + summary: `${text}`, + contentType: 2, + topicIds: topicIds, + uids: uids, + url: `${WP_URL}`, + }; + const options = { + url: `http://wxpusher.zjiecode.com/api/send/message`, + body: JSON.stringify(body), + headers: { + "Content-Type": "application/json", + }, + timeout, + }; + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log("WxPusher 发送通知调用 API 失败!!\n"); + console.log(err); + } else { + data = JSON.parse(data); + if (data.code === 1000) { + console.log("WxPusher 发送通知消息成功!\n"); + } + } + } catch (e) { + $.logErr(e, resp); + } + finally { + resolve(data); + } + }); + } else { + resolve(); + } + }); +} + +function GetDateTime(date) { + + var timeString = ""; + + var timeString = date.getFullYear() + "-"; + if ((date.getMonth() + 1) < 10) + timeString += "0" + (date.getMonth() + 1) + "-"; + else + timeString += (date.getMonth() + 1) + "-"; + + if ((date.getDate()) < 10) + timeString += "0" + date.getDate() + " "; + else + timeString += date.getDate() + " "; + + if ((date.getHours()) < 10) + timeString += "0" + date.getHours() + ":"; + else + timeString += date.getHours() + ":"; + + if ((date.getMinutes()) < 10) + timeString += "0" + date.getMinutes() + ":"; + else + timeString += date.getMinutes() + ":"; + + if ((date.getSeconds()) < 10) + timeString += "0" + date.getSeconds(); + else + timeString += date.getSeconds(); + + return timeString; +} + +function GetnickName() { + return new Promise(async resolve => { + 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": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), + "Accept-Language": "zh-cn", + "Referer": "https://home.m.jd.com/myJd/newhome.action?sceneval=2&ufc=&", + "Accept-Encoding": "gzip, deflate, br" + } + } + $.get(options, (err, resp, data) => { + try { + if (err) { + $.logErr(err) + } else { + if (data) { + data = JSON.parse(data); + if (data['retcode'] === "1001") { + return; + } + if (data['retcode'] === "0" && data.data && data.data.hasOwnProperty("userInfo")) { + $.nickName = data.data.userInfo.baseInfo.nickname; + } + + } else { + $.log('京东服务器返回空数据'); + } + } + } catch (e) { + $.logErr(e) + } + finally { + resolve(); + } + }) + }) +} + +function GetnickName2() { + return new Promise(async (resolve) => { + const options = { + url: `https://wxapp.m.jd.com/kwxhome/myJd/home.json?&useGuideModule=0&bizId=&brandId=&fromType=wxapp×tamp=${Date.now()}`, + headers: { + Cookie: cookie, + 'content-type': `application/x-www-form-urlencoded`, + Connection: `keep-alive`, + 'Accept-Encoding': `gzip,compress,br,deflate`, + Referer: `https://servicewechat.com/wxa5bf5ee667d91626/161/page-frame.html`, + Host: `wxapp.m.jd.com`, + 'User-Agent': `Mozilla/5.0 (iPhone; CPU iPhone OS 15_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/8.0.10(0x18000a2a) NetType/WIFI Language/zh_CN`, + }, + }; + $.post(options, (err, resp, data) => { + try { + if (err) { + $.logErr(err); + } else { + if (data) { + data = JSON.parse(data); + if (!data.user) { + $.isLogin = false; //cookie过期 + return; + } + const userInfo = data.user; + if (userInfo) { + $.nickName = userInfo.petName; + } + } else { + $.log('京东服务器返回空数据'); + } + } + } catch (e) { + $.logErr(e); + } + finally { + resolve(); + } + }); + }); +} + +module.exports = { + sendNotify, + sendNotifybyWxPucher, + BARK_PUSH, +}; + +// prettier-ignore +function Env(t, s) { + return new (class { + constructor(t, s) { + (this.name = t), + (this.data = null), + (this.dataFile = 'box.dat'), + (this.logs = []), + (this.logSeparator = '\n'), + (this.startTime = new Date().getTime()), + Object.assign(this, s), + this.log('', `\ud83d\udd14${this.name}, \u5f00\u59cb!`); + } + isNode() { + return 'undefined' != typeof module && !!module.exports; + } + isQuanX() { + return 'undefined' != typeof $task; + } + isSurge() { + return 'undefined' != typeof $httpClient && 'undefined' == typeof $loon; + } + isLoon() { + return 'undefined' != typeof $loon; + } + getScript(t) { + return new Promise((s) => { + $.get({ + url: t + }, (t, e, i) => s(i)); + }); + } + runScript(t, s) { + return new Promise((e) => { + let i = this.getdata('@chavy_boxjs_userCfgs.httpapi'); + i = i ? i.replace(/\n/g, '').trim() : i; + let o = this.getdata('@chavy_boxjs_userCfgs.httpapi_timeout'); + (o = o ? 1 * o : 20), + (o = s && s.timeout ? s.timeout : o); + const [h, a] = i.split('@'), + r = { + url: `http://${a}/v1/scripting/evaluate`, + body: { + script_text: t, + mock_type: 'cron', + timeout: o + }, + headers: { + 'X-Key': h, + Accept: '*/*' + }, + }; + $.post(r, (t, s, i) => e(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), + s = this.path.resolve(process.cwd(), this.dataFile), + e = this.fs.existsSync(t), + i = !e && this.fs.existsSync(s); + if (!e && !i) + return {}; { + const i = e ? t : s; + 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), + s = this.path.resolve(process.cwd(), this.dataFile), + e = this.fs.existsSync(t), + i = !e && this.fs.existsSync(s), + o = JSON.stringify(this.data); + e ? this.fs.writeFileSync(t, o) : i ? this.fs.writeFileSync(s, o) : this.fs.writeFileSync(t, o); + } + } + lodash_get(t, s, e) { + const i = s.replace(/\[(\d+)\]/g, '.$1').split('.'); + let o = t; + for (const t of i) + if (((o = Object(o)[t]), void 0 === o)) + return e; + return o; + } + lodash_set(t, s, e) { + return Object(t) !== t ? t : (Array.isArray(s) || (s = s.toString().match(/[^.[\]]+/g) || []), (s.slice(0, -1).reduce((t, e, i) => (Object(t[e]) === t[e] ? t[e] : (t[e] = Math.abs(s[i + 1]) >> 0 == +s[i + 1] ? [] : {})), t)[s[s.length - 1]] = e), t); + } + getdata(t) { + let s = this.getval(t); + if (/^@/.test(t)) { + const [, e, i] = /^@(.*?)\.(.*?)$/.exec(t), + o = e ? this.getval(e) : ''; + if (o) + try { + const t = JSON.parse(o); + s = t ? this.lodash_get(t, i, '') : s; + } catch (t) { + s = ''; + } + } + return s; + } + setdata(t, s) { + let e = !1; + if (/^@/.test(s)) { + const [, i, o] = /^@(.*?)\.(.*?)$/.exec(s), + h = this.getval(i), + a = i ? ('null' === h ? null : h || '{}') : '{}'; + try { + const s = JSON.parse(a); + this.lodash_set(s, o, t), + (e = this.setval(JSON.stringify(s), i)); + } catch (s) { + const h = {}; + this.lodash_set(h, o, t), + (e = this.setval(JSON.stringify(h), i)); + } + } else + e = $.setval(t, s); + return e; + } + 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, s) { + return this.isSurge() || this.isLoon() ? $persistentStore.write(t, s) : this.isQuanX() ? $prefs.setValueForKey(t, s) : this.isNode() ? ((this.data = this.loaddata()), (this.data[s] = t), this.writedata(), !0) : (this.data && this.data[s]) || 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, s = () => { }) { + t.headers && (delete t.headers['Content-Type'], delete t.headers['Content-Length']), + this.isSurge() || this.isLoon() ? $httpClient.get(t, (t, e, i) => { + !t && e && ((e.body = i), (e.statusCode = e.status)), + s(t, e, i); + }) : this.isQuanX() ? $task.fetch(t).then((t) => { + const { + statusCode: e, + statusCode: i, + headers: o, + body: h + } = t; + s(null, { + status: e, + statusCode: i, + headers: o, + body: h + }, h); + }, (t) => s(t)) : this.isNode() && (this.initGotEnv(t), this.got(t).on('redirect', (t, s) => { + try { + const e = t.headers['set-cookie'].map(this.cktough.Cookie.parse).toString(); + this.ckjar.setCookieSync(e, null), + (s.cookieJar = this.ckjar); + } catch (t) { + this.logErr(t); + } + }).then((t) => { + const { + statusCode: e, + statusCode: i, + headers: o, + body: h + } = t; + s(null, { + status: e, + statusCode: i, + headers: o, + body: h + }, h); + }, (t) => s(t))); + } + post(t, s = () => { }) { + if ((t.body && t.headers && !t.headers['Content-Type'] && (t.headers['Content-Type'] = 'application/x-www-form-urlencoded'), delete t.headers['Content-Length'], this.isSurge() || this.isLoon())) + $httpClient.post(t, (t, e, i) => { + !t && e && ((e.body = i), (e.statusCode = e.status)), + s(t, e, i); + }); + else if (this.isQuanX()) + (t.method = 'POST'), $task.fetch(t).then((t) => { + const { + statusCode: e, + statusCode: i, + headers: o, + body: h + } = t; + s(null, { + status: e, + statusCode: i, + headers: o, + body: h + }, h); + }, (t) => s(t)); + else if (this.isNode()) { + this.initGotEnv(t); + const { + url: e, + ...i + } = t; + this.got.post(e, i).then((t) => { + const { + statusCode: e, + statusCode: i, + headers: o, + body: h + } = t; + s(null, { + status: e, + statusCode: i, + headers: o, + body: h + }, h); + }, (t) => s(t)); + } + } + time(t) { + let s = { + 'M+': new Date().getMonth() + 1, + 'd+': new Date().getDate(), + 'H+': new Date().getHours(), + 'm+': new Date().getMinutes(), + 's+': new Date().getSeconds(), + 'q+': Math.floor((new Date().getMonth() + 3) / 3), + S: new Date().getMilliseconds(), + }; + /(y+)/.test(t) && (t = t.replace(RegExp.$1, (new Date().getFullYear() + '').substr(4 - RegExp.$1.length))); + for (let e in s) + new RegExp('(' + e + ')').test(t) && (t = t.replace(RegExp.$1, 1 == RegExp.$1.length ? s[e] : ('00' + s[e]).substr(('' + s[e]).length))); + return t; + } + msg(s = t, e = '', i = '', o) { + const h = (t) => !t || (!this.isLoon() && this.isSurge()) ? t : 'string' == typeof t ? this.isLoon() ? t : this.isQuanX() ? { + 'open-url': t + } + : void 0 : 'object' == typeof t && (t['open-url'] || t['media-url']) ? this.isLoon() ? t['open-url'] : this.isQuanX() ? t : void 0 : void 0; + $.isMute || (this.isSurge() || this.isLoon() ? $notification.post(s, e, i, h(o)) : this.isQuanX() && $notify(s, e, i, h(o))), + this.logs.push('', '==============\ud83d\udce3\u7cfb\u7edf\u901a\u77e5\ud83d\udce3=============='), + this.logs.push(s), + e && this.logs.push(e), + i && this.logs.push(i); + } + log(...t) { + t.length > 0 ? (this.logs = [...this.logs, ...t]) : console.log(this.logs.join(this.logSeparator)); + } + logErr(t, s) { + const e = !this.isSurge() && !this.isQuanX() && !this.isLoon(); + e ? $.log('', `\u2757\ufe0f${this.name}, \u9519\u8bef!`, t.stack) : $.log('', `\u2757\ufe0f${this.name}, \u9519\u8bef!`, t); + } + wait(t) { + return new Promise((s) => setTimeout(s, t)); + } + done(t = {}) { + const s = new Date().getTime(), + e = (s - this.startTime) / 1e3; + this.log('', `\ud83d\udd14${this.name}, \u7ed3\u675f! \ud83d\udd5b ${e} \u79d2`), + this.log(), + (this.isSurge() || this.isQuanX() || this.isLoon()) && $done(t); + } + })(t, s); +}