I've no experience with chrome extensions, if it's easy to do then you can give it a try. The script is fairly basic and the only required lib is jQuery.

Regards,
John K.

On 18 November 2016 at 10:54, You Yuxi <josephkoech.dev@gmail.com> wrote:
Hi John,
Why can't you make it a chrome/firefox/edge extension? It's will be much easier for devs & non-devs. I can help with this.

Kind regards,
Joseph.

On Thu, Nov 17, 2016 at 4:52 PM, Peter Karunyu via skunkworks <skunkworks@lists.my.co.ke> wrote:
This is pretty nice dude! 

On Thu, Nov 17, 2016 at 1:16 PM, John K. via skunkworks <skunkworks@lists.my.co.ke> wrote:
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

Regards,
John K.

_______________________________________________
skunkworks mailing list
skunkworks@lists.my.co.ke
------------
List info, subscribe/unsubscribe
http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks
------------

Skunkworks Rules
http://my.co.ke/phpbb/viewtopic.php?f=24&t=94
------------
Other services @ http://my.co.ke


_______________________________________________
skunkworks mailing list
skunkworks@lists.my.co.ke
------------
List info, subscribe/unsubscribe
http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks
------------

Skunkworks Rules
http://my.co.ke/phpbb/viewtopic.php?f=24&t=94
------------
Other services @ http://my.co.ke