Created
October 7, 2015 15:50
-
-
Save BatuhanK/4aa13271d7737cdff6cd to your computer and use it in GitHub Desktop.
whatsapp-web-dev-console-sendMessage
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
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