node-ainzfb-new 1.4.4 → 1.4.7
Sign up to get free protection for your applications and to get access to all the features.
- package/index.js +277 -225
- package/package.json +3 -3
- package/deleted.js +0 -587
- package/index-backup.js +0 -1089
package/deleted.js
DELETED
@@ -1,587 +0,0 @@
|
|
1
|
-
async function loginHelper(appState, email, password, globalOptions, callback, prCallback) {
|
2
|
-
var mainPromise = null;
|
3
|
-
var jar = utils.getJar();
|
4
|
-
|
5
|
-
// If we're given an appState we loop through it and save each cookie
|
6
|
-
// back into the jar.
|
7
|
-
try {
|
8
|
-
if (appState) {
|
9
|
-
//const readline = require("readline");
|
10
|
-
//const chalk = require("chalk");
|
11
|
-
//const figlet = require("figlet");
|
12
|
-
//const os = require("os");
|
13
|
-
//const { execSync } = require('child_process');
|
14
|
-
// let rl = readline.createInterface({
|
15
|
-
// input: process.stdin,
|
16
|
-
// output: process.stdout,
|
17
|
-
// prompt: chalk.hex('#00CCCC').bold('[FCA-SUS] • ')
|
18
|
-
// });
|
19
|
-
// let type = {
|
20
|
-
// 1: {
|
21
|
-
// "name": "Tạo Mật Khẩu Cho Appstate",
|
22
|
-
// onRun: async function() {
|
23
|
-
// try {
|
24
|
-
// rl.question("Hãy Nhập Mật Khẩu Bạn Muốn Đặt Cho Appstate !", (answer) => {
|
25
|
-
// console.log("Được Rồi Mật Khẩu Của Bạn Là: " + answer + ", Bạn Hãy Nhớ Kĩ Nhé !");
|
26
|
-
// process.env["FBKEY"] = answer;
|
27
|
-
// fs.writeFile('../.env', `FBKEY=${answer}`, function (err) {
|
28
|
-
// if (err) {
|
29
|
-
// submiterr(err)
|
30
|
-
// logger("Tạo File ENV Thất Bại !", "[ FCA-SUS ]")
|
31
|
-
// rl.pause();
|
32
|
-
// }
|
33
|
-
// else logger("Tạo Thành Công File ENV !","[ FCA-SUS ]")
|
34
|
-
// rl.pause();
|
35
|
-
// });
|
36
|
-
// })
|
37
|
-
// }
|
38
|
-
// catch (e) {
|
39
|
-
// console.log(e);
|
40
|
-
// logger("Đã Có Lỗi Khi Đang Try Tạo Ra Câu Hỏi =))", "[ FCA-SUS ]");
|
41
|
-
// rl.pause();
|
42
|
-
// }
|
43
|
-
// }
|
44
|
-
// },
|
45
|
-
// 2: {
|
46
|
-
// "name": "Tiếp Tục Chạy Fca Mà Không Cần Mã Hóa AppState",
|
47
|
-
// onRun: async function () {
|
48
|
-
// rl.pause();
|
49
|
-
// }
|
50
|
-
// },
|
51
|
-
// 3: {
|
52
|
-
// "name": "Đổi Mật Khẩu AppState (Comming Soon..)",
|
53
|
-
// onRun: async function () {
|
54
|
-
// console.log(chalk.red.bold("Đã bảo là comming soon rồi mà >:v"));
|
55
|
-
// }
|
56
|
-
// }
|
57
|
-
// }
|
58
|
-
// const localbrand = JSON.parse(readFileSync('./package.json')).name;
|
59
|
-
// const localbrand2 = JSON.parse(readFileSync('./node_modules/fca-sus/package.json')).version;
|
60
|
-
// var axios = require('axios');
|
61
|
-
// axios.get('https://raw.githubusercontent.com/amogusdevlol/fca-sus/main/package.json').then(async (res) => {
|
62
|
-
// if (localbrand.toUpperCase() == 'HORIZON') {
|
63
|
-
// console.group(chalk.bold.cyan('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'))
|
64
|
-
// console.log(chalk.bold.hex('#00FFCC')("[</>]") + chalk.bold.yellow(' => ') + "Hệ Điều Hành: " + chalk.bold.red(os.type()));
|
65
|
-
// console.log(chalk.bold.hex('#00FFCC')("[</>]") + chalk.bold.yellow(' => ') + "Thông Tin Máy: " + chalk.bold.red(os.version()));
|
66
|
-
// console.log(chalk.bold.hex('#00FFCC')("[</>]") + chalk.bold.yellow(' => ') + "Phiên Bản Hiện Tại: " + chalk.bold.red(localbrand2));
|
67
|
-
// console.log(chalk.bold.hex('#00FFCC')("[</>]") + chalk.bold.yellow(' => ') + "Phiên Bản Mới Nhất: " + chalk.bold.red(res.data.version));
|
68
|
-
// console.groupEnd();
|
69
|
-
// }
|
70
|
-
// else {
|
71
|
-
// console.clear();
|
72
|
-
// console.log(figlet.textSync('TeamHorizon', {font: 'ANSI Shadow',horizontalLayout: 'default',verticalLayout: 'default',width: 0,whitespaceBreak: true }))
|
73
|
-
// console.log(chalk.hex('#9966CC')(`━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━`));
|
74
|
-
// }
|
75
|
-
// });
|
76
|
-
|
77
|
-
logger(Language.OnProcess, "[ FCA-SUS ]");
|
78
|
-
var backup = async(data) => {
|
79
|
-
if (fs.existsSync('./appstate.json')) {
|
80
|
-
try {
|
81
|
-
fs.writeFileSync('./appstate.json', data);
|
82
|
-
} catch (e) {
|
83
|
-
fs.writeFileSync('./appstate.json', JSON.stringify(data, null, "\t"));
|
84
|
-
}
|
85
|
-
logger(Language.BackupNoti, "[ FCA-SUS ]");
|
86
|
-
await new Promise(resolve => setTimeout(resolve, 5 * 1000));
|
87
|
-
process.exit(1);
|
88
|
-
} else if (fs.existsSync('./Facebook.json')) {
|
89
|
-
try {
|
90
|
-
fs.writeFileSync('./Facebook.json', data);
|
91
|
-
} catch (e) {
|
92
|
-
fs.writeFileSync('./Facebook.json', JSON.stringify(data, null, "\t"));
|
93
|
-
}
|
94
|
-
logger(Language.BackupNoti, "[ FCA-SUS ]");
|
95
|
-
await new Promise(resolve => setTimeout(resolve, 5 * 1000));
|
96
|
-
process.exit(1);
|
97
|
-
} else if (fs.existsSync('fbstate.json')) {
|
98
|
-
try {
|
99
|
-
fs.writeFileSync('./fbstate.json', data);
|
100
|
-
} catch (e) {
|
101
|
-
fs.writeFileSync('./fbstate.json', JSON.stringify(data), null, "\t");
|
102
|
-
}
|
103
|
-
logger(Language.BackupNoti, "[ FCA-SUS ]");
|
104
|
-
await new Promise(resolve => setTimeout(resolve, 5 * 1000));
|
105
|
-
process.exit(1);
|
106
|
-
} else return logger.Error();
|
107
|
-
}
|
108
|
-
|
109
|
-
switch (process.platform) {
|
110
|
-
case "win32":
|
111
|
-
{
|
112
|
-
try {
|
113
|
-
var { body } = await Fetch('https://decrypt-appstate-production.up.railway.app/getKey');
|
114
|
-
process.env['FBKEY'] = JSON.parse(body).Data;
|
115
|
-
} catch (e) {
|
116
|
-
logger(Language.ErrGetPassWord);
|
117
|
-
logger.Error();
|
118
|
-
process.exit(1);
|
119
|
-
}
|
120
|
-
}
|
121
|
-
break;
|
122
|
-
case "linux":
|
123
|
-
{
|
124
|
-
if (process.env["REPL_ID"] == undefined) {
|
125
|
-
try {
|
126
|
-
var { body } = await Fetch.get('https://decrypt-appstate-production.up.railway.app/getKey');
|
127
|
-
process.env['FBKEY'] = JSON.parse(body).Data;
|
128
|
-
} catch (e) {
|
129
|
-
logger(Language.ErrGetPassWord, '[ FCA-SUS ]');
|
130
|
-
logger.Error();
|
131
|
-
process.exit(1);
|
132
|
-
}
|
133
|
-
} else {
|
134
|
-
try {
|
135
|
-
const client = new Client();
|
136
|
-
let key = await client.get("FBKEY");
|
137
|
-
if (!key) {
|
138
|
-
await client.set("FBKEY", makeid(49));
|
139
|
-
let key = await client.get("FBKEY");
|
140
|
-
process.env['FBKEY'] = key;
|
141
|
-
} else {
|
142
|
-
process.env['FBKEY'] = key;
|
143
|
-
}
|
144
|
-
} catch (e) {
|
145
|
-
logger(Language.ErrGenerateKey, '[ FCA-SUS ]');
|
146
|
-
logger(e, '[ FCA-SUS ]');
|
147
|
-
logger.Error();
|
148
|
-
process.exit(0)
|
149
|
-
}
|
150
|
-
}
|
151
|
-
}
|
152
|
-
break;
|
153
|
-
case "android":
|
154
|
-
{
|
155
|
-
try {
|
156
|
-
var { body } = await Fetch.get('https://decrypt-appstate-production.up.railway.app/getKey');
|
157
|
-
process.env['FBKEY'] = JSON.parse(body).Data;
|
158
|
-
} catch (e) {
|
159
|
-
logger(Language.ErrGetPassWord, '[ FCA-SUS ]');
|
160
|
-
return logger.Error();
|
161
|
-
}
|
162
|
-
}
|
163
|
-
break;
|
164
|
-
default:
|
165
|
-
{
|
166
|
-
logger(Language.UnsupportedDevice, '[ FCA-SUS ]');
|
167
|
-
logger.Error();
|
168
|
-
process.exit(0);
|
169
|
-
}
|
170
|
-
}
|
171
|
-
|
172
|
-
try {
|
173
|
-
switch (require("../../FastConfigFca.json").EncryptFeature) {
|
174
|
-
case true:
|
175
|
-
{
|
176
|
-
appState = JSON.parse(JSON.stringify(appState, null, "\t"));
|
177
|
-
switch (utils.getType(appState)) {
|
178
|
-
case "Array":
|
179
|
-
{
|
180
|
-
logger(Language.NotReadyToDecrypt, '[ FCA-SUS ]');
|
181
|
-
}
|
182
|
-
break;
|
183
|
-
case "String":
|
184
|
-
{
|
185
|
-
try {
|
186
|
-
appState = StateCrypt.decryptState(appState, process.env['FBKEY']);
|
187
|
-
logger(Language.DecryptSuccess, '[ FCA-SUS ]');
|
188
|
-
} catch (e) {
|
189
|
-
if (process.env.Backup != undefined && process.env.Backup) {
|
190
|
-
backup(process.env.Backup);
|
191
|
-
} else switch (process.platform) {
|
192
|
-
case "win32":
|
193
|
-
{
|
194
|
-
try {
|
195
|
-
if (fs.existsSync('./backupappstate.json')) {
|
196
|
-
let content = fs.readFileSync('./backupappstate.json', 'utf8');
|
197
|
-
return backup(content);
|
198
|
-
}
|
199
|
-
} catch (e) {
|
200
|
-
logger(Language.ErrBackup, '[ FCA-SUS ]');
|
201
|
-
logger.Error();
|
202
|
-
process.exit(0);
|
203
|
-
}
|
204
|
-
}
|
205
|
-
break;
|
206
|
-
case "linux":
|
207
|
-
{
|
208
|
-
if (process.env["REPL_ID"] == undefined) {
|
209
|
-
try {
|
210
|
-
if (fs.existsSync('./backupappstate.json')) {
|
211
|
-
let content = fs.readFileSync('./backupappstate.json', 'utf8');
|
212
|
-
return backup(content);
|
213
|
-
}
|
214
|
-
} catch (e) {
|
215
|
-
logger(Language.ErrBackup, '[ FCA-SUS ]');
|
216
|
-
logger.Error();
|
217
|
-
process.exit(0);
|
218
|
-
}
|
219
|
-
} else {
|
220
|
-
try {
|
221
|
-
const client = new Client();
|
222
|
-
let key = await client.get("Backup");
|
223
|
-
if (key) {
|
224
|
-
return backup(JSON.stringify(key));
|
225
|
-
} else {
|
226
|
-
logger(Language.ErrBackup, '[ FCA-SUS ]');
|
227
|
-
}
|
228
|
-
} catch (e) {
|
229
|
-
logger(Language.ErrBackup, '[ FCA-SUS ]');
|
230
|
-
}
|
231
|
-
}
|
232
|
-
}
|
233
|
-
break;
|
234
|
-
case "android":
|
235
|
-
{
|
236
|
-
try {
|
237
|
-
if (fs.existsSync('./backupappstate.json')) {
|
238
|
-
let content = fs.readFileSync('./backupappstate.json', 'utf8');
|
239
|
-
return backup(content);
|
240
|
-
}
|
241
|
-
} catch (e) {
|
242
|
-
logger(Language.ErrBackup, '[ FCA-SUS ]');
|
243
|
-
logger.Error();
|
244
|
-
process.exit(0);
|
245
|
-
}
|
246
|
-
}
|
247
|
-
}
|
248
|
-
logger(Language.DecryptFailed, '[ FCA-SUS ]');
|
249
|
-
return logger.Error();
|
250
|
-
}
|
251
|
-
logger(getText.gettext(Language.YourAppStatePass, process.env.FBKEY), '[ FCA-SUS ]');
|
252
|
-
}
|
253
|
-
break;
|
254
|
-
default:
|
255
|
-
{
|
256
|
-
logger(Language.InvaildAppState, "[ FCA-SUS ]");
|
257
|
-
process.exit(0)
|
258
|
-
}
|
259
|
-
}
|
260
|
-
}
|
261
|
-
break;
|
262
|
-
case false:
|
263
|
-
{
|
264
|
-
switch (utils.getType(appState)) {
|
265
|
-
case "Array":
|
266
|
-
{
|
267
|
-
logger(Language.EncryptStateOff, "[ FCA-SUS ]");
|
268
|
-
}
|
269
|
-
break;
|
270
|
-
case "String":
|
271
|
-
{
|
272
|
-
logger(Language.EncryptStateOff, "[ FCA-SUS ]");
|
273
|
-
try {
|
274
|
-
appState = StateCrypt.decryptState(appState, process.env['FBKEY']);
|
275
|
-
logger(Language.DecryptSuccess, '[ FCA-SUS ]');
|
276
|
-
} catch (e) {
|
277
|
-
if (process.env.Backup != undefined && process.env.Backup) {
|
278
|
-
backup(process.env.Backup);
|
279
|
-
} else switch (process.platform) {
|
280
|
-
case "win32":
|
281
|
-
{
|
282
|
-
try {
|
283
|
-
if (fs.existsSync('./backupappstate.json')) {
|
284
|
-
let content = fs.readFileSync('./backupappstate.json', 'utf8');
|
285
|
-
return backup(content);
|
286
|
-
}
|
287
|
-
} catch (e) {
|
288
|
-
logger(Language.ErrBackup, '[ FCA-SUS ]');
|
289
|
-
logger.Error();
|
290
|
-
process.exit(0);
|
291
|
-
}
|
292
|
-
}
|
293
|
-
break;
|
294
|
-
case "linux":
|
295
|
-
{
|
296
|
-
if (process.env["REPL_ID"] == undefined) {
|
297
|
-
try {
|
298
|
-
if (fs.existsSync('./backupappstate.json')) {
|
299
|
-
let content = fs.readFileSync('./backupappstate.json', 'utf8');
|
300
|
-
return backup(content);
|
301
|
-
}
|
302
|
-
} catch (e) {
|
303
|
-
logger(Language.ErrBackup, '[ FCA-SUS ]');
|
304
|
-
logger.Error();
|
305
|
-
process.exit(0);
|
306
|
-
}
|
307
|
-
} else {
|
308
|
-
try {
|
309
|
-
const client = new Client();
|
310
|
-
let key = await client.get("Backup");
|
311
|
-
if (key) {
|
312
|
-
return backup(JSON.stringify(key));
|
313
|
-
} else {
|
314
|
-
logger(Language.ErrBackup, '[ FCA-SUS ]');
|
315
|
-
}
|
316
|
-
} catch (e) {
|
317
|
-
logger(Language.ErrBackup, '[ FCA-SUS ]');
|
318
|
-
}
|
319
|
-
}
|
320
|
-
}
|
321
|
-
break;
|
322
|
-
case "android":
|
323
|
-
{
|
324
|
-
try {
|
325
|
-
if (fs.existsSync('./backupappstate.json')) {
|
326
|
-
let content = fs.readFileSync('./backupappstate.json', 'utf8');
|
327
|
-
return backup(content);
|
328
|
-
}
|
329
|
-
} catch (e) {
|
330
|
-
logger(Language.ErrBackup, '[ FCA-SUS ]');
|
331
|
-
logger.Error();
|
332
|
-
process.exit(0);
|
333
|
-
}
|
334
|
-
}
|
335
|
-
}
|
336
|
-
logger(Language.DecryptFailed, '[ FCA-SUS ]');
|
337
|
-
return logger.Error();
|
338
|
-
}
|
339
|
-
}
|
340
|
-
break;
|
341
|
-
default:
|
342
|
-
{
|
343
|
-
logger(Language.InvaildAppState, "[ FCA-SUS ]");
|
344
|
-
process.exit(0)
|
345
|
-
}
|
346
|
-
}
|
347
|
-
}
|
348
|
-
break;
|
349
|
-
default:
|
350
|
-
{
|
351
|
-
logger(getText.gettext(Language.IsNotABoolean, require("../../FastConfigFca.json").EncryptFeature), "[ FCA-SUS ]")
|
352
|
-
process.exit(0);
|
353
|
-
}
|
354
|
-
}
|
355
|
-
} catch (e) {
|
356
|
-
console.log(e);
|
357
|
-
}
|
358
|
-
|
359
|
-
try {
|
360
|
-
appState = JSON.parse(appState);
|
361
|
-
} catch (e) {
|
362
|
-
try {
|
363
|
-
appState = appState;
|
364
|
-
} catch (e) {
|
365
|
-
return logger.Error();
|
366
|
-
}
|
367
|
-
}
|
368
|
-
try {
|
369
|
-
appState.map(function(c) {
|
370
|
-
var str = c.key + "=" + c.value + "; expires=" + c.expires + "; domain=" + c.domain + "; path=" + c.path + ";";
|
371
|
-
jar.setCookie(str, "http://" + c.domain);
|
372
|
-
});
|
373
|
-
switch (process.platform) {
|
374
|
-
case "win32":
|
375
|
-
{
|
376
|
-
try {
|
377
|
-
fs.writeFileSync("./backupappstate.json", JSON.stringify(appState, null, "\t"));
|
378
|
-
process.env.Backup = JSON.stringify(appState, null, "\t");
|
379
|
-
} catch (e) {
|
380
|
-
logger(Language.BackupFailed, '[ FCA-SUS ]');
|
381
|
-
}
|
382
|
-
}
|
383
|
-
break;
|
384
|
-
case "linux":
|
385
|
-
{
|
386
|
-
if (process.env["REPL_ID"] == undefined) {
|
387
|
-
try {
|
388
|
-
fs.writeFileSync("./backupappstate.json", JSON.stringify(appState, null, "\t"));
|
389
|
-
process.env.Backup = JSON.stringify(appState, null, "\t");
|
390
|
-
} catch (e) {
|
391
|
-
logger(Language.BackupFailed, '[ FCA-SUS ]');
|
392
|
-
}
|
393
|
-
} else {
|
394
|
-
try {
|
395
|
-
if (fs.existsSync('./backupappstate.json')) {
|
396
|
-
fs.unlinkSync('./backupappstate.json');
|
397
|
-
}
|
398
|
-
const client = new Client();
|
399
|
-
await client.set("Backup", appState);
|
400
|
-
process.env.Backup = JSON.stringify(appState, null, "\t");
|
401
|
-
} catch (e) {
|
402
|
-
logger(Language.BackupFailed, '[ FCA-SUS ]');
|
403
|
-
}
|
404
|
-
}
|
405
|
-
}
|
406
|
-
break;
|
407
|
-
case "android":
|
408
|
-
{
|
409
|
-
try {
|
410
|
-
fs.writeFileSync("./backupappstate.json", JSON.stringify(appState, null, "\t"));
|
411
|
-
process.env.Backup = JSON.stringify(appState, null, "\t");
|
412
|
-
} catch (e) {
|
413
|
-
logger(Language.BackupFailed, '[ FCA-SUS ]');
|
414
|
-
}
|
415
|
-
}
|
416
|
-
}
|
417
|
-
|
418
|
-
mainPromise = utils.get('https://www.facebook.com/', jar, null, globalOptions, { noRef: true }).then(utils.saveCookies(jar));
|
419
|
-
} catch (e) {
|
420
|
-
|
421
|
-
if (process.env.Backup != undefined && process.env.Backup) {
|
422
|
-
return backup(process.env.Backup);
|
423
|
-
}
|
424
|
-
switch (process.platform) {
|
425
|
-
case "win32":
|
426
|
-
{
|
427
|
-
try {
|
428
|
-
if (fs.existsSync('./backupappstate.json')) {
|
429
|
-
let content = fs.readFileSync('./backupappstate.json', 'utf8');
|
430
|
-
return backup(content);
|
431
|
-
}
|
432
|
-
} catch (e) {
|
433
|
-
logger(Language.ErrBackup, '[ FCA-SUS ]');
|
434
|
-
logger.Error();
|
435
|
-
process.exit(0);
|
436
|
-
}
|
437
|
-
}
|
438
|
-
break;
|
439
|
-
case "linux":
|
440
|
-
{
|
441
|
-
if (process.env["REPL_ID"] == undefined) {
|
442
|
-
try {
|
443
|
-
if (fs.existsSync('./backupappstate.json')) {
|
444
|
-
let content = fs.readFileSync('./backupappstate.json', 'utf8');
|
445
|
-
return backup(content);
|
446
|
-
}
|
447
|
-
} catch (e) {
|
448
|
-
logger(Language.ErrBackup, '[ FCA-SUS ]');
|
449
|
-
logger.Error();
|
450
|
-
process.exit(0);
|
451
|
-
}
|
452
|
-
} else {
|
453
|
-
try {
|
454
|
-
const client = new Client();
|
455
|
-
let key = await client.get("Backup");
|
456
|
-
if (key) {
|
457
|
-
backup(JSON.stringify(key));
|
458
|
-
} else {
|
459
|
-
logger(Language.ErrBackup, '[ FCA-SUS ]');
|
460
|
-
}
|
461
|
-
} catch (e) {
|
462
|
-
logger(Language.ErrBackup, '[ FCA-SUS ]');
|
463
|
-
}
|
464
|
-
}
|
465
|
-
}
|
466
|
-
break;
|
467
|
-
case "android":
|
468
|
-
{
|
469
|
-
try {
|
470
|
-
if (fs.existsSync('./backupappstate.json')) {
|
471
|
-
let content = fs.readFileSync('./backupappstate.json', 'utf8');
|
472
|
-
return backup(content);
|
473
|
-
}
|
474
|
-
} catch (e) {
|
475
|
-
logger(Language.ErrBackup, '[ FCA-SUS ]');
|
476
|
-
logger.Error();
|
477
|
-
process.exit(0);
|
478
|
-
}
|
479
|
-
}
|
480
|
-
break;
|
481
|
-
}
|
482
|
-
|
483
|
-
console.log(e);
|
484
|
-
return logger(Language.ScreenShotConsoleAndSendToAdmin, '[ FCA-HSP ]');
|
485
|
-
}
|
486
|
-
} else {
|
487
|
-
// Open the main page, then we login with the given credentials and finally
|
488
|
-
// load the main page again (it'll give us some IDs that we need)
|
489
|
-
mainPromise = utils
|
490
|
-
.get("https://www.facebook.com/", null, null, globalOptions, { noRef: true })
|
491
|
-
.then(utils.saveCookies(jar))
|
492
|
-
.then(makeLogin(jar, email, password, globalOptions, callback, prCallback))
|
493
|
-
.then(function() {
|
494
|
-
return utils.get('https://www.facebook.com/', jar, null, globalOptions).then(utils.saveCookies(jar));
|
495
|
-
});
|
496
|
-
}
|
497
|
-
} catch (e) {
|
498
|
-
console.log(e);
|
499
|
-
}
|
500
|
-
var ctx = null;
|
501
|
-
var _defaultFuncs = null;
|
502
|
-
var api = null;
|
503
|
-
|
504
|
-
mainPromise = mainPromise
|
505
|
-
.then(function(res) {
|
506
|
-
// Hacky check for the redirection that happens on some ISPs, which doesn't return statusCode 3xx
|
507
|
-
var reg = /<meta http-equiv="refresh" content="0;url=([^"]+)[^>]+>/;
|
508
|
-
var redirect = reg.exec(res.body);
|
509
|
-
if (redirect && redirect[1]) return utils.get(redirect[1], jar, null, globalOptions).then(utils.saveCookies(jar));
|
510
|
-
return res;
|
511
|
-
})
|
512
|
-
.then(async function(res) {
|
513
|
-
var html = res.body;
|
514
|
-
var stuff = await buildAPI(globalOptions, html, jar);
|
515
|
-
ctx = stuff[0];
|
516
|
-
_defaultFuncs = stuff[1];
|
517
|
-
api = stuff[2];
|
518
|
-
return res;
|
519
|
-
});
|
520
|
-
// given a pageID we log in as a page
|
521
|
-
if (globalOptions.pageID) {
|
522
|
-
mainPromise = mainPromise
|
523
|
-
.then(function() {
|
524
|
-
return utils.get('https://www.facebook.com/' + ctx.globalOptions.pageID + '/messages/?section=messages&subsection=inbox', ctx.jar, null, globalOptions);
|
525
|
-
})
|
526
|
-
.then(function(resData) {
|
527
|
-
var url = utils.getFrom(resData.body, 'window.location.replace("https:\\/\\/www.facebook.com\\', '");').split('\\').join('');
|
528
|
-
url = url.substring(0, url.length - 1);
|
529
|
-
return utils.get('https://www.facebook.com' + url, ctx.jar, null, globalOptions);
|
530
|
-
});
|
531
|
-
}
|
532
|
-
|
533
|
-
// At the end we call the callback or catch an exception
|
534
|
-
mainPromise
|
535
|
-
.then(function() {
|
536
|
-
logger(Language.DoneLogin, "[ FCA-SUS ]");
|
537
|
-
logger(Language.AutoCheckUpdate, "[ FCA-SUS ]");
|
538
|
-
//!---------- Auto Check, Update START -----------------!//
|
539
|
-
var Fetch = require('got');
|
540
|
-
var { readFileSync } = require('fs-extra');
|
541
|
-
const { execSync } = require('child_process');
|
542
|
-
Fetch('https://raw.githubusercontent.com/amogusdevlol/node-ainzfb/main/package.json').then(async(res) => {
|
543
|
-
const localbrand = JSON.parse(readFileSync('./node_modules/node-ainzfb/package.json')).version;
|
544
|
-
if (Number(localbrand.replace(/\./g, "")) < Number(JSON.parse(res.body.toString()).version.replace(/\./g, ""))) {
|
545
|
-
log.warn("[ FCA-SUS ] •", getText.gettext(Language.NewVersionFound, JSON.parse(readFileSync('./node_modules/node-ainzfb/package.json')).version, JSON.parse(res.body.toString()).version));
|
546
|
-
log.warn("[ FCA-SUS ] •", Language.AutoUpdate);
|
547
|
-
try {
|
548
|
-
execSync('npm install node-ainzfb@latest', { stdio: 'inherit' });
|
549
|
-
logger(Language.UpdateSuccess, "[ FCA-SUS ]")
|
550
|
-
logger(Language.RestartAfterUpdate, '[ FCA-SUS ]');
|
551
|
-
await new Promise(resolve => setTimeout(resolve, 5 * 1000));
|
552
|
-
console.clear();
|
553
|
-
process.exit(1);
|
554
|
-
} catch (err) {
|
555
|
-
log.warn('Error Update: ' + err);
|
556
|
-
logger(Language.UpdateFailed, "[ FCA-SUS ]");
|
557
|
-
try {
|
558
|
-
require.resolve('sus-support');
|
559
|
-
} catch (e) {
|
560
|
-
logger(Language.InstallSupportTool, "[ FCA-SUS ]");
|
561
|
-
execSync('npm install git+https://github.com/amogusdevlol/sus-support.git', { stdio: 'inherit' });
|
562
|
-
process.exit(1);
|
563
|
-
}
|
564
|
-
var fcasp = require('sus-support');
|
565
|
-
try {
|
566
|
-
fcasp.onError()
|
567
|
-
} catch (e) {
|
568
|
-
logger(Language.NotiAfterUseToolFail, "[ Fca - Helper ]")
|
569
|
-
logger("rmdir ./node_modules then enter npm i && npm start", "[ Fca - Helper ]");
|
570
|
-
process.exit(0);
|
571
|
-
}
|
572
|
-
|
573
|
-
}
|
574
|
-
} else {
|
575
|
-
logger(getText.gettext(Language.LocalVersion, localbrand), "[ FCA-SUS ]");
|
576
|
-
logger(Language.WishMessage[Math.floor(Math.random() * Language.WishMessage.length)], "[ FCA-SUS ]");
|
577
|
-
require('./Extra/ExtraUptimeRobot')()
|
578
|
-
await new Promise(resolve => setTimeout(resolve, 5 * 1000));
|
579
|
-
callback(null, api);
|
580
|
-
}
|
581
|
-
});
|
582
|
-
}).catch(function(e) {
|
583
|
-
log.error("login", e.error || e);
|
584
|
-
callback(e);
|
585
|
-
});
|
586
|
-
//!---------- Auto Check, Update END -----------------!//
|
587
|
-
}
|