forked from Toulu-debug/enen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjd_618_hongbao_1.ts
99 lines (86 loc) · 3.35 KB
/
jd_618_hongbao_1.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
/**
* 20点开奖的🧧
* cron: 10 20,21,22 * * *
*/
import axios from 'axios'
import USER_AGENT, {getCookie, getshareCodeHW, o2s, wait} from './TS_USER_AGENTS'
import {Log_618} from "./utils/log_618"
let cookie: string = '', res: any = '', UserName: string, index: number, log: { log: string, random: string }, secretp: string = ''
let shareCodeHW: string[] = [], shareCodeSelf: string [] = [], shareCode: string[] = []
!(async () => {
if (new Date().getHours() < 20) {
console.log('20点开始')
process.exit(0)
}
let cookiesArr: string[] = await getCookie()
let tool: Log_618 = new Log_618()
for (let i = 0; i < cookiesArr.length; i++) {
try {
cookie = cookiesArr[i]
UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1])
index = i + 1
console.log(`\n开始【京东账号${index}】${UserName}\n`)
res = await api('promote_getHomeData', {})
secretp = res.data.result.homeMainInfo.secretp
if (!res.data.result?.userAward) {
console.log('组队失败')
continue
}
res = await api('promote_pk_getAmountForecast', {})
console.log('🧧', parseFloat(res.data.result.userAward))
log = await tool.main()
await wait(4000)
res = await api('promote_pk_getExpandDetail', {"ss": JSON.stringify({extraData: {log: encodeURIComponent(log.log), sceneid: 'RAhomePageh5'}, secretp: secretp, random: log.random})})
console.log('助力码', res.data.result.inviteId)
shareCodeSelf.push(res.data.result.inviteId)
} catch (e) {
}
await wait(2000)
}
console.log('内部互助')
o2s(shareCodeSelf)
for (let i = 0; i < cookiesArr.length; i++) {
try {
cookie = cookiesArr[i]
UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1])
index = i + 1
console.log(`\n开始【京东账号${index}】${UserName}\n`)
res = await api('promote_getHomeData', {})
secretp = res.data.result.homeMainInfo.secretp
if (shareCodeHW.length === 0) {
shareCodeHW = await getshareCodeHW('lyb_pz')
}
if (i === 0) {
shareCode = Array.from(new Set([...shareCodeHW, ...shareCodeSelf]))
} else {
shareCode = Array.from(new Set([...shareCodeSelf, ...shareCodeHW]))
}
for (let code of shareCode) {
console.log('去助力', code)
log = await tool.main()
res = await api('promote_pk_collectPkExpandScore', {"ss": JSON.stringify({extraData: {log: encodeURIComponent(log.log), sceneid: 'RAhomePageh5'}, secretp: secretp, random: log.random}), "actionType": "0", "inviteId": code})
console.log(res.data.bizMsg)
await wait(4000)
}
} catch (e) {
console.log('error', e)
} finally {
await wait(1000)
}
}
})()
async function api(fn: string, body: object) {
let appid: string = fn.includes('promote_') ? 'signed_wh5' : 'wh5'
let {data} = await axios.post(`https://api.m.jd.com/client.action?functionId=${fn}`, `functionId=${fn}&client=m&clientVersion=1.0.0&appid=${appid}&body=${JSON.stringify(body)}`, {
headers: {
'Host': 'api.m.jd.com',
'Origin': 'https://wbbny.m.jd.com',
'Accept': 'application/json, text/plain, */*',
'User-Agent': USER_AGENT,
'Referer': 'https://wbbny.m.jd.com/',
'Content-Type': 'application/x-www-form-urlencoded',
'Cookie': cookie
}
})
return data
}