-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
jd_fruit_help.ts
86 lines (78 loc) · 2.79 KB
/
jd_fruit_help.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
/**
* 种树助力
* cron: 35 0,6,12,18,23 * * *
*/
import {User, JDHelloWorld} from "./TS_JDHelloWorld"
import CryptoJS from "crypto-js"
class Jd_fruit_help extends JDHelloWorld {
user: User
shareCodeSelf: string[] = []
h5stTool: { sign: Function }
constructor() {
super();
}
async init() {
await this.run(this)
}
async api(fn: string, body: object) {
let timestamp: number = Date.now()
let h5st: string = (await this.h5stTool.sign({
appid: 'signed_wh5',
body: CryptoJS.SHA256(JSON.stringify(body)).toString(CryptoJS.enc.Hex),
client: 'iOS',
clientVersion: '12.3.2',
functionId: fn,
t: timestamp
})).h5st
return await this.get(`https://api.m.jd.com/client.action?functionId=${fn}&body=${encodeURIComponent(JSON.stringify(body))}&appid=signed_wh5×tamp=${timestamp}&client=iOS&clientVersion=12.3.2&h5st=${h5st}`, {
'authority': 'api.m.jd.com',
'cookie': this.user.cookie,
'origin': 'https://carry.m.jd.com',
'referer': 'https://carry.m.jd.com/',
'user-agent': this.user.UserAgent,
'x-referer-page': 'https://carry.m.jd.com/babelDiy/Zeus/3KSjXqQabiTuD1cJ28QskrpWoBKT/index.html',
'x-rp-client': 'h5_1.0.0'
})
}
async main(user: User) {
try {
this.user = user
this.h5stTool = this.h5st('42', '8a2af', this.user.UserAgent)
let res: any = await this.api('initForFarm', {"babelChannel": "522", "version": 26, "channel": 1, "lat": "0", "lng": "0"})
console.log('助力码', res['farmUserPro'].shareCode)
this.shareCodeSelf.push(res['farmUserPro'].shareCode)
} catch (e) {
console.log('获取失败', e)
}
await this.wait(5000)
}
async help(users: User[]) {
let res: any
for (let user of users) {
try {
this.user = user
this.h5stTool = this.h5st('42', '8a2af', this.user.UserAgent)
let shareCodePool: string[] = await this.getShareCodePool('farm', 50)
let shareCode: string[] = Array.from(new Set([...this.shareCodeSelf, ...shareCodePool]))
for (let code of shareCode) {
try {
console.log(`账号${user.index + 1} ${user.UserName} 去助力 ${code}`)
res = await this.api('initForFarm', {"babelChannel": "522", "shareCode": code, "mpin": "", "from": "kouling", "version": 26, "channel": 1, "lat": "0", "lng": "0"})
console.log('剩余助力', res.helpResult.remainTimes, '助力结果', res.helpResult.code)
if (res.helpResult.remainTimes === 0) {
console.log('上限')
break
}
} catch (e) {
console.log(e.message)
}
await this.wait(5000)
}
} catch (e) {
console.log(e)
}
await this.wait(15000)
}
}
}
new Jd_fruit_help().init().then()