-
-
Save yask123/d085d4b7a486d00dd103 to your computer and use it in GitHub Desktop.
document.getElementsByClassName("input")[1].innerHTML="This message was written via JS script! "; // Fills the text box message | |
var input = document.getElementsByClassName("icon btn-icon icon-send");//Grabs the send button | |
input[0].click();// Clicks the send button |
update::
`function whatsAppText(t) {
window.InputEvent = window.Event || window.InputEvent;
var d = new Date();
var event = new InputEvent('input', {bubbles: true});
var textbox= document.querySelector('#main > footer > div._3oju3 > div._2bXVy > div > div._2S1VP.copyable-text.selectable-text');
textbox.textContent = t;
textbox.dispatchEvent(event);
document.querySelector("#main > footer > div._3oju3 > button > span").click();
}`
nothing is happening. it show only undefined
!!!Update!!!
var y = 1;
while( y < 100) {
window.InputEvent = window.Event || window.InputEvent;
var d = new Date();
var event = new InputEvent('input', {bubbles: true});
var textbox= document.querySelector('#main > footer > div._3oju3 > div._2bXVy > div > div._2S1VP.copyable-text.selectable-text');
textbox.textContent = "Test";
textbox.dispatchEvent(event);
document.querySelector("#main > footer > div._3oju3 > button > span").click();
console.log("Send " + i);
y = y + 1;
}
@felipsilva2 A small logical error: console.log("Send " + i);
should be console.log("Send " + y);
but after changing this, it works! Thanks for sharing your snippet 👍
Hi! How might I integrate this code with WhatsApp API feature?
A maneira mais simples de enviar um texto via javascript para WhatsApp WEB é:
Store.Chat.models.find((x) => x.id == "[email protected]").sendMessage("Sua mensagem aqui");
@wallysonn so much thanks. Works like a charm. I have used:
Store.Chat.models.find((x) => x.__x_formattedTitle === 'Contact or group name').sendMessage('A message here')
How to use this to send message to a new chat/contact no.
example: Store.Chat.models.find((x) => x.id == "[email protected]").sendMessage("testing");
please help. Thanks.
@webglisten @ClementWalter @wallysonn @yask123
Whatsapp web has updated and now the Store is no longer available
Is anyone still able to use the Store?
"Store.Chat.models"
Console Firefox
Store
ReferenceError: Store is not defined[Learn More]
@dennyphilipp not anymore, is there anyone able to reach the Store data somehow?
@felipsilva2 it is not working multiple times, it works only for 1 time and then stop, any idea why?
@tinyCoder32
Just run
if (window.Store === undefined) {
webpackJsonp([], {"bcihgfbdeb": (x, y, z) => window.Store = z('"bcihgfbdeb"')}, "bcihgfbdeb");
webpackJsonp([], {"iaeeehaci": (x, y, z) => window.Store.Wap = z('"iaeeehaci"')}, "iaeeehaci");
}
console.log(window.Store);
thanks @dennyphilipp!
But it didn't work from my content script, only from console of browser, it says Error: Permission denied to access property "length"
, any idea why?
how to send media ?
.sendMessage('') .sendMedia : )
how can we send image?
because i convert image to data-url but that is not working.
@dennyphilipp please consider my question, thanks.
For unknow contacts (contacts that I never chatted before). Any advices? This code doesn't work. @dennyphilipp @webglisten
@felipsilva2 - Update!!!
window.InputEvent = window.Event || window.InputEvent;
var d = new Date();
var event = new InputEvent('input', {bubbles: true});
var textbox= document.querySelector('#main > footer > div._3pkkz > div._1Plpp > div > div._2S1VP.copyable-text.selectable-text');
textbox.textContent = "Test";
textbox.dispatchEvent(event);
document.querySelector("#main > footer > div._3pkkz > div > button > span").click();
@tinyCoder32, @leonanluppi
Sorry for the delay, whats updated how to get the information, follow the correction of the previous script.
Store.Wap I did not find in their JS anymore.
This works via browser console, to use embedded next to some other application is necessary to inject the script together in the whats script, using something to remove the permissions, remembering that your JS needs to be hosted in some domain with https
if (window.Store === undefined) {
webpackJsonp([], {"bcihgfbdeb": (x, y, z) => window.Store = z('"bcihgfbdeb"')}, "bcihgfbdeb");
webpackJsonp([], {"jfefjijii": (x, y, z) => window.Store.Conn = z('"jfefjijii"')}, "jfefjijii");
//webpackJsonp([], {"iaeeehaci": (x, y, z) => window.Store.Wap = z('"iaeeehaci"')}, "iaeeehaci");
}
The latest solution of @dennyphilipp works perfectly.
I was making an extension which emulates user actions, but this method is way easy.
I wonder if this method is stable though, especially if this changes a lot.
To send multiple just put the for loop
for(var i=0;i<10;i++){ window.InputEvent = window.Event || window.InputEvent;
var d = new Date();
var event = new InputEvent('input', {bubbles: true});
var textbox= document.querySelector('#main > footer > div._3pkkz > div._1Plpp > div > div._2S1VP.copyable-text.selectable-text');
textbox.textContent = "Test";
textbox.dispatchEvent(event);
document.querySelector("#main > footer > div._3pkkz > div > button > span").click();}
worked for me but you have open web.whatsapp for the same.
@shyamzzp Thank you~ Its worked for me
for(var i=0;i<10;i++){ window.InputEvent = window.Event || window.InputEvent;
var d = new Date();
var event = new InputEvent('input', {bubbles: true});
var textbox= document.querySelector('#main > footer > div._3pkkz > div._1Plpp > div > div._2S1VP.copyable-text.selectable-text');textbox.textContent = "Test";
textbox.dispatchEvent(event);
document.querySelector("#main > footer > div._3pkkz > div > button > span").click();
}
how to select particular group?
UPDATE:
function whatsAppText(t) { window.InputEvent = window.Event || window.InputEvent; var d = new Date(); var event = new InputEvent('input', {bubbles: true}); var textbox = $('div._2S1VP'); textbox.textContent = t; textbox.dispatchEvent(event); $("button._35EW6").click(); }
UPDATE + SPAM SEND EVERY X SECONDS + MORE LEGIBLE CODE (credits to rafaelxavierborges for the skeleton of the code)
Tested on Google Chrome = does not work
Tested on Firefox = works
var t=0; //This is the counter, where the counting starts
var messageToSendEveryXTime; //the is the variable that holds the message to send
messageToSendEveryXTime = t; //in my case I want to spam counting numbers starting at zero
//if you want to send something else change here
//for example you migh want to send "I love you every second" every second
setInterval(function(){
window.InputEvent = window.Event || window.InputEvent;
var d = new Date();
var event = new InputEvent('input', {bubbles: true});
var textbox = $('div._2S1VP');
textbox.textContent = messageToSendEveryXTime; //inserts the message in the textbox
textbox.dispatchEvent(event); $("button._35EW6").click(); //sends the message
t++; //increments the counter
}, 1000); //interval to send messages, 1000= 1 second
//choose the delay in seconds times 1000, example, 5 seconds is 5000
If you are looking for a whatsapp spammer bot, I have updated it with instructions and working 29 september 2018
https://gist.github.com/igormuba/f37b8630cadbb511c53e7765de34bc6c
/**
* 1) Open a contact or group on Whatsapp Web;
* 2) Copy the Javascript code below;
* 3) Open the developer tools: CTRL + SHIFT + I;
* 4) Go to the "Console" tab and paste the code;
* 5) The function was added on the page;
* 6) Now, still on the console, type: spam ();
* 7) A pop-up will be displayed requesting the spam message and
* how many messages you want to send per second (I recommend placing 2 to 5).
*/
function spam() {
let prompt1 = prompt("Enter the spam message", "");
const prompt2 = prompt("Send how many messages per second?", 1);
const input = document.getElementsByClassName("_3FRCZ")[1];
window.InputEvent = window.Event || window.InputEvent;
let count = 0;
if (prompt1 === "") {
prompt1 = "​";
}
console.log("Spam started ...");
window.setInterval(function() {
count++;
input.innerHTML = prompt1;
input.dispatchEvent(new InputEvent("input", {
bubbles: true
}));
let enviar = document.getElementsByClassName("_1U1xa")[0];
enviar.click();
console.log('Messasages sent: ' + count);
}, 1000 / prompt2);
}
/** * 1) Open a contact or group on Whatsapp Web; * 2) Copy the Javascript code below; * 3) Open the developer tools: CTRL + SHIFT + I; * 4) Go to the "Console" tab and paste the code; * 5) The function was added on the page; * 6) Now, still on the console, type: spam (); * 7) A pop-up will be displayed requesting the spam message and * how many messages you want to send per second (I recommend placing 2 to 5). */ function spam() { let prompt1 = prompt("Enter the spam message", ""); const prompt2 = prompt("Send how many messages per second?", 1); const input = document.getElementsByClassName("_3FRCZ")[1]; window.InputEvent = window.Event || window.InputEvent; let count = 0; if (prompt1 === "") { prompt1 = "​"; } console.log("Spam started ..."); window.setInterval(function() { count++; input.innerHTML = prompt1; input.dispatchEvent(new InputEvent("input", { bubbles: true })); let enviar = document.getElementsByClassName("_1U1xa")[0]; enviar.click(); console.log('Messasages sent: ' + count); }, 1000 / prompt2); }
It shows
Uncaught TypeError: Cannot set property 'innerHTML' of undefined
at :19:25
How to send with media ?
and how to create a new chat?