Skip to content

Instantly share code, notes, and snippets.

@techguybiswa
Created March 11, 2019 18:36
Show Gist options
  • 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

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