forked from smlie-cyber/faker2
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjd_tiger.js
224 lines (214 loc) · 8.74 KB
/
jd_tiger.js
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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
/*
萌虎摇摇乐
https://yearfestival.jd.com
优先内部互助,剩余次数助力作者和助力池
0 0,12,18 * * * jd_tiger.js
转义自HW大佬
const $ = new Env('萌虎摇摇乐');
*/
const name = '萌虎摇摇乐'
let UA = process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)
const got = require('got')
const notify = require('./sendNotify')
const jdCookieNode = require('./jdCookie.js')
let shareCodesSelf = []
let cookiesArr = [],
cookie
Object.keys(jdCookieNode).forEach((item) => {
cookiesArr.push(jdCookieNode[item])
})
!(async () => {
if (!cookiesArr[0]) {
console.error('No CK found')
return
}
for (let i = 0; i < cookiesArr.length; i++) {
cookie = cookiesArr[i]
const userName = decodeURIComponent(cookie.match(/pt_pin=(.+?);/) && cookie.match(/pt_pin=(.+?);/)[1])
console.log(`\n开始【京东账号${i + 1}】${userName}\n`)
try {
let res = await api({ "apiMapping": "/api/task/support/getShareId" })
console.log('助力码:', res.data)
await wait(1000)
shareCodesSelf.push(res.data)
res = await api({ "apiMapping": "/api/task/support/list" })
console.log('收到助力:', res.data.supportedNum)
await wait(1000)
res = await api({ "apiMapping": "/api/task/brand/tabs" })
await wait(1000)
for (let tab of res.data) {
let taskGroupId = tab.taskGroupId
res = await api({ "taskGroupId": taskGroupId, "apiMapping": "/api/task/brand/getTaskList" })
for (let t of res.data) {
for (let i = t.finishNum; i < t.totalNum; i++) {
res = await getTaskDetail(taskGroupId)
if (res) {
console.log(taskGroupId, res.taskId, res.taskItemId, res.taskType, res.taskItemName)
let sleep = res.browseTime ? res.browseTime * 1000 : 1000
res = await api({ "taskGroupId": taskGroupId, "taskId": res.taskId, "taskItemId": res.taskItemId, "apiMapping": "/api/task/brand/doTask" })
await wait(sleep)
if (res.data.taskType === 'BROWSE_TASK') {
res = await api({ "taskGroupId": taskGroupId, "taskId": res.data.taskId, "taskItemId": res.data.taskItemId, "timestamp": res.data.timeStamp, "apiMapping": "/api/task/brand/getReward" })
console.log('任务完成,积分:', res.data.integral, ',京豆:', res.data.jbean)
await wait(1000)
} else if (res.data.taskType === 'FOLLOW_SHOP_TASK') {
// console.log('任务完成,获得:', res.data.rewardInfoVo?.integral, res.data.rewardInfoVo?.jbean)
console.log(res.data.rewardInfoVo)
}
}
}
}
}
} catch (e) {
console.log('黑号?', e)
}
}
let authorCode = []
let res = await getAuthorShareCode('https://raw.githubusercontent.com/zero205/updateTeam/main/shareCodes/tiger.json')
if (!res) {
res = await getAuthorShareCode('https://raw.fastgit.org/zero205/updateTeam/main/shareCodes/tiger.json')
}
if (res) {
authorCode = res.sort(() => 0.5 - Math.random())
const limit = 3
if (authorCode.length > limit) {
authorCode = authorCode.splice(0, limit)
}
}
for (let i = 0; i < cookiesArr.length; i++) {
cookie = cookiesArr[i]
const userName = decodeURIComponent(cookie.match(/pt_pin=(.+?);/) && cookie.match(/pt_pin=(.+?);/)[1])
const pool = await getShareCodePool('tiger', 5)
// if (shareCodesHW.length === 0) {
// shareCodesHW = await getshareCodeHW('tiger')
// }
// index === 0 ?
// shareCodes = Array.from(new Set([...shareCodesHW, ...shareCodesSelf, ...temp])) :
// shareCodes = Array.from(new Set([...shareCodesSelf, ...shareCodesHW, ...temp]))
shareCodes = Array.from(new Set([...shareCodesSelf, ...authorCode, ...pool]))
// console.log(shareCodes)
for (let code of shareCodes) {
console.log(`账号${i + 1} 去助力 ${code} ${shareCodesSelf.includes(code) ? '(内部)' : ''}`)
try {
const res = await api({ "shareId": code, "apiMapping": "/api/task/support/doSupport" })
if (res.data.status === 1) {
!res.data.supporterPrize ?
console.log('不助力自己') :
console.log('助力成功,京豆:', res.data.supporterPrize.beans, ',积分:', res.data.supporterPrize.score)
} else if (res.data.status === 7) {
console.log('上限')
break
} else if (res.data.status === 3) {
console.log('已助力过')
} else {
console.log('其他情况', res.data.status)
}
await wait(1000)
} catch (e) {
console.log('黑号?', e)
}
}
}
for (let i = 0; i < cookiesArr.length; i++) {
cookie = cookiesArr[i]
const userName = decodeURIComponent(cookie.match(/pt_pin=(.+?);/) && cookie.match(/pt_pin=(.+?);/)[1])
console.log(`\n开始【京东账号${i + 1}】${userName}\n`)
try {
let res = await api({ "apiMapping": "/api/index/indexInfo" })
let lotteryNum = res.data.lotteryNum
console.log('抽奖次数:', lotteryNum)
for (let i = 0; i < lotteryNum; i++) {
res = await api({ "apiMapping": "/api/lottery/lottery" })
console.log('抽奖', i + 1, '/', lotteryNum, res.data.prizeName)
await wait(4000)
}
} catch (e) {
console.log('黑号?', e)
}
}
})()
.catch((e) => {
console.error(`${name} error: ${e.stack}`)
})
.finally(() => {
console.log(`${name} finished}`)
})
async function getAuthorShareCode(url) {
try {
const options = {
url,
"timeout": 10000,
headers: {
"User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1 Edg/87.0.4280.88"
}
};
const { body } = await got(options)
// console.debug('getAuthorShareCode:',body)
return JSON.parse(body) || []
} catch (e) {
// console.warn('getAuthorShareCode:', e)
return false
}
}
function wait(time) {
return new Promise(resolve => {
setTimeout(() => {
resolve()
}, time)
})
}
async function api(r_body) {
const options = {
url: 'https://api.m.jd.com/api',
headers: {
'Host': 'api.m.jd.com',
'Origin': 'https://yearfestival.jd.com',
'Accept': 'application/json, text/plain, */*',
'User-Agent': UA,
'Referer': 'https://yearfestival.jd.com/',
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
'Cookie': cookie
},
form: {
appid: 'china-joy',
functionId: 'collect_bliss_cards_prod',
body: JSON.stringify(r_body),
t: Date.now(),
loginType: 2
}
// body: `appid=china-joy&functionId=collect_bliss_cards_prod&body=${JSON.stringify(r_body)}&t=${Date.now()}&loginType=2`
}
const { body } = await got.post(options)
// console.debug(options)
// console.log(body)
return JSON.parse(body)
}
async function getShareCodePool(key, num) {
let shareCode = []
for (let i = 0; i < 2; i++) {
try {
const { body } = await got(`https://api.jdsharecode.xyz/api/${key}/${num}`)
console.debug('getShareCodePool:', body)
shareCode = JSON.parse(body).data || []
console.log(`随机获取${num}个${key}成功:${JSON.stringify(shareCode)}`)
if (shareCode.length !== 0) {
break
}
} catch (e) {
// console.warn(e.stack)
console.log("getShareCodePool Error, Retry...")
await wait(2000 + Math.floor((Math.random() * 4000)))
}
}
return shareCode
}
async function getTaskDetail(taskGroupId) {
let res = await api({ "taskGroupId": taskGroupId, "apiMapping": "/api/task/brand/getTaskList" })
await wait(1000)
for (let t of res.data) {
if (t.finishNum !== t.totalNum) {
return t
}
}
return ''
}