Last active
October 1, 2019 03:11
-
-
Save qgustavor/25b1896467e2d6a3d85e to your computer and use it in GitHub Desktop.
Batch Messages on WhatsApp Web
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name Batch Messages on WhatsApp Web | |
| // @namespace [email protected] | |
| // @include https://web.whatsapp.com/ | |
| // @version 1 | |
| // @grant unsafeWindow | |
| // ==/UserScript== | |
| // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // | |
| // Disclaimer: WhatsApp is banning people who use this // | |
| // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // | |
| checkButton(); | |
| function checkButton(){ | |
| var menuButton = document.querySelector('button.icon-menu[data-reactid*="$conversation-header"]'); | |
| if (menuButton) { | |
| menuButton.onclick = addAction; | |
| } else { | |
| setTimeout(checkButton, 1000); | |
| } | |
| } | |
| function addAction (){ | |
| var headerMenuList = document.querySelector('ul[data-reactid*="$conversation-header"]'); | |
| if (!headerMenuList) { return setTimeout(addAction, 150); } | |
| var newListElement = document.createElement('li'); | |
| newListElement.className = 'menu-item menu-shortcut'; | |
| newListElement.style.opacity = 1; | |
| var newListAnchor = document.createElement('a'); | |
| newListAnchor.onclick = createSendScript; | |
| newListAnchor.textContent = 'Send last message to all contacts'; | |
| newListElement.appendChild(newListAnchor); | |
| headerMenuList.appendChild(newListElement); | |
| (function check(){ | |
| if (newListElement.parentNode) { | |
| setTimeout(check, 1000); | |
| } else { | |
| checkButton(); | |
| } | |
| }()); | |
| } | |
| function createSendScript() { | |
| unsafeWindow.eval('('+sendMessages+'());'); | |
| } | |
| function sendMessages() { | |
| var b = Store.Chat.models.filter(function(a) { | |
| return a.active; | |
| })[0].msgs.last().attributes.body; | |
| if(confirm('You\'re sure that you want to send this message\n"' + b + '"\nto everyone?')) { | |
| Store.Chat.models.filter(function(a) { | |
| return !a.active; | |
| }).forEach(function(a) { | |
| a.sendMessage(b); | |
| }); | |
| } | |
| } |
Author
"Broadcast List" don't deliver messages if the sender contact is not in the recipient contact list.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
"What, WhatsApp supports it natively? It's named Broadcast Lists? Whoa..."