-
Notifications
You must be signed in to change notification settings - Fork 13
/
jd_sgmh.ts
128 lines (118 loc) · 4.34 KB
/
jd_sgmh.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/**
* 闪购盲盒
* cron: 20 8 * * *
*/
import {getCookie, getShareCodePool, wait} from "./TS_USER_AGENTS"
import axios from "axios";
let cookie: string = '', UserName: string, res: any
let shareCodeSelf: string[] = [], shareCode: string[] = [], shareCodePool: string[] = []
!(async () => {
let cookiesArr: string[] = await getCookie()
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('healthyDay_getHomeData', {"appId": "1ElZXwKuP", "taskToken": "", "channelId": 1})
for (let t of res.data.result.taskVos) {
if (t.taskType === 14) {
console.log('助力码', t.assistTaskDetailVo?.taskToken)
shareCodeSelf.push(t.assistTaskDetailVo?.taskToken)
}
if ((t.browseShopVo || t.productInfoVos || t.shoppingActivityVos) && t.times < t.maxTimes) {
for (let i = 0; i < t.maxTimes - t.times; i++) {
let tp: any[] = []
if (t.productInfoVos)
tp = t.productInfoVos
else if (t.browseShopVo)
tp = t.browseShopVo
else if (t.shoppingActivityVos)
tp = t.shoppingActivityVos
console.log(tp[i]?.shopName || tp[i]?.skuName || tp[i]?.title)
if (!t.shoppingActivityVos) {
res = await api('harmony_collectScore', {
"appId": "1ElZXwKuP",
"taskToken": tp[i].taskToken,
"taskId": t.taskId,
"actionType": 1
})
console.log(res.data.bizMsg)
await wait(t.waitDuration * 1000 || 2000)
}
res = await api('harmony_collectScore', {
"appId": "1ElZXwKuP",
"taskToken": tp[i].taskToken,
"taskId": t.taskId,
"actionType": 0
})
await wait(1000)
if (res.data.bizMsg === 'success') {
console.log('任务完成')
} else {
break
}
}
}
}
}
// 助力
let full: string[] = []
for (let [index, value] of cookiesArr.entries()) {
cookie = value
UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1])
console.log(`\n开始【京东账号${index + 1}】${UserName}\n`)
shareCodePool = await getShareCodePool('sgmh', 30)
shareCode = Array.from(new Set([...shareCodeSelf, ...shareCodePool]))
for (let code of shareCode) {
if (full.includes(code)) {
console.log('full contains')
continue
}
console.log('去助力', code)
res = await api('harmony_collectScore', {"appId": "1ElZXwKuP", "taskToken": code, "taskId": 3})
if (res.data.bizCode === 0) {
console.log('助力成功')
} else if (res.data.bizCode === 108) {
console.log('上限')
break
} else if (res.data.bizMsg === '助力已满员!谢谢你哦~') {
full.push(code)
console.log('已满')
} else {
console.log('助力失败', res.data.bizMsg)
}
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`)
res = await api('healthyDay_getHomeData', {"appId": "1ElZXwKuP", "taskToken": "", "channelId": 1})
await wait(1000)
let lotteryNum: number = parseInt(res.data.result.userInfo.lotteryNum)
console.log('可以抽奖', lotteryNum, '次')
for (let i = 0; i < lotteryNum; i++) {
res = await api('interact_template_getLotteryResult', {"appId": "1ElZXwKuP"})
if (res.data.result.userAwardsCacheDto.type === 0) {
console.log('抽奖成功 空气')
} else {
console.log('抽奖成功', res.data.result.userAwardsCacheDto.jBeanAwardVo?.prizeName)
}
await wait(1000)
}
}
})()
async function api(fn: string, body: object) {
let {data} = await axios.post('https://api.m.jd.com/client.action',
`functionId=${fn}&body=${JSON.stringify(body)}&client=wh5&clientVersion=1.0.0`, {
headers: {
'Host': 'api.m.jd.com',
'Origin': 'https://h5.m.jd.com',
'User-Agent': 'jdapp;iPhone;10.4.3;',
'Referer': 'https://h5.m.jd.com/',
'Cookie': cookie
}
})
return data
}