forked from Toulu-debug/enen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jd_moneyTree.ts
207 lines (196 loc) · 6.88 KB
/
jd_moneyTree.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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
import axios from 'axios';
import USER_AGENT, {requireConfig, wait} from "./TS_USER_AGENTS";
import {read} from "fs";
let cookie: string = '', res: any = '', UserName: string, index: number;
!(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 body: any = {
"sharePin": "",
"shareType": 1,
"channelLV": "",
"source": 2,
"riskDeviceParam": {
"eid": "",
"fp": "",
"sdkToken": "",
"token": "",
"jstub": "",
"appType": "2",
}
}
body.riskDeviceParam = JSON.stringify(body.riskDeviceParam)
res = await api('login', body)
console.log(JSON.stringify(res))
let user: any = res.resultData.data
if (!user.realName) {
console.log(`${UserName}未开通游戏`)
continue
}
console.log('助力码:', user.sharePin)
// 收果子
console.log('树上果子:', user.treeInfo.fruitOnTree)
body = {
"source": 2,
"sharePin": "",
"userId": user.userInfo,
"userToken": user.userToken,
"shareType": 1,
"channel": "",
"riskDeviceParam": "{\"eid\":\"\",\"fp\":\"\",\"sdkToken\":\"\",\"token\":\"\",\"jstub\":\"\",\"appType\":2}"
}
res = await api('harvest', body)
await wait(3000)
if (res.resultData.code === '200') {
console.log('收果子成功,剩余:', res.resultData.data.treeInfo.fruit)
console.log(`距离${res.resultData.data.treeInfo.treeName}还有${res.resultData.data.treeInfo.progressLeft}`)
}
// 签到
body = {
"source": 2,
"riskDeviceParam": "{\"eid\":\"\",\"fp\":\"\",\"sdkToken\":\"\",\"token\":\"\",\"jstub\":\"\",\"appType\":4}"
}
res = await api('signIndex', body)
await wait(3000)
if (res.resultData.data?.canSign === 2) {
console.log('今日未签到')
for (let sign of res.resultData.data.result) {
if (sign.signStatus === 0) {
console.log(sign)
body = {"source": 2, "signDay": sign.signDays, "riskDeviceParam": "{\"eid\":\"\",\"fp\":\"\",\"sdkToken\":\"\",\"token\":\"\",\"jstub\":\"\",\"appType\":4}"}
res = await api('signOne', body)
console.log('签到:', res)
break
}
}
} else {
console.log('今日已签到')
}
await wait(3000)
// 获取任务
body = {
"source": 0,
"linkMissionIds": [],
"LinkMissionIdValues": [],
"riskDeviceParam": {
"eid": "",
"fp": "",
"sdkToken": "",
"token": "",
"jstub": "",
"appType": 2
}
}
for (let k = 0; k < 3; k++) {
console.log('Round:', k + 1)
body.riskDeviceParam = JSON.stringify(body.riskDeviceParam)
res = await api('dayWork', body)
// console.log('dayWork⬇️')
// console.log(JSON.stringify(res))
await wait(3000)
for (let t of res.resultData.data) {
/**
* -1 未开始
* 0 已开始
* 1 可领奖
* 2 已完成
*/
if (t.workStatus !== 2) {
if (t.workType === 1) {
// 时段签到
body = {
"source": 2,
"workType": 1,
"opType": 2,
"mid": 0,
"riskDeviceParam": "{\"eid\":\"\",\"fp\":\"\",\"sdkToken\":\"\",\"token\":\"\",\"jstub\":\"\",\"appType\":4}"
}
await api('doWork', body)
await wait(2000)
console.log('时段签到:', res)
}
/*
if (t.url?.indexOf('juid') > -1) {
console.log(t.workName)
let juid: string = t.url.split('juid=')[1];
res = await mission('getJumpInfo', `%7B%22juid%22:%22${juid}%22%7D`, t.url)
console.log(res)
await wait(3000)
break
}
*/
if (t.url?.indexOf('readTime') > -1) {
console.log(t.workName)
if (t.workStatus === -1) {
body = {"source": 2, "workType": t.workType, "opType": 4, "mid": t.mid, "riskDeviceParam": "{\"eid\":\"\",\"fp\":\"\",\"sdkToken\":\"\",\"token\":\"\",\"jstub\":\"\",\"appType\":4}"}
res = await api('doWork', body)
await wait(2000)
console.log('领取任务:', res.resultData?.data?.opMsg)
}
if (t.workStatus === 0) {
res = await mission('queryMissionReceiveAfterStatus', `%7B%22missionId%22:%22${t.mid}%22%7D`, t.url)
console.log('任务开始:', res.resultData?.msg)
let readTime: number = t.url.split('readTime=')![1]
await wait(readTime * 1000)
res = await mission('finishReadMission', `%7B%22missionId%22%3A%22${t.mid}%22%2C%22readTime%22%3A${readTime}%7D`, t.url)
console.log('任务完成:', res.resultData?.msg)
await wait(2000)
}
}
if (t.workStatus === 1) {
body = {
"source": 0,
"workType": t.workType,
"opType": 2,
"mid": t.mid,
"riskDeviceParam": "{\"eid\":\"\",\"fp\":\"\",\"sdkToken\":\"\",\"token\":\"\",\"jstub\":\"\",\"appType\":2}"
}
res = await api('doWork', body)
console.log(t.workName, res.resultData.data.opMsg, res.resultData.data.prizeAmount)
await wait(2000);
}
}
}
await wait(3000)
}
}
})()
async function api(fn: string, body: any) {
if (['doWork'].indexOf(fn) > -1) {
body = JSON.stringify(body)
} else {
body = encodeURIComponent(JSON.stringify(body))
}
let {data}: any = await axios.post(`https://ms.jr.jd.com/gw/generic/uc/h5/m/${fn}?_=${Date.now() * 1000}`,
`reqData=${body}`,
{
headers: {
'User-Agent': USER_AGENT,
'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
'Origin': 'https://uua.jr.jd.com',
'Host': 'ms.jr.jd.com',
'Referer': 'https://uua.jr.jd.com/uc-fe-wxgrowing/moneytree/index',
'Accept': 'application/json',
'Cookie': cookie
}
})
return data
}
async function mission(fn: string, reqData: string, referer: string) {
let url = 'https://ms.jr.jd.com/gw/generic/mission/h5/m/' + fn + '?reqData=' + reqData
let {data}: any = await axios.get(url, {
headers: {
'Host': 'ms.jr.jd.com',
'Origin': referer.split('.com/')[0] + '.com',
'User-Agent': 'Mozilla/5.0 (Linux; Android 10; M2004J7AC Build/QP1A.190711.020; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045710 Mobile',
'X-Requested-With': 'com.jd.jrapp',
'Referer': referer.split('.com/')[0] + '.com',
'cookie': cookie
}
})
return data
}