Skip to content

Instantly share code, notes, and snippets.

@techguybiswa
Created March 11, 2019 18:36
Show Gist options
  • Star 14 You must be signed in to star a gist
  • Fork 8 You must be signed in to fork a gist
  • Save techguybiswa/267587c6ce727710fda3720739ae8bfe to your computer and use it in GitHub Desktop.
Save techguybiswa/267587c6ce727710fda3720739ae8bfe to your computer and use it in GitHub Desktop.
What's App Automated "New Year Wish" Script
let listOfRecentContacts = document.getElementsByClassName("_3j7s9");
console.log("listOfRecentContacts.length = " + listOfRecentContacts.length);
var eventToSwitchMessageBox = new MouseEvent('mousedown', {
bubbles: true,
});
let count =1;
let openMessageBox = setInterval(function(){
// if(count>listOfRecentContacts.length) {
if(count>5) {
console.log("Clearing interval with clearInterval...");
clearInterval(openMessageBox);
}
listOfRecentContacts[count].dispatchEvent(eventToSwitchMessageBox);
console.log("Opening message box of " + listOfRecentContacts[count].getElementsByClassName("_1wjpf")[0].title + " -> " + count);
// let textToSend = "Hello " + listOfRecentContacts[count-1].getElementsByClassName("_1wjpf")[0].title + ". I hope you are doing great. This is an autogenerated message from Bisso. Please Ignore. Do not reply.";
let textToSend = "Hello. Wish you a very happy new year from Bisso. PS: Ignore this message I am testing out a program.";
let textbox = document.querySelector('div._2S1VP');
let sendMessageEvent = new InputEvent('input', {
bubbles: true
});
textbox.textContent =textToSend;
textbox.dispatchEvent(sendMessageEvent);
document.querySelector("button._35EW6").click();
count++;
}, 3000);
@techguybiswa
Copy link
Author

Simply copy paste the above code in the console of https://web.whatsapp.com/

@AbdullahiAbdulkabir
Copy link

Nice

@dogancankilment
Copy link

Thanks 👍

@gittu4
Copy link

gittu4 commented Mar 14, 2019

I could not understand what do you mean by console? I don't see an option in web.whatsapp to paste the script.

@sadiqhirani
Copy link

@gittu4 get some hands on

how to debug javascript?

google pls

@davidnickmann
Copy link

Nice

@utkarsh1996
Copy link

I could not understand what do you mean by console? I don't see an option in web.whatsapp to paste the script.

Just press F12 after opening web whatsapp..
Developer tool will be open
there is an option of Console
just paste the code over their and run it

@techguybiswa
Copy link
Author

techguybiswa commented Mar 17, 2019

I could not understand what do you mean by console? I don't see an option in web.whatsapp to paste the script.

Hi @gittu4 .
So open web.whatsapp.com.
Then press cmd + option + J if you are in mac or ctrl + shift + I if you are in windows/linux.
Then the developer tools will open.
Then from developer tools go to the "Console" Tab.
Let me know if you need more help.

@techguybiswa
Copy link
Author

I could not understand what do you mean by console? I don't see an option in web.whatsapp to paste the script.

Just press F12 after opening web whatsapp..
Developer tool will be open
there is an option of Console
just paste the code over their and run it

Thanks @utkarsh1996 for helping him out :)

@letsgrowider
Copy link

Hey Bisso, I've tried the code but the message was sent only to 21 people while my contact list has about 600 people. What do you think the issue here could be?

@techguybiswa
Copy link
Author

Hey Bisso, I've tried the code but the message was sent only to 21 people while my contact list has about 600 people. What do you think the issue here could be?

Yeah so the script uses DOM manipulation.
That means for now it cannot message all 600 people but can message only the most recently contacted ones.
You can modify the script to add a scroll function that would keep on adding more and more contacts one by one to the DOM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment