mirror of
https://github.com/shufflewzc/faker2.git
synced 2025-04-23 02:48:44 +08:00
update
This commit is contained in:
parent
f7e84615dd
commit
27c78f9f4c
318
fruit.ts
Normal file
318
fruit.ts
Normal file
@ -0,0 +1,318 @@
|
||||
import {sendNotify} from './sendNotify';
|
||||
import USER_AGENT, {get, getShareCodePool, o2s, requireConfig, wait} from './TS_USER_AGENTS'
|
||||
import {H5ST} from "./utils/h5st";
|
||||
|
||||
let cookie: string = '', res: any = '', data: any, UserName: string
|
||||
let shareCodeSelf: string[] = [], shareCodePool: string[] = [], shareCode: string[] = [], shareCodeFile: object = require('./jdFruitShareCodes')
|
||||
let message: string = '', h5stTool: H5ST = new H5ST("0c010", USER_AGENT, "8389547038003203")
|
||||
|
||||
!(async () => {
|
||||
let cookiesArr: string[] = await requireConfig()
|
||||
for (let [index, value] of cookiesArr.entries()) {
|
||||
cookie = value
|
||||
UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1])
|
||||
console.log(`\n开始【京东账号${index + 1}】${UserName}\n`)
|
||||
message += `【账号${index + 1}】 ${UserName}\n`
|
||||
await h5stTool.__genAlgo()
|
||||
|
||||
try {
|
||||
if (Object.keys(shareCodeFile)[index]) {
|
||||
shareCodeSelf = shareCodeFile[Object.keys(shareCodeFile)[index]].split('@')
|
||||
}
|
||||
console.log(`第${index + 1}个账号获取的内部互助`, shareCodeSelf)
|
||||
|
||||
// 初始化
|
||||
res = await api('initForFarm', {"version": 11, "channel": 3})
|
||||
o2s(res)
|
||||
|
||||
if (res.code === '6') {
|
||||
console.log('黑号')
|
||||
await wait(5000)
|
||||
continue
|
||||
}
|
||||
await wait(1000)
|
||||
if (res.todayGotWaterGoalTask.canPop) {
|
||||
data = await api('gotWaterGoalTaskForFarm', {"type": 3, "version": 14, "channel": 1, "babelChannel": "120"})
|
||||
o2s(data)
|
||||
console.log("弹窗获得水滴", data.addEnergy)
|
||||
}
|
||||
o2s(res, 'initForFarm')
|
||||
let totalEnergy: number = res.farmUserPro.totalEnergy // 背包剩余水滴
|
||||
if (res.farmUserPro.treeState === 2) {
|
||||
console.log("可以兑换奖品了")
|
||||
await sendNotify("东东农场", `账号${index + 1} ${UserName}\n\n已成熟`)
|
||||
} else if (res.farmUserPro.treeState === 0) {
|
||||
console.log("自动种植")
|
||||
}
|
||||
|
||||
// 添加好友
|
||||
|
||||
|
||||
// 删除好友
|
||||
res = await api('friendListInitForFarm', {"lastId": null, "version": 14, "channel": 1, "babelChannel": "120"})
|
||||
await wait(1000)
|
||||
if (!res.newFriendMsg) {
|
||||
for (let fr of res.friends) {
|
||||
res = await api('deleteFriendForFarm', {"shareCode": fr.shareCode, "version": 14, "channel": 1, "babelChannel": "121"})
|
||||
await wait(1000)
|
||||
if (res.code === '0') {
|
||||
console.log(`删除好友${fr.nickName}成功`)
|
||||
} else {
|
||||
console.log(`删除好友${fr.nickName}失败`)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 背包
|
||||
// process.env.jdFruitBeanCard = 'True'
|
||||
// if (process.env.jdFruitBeanCard.toLowerCase() === 'true') {
|
||||
// res = await api('myCardInfoForFarm', {"version": 14, "channel": 3, "babelChannel": "10"})
|
||||
// o2s(res, 'myCardInfoForFarm')
|
||||
// let beanCard: number = res.beanCard // 换豆卡
|
||||
// console.log('换豆卡数量', beanCard)
|
||||
// for (let i = 0; i < 10; i++) {
|
||||
// if (totalEnergy >= 100 && beanCard) {
|
||||
// data = await api('userMyCardForFarm', {"cardType": "beanCard", "babelChannel": "10", "channel": 3, "version": 14})
|
||||
// console.log('使用水滴换豆卡,获得京豆', data.beanCount)
|
||||
// totalEnergy -= 100
|
||||
// beanCard--
|
||||
// await wait(1000)
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// console.log('未设置水滴换豆卡环境变量')
|
||||
// }
|
||||
|
||||
|
||||
// 好友邀请奖励
|
||||
res = await api('friendListInitForFarm', {"lastId": null, "version": 14, "channel": 1, "babelChannel": "120"})
|
||||
o2s(res, 'friendListInitForFarm')
|
||||
let friendList: any[] = res.friends
|
||||
if (res.inviteFriendCount > res.inviteFriendGotAwardCount) {
|
||||
data = await api('awardInviteFriendForFarm', {})
|
||||
await wait(1000)
|
||||
o2s(data, '好友邀请奖励')
|
||||
}
|
||||
|
||||
// 给好友浇水
|
||||
res = await api('taskInitForFarm', {"version": 14, "channel": 1, "babelChannel": "120"})
|
||||
o2s(res, 'taskInitForFarm')
|
||||
await wait(1000)
|
||||
console.log(`今日已给${res.waterFriendTaskInit.waterFriendCountKey}个好友浇水`);
|
||||
if (res.waterFriendTaskInit.waterFriendCountKey < res.waterFriendTaskInit.waterFriendMax) {
|
||||
for (let i = res.waterFriendTaskInit.waterFriendCountKey; i < res.waterFriendTaskInit.waterFriendMax; i++) {
|
||||
for (let fr of friendList) {
|
||||
if (fr.friendState === 1) {
|
||||
data = await api('waterFriendForFarm', {"shareCode": fr.shareCode, "version": 14, "channel": 1, "babelChannel": "120"})
|
||||
if (data.code === '0')
|
||||
console.log(`给好友${fr.nickName}浇水成功`)
|
||||
if (data.cardInfo) {
|
||||
console.log('获得卡片')
|
||||
}
|
||||
await wait(2000)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (res.waterFriendTaskInit.waterFriendCountKey === res.waterFriendTaskInit.waterFriendMax && !res.waterFriendTaskInit.waterFriendGotAward) {
|
||||
data = await api('waterFriendGotAwardForFarm', {"version": 14, "channel": 1, "babelChannel": "120"})
|
||||
console.log('给好友浇水奖励', data.addWater)
|
||||
await wait(1000)
|
||||
}
|
||||
|
||||
// 签到
|
||||
res = await api('clockInInitForFarm', {"timestamp": Date.now(), "version": 14, "channel": 1, "babelChannel": "120"})
|
||||
await wait(1000)
|
||||
if (!res.todaySigned) {
|
||||
data = await api('clockInForFarm', {"type": 1, "version": 14, "channel": 1, "babelChannel": "120"})
|
||||
if (data.signDay === 7) {
|
||||
// data = await api('gotClockInGift', {"type": 2, "version": 14, "channel": 1, "babelChannel": "120"})
|
||||
// o2s(data, 'gotClockInGift')
|
||||
// await wait(1000)
|
||||
}
|
||||
await wait(1000)
|
||||
}
|
||||
|
||||
res = await api('clockInInitForFarm', {"timestamp": Date.now(), "version": 14, "channel": 1, "babelChannel": "120"})
|
||||
for (let t of res.themes || []) {
|
||||
if (!t.hadGot) {
|
||||
console.log('关注', t.name)
|
||||
res = await api('clockInFollowForFarm', {"id": t.id, "type": "theme", "step": 1, "version": 14, "channel": 1, "babelChannel": "120"})
|
||||
await wait(5000)
|
||||
res = await api('clockInFollowForFarm', {"id": t.id, "type": "theme", "step": 2, "version": 14, "channel": 1, "babelChannel": "120"})
|
||||
console.log('获得水滴', res.amount)
|
||||
}
|
||||
}
|
||||
|
||||
// 任务
|
||||
res = await api('taskInitForFarm', {"version": 14, "channel": 1, "babelChannel": "120"})
|
||||
o2s(res)
|
||||
if (res.signInit.todaySigned) {
|
||||
console.log(`今天已签到,已经连续签到${res.signInit.totalSigned}天,下次签到可得${res.signInit.signEnergyEachAmount}g`);
|
||||
} else {
|
||||
data = await api('signForFarm', {"version": 14, "channel": 1, "babelChannel": "120"})
|
||||
o2s(data, 'signForFarm')
|
||||
|
||||
console.log('签到成功', data.amount)
|
||||
await wait(1000)
|
||||
}
|
||||
|
||||
if (!res.gotBrowseTaskAdInit.f) {
|
||||
for (let t of res.gotBrowseTaskAdInit.userBrowseTaskAds) {
|
||||
if (t.hadFinishedTimes !== t.limit) {
|
||||
data = await api('browseAdTaskForFarm', {"advertId": t.advertId, "type": 0, "version": 14, "channel": 1, "babelChannel": "120"})
|
||||
o2s(data, 'browseAdTaskForFarm')
|
||||
await wait(t.time * 1000 || 1000)
|
||||
data = await api('browseAdTaskForFarm', {"advertId": t.advertId, "type": 1, "version": 14, "channel": 1, "babelChannel": "120"})
|
||||
console.log('任务完成,获得', data.amount)
|
||||
}
|
||||
await wait(1000)
|
||||
}
|
||||
}
|
||||
|
||||
if (!res.gotThreeMealInit.f) {
|
||||
if (![10, 15, 16, 22, 23].includes(new Date().getHours())) {
|
||||
data = await api('gotThreeMealForFarm', {"version": 14, "channel": 1, "babelChannel": "120"})
|
||||
if (data.code === '0') {
|
||||
console.log('定时奖励成功', data.amount)
|
||||
}
|
||||
await wait(1000)
|
||||
}
|
||||
}
|
||||
|
||||
if (!res.waterRainInit.f) {
|
||||
if (Date.now < res.waterRainInit.lastTime + 3 * 60 * 60 * 1000) {
|
||||
data = await api('waterRainForFarm', {"type": 1, "hongBaoTimes": 100, "version": 3})
|
||||
o2s(data, 'waterRainForFarm')
|
||||
if (data.code === '0') {
|
||||
console.log('获得水滴', data.addEnergy)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!res.firstWaterInit.f && res.firstWaterInit.totalWaterTimes !== 0) {
|
||||
data = await api('firstWaterTaskForFarm', {"version": 14, "channel": 1, "babelChannel": "120"})
|
||||
console.log('firstWaterTaskForFarm', data.amount)
|
||||
}
|
||||
|
||||
// 红包
|
||||
res = await api('initForTurntableFarm', {"version": 4, "channel": 1})
|
||||
o2s(res, 'initForTurntableFarm')
|
||||
for (let t of res.turntableBrowserAds) {
|
||||
if (!t.status) {
|
||||
console.log("browserForTurntableFarm", t.main)
|
||||
data = await api('browserForTurntableFarm', {"type": 1, "adId": t.adId, "version": 4, "channel": 1})
|
||||
await wait(t.browserTimes * 1000 || 1000)
|
||||
data = await api('browserForTurntableFarm', {"type": 2, "adId": t.adId, "version": 4, "channel": 1})
|
||||
}
|
||||
}
|
||||
|
||||
if (!res.timingGotStatus && res.remainLotteryTimes) {
|
||||
if (Date.now() > (res.timingLastSysTime + 60 * 60 * res.timingIntervalHours * 1000)) {
|
||||
data = await api('timingAwardForTurntableFarm', {"version": 4, "channel": 1})
|
||||
await wait(1000)
|
||||
o2s(data, 'timingAwardForTurntableFarm')
|
||||
} else {
|
||||
console.log(`免费赠送的抽奖机会未到时间`)
|
||||
}
|
||||
}
|
||||
|
||||
// 天天红包助力
|
||||
shareCodePool = await getShareCodePool('farm', 30)
|
||||
shareCode = Array.from(new Set([...shareCodeSelf, ...shareCodePool]))
|
||||
for (let code of shareCodeSelf) {
|
||||
console.log('去红包助力', code)
|
||||
data = await api('initForFarm', {"shareCode": `${code}-3`, "lng": "0.000000", "lat": "0.000000", "sid": "2871ac0252645ef0e2731aa7d03c1d3w", "un_area": "16_1341_1347_44750", "version": 14, "channel": 1, "babelChannel": 0})
|
||||
await wait(3000)
|
||||
if (data.code === '0') {
|
||||
console.log('红包助力成功')
|
||||
} else if (data.code === '11') {
|
||||
console.log('红包已助力过')
|
||||
} else if (data.code === '13') {
|
||||
console.log('上限')
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// 抽奖
|
||||
for (let i = 0; i < res.remainLotteryTimes; i++) {
|
||||
data = await api('lotteryForTurntableFarm', {"type": 1, "version": 4, "channel": 1})
|
||||
if (data.type === 'thanks') {
|
||||
console.log('抽奖获得 空气')
|
||||
} else {
|
||||
console.log('抽奖获得', data.type)
|
||||
}
|
||||
await wait(2000)
|
||||
}
|
||||
|
||||
// 助力
|
||||
shareCodePool = await getShareCodePool('farm', 30)
|
||||
shareCode = Array.from(new Set([...shareCodeSelf, ...shareCodePool]))
|
||||
for (let code of shareCodeSelf) {
|
||||
console.log('去助力', code)
|
||||
res = await api('initForFarm', {"mpin": "", "utm_campaign": "t_335139774", "utm_medium": "appshare", "shareCode": code, "utm_term": "Wxfriends", "utm_source": "iosapp", "imageUrl": "", "nickName": "", "version": 14, "channel": 2, "babelChannel": 0})
|
||||
await wait(6000)
|
||||
o2s(res, '助力')
|
||||
if (res.helpResult.code === '7') {
|
||||
console.log('不给自己助力')
|
||||
} else if (res.helpResult.code === '0') {
|
||||
console.log('助力成功,获得', res.helpResult.salveHelpAddWater)
|
||||
} else if (res.helpResult.code === '8') {
|
||||
console.log('上限')
|
||||
break
|
||||
} else if (res.helpResult.code === '9') {
|
||||
console.log('已助力')
|
||||
} else if (res.helpResult.code === '10') {
|
||||
console.log('已满')
|
||||
} else if (res.helpResult.remainTimes === 0) {
|
||||
console.log('次数用完')
|
||||
break
|
||||
}
|
||||
}
|
||||
// 助力奖励
|
||||
res = await api('farmAssistInit', {"version": 14, "channel": 1, "babelChannel": "120"})
|
||||
await wait(1000)
|
||||
o2s(res, 'farmAssistInit')
|
||||
let farmAssistInit_waterEnergy: number = 0
|
||||
for (let t of res.assistStageList) {
|
||||
if (t.percentage === '100%' && t.stageStaus === 2) {
|
||||
data = await api('receiveStageEnergy', {"version": 14, "channel": 1, "babelChannel": "120"})
|
||||
await wait(1000)
|
||||
farmAssistInit_waterEnergy += t.waterEnergy
|
||||
} else if (t.stageStaus === 3) {
|
||||
farmAssistInit_waterEnergy += t.waterEnergy
|
||||
}
|
||||
}
|
||||
console.log('收到助力', res.assistFriendList.length)
|
||||
console.log('助力已领取', farmAssistInit_waterEnergy)
|
||||
message += `【助力已领取】 ${farmAssistInit_waterEnergy}\n`
|
||||
|
||||
message += '\n\n'
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
} finally {
|
||||
await wait(5000)
|
||||
}
|
||||
}
|
||||
if (message)
|
||||
await sendNotify('东东农场', message)
|
||||
})()
|
||||
|
||||
async function api(fn: string, body: object) {
|
||||
let h5st: string = h5stTool.__genH5st({
|
||||
'appid': 'wh5',
|
||||
'body': JSON.stringify(body),
|
||||
'client': 'apple',
|
||||
'clientVersion': '10.2.4',
|
||||
'functionId': fn,
|
||||
})
|
||||
return await get(`https://api.m.jd.com/client.action?functionId=${fn}&body=${JSON.stringify(body)}&appid=wh5&client=apple&clientVersion=10.2.4&h5st=${h5st}`, {
|
||||
"Host": "api.m.jd.com",
|
||||
"Origin": "https://carry.m.jd.com",
|
||||
"User-Agent": USER_AGENT,
|
||||
"Accept-Language": "zh-CN,zh-Hans;q=0.9",
|
||||
"Referer": "https://carry.m.jd.com/",
|
||||
"Cookie": cookie
|
||||
})
|
||||
}
|
178
jd_19_5.js
Normal file
178
jd_19_5.js
Normal file
File diff suppressed because one or more lines are too long
139
jd_bean_box.ts
Normal file
139
jd_bean_box.ts
Normal file
@ -0,0 +1,139 @@
|
||||
/**
|
||||
* 领京豆-任务
|
||||
* 助力:内部 -> HW
|
||||
* cron: 1 0,9,12,18 * * *
|
||||
*/
|
||||
|
||||
import axios from 'axios'
|
||||
import USER_AGENT, {get, randomNumString, requireConfig, wait} from './TS_USER_AGENTS'
|
||||
|
||||
let cookie: string = '', res: any = '', UserName: string, index: number, uuid: string
|
||||
// let shareCodeSelf: { shareCode: string, groupCode: string, activeId: string }[] = [], shareCode: { shareCode: string, groupCode: string, activeId: string }[] = [], shareCodeHW: { shareCode: string, groupCode: string, activeId: string }[] = []
|
||||
|
||||
!(async () => {
|
||||
let cookiesArr: string[] = await requireConfig()
|
||||
for (let i = 0; i < cookiesArr.length; i++) {
|
||||
cookie = cookiesArr[i]
|
||||
UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1])
|
||||
index = i + 1
|
||||
console.log(`\n开始【京东账号${index}】${UserName}\n`)
|
||||
|
||||
let headers: object = {
|
||||
'Host': 'api.m.jd.com',
|
||||
'Origin': 'https://h5.m.jd.com',
|
||||
'User-Agent': USER_AGENT,
|
||||
'Referer': 'https://h5.m.jd.com/',
|
||||
'Cookie': cookie
|
||||
}
|
||||
res = await get('https://api.m.jd.com/client.action?functionId=initForTurntableFarm&body=%7B%22version%22%3A4%2C%22channel%22%3A1%7D&appid=wh5', headers)
|
||||
let times: number = res.remainLotteryTimes
|
||||
console.log('剩余抽奖机会:', times)
|
||||
for (let j = 0; j < times; j++) {
|
||||
console.log('开始抽奖...')
|
||||
res = await get('https://api.m.jd.com/client.action?functionId=lotteryForTurntableFarm&body=%7B%22type%22%3A1%2C%22version%22%3A4%2C%22channel%22%3A1%7D&appid=wh5', headers)
|
||||
if (res.code === '0') {
|
||||
if (res.type === 'thanks') {
|
||||
console.log('抽奖成功,获得:狗屁')
|
||||
} else {
|
||||
console.log('抽奖成功,获得:', res.type)
|
||||
}
|
||||
} else {
|
||||
console.log('抽奖失败', res)
|
||||
}
|
||||
await wait(5000)
|
||||
}
|
||||
|
||||
uuid = randomNumString(40)
|
||||
for (let j = 0; j < 2; j++) {
|
||||
console.log(`Round:${j + 1}`)
|
||||
res = await api('beanTaskList', {"viewChannel": "AppHome"})
|
||||
try {
|
||||
for (let t of res.data.taskInfos) {
|
||||
if (t.status === 1) {
|
||||
console.log(t.taskName)
|
||||
res = await api('beanDoTask', {
|
||||
"actionType": t.taskType === 3 ? 0 : 1,
|
||||
"taskToken": t.subTaskVOS[0].taskToken
|
||||
})
|
||||
res.data?.bizMsg ? console.log(res.data.bizMsg) : console.log(res)
|
||||
await wait(t.waitDuration * 1000 || 2000)
|
||||
|
||||
if (t.taskType !== 3) {
|
||||
res = await api('beanDoTask', {
|
||||
"actionType": 0,
|
||||
"taskToken": t.subTaskVOS[0].taskToken
|
||||
})
|
||||
if (res.data?.bizMsg)
|
||||
console.log(res.data.bizMsg)
|
||||
}
|
||||
await wait(1000)
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('Error!', e)
|
||||
}
|
||||
await wait(2000)
|
||||
}
|
||||
|
||||
// 抢京豆
|
||||
/*
|
||||
res = await qjd('signBeanGroupStageIndex', {"monitor_refer": "", "rnVersion": "3.9", "fp": "-1", "shshshfp": "-1", "shshshfpa": "-1", "referUrl": "-1", "userAgent": "-1", "jda": "-1", "monitor_source": "bean_m_bean_index"})
|
||||
if (!res.data.shareCode) {
|
||||
console.log('抢京豆 init...')
|
||||
res = await qjd('signGroupHit', {"activeType": 2})
|
||||
await wait(1000)
|
||||
res = await qjd('signBeanGroupStageIndex', {"monitor_refer": "", "rnVersion": "3.9", "fp": "-1", "shshshfp": "-1", "shshshfpa": "-1", "referUrl": "-1", "userAgent": "-1", "jda": "-1", "monitor_source": "bean_m_bean_index"})
|
||||
}
|
||||
if (res.data.shareCode) {
|
||||
console.log('助力码', res.data.shareCode)
|
||||
shareCodeSelf.push({shareCode: res.data.shareCode, groupCode: res.data.groupCode, activeId: res.data.jklInfo.keyId})
|
||||
await wait(2000)
|
||||
}
|
||||
}
|
||||
|
||||
console.log('内部助力', shareCodeSelf)
|
||||
for (let i = 0; i < cookiesArr.length; i++) {
|
||||
if (shareCodeHW.length === 0) {
|
||||
await getShareCodeHW()
|
||||
}
|
||||
shareCode = [...shareCodeSelf, ...shareCodeHW]
|
||||
uuid = randomString(40)
|
||||
cookie = cookiesArr[i]
|
||||
UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1])
|
||||
for (let code of shareCode) {
|
||||
console.log(`${UserName} 去助力 ${code.shareCode}`)
|
||||
res = await qjd('signGroupHelp', {"activeType": 2, "groupCode": code.groupCode, "shareCode": code.shareCode, "activeId": code.activeId, "source": "guest"})
|
||||
console.log(res.data?.helpToast)
|
||||
if (res.data.respCode === 'SG209')
|
||||
break
|
||||
await wait(2000)
|
||||
}
|
||||
*/
|
||||
}
|
||||
})()
|
||||
|
||||
async function api(fn: string, body: object) {
|
||||
let {data}: any = await axios.post(`https://api.m.jd.com/client.action?functionId=${fn}`,
|
||||
`body=${encodeURIComponent(JSON.stringify(body))}&appid=ld&client=apple&clientVersion=10.0.8&uuid=${uuid}&openudid=${uuid}`, {
|
||||
headers: {
|
||||
'Host': 'api.m.jd.com',
|
||||
'content-type': 'application/x-www-form-urlencoded',
|
||||
'referer': '',
|
||||
'user-agent': 'JD4iPhone/167863%20(iPhone;%20iOS;%20Scale/3.00)',
|
||||
'Cookie': cookie
|
||||
}
|
||||
})
|
||||
return data
|
||||
}
|
||||
|
||||
/*async function qjd(fn: string, body?: object) {
|
||||
let {data} = await axios.get(`https://api.m.jd.com/client.action?functionId=${fn}&body=${encodeURIComponent(JSON.stringify(body))}&appid=ld&client=apple&clientVersion=10.0.8&uuid=${uuid}&openudid=${uuid}`, {
|
||||
headers: {
|
||||
'Host': 'api.m.jd.com',
|
||||
'User-Agent': USER_AGENT,
|
||||
'Referer': 'https://h5.m.jd.com/rn/3MQXMdRUTeat9xqBSZDSCCAE9Eqz/index.html',
|
||||
'Cookie': cookie
|
||||
}
|
||||
})
|
||||
return data
|
||||
}*/
|
37
jd_dpqd.js
37
jd_dpqd.js
@ -25,27 +25,26 @@ let vender=''
|
||||
let num=0
|
||||
let shopname=''
|
||||
const token = [
|
||||
"5A5DDD7A9538CE94B97038C83661814E",
|
||||
"35D4DA3E0543F4E5BE9B064A168EB8FC",
|
||||
"07D72B6BEC5DDC95E475D019FA89F39D",
|
||||
"BB66511DCB566F6348291EAEB6F42D63",
|
||||
"BB75EC65052F079C46028E6138658A7C",
|
||||
"E20BD5091D8F70B4649D529A09183F04",
|
||||
"D80A58B6F00DE6A6D1220AF8D31FD7DC",
|
||||
"72F2D2763CC3F2EA466EA66D75FBCE19",
|
||||
"B855B744C0E57CC72B97DC3A79C16372",
|
||||
"3ABF873A139B3581FC039CCD3F35E73F",
|
||||
"D06B3EABDA970A2D3EB09959A0FA1B8B",
|
||||
"55903E776291DDC7E2C785A4659EC4CB",
|
||||
"CDDABF3428C94BFF4575B7C712F3E233",
|
||||
"46CF055009756611524DFC1EC56BF287",
|
||||
"62F921549D1B7244101CCC5AFBC2E952",
|
||||
"A3B3E3A15E365F2F5709618D27C9DDCD",
|
||||
"80E78A5F090820E5B1754E17E1485D3F",
|
||||
"B3E1665D2154B1CCF6FA036F53D28707",
|
||||
"02BC0ECE5C47F27DD21BEBB0B0DFDB88",
|
||||
"A0D5832C2A4A942DBFBC0816BA6691C8",
|
||||
"7127A3861F6478043B1BF112803B9A25",
|
||||
"7C513EAE76DCB43D86E0C64762719976",
|
||||
"D88BAFF737E9C4295F973732214F5DE5",
|
||||
"3C40932565A6F6E69237E17773D907AA",
|
||||
"63F7C22BEBF3EB981821C9188C8EB8EE",
|
||||
"FE30AB00038CFFEF00DA9E9B8E932721",
|
||||
"F0C24D7588D90922393B423C6623F31A",
|
||||
"7DB2D4F64C26D480216C14DB846BC52A",
|
||||
"12354835F829F4D14665FA0B78486D73",
|
||||
"D78133EA70D91C06D9CEE0738B5CD1C3"
|
||||
"D881655EDC90A9B4387ACFE495CA3F18",
|
||||
"A2AA33A7E1E40FBD7DA60DCEEB7DDD59",
|
||||
"A450EC209D203EDF09D5FE7A10B74626",
|
||||
"164E5ED72ECB8B6CC85E722A380D0D47",
|
||||
"3AF4B68A4BB3BD09D371B766E6A1B721",
|
||||
"37C465E26FCFFCFC72B991036CBC6A79",
|
||||
"7C071F9A6D11D5F26B83CF6BB91D2E89",
|
||||
"3D2F9CF0C806133D3C64949F06CD4A80",
|
||||
"19FC5C93948E015ED82F4740299F95FD"
|
||||
]
|
||||
|
||||
if ($.isNode()) {
|
||||
|
330
jd_fc_winner.js
Normal file
330
jd_fc_winner.js
Normal file
File diff suppressed because one or more lines are too long
443
jd_fruit.js
443
jd_fruit.js
File diff suppressed because one or more lines are too long
@ -6,15 +6,18 @@
|
||||
* CK2~n 内部 -> HW.ts
|
||||
*/
|
||||
|
||||
import axios from 'axios'
|
||||
import {sendNotify} from './sendNotify'
|
||||
import {get, getshareCodeHW, o2s, requireConfig, wait} from "./TS_USER_AGENTS"
|
||||
import * as dotenv from 'dotenv'
|
||||
import {get, post, getshareCodeHW, o2s, requireConfig, wait} from "./TS_USER_AGENTS"
|
||||
|
||||
let rabbitToken: string = process.env.RABBIT_TOKEN || '', tg_id: string = process.env.TG_ID || ''
|
||||
let cookie: string, cookiesArr: string[] = [], res: any, UserName: string
|
||||
let ua: string = "Mozilla/5.0 (Linux; U; Android 8.0.0; zh-cn; Mi Note 2 Build/OPR1.170623.032) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/61.0.3163.128 Mobile Safari/537.36 XiaoMi/MiuiBrowser/10.1.1"
|
||||
let shareCodesSelf: string[] = [], shareCodes: string[] = [], shareCodesHW: string[] = [], fullCode: string[] = []
|
||||
let min: number[] = [0.02, 0.03, 0.12, 0.3, 0.4, 0.6, 0.7, 0.8, 1, 1.2, 2, 3.6], log: string
|
||||
|
||||
!(async () => {
|
||||
dotenv.config()
|
||||
cookiesArr = await requireConfig(false)
|
||||
cookiesArr = cookiesArr.slice(0, 1)
|
||||
await join()
|
||||
@ -22,11 +25,12 @@ let min: number[] = [0.02, 0.03, 0.12, 0.3, 0.4, 0.6, 0.7, 0.8, 1, 1.2, 2, 3.6],
|
||||
|
||||
cookiesArr = await requireConfig(false)
|
||||
cookiesArr = cookiesArr.slice(0, 9)
|
||||
if (new Date().getHours() !== 6)
|
||||
if ([0, 1].includes(new Date().getHours())) {
|
||||
await join()
|
||||
}
|
||||
await getShareCodeSelf()
|
||||
await help()
|
||||
await open(1)
|
||||
await open(0)
|
||||
})()
|
||||
|
||||
async function join() {
|
||||
@ -40,11 +44,11 @@ async function join() {
|
||||
log = await getLog()
|
||||
res = await api('h5launch', {followShop: 0, random: log.match(/"random":"(\d+)"/)[1], log: log.match(/"log":"(.*)"/)[1], sceneid: 'JLHBhPageh5'})
|
||||
console.log('活动初始化:', res.data.result.statusDesc)
|
||||
if (res.rtn_code !== 403) {
|
||||
if (res.rtn_code === 0) {
|
||||
break
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('log error', e)
|
||||
console.log('join error', res.rtn_code)
|
||||
await wait(3000)
|
||||
}
|
||||
}
|
||||
@ -143,8 +147,8 @@ async function help() {
|
||||
if (success) break
|
||||
log = await getLog()
|
||||
res = await api('jinli_h5assist', {"redPacketId": code, "followShop": 0, random: log.match(/"random":"(\d+)"/)[1], log: log.match(/"log":"(.*)"/)[1], sceneid: 'JLHBhPageh5'})
|
||||
if (res.rtn_code === 403) {
|
||||
console.log('log error')
|
||||
if (res.rtn_code !== 0) {
|
||||
console.log('help error', res.rtn_code)
|
||||
await wait(5000)
|
||||
} else {
|
||||
success = true
|
||||
@ -177,20 +181,18 @@ async function help() {
|
||||
}
|
||||
|
||||
async function api(fn: string, body: object) {
|
||||
let {data} = await axios.post(`https://api.m.jd.com/api?appid=jinlihongbao&functionId=${fn}&loginType=2&client=jinlihongbao&clientVersion=10.2.4&osVersion=AndroidOS&d_brand=Xiaomi&d_model=Xiaomi`, `body=${encodeURIComponent(JSON.stringify(body))}`, {
|
||||
headers: {
|
||||
return await post(`https://api.m.jd.com/api?appid=jinlihongbao&functionId=${fn}&loginType=2&client=jinlihongbao&clientVersion=10.2.4&osVersion=AndroidOS&d_brand=Xiaomi&d_model=Xiaomi`, `body=${encodeURIComponent(JSON.stringify(body))}`, {
|
||||
"origin": "https://h5.m.jd.com",
|
||||
"referer": "https://h5.m.jd.com/babelDiy/Zeus/2NUvze9e1uWf4amBhe1AV6ynmSuH/index.html",
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
"X-Requested-With": "com.jingdong.app.mall",
|
||||
"User-Agent": "Mozilla/5.0 (Linux; U; Android 8.0.0; zh-cn; Mi Note 2 Build/OPR1.170623.032) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/61.0.3163.128 Mobile Safari/537.36 XiaoMi/MiuiBrowser/10.1.1",
|
||||
"User-Agent": ua,
|
||||
"Cookie": cookie,
|
||||
}
|
||||
})
|
||||
return data
|
||||
}
|
||||
|
||||
async function getLog() {
|
||||
if (!rabbitToken && !tg_id) {
|
||||
let data = await get(`https://api.jdsharecode.xyz/api/jlhb`)
|
||||
if (data !== 1 && data !== '1') {
|
||||
return data
|
||||
@ -198,4 +200,17 @@ async function getLog() {
|
||||
console.log('No log')
|
||||
process.exit(0)
|
||||
}
|
||||
} else {
|
||||
console.log('rabbit log')
|
||||
let data: any = ''
|
||||
for (let i = 0; i < 10; i++) {
|
||||
try {
|
||||
data = await get(`http://www.madrabbit.cf:8080/license/log?tg_id=${tg_id}&token=${rabbitToken}`)
|
||||
break
|
||||
} catch (e) {
|
||||
console.log('rabbit log api error')
|
||||
}
|
||||
}
|
||||
return `'"random":"${data.data.random}","log":"${data.data.log}"'`
|
||||
}
|
||||
}
|
198
jd_joy_park_run.ts
Normal file
198
jd_joy_park_run.ts
Normal file
@ -0,0 +1,198 @@
|
||||
/**
|
||||
* 汪汪乐园-跑步+组队
|
||||
* 默认翻倍到0.04红包结束
|
||||
* export JD_JOY_PARK_RUN_ASSETS="0.04"
|
||||
* cron: 20 * * * *
|
||||
*/
|
||||
|
||||
import {get, post, requireConfig, wait} from './TS_USER_AGENTS'
|
||||
import {H5ST} from "./utils/h5st"
|
||||
import {existsSync, readFileSync} from "fs";
|
||||
import {getDate} from "date-fns";
|
||||
|
||||
let cookie: string = '', res: any = '', UserName: string = ''
|
||||
let assets: number = 0.04, captainId: string = '', h5stTool: H5ST = new H5ST('b6ac3', 'jdltapp;', '1804945295425750')
|
||||
|
||||
!(async () => {
|
||||
let cookiesArr: string[] = await requireConfig()
|
||||
let account: { pt_pin: string, joy_park_run: number }[] = []
|
||||
if (existsSync('./utils/account.json')) {
|
||||
try {
|
||||
account = JSON.parse(readFileSync('./utils/account.json').toString())
|
||||
} catch (e) {
|
||||
console.log('./utils/account.json 加载出错')
|
||||
}
|
||||
}
|
||||
|
||||
for (let [index, value] of cookiesArr.entries()) {
|
||||
cookie = value
|
||||
UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1])
|
||||
console.log(`\n开始【京东账号${index + 1}】${UserName}\n`)
|
||||
|
||||
assets = parseFloat(process.env.JD_JOY_PARK_RUN_ASSETS || '0.04')
|
||||
for (let user of account) {
|
||||
if (user.pt_pin === encodeURIComponent(UserName) && user.joy_park_run) {
|
||||
console.log('自定义终点', user.joy_park_run)
|
||||
assets = parseFloat(user.joy_park_run.toString())
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
res = await team('runningMyPrize', {"linkId": "L-sOanK_5RJCz7I314FpnQ", "pageSize": 20, "time": null, "ids": null})
|
||||
let sum: number = 0
|
||||
for (let t of res.data.detailVos) {
|
||||
if (getDate(new Date(t.createTime)) === new Date().getDate()) {
|
||||
sum = add(sum, t.amount)
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
console.log('今日收益', sum)
|
||||
|
||||
await h5stTool.__genAlgo()
|
||||
res = await team('runningTeamInfo', {"linkId": "L-sOanK_5RJCz7I314FpnQ"})
|
||||
if (!captainId && res.data.members.length === 0) {
|
||||
console.log('组队ID不存在,开始创建组队')
|
||||
captainId = res.data.captainId
|
||||
} else if (captainId && res.data.members.length === 0) {
|
||||
console.log('已有组队ID,未加入队伍')
|
||||
res = await team('runningJoinTeam', {"linkId": "L-sOanK_5RJCz7I314FpnQ", "captainId": captainId})
|
||||
if (res.code === 0) {
|
||||
console.log('组队成功')
|
||||
for (let member of res.data.members) {
|
||||
if (member.captain) {
|
||||
console.log('队长', member.nickName)
|
||||
break
|
||||
}
|
||||
}
|
||||
if (res.data.members.length === 6) {
|
||||
console.log('队伍已满')
|
||||
captainId = ''
|
||||
}
|
||||
}
|
||||
} else {
|
||||
console.log('已组队', res.data.members.length)
|
||||
console.log('战队收益', res.data.teamSumPrize)
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('组队 Error', e)
|
||||
}
|
||||
|
||||
try {
|
||||
res = await runningPageHome()
|
||||
console.log('🧧', res.data.runningHomeInfo.prizeValue)
|
||||
await wait(2000)
|
||||
|
||||
console.log('能量恢复中', secondsToMinutes(res.data.runningHomeInfo.nextRunningTime / 1000), '能量棒', res.data.runningHomeInfo.energy)
|
||||
if (res.data.runningHomeInfo.nextRunningTime && res.data.runningHomeInfo.nextRunningTime / 1000 < 300) {
|
||||
await wait(res.data.runningHomeInfo.nextRunningTime)
|
||||
res = await runningPageHome()
|
||||
console.log('能量恢复中', secondsToMinutes(res.data.runningHomeInfo.nextRunningTime / 1000), '能量棒', res.data.runningHomeInfo.energy)
|
||||
await wait(1000)
|
||||
}
|
||||
|
||||
if (!res.data.runningHomeInfo.nextRunningTime) {
|
||||
console.log('终点目标', assets)
|
||||
for (let i = 0; i < 10; i++) {
|
||||
res = await api('runningOpenBox', {"linkId": "L-sOanK_5RJCz7I314FpnQ"})
|
||||
if (parseFloat(res.data.assets) >= assets) {
|
||||
let assets: number = parseFloat(res.data.assets)
|
||||
res = await api('runningPreserveAssets', {"linkId": "L-sOanK_5RJCz7I314FpnQ"})
|
||||
console.log('领取成功', assets)
|
||||
break
|
||||
} else {
|
||||
if (res.data.doubleSuccess) {
|
||||
console.log('翻倍成功', parseFloat(res.data.assets))
|
||||
await wait(5000)
|
||||
} else if (!res.data.doubleSuccess && !res.data.runningHomeInfo.runningFinish) {
|
||||
console.log('开始跑步', parseFloat(res.data.assets))
|
||||
await wait(5000)
|
||||
} else {
|
||||
console.log('翻倍失败')
|
||||
break
|
||||
}
|
||||
}
|
||||
await wait(5000)
|
||||
}
|
||||
}
|
||||
|
||||
res = await runningPageHome()
|
||||
console.log('🧧', res.data.runningHomeInfo.prizeValue)
|
||||
await wait(2000)
|
||||
} catch (e) {
|
||||
console.log('跑步 Error', e)
|
||||
}
|
||||
}
|
||||
})()
|
||||
|
||||
async function api(fn: string, body: object) {
|
||||
let timestamp: number = Date.now(), h5st: string = ''
|
||||
if (fn === 'runningOpenBox') {
|
||||
h5st = h5stTool.__genH5st({
|
||||
appid: "activities_platform",
|
||||
body: JSON.stringify(body),
|
||||
client: "ios",
|
||||
clientVersion: "3.1.0",
|
||||
functionId: "runningOpenBox",
|
||||
t: timestamp.toString()
|
||||
})
|
||||
}
|
||||
let params: string = `functionId=${fn}&body=${JSON.stringify(body)}&t=${timestamp}&appid=activities_platform&client=ios&clientVersion=3.1.0&cthr=1`
|
||||
h5st && (params += `&h5st=${h5st}`)
|
||||
return await post('https://api.m.jd.com/', params, {
|
||||
'authority': 'api.m.jd.com',
|
||||
'content-type': 'application/x-www-form-urlencoded',
|
||||
'cookie': cookie,
|
||||
'origin': 'https://h5platform.jd.com',
|
||||
'referer': 'https://h5platform.jd.com/',
|
||||
'user-agent': 'jdltapp;'
|
||||
})
|
||||
}
|
||||
|
||||
async function runningPageHome() {
|
||||
return get(`https://api.m.jd.com/?functionId=runningPageHome&body=%7B%22linkId%22:%22L-sOanK_5RJCz7I314FpnQ%22,%22isFromJoyPark%22:true,%22joyLinkId%22:%22LsQNxL7iWDlXUs6cFl-AAg%22%7D&t=${Date.now()}&appid=activities_platform&client=ios&clientVersion=3.1.0`, {
|
||||
'Host': 'api.m.jd.com',
|
||||
'Origin': 'https://h5platform.jd.com',
|
||||
'User-Agent': 'jdltapp;',
|
||||
'Referer': 'https://h5platform.jd.com/',
|
||||
'Cookie': cookie
|
||||
})
|
||||
}
|
||||
|
||||
async function team(fn: string, body: object) {
|
||||
let timestamp: number = Date.now()
|
||||
let h5st: string = ''
|
||||
return await get(`https://api.m.jd.com/?functionId=${fn}&body=${encodeURIComponent(JSON.stringify(body))}&t=${timestamp}&appid=activities_platform&client=ios&clientVersion=3.1.0&cthr=1&h5st=${h5st}`, {
|
||||
'Host': 'api.m.jd.com',
|
||||
'User-Agent': 'jdltapp;',
|
||||
'Origin': 'https://h5platform.jd.com',
|
||||
'X-Requested-With': 'com.jd.jdlite',
|
||||
'Referer': 'https://h5platform.jd.com/',
|
||||
'Cookie': cookie
|
||||
})
|
||||
}
|
||||
|
||||
// 秒转时分秒
|
||||
function secondsToMinutes(seconds: number) {
|
||||
let minutes: number = Math.floor(seconds / 60)
|
||||
let second: number = Math.floor(seconds % 60)
|
||||
return `${minutes}分${second}秒`
|
||||
}
|
||||
|
||||
// 小数加法
|
||||
function add(num1: number, num2: number) {
|
||||
let r1: number, r2: number
|
||||
try {
|
||||
r1 = num1.toString().split('.')[1].length
|
||||
} catch (e) {
|
||||
r1 = 0
|
||||
}
|
||||
try {
|
||||
r2 = num2.toString().split('.')[1].length
|
||||
} catch (e) {
|
||||
r2 = 0
|
||||
}
|
||||
let m: number = Math.pow(10, Math.max(r1, r2))
|
||||
return (num1 * m + num2 * m) / m
|
||||
}
|
384
jd_jxmc.ts
Normal file
384
jd_jxmc.ts
Normal file
@ -0,0 +1,384 @@
|
||||
/**
|
||||
* 京喜牧场
|
||||
* cron: 10 0,12,18 * * *
|
||||
*/
|
||||
|
||||
import * as path from "path"
|
||||
import {Md5} from "ts-md5"
|
||||
import {sendNotify} from './sendNotify'
|
||||
import {requireConfig, getBeanShareCode, getFarmShareCode, wait, o2s, randomWord, getshareCodeHW, exceptCookie, get} from './TS_USER_AGENTS'
|
||||
import {H5ST} from "./utils/h5st";
|
||||
import {existsSync, readFileSync} from "fs";
|
||||
import axios from "axios";
|
||||
|
||||
const token = require('./utils/jd_jxmc.js').token
|
||||
const h5stTool: H5ST = new H5ST("00df8", "jdpingou;", "")
|
||||
|
||||
let cookie: string = '', res: any = '', shareCodes: string[] = [], homePageInfo: any = '', jxToken: any = '', UserName: string = '', ua: string = null, account: { pt_pin: string, remarks: string, jdpingou: string }[] = []
|
||||
let shareCodesSelf: string[] = [], shareCodesHW: string[] = []
|
||||
|
||||
!(async () => {
|
||||
let except: string[] = exceptCookie(path.basename(__filename))
|
||||
if (existsSync('./utils/account.json')) {
|
||||
try {
|
||||
account = JSON.parse(readFileSync('./utils/account.json').toString())
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
}
|
||||
|
||||
let cookiesArr: any = await requireConfig()
|
||||
for (let [index, value] of cookiesArr.entries()) {
|
||||
cookie = value
|
||||
UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1])
|
||||
console.log(`\n开始【京东账号${index + 1}】${UserName}\n`)
|
||||
if (except.includes(encodeURIComponent(UserName))) {
|
||||
console.log('已设置跳过')
|
||||
continue
|
||||
}
|
||||
ua = null
|
||||
for (let acc of account) {
|
||||
if (acc?.pt_pin.includes(UserName)) {
|
||||
ua = acc.jdpingou
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
await h5stTool.__genAlgo()
|
||||
jxToken = await token(cookie)
|
||||
homePageInfo = await api('queryservice/GetHomePageInfo', 'activeid,activekey,channel,isgift,isqueryinviteicon,isquerypicksite,jxmc_jstoken,phoneid,sceneid,timestamp', {isgift: 1, isquerypicksite: 1, isqueryinviteicon: 1})
|
||||
let lastgettime: number
|
||||
if (homePageInfo.data?.cow?.lastgettime) {
|
||||
lastgettime = homePageInfo.data.cow.lastgettime
|
||||
} else {
|
||||
continue
|
||||
}
|
||||
|
||||
let food: number = 0, petid: string = '', coins: number = 0, petNum: number = 0, petids: string[] = []
|
||||
try {
|
||||
food = homePageInfo.data.materialinfo[0].value
|
||||
petid = homePageInfo.data.petinfo[0].petid
|
||||
petids = homePageInfo.data.petinfo.map(pet => {
|
||||
return pet.petid
|
||||
})
|
||||
console.log('当前🐔🐔:', petids)
|
||||
petNum = homePageInfo.data.petinfo.length
|
||||
coins = homePageInfo.data.coins
|
||||
} catch (e: any) {
|
||||
console.log('初始化出错,手动去app')
|
||||
continue
|
||||
}
|
||||
|
||||
console.log('助力码:', homePageInfo.data.sharekey)
|
||||
shareCodesSelf.push(homePageInfo.data.sharekey)
|
||||
try {
|
||||
await makeShareCodes(homePageInfo.data.sharekey)
|
||||
} catch (e: any) {
|
||||
console.log("提交助力码出错")
|
||||
}
|
||||
|
||||
console.log('草草🌿', food)
|
||||
console.log('蛋蛋🥚', homePageInfo.data.eggcnt)
|
||||
console.log('钱钱💰', coins)
|
||||
console.log('鸡鸡🐔', petNum)
|
||||
await wait(3000)
|
||||
|
||||
// 扭蛋机
|
||||
res = await api('queryservice/GetCardInfo', 'activeid,activekey,channel,jxmc_jstoken,phoneid,sceneid,timestamp')
|
||||
await wait(5000)
|
||||
let drawTimes = res.data.times
|
||||
if (typeof drawTimes === "undefined") {
|
||||
await sendNotify("牧场扭蛋机错误", `账号${index + 1} ${UserName}\n手动建造扭蛋机`)
|
||||
} else {
|
||||
console.log('扭蛋机剩余次数:', drawTimes)
|
||||
for (let j = 0; j < drawTimes; j++) {
|
||||
res = await api('operservice/DrawCard', 'activeid,activekey,channel,jxmc_jstoken,phoneid,sceneid,timestamp')
|
||||
if (res.ret === 0) {
|
||||
if (res.data.prizetype === 3) {
|
||||
console.log('抽奖成功,金币:', res.data.addcoins)
|
||||
} else if (res.data.prizetype === 1) {
|
||||
console.log('抽奖成功,卡片:', res.data.cardtype)
|
||||
} else {
|
||||
console.log('抽奖成功,其他:', res)
|
||||
}
|
||||
await wait(8000)
|
||||
} else {
|
||||
console.log('抽奖失败:', res)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
res = await api('queryservice/GetCardInfo', 'activeid,activekey,channel,jxmc_jstoken,phoneid,sceneid,timestamp')
|
||||
try {
|
||||
for (let card of res.data.cardinfo) {
|
||||
console.log(`card ${card.cardtype}`, card.currnum, '/', card.neednum)
|
||||
if (card.currnum >= card.neednum && petNum < 6) {
|
||||
console.log('可以兑换')
|
||||
res = await api('operservice/Combine', 'activeid,activekey,cardtype,channel,jxmc_jstoken,phoneid,sceneid,timestamp', {cardtype: card.cardtype})
|
||||
res.ret === 0 ? console.log('兑换成功') : ''
|
||||
await wait(4000)
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
}
|
||||
await wait(5000)
|
||||
|
||||
// 签到
|
||||
res = await api('queryservice/GetSignInfo', 'activeid,activekey,channel,jxmc_jstoken,phoneid,sceneid,timestamp')
|
||||
if (res.data.signlist) {
|
||||
for (let day of res.data.signlist) {
|
||||
if (day.fortoday && !day.hasdone) {
|
||||
res = await api('operservice/GetSignReward', 'channel,currdate,sceneid', {currdate: res.data.currdate})
|
||||
if (res.ret === 0) {
|
||||
console.log('签到成功!')
|
||||
} else {
|
||||
console.log(res)
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
} else {
|
||||
console.log('没有获取到签到信息!')
|
||||
}
|
||||
await wait(5000)
|
||||
|
||||
// 登录领白菜
|
||||
res = await api('queryservice/GetVisitBackInfo', 'activeid,activekey,channel,jxmc_jstoken,phoneid,sceneid,timestamp')
|
||||
await wait(2000)
|
||||
if (res.data.iscandraw === 1) {
|
||||
res = await api('operservice/GetVisitBackCabbage', 'activeid,activekey,channel,jxmc_jstoken,phoneid,sceneid,timestamp')
|
||||
if (res.ret === 0) {
|
||||
console.log('登录领白菜:', res.data.drawnum)
|
||||
}
|
||||
}
|
||||
await wait(5000)
|
||||
|
||||
console.log('任务列表开始')
|
||||
for (let j = 0; j < 30; j++) {
|
||||
if (await getTask() === 0) {
|
||||
break
|
||||
}
|
||||
await wait(4000)
|
||||
}
|
||||
console.log('任务列表结束')
|
||||
await wait(5000)
|
||||
|
||||
while (coins >= 5000 && food <= 500) {
|
||||
res = await api('operservice/Buy', 'activeid,activekey,channel,jxmc_jstoken,phoneid,sceneid,timestamp,type', {type: '1'})
|
||||
if (res.ret === 0) {
|
||||
console.log('买草成功:', res.data.newnum)
|
||||
coins -= 5000
|
||||
food += 100
|
||||
} else {
|
||||
console.log(res)
|
||||
break
|
||||
}
|
||||
await wait(8000)
|
||||
}
|
||||
await wait(6000)
|
||||
|
||||
while (food >= 10) {
|
||||
food -= 10
|
||||
res = await api('operservice/Feed', 'activeid,activekey,channel,jxmc_jstoken,phoneid,sceneid,timestamp')
|
||||
if (res.ret === 0) {
|
||||
console.log('喂食:', res.data.newnum)
|
||||
} else if (res.ret === 2020) {
|
||||
console.log('收🥚')
|
||||
homePageInfo = await api('queryservice/GetHomePageInfo', 'activeid,activekey,channel,isgift,isqueryinviteicon,isquerypicksite,jxmc_jstoken,phoneid,sceneid,timestamp', {
|
||||
isgift: 1,
|
||||
isquerypicksite: 1,
|
||||
isqueryinviteicon: 1
|
||||
})
|
||||
for (let t of homePageInfo.data.petinfo) {
|
||||
if (t.cangetborn === 1) {
|
||||
petid = t.petid
|
||||
break
|
||||
}
|
||||
}
|
||||
res = await api('operservice/GetSelfResult', 'activeid,activekey,channel,itemid,jxmc_jstoken,phoneid,sceneid,timestamp,type', {itemid: petid, type: '11'})
|
||||
if (res.ret === 0) {
|
||||
console.log('收🥚成功:', res.data.newnum)
|
||||
} else {
|
||||
console.log('收🥚失败:', res)
|
||||
break
|
||||
}
|
||||
} else if (res.ret === 2005) {
|
||||
console.log('今天吃撑了')
|
||||
break
|
||||
} else {
|
||||
console.log('Feed未知错误:', res)
|
||||
break
|
||||
}
|
||||
await wait(10000)
|
||||
}
|
||||
await wait(8000)
|
||||
|
||||
console.log('除草...start')
|
||||
for (let j = 0; j < 30; j++) {
|
||||
try {
|
||||
res = await api('operservice/Action', 'activeid,activekey,channel,jxmc_jstoken,phoneid,sceneid,timestamp,type', {type: '2'})
|
||||
if (res.data.addcoins === 0 || JSON.stringify(res.data) === '{}') break
|
||||
console.log('锄草:', res.data.addcoins)
|
||||
await wait(5000)
|
||||
if (res.data.surprise) {
|
||||
res = await api("operservice/GetSelfResult", "activeid,activekey,channel,jxmc_jstoken,phoneid,sceneid,timestamp,type", {type: '14', itemid: 'undefined'})
|
||||
console.log('锄草奖励:', res.data.prizepool)
|
||||
await wait(5000)
|
||||
}
|
||||
} catch (e: any) {
|
||||
console.log('除草 Error')
|
||||
break
|
||||
}
|
||||
}
|
||||
await wait(6000)
|
||||
|
||||
for (let j = 0; j < 30; j++) {
|
||||
try {
|
||||
res = await api('operservice/Action', 'activeid,activekey,channel,jxmc_jstoken,petid,phoneid,sceneid,timestamp,type', {type: '1', petid: petids[Math.floor((Math.random() * petids.length))]})
|
||||
if (res.data.addcoins === 0 || JSON.stringify(res.data) === '{}') break
|
||||
console.log('挑逗:', res.data.addcoins)
|
||||
await wait(6000)
|
||||
} catch (e: any) {
|
||||
console.log('挑逗 Error')
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
for (let [index, value] of cookiesArr.entries()) {
|
||||
if (shareCodesHW.length === 0) {
|
||||
shareCodesHW = await getshareCodeHW('jxmc')
|
||||
}
|
||||
// 获取随机助力码
|
||||
try {
|
||||
let {data}: any = await axios.get(`https://api.jdsharecode.xyz/api/jxmc/30`, {timeout: 10000})
|
||||
console.log('获取到30个随机助力码:', data.data)
|
||||
shareCodes = Array.from(new Set([...shareCodesSelf, ...shareCodesHW, ...data.data]))
|
||||
} catch (e: any) {
|
||||
console.log('获取助力池失败')
|
||||
shareCodes = Array.from(new Set([...shareCodesSelf, ...shareCodesHW]))
|
||||
}
|
||||
|
||||
cookie = value
|
||||
jxToken = await token(cookie)
|
||||
for (let code of shareCodes) {
|
||||
console.log(`账号${index + 1} 去助力 ${code}`)
|
||||
res = await api('operservice/EnrollFriend', 'activeid,activekey,channel,jxmc_jstoken,phoneid,sceneid,sharekey,timestamp', {sharekey: code})
|
||||
if (res.ret === 0) {
|
||||
console.log('成功,获得:', res.data.addcoins)
|
||||
} else if(res.ret===1016){
|
||||
console.log('火爆:', res)
|
||||
break
|
||||
}
|
||||
} else {
|
||||
console.log('失败:', res)
|
||||
}
|
||||
await wait(8000)
|
||||
}
|
||||
}
|
||||
*/
|
||||
})()
|
||||
|
||||
interface Params {
|
||||
isgift?: number,
|
||||
isquerypicksite?: number,
|
||||
petid?: string,
|
||||
itemid?: string,
|
||||
type?: string,
|
||||
taskId?: number
|
||||
configExtra?: string,
|
||||
sharekey?: string,
|
||||
currdate?: string,
|
||||
token?: string,
|
||||
isqueryinviteicon?: number,
|
||||
showAreaTaskFlag?: number,
|
||||
jxpp_wxapp_type?: number,
|
||||
dateType?: string,
|
||||
step?: string,
|
||||
cardtype?: number,
|
||||
}
|
||||
|
||||
async function getTask() {
|
||||
console.log('刷新任务列表')
|
||||
res = await api('GetUserTaskStatusList', 'bizCode,dateType,jxpp_wxapp_type,showAreaTaskFlag,source', {dateType: '', showAreaTaskFlag: 0, jxpp_wxapp_type: 7})
|
||||
for (let t of res.data.userTaskStatusList) {
|
||||
if (t.completedTimes == t.targetTimes && t.awardStatus === 2) {
|
||||
res = await api('Award', 'bizCode,source,taskId', {taskId: t.taskId})
|
||||
if (res.ret === 0) {
|
||||
let awardCoin = res.data.prizeInfo.match(/:(.*)}/)![1] * 1
|
||||
console.log('领奖成功:', awardCoin)
|
||||
await wait(4000)
|
||||
return 1
|
||||
} else {
|
||||
console.log('领奖失败:', res)
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
if (t.dateType === 2 && t.completedTimes < t.targetTimes && t.awardStatus === 2 && t.taskType === 2) {
|
||||
res = await api('DoTask', 'bizCode,configExtra,source,taskId', {taskId: t.taskId, configExtra: ''})
|
||||
if (res.ret === 0) {
|
||||
console.log('任务完成')
|
||||
await wait(5000)
|
||||
return 1
|
||||
} else {
|
||||
console.log('任务失败:', res)
|
||||
return 0
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
async function api(fn: string, stk: string, params: Params = {}) {
|
||||
let url: string, t: { [key: string]: string } = {
|
||||
activeid: 'jxmc_active_0001',
|
||||
activekey: 'null',
|
||||
channel: '7',
|
||||
jxmc_jstoken: jxToken['farm_jstoken'],
|
||||
phoneid: jxToken['phoneid'],
|
||||
sceneid: '1001',
|
||||
timestamp: jxToken['timestamp'],
|
||||
}
|
||||
if (['GetUserTaskStatusList', 'DoTask', 'Award'].indexOf(fn) > -1)
|
||||
url = `https://m.jingxi.com/newtasksys/newtasksys_front/${fn}?_=${Date.now()}&source=jxmc&bizCode=jxmc&_stk=${encodeURIComponent(stk)}&_ste=1&sceneval=2&g_login_type=1&callback=jsonpCBK${randomWord()}&g_ty=ls`
|
||||
else
|
||||
url = `https://m.jingxi.com/jxmc/${fn}?channel=7&sceneid=1001&activeid=jxmc_active_0001&activekey=null&jxmc_jstoken=${jxToken['farm_jstoken']}×tamp=${jxToken['timestamp']}&phoneid=${jxToken['phoneid']}&_stk=${encodeURIComponent(stk)}&_ste=1&_=${Date.now()}&sceneval=2&g_login_type=1&callback=jsonpCBK${randomWord()}&g_ty=ls`
|
||||
|
||||
for (let [key, value] of Object.entries(params)) {
|
||||
t[key] = value
|
||||
url += `&${key}=${value}`
|
||||
}
|
||||
let h5st: string = h5stTool.__genH5st(t)
|
||||
url += `&h5st=${h5st}`
|
||||
try {
|
||||
let {data}: any = await axios.get(url, {
|
||||
headers: {
|
||||
'Host': 'm.jingxi.com',
|
||||
'Accept': '*/*',
|
||||
'User-Agent': ua ?? 'jdpingou;',
|
||||
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
|
||||
'Referer': 'https://st.jingxi.com/',
|
||||
'Cookie': cookie
|
||||
}
|
||||
})
|
||||
return JSON.parse(data.match(/jsonpCBK.?\((.*)/)![1])
|
||||
} catch (e) {
|
||||
o2s(e)
|
||||
}
|
||||
}
|
||||
|
||||
async function makeShareCodes(code: string) {
|
||||
try {
|
||||
let bean: string = await getBeanShareCode(cookie)
|
||||
let farm: string = await getFarmShareCode(cookie)
|
||||
let pin: string = Md5.hashStr(cookie.match(/pt_pin=([^;]*)/)![1])
|
||||
let data = await get(`https://api.jdsharecode.xyz/api/autoInsert/jxmc?sharecode=${code}&bean=${bean}&farm=${farm}&pin=${pin}`)
|
||||
console.log(data.message)
|
||||
} catch (e) {
|
||||
console.log('自动提交失败')
|
||||
console.log(e)
|
||||
}
|
||||
}
|
19
jd_mofang.ts
19
jd_mofang.ts
@ -1,10 +1,10 @@
|
||||
/**
|
||||
* 京东-新品-魔方
|
||||
* 本地log或rabbit log
|
||||
* rabbit log
|
||||
* cron: 10 9,12,15 * * *
|
||||
*/
|
||||
|
||||
import {o2s, requireConfig, wait, post, get} from './TS_USER_AGENTS'
|
||||
import {requireConfig, wait, post, get} from './TS_USER_AGENTS'
|
||||
import {existsSync} from "fs";
|
||||
import * as dotenv from 'dotenv'
|
||||
|
||||
@ -29,7 +29,6 @@ let rabbitToken: string = process.env.RABBIT_TOKEN || '', tg_id: string = proces
|
||||
let sign: string = res.result.taskConfig.projectId
|
||||
|
||||
res = await api(`functionId=queryInteractiveInfo&body=%7B%22encryptProjectId%22%3A%22${sign}%22%2C%22sourceCode%22%3A%22acexinpin0823%22%2C%22ext%22%3A%7B%7D%7D&client=wh5&clientVersion=1.0.0&appid=content_ecology`)
|
||||
// o2s(res)
|
||||
for (let t of res.assignmentList) {
|
||||
if (t.completionCnt < t.assignmentTimesLimit) {
|
||||
if (t.ext) {
|
||||
@ -42,7 +41,7 @@ let rabbitToken: string = process.env.RABBIT_TOKEN || '', tg_id: string = proces
|
||||
res = await api(`functionId=doInteractiveAssignment&body=${JSON.stringify({
|
||||
"encryptProjectId": sign, "encryptAssignmentId": t.encryptAssignmentId, "sourceCode": "acexinpin0823", "itemId": "1", "actionType": "", "completionFlag": "", "ext": {}, "extParam": {"businessData": {"random": log.match(/"random":"(\d+)"/)[1]}, "signStr": log.match(/"log":"(.*)"/)[1], "sceneid": "XMFhPageh5"}
|
||||
})}&client=wh5&clientVersion=1.0.0&appid=content_ecology`)
|
||||
o2s(res, '签到成功')
|
||||
console.log('签到成功')
|
||||
} else {
|
||||
console.log('已签到')
|
||||
}
|
||||
@ -53,7 +52,7 @@ let rabbitToken: string = process.env.RABBIT_TOKEN || '', tg_id: string = proces
|
||||
console.log(t.assignmentName)
|
||||
log = await getLog()
|
||||
res = await api(`functionId=doInteractiveAssignment&body=${encodeURIComponent(JSON.stringify({"encryptProjectId": sign, "encryptAssignmentId": t.encryptAssignmentId, "sourceCode": "acexinpin0823", "itemId": proInfo.itemId, "actionType": 0, "completionFlag": "", "ext": {}, "extParam": {"businessData": {"random": log.match(/"random":"(\d+)"/)[1]}, "signStr": log.match(/"log":"(.*)"/)[1], "sceneid": "XMFhPageh5"}}))}&client=wh5&clientVersion=1.0.0&appid=content_ecology`)
|
||||
o2s(res)
|
||||
console.log(res.msg)
|
||||
if (res.msg === '任务已完成') {
|
||||
break
|
||||
}
|
||||
@ -65,11 +64,11 @@ let rabbitToken: string = process.env.RABBIT_TOKEN || '', tg_id: string = proces
|
||||
console.log(t.assignmentName)
|
||||
log = await getLog()
|
||||
res = await api(`functionId=doInteractiveAssignment&body=${encodeURIComponent(JSON.stringify({"encryptProjectId": sign, "encryptAssignmentId": t.encryptAssignmentId, "sourceCode": "acexinpin0823", "itemId": proInfo.itemId, "actionType": 1, "completionFlag": "", "ext": {}, "extParam": {"businessData": {"random": log.match(/"random":"(\d+)"/)[1]}, "signStr": log.match(/"log":"(.*)"/)[1], "sceneid": "XMFhPageh5"}}))}&client=wh5&clientVersion=1.0.0&appid=content_ecology`)
|
||||
o2s(res)
|
||||
console.log(res.msg)
|
||||
await wait(t.ext.waitDuration * 1000)
|
||||
log = await getLog()
|
||||
res = await api(`functionId=doInteractiveAssignment&body=${encodeURIComponent(JSON.stringify({"encryptProjectId": sign, "encryptAssignmentId": t.encryptAssignmentId, "sourceCode": "acexinpin0823", "itemId": proInfo.itemId, "actionType": 0, "completionFlag": "", "ext": {}, "extParam": {"businessData": {"random": log.match(/"random":"(\d+)"/)[1]}, "signStr": log.match(/"log":"(.*)"/)[1], "sceneid": "XMFhPageh5"}}))}&client=wh5&clientVersion=1.0.0&appid=content_ecology`)
|
||||
o2s(res)
|
||||
console.log(res.msg)
|
||||
}
|
||||
}
|
||||
|
||||
@ -80,13 +79,13 @@ let rabbitToken: string = process.env.RABBIT_TOKEN || '', tg_id: string = proces
|
||||
res = await api(`functionId=doInteractiveAssignment&body=${JSON.stringify({
|
||||
"encryptProjectId": sign, "encryptAssignmentId": t.encryptAssignmentId, "sourceCode": "acexinpin0823", "itemId": proInfo.itemId, "actionType": 1, "completionFlag": "", "ext": {}, "extParam": {"businessData": {"random": log.match(/"random":"(\d+)"/)[1]}, "signStr": log.match(/"log":"(.*)"/)[1], "sceneid": "XMFhPageh5"}
|
||||
})}&client=wh5&clientVersion=1.0.0&appid=content_ecology`)
|
||||
o2s(res)
|
||||
console.log(res.msg)
|
||||
await wait(t.ext.waitDuration * 1000)
|
||||
log = await getLog()
|
||||
res = await api(`functionId=doInteractiveAssignment&body=${JSON.stringify({
|
||||
"encryptProjectId": sign, "encryptAssignmentId": t.encryptAssignmentId, "sourceCode": "acexinpin0823", "itemId": proInfo.itemId, "actionType": 0, "completionFlag": "", "ext": {}, "extParam": {"businessData": {"random": log.match(/"random":"(\d+)"/)[1]}, "signStr": log.match(/"log":"(.*)"/)[1], "sceneid": "XMFhPageh5"}
|
||||
})}&client=wh5&clientVersion=1.0.0&appid=content_ecology`)
|
||||
o2s(res)
|
||||
console.log(res.msg)
|
||||
}
|
||||
}
|
||||
|
||||
@ -95,7 +94,7 @@ let rabbitToken: string = process.env.RABBIT_TOKEN || '', tg_id: string = proces
|
||||
console.log(t.assignmentName)
|
||||
log = await getLog()
|
||||
res = await api(`functionId=doInteractiveAssignment&body=${encodeURIComponent(JSON.stringify({"encryptProjectId": sign, "encryptAssignmentId": t.encryptAssignmentId, "sourceCode": "acexinpin0823", "itemId": proInfo.itemId, "actionType": "0", "completionFlag": "", "ext": {}, "extParam": {"businessData": {"random": log.match(/"random":"(\d+)"/)[1]}, "signStr": log.match(/"log":"(.*)"/)[1], "sceneid": "XMFJGh5"}}))}&client=wh5&clientVersion=1.0.0&appid=content_ecology`)
|
||||
o2s(res)
|
||||
console.log(res.msg)
|
||||
if (res.msg === '任务已完成') {
|
||||
break
|
||||
}
|
||||
|
159
jd_speed_happy_dig.ts
Normal file
159
jd_speed_happy_dig.ts
Normal file
@ -0,0 +1,159 @@
|
||||
/**
|
||||
* 极速版-挖宝
|
||||
* 助力,挖宝,任务,提现
|
||||
* cron: 2 0,1,18 * * *
|
||||
* CK1 HW.ts -> 内部
|
||||
* CK2~n 内部 -> HW.ts
|
||||
*/
|
||||
|
||||
import {get, getshareCodeHW, o2s, randomString, requireConfig, wait} from './TS_USER_AGENTS'
|
||||
import {H5ST} from "./utils/h5st";
|
||||
|
||||
let cookie: string = '', res: any = '', UserName: string, data: any, h5stTool: any = new H5ST("ce6c2", "jdltapp;", "9929056438203725")
|
||||
|
||||
interface INVITE {
|
||||
inviter: string,
|
||||
inviteCode: string
|
||||
}
|
||||
|
||||
let shareCodes: INVITE[] = [], shareCodesHW = [], shareCodesSelf: INVITE[] = []
|
||||
|
||||
!(async () => {
|
||||
let cookiesArr: string[] = await requireConfig()
|
||||
for (let [index, value] of cookiesArr.entries()) {
|
||||
try {
|
||||
cookie = value
|
||||
UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1])
|
||||
console.log(`\n开始【京东账号${index + 1}】${UserName}\n`)
|
||||
|
||||
await h5stTool.__genAlgo()
|
||||
res = await api('happyDigHome', {"linkId": "pTTvJeSTrpthgk9ASBVGsw"})
|
||||
console.log('助力码', res.data.markedPin, res.data.inviteCode)
|
||||
shareCodesSelf.push({inviter: res.data.markedPin, inviteCode: res.data.inviteCode})
|
||||
} catch (e) {
|
||||
console.log('error')
|
||||
}
|
||||
await wait(2000)
|
||||
}
|
||||
console.log('内部助力')
|
||||
o2s(shareCodesSelf)
|
||||
|
||||
for (let [index, value] of cookiesArr.entries()) {
|
||||
try {
|
||||
cookie = value
|
||||
UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1])
|
||||
console.log(`\n开始【京东账号${index + 1}】${UserName}\n`)
|
||||
|
||||
await h5stTool.__genAlgo()
|
||||
if (shareCodesHW.length === 0) {
|
||||
shareCodesHW = await getshareCodeHW('fcwb')
|
||||
}
|
||||
if (index === 0 && cookiesArr.length === 1) {
|
||||
shareCodes = Array.from(new Set([...shareCodesHW, ...shareCodesSelf]))
|
||||
} else {
|
||||
shareCodes = Array.from(new Set([...shareCodesSelf, ...shareCodesHW]))
|
||||
}
|
||||
|
||||
for (let code of shareCodesSelf) {
|
||||
console.log(`去助力 ${code.inviteCode}`)
|
||||
res = await api('happyDigHelp', {"linkId": "pTTvJeSTrpthgk9ASBVGsw", "inviter": code.inviter, "inviteCode": code.inviteCode})
|
||||
if (res.code === 0) {
|
||||
console.log('助力成功')
|
||||
await wait(2000)
|
||||
break
|
||||
} else if (res.code === 16143) {
|
||||
console.log('已助力')
|
||||
} else if (res.code === 16144) {
|
||||
console.log('上限')
|
||||
await wait(2000)
|
||||
break
|
||||
} else {
|
||||
o2s(res)
|
||||
}
|
||||
await wait(2000)
|
||||
}
|
||||
|
||||
res = await api('apTaskList', {"linkId": "pTTvJeSTrpthgk9ASBVGsw"})
|
||||
await wait(1000)
|
||||
|
||||
for (let t of res.data) {
|
||||
if (t.taskType === 'BROWSE_CHANNEL' && t.taskDoTimes === 0 && t.taskLimitTimes === 1) {
|
||||
console.log(t.taskShowTitle)
|
||||
data = await api('apDoTask', {"linkId": "pTTvJeSTrpthgk9ASBVGsw", "taskType": "BROWSE_CHANNEL", "taskId": t.id, "channel": 4, "itemId": encodeURIComponent(t.taskSourceUrl), "checkVersion": false})
|
||||
await wait(1000)
|
||||
if (data.success) {
|
||||
console.log('任务完成')
|
||||
} else {
|
||||
o2s(data, '任务失败')
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('error', e)
|
||||
await wait(2000)
|
||||
}
|
||||
}
|
||||
|
||||
for (let [index, value] of cookiesArr.entries()) {
|
||||
cookie = value
|
||||
UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1])
|
||||
console.log(`\n开始【京东账号${index + 1}】${UserName}\n`)
|
||||
|
||||
await h5stTool.__genAlgo()
|
||||
res = await api('happyDigHome', {"linkId": "pTTvJeSTrpthgk9ASBVGsw"})
|
||||
let blood: number = res.data.blood
|
||||
for (let i = 0; i < 4; i++) {
|
||||
try {
|
||||
if (blood <= 1) {
|
||||
console.log('能量剩余1,跳过 A')
|
||||
break
|
||||
}
|
||||
for (let j = 0; j < 4; j++) {
|
||||
if (blood <= 1) {
|
||||
console.log('能量剩余1,跳过 B')
|
||||
break
|
||||
}
|
||||
res = await api('happyDigDo', {"round": 1, "rowIdx": i, "colIdx": j, "linkId": "pTTvJeSTrpthgk9ASBVGsw"})
|
||||
o2s(res)
|
||||
|
||||
if (res.data.chunk.type === 1) {
|
||||
console.log('挖到👎')
|
||||
} else if (res.data.chunk.type === 2) {
|
||||
console.log('挖到🧧', parseFloat(res.data.chunk.value))
|
||||
} else if (res.data.chunk.type === 4) {
|
||||
console.log('挖到💣')
|
||||
}
|
||||
await wait(1000)
|
||||
res = await api('happyDigHome', {"linkId": "pTTvJeSTrpthgk9ASBVGsw"})
|
||||
if (res.data.blood === 1) {
|
||||
blood = 1
|
||||
console.log('能量剩余1,退出')
|
||||
break
|
||||
}
|
||||
await wait(4000)
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('error', res?.errMsg)
|
||||
}
|
||||
}
|
||||
}
|
||||
})()
|
||||
|
||||
async function api(fn: string, body: object) {
|
||||
let timestamp: number = Date.now()
|
||||
let h5st: string = h5stTool.__genH5st({
|
||||
appid: 'activities_platform',
|
||||
body: JSON.stringify(body),
|
||||
client: 'H5',
|
||||
clientVersion: '1.0.0',
|
||||
functionId: fn,
|
||||
t: timestamp.toString(),
|
||||
})
|
||||
return await get(`https://api.m.jd.com/?functionId=${fn}&body=${encodeURIComponent(JSON.stringify(body))}&t=${timestamp}&appid=activities_platform&client=H5&clientVersion=1.0.0&h5st=${h5st}`, {
|
||||
'Host': 'api.m.jd.com',
|
||||
'Origin': 'https://bnzf.jd.com',
|
||||
'User-Agent': `jdapp;iPhone;10.2.2;14.3;${randomString(40)};M/5.0;network/wifi;ADID/;model/iPhone12,1;addressid/4199175193;appBuild/167863;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1;`,
|
||||
'Referer': 'https://bnzf.jd.com/',
|
||||
'Cookie': cookie
|
||||
})
|
||||
}
|
36
jd_speed_monitor.ts
Normal file
36
jd_speed_monitor.ts
Normal file
@ -0,0 +1,36 @@
|
||||
import axios from 'axios'
|
||||
import {sendNotify} from './sendNotify';
|
||||
import {requireConfig} from './TS_USER_AGENTS'
|
||||
|
||||
const CryptoJS = require('crypto-js');
|
||||
let cookie: string = '', UserName: string
|
||||
|
||||
!(async () => {
|
||||
let cookiesArr: string[] = await requireConfig()
|
||||
cookie = cookiesArr[Math.random() * cookiesArr.length | 0]
|
||||
UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1])
|
||||
console.log(`<Start> ${UserName}\n`)
|
||||
|
||||
let t: number = Date.now(), fn: string = 'MyAssetsService.execute', body: object = {"method": "goldShopPage", "data": {"channel": 1}}
|
||||
let params: string = `lite-android&${JSON.stringify(body)}&android&3.1.0&${fn}&${t}&846c4c32dae910ef`
|
||||
let key = CryptoJS.HmacSHA256(params, '12aea658f76e453faf803d15c40a72e0').toString()
|
||||
|
||||
let {data} = await axios.get(`https://api.m.jd.com/api?functionId=${fn}&body=${encodeURIComponent(JSON.stringify(body))}&appid=lite-android&client=android&uuid=846c4c32dae910ef&clientVersion=3.1.0&t=${t}&sign=${key}`, {
|
||||
headers: {
|
||||
'Host': 'api.m.jd.com',
|
||||
'accept': '*/*',
|
||||
'kernelplatform': 'RN',
|
||||
'user-agent': 'JDMobileLite/3.1.0 (iPad; iOS 14.4; Scale/2.00)',
|
||||
'accept-language': 'zh-Hans-CN;q=1, ja-CN;q=0.9',
|
||||
'Cookie': cookie
|
||||
}
|
||||
})
|
||||
|
||||
for (let t of data.data.gears) {
|
||||
console.log(t.amount)
|
||||
if (t.amount === '50' || t.amount === '10') {
|
||||
await sendNotify('极速版金币', `${t.amount}🧧`)
|
||||
break
|
||||
}
|
||||
}
|
||||
})()
|
155
jd_tewu.ts
Normal file
155
jd_tewu.ts
Normal file
@ -0,0 +1,155 @@
|
||||
/**
|
||||
* 京东-下拉
|
||||
* cron: 15 8,20 * * *
|
||||
*/
|
||||
|
||||
import axios from 'axios';
|
||||
import USER_AGENT, {requireConfig, wait, o2s, getshareCodeHW, post} from './TS_USER_AGENTS'
|
||||
|
||||
interface ShareCode {
|
||||
activityId: number,
|
||||
encryptProjectId: string,
|
||||
encryptAssignmentId: string,
|
||||
itemId: string
|
||||
}
|
||||
|
||||
let cookie: string = '', UserName: string = '', res: any = '', message: string = '', shareCodes: ShareCode[] = [], shareCodesSelf: ShareCode[] = [], shareCodesHW: any = [], black: string[] = []
|
||||
|
||||
!(async () => {
|
||||
let cookiesArr: string[] = await requireConfig()
|
||||
let activityId: number
|
||||
for (let [index, value] of cookiesArr.entries()) {
|
||||
cookie = value
|
||||
UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1])
|
||||
console.log(`\n开始【京东账号${index + 1}】${UserName}\n`)
|
||||
|
||||
res = await api('showSecondFloorCardInfo', {"source": "card"})
|
||||
try {
|
||||
activityId = res.data.result.activityBaseInfo.activityId
|
||||
} catch (e) {
|
||||
console.log('获取活动信息错误')
|
||||
black.push(UserName)
|
||||
await wait(2000)
|
||||
continue
|
||||
}
|
||||
let encryptProjectId: string = res.data.result.activityBaseInfo.encryptProjectId
|
||||
await wait(1000)
|
||||
|
||||
// 任务
|
||||
res = await api('superBrandTaskList', {"source": "card", "activityId": activityId, "assistInfoFlag": 1})
|
||||
o2s(res)
|
||||
|
||||
for (let t of res.data.result.taskList) {
|
||||
if (t.completionCnt !== t.assignmentTimesLimit) {
|
||||
// 浏览、关注
|
||||
if (t.ext?.shoppingActivity || t.ext?.followShop) {
|
||||
let tp = t.ext?.shoppingActivity || t.ext?.followShop
|
||||
tp = tp[0]
|
||||
console.log(tp.title || tp.shopName, tp.itemId)
|
||||
res = await api('superBrandDoTask', {"source": "card", "activityId": activityId, "encryptProjectId": encryptProjectId, "encryptAssignmentId": t.encryptAssignmentId, "assignmentType": t.assignmentType, "itemId": tp.itemId, "actionType": 0})
|
||||
console.log(res.data?.bizMsg)
|
||||
await wait(2000)
|
||||
}
|
||||
|
||||
// 下拉
|
||||
if (t.ext?.sign2) {
|
||||
for (let sign of t.ext.sign2) {
|
||||
if (sign.status === 0 && [10, 18].includes(new Date().getHours())) {
|
||||
res = await api('superBrandDoTask', {"source": "card", "activityId": activityId, "encryptProjectId": encryptProjectId, "encryptAssignmentId": t.encryptAssignmentId, "assignmentType": t.assignmentType, "itemId": t.ext.currentSectionItemId, "actionType": 0})
|
||||
console.log(res.data?.bizMsg)
|
||||
await wait(2000)
|
||||
console.log('下拉任务', t.ext?.sign2)
|
||||
} else if (sign.status !== 0) {
|
||||
console.log(`${sign.beginTime} 签到完成`)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 助力码
|
||||
if (t.ext?.assistTaskDetail) {
|
||||
console.log('助力码:', t.ext.assistTaskDetail.itemId)
|
||||
console.log('收到助力:', t.ext?.assistList?.length ?? 0)
|
||||
shareCodesSelf.push({
|
||||
activityId: activityId,
|
||||
encryptProjectId: encryptProjectId,
|
||||
encryptAssignmentId: t.encryptAssignmentId,
|
||||
itemId: t.ext.assistTaskDetail.itemId
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// 抽奖
|
||||
try {
|
||||
if (new Date().getHours() === 20) {
|
||||
let sum: number = 0
|
||||
res = await api('superBrandSecondFloorMainPage', {"source": "card"})
|
||||
let userStarNum: number = res.data.result.activityUserInfo.userStarNum
|
||||
console.log('可以抽奖', userStarNum, '次')
|
||||
for (let i = 0; i < userStarNum; i++) {
|
||||
res = await api('superBrandTaskLottery', {"source": "card", "activityId": activityId})
|
||||
if (res.data.result?.rewardComponent?.beanList?.length) {
|
||||
console.log('抽奖获得京豆:', res.data.result.rewardComponent.beanList[0].quantity)
|
||||
sum += res.data.result.rewardComponent.beanList[0].quantity
|
||||
} else {
|
||||
console.log('没抽到?', JSON.stringify(res))
|
||||
}
|
||||
await wait(2000)
|
||||
}
|
||||
message += `【京东账号${index + 1}】${UserName}\n抽奖${userStarNum}次,获得京豆${sum}\n\n`
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('error')
|
||||
}
|
||||
await wait(2000)
|
||||
}
|
||||
|
||||
o2s(shareCodesSelf)
|
||||
shareCodesHW = await getshareCodeHW('tewu')
|
||||
shareCodes = [...shareCodesSelf, ...shareCodesHW]
|
||||
|
||||
let full: string[] = []
|
||||
for (let [index, value] of cookiesArr.entries()) {
|
||||
cookie = value
|
||||
UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1])
|
||||
if (black.includes(UserName)) {
|
||||
console.log('黑号')
|
||||
continue
|
||||
}
|
||||
for (let code of shareCodes) {
|
||||
if (full.includes(code.itemId))
|
||||
continue
|
||||
console.log(`账号${index + 1} ${UserName} 去助力 ${code.itemId}`)
|
||||
res = await api('superBrandDoTask', {"source": "card", "activityId": code.activityId, "encryptProjectId": code.encryptProjectId, "encryptAssignmentId": code.encryptAssignmentId, "assignmentType": 2, "itemId": code.itemId, "actionType": 0})
|
||||
if (res.data.bizCode === '0') {
|
||||
console.log('助力成功')
|
||||
} else if (res.data.bizCode === '103') {
|
||||
console.log('助力满了')
|
||||
full.push(code.itemId)
|
||||
} else if (res.data.bizCode === '104') {
|
||||
console.log('已助力过')
|
||||
} else if (res.data.bizCode === '108') {
|
||||
console.log('上限')
|
||||
break
|
||||
} else if (res.data.bizCode === '2001') {
|
||||
console.log('黑号')
|
||||
break
|
||||
} else if (res.data.bizCode === '4001') {
|
||||
console.log('助力码过期')
|
||||
} else {
|
||||
o2s(res, 'error')
|
||||
}
|
||||
await wait(2000)
|
||||
}
|
||||
}
|
||||
})()
|
||||
|
||||
async function api(fn: string, body: object) {
|
||||
return await post(`https://api.m.jd.com/?uuid=&client=wh5&appid=ProductZ4Brand&functionId=${fn}&t=${Date.now()}&body=${encodeURIComponent(JSON.stringify(body))}`, '', {
|
||||
'Host': 'api.m.jd.com',
|
||||
'Origin': 'https://pro.m.jd.com',
|
||||
'User-Agent': USER_AGENT,
|
||||
'Referer': 'https://pro.m.jd.com/',
|
||||
'Cookie': cookie
|
||||
})
|
||||
}
|
133
jd_track.ts
Normal file
133
jd_track.ts
Normal file
@ -0,0 +1,133 @@
|
||||
/**
|
||||
* 京东快递更新通知
|
||||
* cron: 0 0-23/4 * * *
|
||||
*/
|
||||
|
||||
import * as path from "path"
|
||||
import {sendNotify} from './sendNotify'
|
||||
import {existsSync, mkdirSync, readFileSync, writeFileSync} from "fs"
|
||||
import USER_AGENT, {get, requireConfig, exceptCookie, wait, o2s} from "./TS_USER_AGENTS"
|
||||
import {pushplus} from "./utils/pushplus";
|
||||
|
||||
let cookie: string = '', UserName: string, allMessage: string = '', res: any = ''
|
||||
|
||||
!(async () => {
|
||||
let cookiesArr: string[] = await requireConfig()
|
||||
let except: string[] = exceptCookie(path.basename(__filename))
|
||||
let orders: any = {}, pushplusArr: { pt_pin: string, pushplus: string }[], pushplusUser: string[] = []
|
||||
try {
|
||||
pushplusArr = JSON.parse(readFileSync('./utils/account.json').toString())
|
||||
} catch (e) {
|
||||
console.log('utils/account.json load failed')
|
||||
}
|
||||
for (let user of pushplusArr) {
|
||||
if (user.pushplus)
|
||||
pushplusUser.push(decodeURIComponent(user.pt_pin))
|
||||
}
|
||||
if (existsSync('./json')) {
|
||||
if (existsSync('./json/jd_track.json')) {
|
||||
orders = JSON.parse(readFileSync('./json/jd_track.json').toString() || '{}')
|
||||
} else {
|
||||
writeFileSync('./json/jd_track.json', '{}')
|
||||
}
|
||||
} else {
|
||||
mkdirSync('./json')
|
||||
writeFileSync('./json/jd_track.json', '{}')
|
||||
}
|
||||
for (let [index, value] of cookiesArr.entries()) {
|
||||
cookie = value
|
||||
UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1])
|
||||
console.log(`\n开始【京东账号${index + 1}】${UserName}\n`)
|
||||
|
||||
if (except.includes(encodeURIComponent(UserName))) {
|
||||
console.log('已设置跳过')
|
||||
continue
|
||||
}
|
||||
|
||||
let message: string = '', markdown: string = '', i: number = 1
|
||||
|
||||
let headers: object = {
|
||||
'authority': 'wq.jd.com',
|
||||
'user-agent': USER_AGENT,
|
||||
'referer': 'https://wqs.jd.com/',
|
||||
'cookie': cookie
|
||||
}
|
||||
|
||||
res = await get(`https://wq.jd.com/bases/orderlist/list?order_type=2&start_page=1&last_page=0&page_size=10&callersource=mainorder&t=${Date.now()}&sceneval=2&_=${Date.now()}&sceneval=2`, headers)
|
||||
await wait(1000)
|
||||
|
||||
for (let order of res.orderList) {
|
||||
let orderId: string = order.orderId
|
||||
let orderType: string = order.orderType
|
||||
let title: string = order.productList[0].title
|
||||
let t: string = order.progressInfo?.tip || null
|
||||
let status: string = order.progressInfo?.content || null
|
||||
let shopName: string = order.shopInfo.shopName
|
||||
|
||||
res = await get(`https://wq.jd.com/bases/wuliudetail/dealloglist?deal_id=${orderId}&orderstate=15&ordertype=${orderType}&t=${Date.now()}&sceneval=2`, headers)
|
||||
await wait(1000)
|
||||
let carrier: string = res.carrier, carriageId: string = res.carriageId
|
||||
|
||||
if (t && status) {
|
||||
if (status.match(/(?=签收|已取走|已暂存)/))
|
||||
continue
|
||||
if (!pushplusUser.includes(UserName)) {
|
||||
console.log(`<${shopName}>\t${title}`)
|
||||
console.log('\t', t, status)
|
||||
console.log()
|
||||
} else {
|
||||
console.log('隐私保护,不显示日志')
|
||||
}
|
||||
if (!Object.keys(orders).includes(orderId) || orders[orderId]['status'] !== status) {
|
||||
if (pushplusUser.includes(UserName)) {
|
||||
console.log('+ pushplus')
|
||||
markdown += `${i++}. ${title}\n\t- ${carrier} ${carriageId}\n\t- ${t} ${status}\n`
|
||||
} else {
|
||||
console.log('+ sendNotify')
|
||||
message += `<${shopName}>\t${title}\n${carrier} ${carriageId}\n${t} ${status}\n\n`
|
||||
}
|
||||
}
|
||||
orders[orderId] = {
|
||||
user: UserName, shopName, title, t, status, carrier, carriageId
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (message) {
|
||||
message = `【京东账号${index + 1}】 ${UserName}\n\n${message}`
|
||||
allMessage += message
|
||||
}
|
||||
if (markdown) {
|
||||
markdown = `#### <${UserName}>\n${markdown}`
|
||||
await pushplus('京东快递更新', markdown, 'markdown')
|
||||
}
|
||||
await wait(1000)
|
||||
}
|
||||
|
||||
|
||||
let account: { pt_pin: string, remarks: string }[] = []
|
||||
try {
|
||||
account = JSON.parse(readFileSync('./utils/account.json').toString())
|
||||
} catch (e) {
|
||||
console.log('utils/account.json load failed')
|
||||
}
|
||||
|
||||
// 删除已签收
|
||||
Object.keys(orders).map(key => {
|
||||
if (orders[key].status.match(/(?=签收|已取走|已暂存)/)) {
|
||||
delete orders[key]
|
||||
}
|
||||
if (pushplusUser.includes(orders[key].user)) {
|
||||
orders[key].title = '******'
|
||||
}
|
||||
})
|
||||
|
||||
// 替换通知中的用户名为备注
|
||||
orders = JSON.stringify(orders, null, 2)
|
||||
for (let acc of account) {
|
||||
orders = orders.replace(new RegExp(decodeURIComponent(acc.pt_pin), 'g'), acc.remarks ?? acc.pt_pin)
|
||||
}
|
||||
writeFileSync('./json/jd_track.json', orders)
|
||||
if (allMessage)
|
||||
await sendNotify('京东快递更新', allMessage)
|
||||
})()
|
43
jd_wechat_sign.ts
Normal file
43
jd_wechat_sign.ts
Normal file
@ -0,0 +1,43 @@
|
||||
/**
|
||||
* 微信小程序签到红包
|
||||
* cron: 8 0 * * *
|
||||
*/
|
||||
|
||||
import {sendNotify} from './sendNotify'
|
||||
import {post, requireConfig, wait} from './TS_USER_AGENTS'
|
||||
import {H5ST} from "./utils/h5st"
|
||||
|
||||
let cookie: string = '', res: any = '', UserName: string, msg: string = '', h5stTool: H5ST = new H5ST("9a38a", 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15F79 MicroMessenger/8.0.15(0x18000f2e) NetType/WIFI Language/zh_CN', "6468223550974529");
|
||||
|
||||
!(async () => {
|
||||
let cookiesArr: string[] = await requireConfig()
|
||||
for (let [index, value] of cookiesArr.entries()) {
|
||||
cookie = value
|
||||
UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1])
|
||||
console.log(`\n开始【京东账号${index + 1}】${UserName}\n`)
|
||||
|
||||
await h5stTool.__genAlgo()
|
||||
let timestamp: number = Date.now()
|
||||
let h5st: string = h5stTool.__genH5st({
|
||||
appid: 'hot_channel',
|
||||
body: JSON.stringify({"activityId": "10002"}),
|
||||
client: 'android',
|
||||
clientVersion: '7.16.250',
|
||||
functionId: 'SignComponent_doSignTask',
|
||||
t: timestamp.toString(),
|
||||
})
|
||||
res = await post(`https://api.m.jd.com/signTask/doSignTask?functionId=SignComponent_doSignTask&appid=hot_channel&body={"activityId":"10002"}&client=android&clientVersion=7.16.250&t=${timestamp}&h5st=${h5st}`, '', {
|
||||
'content-type': 'application/json',
|
||||
'user-agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15F79 MicroMessenger/8.0.15(0x18000f2e) NetType/WIFI Language/zh_CN',
|
||||
'referer': 'https://servicewechat.com/wx91d27dbf599dff74/581/page-frame.html',
|
||||
'cookie': cookie
|
||||
})
|
||||
if (res.data) {
|
||||
console.log('已签到', res.data.signDays, '天,奖励', res.data.rewardValue, '元')
|
||||
msg += `【京东账号${index + 1}】 ${UserName}\n已签到 ${res.data.signDays}天\n奖励 ${res.data.rewardValue}元\n\n`
|
||||
} else
|
||||
console.log(res.message)
|
||||
await wait(3000)
|
||||
}
|
||||
await sendNotify('微信小程序签到红包', msg)
|
||||
})()
|
@ -25,8 +25,8 @@ let message = '', allMessage = '';
|
||||
//IOS等用户直接用NobyDa的jd cookie
|
||||
let cookiesArr = [], cookie = '';
|
||||
const JD_API_HOST = 'https://api.m.jd.com/client.action';
|
||||
let appIdArr = ['1EFBTxa6H','1FFVQyqw','1EFRWxKuG', '1E1xZy6s'];
|
||||
let appNameArr = ['森林历险记','1111点心动','许愿抽好礼', 'PLUS生活特权'];
|
||||
let appIdArr = ['1EFFSyqaC','1FFVQyqw','1EFRWxKuG', '1E1xZy6s'];
|
||||
let appNameArr = ['吃货嘉年华','1111点心动','许愿抽好礼', 'PLUS生活特权'];
|
||||
let appId, appName;
|
||||
$.shareCode = [];
|
||||
if ($.isNode()) {
|
||||
|
@ -14,7 +14,7 @@ const querystring = require('querystring');
|
||||
const exec = require('child_process').exec;
|
||||
const $ = new Env();
|
||||
const timeout = 15000; //超时时间(单位毫秒)
|
||||
console.log("加载sendNotify,当前版本: 20220327");
|
||||
console.log("加载sendNotify,当前版本: 20220504");
|
||||
// =======================================go-cqhttp通知设置区域===========================================
|
||||
//gobot_url 填写请求地址http://127.0.0.1/send_private_msg
|
||||
//gobot_token 填写在go-cqhttp文件设置的访问密钥
|
||||
@ -410,15 +410,6 @@ async function sendNotify(text, desp, params = {}, author = '\n\n本通知 By cc
|
||||
}
|
||||
}
|
||||
|
||||
//检查黑名单屏蔽通知
|
||||
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 = "东东农场领取";
|
||||
@ -470,6 +461,15 @@ async function sendNotify(text, desp, params = {}, author = '\n\n本通知 By cc
|
||||
|
||||
console.log("通知标题: " + strTitle);
|
||||
|
||||
//检查黑名单屏蔽通知
|
||||
const notifySkipList = process.env.NOTIFY_SKIP_LIST ? process.env.NOTIFY_SKIP_LIST.split('&') : [];
|
||||
let titleIndex = notifySkipList.findIndex((item) => item === strTitle);
|
||||
|
||||
if (titleIndex !== -1) {
|
||||
console.log(`${strTitle} 在推送黑名单中,已跳过推送`);
|
||||
return;
|
||||
}
|
||||
|
||||
//检查脚本名称是否需要通知到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);
|
||||
|
@ -1,15 +1,10 @@
|
||||
/*
|
||||
由于 canvas 依赖系统底层需要编译且预编译包在 github releases 上,改用另一个纯 js 解码图片。若想继续使用 canvas 可调用 runWithCanvas 。
|
||||
|
||||
添加 injectToRequest 用以快速修复需验证的请求。eg: $.get=injectToRequest($.get.bind($))
|
||||
*/
|
||||
const https = require('https');
|
||||
const http = require('http');
|
||||
const stream = require('stream');
|
||||
const zlib = require('zlib');
|
||||
const vm = require('vm');
|
||||
const PNG = require('png-js');
|
||||
const UA = require('../USER_AGENTS.js').USER_AGENT;
|
||||
let UA = require('../USER_AGENTS.js').USER_AGENT;
|
||||
const validatorCount = process.env.JDJR_validator_Count ? process.env.JDJR_validator_Count : 100
|
||||
|
||||
|
||||
Math.avg = function average() {
|
||||
@ -33,14 +28,10 @@ class PNGDecoder extends PNG {
|
||||
|
||||
decodeToPixels() {
|
||||
return new Promise((resolve) => {
|
||||
try {
|
||||
this.decode((pixels) => {
|
||||
this.pixels = pixels;
|
||||
resolve();
|
||||
});
|
||||
} catch (e) {
|
||||
console.info(e)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -74,14 +65,10 @@ class PuzzleRecognizer {
|
||||
}
|
||||
|
||||
async run() {
|
||||
try {
|
||||
await this.bg.decodeToPixels();
|
||||
await this.patch.decodeToPixels();
|
||||
|
||||
return this.recognize();
|
||||
} catch (e) {
|
||||
console.info(e)
|
||||
}
|
||||
}
|
||||
|
||||
recognize() {
|
||||
@ -215,19 +202,19 @@ const DATA = {
|
||||
"product": "embed",
|
||||
"lang": "zh_CN",
|
||||
};
|
||||
const SERVER = '61.49.99.122';
|
||||
const SERVER = 'iv.jd.com';
|
||||
|
||||
class JDJRValidator {
|
||||
constructor() {
|
||||
this.data = {};
|
||||
this.x = 0;
|
||||
this.t = Date.now();
|
||||
this.count = 0;
|
||||
}
|
||||
|
||||
async run(scene) {
|
||||
try {
|
||||
async run(scene = 'cww', eid='') {
|
||||
const tryRecognize = async () => {
|
||||
const x = await this.recognize(scene);
|
||||
const x = await this.recognize(scene, eid);
|
||||
|
||||
if (x > 0) {
|
||||
return x;
|
||||
@ -243,6 +230,7 @@ class JDJRValidator {
|
||||
// console.log(pos[pos.length-1][2] -Date.now());
|
||||
// await sleep(4500);
|
||||
await sleep(pos[pos.length - 1][2] - Date.now());
|
||||
this.count++;
|
||||
const result = await JDJRValidator.jsonp('/slide/s.html', {d, ...this.data}, scene);
|
||||
|
||||
if (result.message === 'success') {
|
||||
@ -250,39 +238,38 @@ class JDJRValidator {
|
||||
console.log('JDJR验证用时: %fs', (Date.now() - this.t) / 1000);
|
||||
return result;
|
||||
} else {
|
||||
console.count("验证失败");
|
||||
// console.count(JSON.stringify(result));
|
||||
console.log(`验证失败: ${this.count}/${validatorCount}`);
|
||||
// console.log(JSON.stringify(result));
|
||||
if(this.count >= validatorCount){
|
||||
console.log("JDJR验证次数已达上限,退出验证");
|
||||
return result;
|
||||
}else{
|
||||
await sleep(300);
|
||||
return await this.run(scene);
|
||||
return await this.run(scene, eid);
|
||||
}
|
||||
} catch (e) {
|
||||
console.info(e)
|
||||
}
|
||||
}
|
||||
|
||||
async recognize(scene) {
|
||||
try {
|
||||
const data = await JDJRValidator.jsonp('/slide/g.html', {e: ''}, scene);
|
||||
async recognize(scene, eid) {
|
||||
const data = await JDJRValidator.jsonp('/slide/g.html', {e: eid}, scene);
|
||||
const {bg, patch, y} = data;
|
||||
// const uri = 'data:image/png;base64,';
|
||||
// const re = new PuzzleRecognizer(uri+bg, uri+patch, y);
|
||||
const re = new PuzzleRecognizer(bg, patch, y);
|
||||
// console.log(JSON.stringify(re))
|
||||
const puzzleX = await re.run();
|
||||
|
||||
if (puzzleX > 0) {
|
||||
this.data = {
|
||||
c: data.challenge,
|
||||
w: re.w,
|
||||
e: '',
|
||||
e: eid,
|
||||
s: '',
|
||||
o: '',
|
||||
};
|
||||
this.x = puzzleX;
|
||||
}
|
||||
return puzzleX;
|
||||
} catch (e) {
|
||||
console.info(e)
|
||||
}
|
||||
}
|
||||
|
||||
async report(n) {
|
||||
@ -299,6 +286,7 @@ class JDJRValidator {
|
||||
}
|
||||
|
||||
console.log('验证成功: %f\%', (count / n) * 100);
|
||||
console.clear()
|
||||
console.timeEnd('PuzzleRecognizer');
|
||||
}
|
||||
|
||||
@ -306,19 +294,20 @@ class JDJRValidator {
|
||||
return new Promise((resolve, reject) => {
|
||||
const fnId = `jsonp_${String(Math.random()).replace('.', '')}`;
|
||||
const extraData = {callback: fnId};
|
||||
const query = new URLSearchParams({...DATA, ...{"scene": scene}, ...extraData, ...data}).toString();
|
||||
const url = `http://${SERVER}${api}?${query}`;
|
||||
const query = new URLSearchParams({...DATA,...{"scene": scene}, ...extraData, ...data}).toString();
|
||||
const url = `https://${SERVER}${api}?${query}`;
|
||||
const headers = {
|
||||
'Accept': '*/*',
|
||||
'Accept-Encoding': 'gzip,deflate,br',
|
||||
'Accept-Language': 'zh-CN,en-US',
|
||||
'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8',
|
||||
'Connection': 'keep-alive',
|
||||
'Host': SERVER,
|
||||
'Host': "iv.jd.com",
|
||||
'Proxy-Connection': 'keep-alive',
|
||||
'Referer': 'https://h5.m.jd.com/babelDiy/Zeus/2wuqXrZrhygTQzYA7VufBEpj4amH/index.html',
|
||||
'Referer': 'https://h5.m.jd.com/',
|
||||
'User-Agent': UA,
|
||||
};
|
||||
const req = http.get(url, {headers}, (response) => {
|
||||
|
||||
const req = https.get(url, {headers}, (response) => {
|
||||
let res = response;
|
||||
if (res.headers['content-encoding'] === 'gzip') {
|
||||
const unzipStream = new stream.PassThrough();
|
||||
@ -406,7 +395,7 @@ function getCoordinate(c) {
|
||||
return b.join("")
|
||||
}
|
||||
|
||||
const HZ = 5;
|
||||
const HZ = 20;
|
||||
|
||||
class MousePosFaker {
|
||||
constructor(puzzleX) {
|
||||
@ -511,43 +500,32 @@ class MousePosFaker {
|
||||
}
|
||||
}
|
||||
|
||||
// new JDJRValidator().run();
|
||||
// new JDJRValidator().report(1000);
|
||||
// console.log(getCoordinate(new MousePosFaker(100).run()));
|
||||
|
||||
function injectToRequest2(fn, scene = 'cww') {
|
||||
function injectToRequest(fn,scene = 'cww', ua = '') {
|
||||
if(ua) UA = ua
|
||||
return (opts, cb) => {
|
||||
fn(opts, async (err, resp, data) => {
|
||||
try {
|
||||
if (err) {
|
||||
console.error('验证请求失败.');
|
||||
console.error(JSON.stringify(err));
|
||||
return;
|
||||
}
|
||||
if (data.search('验证') > -1) {
|
||||
console.log('JDJR验证中......');
|
||||
const res = await new JDJRValidator().run(scene);
|
||||
if (res) {
|
||||
opts.url += `&validate=${res.validate}`;
|
||||
let arr = opts.url.split("&")
|
||||
let eid = ''
|
||||
for(let i of arr){
|
||||
if(i.indexOf("eid=")>-1){
|
||||
eid = i.split("=") && i.split("=")[1] || ''
|
||||
}
|
||||
}
|
||||
const res = await new JDJRValidator().run(scene, eid);
|
||||
|
||||
opts.url += `&validate=${res.validate}`;
|
||||
fn(opts, cb);
|
||||
} else {
|
||||
cb(err, resp, data);
|
||||
}
|
||||
} catch (e) {
|
||||
console.info(e)
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
async function injectToRequest(scene = 'cww') {
|
||||
console.log('JDJR验证中......');
|
||||
const res = await new JDJRValidator().run(scene);
|
||||
return `&validate=${res.validate}`
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
sleep,
|
||||
injectToRequest,
|
||||
injectToRequest2
|
||||
}
|
||||
exports.injectToRequest = injectToRequest;
|
||||
|
51
utils/V3.ts
Normal file
51
utils/V3.ts
Normal file
@ -0,0 +1,51 @@
|
||||
import axios from "axios";
|
||||
import {format} from "date-fns";
|
||||
|
||||
const CryptoJS = require('crypto-js')
|
||||
|
||||
let fp: string = '', tk: string = '', genKey: any = null
|
||||
|
||||
async function requestAlgo(appId: string, USER_AGENT: string = 'jdpingou;') {
|
||||
function generateFp() {
|
||||
let e = "0123456789";
|
||||
let a = 13;
|
||||
let i = '';
|
||||
for (; a--;)
|
||||
i += e[Math.random() * e.length | 0];
|
||||
return (i + Date.now()).slice(0, 16)
|
||||
}
|
||||
|
||||
fp = generateFp()
|
||||
let {data} = await axios.post(`https://cactus.jd.com/request_algo?g_ty=ajax`, `{"version":"3.0","fp":"${fp}","appId":"${appId}","timestamp":${Date.now()},"platform":"web","expandParams":""}`, {
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
"Accept-Encoding": "gzip, deflate, br",
|
||||
"Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8",
|
||||
'host': 'cactus.jd.com',
|
||||
'Referer': 'https://cactus.jd.com',
|
||||
'User-Agent': USER_AGENT
|
||||
}
|
||||
})
|
||||
tk = data.data.result.tk;
|
||||
genKey = new Function(`return ${data.data.result.algo}`)();
|
||||
return {fp, tk, genKey}
|
||||
}
|
||||
|
||||
function geth5st(t: { key: string, value: string } [], appId: string) {
|
||||
let a = ''
|
||||
t.forEach(({key, value}) => {
|
||||
a += `${key}:${value}&`
|
||||
})
|
||||
a = a.slice(0, -1)
|
||||
let time = Date.now()
|
||||
let timestamp = format(time, "yyyyMMddHHmmssSSS");
|
||||
let hash1 = genKey(tk, fp.toString(), timestamp.toString(), appId.toString(), CryptoJS).toString(CryptoJS.enc.Hex);
|
||||
const hash2 = CryptoJS.HmacSHA256(a, hash1).toString();
|
||||
return encodeURIComponent(["".concat(timestamp.toString()), "".concat(fp.toString()), "".concat(appId.toString()), "".concat(tk), "".concat(hash2), "3.0", "".concat(time.toString())].join(";"))
|
||||
}
|
||||
|
||||
export {
|
||||
requestAlgo,
|
||||
geth5st,
|
||||
}
|
13
utils/account_demo.json
Normal file
13
utils/account_demo.json
Normal file
@ -0,0 +1,13 @@
|
||||
[
|
||||
{
|
||||
"pt_pin": "与jdCookie中pt_pin相同,禁止出现中文",
|
||||
"remarks": "备注",
|
||||
"pushplus": "",
|
||||
"jdpingou": "jdpingou;",
|
||||
"joy_park_run": 0.04
|
||||
},
|
||||
{
|
||||
"pt_pin": "jd_xxxx",
|
||||
"joy_park_run": 0.08
|
||||
}
|
||||
]
|
1
utils/empty.json
Normal file
1
utils/empty.json
Normal file
@ -0,0 +1 @@
|
||||
[]
|
8
utils/exceptCookie.json
Normal file
8
utils/exceptCookie.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"jd_88hb.ts": [
|
||||
"jd_xxxxx"
|
||||
],
|
||||
"jd_jxgc.ts": [
|
||||
"%E7%A4%BA%E4%BE%8B%E8%B4%A6%E5%8F%B7"
|
||||
]
|
||||
}
|
73
utils/h5st.ts
Normal file
73
utils/h5st.ts
Normal file
@ -0,0 +1,73 @@
|
||||
import axios from "axios"
|
||||
import {format} from "date-fns"
|
||||
|
||||
const CryptoJS = require("crypto-js")
|
||||
|
||||
class H5ST {
|
||||
tk: string;
|
||||
timestamp: string;
|
||||
rd: string;
|
||||
appId: string;
|
||||
fp: string;
|
||||
time: number;
|
||||
ua: string
|
||||
enc: string;
|
||||
|
||||
constructor(appId: string, ua: string, fp: string) {
|
||||
this.appId = appId
|
||||
this.ua = ua
|
||||
this.fp = fp || this.__genFp()
|
||||
}
|
||||
|
||||
__genFp() {
|
||||
let e = "0123456789";
|
||||
let a = 13;
|
||||
let i = '';
|
||||
for (; a--;)
|
||||
i += e[Math.random() * e.length | 0];
|
||||
return (i + Date.now()).slice(0, 16)
|
||||
}
|
||||
|
||||
async __genAlgo() {
|
||||
this.time = Date.now()
|
||||
this.timestamp = format(this.time, "yyyyMMddHHmmssSSS")
|
||||
let {data} = await axios.post(`https://cactus.jd.com/request_algo?g_ty=ajax`, {
|
||||
'version': '3.0',
|
||||
'fp': this.fp,
|
||||
'appId': this.appId.toString(),
|
||||
'timestamp': this.time,
|
||||
'platform': 'web',
|
||||
'expandParams': ''
|
||||
}, {
|
||||
headers: {
|
||||
'Host': 'cactus.jd.com',
|
||||
'accept': 'application/json',
|
||||
'content-type': 'application/json',
|
||||
'user-agent': this.ua,
|
||||
}
|
||||
})
|
||||
this.tk = data.data.result.tk
|
||||
this.rd = data.data.result.algo.match(/rd='(.*)'/)[1]
|
||||
this.enc = data.data.result.algo.match(/algo\.(.*)\(/)[1]
|
||||
}
|
||||
|
||||
__genKey(tk, fp, ts, ai, algo) {
|
||||
let str = `${tk}${fp}${ts}${ai}${this.rd}`;
|
||||
return algo[this.enc](str, tk)
|
||||
}
|
||||
|
||||
__genH5st(body: object) {
|
||||
let y = this.__genKey(this.tk, this.fp, this.timestamp, this.appId, CryptoJS).toString(CryptoJS.enc.Hex)
|
||||
let s = ''
|
||||
for (let i in body) {
|
||||
i === 'body' ? s += `${i}:${CryptoJS.SHA256(body[i]).toString(CryptoJS.enc.Hex)}&` : s += `${i}:${body[i]}&`
|
||||
}
|
||||
s = s.slice(0, -1)
|
||||
s = CryptoJS.HmacSHA256(s, y).toString(CryptoJS.enc.Hex)
|
||||
return encodeURIComponent(`${this.timestamp};${this.fp};${this.appId.toString()};${this.tk};${s};3.0;${this.time.toString()}`)
|
||||
}
|
||||
}
|
||||
|
||||
export {
|
||||
H5ST
|
||||
}
|
306
utils/jd_appopen.js
Normal file
306
utils/jd_appopen.js
Normal file
@ -0,0 +1,306 @@
|
||||
/*
|
||||
|
||||
杀掉后台后打开京东app获取app_open
|
||||
在脚本日志查看值
|
||||
|
||||
[MITM]
|
||||
hostname = api.m.jd.com
|
||||
|
||||
===========Surge=================
|
||||
[Script]
|
||||
jd_appopen = type=http-request,pattern=^https:\/\/api\.m\.jd\.com\/openUpgrade, max-size=0, script-path=jd_appopen.js
|
||||
|
||||
===================Quantumult X=====================
|
||||
[rewrite_local]
|
||||
# jd_appopen
|
||||
^https:\/\/api\.m\.jd\.com\/openUpgrade url script-request-header jd_appopen.js
|
||||
|
||||
=====================Loon=====================
|
||||
[Script]
|
||||
http-request ^https:\/\/api\.m\.jd\.com\/openUpgrade script-path=jd_appopen.js, timeout=3600, tag=jd_appopen
|
||||
|
||||
*/
|
||||
|
||||
const $ = new Env("app_open")
|
||||
|
||||
let cookie = $request.headers.Cookie
|
||||
let pt_key = cookie.match(/(pt_key=[^;]*)/)[1]
|
||||
let pt_pin = cookie.match(/(pt_pin=[^;]*)/)[1]
|
||||
console.log('================')
|
||||
console.log(`${pt_key};${pt_pin};`)
|
||||
console.log('================')
|
||||
$.msg("app_open获取成功!", "在运行日志中查看")
|
||||
|
||||
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)
|
||||
}
|
28
utils/jd_joy_getInvokeKey.ts
Normal file
28
utils/jd_joy_getInvokeKey.ts
Normal file
@ -0,0 +1,28 @@
|
||||
/**
|
||||
* cron: 0 0 * * *
|
||||
*/
|
||||
|
||||
import axios from "axios";
|
||||
import {sendNotify} from '../sendNotify';
|
||||
|
||||
!(async () => {
|
||||
let res: any = await api('https://prodev.m.jd.com/mall/active/2tZssTgnQsiUqhmg5ooLSHY9XSeN/index.html')
|
||||
let file: string = 'https://storage.360buyimg.com/' + res.match(/htmlSourceUrl":"([^"]*)/)[1]
|
||||
res = await api(file)
|
||||
file = 'https:' + res.match(/src="(\/\/storage.*)"/)[1]
|
||||
res = await api(file)
|
||||
file = res.match(/invokeKey: '(.*)'/)[1]
|
||||
console.log('invokeKey:', file)
|
||||
if (file !== 'q8DNJdpcfRQ69gIx') {
|
||||
await sendNotify('invokeKey Update', file)
|
||||
}
|
||||
})()
|
||||
|
||||
async function api(url: string) {
|
||||
let {data}: any = await axios.get(url, {
|
||||
headers: {
|
||||
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.159 Safari/537.36',
|
||||
}
|
||||
})
|
||||
return data
|
||||
}
|
447
utils/jd_joy_validate.js
Normal file
447
utils/jd_joy_validate.js
Normal file
@ -0,0 +1,447 @@
|
||||
const http = require('http');
|
||||
const stream = require('stream');
|
||||
const zlib = require('zlib');
|
||||
const vm = require('vm');
|
||||
const PNG = require('png-js');
|
||||
const UA = require('../USER_AGENTS.js').USER_AGENT;
|
||||
|
||||
Math.avg = function average() {
|
||||
var sum = 0;
|
||||
var len = this.length;
|
||||
for (var i = 0; i < len; i++) {
|
||||
sum += this[i];
|
||||
}
|
||||
return sum / len;
|
||||
};
|
||||
|
||||
function sleep(timeout) {
|
||||
return new Promise((resolve) => setTimeout(resolve, timeout));
|
||||
}
|
||||
|
||||
class PNGDecoder extends PNG {
|
||||
constructor(args) {
|
||||
super(args);
|
||||
this.pixels = [];
|
||||
}
|
||||
|
||||
decodeToPixels() {
|
||||
return new Promise((resolve) => {
|
||||
this.decode((pixels) => {
|
||||
this.pixels = pixels;
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
getImageData(x, y, w, h) {
|
||||
const {pixels} = this;
|
||||
const len = w * h * 4;
|
||||
const startIndex = x * 4 + y * (w * 4);
|
||||
|
||||
return {data: pixels.slice(startIndex, startIndex + len)};
|
||||
}
|
||||
}
|
||||
|
||||
const PUZZLE_GAP = 8;
|
||||
const PUZZLE_PAD = 10;
|
||||
|
||||
class PuzzleRecognizer {
|
||||
constructor(bg, patch, y) {
|
||||
// console.log(bg);
|
||||
const imgBg = new PNGDecoder(Buffer.from(bg, 'base64'));
|
||||
const imgPatch = new PNGDecoder(Buffer.from(patch, 'base64'));
|
||||
|
||||
// console.log(imgBg);
|
||||
|
||||
this.bg = imgBg;
|
||||
this.patch = imgPatch;
|
||||
this.rawBg = bg;
|
||||
this.rawPatch = patch;
|
||||
this.y = y;
|
||||
this.w = imgBg.width;
|
||||
this.h = imgBg.height;
|
||||
}
|
||||
|
||||
async run() {
|
||||
await this.bg.decodeToPixels();
|
||||
await this.patch.decodeToPixels();
|
||||
|
||||
return this.recognize();
|
||||
}
|
||||
|
||||
recognize() {
|
||||
const {ctx, w: width, bg} = this;
|
||||
const {width: patchWidth, height: patchHeight} = this.patch;
|
||||
const posY = this.y + PUZZLE_PAD + ((patchHeight - PUZZLE_PAD) / 2) - (PUZZLE_GAP / 2);
|
||||
// const cData = ctx.getImageData(0, a.y + 10 + 20 - 4, 360, 8).data;
|
||||
const cData = bg.getImageData(0, posY, width, PUZZLE_GAP).data;
|
||||
const lumas = [];
|
||||
|
||||
for (let x = 0; x < width; x++) {
|
||||
var sum = 0;
|
||||
|
||||
// y xais
|
||||
for (let y = 0; y < PUZZLE_GAP; y++) {
|
||||
var idx = x * 4 + y * (width * 4);
|
||||
var r = cData[idx];
|
||||
var g = cData[idx + 1];
|
||||
var b = cData[idx + 2];
|
||||
var luma = 0.2126 * r + 0.7152 * g + 0.0722 * b;
|
||||
|
||||
sum += luma;
|
||||
}
|
||||
|
||||
lumas.push(sum / PUZZLE_GAP);
|
||||
}
|
||||
|
||||
const n = 2; // minium macroscopic image width (px)
|
||||
const margin = patchWidth - PUZZLE_PAD;
|
||||
const diff = 20; // macroscopic brightness difference
|
||||
const radius = PUZZLE_PAD;
|
||||
for (let i = 0, len = lumas.length - 2 * 4; i < len; i++) {
|
||||
const left = (lumas[i] + lumas[i + 1]) / n;
|
||||
const right = (lumas[i + 2] + lumas[i + 3]) / n;
|
||||
const mi = margin + i;
|
||||
const mLeft = (lumas[mi] + lumas[mi + 1]) / n;
|
||||
const mRigth = (lumas[mi + 2] + lumas[mi + 3]) / n;
|
||||
|
||||
if (left - right > diff && mLeft - mRigth < -diff) {
|
||||
const pieces = lumas.slice(i + 2, margin + i + 2);
|
||||
const median = pieces.sort((x1, x2) => x1 - x2)[20];
|
||||
const avg = Math.avg(pieces);
|
||||
|
||||
// noise reducation
|
||||
if (median > left || median > mRigth) return;
|
||||
if (avg > 100) return;
|
||||
// console.table({left,right,mLeft,mRigth,median});
|
||||
// ctx.fillRect(i+n-radius, 0, 1, 360);
|
||||
// console.log(i+n-radius);
|
||||
return i + n - radius;
|
||||
}
|
||||
}
|
||||
|
||||
// not found
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
const DATA = {
|
||||
"appId": "17839d5db83",
|
||||
"scene": "cww",
|
||||
"product": "embed",
|
||||
"lang": "zh_CN",
|
||||
};
|
||||
|
||||
// const SERVER = 'iv.jd.com';
|
||||
const SERVER = '61.49.99.122';
|
||||
|
||||
class JDJRValidator {
|
||||
constructor() {
|
||||
this.data = {};
|
||||
this.x = 0;
|
||||
this.t = Date.now();
|
||||
}
|
||||
|
||||
async run() {
|
||||
const tryRecognize = async () => {
|
||||
const x = await this.recognize();
|
||||
|
||||
if (x > 0) {
|
||||
return x;
|
||||
}
|
||||
// retry
|
||||
return await tryRecognize();
|
||||
};
|
||||
const puzzleX = await tryRecognize();
|
||||
// console.log(puzzleX);
|
||||
const pos = new MousePosFaker(puzzleX).run();
|
||||
const d = getCoordinate(pos);
|
||||
|
||||
// console.log(pos[pos.length-1][2] -Date.now());
|
||||
// await sleep(4500);
|
||||
await sleep(pos[pos.length - 1][2] - Date.now());
|
||||
const result = await JDJRValidator.jsonp('/slide/s.html', {d, ...this.data});
|
||||
|
||||
if (result.message === 'success') {
|
||||
console.log(result);
|
||||
console.log('JDJRValidator: %fs', (Date.now() - this.t) / 1000);
|
||||
return result;
|
||||
} else {
|
||||
console.count(JSON.stringify(result));
|
||||
await sleep(300);
|
||||
return await this.run();
|
||||
}
|
||||
}
|
||||
|
||||
async recognize() {
|
||||
const data = await JDJRValidator.jsonp('/slide/g.html', {e: ''});
|
||||
const {bg, patch, y} = data;
|
||||
// const uri = 'data:image/png;base64,';
|
||||
// const re = new PuzzleRecognizer(uri+bg, uri+patch, y);
|
||||
const re = new PuzzleRecognizer(bg, patch, y);
|
||||
const puzzleX = await re.run();
|
||||
|
||||
if (puzzleX > 0) {
|
||||
this.data = {
|
||||
c: data.challenge,
|
||||
w: re.w,
|
||||
e: '',
|
||||
s: '',
|
||||
o: '',
|
||||
};
|
||||
this.x = puzzleX;
|
||||
}
|
||||
return puzzleX;
|
||||
}
|
||||
|
||||
async report(n) {
|
||||
console.time('PuzzleRecognizer');
|
||||
let count = 0;
|
||||
|
||||
for (let i = 0; i < n; i++) {
|
||||
const x = await this.recognize();
|
||||
|
||||
if (x > 0) count++;
|
||||
if (i % 50 === 0) {
|
||||
// console.log('%f\%', (i / n) * 100);
|
||||
}
|
||||
}
|
||||
|
||||
// console.log('successful: %f\%', (count / n) * 100);
|
||||
console.timeEnd('PuzzleRecognizer');
|
||||
}
|
||||
|
||||
static jsonp(api, data = {}) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const fnId = `jsonp_${String(Math.random()).replace('.', '')}`;
|
||||
const extraData = {callback: fnId};
|
||||
const query = new URLSearchParams({...DATA, ...extraData, ...data}).toString();
|
||||
const url = `http://${SERVER}${api}?${query}`;
|
||||
const headers = {
|
||||
'Accept': '*/*',
|
||||
'Accept-Encoding': 'gzip,deflate,br',
|
||||
'Accept-Language': 'zh-CN,en-US',
|
||||
'Connection': 'keep-alive',
|
||||
'Host': SERVER,
|
||||
'Proxy-Connection': 'keep-alive',
|
||||
'Referer': 'https://h5.m.jd.com/babelDiy/Zeus/2wuqXrZrhygTQzYA7VufBEpj4amH/index.html',
|
||||
'User-Agent': UA,
|
||||
};
|
||||
const req = http.get(url, {headers}, (response) => {
|
||||
try {
|
||||
let res = response;
|
||||
if (res.headers['content-encoding'] === 'gzip') {
|
||||
const unzipStream = new stream.PassThrough();
|
||||
stream.pipeline(
|
||||
response,
|
||||
zlib.createGunzip(),
|
||||
unzipStream,
|
||||
reject,
|
||||
);
|
||||
res = unzipStream;
|
||||
}
|
||||
res.setEncoding('utf8');
|
||||
|
||||
let rawData = '';
|
||||
|
||||
res.on('data', (chunk) => rawData += chunk);
|
||||
res.on('end', () => {
|
||||
try {
|
||||
const ctx = {
|
||||
[fnId]: (data) => ctx.data = data,
|
||||
data: {},
|
||||
};
|
||||
vm.createContext(ctx);
|
||||
vm.runInContext(rawData, ctx);
|
||||
res.resume();
|
||||
resolve(ctx.data);
|
||||
} catch (e) {
|
||||
console.log('生成验证码必须使用大陆IP')
|
||||
}
|
||||
})
|
||||
} catch (e) {
|
||||
}
|
||||
})
|
||||
|
||||
req.on('error', reject);
|
||||
req.end();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function getCoordinate(c) {
|
||||
function string10to64(d) {
|
||||
var c = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-~".split("")
|
||||
, b = c.length
|
||||
, e = +d
|
||||
, a = [];
|
||||
do {
|
||||
mod = e % b;
|
||||
e = (e - mod) / b;
|
||||
a.unshift(c[mod])
|
||||
} while (e);
|
||||
return a.join("")
|
||||
}
|
||||
|
||||
function prefixInteger(a, b) {
|
||||
return (Array(b).join(0) + a).slice(-b)
|
||||
}
|
||||
|
||||
function pretreatment(d, c, b) {
|
||||
var e = string10to64(Math.abs(d));
|
||||
var a = "";
|
||||
if (!b) {
|
||||
a += (d > 0 ? "1" : "0")
|
||||
}
|
||||
a += prefixInteger(e, c);
|
||||
return a
|
||||
}
|
||||
|
||||
var b = new Array();
|
||||
for (var e = 0; e < c.length; e++) {
|
||||
if (e == 0) {
|
||||
b.push(pretreatment(c[e][0] < 262143 ? c[e][0] : 262143, 3, true));
|
||||
b.push(pretreatment(c[e][1] < 16777215 ? c[e][1] : 16777215, 4, true));
|
||||
b.push(pretreatment(c[e][2] < 4398046511103 ? c[e][2] : 4398046511103, 7, true))
|
||||
} else {
|
||||
var a = c[e][0] - c[e - 1][0];
|
||||
var f = c[e][1] - c[e - 1][1];
|
||||
var d = c[e][2] - c[e - 1][2];
|
||||
b.push(pretreatment(a < 4095 ? a : 4095, 2, false));
|
||||
b.push(pretreatment(f < 4095 ? f : 4095, 2, false));
|
||||
b.push(pretreatment(d < 16777215 ? d : 16777215, 4, true))
|
||||
}
|
||||
}
|
||||
return b.join("")
|
||||
}
|
||||
|
||||
const HZ = 5;
|
||||
|
||||
class MousePosFaker {
|
||||
constructor(puzzleX) {
|
||||
this.x = parseInt(Math.random() * 20 + 20, 10);
|
||||
this.y = parseInt(Math.random() * 80 + 80, 10);
|
||||
this.t = Date.now();
|
||||
this.pos = [[this.x, this.y, this.t]];
|
||||
this.minDuration = parseInt(1000 / HZ, 10);
|
||||
// this.puzzleX = puzzleX;
|
||||
this.puzzleX = puzzleX + parseInt(Math.random() * 2 - 1, 10);
|
||||
|
||||
this.STEP = parseInt(Math.random() * 6 + 5, 10);
|
||||
this.DURATION = parseInt(Math.random() * 7 + 14, 10) * 100;
|
||||
// [9,1600] [10,1400]
|
||||
this.STEP = 9;
|
||||
// this.DURATION = 2000;
|
||||
// console.log(this.STEP, this.DURATION);
|
||||
}
|
||||
|
||||
run() {
|
||||
const perX = this.puzzleX / this.STEP;
|
||||
const perDuration = this.DURATION / this.STEP;
|
||||
const firstPos = [this.x - parseInt(Math.random() * 6, 10), this.y + parseInt(Math.random() * 11, 10), this.t];
|
||||
|
||||
this.pos.unshift(firstPos);
|
||||
this.stepPos(perX, perDuration);
|
||||
this.fixPos();
|
||||
|
||||
const reactTime = parseInt(60 + Math.random() * 100, 10);
|
||||
const lastIdx = this.pos.length - 1;
|
||||
const lastPos = [this.pos[lastIdx][0], this.pos[lastIdx][1], this.pos[lastIdx][2] + reactTime];
|
||||
|
||||
this.pos.push(lastPos);
|
||||
return this.pos;
|
||||
}
|
||||
|
||||
stepPos(x, duration) {
|
||||
let n = 0;
|
||||
const sqrt2 = Math.sqrt(2);
|
||||
for (let i = 1; i <= this.STEP; i++) {
|
||||
n += 1 / i;
|
||||
}
|
||||
for (let i = 0; i < this.STEP; i++) {
|
||||
x = this.puzzleX / (n * (i + 1));
|
||||
const currX = parseInt((Math.random() * 30 - 15) + x, 10);
|
||||
const currY = parseInt(Math.random() * 7 - 3, 10);
|
||||
const currDuration = parseInt((Math.random() * 0.4 + 0.8) * duration, 10);
|
||||
|
||||
this.moveToAndCollect({
|
||||
x: currX,
|
||||
y: currY,
|
||||
duration: currDuration,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
fixPos() {
|
||||
const actualX = this.pos[this.pos.length - 1][0] - this.pos[1][0];
|
||||
const deviation = this.puzzleX - actualX;
|
||||
|
||||
if (Math.abs(deviation) > 4) {
|
||||
this.moveToAndCollect({
|
||||
x: deviation,
|
||||
y: parseInt(Math.random() * 8 - 3, 10),
|
||||
duration: 250,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
moveToAndCollect({x, y, duration}) {
|
||||
let movedX = 0;
|
||||
let movedY = 0;
|
||||
let movedT = 0;
|
||||
const times = duration / this.minDuration;
|
||||
let perX = x / times;
|
||||
let perY = y / times;
|
||||
let padDuration = 0;
|
||||
|
||||
if (Math.abs(perX) < 1) {
|
||||
padDuration = duration / Math.abs(x) - this.minDuration;
|
||||
perX = 1;
|
||||
perY = y / Math.abs(x);
|
||||
}
|
||||
|
||||
while (Math.abs(movedX) < Math.abs(x)) {
|
||||
const rDuration = parseInt(padDuration + Math.random() * 16 - 4, 10);
|
||||
|
||||
movedX += perX + Math.random() * 2 - 1;
|
||||
movedY += perY;
|
||||
movedT += this.minDuration + rDuration;
|
||||
|
||||
const currX = parseInt(this.x + movedX, 10);
|
||||
const currY = parseInt(this.y + movedY, 10);
|
||||
const currT = this.t + movedT;
|
||||
|
||||
this.pos.push([currX, currY, currT]);
|
||||
}
|
||||
|
||||
this.x += x;
|
||||
this.y += y;
|
||||
this.t += Math.max(duration, movedT);
|
||||
}
|
||||
}
|
||||
|
||||
function injectToRequest(fn) {
|
||||
return (opts, cb) => {
|
||||
fn(opts, async (err, resp, data) => {
|
||||
if (err) {
|
||||
console.error('Failed to request.');
|
||||
return;
|
||||
}
|
||||
|
||||
if (data.search('验证') > -1) {
|
||||
console.log('JDJRValidator trying......');
|
||||
const res = await new JDJRValidator().run();
|
||||
|
||||
opts.url += `&validate=${res.validate}`;
|
||||
fn(opts, cb);
|
||||
} else {
|
||||
cb(err, resp, data);
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
JDJRValidator,
|
||||
injectToRequest
|
||||
}
|
54
utils/jd_jxmc.js
Normal file
54
utils/jd_jxmc.js
Normal file
File diff suppressed because one or more lines are too long
237
utils/jd_zjd_tool.js
Normal file
237
utils/jd_zjd_tool.js
Normal file
@ -0,0 +1,237 @@
|
||||
const axios = require('axios');
|
||||
const CryptoJS = require('crypto-js')
|
||||
const {format} = require("date-fns");
|
||||
let tk = '', genKey = null
|
||||
|
||||
var _0xodn = 'jsjiami.com.v6', _0xodn_ = ['_0xodn'],
|
||||
_0x3b72 = [_0xodn, 'wro/eFkzwpkZ', 'wrUMK8Kj', 'D1jCtlJvwrY=', 'NQpkwoE=', 'wozDssKdajXCocKNwqo6wpbCgcOsZ8KsPHjDuiDCuE83', 'wp/CpMKffzTDqMOLw6o3w5XDmMK6IcOxIjDCsizCvVB4TcO4w44uXgpwwqh4wop7S8KcwrrDmMOcw4jDnBB4XMKxwrokwqkUJMO/eVRsZhfDojIIIQTCiMOyI8OVbBRSLAQD', 'woQZWw==', 'wr91w6IJw7LDnMOpecOqO8KQQsKcKcKqw4gALsOAdjR6ZyTCqMKsXsOdCMKICsO6QsKAZMKa', 'w4U8wp/Cq3jCmn52BnfDv8KJZsKywqUT', 'E1PCrHjChw==', 'TjbCr8K6wp0=', 'DlfCvl7CmWNlEzlxEWnDgE7CpsKzw67DnkZpYsOvDsOGw5ovw7ZfPsKsYsKGS8OzRsOXO1DDr8Kgw5Juwq3DlkHCoFvDnMKSwqnCgMOpw5xRJcKrcMOqwqbCpcKzw49+w5NewpYqwqdWwo4UKsOkwrNiw5XDk2nCpMKxL8KJw6TCu8OVXHHDiUXCoQxCw4XDmsOTd8KcJ8OJTcKQwrbDsjgww5ggwoPDh1LCpSACw7bDssKcW8K9w5jDlMKpwrHCi8ObMsOxwpUPw74hH8OSJMKJAUvCicKfAcO6wqAVAMK4f1BKSHpUeMOkCsOudsOaw54Tw7bDrMKJwpo8HMKoRcK4HcOVdMK8wp07worDrQ7DnzQFWcKXWFHCuWE4esOYwrjCscKVbU/Cun3CucKQwrTCkcKIwp1L', 'IA5mwoA=', 'Xi3DhGA=', 'wr8fZkvDoyM=', 'jUMsUjViEbaMYgminN.HXcoHmh.v6=='];
|
||||
if (function (_0x2743f4, _0x3fb1a4, _0x305864) {
|
||||
function _0x262557(_0x12e420, _0x159a53, _0x5a10b1, _0x549630, _0x34e649, _0x48a933) {
|
||||
_0x159a53 = _0x159a53 >> 0x8, _0x34e649 = 'po';
|
||||
var _0x173d72 = 'shift', _0x2b02e9 = 'push', _0x48a933 = '';
|
||||
if (_0x159a53 < _0x12e420) {
|
||||
while (--_0x12e420) {
|
||||
_0x549630 = _0x2743f4[_0x173d72]();
|
||||
if (_0x159a53 === _0x12e420 && _0x48a933 === '' && _0x48a933['length'] === 0x1) {
|
||||
_0x159a53 = _0x549630, _0x5a10b1 = _0x2743f4[_0x34e649 + 'p']();
|
||||
} else if (_0x159a53 && _0x5a10b1['replace'](/[UMUVEbMYgnNHXHh=]/g, '') === _0x159a53) {
|
||||
_0x2743f4[_0x2b02e9](_0x549630);
|
||||
}
|
||||
}
|
||||
_0x2743f4[_0x2b02e9](_0x2743f4[_0x173d72]());
|
||||
}
|
||||
return 0xd646f;
|
||||
};
|
||||
return _0x262557(++_0x3fb1a4, _0x305864) >> _0x3fb1a4 ^ _0x305864;
|
||||
}(_0x3b72, 0xf4, 0xf400), _0x3b72) {
|
||||
_0xodn_ = _0x3b72['length'] ^ 0xf4;
|
||||
}
|
||||
;
|
||||
|
||||
function _0x10b2(_0x45658b, _0xa6ed42) {
|
||||
_0x45658b = ~~'0x'['concat'](_0x45658b['slice'](0x1));
|
||||
var _0x1c3a83 = _0x3b72[_0x45658b];
|
||||
if (_0x10b2['LvPUvb'] === undefined) {
|
||||
(function () {
|
||||
var _0x563495 = typeof window !== 'undefined' ? window : typeof process === 'object' && typeof require === 'function' && typeof global === 'object' ? global : this;
|
||||
var _0x37b199 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
||||
_0x563495['atob'] || (_0x563495['atob'] = function (_0x1eac82) {
|
||||
var _0x16b82d = String(_0x1eac82)['replace'](/=+$/, '');
|
||||
for (var _0xee2dd0 = 0x0, _0x4d50ce, _0x4339f9, _0x17dab4 = 0x0, _0x52b38d = ''; _0x4339f9 = _0x16b82d['charAt'](_0x17dab4++); ~_0x4339f9 && (_0x4d50ce = _0xee2dd0 % 0x4 ? _0x4d50ce * 0x40 + _0x4339f9 : _0x4339f9, _0xee2dd0++ % 0x4) ? _0x52b38d += String['fromCharCode'](0xff & _0x4d50ce >> (-0x2 * _0xee2dd0 & 0x6)) : 0x0) {
|
||||
_0x4339f9 = _0x37b199['indexOf'](_0x4339f9);
|
||||
}
|
||||
return _0x52b38d;
|
||||
});
|
||||
}());
|
||||
|
||||
function _0x565be9(_0x1ed74f, _0xa6ed42) {
|
||||
var _0xc416e3 = [], _0x536e9b = 0x0, _0x7e5a8a, _0xdf715e = '', _0x3b5e2b = '';
|
||||
_0x1ed74f = atob(_0x1ed74f);
|
||||
for (var _0x25153a = 0x0, _0x28040c = _0x1ed74f['length']; _0x25153a < _0x28040c; _0x25153a++) {
|
||||
_0x3b5e2b += '%' + ('00' + _0x1ed74f['charCodeAt'](_0x25153a)['toString'](0x10))['slice'](-0x2);
|
||||
}
|
||||
_0x1ed74f = decodeURIComponent(_0x3b5e2b);
|
||||
for (var _0x38a058 = 0x0; _0x38a058 < 0x100; _0x38a058++) {
|
||||
_0xc416e3[_0x38a058] = _0x38a058;
|
||||
}
|
||||
for (_0x38a058 = 0x0; _0x38a058 < 0x100; _0x38a058++) {
|
||||
_0x536e9b = (_0x536e9b + _0xc416e3[_0x38a058] + _0xa6ed42['charCodeAt'](_0x38a058 % _0xa6ed42['length'])) % 0x100;
|
||||
_0x7e5a8a = _0xc416e3[_0x38a058];
|
||||
_0xc416e3[_0x38a058] = _0xc416e3[_0x536e9b];
|
||||
_0xc416e3[_0x536e9b] = _0x7e5a8a;
|
||||
}
|
||||
_0x38a058 = 0x0;
|
||||
_0x536e9b = 0x0;
|
||||
for (var _0x399e67 = 0x0; _0x399e67 < _0x1ed74f['length']; _0x399e67++) {
|
||||
_0x38a058 = (_0x38a058 + 0x1) % 0x100;
|
||||
_0x536e9b = (_0x536e9b + _0xc416e3[_0x38a058]) % 0x100;
|
||||
_0x7e5a8a = _0xc416e3[_0x38a058];
|
||||
_0xc416e3[_0x38a058] = _0xc416e3[_0x536e9b];
|
||||
_0xc416e3[_0x536e9b] = _0x7e5a8a;
|
||||
_0xdf715e += String['fromCharCode'](_0x1ed74f['charCodeAt'](_0x399e67) ^ _0xc416e3[(_0xc416e3[_0x38a058] + _0xc416e3[_0x536e9b]) % 0x100]);
|
||||
}
|
||||
return _0xdf715e;
|
||||
}
|
||||
|
||||
_0x10b2['SYVfKK'] = _0x565be9;
|
||||
_0x10b2['DcCxBY'] = {};
|
||||
_0x10b2['LvPUvb'] = !![];
|
||||
}
|
||||
var _0x185efa = _0x10b2['DcCxBY'][_0x45658b];
|
||||
if (_0x185efa === undefined) {
|
||||
if (_0x10b2['XNcqmw'] === undefined) {
|
||||
_0x10b2['XNcqmw'] = !![];
|
||||
}
|
||||
_0x1c3a83 = _0x10b2['SYVfKK'](_0x1c3a83, _0xa6ed42);
|
||||
_0x10b2['DcCxBY'][_0x45658b] = _0x1c3a83;
|
||||
} else {
|
||||
_0x1c3a83 = _0x185efa;
|
||||
}
|
||||
return _0x1c3a83;
|
||||
};
|
||||
|
||||
function zjdInit() {
|
||||
var _0x5b6562 = {
|
||||
'UHkNG': function (_0x1dee04) {
|
||||
return _0x1dee04();
|
||||
}, 'PkhOr': 'cactus.jd.com', 'vcwqy': _0x10b2('0', 'T5oN')
|
||||
};
|
||||
return new Promise(_0x3e8e66 => {
|
||||
axios['post']('https://cactus.jd.com/request_algo?g_ty=ajax', _0x10b2('1', 'T5oN') + Date[_0x10b2('2', 'Y8g5')]() + _0x10b2('3', 'Cs^f'), {
|
||||
'headers': {
|
||||
'Content-Type': _0x10b2('4', '41Yi'),
|
||||
'host': _0x5b6562[_0x10b2('5', 'otKY')],
|
||||
'Referer': _0x5b6562[_0x10b2('6', 'JEgu')],
|
||||
'User-Agent': _0x10b2('7', 'otKY')
|
||||
}
|
||||
})[_0x10b2('8', ')mWR')](_0x20c5db => {
|
||||
tk = _0x20c5db[_0x10b2('9', 'QWq9')]['data'][_0x10b2('a', 'brNj')]['tk'];
|
||||
genKey = new Function(_0x10b2('b', '[LTK') + _0x20c5db['data'][_0x10b2('c', 'net@')][_0x10b2('d', 'XS2!')][_0x10b2('e', ')mWR')])();
|
||||
_0x5b6562['UHkNG'](_0x3e8e66);
|
||||
});
|
||||
});
|
||||
};_0xodn = 'jsjiami.com.v6';
|
||||
var _0xod6 = 'jsjiami.com.v6', _0xod6_ = ['_0xod6'],
|
||||
_0x27ab = [_0xod6, 'LcOUw6zCtcKB', 'woMBw5w=', 'wr3DlX/CjDI=', 'w4jDtcKnw4JuMcKCwrg=', 'w6nDq8KmwqlF', 'w45sHcK/wqzDpnZI', 'w59tLQ==', 'wpJew68=', 'w6lbR15iQgLDmQTCqw==', 'w4p5wr7ChwVZbMKt', 'bVjDi2LDtsOm', 'wpzCg8OdKGnCr1Qx', 'wo4Bw4UCBS0=', 'w7XDl0TCrcKu', 'JcOUWMO5ZUE=', 'bcOmSjRvw6U=', 'w7dvOsKnwp0=', 'HcOfwpPCq8OoKg==', 'wqd4eRzDvE40w60=', 'N8KtMB4=', 'HMOfwpnCsQ==', 'JMKIAsKoYQ==', 'w7EkAFpBJXR9w6bCq8KYw6w8w65RYA==', 'bsOsaQ==', 'VcONUcOMwrg=', 'b8O5VD5q', 'w7diAMKuwrk=', 'w57DtcKQw48=', 'P2tawoJzw7tTwrRxMg==', 'Jn7DgyLCui/Clg==', 'IPjsjiaKWmFXDUi.cgZSToSRmQ.vG6=='];
|
||||
if (function (_0x4e8c73, _0x49b949, _0x2c3ac) {
|
||||
function _0x2d2117(_0x11fa21, _0x2e2494, _0x148ee4, _0x2156e5, _0xc853f9, _0x19be61) {
|
||||
_0x2e2494 = _0x2e2494 >> 0x8, _0xc853f9 = 'po';
|
||||
var _0x368a00 = 'shift', _0x523621 = 'push', _0x19be61 = '';
|
||||
if (_0x2e2494 < _0x11fa21) {
|
||||
while (--_0x11fa21) {
|
||||
_0x2156e5 = _0x4e8c73[_0x368a00]();
|
||||
if (_0x2e2494 === _0x11fa21 && _0x19be61 === '' && _0x19be61['length'] === 0x1) {
|
||||
_0x2e2494 = _0x2156e5, _0x148ee4 = _0x4e8c73[_0xc853f9 + 'p']();
|
||||
} else if (_0x2e2494 && _0x148ee4['replace'](/[IPKWFXDUgZSTSRQG=]/g, '') === _0x2e2494) {
|
||||
_0x4e8c73[_0x523621](_0x2156e5);
|
||||
}
|
||||
}
|
||||
_0x4e8c73[_0x523621](_0x4e8c73[_0x368a00]());
|
||||
}
|
||||
return 0xd6470;
|
||||
};
|
||||
return _0x2d2117(++_0x49b949, _0x2c3ac) >> _0x49b949 ^ _0x2c3ac;
|
||||
}(_0x27ab, 0x17c, 0x17c00), _0x27ab) {
|
||||
_0xod6_ = _0x27ab['length'] ^ 0x17c;
|
||||
}
|
||||
;
|
||||
|
||||
function _0x1d9f(_0x379f0e, _0x49209e) {
|
||||
_0x379f0e = ~~'0x'['concat'](_0x379f0e['slice'](0x1));
|
||||
var _0x1bce16 = _0x27ab[_0x379f0e];
|
||||
if (_0x1d9f['XzctjE'] === undefined) {
|
||||
(function () {
|
||||
var _0x8e43ac = typeof window !== 'undefined' ? window : typeof process === 'object' && typeof require === 'function' && typeof global === 'object' ? global : this;
|
||||
var _0x42dbb9 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
||||
_0x8e43ac['atob'] || (_0x8e43ac['atob'] = function (_0xc1e76a) {
|
||||
var _0x3446db = String(_0xc1e76a)['replace'](/=+$/, '');
|
||||
for (var _0x3ef7da = 0x0, _0x568ff1, _0x2d3643, _0x3b6731 = 0x0, _0x37d9eb = ''; _0x2d3643 = _0x3446db['charAt'](_0x3b6731++); ~_0x2d3643 && (_0x568ff1 = _0x3ef7da % 0x4 ? _0x568ff1 * 0x40 + _0x2d3643 : _0x2d3643, _0x3ef7da++ % 0x4) ? _0x37d9eb += String['fromCharCode'](0xff & _0x568ff1 >> (-0x2 * _0x3ef7da & 0x6)) : 0x0) {
|
||||
_0x2d3643 = _0x42dbb9['indexOf'](_0x2d3643);
|
||||
}
|
||||
return _0x37d9eb;
|
||||
});
|
||||
}());
|
||||
|
||||
function _0x36dc7f(_0x3b1410, _0x49209e) {
|
||||
var _0x55c058 = [], _0x257b50 = 0x0, _0x5a0d50, _0x26b891 = '', _0x56def6 = '';
|
||||
_0x3b1410 = atob(_0x3b1410);
|
||||
for (var _0x33e9f5 = 0x0, _0x28a526 = _0x3b1410['length']; _0x33e9f5 < _0x28a526; _0x33e9f5++) {
|
||||
_0x56def6 += '%' + ('00' + _0x3b1410['charCodeAt'](_0x33e9f5)['toString'](0x10))['slice'](-0x2);
|
||||
}
|
||||
_0x3b1410 = decodeURIComponent(_0x56def6);
|
||||
for (var _0x229272 = 0x0; _0x229272 < 0x100; _0x229272++) {
|
||||
_0x55c058[_0x229272] = _0x229272;
|
||||
}
|
||||
for (_0x229272 = 0x0; _0x229272 < 0x100; _0x229272++) {
|
||||
_0x257b50 = (_0x257b50 + _0x55c058[_0x229272] + _0x49209e['charCodeAt'](_0x229272 % _0x49209e['length'])) % 0x100;
|
||||
_0x5a0d50 = _0x55c058[_0x229272];
|
||||
_0x55c058[_0x229272] = _0x55c058[_0x257b50];
|
||||
_0x55c058[_0x257b50] = _0x5a0d50;
|
||||
}
|
||||
_0x229272 = 0x0;
|
||||
_0x257b50 = 0x0;
|
||||
for (var _0x107b1d = 0x0; _0x107b1d < _0x3b1410['length']; _0x107b1d++) {
|
||||
_0x229272 = (_0x229272 + 0x1) % 0x100;
|
||||
_0x257b50 = (_0x257b50 + _0x55c058[_0x229272]) % 0x100;
|
||||
_0x5a0d50 = _0x55c058[_0x229272];
|
||||
_0x55c058[_0x229272] = _0x55c058[_0x257b50];
|
||||
_0x55c058[_0x257b50] = _0x5a0d50;
|
||||
_0x26b891 += String['fromCharCode'](_0x3b1410['charCodeAt'](_0x107b1d) ^ _0x55c058[(_0x55c058[_0x229272] + _0x55c058[_0x257b50]) % 0x100]);
|
||||
}
|
||||
return _0x26b891;
|
||||
}
|
||||
|
||||
_0x1d9f['WLbbFD'] = _0x36dc7f;
|
||||
_0x1d9f['ScaaVh'] = {};
|
||||
_0x1d9f['XzctjE'] = !![];
|
||||
}
|
||||
var _0x419794 = _0x1d9f['ScaaVh'][_0x379f0e];
|
||||
if (_0x419794 === undefined) {
|
||||
if (_0x1d9f['qmTRps'] === undefined) {
|
||||
_0x1d9f['qmTRps'] = !![];
|
||||
}
|
||||
_0x1bce16 = _0x1d9f['WLbbFD'](_0x1bce16, _0x49209e);
|
||||
_0x1d9f['ScaaVh'][_0x379f0e] = _0x1bce16;
|
||||
} else {
|
||||
_0x1bce16 = _0x419794;
|
||||
}
|
||||
return _0x1bce16;
|
||||
};
|
||||
|
||||
function zjdH5st(_0x4be4df) {
|
||||
var _0x4cff43 = {
|
||||
'XOTjk': 'appid',
|
||||
'MaNeg': _0x1d9f('0', '4U@&'),
|
||||
'BYwop': function (_0x448c0d, _0x2f169d, _0x20a32e) {
|
||||
return _0x448c0d(_0x2f169d, _0x20a32e);
|
||||
},
|
||||
'uEkhV': 'yyyyMMddhhmmssSSS',
|
||||
'ZFYLd': function (_0x413960, _0x55afdb, _0x10fff9, _0xd657f3, _0x4825ba, _0x18a52d) {
|
||||
return _0x413960(_0x55afdb, _0x10fff9, _0xd657f3, _0x4825ba, _0x18a52d);
|
||||
},
|
||||
'nhcGz': _0x1d9f('1', 'THL^'),
|
||||
'BnPMu': _0x1d9f('2', 'ea1p'),
|
||||
'MltlC': _0x1d9f('3', 'ud6)')
|
||||
};
|
||||
let _0x5b05fe = [{
|
||||
'key': _0x4cff43[_0x1d9f('4', 'ws7Y')],
|
||||
'value': _0x4be4df[_0x1d9f('5', 'L%hf')]
|
||||
}, {'key': _0x4cff43[_0x1d9f('6', 'Jhwj')], 'value': _0x4be4df[_0x1d9f('7', '(kW3')]}, {
|
||||
'key': 'functionId',
|
||||
'value': _0x4be4df[_0x1d9f('8', '!zoL')]
|
||||
}], _0x593076 = '';
|
||||
_0x5b05fe[_0x1d9f('9', 'a@D4')](({key, value}) => {
|
||||
_0x593076 += key + ':' + value + '&';
|
||||
});
|
||||
_0x593076 = _0x593076[_0x1d9f('a', 'ZO!Y')](0x0, -0x1);
|
||||
let _0x24a2f4 = Date[_0x1d9f('b', '32dU')]();
|
||||
let _0x5c2223 = _0x4cff43['BYwop'](format, _0x24a2f4, _0x4cff43['uEkhV']);
|
||||
let _0x1ea52b = _0x4cff43[_0x1d9f('c', 'IG!]')](genKey, tk, '5751706390487846', _0x5c2223[_0x1d9f('d', '(kW3')](), _0x4cff43[_0x1d9f('e', 'XMEY')], CryptoJS)[_0x1d9f('f', 'Jhwj')](CryptoJS[_0x1d9f('10', 'Jhwj')][_0x1d9f('11', '%epl')]);
|
||||
const _0x55d05d = CryptoJS[_0x1d9f('12', 'bhY9')](_0x593076, _0x1ea52b)[_0x1d9f('13', '57Uz')]();
|
||||
return [''[_0x1d9f('14', '(ag8')](_0x5c2223[_0x1d9f('15', 'MW(X')]()), ''[_0x1d9f('16', '32dU')](_0x4cff43['BnPMu']), ''['concat'](_0x4cff43[_0x1d9f('17', 'eG&t')]), ''[_0x1d9f('18', 'THL^')](tk), ''[_0x1d9f('19', 'L%hf')](_0x55d05d), _0x4cff43[_0x1d9f('1a', 'Jhwj')], ''[_0x1d9f('1b', '4U@&')](_0x24a2f4[_0x1d9f('1c', '#7Xk')]())][_0x1d9f('1d', 'ud6)')](';');
|
||||
};_0xod6 = 'jsjiami.com.v6';
|
||||
|
||||
module.exports = {
|
||||
zjdInit,
|
||||
zjdH5st
|
||||
}
|
39
utils/pushplus.ts
Normal file
39
utils/pushplus.ts
Normal file
@ -0,0 +1,39 @@
|
||||
import axios from "axios";
|
||||
import {readFileSync} from "fs";
|
||||
|
||||
let account: { pt_pin: string, pushplus?: string } [] = []
|
||||
|
||||
try {
|
||||
account = JSON.parse(readFileSync("./utils/account.json").toString())
|
||||
} catch (e) {
|
||||
console.log('utils/account.json load failed')
|
||||
}
|
||||
|
||||
export async function pushplus(title: string, content: string, template: string = 'html'): Promise<void> {
|
||||
let token: string
|
||||
for (let user of account) {
|
||||
if (content.includes(decodeURIComponent(user.pt_pin)) && user.pushplus) {
|
||||
token = user.pushplus
|
||||
break
|
||||
}
|
||||
}
|
||||
if (!token) {
|
||||
console.log('no pushplus token')
|
||||
return
|
||||
}
|
||||
let {data}: any = await axios.post('https://www.pushplus.plus/send', {
|
||||
token: token,
|
||||
title: title,
|
||||
content: content,
|
||||
template: template
|
||||
}, {
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
})
|
||||
if (data.code === 200) {
|
||||
console.log('pushplus发送成功')
|
||||
} else {
|
||||
console.log('pushplus发送失败', JSON.stringify(data))
|
||||
}
|
||||
}
|
137
utils/shareCodesTool.ts
Normal file
137
utils/shareCodesTool.ts
Normal file
@ -0,0 +1,137 @@
|
||||
import axios from "axios";
|
||||
import USER_AGENT, {randomWord} from "../TS_USER_AGENTS";
|
||||
import {requestAlgo, geth5st} from './V3'
|
||||
|
||||
async function bean(cookie: string) {
|
||||
let {data}: any = await axios.post('https://api.m.jd.com/client.action', `functionId=plantBeanIndex&body=${decodeURIComponent(JSON.stringify({version: "9.0.0.1", "monitor_source": "plant_app_plant_index", "monitor_refer": ""}))}&appid=ld&client=apple&area=5_274_49707_49973&build=167283&clientVersion=9.1.0`, {
|
||||
headers: {
|
||||
Cookie: cookie,
|
||||
Host: "api.m.jd.com",
|
||||
"User-Agent": USER_AGENT
|
||||
}
|
||||
})
|
||||
if (data.data?.jwordShareInfo?.shareUrl)
|
||||
return data.data?.jwordShareInfo.shareUrl.split('Uuid=')![1]
|
||||
else
|
||||
return 'null'
|
||||
}
|
||||
|
||||
async function farm(cookie: string) {
|
||||
let {data}: any = await axios.post('https://api.m.jd.com/client.action?functionId=initForFarm', `body=${encodeURIComponent(JSON.stringify({"version": 4}))}&appid=wh5&clientVersion=9.1.0`, {
|
||||
headers: {
|
||||
"cookie": cookie,
|
||||
"origin": "https://home.m.jd.com",
|
||||
"referer": "https://home.m.jd.com/myJd/newhome.action",
|
||||
"User-Agent": USER_AGENT,
|
||||
"Content-Type": "application/x-www-form-urlencoded"
|
||||
}
|
||||
})
|
||||
return data.farmUserPro?.shareCode ?? 'null'
|
||||
}
|
||||
|
||||
async function health(cookie: string) {
|
||||
let {data}: any = await axios.get(`https://api.m.jd.com/client.action/client.action?functionId=jdhealth_getTaskDetail&body=${encodeURIComponent(JSON.stringify({"buildingId": "", taskId: 6, "channelId": 1}))}&client=wh5&clientVersion=1.0.0`, {
|
||||
headers: {
|
||||
"Cookie": cookie,
|
||||
"origin": "https://h5.m.jd.com",
|
||||
"referer": "https://h5.m.jd.com/",
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
"User-Agent": USER_AGENT
|
||||
}
|
||||
})
|
||||
return data.data?.result?.taskVos[0].assistTaskDetailVo.taskToken ?? 'null'
|
||||
}
|
||||
|
||||
async function pet(cookie: string) {
|
||||
let {data} = await axios.post('https://api.m.jd.com/client.action',
|
||||
`functionId=initPetTown&body=${JSON.stringify({"version": 1})}&appid=wh5&client=apple&clientVersion=10.3.6&build=167963&rfs=0000`, {
|
||||
headers: {
|
||||
'Host': 'api.m.jd.com',
|
||||
'Origin': 'https://h5.m.jd.com',
|
||||
'User-Agent': USER_AGENT,
|
||||
'Referer': 'https://h5.m.jd.com/',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Cookie': cookie
|
||||
}
|
||||
})
|
||||
return data.result?.shareCode ?? 'null'
|
||||
}
|
||||
|
||||
async function factory(cookie: string) {
|
||||
let {data}: any = await axios.post(`https://api.m.jd.com/client.action?functionId=jdfactory_getTaskDetail`,
|
||||
`functionId=jdfactory_getTaskDetail&body=${encodeURIComponent(JSON.stringify({}))}&client=wh5&clientVersion=9.1.0`, {
|
||||
headers: {
|
||||
Cookie: cookie,
|
||||
origin: "https://h5.m.jd.com",
|
||||
referer: "https://h5.m.jd.com/",
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
'User-Agent': USER_AGENT,
|
||||
}
|
||||
});
|
||||
if (data.data.bizCode === 0) {
|
||||
for (let t of data.data?.result?.taskVos) {
|
||||
if (t.taskType === 14)
|
||||
return t.assistTaskDetailVo.taskToken
|
||||
}
|
||||
}
|
||||
return 'null'
|
||||
}
|
||||
|
||||
async function sgmh(cookie: string) {
|
||||
let {data}: any = await axios.post(`https://api.m.jd.com/client.action`,
|
||||
`functionId=interact_template_getHomeData&body={"appId":"1EFRXxg","taskToken":""}&client=wh5&clientVersion=1.0.0`, {
|
||||
headers: {
|
||||
'Origin': `https://h5.m.jd.com`,
|
||||
'Cookie': cookie,
|
||||
'Accept': `application/json, text/plain, */*`,
|
||||
'Referer': `https://h5.m.jd.com/babelDiy/Zeus/2WBcKYkn8viyxv7MoKKgfzmu7Dss/index.html`,
|
||||
'Host': `api.m.jd.com`,
|
||||
}
|
||||
})
|
||||
if (data.data.bizCode === 0) {
|
||||
for (let t of data.data?.result?.taskVos) {
|
||||
if (t.taskName === '邀请好友助力')
|
||||
return t.assistTaskDetailVo.taskToken
|
||||
}
|
||||
}
|
||||
return 'null'
|
||||
}
|
||||
|
||||
async function jxfactory(cookie: string) {
|
||||
await requestAlgo('c0ff1')
|
||||
let url: string, timestamp = Date.now()
|
||||
let stk = `_time,bizCode,showAreaTaskFlag,source`, params = {showAreaTaskFlag: '1', bizCode: 'dream_factory'}
|
||||
let t: { key: string, value: string } [] = [
|
||||
{key: '_time', value: timestamp.toString()},
|
||||
{key: '_ts', value: timestamp.toString()},
|
||||
{key: 'bizCode', value: 'dream_factory'},
|
||||
{key: 'source', value: 'dreamfactory'},
|
||||
]
|
||||
url = `https://m.jingxi.com/newtasksys/newtasksys_front/GetUserTaskStatusList?source=dreamfactory&_time=${timestamp}&_ts=${timestamp}&_stk=${encodeURIComponent(stk)}&_=${timestamp + 3}&sceneval=2&g_login_type=1&callback=jsonpCBK${randomWord()}&g_ty=ls`
|
||||
|
||||
for (let [key, value] of Object.entries(params)) {
|
||||
t.push({key, value})
|
||||
url += `&${key}=${value}`
|
||||
}
|
||||
let h5st = geth5st(t, 'c0ff1')
|
||||
url += `&h5st=${encodeURIComponent(h5st)}`
|
||||
let {data}: any = await axios.get(url, {
|
||||
headers: {
|
||||
'Referer': 'https://actst.jingxi.com/pingou/dream_factory/index.html',
|
||||
'User-Agent': USER_AGENT,
|
||||
'Host': 'm.jingxi.com',
|
||||
'Cookie': cookie
|
||||
}
|
||||
})
|
||||
return JSON.parse(data.match(/try{jsonpCBK.?\((.*)/)![1]).data?.encryptPin || 'null'
|
||||
}
|
||||
|
||||
export {
|
||||
bean,
|
||||
farm,
|
||||
health,
|
||||
pet,
|
||||
factory,
|
||||
sgmh,
|
||||
jxfactory
|
||||
}
|
4
utils/sharecodes.json
Normal file
4
utils/sharecodes.json
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"cfd":["abcd", "abc123"],
|
||||
"jxfactory":["tuanid:123", "tuanid:234"]
|
||||
}
|
2078
utils/sign_graphics_validate.js
Normal file
2078
utils/sign_graphics_validate.js
Normal file
File diff suppressed because it is too large
Load Diff
497
utils/validate_single.js
Normal file
497
utils/validate_single.js
Normal file
@ -0,0 +1,497 @@
|
||||
const http = require('http');
|
||||
const stream = require('stream');
|
||||
const zlib = require('zlib');
|
||||
const vm = require('vm');
|
||||
const PNG = require('png-js');
|
||||
const UA = require('../USER_AGENTS.js').USER_AGENT;
|
||||
|
||||
|
||||
Math.avg = function average() {
|
||||
var sum = 0;
|
||||
var len = this.length;
|
||||
for (var i = 0; i < len; i++) {
|
||||
sum += this[i];
|
||||
}
|
||||
return sum / len;
|
||||
};
|
||||
|
||||
function sleep(timeout) {
|
||||
return new Promise((resolve) => setTimeout(resolve, timeout));
|
||||
}
|
||||
|
||||
class PNGDecoder extends PNG {
|
||||
constructor(args) {
|
||||
super(args);
|
||||
this.pixels = [];
|
||||
}
|
||||
|
||||
decodeToPixels() {
|
||||
return new Promise((resolve) => {
|
||||
this.decode((pixels) => {
|
||||
this.pixels = pixels;
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
getImageData(x, y, w, h) {
|
||||
const {pixels} = this;
|
||||
const len = w * h * 4;
|
||||
const startIndex = x * 4 + y * (w * 4);
|
||||
|
||||
return {data: pixels.slice(startIndex, startIndex + len)};
|
||||
}
|
||||
}
|
||||
|
||||
const PUZZLE_GAP = 8;
|
||||
const PUZZLE_PAD = 10;
|
||||
|
||||
class PuzzleRecognizer {
|
||||
constructor(bg, patch, y) {
|
||||
// console.log(bg);
|
||||
const imgBg = new PNGDecoder(Buffer.from(bg, 'base64'));
|
||||
const imgPatch = new PNGDecoder(Buffer.from(patch, 'base64'));
|
||||
|
||||
// console.log(imgBg);
|
||||
|
||||
this.bg = imgBg;
|
||||
this.patch = imgPatch;
|
||||
this.rawBg = bg;
|
||||
this.rawPatch = patch;
|
||||
this.y = y;
|
||||
this.w = imgBg.width;
|
||||
this.h = imgBg.height;
|
||||
}
|
||||
|
||||
async run() {
|
||||
await this.bg.decodeToPixels();
|
||||
await this.patch.decodeToPixels();
|
||||
|
||||
return this.recognize();
|
||||
}
|
||||
|
||||
recognize() {
|
||||
const {ctx, w: width, bg} = this;
|
||||
const {width: patchWidth, height: patchHeight} = this.patch;
|
||||
const posY = this.y + PUZZLE_PAD + ((patchHeight - PUZZLE_PAD) / 2) - (PUZZLE_GAP / 2);
|
||||
// const cData = ctx.getImageData(0, a.y + 10 + 20 - 4, 360, 8).data;
|
||||
const cData = bg.getImageData(0, posY, width, PUZZLE_GAP).data;
|
||||
const lumas = [];
|
||||
|
||||
for (let x = 0; x < width; x++) {
|
||||
var sum = 0;
|
||||
|
||||
// y xais
|
||||
for (let y = 0; y < PUZZLE_GAP; y++) {
|
||||
var idx = x * 4 + y * (width * 4);
|
||||
var r = cData[idx];
|
||||
var g = cData[idx + 1];
|
||||
var b = cData[idx + 2];
|
||||
var luma = 0.2126 * r + 0.7152 * g + 0.0722 * b;
|
||||
|
||||
sum += luma;
|
||||
}
|
||||
|
||||
lumas.push(sum / PUZZLE_GAP);
|
||||
}
|
||||
|
||||
const n = 2; // minium macroscopic image width (px)
|
||||
const margin = patchWidth - PUZZLE_PAD;
|
||||
const diff = 20; // macroscopic brightness difference
|
||||
const radius = PUZZLE_PAD;
|
||||
for (let i = 0, len = lumas.length - 2 * 4; i < len; i++) {
|
||||
const left = (lumas[i] + lumas[i + 1]) / n;
|
||||
const right = (lumas[i + 2] + lumas[i + 3]) / n;
|
||||
const mi = margin + i;
|
||||
const mLeft = (lumas[mi] + lumas[mi + 1]) / n;
|
||||
const mRigth = (lumas[mi + 2] + lumas[mi + 3]) / n;
|
||||
|
||||
if (left - right > diff && mLeft - mRigth < -diff) {
|
||||
const pieces = lumas.slice(i + 2, margin + i + 2);
|
||||
const median = pieces.sort((x1, x2) => x1 - x2)[20];
|
||||
const avg = Math.avg(pieces);
|
||||
|
||||
// noise reducation
|
||||
if (median > left || median > mRigth) return;
|
||||
if (avg > 100) return;
|
||||
// console.table({left,right,mLeft,mRigth,median});
|
||||
// ctx.fillRect(i+n-radius, 0, 1, 360);
|
||||
// console.log(i+n-radius);
|
||||
return i + n - radius;
|
||||
}
|
||||
}
|
||||
|
||||
// not found
|
||||
return -1;
|
||||
}
|
||||
|
||||
runWithCanvas() {
|
||||
const {createCanvas, Image} = require('canvas');
|
||||
const canvas = createCanvas();
|
||||
const ctx = canvas.getContext('2d');
|
||||
const imgBg = new Image();
|
||||
const imgPatch = new Image();
|
||||
const prefix = 'data:image/png;base64,';
|
||||
|
||||
imgBg.src = prefix + this.rawBg;
|
||||
imgPatch.src = prefix + this.rawPatch;
|
||||
const {naturalWidth: w, naturalHeight: h} = imgBg;
|
||||
canvas.width = w;
|
||||
canvas.height = h;
|
||||
ctx.clearRect(0, 0, w, h);
|
||||
ctx.drawImage(imgBg, 0, 0, w, h);
|
||||
|
||||
const width = w;
|
||||
const {naturalWidth, naturalHeight} = imgPatch;
|
||||
const posY = this.y + PUZZLE_PAD + ((naturalHeight - PUZZLE_PAD) / 2) - (PUZZLE_GAP / 2);
|
||||
// const cData = ctx.getImageData(0, a.y + 10 + 20 - 4, 360, 8).data;
|
||||
const cData = ctx.getImageData(0, posY, width, PUZZLE_GAP).data;
|
||||
const lumas = [];
|
||||
|
||||
for (let x = 0; x < width; x++) {
|
||||
var sum = 0;
|
||||
|
||||
// y xais
|
||||
for (let y = 0; y < PUZZLE_GAP; y++) {
|
||||
var idx = x * 4 + y * (width * 4);
|
||||
var r = cData[idx];
|
||||
var g = cData[idx + 1];
|
||||
var b = cData[idx + 2];
|
||||
var luma = 0.2126 * r + 0.7152 * g + 0.0722 * b;
|
||||
|
||||
sum += luma;
|
||||
}
|
||||
|
||||
lumas.push(sum / PUZZLE_GAP);
|
||||
}
|
||||
|
||||
const n = 2; // minium macroscopic image width (px)
|
||||
const margin = naturalWidth - PUZZLE_PAD;
|
||||
const diff = 20; // macroscopic brightness difference
|
||||
const radius = PUZZLE_PAD;
|
||||
for (let i = 0, len = lumas.length - 2 * 4; i < len; i++) {
|
||||
const left = (lumas[i] + lumas[i + 1]) / n;
|
||||
const right = (lumas[i + 2] + lumas[i + 3]) / n;
|
||||
const mi = margin + i;
|
||||
const mLeft = (lumas[mi] + lumas[mi + 1]) / n;
|
||||
const mRigth = (lumas[mi + 2] + lumas[mi + 3]) / n;
|
||||
|
||||
if (left - right > diff && mLeft - mRigth < -diff) {
|
||||
const pieces = lumas.slice(i + 2, margin + i + 2);
|
||||
const median = pieces.sort((x1, x2) => x1 - x2)[20];
|
||||
const avg = Math.avg(pieces);
|
||||
|
||||
// noise reducation
|
||||
if (median > left || median > mRigth) return;
|
||||
if (avg > 100) return;
|
||||
// console.table({left,right,mLeft,mRigth,median});
|
||||
// ctx.fillRect(i+n-radius, 0, 1, 360);
|
||||
// console.log(i+n-radius);
|
||||
return i + n - radius;
|
||||
}
|
||||
}
|
||||
|
||||
// not found
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
const DATA = {
|
||||
"appId": "17839d5db83",
|
||||
"scene": "cww",
|
||||
"product": "embed",
|
||||
"lang": "zh_CN",
|
||||
};
|
||||
const SERVER = 'iv.jd.com';
|
||||
|
||||
class JDJRValidator {
|
||||
constructor() {
|
||||
this.data = {};
|
||||
this.x = 0;
|
||||
this.t = Date.now();
|
||||
}
|
||||
|
||||
async run() {
|
||||
const tryRecognize = async () => {
|
||||
const x = await this.recognize();
|
||||
|
||||
if (x > 0) {
|
||||
return x;
|
||||
}
|
||||
// retry
|
||||
return await tryRecognize();
|
||||
};
|
||||
const puzzleX = await tryRecognize();
|
||||
console.log(puzzleX);
|
||||
const pos = new MousePosFaker(puzzleX).run();
|
||||
const d = getCoordinate(pos);
|
||||
|
||||
// console.log(pos[pos.length-1][2] -Date.now());
|
||||
// await sleep(4500);
|
||||
await sleep(pos[pos.length - 1][2] - Date.now());
|
||||
const result = await JDJRValidator.jsonp('/slide/s.html', {d, ...this.data});
|
||||
|
||||
if (result.message === 'success') {
|
||||
console.log(result);
|
||||
console.log('JDJRValidator: %fs', (Date.now() - this.t) / 1000);
|
||||
return result;
|
||||
} else {
|
||||
console.count(JSON.stringify(result));
|
||||
await sleep(300);
|
||||
return await this.run();
|
||||
}
|
||||
}
|
||||
|
||||
async recognize() {
|
||||
const data = await JDJRValidator.jsonp('/slide/g.html', {e: ''});
|
||||
const {bg, patch, y} = data;
|
||||
// const uri = 'data:image/png;base64,';
|
||||
// const re = new PuzzleRecognizer(uri+bg, uri+patch, y);
|
||||
const re = new PuzzleRecognizer(bg, patch, y);
|
||||
const puzzleX = await re.run();
|
||||
|
||||
if (puzzleX > 0) {
|
||||
this.data = {
|
||||
c: data.challenge,
|
||||
w: re.w,
|
||||
e: '',
|
||||
s: '',
|
||||
o: '',
|
||||
};
|
||||
this.x = puzzleX;
|
||||
}
|
||||
return puzzleX;
|
||||
}
|
||||
|
||||
async report(n) {
|
||||
console.time('PuzzleRecognizer');
|
||||
let count = 0;
|
||||
|
||||
for (let i = 0; i < n; i++) {
|
||||
const x = await this.recognize();
|
||||
|
||||
if (x > 0) count++;
|
||||
if (i % 50 === 0) {
|
||||
console.log('%f\%', (i / n) * 100);
|
||||
}
|
||||
}
|
||||
|
||||
console.log('successful: %f\%', (count / n) * 100);
|
||||
console.timeEnd('PuzzleRecognizer');
|
||||
}
|
||||
|
||||
static jsonp(api, data = {}) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const fnId = `jsonp_${String(Math.random()).replace('.', '')}`;
|
||||
const extraData = {callback: fnId};
|
||||
const query = new URLSearchParams({...DATA, ...extraData, ...data}).toString();
|
||||
const url = `http://${SERVER}${api}?${query}`;
|
||||
const headers = {
|
||||
'Accept': '*/*',
|
||||
'Accept-Encoding': 'gzip,deflate,br',
|
||||
'Accept-Language': 'zh-CN,en-US',
|
||||
'Connection': 'keep-alive',
|
||||
'Host': SERVER,
|
||||
'Proxy-Connection': 'keep-alive',
|
||||
'Referer': 'https://h5.m.jd.com/babelDiy/Zeus/2wuqXrZrhygTQzYA7VufBEpj4amH/index.html',
|
||||
'User-Agent': UA,
|
||||
};
|
||||
const req = http.get(url, {headers}, (response) => {
|
||||
let res = response;
|
||||
if (res.headers['content-encoding'] === 'gzip') {
|
||||
const unzipStream = new stream.PassThrough();
|
||||
stream.pipeline(
|
||||
response,
|
||||
zlib.createGunzip(),
|
||||
unzipStream,
|
||||
reject,
|
||||
);
|
||||
res = unzipStream;
|
||||
}
|
||||
res.setEncoding('utf8');
|
||||
|
||||
let rawData = '';
|
||||
|
||||
res.on('data', (chunk) => rawData += chunk);
|
||||
res.on('end', () => {
|
||||
try {
|
||||
const ctx = {
|
||||
[fnId]: (data) => ctx.data = data,
|
||||
data: {},
|
||||
};
|
||||
|
||||
vm.createContext(ctx);
|
||||
vm.runInContext(rawData, ctx);
|
||||
|
||||
// console.log(ctx.data);
|
||||
res.resume();
|
||||
resolve(ctx.data);
|
||||
} catch (e) {
|
||||
reject(e);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
req.on('error', reject);
|
||||
req.end();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function getCoordinate(c) {
|
||||
function string10to64(d) {
|
||||
var c = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-~".split("")
|
||||
, b = c.length
|
||||
, e = +d
|
||||
, a = [];
|
||||
do {
|
||||
mod = e % b;
|
||||
e = (e - mod) / b;
|
||||
a.unshift(c[mod])
|
||||
} while (e);
|
||||
return a.join("")
|
||||
}
|
||||
|
||||
function prefixInteger(a, b) {
|
||||
return (Array(b).join(0) + a).slice(-b)
|
||||
}
|
||||
|
||||
function pretreatment(d, c, b) {
|
||||
var e = string10to64(Math.abs(d));
|
||||
var a = "";
|
||||
if (!b) {
|
||||
a += (d > 0 ? "1" : "0")
|
||||
}
|
||||
a += prefixInteger(e, c);
|
||||
return a
|
||||
}
|
||||
|
||||
var b = new Array();
|
||||
for (var e = 0; e < c.length; e++) {
|
||||
if (e == 0) {
|
||||
b.push(pretreatment(c[e][0] < 262143 ? c[e][0] : 262143, 3, true));
|
||||
b.push(pretreatment(c[e][1] < 16777215 ? c[e][1] : 16777215, 4, true));
|
||||
b.push(pretreatment(c[e][2] < 4398046511103 ? c[e][2] : 4398046511103, 7, true))
|
||||
} else {
|
||||
var a = c[e][0] - c[e - 1][0];
|
||||
var f = c[e][1] - c[e - 1][1];
|
||||
var d = c[e][2] - c[e - 1][2];
|
||||
b.push(pretreatment(a < 4095 ? a : 4095, 2, false));
|
||||
b.push(pretreatment(f < 4095 ? f : 4095, 2, false));
|
||||
b.push(pretreatment(d < 16777215 ? d : 16777215, 4, true))
|
||||
}
|
||||
}
|
||||
return b.join("")
|
||||
}
|
||||
|
||||
const HZ = 20;
|
||||
|
||||
class MousePosFaker {
|
||||
constructor(puzzleX) {
|
||||
this.x = parseInt(Math.random() * 20 + 20, 10);
|
||||
this.y = parseInt(Math.random() * 80 + 80, 10);
|
||||
this.t = Date.now();
|
||||
this.pos = [[this.x, this.y, this.t]];
|
||||
this.minDuration = parseInt(1000 / HZ, 10);
|
||||
// this.puzzleX = puzzleX;
|
||||
this.puzzleX = puzzleX + parseInt(Math.random() * 2 - 1, 10);
|
||||
|
||||
this.STEP = parseInt(Math.random() * 6 + 5, 10);
|
||||
this.DURATION = parseInt(Math.random() * 7 + 14, 10) * 100;
|
||||
// [9,1600] [10,1400]
|
||||
this.STEP = 9;
|
||||
// this.DURATION = 2000;
|
||||
console.log(this.STEP, this.DURATION);
|
||||
}
|
||||
|
||||
run() {
|
||||
const perX = this.puzzleX / this.STEP;
|
||||
const perDuration = this.DURATION / this.STEP;
|
||||
const firstPos = [this.x - parseInt(Math.random() * 6, 10), this.y + parseInt(Math.random() * 11, 10), this.t];
|
||||
|
||||
this.pos.unshift(firstPos);
|
||||
this.stepPos(perX, perDuration);
|
||||
this.fixPos();
|
||||
|
||||
const reactTime = parseInt(60 + Math.random() * 100, 10);
|
||||
const lastIdx = this.pos.length - 1;
|
||||
const lastPos = [this.pos[lastIdx][0], this.pos[lastIdx][1], this.pos[lastIdx][2] + reactTime];
|
||||
|
||||
this.pos.push(lastPos);
|
||||
return this.pos;
|
||||
}
|
||||
|
||||
stepPos(x, duration) {
|
||||
let n = 0;
|
||||
const sqrt2 = Math.sqrt(2);
|
||||
for (let i = 1; i <= this.STEP; i++) {
|
||||
n += 1 / i;
|
||||
}
|
||||
for (let i = 0; i < this.STEP; i++) {
|
||||
x = this.puzzleX / (n * (i + 1));
|
||||
const currX = parseInt((Math.random() * 30 - 15) + x, 10);
|
||||
const currY = parseInt(Math.random() * 7 - 3, 10);
|
||||
const currDuration = parseInt((Math.random() * 0.4 + 0.8) * duration, 10);
|
||||
|
||||
this.moveToAndCollect({
|
||||
x: currX,
|
||||
y: currY,
|
||||
duration: currDuration,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
fixPos() {
|
||||
const actualX = this.pos[this.pos.length - 1][0] - this.pos[1][0];
|
||||
const deviation = this.puzzleX - actualX;
|
||||
|
||||
if (Math.abs(deviation) > 4) {
|
||||
this.moveToAndCollect({
|
||||
x: deviation,
|
||||
y: parseInt(Math.random() * 8 - 3, 10),
|
||||
duration: 250,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
moveToAndCollect({x, y, duration}) {
|
||||
let movedX = 0;
|
||||
let movedY = 0;
|
||||
let movedT = 0;
|
||||
const times = duration / this.minDuration;
|
||||
let perX = x / times;
|
||||
let perY = y / times;
|
||||
let padDuration = 0;
|
||||
|
||||
if (Math.abs(perX) < 1) {
|
||||
padDuration = duration / Math.abs(x) - this.minDuration;
|
||||
perX = 1;
|
||||
perY = y / Math.abs(x);
|
||||
}
|
||||
|
||||
while (Math.abs(movedX) < Math.abs(x)) {
|
||||
const rDuration = parseInt(padDuration + Math.random() * 16 - 4, 10);
|
||||
|
||||
movedX += perX + Math.random() * 2 - 1;
|
||||
movedY += perY;
|
||||
movedT += this.minDuration + rDuration;
|
||||
|
||||
const currX = parseInt(this.x + movedX, 10);
|
||||
const currY = parseInt(this.y + movedY, 10);
|
||||
const currT = this.t + movedT;
|
||||
|
||||
this.pos.push([currX, currY, currT]);
|
||||
}
|
||||
|
||||
this.x += x;
|
||||
this.y += y;
|
||||
this.t += Math.max(duration, movedT);
|
||||
}
|
||||
}
|
||||
|
||||
// new JDJRValidator().run().then(r => {
|
||||
// console.log(r.validate)
|
||||
// })
|
||||
module.exports = {
|
||||
JDJRValidator
|
||||
}
|
Loading…
Reference in New Issue
Block a user