forked from Toulu-debug/enen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jd_jxmc.ts
386 lines (360 loc) · 13.3 KB
/
jd_jxmc.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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
/**
* 京喜牧场
* 买、喂、收蛋、锄草、挑逗
* new Env('京喜牧场');
* cron: 10 0,12,18 * * *
*/
import * as path from "path"
import {Md5} from "ts-md5"
import {sendNotify} from './sendNotify'
import {getCookie, getBeanShareCode, getFarmShareCode, wait, o2s, randomWord, getshareCodeHW, exceptCookie, get} from './TS_USER_AGENTS'
import {H5ST} from "./utils/h5st";
import {existsSync, readFileSync} from "fs";
import axios from "axios";
const token = require('./utils/jd_jxmc.js').token
const h5stTool: H5ST = new H5ST("00df8", "jdpingou;", "")
let cookie: string = '', res: any = '', shareCodes: string[] = [], homePageInfo: any = '', jxToken: any = '', UserName: string = '', ua: string = null, account: { pt_pin: string, remarks: string, jdpingou: string }[] = []
let shareCodesSelf: string[] = [], shareCodesHW: string[] = []
!(async () => {
let except: string[] = exceptCookie(path.basename(__filename))
if (existsSync('./utils/account.json')) {
try {
account = JSON.parse(readFileSync('./utils/account.json').toString())
} catch (e) {
console.log(e)
}
}
let cookiesArr: any = await getCookie()
for (let [index, value] of cookiesArr.entries()) {
cookie = value
UserName = decodeURIComponent(cookie.match(/pt_pin=([^;]*)/)![1])
console.log(`\n开始【京东账号${index + 1}】${UserName}\n`)
if (except.includes(encodeURIComponent(UserName))) {
console.log('已设置跳过')
continue
}
ua = null
for (let acc of account) {
if (acc?.pt_pin.includes(UserName)) {
ua = acc.jdpingou
break
}
}
await h5stTool.__genAlgo()
jxToken = await token(cookie)
homePageInfo = await api('queryservice/GetHomePageInfo', 'activeid,activekey,channel,isgift,isqueryinviteicon,isquerypicksite,jxmc_jstoken,phoneid,sceneid,timestamp', {isgift: 1, isquerypicksite: 1, isqueryinviteicon: 1})
let lastgettime: number
if (homePageInfo.data?.cow?.lastgettime) {
lastgettime = homePageInfo.data.cow.lastgettime
} else {
continue
}
let food: number = 0, petid: string = '', coins: number = 0, petNum: number = 0, petids: string[] = []
try {
food = homePageInfo.data.materialinfo[0].value
petid = homePageInfo.data.petinfo[0].petid
petids = homePageInfo.data.petinfo.map(pet => {
return pet.petid
})
console.log('当前🐔🐔:', petids)
petNum = homePageInfo.data.petinfo.length
coins = homePageInfo.data.coins
} catch (e: any) {
console.log('初始化出错,手动去app')
continue
}
console.log('助力码:', homePageInfo.data.sharekey)
shareCodesSelf.push(homePageInfo.data.sharekey)
try {
await makeShareCodes(homePageInfo.data.sharekey)
} catch (e: any) {
console.log("提交助力码出错")
}
console.log('草草🌿', food)
console.log('蛋蛋🥚', homePageInfo.data.eggcnt)
console.log('钱钱💰', coins)
console.log('鸡鸡🐔', petNum)
await wait(3000)
// 扭蛋机
res = await api('queryservice/GetCardInfo', 'activeid,activekey,channel,jxmc_jstoken,phoneid,sceneid,timestamp')
await wait(5000)
let drawTimes = res.data.times
if (typeof drawTimes === "undefined") {
await sendNotify("牧场扭蛋机错误", `账号${index + 1} ${UserName}\n手动建造扭蛋机`)
} else {
console.log('扭蛋机剩余次数:', drawTimes)
for (let j = 0; j < drawTimes; j++) {
res = await api('operservice/DrawCard', 'activeid,activekey,channel,jxmc_jstoken,phoneid,sceneid,timestamp')
if (res.ret === 0) {
if (res.data.prizetype === 3) {
console.log('抽奖成功,金币:', res.data.addcoins)
} else if (res.data.prizetype === 1) {
console.log('抽奖成功,卡片:', res.data.cardtype)
} else {
console.log('抽奖成功,其他:', res)
}
await wait(8000)
} else {
console.log('抽奖失败:', res)
break
}
}
}
res = await api('queryservice/GetCardInfo', 'activeid,activekey,channel,jxmc_jstoken,phoneid,sceneid,timestamp')
try {
for (let card of res.data.cardinfo) {
console.log(`card ${card.cardtype}`, card.currnum, '/', card.neednum)
if (card.currnum >= card.neednum && petNum < 6) {
console.log('可以兑换')
res = await api('operservice/Combine', 'activeid,activekey,cardtype,channel,jxmc_jstoken,phoneid,sceneid,timestamp', {cardtype: card.cardtype})
res.ret === 0 ? console.log('兑换成功') : ''
await wait(4000)
}
}
} catch (e) {
}
await wait(5000)
// 签到
res = await api('queryservice/GetSignInfo', 'activeid,activekey,channel,jxmc_jstoken,phoneid,sceneid,timestamp')
if (res.data.signlist) {
for (let day of res.data.signlist) {
if (day.fortoday && !day.hasdone) {
res = await api('operservice/GetSignReward', 'channel,currdate,sceneid', {currdate: res.data.currdate})
if (res.ret === 0) {
console.log('签到成功!')
} else {
console.log(res)
}
break
}
}
} else {
console.log('没有获取到签到信息!')
}
await wait(5000)
// 登录领白菜
res = await api('queryservice/GetVisitBackInfo', 'activeid,activekey,channel,jxmc_jstoken,phoneid,sceneid,timestamp')
await wait(2000)
if (res.data.iscandraw === 1) {
res = await api('operservice/GetVisitBackCabbage', 'activeid,activekey,channel,jxmc_jstoken,phoneid,sceneid,timestamp')
if (res.ret === 0) {
console.log('登录领白菜:', res.data.drawnum)
}
}
await wait(5000)
console.log('任务列表开始')
for (let j = 0; j < 30; j++) {
if (await getTask() === 0) {
break
}
await wait(4000)
}
console.log('任务列表结束')
await wait(5000)
while (coins >= 5000 && food <= 500) {
res = await api('operservice/Buy', 'activeid,activekey,channel,jxmc_jstoken,phoneid,sceneid,timestamp,type', {type: '1'})
if (res.ret === 0) {
console.log('买草成功:', res.data.newnum)
coins -= 5000
food += 100
} else {
console.log(res)
break
}
await wait(8000)
}
await wait(6000)
while (food >= 10) {
food -= 10
res = await api('operservice/Feed', 'activeid,activekey,channel,jxmc_jstoken,phoneid,sceneid,timestamp')
if (res.ret === 0) {
console.log('喂食:', res.data.newnum)
} else if (res.ret === 2020) {
console.log('收🥚')
homePageInfo = await api('queryservice/GetHomePageInfo', 'activeid,activekey,channel,isgift,isqueryinviteicon,isquerypicksite,jxmc_jstoken,phoneid,sceneid,timestamp', {
isgift: 1,
isquerypicksite: 1,
isqueryinviteicon: 1
})
for (let t of homePageInfo.data.petinfo) {
if (t.cangetborn === 1) {
petid = t.petid
break
}
}
res = await api('operservice/GetSelfResult', 'activeid,activekey,channel,itemid,jxmc_jstoken,phoneid,sceneid,timestamp,type', {itemid: petid, type: '11'})
if (res.ret === 0) {
console.log('收🥚成功:', res.data.newnum)
} else {
console.log('收🥚失败:', res)
break
}
} else if (res.ret === 2005) {
console.log('今天吃撑了')
break
} else {
console.log('Feed未知错误:', res)
break
}
await wait(10000)
}
await wait(8000)
console.log('除草...start')
for (let j = 0; j < 30; j++) {
try {
res = await api('operservice/Action', 'activeid,activekey,channel,jxmc_jstoken,phoneid,sceneid,timestamp,type', {type: '2'})
if (res.data.addcoins === 0 || JSON.stringify(res.data) === '{}') break
console.log('锄草:', res.data.addcoins)
await wait(5000)
if (res.data.surprise) {
res = await api("operservice/GetSelfResult", "activeid,activekey,channel,jxmc_jstoken,phoneid,sceneid,timestamp,type", {type: '14', itemid: 'undefined'})
console.log('锄草奖励:', res.data.prizepool)
await wait(5000)
}
} catch (e: any) {
console.log('除草 Error')
break
}
}
await wait(6000)
for (let j = 0; j < 30; j++) {
try {
res = await api('operservice/Action', 'activeid,activekey,channel,jxmc_jstoken,petid,phoneid,sceneid,timestamp,type', {type: '1', petid: petids[Math.floor((Math.random() * petids.length))]})
if (res.data.addcoins === 0 || JSON.stringify(res.data) === '{}') break
console.log('挑逗:', res.data.addcoins)
await wait(6000)
} catch (e: any) {
console.log('挑逗 Error')
break
}
}
}
/*
for (let [index, value] of cookiesArr.entries()) {
if (shareCodesHW.length === 0) {
shareCodesHW = await getshareCodeHW('jxmc')
}
// 获取随机助力码
try {
let {data}: any = await axios.get(`https://api.jdsharecode.xyz/api/jxmc/30`, {timeout: 10000})
console.log('获取到30个随机助力码:', data.data)
shareCodes = Array.from(new Set([...shareCodesSelf, ...shareCodesHW, ...data.data]))
} catch (e: any) {
console.log('获取助力池失败')
shareCodes = Array.from(new Set([...shareCodesSelf, ...shareCodesHW]))
}
cookie = value
jxToken = await token(cookie)
for (let code of shareCodes) {
console.log(`账号${index + 1} 去助力 ${code}`)
res = await api('operservice/EnrollFriend', 'activeid,activekey,channel,jxmc_jstoken,phoneid,sceneid,sharekey,timestamp', {sharekey: code})
if (res.ret === 0) {
console.log('成功,获得:', res.data.addcoins)
} else if(res.ret===1016){
console.log('火爆:', res)
break
}
} else {
console.log('失败:', res)
}
await wait(8000)
}
}
*/
})()
interface Params {
isgift?: number,
isquerypicksite?: number,
petid?: string,
itemid?: string,
type?: string,
taskId?: number
configExtra?: string,
sharekey?: string,
currdate?: string,
token?: string,
isqueryinviteicon?: number,
showAreaTaskFlag?: number,
jxpp_wxapp_type?: number,
dateType?: string,
step?: string,
cardtype?: number,
}
async function getTask() {
console.log('刷新任务列表')
res = await api('GetUserTaskStatusList', 'bizCode,dateType,jxpp_wxapp_type,showAreaTaskFlag,source', {dateType: '', showAreaTaskFlag: 0, jxpp_wxapp_type: 7})
for (let t of res.data.userTaskStatusList) {
if (t.completedTimes == t.targetTimes && t.awardStatus === 2) {
res = await api('Award', 'bizCode,source,taskId', {taskId: t.taskId})
if (res.ret === 0) {
let awardCoin = res.data.prizeInfo.match(/:(.*)}/)![1] * 1
console.log('领奖成功:', awardCoin)
await wait(4000)
return 1
} else {
console.log('领奖失败:', res)
return 0
}
}
if (t.dateType === 2 && t.completedTimes < t.targetTimes && t.awardStatus === 2 && t.taskType === 2) {
res = await api('DoTask', 'bizCode,configExtra,source,taskId', {taskId: t.taskId, configExtra: ''})
if (res.ret === 0) {
console.log('任务完成')
await wait(5000)
return 1
} else {
console.log('任务失败:', res)
return 0
}
}
}
return 0
}
async function api(fn: string, stk: string, params: Params = {}) {
let url: string, t: { [key: string]: string } = {
activeid: 'jxmc_active_0001',
activekey: 'null',
channel: '7',
jxmc_jstoken: jxToken['farm_jstoken'],
phoneid: jxToken['phoneid'],
sceneid: '1001',
timestamp: jxToken['timestamp'],
}
if (['GetUserTaskStatusList', 'DoTask', 'Award'].indexOf(fn) > -1)
url = `https://m.jingxi.com/newtasksys/newtasksys_front/${fn}?_=${Date.now()}&source=jxmc&bizCode=jxmc&_stk=${encodeURIComponent(stk)}&_ste=1&sceneval=2&g_login_type=1&callback=jsonpCBK${randomWord()}&g_ty=ls`
else
url = `https://m.jingxi.com/jxmc/${fn}?channel=7&sceneid=1001&activeid=jxmc_active_0001&activekey=null&jxmc_jstoken=${jxToken['farm_jstoken']}×tamp=${jxToken['timestamp']}&phoneid=${jxToken['phoneid']}&_stk=${encodeURIComponent(stk)}&_ste=1&_=${Date.now()}&sceneval=2&g_login_type=1&callback=jsonpCBK${randomWord()}&g_ty=ls`
for (let [key, value] of Object.entries(params)) {
t[key] = value
url += `&${key}=${value}`
}
let h5st: string = h5stTool.__genH5st(t)
url += `&h5st=${h5st}`
try {
let {data}: any = await axios.get(url, {
headers: {
'Host': 'm.jingxi.com',
'Accept': '*/*',
'User-Agent': ua ?? 'jdpingou;',
'Accept-Language': 'zh-CN,zh-Hans;q=0.9',
'Referer': 'https://st.jingxi.com/',
'Cookie': cookie
}
})
return JSON.parse(data.match(/jsonpCBK.?\((.*)/)![1])
} catch (e) {
o2s(e)
}
}
async function makeShareCodes(code: string) {
try {
let bean: string = await getBeanShareCode(cookie)
let farm: string = await getFarmShareCode(cookie)
let pin: string = Md5.hashStr(cookie.match(/pt_pin=([^;]*)/)![1])
let data = await get(`https://api.jdsharecode.xyz/api/autoInsert/jxmc?sharecode=${code}&bean=${bean}&farm=${farm}&pin=${pin}`)
console.log(data.message)
} catch (e) {
console.log('自动提交失败')
console.log(e)
}
}