-
Notifications
You must be signed in to change notification settings - Fork 18
/
api.js
104 lines (93 loc) · 2.55 KB
/
api.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
import {
sleep,
injectConfig,
injectParasiteSnake,
processFiles,
base64ToFile,
generateMediaKey,
arrayBufferToBase64,
encryptAndUploadFile,
getFileHash
} from './help';
import {
getChat,
scope,
getNewId,
getNewMessageId,
sendExist,
checkNumberStatus,
isMD,
sendCheckType,
addChatWapi
} from './functions/help';
import {
sendMessage,
baseSendMessage,
getAllContacts,
createGroup,
addParticipant
} from './functions';
import {
addOnStream,
addOnNewMessage,
AddOnAck
} from './listeners';
import {
serializeMessageObj,
serializeChatObj,
serializeContactObj,
serializeProfilePicThumb,
serializeRawObj,
} from './serializers'
//initialized scrap webpack
(async () => {
window[injectConfig.webpack] = window[injectConfig.webpack] || [];
window.Store = {};
while (true) {
try {
const webPackLast = window[injectConfig.webpack].length - 1;
if (!window[injectConfig.webpack][webPackLast][0].includes(injectConfig.parasite)) {
await injectParasiteSnake();
return;
}
} catch {
await sleep(1000);
}
}
})();
if (typeof window.API === 'undefined') {
window.API = {};
// Helps
window.API.getChat = getChat;
window.API.scope = scope;
window.API.getNewId = getNewId;
window.API.getNewMessageId = getNewMessageId;
window.API.sendExist = sendExist;
window.API.checkNumberStatus = checkNumberStatus;
window.API.isMD = isMD;
window.API.baseSendMessage = baseSendMessage;
window.API.processFiles = processFiles;
window.API.base64ToFile = base64ToFile;
window.API.generateMediaKey = generateMediaKey;
window.API.arrayBufferToBase64 = arrayBufferToBase64;
window.API.encryptAndUploadFile = encryptAndUploadFile;
window.API.getFileHash = getFileHash;
window.API.sendCheckType = sendCheckType;
window.API.addChatWapi = addChatWapi;
// Functions
window.API.sendMessage = sendMessage;
window.API.getAllContacts = getAllContacts;
// Group
window.API.createGroup = createGroup;
window.API.addParticipant = addParticipant;
// Serialize
window.API.serializeMessageObj = serializeMessageObj;
window.API.serializeChatObj = serializeChatObj;
window.API.serializeContactObj = serializeContactObj;
window.API.serializeProfilePicThumb = serializeProfilePicThumb;
window.API.serializeRawObj = serializeRawObj;
// On
addOnStream();
addOnNewMessage();
AddOnAck();
}