@another-trial/whatsapp-web.js 1.34.0 → 1.34.5-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +2 -2
- package/CODE_OF_CONDUCT.md +133 -133
- package/LICENSE +201 -201
- package/README.md +155 -185
- package/example.js +706 -690
- package/index.d.ts +2259 -2202
- package/index.js +35 -35
- package/package.json +59 -59
- package/shell.js +36 -36
- package/src/Client.js +2533 -2361
- package/src/authStrategies/BaseAuthStrategy.js +26 -26
- package/src/authStrategies/LocalAuth.js +58 -58
- package/src/authStrategies/NoAuth.js +11 -11
- package/src/authStrategies/RemoteAuth.js +210 -210
- package/src/factories/ChatFactory.js +21 -21
- package/src/factories/ContactFactory.js +15 -15
- package/src/structures/Base.js +21 -21
- package/src/structures/Broadcast.js +69 -69
- package/src/structures/BusinessContact.js +20 -20
- package/src/structures/Buttons.js +81 -81
- package/src/structures/Call.js +75 -75
- package/src/structures/Channel.js +382 -382
- package/src/structures/Chat.js +329 -299
- package/src/structures/ClientInfo.js +70 -70
- package/src/structures/Contact.js +215 -208
- package/src/structures/GroupChat.js +485 -485
- package/src/structures/GroupNotification.js +104 -104
- package/src/structures/Label.js +49 -49
- package/src/structures/List.js +79 -79
- package/src/structures/Location.js +61 -61
- package/src/structures/Message.js +787 -747
- package/src/structures/MessageMedia.js +111 -111
- package/src/structures/Order.js +51 -51
- package/src/structures/Payment.js +79 -79
- package/src/structures/Poll.js +44 -44
- package/src/structures/PollVote.js +75 -75
- package/src/structures/PrivateChat.js +12 -12
- package/src/structures/PrivateContact.js +12 -12
- package/src/structures/Product.js +67 -67
- package/src/structures/ProductMetadata.js +24 -24
- package/src/structures/Reaction.js +68 -68
- package/src/structures/ScheduledEvent.js +71 -71
- package/src/structures/index.js +27 -27
- package/src/util/Constants.js +186 -183
- package/src/util/Injected/AuthStore/AuthStore.js +16 -16
- package/src/util/Injected/AuthStore/LegacyAuthStore.js +21 -21
- package/src/util/Injected/LegacyStore.js +145 -145
- package/src/util/Injected/Store.js +263 -231
- package/src/util/Injected/Utils.js +1221 -1169
- package/src/util/InterfaceController.js +126 -126
- package/src/util/Puppeteer.js +23 -23
- package/src/util/Util.js +186 -186
- package/src/webCache/LocalWebCache.js +40 -40
- package/src/webCache/RemoteWebCache.js +39 -39
- package/src/webCache/WebCache.js +13 -13
- package/src/webCache/WebCacheFactory.js +19 -19
|
@@ -1,146 +1,146 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
//TODO: To be removed by version 2.3000.x hard release
|
|
4
|
-
|
|
5
|
-
// Exposes the internal Store to the WhatsApp Web client
|
|
6
|
-
exports.ExposeLegacyStore = () => {
|
|
7
|
-
window.Store = Object.assign({}, window.mR.findModule(m => m.default && m.default.Chat)[0].default);
|
|
8
|
-
window.Store.AppState = window.mR.findModule('Socket')[0].Socket;
|
|
9
|
-
window.Store.Conn = window.mR.findModule('Conn')[0].Conn;
|
|
10
|
-
window.Store.BlockContact = window.mR.findModule('blockContact')[0];
|
|
11
|
-
window.Store.Call = window.mR.findModule((module) => module.default && module.default.Call)[0].default.Call;
|
|
12
|
-
window.Store.Cmd = window.mR.findModule('Cmd')[0].Cmd;
|
|
13
|
-
window.Store.CryptoLib = window.mR.findModule('decryptE2EMedia')[0];
|
|
14
|
-
window.Store.DownloadManager = window.mR.findModule('downloadManager')[0].downloadManager;
|
|
15
|
-
window.Store.GroupMetadata = window.mR.findModule('GroupMetadata')[0].default.GroupMetadata;
|
|
16
|
-
window.Store.GroupQueryAndUpdate = window.mR.findModule('queryAndUpdateGroupMetadataById')[0].queryAndUpdateGroupMetadataById;
|
|
17
|
-
window.Store.Label = window.mR.findModule('LabelCollection')[0].LabelCollection;
|
|
18
|
-
window.Store.MediaPrep = window.mR.findModule('prepRawMedia')[0];
|
|
19
|
-
window.Store.MediaObject = window.mR.findModule('getOrCreateMediaObject')[0];
|
|
20
|
-
window.Store.NumberInfo = window.mR.findModule('formattedPhoneNumber')[0];
|
|
21
|
-
window.Store.MediaTypes = window.mR.findModule('msgToMediaType')[0];
|
|
22
|
-
window.Store.MediaUpload = window.mR.findModule('uploadMedia')[0];
|
|
23
|
-
window.Store.MsgKey = window.mR.findModule((module) => module.default && module.default.fromString)[0].default;
|
|
24
|
-
window.Store.OpaqueData = window.mR.findModule(module => module.default && module.default.createFromData)[0].default;
|
|
25
|
-
window.Store.QueryProduct = window.mR.findModule('queryProduct')[0];
|
|
26
|
-
window.Store.QueryOrder = window.mR.findModule('queryOrder')[0];
|
|
27
|
-
window.Store.SendClear = window.mR.findModule('sendClear')[0];
|
|
28
|
-
window.Store.SendDelete = window.mR.findModule('sendDelete')[0];
|
|
29
|
-
window.Store.SendMessage = window.mR.findModule('addAndSendMsgToChat')[0];
|
|
30
|
-
window.Store.EditMessage = window.mR.findModule('addAndSendMessageEdit')[0];
|
|
31
|
-
window.Store.SendSeen = window.mR.findModule('sendSeen')[0];
|
|
32
|
-
window.Store.User = window.mR.findModule('getMaybeMeUser')[0];
|
|
33
|
-
window.Store.ContactMethods = window.mR.findModule('getUserid')[0];
|
|
34
|
-
window.Store.UploadUtils = window.mR.findModule((module) => (module.default && module.default.encryptAndUpload) ? module.default : null)[0].default;
|
|
35
|
-
window.Store.UserConstructor = window.mR.findModule((module) => (module.default && module.default.prototype && module.default.prototype.isServer && module.default.prototype.isUser) ? module.default : null)[0].default;
|
|
36
|
-
window.Store.Validators = window.mR.findModule('findLinks')[0];
|
|
37
|
-
window.Store.VCard = window.mR.findModule('vcardFromContactModel')[0];
|
|
38
|
-
window.Store.WidFactory = window.mR.findModule('createWid')[0];
|
|
39
|
-
window.Store.ProfilePic = window.mR.findModule('profilePicResync')[0];
|
|
40
|
-
window.Store.PresenceUtils = window.mR.findModule('sendPresenceAvailable')[0];
|
|
41
|
-
window.Store.ChatState = window.mR.findModule('sendChatStateComposing')[0];
|
|
42
|
-
window.Store.findCommonGroups = window.mR.findModule('findCommonGroups')[0].findCommonGroups;
|
|
43
|
-
window.Store.StatusUtils = window.mR.findModule('setMyStatus')[0];
|
|
44
|
-
window.Store.ConversationMsgs = window.mR.findModule('loadEarlierMsgs')[0];
|
|
45
|
-
window.Store.sendReactionToMsg = window.mR.findModule('sendReactionToMsg')[0].sendReactionToMsg;
|
|
46
|
-
window.Store.createOrUpdateReactionsModule = window.mR.findModule('createOrUpdateReactions')[0];
|
|
47
|
-
window.Store.EphemeralFields = window.mR.findModule('getEphemeralFields')[0];
|
|
48
|
-
window.Store.MsgActionChecks = window.mR.findModule('canSenderRevokeMsg')[0];
|
|
49
|
-
window.Store.QuotedMsg = window.mR.findModule('getQuotedMsgObj')[0];
|
|
50
|
-
window.Store.LinkPreview = window.mR.findModule('getLinkPreview')[0];
|
|
51
|
-
window.Store.Socket = window.mR.findModule('deprecatedSendIq')[0];
|
|
52
|
-
window.Store.SocketWap = window.mR.findModule('wap')[0];
|
|
53
|
-
window.Store.SearchContext = window.mR.findModule('getSearchContext')[0].getSearchContext;
|
|
54
|
-
window.Store.DrawerManager = window.mR.findModule('DrawerManager')[0].DrawerManager;
|
|
55
|
-
window.Store.LidUtils = window.mR.findModule('getCurrentLid')[0];
|
|
56
|
-
window.Store.WidToJid = window.mR.findModule('widToUserJid')[0];
|
|
57
|
-
window.Store.JidToWid = window.mR.findModule('userJidToUserWid')[0];
|
|
58
|
-
window.Store.getMsgInfo = (window.mR.findModule('sendQueryMsgInfo')[0] || {}).sendQueryMsgInfo || window.mR.findModule('queryMsgInfo')[0].queryMsgInfo;
|
|
59
|
-
window.Store.pinUnpinMsg = window.mR.findModule('sendPinInChatMsg')[0].sendPinInChatMsg;
|
|
60
|
-
|
|
61
|
-
/* eslint-disable no-undef, no-cond-assign */
|
|
62
|
-
window.Store.QueryExist = ((m = window.mR.findModule('queryExists')[0]) ? m.queryExists : window.mR.findModule('queryExist')[0].queryWidExists);
|
|
63
|
-
window.Store.ReplyUtils = (m = window.mR.findModule('canReplyMsg')).length > 0 && m[0];
|
|
64
|
-
/* eslint-enable no-undef, no-cond-assign */
|
|
65
|
-
|
|
66
|
-
window.Store.Settings = {
|
|
67
|
-
...window.mR.findModule('ChatlistPanelState')[0],
|
|
68
|
-
setPushname: window.mR.findModule((m) => m.setPushname && !m.ChatlistPanelState)[0].setPushname
|
|
69
|
-
};
|
|
70
|
-
window.Store.StickerTools = {
|
|
71
|
-
...window.mR.findModule('toWebpSticker')[0],
|
|
72
|
-
...window.mR.findModule('addWebpMetadata')[0]
|
|
73
|
-
};
|
|
74
|
-
window.Store.GroupUtils = {
|
|
75
|
-
...window.mR.findModule('createGroup')[0],
|
|
76
|
-
...window.mR.findModule('setGroupDescription')[0],
|
|
77
|
-
...window.mR.findModule('sendExitGroup')[0],
|
|
78
|
-
...window.mR.findModule('sendSetPicture')[0]
|
|
79
|
-
};
|
|
80
|
-
window.Store.GroupParticipants = {
|
|
81
|
-
...window.mR.findModule('promoteParticipants')[0],
|
|
82
|
-
...window.mR.findModule('sendAddParticipantsRPC')[0]
|
|
83
|
-
};
|
|
84
|
-
window.Store.GroupInvite = {
|
|
85
|
-
...window.mR.findModule('resetGroupInviteCode')[0],
|
|
86
|
-
...window.mR.findModule('queryGroupInvite')[0]
|
|
87
|
-
};
|
|
88
|
-
window.Store.GroupInviteV4 = {
|
|
89
|
-
...window.mR.findModule('queryGroupInviteV4')[0],
|
|
90
|
-
...window.mR.findModule('sendGroupInviteMessage')[0]
|
|
91
|
-
};
|
|
92
|
-
window.Store.MembershipRequestUtils = {
|
|
93
|
-
...window.mR.findModule('getMembershipApprovalRequests')[0],
|
|
94
|
-
...window.mR.findModule('sendMembershipRequestsActionRPC')[0]
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
if (!window.Store.Chat._find) {
|
|
98
|
-
window.Store.Chat._find = e => {
|
|
99
|
-
const target = window.Store.Chat.get(e);
|
|
100
|
-
return target ? Promise.resolve(target) : Promise.resolve({
|
|
101
|
-
id: e
|
|
102
|
-
});
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// eslint-disable-next-line no-undef
|
|
107
|
-
if ((m = window.mR.findModule('ChatCollection')[0]) && m.ChatCollection && typeof m.ChatCollection.findImpl === 'undefined' && typeof m.ChatCollection._find !== 'undefined') m.ChatCollection.findImpl = m.ChatCollection._find;
|
|
108
|
-
|
|
109
|
-
const _isMDBackend = window.mR.findModule('isMDBackend');
|
|
110
|
-
if(_isMDBackend && _isMDBackend[0] && _isMDBackend[0].isMDBackend) {
|
|
111
|
-
window.Store.MDBackend = _isMDBackend[0].isMDBackend();
|
|
112
|
-
} else {
|
|
113
|
-
window.Store.MDBackend = true;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
const _features = window.mR.findModule('FEATURE_CHANGE_EVENT')[0];
|
|
117
|
-
if(_features) {
|
|
118
|
-
window.Store.Features = _features.LegacyPhoneFeatures;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Target options object description
|
|
123
|
-
* @typedef {Object} TargetOptions
|
|
124
|
-
* @property {string|number} module The name or a key of the target module to search
|
|
125
|
-
* @property {number} index The index value of the target module
|
|
126
|
-
* @property {string} function The function name to get from a module
|
|
127
|
-
*/
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Function to modify functions
|
|
131
|
-
* @param {TargetOptions} target Options specifying the target function to search for modifying
|
|
132
|
-
* @param {Function} callback Modified function
|
|
133
|
-
*/
|
|
134
|
-
window.injectToFunction = (target, callback) => {
|
|
135
|
-
const module = typeof target.module === 'string'
|
|
136
|
-
? window.mR.findModule(target.module)
|
|
137
|
-
: window.mR.modules[target.module];
|
|
138
|
-
const originalFunction = module[target.index][target.function];
|
|
139
|
-
const modifiedFunction = (...args) => callback(originalFunction, ...args);
|
|
140
|
-
module[target.index][target.function] = modifiedFunction;
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
window.injectToFunction({ module: 'mediaTypeFromProtobuf', index: 0, function: 'mediaTypeFromProtobuf' }, (func, ...args) => { const [proto] = args; return proto.locationMessage ? null : func(...args); });
|
|
144
|
-
|
|
145
|
-
window.injectToFunction({ module: 'typeAttributeFromProtobuf', index: 0, function: 'typeAttributeFromProtobuf' }, (func, ...args) => { const [proto] = args; return proto.locationMessage || proto.groupInviteMessage ? 'text' : func(...args); });
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
//TODO: To be removed by version 2.3000.x hard release
|
|
4
|
+
|
|
5
|
+
// Exposes the internal Store to the WhatsApp Web client
|
|
6
|
+
exports.ExposeLegacyStore = () => {
|
|
7
|
+
window.Store = Object.assign({}, window.mR.findModule(m => m.default && m.default.Chat)[0].default);
|
|
8
|
+
window.Store.AppState = window.mR.findModule('Socket')[0].Socket;
|
|
9
|
+
window.Store.Conn = window.mR.findModule('Conn')[0].Conn;
|
|
10
|
+
window.Store.BlockContact = window.mR.findModule('blockContact')[0];
|
|
11
|
+
window.Store.Call = window.mR.findModule((module) => module.default && module.default.Call)[0].default.Call;
|
|
12
|
+
window.Store.Cmd = window.mR.findModule('Cmd')[0].Cmd;
|
|
13
|
+
window.Store.CryptoLib = window.mR.findModule('decryptE2EMedia')[0];
|
|
14
|
+
window.Store.DownloadManager = window.mR.findModule('downloadManager')[0].downloadManager;
|
|
15
|
+
window.Store.GroupMetadata = window.mR.findModule('GroupMetadata')[0].default.GroupMetadata;
|
|
16
|
+
window.Store.GroupQueryAndUpdate = window.mR.findModule('queryAndUpdateGroupMetadataById')[0].queryAndUpdateGroupMetadataById;
|
|
17
|
+
window.Store.Label = window.mR.findModule('LabelCollection')[0].LabelCollection;
|
|
18
|
+
window.Store.MediaPrep = window.mR.findModule('prepRawMedia')[0];
|
|
19
|
+
window.Store.MediaObject = window.mR.findModule('getOrCreateMediaObject')[0];
|
|
20
|
+
window.Store.NumberInfo = window.mR.findModule('formattedPhoneNumber')[0];
|
|
21
|
+
window.Store.MediaTypes = window.mR.findModule('msgToMediaType')[0];
|
|
22
|
+
window.Store.MediaUpload = window.mR.findModule('uploadMedia')[0];
|
|
23
|
+
window.Store.MsgKey = window.mR.findModule((module) => module.default && module.default.fromString)[0].default;
|
|
24
|
+
window.Store.OpaqueData = window.mR.findModule(module => module.default && module.default.createFromData)[0].default;
|
|
25
|
+
window.Store.QueryProduct = window.mR.findModule('queryProduct')[0];
|
|
26
|
+
window.Store.QueryOrder = window.mR.findModule('queryOrder')[0];
|
|
27
|
+
window.Store.SendClear = window.mR.findModule('sendClear')[0];
|
|
28
|
+
window.Store.SendDelete = window.mR.findModule('sendDelete')[0];
|
|
29
|
+
window.Store.SendMessage = window.mR.findModule('addAndSendMsgToChat')[0];
|
|
30
|
+
window.Store.EditMessage = window.mR.findModule('addAndSendMessageEdit')[0];
|
|
31
|
+
window.Store.SendSeen = window.mR.findModule('sendSeen')[0];
|
|
32
|
+
window.Store.User = window.mR.findModule('getMaybeMeUser')[0];
|
|
33
|
+
window.Store.ContactMethods = window.mR.findModule('getUserid')[0];
|
|
34
|
+
window.Store.UploadUtils = window.mR.findModule((module) => (module.default && module.default.encryptAndUpload) ? module.default : null)[0].default;
|
|
35
|
+
window.Store.UserConstructor = window.mR.findModule((module) => (module.default && module.default.prototype && module.default.prototype.isServer && module.default.prototype.isUser) ? module.default : null)[0].default;
|
|
36
|
+
window.Store.Validators = window.mR.findModule('findLinks')[0];
|
|
37
|
+
window.Store.VCard = window.mR.findModule('vcardFromContactModel')[0];
|
|
38
|
+
window.Store.WidFactory = window.mR.findModule('createWid')[0];
|
|
39
|
+
window.Store.ProfilePic = window.mR.findModule('profilePicResync')[0];
|
|
40
|
+
window.Store.PresenceUtils = window.mR.findModule('sendPresenceAvailable')[0];
|
|
41
|
+
window.Store.ChatState = window.mR.findModule('sendChatStateComposing')[0];
|
|
42
|
+
window.Store.findCommonGroups = window.mR.findModule('findCommonGroups')[0].findCommonGroups;
|
|
43
|
+
window.Store.StatusUtils = window.mR.findModule('setMyStatus')[0];
|
|
44
|
+
window.Store.ConversationMsgs = window.mR.findModule('loadEarlierMsgs')[0];
|
|
45
|
+
window.Store.sendReactionToMsg = window.mR.findModule('sendReactionToMsg')[0].sendReactionToMsg;
|
|
46
|
+
window.Store.createOrUpdateReactionsModule = window.mR.findModule('createOrUpdateReactions')[0];
|
|
47
|
+
window.Store.EphemeralFields = window.mR.findModule('getEphemeralFields')[0];
|
|
48
|
+
window.Store.MsgActionChecks = window.mR.findModule('canSenderRevokeMsg')[0];
|
|
49
|
+
window.Store.QuotedMsg = window.mR.findModule('getQuotedMsgObj')[0];
|
|
50
|
+
window.Store.LinkPreview = window.mR.findModule('getLinkPreview')[0];
|
|
51
|
+
window.Store.Socket = window.mR.findModule('deprecatedSendIq')[0];
|
|
52
|
+
window.Store.SocketWap = window.mR.findModule('wap')[0];
|
|
53
|
+
window.Store.SearchContext = window.mR.findModule('getSearchContext')[0].getSearchContext;
|
|
54
|
+
window.Store.DrawerManager = window.mR.findModule('DrawerManager')[0].DrawerManager;
|
|
55
|
+
window.Store.LidUtils = window.mR.findModule('getCurrentLid')[0];
|
|
56
|
+
window.Store.WidToJid = window.mR.findModule('widToUserJid')[0];
|
|
57
|
+
window.Store.JidToWid = window.mR.findModule('userJidToUserWid')[0];
|
|
58
|
+
window.Store.getMsgInfo = (window.mR.findModule('sendQueryMsgInfo')[0] || {}).sendQueryMsgInfo || window.mR.findModule('queryMsgInfo')[0].queryMsgInfo;
|
|
59
|
+
window.Store.pinUnpinMsg = window.mR.findModule('sendPinInChatMsg')[0].sendPinInChatMsg;
|
|
60
|
+
|
|
61
|
+
/* eslint-disable no-undef, no-cond-assign */
|
|
62
|
+
window.Store.QueryExist = ((m = window.mR.findModule('queryExists')[0]) ? m.queryExists : window.mR.findModule('queryExist')[0].queryWidExists);
|
|
63
|
+
window.Store.ReplyUtils = (m = window.mR.findModule('canReplyMsg')).length > 0 && m[0];
|
|
64
|
+
/* eslint-enable no-undef, no-cond-assign */
|
|
65
|
+
|
|
66
|
+
window.Store.Settings = {
|
|
67
|
+
...window.mR.findModule('ChatlistPanelState')[0],
|
|
68
|
+
setPushname: window.mR.findModule((m) => m.setPushname && !m.ChatlistPanelState)[0].setPushname
|
|
69
|
+
};
|
|
70
|
+
window.Store.StickerTools = {
|
|
71
|
+
...window.mR.findModule('toWebpSticker')[0],
|
|
72
|
+
...window.mR.findModule('addWebpMetadata')[0]
|
|
73
|
+
};
|
|
74
|
+
window.Store.GroupUtils = {
|
|
75
|
+
...window.mR.findModule('createGroup')[0],
|
|
76
|
+
...window.mR.findModule('setGroupDescription')[0],
|
|
77
|
+
...window.mR.findModule('sendExitGroup')[0],
|
|
78
|
+
...window.mR.findModule('sendSetPicture')[0]
|
|
79
|
+
};
|
|
80
|
+
window.Store.GroupParticipants = {
|
|
81
|
+
...window.mR.findModule('promoteParticipants')[0],
|
|
82
|
+
...window.mR.findModule('sendAddParticipantsRPC')[0]
|
|
83
|
+
};
|
|
84
|
+
window.Store.GroupInvite = {
|
|
85
|
+
...window.mR.findModule('resetGroupInviteCode')[0],
|
|
86
|
+
...window.mR.findModule('queryGroupInvite')[0]
|
|
87
|
+
};
|
|
88
|
+
window.Store.GroupInviteV4 = {
|
|
89
|
+
...window.mR.findModule('queryGroupInviteV4')[0],
|
|
90
|
+
...window.mR.findModule('sendGroupInviteMessage')[0]
|
|
91
|
+
};
|
|
92
|
+
window.Store.MembershipRequestUtils = {
|
|
93
|
+
...window.mR.findModule('getMembershipApprovalRequests')[0],
|
|
94
|
+
...window.mR.findModule('sendMembershipRequestsActionRPC')[0]
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
if (!window.Store.Chat._find) {
|
|
98
|
+
window.Store.Chat._find = e => {
|
|
99
|
+
const target = window.Store.Chat.get(e);
|
|
100
|
+
return target ? Promise.resolve(target) : Promise.resolve({
|
|
101
|
+
id: e
|
|
102
|
+
});
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// eslint-disable-next-line no-undef
|
|
107
|
+
if ((m = window.mR.findModule('ChatCollection')[0]) && m.ChatCollection && typeof m.ChatCollection.findImpl === 'undefined' && typeof m.ChatCollection._find !== 'undefined') m.ChatCollection.findImpl = m.ChatCollection._find;
|
|
108
|
+
|
|
109
|
+
const _isMDBackend = window.mR.findModule('isMDBackend');
|
|
110
|
+
if(_isMDBackend && _isMDBackend[0] && _isMDBackend[0].isMDBackend) {
|
|
111
|
+
window.Store.MDBackend = _isMDBackend[0].isMDBackend();
|
|
112
|
+
} else {
|
|
113
|
+
window.Store.MDBackend = true;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const _features = window.mR.findModule('FEATURE_CHANGE_EVENT')[0];
|
|
117
|
+
if(_features) {
|
|
118
|
+
window.Store.Features = _features.LegacyPhoneFeatures;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Target options object description
|
|
123
|
+
* @typedef {Object} TargetOptions
|
|
124
|
+
* @property {string|number} module The name or a key of the target module to search
|
|
125
|
+
* @property {number} index The index value of the target module
|
|
126
|
+
* @property {string} function The function name to get from a module
|
|
127
|
+
*/
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Function to modify functions
|
|
131
|
+
* @param {TargetOptions} target Options specifying the target function to search for modifying
|
|
132
|
+
* @param {Function} callback Modified function
|
|
133
|
+
*/
|
|
134
|
+
window.injectToFunction = (target, callback) => {
|
|
135
|
+
const module = typeof target.module === 'string'
|
|
136
|
+
? window.mR.findModule(target.module)
|
|
137
|
+
: window.mR.modules[target.module];
|
|
138
|
+
const originalFunction = module[target.index][target.function];
|
|
139
|
+
const modifiedFunction = (...args) => callback(originalFunction, ...args);
|
|
140
|
+
module[target.index][target.function] = modifiedFunction;
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
window.injectToFunction({ module: 'mediaTypeFromProtobuf', index: 0, function: 'mediaTypeFromProtobuf' }, (func, ...args) => { const [proto] = args; return proto.locationMessage ? null : func(...args); });
|
|
144
|
+
|
|
145
|
+
window.injectToFunction({ module: 'typeAttributeFromProtobuf', index: 0, function: 'typeAttributeFromProtobuf' }, (func, ...args) => { const [proto] = args; return proto.locationMessage || proto.groupInviteMessage ? 'text' : func(...args); });
|
|
146
146
|
};
|