forked from Toulu-debug/enen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjd_zjd_v0.2.ts
148 lines (135 loc) · 5.64 KB
/
jd_zjd_v0.2.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
/**
* v0.2
* cron: 15,30,45 0 * * *
* CK1 优先助力HW.ts
*/
import axios from "axios";
import {zjdInit, zjdH5st} from "./utils/jd_zjd_tool.js";
import {o2s, wait, requireConfig, getshareCodeHW} from "./TS_USER_AGENTS";
import {SHA256} from "crypto-js";
let cookie: string = '', res: any = '', UserName: string
let shareCodeSelf: Tuan[] = [], shareCode: Tuan[] = [], shareCodeHW: any = [], full: string[] = []
interface Tuan {
activityIdEncrypted: string, // id
assistStartRecordId: string, // assistStartRecordId
assistedPinEncrypted: string, // encPin unique
}
!(async () => {
let cookiesArr: string[] = await requireConfig()
for (let [index, value] of cookiesArr.entries()) {
try {
await zjdInit()
cookie = value
UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1])
console.log(`\n开始【京东账号${index + 1}】${UserName}\n`)
res = await api('distributeBeanActivityInfo', {"paramData": {"channel": "FISSION_BEAN"}})
// o2s(res)
await wait(1000)
if (res.data.assistStatus === 1) {
// 已开,没满
console.log('已开团,', res.data.assistedRecords.length, '/', res.data.assistNum, ',剩余', Math.round(res.data.assistValidMilliseconds / 1000 / 60), '分钟')
shareCodeSelf.push({
activityIdEncrypted: res.data.id,
assistStartRecordId: res.data.assistStartRecordId,
assistedPinEncrypted: res.data.encPin,
})
} else if (res.data.assistStatus === 2 && res.data.canStartNewAssist) {
// 没开团
res = await api('vvipclub_distributeBean_startAssist', {"activityIdEncrypted": res.data.id, "channel": "FISSION_BEAN"})
// o2s(res)
await wait(1000)
if (res.success) {
console.log(`开团成功,结束时间:${res.data.endTime}`)
res = await api('distributeBeanActivityInfo', {"paramData": {"channel": "FISSION_BEAN"}})
shareCodeSelf.push({
activityIdEncrypted: res.data.id,
assistStartRecordId: res.data.assistStartRecordId,
assistedPinEncrypted: res.data.encPin,
})
await wait(1000)
}
} else if (res.data.assistedRecords.length === res.data.assistNum) {
console.log('已成团')
if (res.data.canStartNewAssist) {
res = await api('vvipclub_distributeBean_startAssist', {"activityIdEncrypted": res.data.id, "channel": "FISSION_BEAN"})
await wait(1000)
if (res.success) {
console.log(`开团成功,结束时间:${res.data.endTime}`)
res = await api('distributeBeanActivityInfo', {"paramData": {"channel": "FISSION_BEAN"}})
shareCodeSelf.push({
activityIdEncrypted: res.data.id,
assistStartRecordId: res.data.assistStartRecordId,
assistedPinEncrypted: res.data.encPin,
})
await wait(1000)
}
}
} else if (!res.data.canStartNewAssist) {
console.log('不可开团')
}
} catch (e) {
continue
}
await wait(1000)
}
o2s(shareCodeSelf)
await wait(5000)
for (let [index, value] of cookiesArr.entries()) {
if (shareCodeHW.length === 0) {
shareCodeHW = await getshareCodeHW('zjd');
}
shareCode = index === 0
? Array.from(new Set([...shareCodeHW, ...shareCodeSelf]))
: Array.from(new Set([...shareCodeSelf, ...shareCodeHW]))
cookie = value
UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1])
await zjdInit()
for (let code of shareCode) {
if (!full.includes(code.assistedPinEncrypted)) {
try {
console.log(`账号${index + 1} ${UserName} 去助力 ${code.assistedPinEncrypted.replace('\n', '')}`)
res = await api('vvipclub_distributeBean_assist', {"activityIdEncrypted": code.activityIdEncrypted, "assistStartRecordId": code.assistStartRecordId, "assistedPinEncrypted": code.assistedPinEncrypted, "channel": "FISSION_BEAN", "launchChannel": "undefined"})
if (res.resultCode === '9200008') {
console.log('不能助力自己')
} else if (res.resultCode === '2400203') {
console.log('上限')
break
} else if (res.resultCode === '2400205') {
console.log('对方已成团')
full.push(code.assistedPinEncrypted)
} else if (res.resultCode === '9200011') {
console.log('已助力过')
} else if (res.success) {
console.log('助力成功')
} else {
console.log('error', JSON.stringify(res))
}
} catch (e) {
console.log(e)
break
}
await wait(2000)
}
}
await wait(2000)
}
})()
async function api(fn: string, body: object) {
let h5st = zjdH5st({
'fromType': 'wxapp',
'timestamp': Date.now(),
'body0': JSON.stringify(body),
'appid': 'swat_miniprogram',
'body': SHA256(JSON.stringify(body)).toString(),
'functionId': fn,
})
let {data} = await axios.post(`https://api.m.jd.com/api?functionId=${fn}&fromType=wxapp×tamp=${Date.now()}`, `functionId=distributeBeanActivityInfo&body=${encodeURIComponent(JSON.stringify(body))}&appid=swat_miniprogram&h5st=${encodeURIComponent(h5st)}`, {
headers: {
'content-type': 'application/x-www-form-urlencoded',
'user-agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E217 MicroMessenger/6.8.0(0x16080000) NetType/WIFI Language/en Branch/Br_trunk MiniProgramEnv/Mac',
'referer': 'https://servicewechat.com/wxa5bf5ee667d91626/173/page-frame.html',
'Cookie': cookie,
}
})
return data
}