Skip to content

Instantly share code, notes, and snippets.

@arthursvpb
Created November 24, 2022 16:15
Show Gist options
  • Save arthursvpb/a2198d9b2d8b4cab355489656a3fcd2f to your computer and use it in GitHub Desktop.
Save arthursvpb/a2198d9b2d8b4cab355489656a3fcd2f to your computer and use it in GitHub Desktop.
Automatization for Whatsapp Web to try joining a full group until someone leaves it.
/**
* Follow the steps bellow and paste this script inside your dev tools
*/
// 1. Click on the invite link, example: https://chat.whatsapp.com/1234
// 2. Click on "Join chat" without whatsapp installed on your machine
// 3. Copy link address of "use whatsapp web" link
// 4. On your whatsapp web, send a message for yourself containing this link
// 4.1. The link should be something like https://web.whatsapp.com/accept?code=<invite-link>
function enterGroup() {
// Replace here with the link retrieved by step 4.1
let link = document.querySelector(/*'[title="https://web.whatsapp.com/accept?code=<invite-link>"]'*/);
link.removeAttribute('target');
link.click()
setTimeout(() => {
searchByText("Join group").click()
}, 1000)
setTimeout(() => {
searchByText("OK").click()
}, 3000)
}
function searchByText(searchText){
let elements = document.querySelectorAll('[data-testid="content"]');
let element;
for (let i = 0; i < elements.length; i++) {
if (elements[i].textContent == searchText) {
element = elements[i];
break;
}
}
return element;
}
setInterval(enterGroup, 4000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment