Skip to content

Instantly share code, notes, and snippets.

@Aditya-Basak
Forked from yask123/send-whatsapp-msg.js
Created July 22, 2016 16:15
Show Gist options
  • Save Aditya-Basak/d985c7b06f2bb1abd5e2c08fa868b62c to your computer and use it in GitHub Desktop.
Save Aditya-Basak/d985c7b06f2bb1abd5e2c08fa868b62c to your computer and use it in GitHub Desktop.
function dispatch(target, eventType, char) {
var evt = document.createEvent("TextEvent");
evt.initTextEvent (eventType, true, true, window, char, 0, "en-US");
target.focus();
target.dispatchEvent(evt);
}
dispatch(document.querySelector("#compose-input div"), "textInput", "hello!");
function triggerClick() {
var event = new MouseEvent('click', {
'view': window,
'bubbles': true,
'cancelable': true
});
document.querySelector(".icon.btn-icon.icon-send").dispatchEvent(event)
}
triggerClick()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment