forked from Toulu-debug/enen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jd_IndustryLottery.ts
82 lines (74 loc) · 2.51 KB
/
jd_IndustryLottery.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
import axios from 'axios';
import {requireConfig, TotalBean, wait} from './TS_USER_AGENTS';
import * as dotenv from 'dotenv';
const notify = require('./sendNotify')
const USER_AGENT = 'jdpingou'
dotenv.config()
let cookie: string = '', res: any = '';
let UserName: string, index: number;
!(async () => {
let cookiesArr: any = await requireConfig();
for (let i = 0; i < cookiesArr.length; i++) {
cookie = cookiesArr[i];
UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1])
index = i + 1;
let {isLogin, nickName}: any = await TotalBean(cookie)
if (!isLogin) {
notify.sendNotify(__filename.split('/').pop(), `cookie已失效\n京东账号${index}:${nickName || UserName}`)
continue
}
console.log(`\n开始【京东账号${index}】${nickName || UserName}\n`);
for (let k = 0; k < 10; k++) {
res = await getTask()
for (let t of res.data.taskConfig) {
if (t.itemCount !== t.finishCount) {
let body = {
"configCode": "e1a458713a854e2abb1db2772e540532",
"taskType": t.taskType,
"itemId": t.taskItem.itemId
}
res = await api('doTask', body)
console.log(res)
await wait(2000)
res = await api("getReward", body)
console.log(res)
await wait(t.viewTime * 1000)
break
}
}
await wait(3000)
}
res = await getTask()
console.log(`有${res.data.chanceLeft}次抽奖机会`)
for (let j = 0; j < res.data.chanceLeft; j++) {
await join()
await wait(5000)
}
}
})()
async function api(fn: string, body: any) {
let {data} = await axios.post(`https://jdjoy.jd.com/module/task/draw/${fn}`, body, {
headers: {
'Host': 'jdjoy.jd.com',
'Referer': 'https://prodev.m.jd.com/mall/active/ebLz35DwiVumB6pcrGkqmnhCgmC/index.html',
'User-Agent': USER_AGENT,
'Origin': 'https://prodev.m.jd.com',
'Content-Type': 'application/json',
'Cookie': cookie
}
})
return data
}
async function getTask() {
let {data} = await axios.get("https://jdjoy.jd.com/module/task/draw/get?configCode=e1a458713a854e2abb1db2772e540532&unionCardCode=", {
headers: {'user-agent': USER_AGENT, 'cookie': cookie}
})
return data
}
async function join() {
let {data} = await axios.get("https://jdjoy.jd.com/module/task/draw/join?configCode=e1a458713a854e2abb1db2772e540532&fp=&eid=", {
headers: {'user-agent': USER_AGENT, 'cookie': cookie}
})
console.log(`抽中:${data.data.rewardName}`)
return
}