Skip to content

Instantly share code, notes, and snippets.

@stampyzfanz
Created October 6, 2021 00:31
Show Gist options
  • Save stampyzfanz/29f0aea420299514d7817c158b454aaa to your computer and use it in GitHub Desktop.
Save stampyzfanz/29f0aea420299514d7817c158b454aaa to your computer and use it in GitHub Desktop.
Automated Whatsapp Web messager. Can also detect when a person is typing and cut them off.
function sendMsg(msg) {
let txt = document.querySelectorAll('._13NKt')[1]
txt.innerText = msg
let startTypingEv = new InputEvent('input', {
bubbles: true
});
txt.dispatchEvent(startTypingEv)
let enterEv = new KeyboardEvent('keydown', {altKey:false,
bubbles: true,
cancelBubble: false,
cancelable: true,
charCode: 0,
code: "Enter",
composed: true,
ctrlKey: false,
currentTarget: null,
defaultPrevented: true,
detail: 0,
eventPhase: 0,
isComposing: false,
isTrusted: true,
key: "Enter",
keyCode: 13,
location: 0,
metaKey: false,
repeat: false,
returnValue: false,
shiftKey: false,
type: "keydown",
which: 13});
txt.dispatchEvent(enterEv)
}
function timeout(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
while (true) {
if (typer = document.querySelectorAll('.2YPr')[0].innerText.match(/(.*)is typing/)) {
sendMsg(`A wild ${typer[1]} is typing`);
await timeout(7000)
}
await timeout(250)
}
@skyme5
Copy link

skyme5 commented Nov 10, 2021

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment