vendredi 23 janvier 2015

I am trying to send text- messages on WhatsApp with javascript?

I am trying to send text messages on whatsapp web version on chrome. (www.web.whatsapp.com)


This is the code:





document.getElementsByClassName("input")[1].innerHTML="This message was written via JS script! ";

var input = document.getElementsByClassName("icon btn-icon icon-send");
input[0].click();



But the problem is , initially when no text is present the input box looks like this: enter image description here


And only when I physically write some text it changes to this:


enter image description here


And only now my script works since it requires the Send text button.


I tried Jquery code to simulate keypresses at $('.input)by following function:





function pressKey() {
var e = jQuery.Event("keypress");
e.which = 32; // # space
$(".input").trigger(e)[1];
e.which = 91;
$(".input").trigger(e)[1];
e.which = 32; // # space
$(".input").trigger(e)[1];
e.which = 32; // # space
$(".input").trigger(e)[1];

}



It didn't work.


How can I get the Send text button by script?


Here is the screen recording :


Aucun commentaire:

Enregistrer un commentaire