forked from Toulu-debug/enen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjd_618_hongbao_award.ts
51 lines (46 loc) · 1.64 KB
/
jd_618_hongbao_award.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
/**
* 运行即领取膨胀红包
* cron: 5 21 * * *
*/
import axios from 'axios'
import USER_AGENT, {getCookie, wait} from './TS_USER_AGENTS'
import {sendNotify} from './sendNotify'
let cookie: string = '', res: any = '', UserName: string, index: number, message: string = ''
!(async () => {
let cookiesArr: string[] = await getCookie()
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_pk_receiveAward', {})
if (res.data.success) {
console.log('领取膨胀红包', parseFloat(res.data.result.value))
message += `账号${index + 1} ${UserName}\n领取膨胀红包 ${res.data.result.value}\n\n`
} else {
console.log(res.data.bizMsg)
}
await wait(2000)
} catch (e) {
}
await wait(2000)
}
if (message)
await sendNotify("领取膨胀红包", message)
})()
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
}