Hi,
Not sure if I'm alone here, but I use WhatsApp web on chrome like all day, and one thing that really bothers me is accidentally sending a message to the wrong group. We've all seen the consequences online, for some it's just a funny mistake, for others it's disastrous.
So I wrote a tiny little script that you can inject into chrome that prompts a confirmation before you send a message to any group. You'll need to install
a chrome extension that can inject javascript into the web page, and enable jQuery 2.xxx.
Here's the script, hope someone else finds it useful. Improvements & suggestions, are welcome. It's very brittle since I rely on class names to find out what's going on in the page, but at least for now it works.
Note: Once you "Save" the script in the extension, reload the page, noticed that jQuery fails to load 1st time round, after that it's ok.
//----------------Script start
jQuery.noConflict();
jQuery(document).keydown(function(e) {
var groupIconCount = jQuery('.pane-chat .icon-group-default').length;
if(groupIconCount > 0 ){
var groupName = jQuery('.pane-chat .chat-title .emojitext:first').text();
if(e.which == 13) {
if(confirm('Are you sure you want to send that message to ' + groupName + '?')==false){
e.preventDefault();
e.stopPropagation();
jQuery('.input-placeholder .input').text('');
return false;
}
}
}
else{
console.log('Not in group, confirm aborted!');
}
});
jQuery(document).click(function(){
var groupName = jQuery('.pane-chat .chat-title .emojitext:first').text();
jQuery('.input-emoji .input-placeholder').html('Type a message to <b style="color:' + getRandomColor() + '">' + groupName.toUpperCase() + '</b>.');
})
function getRandomColor() {
var letters = '0123456789ABCDEF';
var color = '#';
for (var i = 0; i < 6; i++ ) {
color += letters[Math.floor(Math.random() * 16)];
}
return color;
}
//--------------------Script End