forked from orkestral/venom
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
65 changed files
with
1,443 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/** | ||
* Pauses the execution for a specified amount of time. | ||
* @param time The duration to sleep in milliseconds. | ||
*/ | ||
export function sleep(time: number) { | ||
try { | ||
// Create a promise that resolves after the specified time | ||
return new Promise((resolve) => setTimeout(resolve, time)); | ||
} catch {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { Page, Browser } from 'puppeteer'; | ||
import * as path from 'path'; | ||
//import { SenderLayer } from '../api/layes/sender.layes'; | ||
//import { CreateOptions, defaultConfig } from '../model/interface'; | ||
|
||
// export class webPack extends SenderLayer { | ||
// constructor( | ||
// public page: Page, | ||
// public browser: Browser, | ||
// public options: CreateOptions, | ||
// public ev: any | ||
// ) { | ||
// super(page, browser, options, ev); | ||
// this.initService(); | ||
|
||
// this.page.on('load', async () => { | ||
// await this.initService(); | ||
// }); | ||
// } | ||
|
||
// async initService() { | ||
// try { | ||
// await this.page | ||
// .waitForFunction('webpackChunkwhatsapp_web_client.length') | ||
// .catch(); | ||
// await this.page | ||
// .addScriptTag({ | ||
// path: require.resolve(path.join(__dirname, '../assets/', 'api.js')) | ||
// }) | ||
// .catch(); | ||
// this.initLitener(); | ||
// } catch {} | ||
// } | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { onMode } from '../model/enum'; | ||
import { sleep } from '../helpers'; | ||
|
||
/** | ||
* attribution and behavior change of a given event | ||
*/ | ||
export class CallbackOnStatus { | ||
public statusFind: any; | ||
constructor() { | ||
this.statusFind = ''; | ||
} | ||
|
||
/** | ||
* waiting for event change | ||
* @param event returns event status | ||
*/ | ||
async onChange(event: (status: any) => void) { | ||
let change = null; | ||
while (true) { | ||
if (this.statusFind !== change) { | ||
change = this.statusFind; | ||
event && event(change); | ||
} | ||
await sleep(50); | ||
} | ||
} | ||
|
||
/** | ||
* here you can monitor user events | ||
* @param type types of monitoring | ||
* @param callback returns of monitoring | ||
*/ | ||
public async on(type: onMode, callback: (state: any) => void) { | ||
switch (type) { | ||
case onMode.interfaceChange: | ||
this.onChange((event) => { | ||
if (event.onType === onMode.interfaceChange) { | ||
callback(event); | ||
} | ||
}); | ||
break; | ||
case onMode.newOnAck: | ||
this.onChange((event) => { | ||
if (event.onType === onMode.newOnAck) { | ||
callback(event); | ||
} | ||
}); | ||
break; | ||
case onMode.newMessage: | ||
this.onChange((event) => { | ||
if (event.onType === onMode.newMessage) { | ||
callback(event); | ||
} | ||
}); | ||
break; | ||
case onMode.qrcode: | ||
this.onChange((event) => { | ||
if (event.onType === onMode.qrcode) { | ||
callback(event); | ||
} | ||
}); | ||
break; | ||
case onMode.connection: | ||
this.onChange((event) => { | ||
if (event.onType === onMode.connection) { | ||
callback(event); | ||
} | ||
}); | ||
break; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { CallbackOnStatus } from './callback-on.layes'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
export enum onMode { | ||
/** | ||
* Indicates a change in the user interface. | ||
* @description Used to receive information about the current interface the user is on. | ||
*/ | ||
interfaceChange = 'interfaceChange', | ||
|
||
/** | ||
* Monitors new messages. | ||
* @description Used to receive notifications when a new message is received. | ||
*/ | ||
newMessage = 'newMessage', | ||
|
||
/** | ||
* Receives QR code updates. | ||
* @description Used to receive updated information about the QR code. | ||
*/ | ||
qrcode = 'qrcode', | ||
|
||
/** | ||
* User connection information. | ||
* @description Used to obtain information about the user's connection. | ||
*/ | ||
connection = 'connection', | ||
|
||
/** | ||
* Monitors the status of a message. | ||
* @description Used to receive notifications about the delivery status of a message. | ||
*/ | ||
newOnAck = 'newOnAck' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
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, | ||
setGroupDescription, | ||
getHost, | ||
setGroupImage | ||
} from './functions'; | ||
|
||
import { | ||
serializeMessageObj, | ||
serializeChatObj, | ||
serializeContactObj, | ||
serializeProfilePicThumb, | ||
serializeRawObj, | ||
serializeMeObj | ||
} from './serialize'; | ||
|
||
//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.WAPI === 'undefined') { | ||
window.WAPI = {}; | ||
|
||
// Helps | ||
window.WAPI.getChat = getChat; | ||
window.WAPI.scope = scope; | ||
window.WAPI.getNewId = getNewId; | ||
window.WAPI.getNewMessageId = getNewMessageId; | ||
window.WAPI.sendExist = sendExist; | ||
window.WAPI.checkNumberStatus = checkNumberStatus; | ||
window.WAPI.isMD = isMD; | ||
window.WAPI.baseSendMessage = baseSendMessage; | ||
window.WAPI.processFiles = processFiles; | ||
window.WAPI.base64ToFile = base64ToFile; | ||
window.WAPI.generateMediaKey = generateMediaKey; | ||
window.WAPI.arrayBufferToBase64 = arrayBufferToBase64; | ||
window.WAPI.encryptAndUploadFile = encryptAndUploadFile; | ||
window.WAPI.getFileHash = getFileHash; | ||
window.WAPI.sendCheckType = sendCheckType; | ||
window.WAPI.addChatWapi = addChatWapi; | ||
|
||
// Functions | ||
|
||
// Send | ||
window.WAPI.sendMessage = sendMessage; | ||
|
||
// Host | ||
window.WAPI.getAllContacts = getAllContacts; | ||
window.WAPI.getHost = getHost; | ||
|
||
// Group | ||
window.WAPI.createGroup = createGroup; | ||
window.WAPI.addParticipant = addParticipant; | ||
window.WAPI.setGroupDescription = setGroupDescription; | ||
window.WAPI.setGroupImage = setGroupImage; | ||
|
||
// Serialize | ||
window.WAPI.serializeMessageObj = serializeMessageObj; | ||
window.WAPI.serializeChatObj = serializeChatObj; | ||
window.WAPI.serializeContactObj = serializeContactObj; | ||
window.WAPI.serializeProfilePicThumb = serializeProfilePicThumb; | ||
window.WAPI.serializeRawObj = serializeRawObj; | ||
window.WAPI.serializeMeObj = serializeMeObj; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
import { getAllChatsWithNewMessages } from './get-chats-with-new-messages'; | ||
|
||
export const getAllNewMessages = function () { | ||
export const getAllNewMessages = async function () { | ||
const serializeMessageObj = await WAPI._serializeMessageObj; | ||
const _newMessages = | ||
getAllChatsWithNewMessages() | ||
.map((c) => WAPI.getChat(c.id)) | ||
.flatMap((c) => c.msgs._models.filter((x) => x.isNewMsg)) | ||
.map(WAPI._serializeMessageObj) || []; | ||
.map(serializeMessageObj) || []; | ||
|
||
return _newMessages; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.