Skip to content

Instantly share code, notes, and snippets.

@BatuhanK
Created October 7, 2015 15:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BatuhanK/4aa13271d7737cdff6cd to your computer and use it in GitHub Desktop.
Save BatuhanK/4aa13271d7737cdff6cd to your computer and use it in GitHub Desktop.
whatsapp-web-dev-console-sendMessage
function sendMessage(msg){
var msgInput = document.querySelector("#main > footer > div > div.input-container > div > div.input");
var sendButton = document.querySelector(".icon.btn-icon.icon-send");
var typeEvent = document.createEvent("TextEvent");
typeEvent.initTextEvent ("textInput", true, true, window, msg, 0, "en-US");
msgInput.focus();
msgInput.dispatchEvent(typeEvent);
do {
var sendButton = document.querySelector(".icon.btn-icon.icon-send");
} while(!sendButton)
var clickEvent = new MouseEvent('click', {
'view': window,
'bubbles': true,
'cancelable': true
});
sendButton.dispatchEvent(clickEvent);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment