-
Notifications
You must be signed in to change notification settings - Fork 1k
/
jd_fruit_help.ts
107 lines (98 loc) · 3.87 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/**
* 种树助力
* cron: 35 0,6,12,18,23 * * *
*/
import {User, JDHelloWorld} from "./TS_JDHelloWorld"
import {JSDOM, ResourceLoader, VirtualConsole} from "jsdom";
import {readFileSync} from "fs";
import CryptoJS from "crypto-js";
class Jd_fruit_help extends JDHelloWorld {
user: User
shareCodeSelf: string[] = []
appId: string
htstTool: any
constructor() {
super();
}
async init() {
await this.run(this)
}
async h5stToolInit() {
let dom = new JSDOM(`<body><script>${readFileSync('utils/h5st_42.js').toString()}</script></body>`, {
url: "http://localhost",
userAgent: this.user.UserAgent,
runScripts: "dangerously",
resources: new ResourceLoader({
userAgent: this.user.UserAgent
}),
includeNodeLocations: true,
storageQuota: 1000000000,
pretendToBeVisual: true,
virtualConsole: new VirtualConsole()
})
this.htstTool = new dom.window.ParamsSign({appId: this.appId})
}
async api(fn: string, body: object) {
let t = Date.now(), h5st: string = (await this.htstTool.sign({
appid: 'signed_wh5',
body: CryptoJS.SHA256(JSON.stringify(body)).toString(CryptoJS.enc.Hex),
client: 'iOS',
clientVersion: '13.0.2',
functionId: fn,
timestamp: t.toString()
})).h5st
return await this.get(`https://api.m.jd.com/client.action?functionId=${fn}&body=${encodeURIComponent(JSON.stringify(body))}&appid=signed_wh5&area=0_0_0_0×tamp=${t}&client=iOS&clientVersion=13.0.2&h5st=${h5st}`, {
'Host': 'api.m.jd.com',
'Origin': 'https://carry.m.jd.com',
'User-Agent': this.user.UserAgent,
'Cookie': this.user.cookie,
'Referer': 'https://carry.m.jd.com/',
'x-referer-page': 'https://carry.m.jd.com/babelDiy/Zeus/3KSjXqQabiTuD1cJ28QskrpWoBKT/index.html',
})
}
async main(user: User) {
try {
this.user = user
this.user.UserAgent = `jdapp;iPhone;13.0.2;;;M/5.0;appBuild/169363;jdSupportDarkMode/0;ef/1;Mozilla/5.0 (iPhone; CPU iPhone OS ${this.getIosVer()} like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1;`
this.appId = '8a2af'
await this.h5stToolInit()
let res: any = await this.api('initForFarm', {"babelChannel": "522", "shareCode": "", "mpin": "", "from": "", "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.user.UserAgent = `jdapp;iPhone;13.0.2;;;M/5.0;appBuild/169363;jdSupportDarkMode/0;ef/1;Mozilla/5.0 (iPhone; CPU iPhone OS ${this.getIosVer()} like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1;`
this.appId = '8a2af'
await this.h5stToolInit()
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()