forked from angreman/WALL.E
-
Notifications
You must be signed in to change notification settings - Fork 0
/
m_jx_factory_automation.js
323 lines (310 loc) · 16.1 KB
/
m_jx_factory_automation.js
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
//20 * * * * m_jx_factory_automation.js
//问题反馈:https://t.me/Wall_E_Channel
const {Env} = require('./magic');
const $ = new Env('M京喜工厂自动化');
let commodityName = process.env.M_JX_FACTORY_COMMODITY
? process.env.M_JX_FACTORY_COMMODITY
: '你还没设置要生产的变量M_JX_FACTORY_COMMODITY'
let stop = false;
$.logic = async function () {
if (stop) {
return;
}
let info = await GetUserInfo();
$.log(JSON.stringify(info));
if (!info) {
$.putMsg('没有找到工厂信息');
return;
}
await GetUserComponent(info.user.encryptPin);
$.log(info.factoryList[0].name, '等级', info.user.currentLevel);
if (info?.productionList) {
let product = info?.productionList[0];
if (product.investedElectric !== product.needElectric) {
$.log('还没有生产完成');
return
}
let productionId = product.productionId;
await $.wait(300, 500)
let {active} = await ExchangeCommodity(productionId);
await $.wait(300, 500)
await QueryHireReward();
await $.wait(300, 500)
await queryprizedetails(active)
await $.wait(300, 500)
}
let factoryId = info?.deviceList[0].factoryId;
$.log('获取工厂id', factoryId);
let deviceId = info?.deviceList[0].deviceId;
$.log('获取设备id', deviceId);
let {commodityList} = await GetCommodityList();
let filter = commodityList.filter(o => o.name.includes(commodityName));
if (filter.length === 1) {
let commodity = filter[0];
if (commodity?.flashStartTime && commodity?.flashStartTime
> $.timestamp()) {
$.log(`还没到时间`)
return;
}
let data = await GetCommodityDetails(commodity.commodityId);
await $.wait(300, 500)
let newVar = await AddProduction(factoryId, deviceId, data.commodityId);
if (newVar?.productionId) {
$.putMsg(`${data.name}已经开始生产`)
info = await GetUserInfo();
let product = info?.productionList[0];
let productionId = product.productionId;
await InvestElectric(productionId);//添加电力
await InvestElectric(productionId);
}
} else {
$.putMsg(`没找到你要生产的 ${commodityName}`)
stop = true;
}
};
$.run({wait: [2000, 3000]}).catch(reason => $.log(reason));
async function InvestElectric(productionId) {
let url = `https://m.jingxi.com/dreamfactory/userinfo/InvestElectric?zone=dream_factory&productionId=${productionId}&_time=1637743936757&_ts=1637743936757&_=1637743936758&sceneval=2&g_login_type=1&callback=jsonpCBKR&g_ty=ls`;
// noinspection DuplicatedCode
let headers = {
'Accept': '*/*',
'Connection': 'keep-alive',
'Referer': 'https://st.jingxi.com/pingou/dream_factory/index.html',
'Accept-Encoding': 'gzip, deflate, br',
'Host': 'm.jingxi.com',
'Accept-Language': 'zh-cn'
}
// noinspection DuplicatedCode
headers['Cookie'] = $.cookie
headers['User-Agent'] = `jdpingou;iPhone;5.2.2;14.3;${$.randomString(
40)};network/wifi;model/iPhone12,1;appBuild/100630;ADID/00000000-0000-0000-0000-000000000000;supportApplePay/1;hasUPPay/0;pushNoticeIsOpen/0;hasOCPay/0;supportBestPay/0;session/1;pap/JA2019_3111789;brand/apple;supportJDSHWK/1;Mozilla/5.0 (iPhone; CPU iPhone OS 14_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148`
let data = await $.get(url, headers)
// noinspection DuplicatedCode
if (data?.ret === 0) {
return data?.data
}
return false;
}
async function AddProduction(factoryId, deviceId, commodityDimId) {
let url = `https://m.jingxi.com/dreamfactory/userinfo/AddProduction?zone=dream_factory&factoryId=${factoryId}&deviceId=${deviceId}&commodityDimId=${commodityDimId}&replaceProductionId=&_time=1637282973549&_ts=1637282973549&_=1637282973550&sceneval=2&g_login_type=1&callback=jsonpCBKGGG&g_ty=ls`;
// noinspection DuplicatedCode
let headers = {
'Accept': '*/*',
'Connection': 'keep-alive',
'Referer': 'https://st.jingxi.com/pingou/dream_factory/index.html',
'Accept-Encoding': 'gzip, deflate, br',
'Host': 'm.jingxi.com',
'Accept-Language': 'zh-cn',
'Cookie': $.cookie
}
// noinspection DuplicatedCode
headers['User-Agent'] = `jdpingou;iPhone;5.2.2;14.3;${$.randomString(
40)};network/wifi;model/iPhone12,1;appBuild/100630;ADID/00000000-0000-0000-0000-000000000000;supportApplePay/1;hasUPPay/0;pushNoticeIsOpen/0;hasOCPay/0;supportBestPay/0;session/1;pap/JA2019_3111789;brand/apple;supportJDSHWK/1;Mozilla/5.0 (iPhone; CPU iPhone OS 14_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148`
let data = await $.get(url, headers)
// noinspection DuplicatedCode
if (data?.ret === 0) {
return data?.data
} else {
$.putMsg(data?.msg)
}
return false;
}
async function GetDeviceDetails() {
let url = `https://m.jingxi.com/dreamfactory/diminfo/GetDeviceDetails?zone=dream_factory&deviceId=1&_time=1637282971386&_ts=1637282971386&_=1637282971386&sceneval=2&g_login_type=1&callback=jsonpCBKFFF&g_ty=ls`;
// noinspection DuplicatedCode
let headers = {
'Accept': '*/*',
'Connection': 'keep-alive',
'Referer': 'https://st.jingxi.com/pingou/dream_factory/index.html',
'Accept-Encoding': 'gzip, deflate, br',
'Host': 'm.jingxi.com',
'Accept-Language': 'zh-cn',
'Cookie': $.cookie
}
// noinspection DuplicatedCode
headers['User-Agent'] = `jdpingou;iPhone;5.2.2;14.3;${$.randomString(
40)};network/wifi;model/iPhone12,1;appBuild/100630;ADID/00000000-0000-0000-0000-000000000000;supportApplePay/1;hasUPPay/0;pushNoticeIsOpen/0;hasOCPay/0;supportBestPay/0;session/1;pap/JA2019_3111789;brand/apple;supportJDSHWK/1;Mozilla/5.0 (iPhone; CPU iPhone OS 14_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148`
let data = await $.get(url, headers)
// noinspection DuplicatedCode
if (data?.ret === 0) {
return data?.data
}
return false;
}
async function GetUserComponent(pin) {
let url = `https://m.jingxi.com/dreamfactory/usermaterial/GetUserComponent?zone=dream_factory&pin=${pin}&_time=1637282950558&_ts=1637282950559&sceneval=2&g_login_type=1&_=1637282951435&sceneval=2&g_login_type=1&callback=jsonpCBKSS&g_ty=ls`;
// noinspection DuplicatedCode
let headers = {
'Accept': '*/*',
'Connection': 'keep-alive',
'Referer': 'https://st.jingxi.com/pingou/dream_factory/index.html',
'Accept-Encoding': 'gzip, deflate, br',
'Host': 'm.jingxi.com',
'Accept-Language': 'zh-cn',
'Cookie': $.cookie
}
// noinspection DuplicatedCode
headers['User-Agent'] = `jdpingou;iPhone;5.2.2;14.3;${$.randomString(
40)};network/wifi;model/iPhone12,1;appBuild/100630;ADID/00000000-0000-0000-0000-000000000000;supportApplePay/1;hasUPPay/0;pushNoticeIsOpen/0;hasOCPay/0;supportBestPay/0;session/1;pap/JA2019_3111789;brand/apple;supportJDSHWK/1;Mozilla/5.0 (iPhone; CPU iPhone OS 14_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148`
let data = await $.get(url, headers)
// noinspection DuplicatedCode
if (data?.ret === 0) {
return data?.data
}
return false;
}
// noinspection DuplicatedCode
async function GetUserInfo() {
let url = `https://m.jingxi.com/dreamfactory/userinfo/GetUserInfo?zone=dream_factory&pin=&sharePin=&shareType=&materialTuanPin=&materialTuanId=&needPickSiteInfo=1&source=&_time=1637282934811&_ts=1637282934811&timeStamp=&h5st=20211119084854812%3B5505286748222516%3Bc0ff1%3Btk02w96e01bc918n2aG34crijQCFgW%2BYZgoTBRpLWz6TM%2FWXRBmShiIQLtGvxCMJkN0g1uyofC04iuOhphAyAm66c3U5%3B2b53e58445b6ec6a5487e95f6aeae526c6c93b4724a0e54e03f3a8105f1caea6%3B3.0%3B1637282934812&_stk=_time%2C_ts%2CmaterialTuanId%2CmaterialTuanPin%2CneedPickSiteInfo%2Cpin%2CsharePin%2CshareType%2Csource%2CtimeStamp%2Czone&_ste=1&_=1637282934818&sceneval=2&g_login_type=1&callback=jsonpCBKY&g_ty=ls`;
// noinspection DuplicatedCode
let headers = {
'Accept': '*/*',
'Connection': 'keep-alive',
'Referer': 'https://st.jingxi.com/pingou/dream_factory/index.html',
'Accept-Encoding': 'gzip, deflate, br',
'Host': 'm.jingxi.com',
'Accept-Language': 'zh-cn',
'Cookie': $.cookie
}
// noinspection DuplicatedCode
headers['User-Agent'] = `jdpingou;iPhone;5.2.2;14.3;${$.randomString(
40)};network/wifi;model/iPhone12,1;appBuild/100630;ADID/00000000-0000-0000-0000-000000000000;supportApplePay/1;hasUPPay/0;pushNoticeIsOpen/0;hasOCPay/0;supportBestPay/0;session/1;pap/JA2019_3111789;brand/apple;supportJDSHWK/1;Mozilla/5.0 (iPhone; CPU iPhone OS 14_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148`
let data = await $.get(url, headers)
// noinspection DuplicatedCode
if (data?.ret === 0) {
return data?.data
}
return false;
}
// noinspection DuplicatedCode
async function ExchangeCommodity(productionId) {
let url = `https://m.jingxi.com/dreamfactory/userinfo/ExchangeCommodity?zone=dream_factory&productionId=${productionId}&exchangeType=1&_time=1637282949946&_ts=1637282949946&_=1637282949947&sceneval=2&g_login_type=1&callback=jsonpCBKJJ&g_ty=ls`;
// noinspection DuplicatedCode
let headers = {
'Accept': '*/*',
'Connection': 'keep-alive',
'Referer': 'https://st.jingxi.com/pingou/dream_factory/index.html',
'Accept-Encoding': 'gzip, deflate, br',
'Host': 'm.jingxi.com',
'Accept-Language': 'zh-cn',
'Cookie': $.cookie
}
// noinspection DuplicatedCode
headers['User-Agent'] = `jdpingou;iPhone;5.2.2;14.3;${$.randomString(
40)};network/wifi;model/iPhone12,1;appBuild/100630;ADID/00000000-0000-0000-0000-000000000000;supportApplePay/1;hasUPPay/0;pushNoticeIsOpen/0;hasOCPay/0;supportBestPay/0;session/1;pap/JA2019_3111789;brand/apple;supportJDSHWK/1;Mozilla/5.0 (iPhone; CPU iPhone OS 14_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148`
let data = await $.get(url, headers)
// noinspection DuplicatedCode
if (data?.ret === 0) {
return data?.data
}
return false;
}
// noinspection DuplicatedCode
async function GetCommodityList() {
let url = `https://m.jingxi.com/dreamfactory/diminfo/GetCommodityList?zone=dream_factory&flag=2&pageNo=1&pageSize=12&_time=1636619666773&_ts=1636619666773&_=1636619666773&sceneval=2&g_login_type=1&callback=jsonpCBKKK&g_ty=ls`;
// noinspection DuplicatedCode
let headers = {
'Accept': '*/*',
'Connection': 'keep-alive',
'Referer': 'https://st.jingxi.com/pingou/dream_factory/index.html',
'Accept-Encoding': 'gzip, deflate, br',
'Host': 'm.jingxi.com',
'Accept-Language': 'zh-cn',
'Cookie': $.cookie
}
// noinspection DuplicatedCode
headers['User-Agent'] = `jdpingou;iPhone;5.2.2;14.3;${$.randomString(
40)};network/wifi;model/iPhone12,1;appBuild/100630;ADID/00000000-0000-0000-0000-000000000000;supportApplePay/1;hasUPPay/0;pushNoticeIsOpen/0;hasOCPay/0;supportBestPay/0;session/1;pap/JA2019_3111789;brand/apple;supportJDSHWK/1;Mozilla/5.0 (iPhone; CPU iPhone OS 14_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148`
let data = await $.get(url, headers)
// noinspection DuplicatedCode
if (data?.ret === 0) {
return data?.data
}
return false;
}
// noinspection DuplicatedCode
async function GetCommodityDetails(commodityId) {
let url = `https://m.jingxi.com/dreamfactory/diminfo/GetCommodityDetails?zone=dream_factory&commodityId=${commodityId}&_time=1636437544857&_ts=1636437544857&_=1636437544857&sceneval=2&g_login_type=1&callback=jsonpCBKWWW&g_ty=ls`;
// noinspection DuplicatedCode
let headers = {
'Accept': '*/*',
'Connection': 'keep-alive',
'Referer': 'https://st.jingxi.com/pingou/dream_factory/index.html',
'Accept-Encoding': 'gzip, deflate, br',
'Host': 'm.jingxi.com',
'Accept-Language': 'zh-cn',
'Cookie': $.cookie
}
// noinspection DuplicatedCode
headers['User-Agent'] = `jdpingou;iPhone;5.2.2;14.3;${$.randomString(
40)};network/wifi;model/iPhone12,1;appBuild/100630;ADID/00000000-0000-0000-0000-000000000000;supportApplePay/1;hasUPPay/0;pushNoticeIsOpen/0;hasOCPay/0;supportBestPay/0;session/1;pap/JA2019_3111789;brand/apple;supportJDSHWK/1;Mozilla/5.0 (iPhone; CPU iPhone OS 14_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148`
let data = await $.get(url, headers)
// noinspection DuplicatedCode
return data?.data?.commodityList?.[0]
}
async function queryprizedetails(actives) {
let url = `https://m.jingxi.com/active/queryprizedetails?actives=${actives}&_time=1637282950925&_ts=1637282950925&_=1637282950925&sceneval=2&g_login_type=1&callback=jsonpCBKQQ&g_ty=ls`;
// noinspection DuplicatedCode
let headers = {
'Accept': '*/*',
'Connection': 'keep-alive',
'Referer': 'https://st.jingxi.com/pingou/dream_factory/index.html',
'Accept-Encoding': 'gzip, deflate, br',
'Host': 'm.jingxi.com',
'Accept-Language': 'zh-cn',
'Cookie': $.cookie
}
// noinspection DuplicatedCode
headers['User-Agent'] = `jdpingou;iPhone;5.2.2;14.3;${$.randomString(
40)};network/wifi;model/iPhone12,1;appBuild/100630;ADID/00000000-0000-0000-0000-000000000000;supportApplePay/1;hasUPPay/0;pushNoticeIsOpen/0;hasOCPay/0;supportBestPay/0;session/1;pap/JA2019_3111789;brand/apple;supportJDSHWK/1;Mozilla/5.0 (iPhone; CPU iPhone OS 14_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148`
let data = await $.get(url, headers)
// noinspection DuplicatedCode
if (data?.ret === 0) {
return data?.data
}
return false;
}
async function QueryHireReward() {
let url = `https://m.jingxi.com/dreamfactory/friend/QueryHireReward?zone=dream_factory&_time=1637282950550&_ts=1637282950550&_=1637282950550&sceneval=2&g_login_type=1&callback=jsonpCBKLL&g_ty=ls`;
// noinspection DuplicatedCode
let headers = {
'Accept': '*/*',
'Connection': 'keep-alive',
'Referer': 'https://st.jingxi.com/pingou/dream_factory/index.html',
'Accept-Encoding': 'gzip, deflate, br',
'Host': 'm.jingxi.com',
'Accept-Language': 'zh-cn',
'Cookie': $.cookie
}
// noinspection DuplicatedCode
headers['User-Agent'] = `jdpingou;iPhone;5.2.2;14.3;${$.randomString(
40)};network/wifi;model/iPhone12,1;appBuild/100630;ADID/00000000-0000-0000-0000-000000000000;supportApplePay/1;hasUPPay/0;pushNoticeIsOpen/0;hasOCPay/0;supportBestPay/0;session/1;pap/JA2019_3111789;brand/apple;supportJDSHWK/1;Mozilla/5.0 (iPhone; CPU iPhone OS 14_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148`
let data = await $.get(url, headers)
// noinspection DuplicatedCode
if (data?.ret === 0) {
return data?.data
}
return false;
}
async function GetShelvesList() {
let url = `https://m.jingxi.com/dreamfactory/userinfo/GetShelvesList?zone=dream_factory&pageNo=1&pageSize=12&_time=1637282954475&_ts=1637282954475&_=1637282954475&sceneval=2&g_login_type=1&callback=jsonpCBKVV&g_ty=ls`;
// noinspection DuplicatedCode
let headers = {
'Accept': '*/*',
'Connection': 'keep-alive',
'Referer': 'https://st.jingxi.com/pingou/dream_factory/index.html',
'Accept-Encoding': 'gzip, deflate, br',
'Host': 'm.jingxi.com',
'Accept-Language': 'zh-cn',
'Cookie': $.cookie
}
// noinspection DuplicatedCode
headers['User-Agent'] = `jdpingou;iPhone;5.2.2;14.3;${$.randomString(
40)};network/wifi;model/iPhone12,1;appBuild/100630;ADID/00000000-0000-0000-0000-000000000000;supportApplePay/1;hasUPPay/0;pushNoticeIsOpen/0;hasOCPay/0;supportBestPay/0;session/1;pap/JA2019_3111789;brand/apple;supportJDSHWK/1;Mozilla/5.0 (iPhone; CPU iPhone OS 14_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148`
let data = await $.get(url, headers)
// noinspection DuplicatedCode
if (data?.ret === 0) {
return data?.data
}
return false;
}