KR/activity/jd_travel.js

1256 lines
314 KiB
JavaScript
Raw Normal View History

2022-02-11 16:56:14 +08:00
/*
TG https://t.me/aaron_scriptsG
被内鬼偷给柠檬了,大家一起玩吧
33 0,6-23/2 * * * jd_travel.js
*/
const $ = new Env('炸年兽');
const notify = $.isNode() ? require('./sendNotify') : '';
//Node.js用户请在jdCookie.js处填写京东ck;
let cookiesArr = [], cookie = '', message, helpCodeArr = [], expandHelpArr = [], helpPinArr = [], wxCookie = "";
let wxCookieArr = process.env.WXCookie?.split("@") || []
const teamLeaderArr = [], teamPlayerAutoTeam = {}
const jdCookieNode = $.isNode() ? require('./jdCookie.js') : '';
const appid = $.appid = "50089"
let teamMap = {}
let userToTeamMap = {}
$.curlCmd = ""
const h = (new Date()).getHours()
const helpFlag = h >= 9 && h < 12
const puzzleFlag = h >= 13 && h < 18
let expandFlag = h === 22, expandHelpFlag = h === 23
if (process.env.JD_TRAVEL_EXPAND !== undefined) {
expandFlag = h === +process.env.JD_TRAVEL_EXPAND
}
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);
}
const JD_API_HOST = 'https://api.m.jd.com/client.action';
const { getAppCookie } = safeRequire('./utils/wskeyUtils')
const pkTeamNum = () => Math.ceil(cookiesArr.length / 30)
!(async () => {
if (!cookiesArr[0]) {
$.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', { "open-url": "https://bean.m.jd.com/bean/signIndex.action" });
return;
}
console.log(`
温馨提示
默认膨胀时间22 默认开启膨胀红包时间23
如不需要自动膨胀请设置环境变量 JD_TRAVEL_EXPAND=-1
如需自动膨胀请注意设置好corn时间差如22:0023:00运行则刚好错过膨胀红包22:30,23:00运行则助力基本可以成功
`)
const helpSysInfoArr = []
for (let i = 0; i < cookiesArr.length; i++) {
if (cookiesArr[i]) {
cookie = cookiesArr[i];
wxCookie = wxCookieArr[i] ?? "";
const pt_key = cookie.match(/pt_key=([^; ]+)(?=;?)/)?.[1] || ""
if (!/app_open/.test(pt_key)) {
getAppCookie && (cookie = await getAppCookie(cookie));
}
$.pin = cookie.match(/pt_pin=([^; ]+)(?=;?)/)?.[1] || ""
$.UserName = decodeURIComponent($.pin)
$.index = i + 1;
$.isLogin = true;
$.nickName = $.UserName;
$.startActivityTime = Date.now().toString() + randomNum(1e8).toString()
message = '';
await TotalBean();
console.log(`\n******开始【京东账号${$.index}${$.nickName || $.UserName}*********\n`);
if (!$.isLogin) {
$.msg($.name, `【提示】cookie已失效`, `京东账号${$.index} ${$.nickName || $.UserName}\n请重新登录获取\nhttps://bean.m.jd.com/bean/signIndex.action`, { "open-url": "https://bean.m.jd.com/bean/signIndex.action" });
if ($.isNode()) {
await notify.sendNotify(`${$.name}cookie已失效 - ${$.UserName}`, `京东账号${$.index} ${$.UserName}\n请重新登录获取cookie`);
}
continue
}
$.UA = getUA()
$.shshshfpb = randomUUID({
formatData: "x".repeat(23),
charArr: [
...[...Array(10).keys()].map(x => String.fromCharCode(x + 48)),
...[...Array(26).keys()].map(x => String.fromCharCode(x + 97)),
...[...Array(26).keys()].map(x => String.fromCharCode(x + 65)),
"/"
],
followCase: false
}) + "==";
$.__jd_ref_cls = "Babel_dev_adv_selfReproduction"
$.ZooFaker = utils({ $ })
$.joyytoken = await getToken()
$.blog_joyytoken = await getToken("50999", "4")
cookie = $.ZooFaker.getCookie(cookie + `joyytoken=${appid}${$.joyytoken};`)
await travel()
helpSysInfoArr.push({
cookie,
pin: $.UserName,
UA: $.UA,
joyytoken: $.joyytoken,
blog_joyytoken: $.blog_joyytoken,
secretp: $.secretp
})
}
}
//
$.subSceneid = "ZNSZLh5"
const helpInfoArr = []
helpCodeArr.length > 0 && helpInfoArr.push({
flag: helpFlag,
codeArr: helpCodeArr,
preFunctionId: "getHomeData",
functionId: "collectScore"
})
expandHelpArr.length > 0 && helpInfoArr.push({
flag: expandHelpFlag,
codeArr: expandHelpArr,
preFunctionId: "pk_getHomeData",
functionId: "pk_collectPkExpandScore"
})
for (let i = 0; i < helpSysInfoArr.length && helpInfoArr.length > 0; i++) {
const s = helpSysInfoArr[i]
cookie = s.cookie
$.UserName = s.pin
$.pin = encodeURIComponent($.UserName)
$.index = i + 1;
$.isLogin = true;
$.nickName = $.UserName;
await TotalBean();
console.log(`\n******开始【京东账号${$.index}${$.nickName || $.UserName}*********\n`);
if (!$.isLogin) continue
$.UA = s.UA
// $.ZooFaker = require('./utils/ZooFaker_Necklace.js').utils()
$.ZooFaker = utils()
$.joyytoken = s.joyytoken
$.blog_joyytoken = s.blog_joyytoken
$.shshshfpb = s.shshshfpb
$.secretp = s.secretp
for (let j = 0; j < helpInfoArr.length; j++) {
const { flag, codeArr, preFunctionId, functionId } = helpInfoArr[j]
if (flag) {
$.newHelpCodeArr = [...codeArr]
for (let i = 0, codeLen = codeArr.length; i < codeLen; i++) {
const helpCode = codeArr[i]
const { pin, code } = helpCode
if (pin === $.UserName) continue
if (/pk/.test(preFunctionId)) {
const team = teamMap[userToTeamMap[$.UserName]]
if (team.includes(pin)) continue
}
console.log(`去帮助用户:${pin}`)
await doApi(preFunctionId, { inviteId: code })
await dealHelpRes(functionId, code, pin)
await $.wait(3000)
if ($.stopHelp) break
}
if ($.logBysha1) delete $.logBysha1
helpInfoArr[j].codeArr = [...$.newHelpCodeArr]
}
}
}
})()
.catch((e) => {
$.log('', `${$.name}, 失败! 原因: ${e}!`, '')
}).finally(() => {
$.done();
})
async function travel() {
try {
const mainMsgPopUp = await doApi("getMainMsgPopUp", { "channel": "1" })
mainMsgPopUp?.score && formatMsg(mainMsgPopUp.score, "首页弹窗")
const homeData = await doApi("getHomeData")
// console.log(homeData)
if (homeData) {
const { homeMainInfo: { todaySignStatus, secretp } } = homeData
if (secretp) $.secretp = secretp
if (!todaySignStatus) {
const { awardResult, nextRedPacketDays, progress, scoreResult } = await doApi("sign", null, null, true)
let ap = []
for (let key in awardResult || {}) {
if (key === "couponResult") {
const { usageThreshold, quota, desc } = awardResult[key]
ap.push(`获得优惠券:满${usageThreshold || 0}${quota || 0}${desc}`)
} else if (key === "redPacketResult") {
const { value } = awardResult[key]
ap.push(`获得红包:${value}`)
} else {
ap.push(`获得未知东东(${key}${JSON.stringify(awardResult[key])}`)
}
}
ap.push(`还需签到${nextRedPacketDays}天获得红包`)
ap.push(`签到进度:${progress}`)
scoreResult?.score && formatMsg(scoreResult.score, "每日签到", ap.join(""))
}
const collectAutoScore = await doApi("collectAutoScore", null, null, true)
collectAutoScore.produceScore && formatMsg(collectAutoScore.produceScore, "定时收集")
console.log("\n去看看战队\n")
await team()
console.log("\n去做主App任务\n")
await doAppTask()
if (puzzleFlag) {
console.log("\n去做做拼图任务")
const { doPuzzle } = safeRequire('./jd_travel_puzzle')
doPuzzle && await doPuzzle($, cookie)
}
}
} catch (e) {
console.log(e)
}
if (helpFlag) {
try {
$.WxUA = getWxUA()
const WxHomeData = await doWxApi("getHomeData", { inviteId: "" })
$.WxSecretp = WxHomeData?.homeMainInfo?.secretp || $.secretp
console.log("\n去做微信小程序任务\n")
await doWxTask()
} catch (e) {
console.log(e)
}
try {
console.log("\n去做金融App任务\n")
$.sdkToken = "jdd01" + randomUUID({
formatData: "X".repeat(103),
charArr: [...Array(36).keys()].map(k => k.toString(36).toUpperCase())
}) + "0123456"
await doJrAppTask()
} catch (e) {
console.log(e)
}
}
try {
await raise(true)
} catch (e) {
console.log(e)
}
}
async function team() {
const pkHomeData = await doApi("pk_getHomeData")
const pkPopArr = await doApi("pk_getMsgPopup") || []
for (const pkPopInfo of pkPopArr) {
if (pkPopInfo?.type === 50 && pkPopInfo.value) {
const pkDivideInfo = await doApi("pk_divideScores", null, null, true)
pkDivideInfo?.produceScore && formatMsg(pkDivideInfo?.produceScore, "PK战队瓜分收益")
}
}
const { votInfo, divideInfo } = pkHomeData
if (votInfo) {
const { groupPercentA, groupPercentB, packageA, packageB, status } = votInfo
if (status === 2) {
let a = (+ packageA / + groupPercentA).toFixed(3)
let b = (+ packageB / + groupPercentB).toFixed(3)
const vot = a > b ? "A" : "B"
console.log(`'A'投票平均收益:${a}'B'投票平均收益:${b},去投:${vot}`)
await votFor(vot)
}
}
const { groupJoinInviteId, groupName, groupNum } = pkHomeData?.groupInfo || {}
if (groupName && groupNum !== undefined) console.log(`当前战队:${groupName}${groupNum}`)
if (groupNum > 1) {
teamMap[groupName] = teamMap[groupName] || []
teamMap[groupName].push($.UserName)
userToTeamMap[$.UserName] = groupName
}
if (groupNum !== undefined && groupNum < 30 && $.index <= pkTeamNum()) {
if (groupJoinInviteId) {
teamLeaderArr.push({
groupJoinInviteId,
groupNum,
groupName
})
}
} else if (groupNum === 1) {
for (let n = 0; n < teamLeaderArr.length; n++) {
const bakCookie = cookie, bakJoyyToken = $.joyytoken
cookie = cookie.replace(/joyytoken=\S+?;/, "joyytoken=;")
$.joyytoken = ""
$.subSceneid = "HYGJZYh5"
$.logBysha1 = true
const { groupJoinInviteId, groupNum, groupName } = teamLeaderArr[n]
console.log(`${groupName}人数:${groupNum},正在去加入他的队伍...`)
if (await joinTeam(groupJoinInviteId)) {
teamLeaderArr[n].groupNum += 1
await $.wait(2000)
teamPlayerAutoTeam[$.UserName] = n
break
}
cookie = bakCookie, $.joyytoken = bakJoyyToken
delete $.subSceneid
delete $.logBysha1
}
}
if (divideInfo) {
const { status, remainTime } = divideInfo
if (status === 0) {
console.log(`竞猜红包已到瓜分时间,去瓜分...`)
const getAmountForecast = await doApi("pk_getAmountForecast")
if (getAmountForecast) {
const { inflateStatus, userAward, userAwardExpand } = getAmountForecast
if (inflateStatus == '0') {
if (!userAwardExpand) {
console.log(`竞猜红包瓜分金额:${userAward},去收取...`)
await pk_receiveAward()
} else {
console.log(`竞猜红包瓜分金额:${userAward},可膨胀至:${userAwardExpand}`)
if (userAwardExpand > 5) {
await notify.sendNotify(`${$.name}膨胀${userAwardExpand}元! - ${$.UserName}`, `京东账号${$.index} ${$.UserName}\n请进入app首页全民炸年兽或搜索-全民炸年兽)\n点击‘去组队赚红包’右上角即可看到!`);
}
if (expandFlag) {
const getExpandDetail = await doApi("pk_getExpandDetail")
if (getExpandDetail) {
const { inviteId, pkExpandDetailResult: { remainTime, userAward, userAwardExpand } } = getExpandDetail
const expireTimeStr = new Date(new Date(new Date().toLocaleDateString()).getTime() + (+remainTime)).Format("h时m分s秒")
console.log(`竞猜红包开始膨胀任务!膨胀邀请码:${inviteId},膨胀失效时间:${expireTimeStr}`)
} else {
console.log(`获取竞猜红包详细详细失败!`)
}
}
}
} else if (inflateStatus == '1') {
console.log(`竞猜红包瓜分金额:${userAward},膨胀任务已失效,去收取...`)
await pk_receiveAward()
} else if (inflateStatus == '2') {
console.log(`竞猜红包瓜分金额:${userAward},可膨胀至:${userAwardExpand}`)
if (userAwardExpand > 10) {
await notify.sendNotify(`${$.name}膨胀${userAwardExpand}元! - ${$.UserName}`, `京东账号${$.index} ${$.UserName}\n请进入app首页全民炸年兽或搜索-全民炸年兽)\n点击‘去组队赚红包’右上角即可看到!`);
}
if (expandFlag) {
const getExpandDetail = await doApi("pk_getExpandDetail")
if (getExpandDetail) {
const { inviteId, pkExpandDetailResult: { remainTime, userAward, userAwardExpand } } = getExpandDetail
const expireTimeStr = new Date(new Date(new Date().toLocaleDateString()).getTime() + (+remainTime)).Format("h时m分s秒")
console.log(`竞猜红包开始膨胀任务!膨胀邀请码:${inviteId},膨胀失效时间:${expireTimeStr}`)
} else {
console.log(`获取竞猜红包详细详细失败!`)
}
}
}
} else {
console.log(`获取竞猜红包信息失败!`)
}
} else if (status === 1) {
// 红包已领取
} else if (status === 2) {
const getExpandDetail = await doApi("pk_getExpandDetail")
if (getExpandDetail) {
const { inviteId, pkExpandDetailResult: { remainTime, userAward, userAwardExpand } } = getExpandDetail
const expireTimeStr = new Date(new Date(new Date().toLocaleDateString()).getTime() + (+remainTime)).Format("h时m分s秒")
console.log(`竞猜红包膨胀任务进行中!\n原红包金额:${userAward},可膨胀至:${userAwardExpand}\n膨胀邀请码:${inviteId},膨胀失效时间:${expireTimeStr}`)
expandHelpArr.push({
pin: $.UserName,
code: inviteId
})
} else {
console.log(`获取竞猜红包详细详细失败!`)
}
} else if (status === 3) {
// 红包任务已完成
await pk_receiveAward()
}
}
async function pk_receiveAward() {
const { ext, value } = await doApi(`pk_receiveAward`)
console.log(`获得红包:${value}元(${ext}`)
}
}
async function dealHelpRes(functionId, inviteId, pin) {
$.stopHelp = false
const helpRes = await doApi(functionId, null, { inviteId }, true, true)
if (helpRes?.result?.score) {
const { alreadyAssistTimes, maxAssistTimes, maxTimes, score, times } = helpRes.result
const c = maxAssistTimes - alreadyAssistTimes
const needNum = maxTimes - times
if (needNum === 0) {
$.newHelpCodeArr = $.newHelpCodeArr.filter(x => x.pin !== pin)
}
console.log(`互助成功,获得${score}爆竹🧨,他还需要${needNum}人完成助力,你还有${maxAssistTimes - alreadyAssistTimes}次助力机会`)
if (!c) $.stopHelp = true
} else {
console.log(`互助失败,原因:${helpRes?.bizMsg}${helpRes?.bizCode}`)
if (![0, -201, -202, -13, 103].includes(helpRes?.bizCode)) $.stopHelp = true
if (helpRes?.bizCode === -201 || helpRes?.bizCode === 103) {
$.newHelpCodeArr = $.newHelpCodeArr.filter(x => x.pin !== pin)
} else if (helpRes?.bizCode === -1002 && !$.logBysha1) {
console.log(`切换log方式sha1`)
$.logBysha1 = true
await dealHelpRes.apply(this, arguments)
}
}
}
async function joinTeam(groupJoinInviteId) {
const inviteId = groupJoinInviteId
await doApi("pk_getHomeData", { inviteId })
const { bizCode, bizMsg } = await doApi("pk_joinGroup", { inviteId, confirmFlag: "1" }, null, true, true)
if (bizCode === 0) {
console.log("加入队伍成功!")
} else {
formatErr("pk_joinGroup", `${bizMsg}${bizCode}`, $.curlCmd)
}
}
async function votFor(votFor) {
const { bizCode, bizMsg } = await doApi("pk_votFor", { votFor }, null, false, true)
if (bizCode === 0) {
console.log("投票成功!")
} else {
formatErr("pk_votFor", `${bizMsg}${bizCode}`, $.curlCmd)
}
}
async function raise(isFirst = false) {
const homeData = await doApi("getHomeData")
// console.log(homeData)
if (!homeData) return
const { homeMainInfo: { raiseInfo: { cityConfig: { clockNeedsCoins, points }, remainScore } } } = homeData
if (remainScore >= clockNeedsCoins) {
if (isFirst) console.log(`\n开始解锁\n`)
let curScore = remainScore
let flag = false
for (const { status, pointName } of points) {
if (status === 1) {
const res = await doApi("raise", {}, {}, true)
if (res) {
if (!flag) flag = true
let arr = [`解锁'${pointName}'成功`]
const { levelUpAward: { awardCoins, canFirstShare, couponInfo, firstShareAwardCoins, redNum } } = res
arr.push(`获得${awardCoins}个爆竹🧨`)
if (couponInfo) {
arr.push(`获得【${couponInfo.name}】优惠券:满${couponInfo.usageThreshold}${couponInfo.quota}${couponInfo.desc}`)
}
if (redNum) {
arr.push(`获得${redNum}份分红`)
}
console.log(arr.join(""))
if (canFirstShare) {
const WelfareScore = await doApi("getWelfareScore", { type: 1 })
if (WelfareScore?.score) formatMsg(WelfareScore?.score, "分享收益")
}
curScore -= clockNeedsCoins
if (curScore < clockNeedsCoins) return
} else {
return
}
}
await $.wait(2000)
}
if (flag) await raise()
}
}
async function doAppTask() {
const { inviteId, lotteryTaskVos, taskVos } = await doApi("getTaskDetail")
if (inviteId) {
console.log(`你的互助码:${inviteId}`)
if (!helpPinArr.includes($.UserName)) {
helpCodeArr.push({
pin: $.UserName,
code: inviteId
})
helpPinArr.push($.UserName)
}
}
for (const { times, badgeAwardVos } of lotteryTaskVos || []) {
for (const { awardToken, requireIndex, status } of badgeAwardVos) {
if (times >= requireIndex && status === 3) {
const res = await doApi("getBadgeAward", { awardToken })
if (res?.score) {
formatMsg(res.score, "奖励宝箱收益")
} else {
const myAwardVos = mohuReadJson(res, "Vos?$", 1)
if (myAwardVos) {
let flag = false
for (let award of myAwardVos) {
const awardInfo = mohuReadJson(award, "Vos?$", -1, "score")
if (awardInfo?.score) {
if (!flag) flag = true
formatMsg(awardInfo.score, "奖励宝箱收益")
}
}
if (!flag) console.log(res)
}
}
}
}
}
const feedList = []
for (let mainTask of taskVos) {
// console.log(mainTask)
const { taskId, taskName, waitDuration, times: timesTemp, maxTimes, status } = mainTask
if (status === 2) continue
let times = timesTemp, flag = false
const other = mohuReadJson(mainTask, "Vos?$", -1, "taskToken")
if (other) {
const { taskToken } = other
if (!taskToken) continue
if (taskId === 1) {
continue
}
console.log(`当前正在做任务:${taskName}`)
const body = { taskId, taskToken, actionType: 1 }
if (taskId === 31) {
await doApi("pk_getHomeData")
await doApi("pk_getPkTaskDetail", null, null, false, true)
await doApi("pk_getMsgPopup")
delete body.actionType
}
const res = await doApi("collectScore", { taskId, taskToken, actionType: 1 }, null, true)
res?.score && (formatMsg(res.score, "任务收益"), true)/* || console.log(res) */
continue
}
$.stopCard = false
for (let activity of mohuReadJson(mainTask, "Vo(s)?$", maxTimes, "taskToken") || []) {
if (!flag) flag = true
const { shopName, title, taskToken, status } = activity
if (status !== 1) continue
console.log(`当前正在做任务:${shopName || title}`)
const res = await doApi("collectScore", { taskId, taskToken, actionType: 1 }, null, true)
if ($.stopCard) break
if (waitDuration || res?.taskToken) {
await $.wait(waitDuration * 1000)
const res = await doApi("collectScore", { taskId, taskToken, actionType: 0 }, null, true)
res?.score && (formatMsg(res.score, "任务收益"), true)/* || console.log(res) */
} else {
res?.score && (formatMsg(res.score, "任务收益"), true)/* || console.log(res) */
}
times++
if (times >= maxTimes) break
}
if (flag) continue
feedList.push({
taskId: taskId.toString(),
taskName
})
}
for (let feed of feedList) {
const { taskId: id, taskName: name } = feed
const res = await doApi("getFeedDetail", { taskId: id.toString() })
if (!res) continue
for (let mainTask of mohuReadJson(res, "Vos?$", 1, "taskId") || []) {
const { score, taskId, taskBeginTime, taskEndTime, taskName, times: timesTemp, maxTimes, waitDuration } = mainTask
const t = Date.now()
let times = timesTemp
if (t >= taskBeginTime && t <= taskEndTime) {
console.log(`当前正在做任务:${taskName}`)
for (let productInfo of mohuReadJson(mainTask, "Vo(s)?$", maxTimes, "taskToken") || []) {
const { taskToken, status } = productInfo
if (status !== 1) continue
const res = await doApi("collectScore", { taskId, taskToken, actionType: 1 }, null, true)
times = res?.times ?? (times + 1)
await $.wait(waitDuration * 1000)
if (times >= maxTimes) {
formatMsg(score, "任务收益")
break
}
}
}/* else {
console.log(`任务:${taskName}:未到做任务时间`)
} */
}
}
}
async function doWxTask() {
$.stopWxTask = false
const feedList = []
const { taskVos } = await doWxApi("getTaskDetail", { taskId: "", appSign: 2 })
for (let mainTask of taskVos) {
const { taskId, taskName, waitDuration, times: timesTemp, maxTimes, status } = mainTask
let times = timesTemp, flag = false
if (status === 2) continue
const other = mohuReadJson(mainTask, "Vos?$", -1, "taskToken")
if (other) {
const { taskToken } = other
if (!taskToken) continue
if (taskId === 1) {
continue
}
console.log(`当前正在做任务:${taskName}`)
const res = await doWxApi("collectScore", { taskId, taskToken, actionType: 1 }, null, true)
if ($.stopWxTask) return
res?.score && (formatMsg(res.score, "任务收益"), true)/* || console.log(res) */
continue
}
$.stopCard = false
for (let activity of mohuReadJson(mainTask, "Vo(s)?$", maxTimes, "taskToken") || []) {
if (!flag) flag = true
const { shopName, title, taskToken, status } = activity
if (status !== 1) continue
console.log(`当前正在做任务:${shopName || title}`)
const res = await doWxApi("collectScore", { taskId, taskToken, actionType: 1 }, null, true)
if ($.stopCard || $.stopWxTask) break
if (waitDuration || res.taskToken) {
await $.wait(waitDuration * 1000)
const res = await doWxApi("collectScore", { taskId, taskToken, actionType: 0 }, null, true)
if ($.stopWxTask) return
res?.score && (formatMsg(res.score, "任务收益"), true)/* || console.log(res) */
} else {
if ($.stopWxTask) return
res?.score && (formatMsg(res.score, "任务收益"), true)/* || console.log(res) */
}
times++
if (times >= maxTimes) break
}
if (flag) continue
feedList.push({
taskId: taskId.toString(),
taskName
})
}
for (let feed of feedList) {
const { taskId: id, taskName: name } = feed
const res = await doWxApi("getFeedDetail", { taskId: id.toString() }, null, true)
if (!res) continue
for (let mainTask of mohuReadJson(res, "Vos?$", 1, "taskId") || []) {
const { score, taskId, taskBeginTime, taskEndTime, taskName, times: timesTemp, maxTimes, waitDuration } = mainTask
const t = Date.now()
let times = timesTemp
if (t >= taskBeginTime && t <= taskEndTime) {
console.log(`当前正在做任务:${taskName}`)
for (let productInfo of mohuReadJson(mainTask, "Vo(s)?$", maxTimes, "taskToken") || []) {
const { taskToken, status } = productInfo
if (status !== 1) continue
const res = await doWxApi("collectScore", { taskId, taskToken, actionType: 1 }, null, true)
if ($.stopWxTask) return
times = res?.times ?? (times + 1)
await $.wait(waitDuration * 1000)
if (times >= maxTimes) {
formatMsg(score, "任务收益")
break
}
}
}/* else {
console.log(`任务:${taskName}:未到做任务时间`)
} */
}
}
}
async function doJrAppTask() {
$.isJr = true
$.JrUA = getJrUA()
const { trades, views } = await doJrPostApi("miMissions", null, null, true)
/* for (let task of trades || views || []) {
const { status, missionId, channel } = task
if (status !== 1 && status !== 3) continue
const { subTitle, title, url } = await doJrPostApi("miTakeMission", null, {
missionId,
validate: "",
channel,
babelChannel: "1111shouyefuceng"
}, true)
console.log(`当前正在做任务:${title}${subTitle}`)
const { code, msg, data } = await doJrGetApi("queryPlayActiveHelper", { sourceUrl: url })
// const { code, msg, data } = await doJrGetApi("queryMissionReceiveAfterStatus", { missionId })
console.log(`做任务结果:${msg}${code}`)
} */
for (let task of views || []) {
const { status, missionId, channel, total, complete } = task
if (status !== 1 && status !== 3) continue
const { subTitle, title, url } = await doJrPostApi("miTakeMission", null, {
missionId,
validate: "",
channel,
babelChannel: "1111zhuhuichangfuceng"
}, true)
console.log(`当前正在做任务:${title}${subTitle}`)
const readTime = url.getKeyVal("readTime")
const juid = url.getKeyVal("juid")
if (readTime) {
await doJrGetApi("queryMissionReceiveAfterStatus", { missionId })
await $.wait(+ readTime * 1000)
const { code, msg, data } = await doJrGetApi("finishReadMission", { missionId, readTime })
console.log(`做任务结果:${msg}`)
} else if (juid) {
const { code, msg, data } = await doJrGetApi("getJumpInfo", { juid })
console.log(`做任务结果:${msg}`)
} else {
console.log(`不知道这是啥:${url}`)
}
}
$.isJr = false
}
function mohuReadJson(json, key, len, keyName) {
if (!key) return null
for (let jsonKey in json) {
if (RegExp(key).test(jsonKey)) {
if (!len) return json[jsonKey]
if (len === -1) {
if (json[jsonKey][keyName]) return json[jsonKey]
} else if (json[jsonKey]?.length >= len) {
if (keyName) {
if (json[jsonKey][0].hasOwnProperty(keyName)) {
return json[jsonKey]
} else {
continue
}
}
return json[jsonKey]
}
}
}
return null
}
function formatMsg(num, pre, ap) {
console.log(`${pre ? pre + "" : ""}获得${num}个爆竹🧨${ap ? "" + ap : ""}`)
}
function getSs(secretp) {
$.random = Math.floor(1e7 + 9e7 * Math.random()).toString()
$.sceneid = $.subSceneid ?? "ZNShPageh5"
const extraData = $.ZooFaker.getSs($)
return {
extraData,
secretp,
random: $.random
}
}
function getSafeStr() {
$.random = Math.floor(1e7 + 9e7 * Math.random()).toString()
const log = $.ZooFaker.getSs($).log
return {
random: $.random,
secreid: "HYJGJSh5",
log
}
}
function getWxSs(secretp) {
$.random = Math.floor(1e7 + 9e7 * Math.random()).toString()
$.secreid = "HYJhPagewx"
const extraData = $.ZooFaker.getWxSs($)
return {
extraData,
secretp,
random: $.random
}
}
async function doApi(functionId, prepend = {}, append = {}, needSs = false, getLast = false) {
functionId = `tigernian_${functionId}`
const url = JD_API_HOST + `?functionId=${functionId}`
const bodyMain = objToStr2({
functionId,
body: encodeURIComponent(JSON.stringify({
...prepend,
ss: needSs ? JSON.stringify(getSs($.secretp || "E7CRMoDURcyS-_XDYYuo__Ai9oE")) : undefined,
...append,
})),
client: "wh5",
clientVersion: "1.0.0"
})
const option = {
url,
body: bodyMain,
headers: {
'Cookie': cookie,
'Host': 'api.m.jd.com',
'Origin': 'https://wbbny.m.jd.com',
'Referer': 'https://wbbny.m.jd.com/babelDiy/Zeus/2vVU4E7JLH9gKYfLQ5EVW6eN2P7B/index.html',
'Connection': 'keep-alive',
'Content-Type': 'application/x-www-form-urlencoded',
"User-Agent": $.UA,
'Accept': 'application/json, text/plain, */*',
'Accept-Language': 'zh-cn',
'Accept-Encoding': 'gzip, deflate, br',
}
}
$.curlCmd = toCurl(option)
return new Promise(resolve => {
$.post(option, (err, resp, data) => {
let res = null
try {
if (err) console.log(formatErr(functionId, err, toCurl(option)))
else {
if (safeGet(data)) {
data = JSON.parse(data)
if (getLast) {
res = data?.data
if (data?.data?.bizCode === -1002) {
console.log(formatErr(functionId, data, toCurl(option)))
}
} else {
if (data?.data?.bizCode !== 0) {
if (/加入.*?会员.*?获得/.test(data?.data?.bizMsg)) {
console.log(data?.data?.bizMsg + `${data?.data?.bizCode}`)
$.stopCard = true
} else console.log(formatErr(functionId, data?.data?.bizMsg + `${data?.data?.bizCode}`, toCurl(option)))
} else {
res = data?.data?.result || {}
}
}
} else {
console.log(formatErr(functionId, data, toCurl(option)))
}
}
} catch (e) {
console.log(formatErr(functionId, e.toString(), toCurl(option)))
} finally {
resolve(res)
}
})
})
}
async function doJrPostApi(functionId, prepend = {}, append = {}, needEid = false) {
const url = "https://ms.jr.jd.com/gw/generic/uc/h5/m/" + functionId
const bodyMain = `reqData=${encodeURIComponent(JSON.stringify({
...prepend,
...needEid ? {
eid: $.eid || "",
sdkToken: $.sdkToken || "",
} : {},
...append
}))}`
const option = {
url,
body: bodyMain,
headers: {
'Cookie': cookie,
'Host': 'ms.jr.jd.com',
'Origin': 'https://wbbny.m.jd.com',
'Referer': 'https://wbbny.m.jd.com/babelDiy/Zeus/2vVU4E7JLH9gKYfLQ5EVW6eN2P7B/index.html?babelChannel=1111zhuhuichangfuceng&conf=jr',
'Connection': 'keep-alive',
'Content-Type': 'application/x-www-form-urlencoded',
"User-Agent": $.JrUA,
'Accept': 'application/json, text/plain, */*',
'Accept-Language': 'zh-cn',
'Accept-Encoding': 'gzip, deflate, br',
}
}
return new Promise(resolve => {
$.post(option, (err, resp, data) => {
let res = null
try {
if (err) console.log(formatErr(functionId, err, toCurl(option)))
else {
if (safeGet(data)) {
data = JSON.parse(data)
if (data?.resultData?.code !== 0) {
console.log(formatErr(functionId, data?.resultData?.msg + `${data?.resultData?.code}`, toCurl(option)))
} else {
res = data?.resultData?.data || {}
}
} else {
console.log(formatErr(functionId, data, toCurl(option)))
}
}
} catch (e) {
console.log(formatErr(functionId, e.toString(), toCurl(option)))
} finally {
resolve(res)
}
})
})
}
async function doJrGetApi(functionId, prepend = {}, append = {}, needEid = false) {
const url = "https://ms.jr.jd.com/gw/generic/mission/h5/m/" + functionId
const bodyMain = `reqData=${encodeURIComponent(JSON.stringify({
...prepend,
...needEid ? {
eid: $.eid || "",
sdkToken: $.sdkToken || "",
} : {},
...append
}))}`
const option = {
url: `${url}?${bodyMain}`,
headers: {
'Cookie': cookie,
'Host': 'ms.jr.jd.com',
'Origin': 'https://wbbny.m.jd.com',
'Referer': 'https://wbbny.m.jd.com/babelDiy/Zeus/2vVU4E7JLH9gKYfLQ5EVW6eN2P7B/index.html?babelChannel=1111shouyefuceng&conf=jr',
'Connection': 'keep-alive',
'Content-Type': 'application/x-www-form-urlencoded',
"User-Agent": $.JrUA,
'Accept': '*/*',
'Accept-Language': 'zh-cn',
'Accept-Encoding': 'gzip, deflate, br',
}
}
return new Promise(resolve => {
$.get(option, (err, resp, data) => {
let res = null
try {
if (err) console.log(formatErr(functionId, err, toCurl(option)))
else {
if (safeGet(data)) {
data = JSON.parse(data)
res = data?.resultData || {}
} else {
console.log(formatErr(functionId, data, toCurl(option)))
}
}
} catch (e) {
console.log(formatErr(functionId, e.toString(), toCurl(option)))
} finally {
resolve(res)
}
})
})
}
async function doWxApi(functionId, prepend = {}, append = {}, needSs = false) {
functionId = `tigernian_${functionId}`
const url = JD_API_HOST + `?dev=${functionId}&g_ty=ls&g_tk=`
const bodyMain = {
sceneval: "",
callback: functionId,
functionId,
appid: "wh5",
client: "wh5",
clientVersion: "1.0.0",
uuid: -1,
body: encodeURIComponent(JSON.stringify({
...prepend,
ss: needSs ? JSON.stringify(getWxSs($.WxSecretp)) : undefined,
...append,
})),
loginType: 2,
loginWQBiz: "dacu"
}
const cookieA =
wxCookie
?
((bodyMain.loginType = 1), `jdpin=${$.pin};pin=${$.pin};pinStatus=0;wq_auth_token=${wxCookie};shshshfpb=${encodeURIComponent($.shshshfpb)};`)
:
cookie
const option = {
url,
body: objToStr2(bodyMain),
headers: {
'Cookie': cookieA,
'Host': 'api.m.jd.com',
'Referer': 'https://servicewechat.com/wx91d27dbf599dff74/570/page-frame.html',
'wxreferer': 'http://wq.jd.com/wxapp/pages/loveTravel/pages/index/index',
'Connection': 'keep-alive',
'Content-Type': 'application/x-www-form-urlencoded',
"User-Agent": $.WxUA,
'Accept': '*/*',
'Accept-Language': 'zh-cn',
'Accept-Encoding': 'gzip, deflate, br',
}
}
return new Promise(resolve => {
$.post(option, (err, resp, data) => {
let res = null
try {
if (err) console.log(formatErr(functionId, err, toCurl(option)))
else {
if (safeGet(data)) {
data = JSON.parse(data)
if (data?.data?.bizCode !== 0) {
if (data?.data?.bizCode === -1002) $.stopWxTask = true
console.log(formatErr(functionId, data?.data?.bizMsg ? (data?.data?.bizMsg + `${data?.data?.bizCode}`) : JSON.stringify(data), toCurl(option)))
} else {
res = data.data.result
}
} else {
console.log(formatErr(functionId, data, toCurl(option)))
}
}
} catch (e) {
console.log(formatErr(functionId, e.toString(), toCurl(option)))
} finally {
resolve(res)
}
})
})
}
function getToken(appname = appid, platform = "1") {
return new Promise(resolve => {
$.post({
url: "https://rjsb-token-m.jd.com/gettoken",
body: `content=${JSON.stringify({
appname,
whwswswws: "",
jdkey: $.UUID || randomString(40),
body: {
platform,
}
})}`,
headers: {
Accept: "*/*",
'Accept-Encoding': "gzip, deflate, br",
'Accept-Language': "zh-CN,zh-Hans;q=0.9",
Connection: "keep-alive",
'Content-Type': "text/plain;charset=UTF-8",
Host: "rjsb-token-m.jd.com",
Origin: "https://h5.m.jd.com",
Referer: "https://h5.m.jd.com/",
'User-Agent': $.UA
}
}, (err, resp, data) => {
try {
if (err) {
console.log(err)
resolve()
}
const { joyytoken } = JSON.parse(data)
resolve(joyytoken)
} catch (e) {
console.log(e)
resolve()
} finally {
}
})
})
}
function formatErr(functionId, errMsg, curlCmd) {
return JSON.parse(JSON.stringify({
functionId,
errMsg,
curlCmd,
}))
}
function safeGet(data) {
try {
if (typeof JSON.parse(data) == "object") {
return true;
}
} catch (e) {
console.log(e);
console.log(`京东服务器访问数据为空,请检查自身设备网络情况`);
return false;
}
}
function getUA() {
$.UUID = randomString(40)
const buildMap = {
"167814": `10.1.4`,
"167841": `10.1.6`,
"167853": `10.2.0`
}
$.osVersion = `${randomNum(13, 14)}.${randomNum(3, 6)}.${randomNum(1, 3)}`
let network = `network/${['4g', '5g', 'wifi'][randomNum(0, 2)]}`
$.mobile = `iPhone${randomNum(9, 13)},${randomNum(1, 3)}`
$.build = ["167814", "167841", "167853"][randomNum(0, 2)]
$.appVersion = buildMap[$.build]
return `jdapp;iPhone;${$.appVersion};${$.osVersion};${$.UUID};M/5.0;${network};ADID/;model/${$.mobile};addressid/;appBuild/${$.build};jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS ${$.osVersion.replace(/\./g, "_")} like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1;`
}
function getWxUA() {
const osVersion = `${randomNum(12, 14)}.${randomNum(0, 6)}`
$.wxAppid = "wx91d27dbf599dff74"
return `Mozilla/5.0 (iPhone; CPU OS ${osVersion.replace(/\./g, "_")} like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/8.0.15(0x18000f28) NetType/WIFI Language/zh_CN`
}
function randomUUID(option = {
formatData: `${"X".repeat(8)}-${"X".repeat(4)}-${"X".repeat(4)}-${"X".repeat(12)}`,
charArr: [...Array(16).keys()].map(k => k.toString(16).toUpperCase()),
followCase: true,
}) {
if (!option.formatData) option.formatData = `${"X".repeat(8)}-${"X".repeat(4)}-${"X".repeat(4)}-${"X".repeat(12)}`
if (!option.charArr) option.charArr = [...Array(16).keys()].map(k => k.toString(16).toUpperCase())
if (!option.followCase === undefined) option.followCase = true
let { formatData: res, charArr } = option
res = res.split("")
const charLen = charArr.length - 1
const resLen = res.length
for (let i = 0; i < resLen; i++) {
const tis = res[i]
if (/[xX]/.test(tis)) {
res[i] = charArr[randomNum(0, charLen)]
if (option.followCase) res[i] = res[i][tis === "x" ? "toLowerCase" : "toUpperCase"]()
}
}
return res.join("")
}
function getJrUA() {
const randomMobile = {
type: `${randomNum(9, 13)},${randomNum(1, 3)}`,
screen: ["812", "375"]
}
const mobile = $.mobile ?? "iPhone " + randomMobile.type
const screen = randomMobile.screen.join('*')
const osV = $.osVersion ?? `${randomNum(13, 14)}.${randomNum(0, 6)}`
const appV = `6.2.40`
const deviceId = randomUUID({
formatData: 'x'.repeat(36) + '-' + 'x'.repeat(36),
charArr: [...Array(10).keys(), 'd'].map(x => x.toString())
})
const jdPaySdkV = `4.00.10.00`
return `Mozilla/5.0 (iPhone; CPU iPhone OS ${osV.replace(/\./g, "_")} AppleWebKit/60${randomNum(3, 5)}.1.15 (KHTML, like Gecko) Mobile/15E148/application=JDJR-App&deviceId=${deviceId}&eufv=1&clientType=ios&iosType=iphone&clientVersion=${appV}&HiClVersion=${appV}&isUpdate=0&osVersion=${osV}&osName=iOS&platform=${mobile}&screen=${screen}&src=App Store&netWork=1&netWorkType=1&CpayJS=UnionPay/1.0 JDJR&stockSDK=stocksdk-iphone_3.5.0&sPoint=&jdPay=(*#@jdPaySDK*#@jdPayChannel=jdfinance&jdPayChannelVersion=${osV}&jdPaySdkVersion=${jdPaySdkV}&jdPayClientName=iOS*#@jdPaySDK*#@)`
}
function toCurl(option = { url: "", body: "", headers: {} }) {
if (!option.url) return ""
let res = "curl "
if (!option.headers.Host) option.headers.Host = option.url.match(/^http(s)?:\/\/(.*?)($|\/)/)?.[2] || ""
for (let key in option.headers) {
res += `-H '${key}: ${option.headers[key]}' `
}
if (option.body) {
res += `--data-raw '${option.body}' `
}
res += `--compressed "${option.url}"`
return res
}
function objToStr2(jsonMap) {
let isFirst = true
let res = ""
for (let key in jsonMap) {
let keyValue = jsonMap[key]
if (typeof keyValue == "object") {
keyValue = JSON.stringify(keyValue)
}
if (isFirst) {
res += `${key}=${keyValue}`
isFirst = false
} else {
res += `&${key}=${keyValue}`
}
}
return res
}
function str2ToObj(keyMap) {
const keyArr = keyMap.split("&").filter(x => x)
const keyLen = keyArr.length
if (keyLen === 1 && !keyArr[0].includes("=")) {
return keyMap
}
const res = {}
for (let i = 0; i < keyLen; i++) {
const cur = keyArr[i].split('=').filter(x => x)
const curValue = cur[1]
if (/\d{1,16}|[.*?]|{}|{"\w+?":.*?(,"\w+?":.*?)*}|true|false/.test(curValue)) {
try {
cur[1] = eval(`(${curValue})`)
} catch (_) { }
}
res[cur[0]] = cur[1]
}
return res
}
function randomNum(min, max) {
if (arguments.length === 0) return Math.random()
if (!max) max = 10 ** (Math.log(min) * Math.LOG10E + 1 | 0) - 1
return Math.floor(Math.random() * (max - min + 1) + min);
}
function randomString(min, max = 0) {
var str = "", range = min, arr = [...Array(36).keys()].map(k => k.toString(36));
if (max) {
range = Math.floor(Math.random() * (max - min + 1) + min);
}
for (let i = 0; i < range;) {
let randomString = Math.random().toString(16).substring(2)
if ((range - i) > randomString.length) {
str += randomString
i += randomString.length
} else {
str += randomString.slice(i - range)
i += randomString.length
}
}
return str;
}
function TotalBean() {
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") {
$.isLogin = false; //cookie过期
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 safeRequire(path = "") {
try {
return require(path)
} catch (e) {
return {}
}
}
Date.prototype.Format = function (fmt) {
var e,
n = this, d = fmt, l = {
"M+": n.getMonth() + 1,
"d+": n.getDate(),
"D+": n.getDate(),
"h+": n.getHours(),
"H+": n.getHours(),
"m+": n.getMinutes(),
"s+": n.getSeconds(),
"w+": n.getDay(),
"q+": Math.floor((n.getMonth() + 3) / 3),
"S+": n.getMilliseconds()
};
/(y+)/i.test(d) && (d = d.replace(RegExp.$1, "".concat(n.getFullYear()).substr(4 - RegExp.$1.length)));
for (var k in l) {
if (new RegExp("(".concat(k, ")")).test(d)) {
var t, a = "S+" === k ? "000" : "00";
d = d.replace(RegExp.$1, 1 == RegExp.$1.length ? l[k] : ("".concat(a) + l[k]).substr("".concat(l[k]).length))
}
}
return d;
}
String.prototype.getKeyVal = function (str) {
const reg = new RegExp(`${str}\=(.*?)(&|$)`)
let res = ""
if (reg.test(this)) {
res = this.match(reg)[1]
}
return res
}
var _0xod4='jsjiami.com.v6',_0x17c0=[_0xod4,'wqMRwpMhKA==','RQhQwpTCkQ==','wozCrjzDkMKA','Sxhmd384UsOVdQ==','w5d3w7c0aA==','MhUvw4wl','w7zDkMKfwpE4','w6bCmMOMwp4B','w68PaWl+','aBlHwpLDuQ==','wrTCs8K8wr5z','ChcWw5gF','wpnCpVpSwrs=','S3YWfw==','McKEwosDw6jDocOrd8K0w6NGRA4=','w5PDvMKCwoAKCcKQw5V2wqPDnEsk','w53DqsKiwrYaHMKFw4V+','w5HCgMOcw4Zx','bMOBBsOLwrvCukXDrhYKw6QkXQ==','G8OhL114w4jDmg==','worDgMOxIUbCjAh6w73Dl8OiYsOm','w5TDoE7CjWlWXcKTY8O7w4ZkEcOA','w4TCqcO8woA=','NcOcD254','CWPCj8OOwr9PEg==','W0LCkSU1dz4=','wrMoZSd/','Ul7CsTjCrA==','w5rClcObw4hf','wr/DnBzDscO7wq0KBQU=','wqHCrDHDicKG','fmrCncO+w4c=','w6JdCMOyfA==','WlrCrMOVw7Akw44TwoZZf0jCnsKqwqvDtsKAw6LDnMOew4UzHMKiwowkwpU8w6PDkV/CuyrCqcOswq7CrAvDgsKqO8O9wozCnATDg8Kcw48tcXR6w5PCucOkUcOuXMOYwqEJVMKvwpjCjw==','P8KXw6TDtTE=','wqDCsMKww7FG','w6Ziw7g=','FjMh','CgYXTCY=','f8OXI8OxMw==','w5PCuMOtwpfDpMO8JlvDtcO6','TWHCjyQS','w6wZbHxHbg==','wpfCgBnCuls=','Z8OFJMOePQ==','I3HCrMOmwpI=','RsOxAsOLwpU=','wq92w5XDlsOc','w6DDpFjDjMK9','wpjCpjLDp8Kv','wrUiwoczMA==','w77CscO3woch','GydBQcOa','e8O2NMODwrM=','fEzCu8Obw4U=','CHfDjsKBaw==','w5LCusOZwpXDjw==','acOOJ8O/wrY=','RsKww6XCqsKj','GBJCXsOFw7hMwrE=','aVd9REQ=','wpETLE7CrA==','wrnDksOWEGk=','bFnCqzUR','w51hFQ==','wrvCpi3DqsKj','w51Xbm7Dug==','w5XDt3/ChXQ=','w69ww5wUbw==','VDBywqXClsKOw67Dhw==','dFDCpcO3w5E=','w7PCrMKOIizDtcOmw5/Cqw==','fcODKMOZwrg=','azfDpMOWOWE=','aG3CjcOiw4EQw6A1wqg=','w51AJ8OLbA==','w7l4w716wpV+w40Vw6s=','wp7DkMOnFlfCmABhw7Y=','GzMRw7Mm','XMK9w7jCmsKx','byB7wqbDtw==','WQZWwqfDtw==','DMOmCEZDw4LDmmEiJw==','JVPCm8Orwqo=','w515Zl3DuQ==','w4nDgF3CjVA=','woYHwrE8CQ==','M8KLwqHDuw8=','MxMVQj0=','f8OLIcO7wqzCtUrDvA==','wrjCkR/Do8KgWBLDoMKiU0A=','wr7CgA3Ci8O2','wowmFjTCuA==','RD5VwrA=','wqAPwoQTEw==','6Ket5a+F6ZSw6K+h','WcOIBsKbwps=','KSYuw7g5','EsKxwrkSw5I=','woMVNHvCtA==','woPChj7DgMK8','wqLCtMK8wpVo','wr3CmDrDn8Kl','wrjDnB7DscO8wq0LBQY=','w4DDtVbCp2g=','w4VrAcOr','wpobdgtL','HkbDicKBWg==','w6gfUVdV','CcK2wr/Dsz/ChcOo','W0bCmTIadw==','wqsvEWrCtV/Chg==','w699SGrDt3s=','wr1ww7rDlMOF','eHDCjsOjw7QW','VmECf2MgQg==','XGcHaFob','woUlDHrCiw==','OMK7w7fDrxg=','woPCnMKVwopC','fUDCihrCig==','w6Vgw54eUg==','SxZLwrzCqw==','M0bClMOBwqs=','T8KFUMKhDg==','wq8AwpcAOw==','w6/CmcOIwoE=','bD1EwqfDvCQ4wow=','Z8OLFQ==','wo0cMw==','w7DCnsKfIBI=','IMKeJ8OVY8O4AA==','XxLDr8KXw6jDn8KeDcKVw73CvD9MPkl8csKzw7LCjgt0wrwUdFdGw4zCjxzCl0INScOjwqjDilpBw6rCqMKlw4YUw4/DnsKXwqhaf8OqwrrDtAvCosOawofDs8O5w4lkwpQOworDhgd0wolXw7/DkBfCsFk1w5BtLmfCocOSwr8gb1cxUcK2OsKPEzw9aUEUw6NuwpTCo07CrcOmwpRlfX8Hwr1nwrbDssOWF8Kaw5BYwojDsDEMw6TDi8KFEh3DrcKiw4zDmsKSwp7CnQ4Fw4zDgsK8w6/DuElHQ0VFw7FbwpvDjT4/w5g1RSPCnMKjwopvJsOywo5lw5jCiWA3wqEpOsKiMsOaC33CjsKXWMKNY8O+w6Vcc8KDQ8KHw73DisK8w6LChsKowptlwq3CgHrDicOaw4ITwqlNwq4iTsOKacO6woZeBsKIT8K4wrXDs1vCrD3CrsKWwqvCoMK+FMOTPxgUJwjCosKswobCuknDhsKzecOTwo0Kw7HCjAZQbj3Cm3s4w5YraMKAw5vCmcORXMOBN09kegnCkMOgcMOnU8Kzw6J9w7otTQfDisOdJcOqJRHCuDJnM8OeGCJVCMKiFQLDuk0sX8Kyw6fCqmYTBj0Qw5XCuWTCv8KBU8OXXy/DnVbCisOOMcOhVzgiw5BkwpNywqrCpFpdW0XDqMK0w5XCsWQuwo7DuHzCtsKMCsOwwrJKW8OfEVTCjMKMP8OuBMKQwoHCoQzDo8KdVsOYwrglTktSMMK0w7vDkMOtwrccwqXCiMOmwoI6woYSXVnChD3DuCLCrcOuwqDDoMOOI8ONwpjDs8OQeGfDjQ7Dgw7Cni/DrsOjwqhWOWoOZnzDqTrCpDHDlsKfRcKYFcOKEcKhw4rDng3CtsOPbsK0LGU1SjrCmsKtwqMkHMOKQVPCjsO1w4DDmsKkw4RENsKsaUjDnATDosKdw58Xw5jDocKhwq7CiURRw7DCt8O2w5fCnQYNw5LDi8KlPgLCkBEZw6xnDhvCkyAVdsO2J8Kdw41MwpYFwroywpfClCEXw7UrDWtgwpbDhBrCkFPCuxZdIcKGbntxI2XCn3UlLsOBecKqasO0wrl7SsOHcTIMwpt+w41fCMK8Gmk5wp9HHRTDpy7Cm09INMKyasKOwqgsw7A2eSDDq8Kbwo7CuMOveR3Co8KqDSXDiWIfw4LDvsKuDcOow4DDicKEDw7CqsOELMK/wpPDrhrDp3AfRCTDisK/OsOJfcKEwpwiw4XClyDDpmjCtTHChUfCtHrDtnZlw7ZiXFHCuGbCqMKDUcK+w7onS8OTw6PDhAYqRcKuwoYMLWhUbl0yUlAwFMODEVzCpgUIFT9cHjXCl1sQw5DCpMOvc8Osw4DDgD3DscOqw4UNBDdmw415DsOCwrFmB8O7w6TDh8OFwoPDpmc7woDCuMKhTMKHw4fDv8KWHBgvw41fa1bCv8OWw610QBjClEjDuMKETGLDun3CtMKPwrVcbH8Xwos0LMKRGDPCvMO8XmPDgcK7wpptP8O9wrYYCRbDrMKgw53CjGBOw4PDkMOVJ8KwB8OBw6Ekw6BKwox6KkvDoAnCucKIw7nCnSx5JsO5w5/DuDvCugI9w7pHw4Z9WsKnCsOlM8KPw6XCs8KswoTDr1sQfMKUw6LCm8OJUMOmSWRyGMKrBGPCmmdQGMKwQ3zCrWfDrMKcVMOgBsKcUsK5JWxmOlXCh8OYf8OJPlMXAHYVd8K5wpfCnMKBZEnDsGXDgkbCjMKYTcK/UcO5QEnCvUVjwrk5VMOyXFbDo8K7wrVfwp8pwo3CucORwq
function Env(t, e) { "undefined" != typeof process && JSON.stringify(process.env).indexOf("GITHUB") > -1 && process.exit(0); class s { constructor(t) { this.env = t } send(t, e = "GET") { t = "string" == typeof t ? { url: t } : t; let s = this.get; return "POST" === e && (s = this.post), new Promise((e, i) => { s.call(this, t, (t, s, r) => { t ? i(t) : e(s) }) }) } get(t) { return this.send.call(this.env, t) } post(t) { return this.send.call(this.env, t, "POST") } } return new class { constructor(t, e) { this.name = t, this.http = new s(this), this.data = null, this.dataFile = "box.dat", this.logs = [], this.isMute = !1, this.isNeedRewrite = !1, this.logSeparator = "\n", this.startTime = (new Date).getTime(), Object.assign(this, e), this.log("", `🔔${this.name}, 开始!`) } isNode() { return "undefined" != typeof module && !!module.exports } isQuanX() { return "undefined" != typeof $task } isSurge() { return "undefined" != typeof $httpClient && "undefined" == typeof $loon } isLoon() { return "undefined" != typeof $loon } toObj(t, e = null) { try { return JSON.parse(t) } catch { return e } } toStr(t, e = null) { try { return JSON.stringify(t) } catch { return e } } getjson(t, e) { let s = e; const i = this.getdata(t); if (i) try { s = JSON.parse(this.getdata(t)) } catch { } return s } setjson(t, e) { try { return this.setdata(JSON.stringify(t), e) } catch { return !1 } } getScript(t) { return new Promise(e => { this.get({ url: t }, (t, s, i) => e(i)) }) } runScript(t, e) { return new Promise(s => { let i = this.getdata("@chavy_boxjs_userCfgs.httpapi"); i = i ? i.replace(/\n/g, "").trim() : i; let r = this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout"); r = r ? 1 * r : 20, r = e && e.timeout ? e.timeout : r; const [o, h] = i.split("@"), n = { url: `http://${h}/v1/scripting/evaluate`, body: { script_text: t, mock_type: "cron", timeout: r }, headers: { "X-Key": o, Accept: "*/*" } }; this.post(n, (t, e, i) => s(i)) }).catch(t => this.logErr(t)) } loaddata() { if (!this.isNode()) return {}; { this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path"); const t = this.path.resolve(this.dataFile), e = this.path.resolve(process.cwd(), this.dataFile), s = this.fs.existsSync(t), i = !s && this.fs.existsSync(e); if (!s && !i) return {}; { const i = s ? t : e; try { return JSON.parse(this.fs.readFileSync(i)) } catch (t) { return {} } } } } writedata() { if (this.isNode()) { this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path"); const t = this.path.resolve(this.dataFile), e = this.path.resolve(process.cwd(), this.dataFile), s = this.fs.existsSync(t), i = !s && this.fs.existsSync(e), r = JSON.stringify(this.data); s ? this.fs.writeFileSync(t, r) : i ? this.fs.writeFileSync(e, r) : this.fs.writeFileSync(t, r) } } lodash_get(t, e, s) { const i = e.replace(/\[(\d+)\]/g, ".$1").split("."); let r = t; for (const t of i) if (r = Object(r)[t], void 0 === r) return s; return r } lodash_set(t, e, s) { return Object(t) !== t ? t : (Array.isArray(e) || (e = e.toString().match(/[^.[\]]+/g) || []), e.slice(0, -1).reduce((t, s, i) => Object(t[s]) === t[s] ? t[s] : t[s] = Math.abs(e[i + 1]) >> 0 == +e[i + 1] ? [] : {}, t)[e[e.length - 1]] = s, t) } getdata(t) { let e = this.getval(t); if (/^@/.test(t)) { const [, s, i] = /^@(.*?)\.(.*?)$/.exec(t), r = s ? this.getval(s) : ""; if (r) try { const t = JSON.parse(r); e = t ? this.lodash_get(t, i, "") : e } catch (t) { e = "" } } return e } setdata(t, e) { let s = !1; if (/^@/.test(e)) { const [, i, r] = /^@(.*?)\.(.*?)$/.exec(e), o = this.getval(i), h = i ? "null" === o ? null : o || "{}" : "{}"; try { const e = JSON.parse(h); this.lodash_set(e, r, t), s = this.setval(JSON.stringify(e), i) } catch (e) { const o = {}; this.lodash_set(o, r, t), s = this.setval(JSON.stringify(o), i) } } else s = this.setval(t, e); return s } getval(t) { return this.isSurge() || this.isLoon() ? $persistentStore.read(t) : this.isQuanX() ? $prefs.valueForKey(t) : this.isNode() ? (this.data = this.loaddata(), this.data[t]) : this.data && this.d