-
Notifications
You must be signed in to change notification settings - Fork 0
/
whatsapp-prompter.js
46 lines (38 loc) · 1.3 KB
/
whatsapp-prompter.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//----------------Script start
jQuery.noConflict();
var m_warn_on_change = false;
var m_last_item = '';
jQuery(document).keydown(function(e) {
if(m_warn_on_change==false){
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;
}
m_warn_on_change = true;
}
}
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>.');
console.log(groupName);
if(m_last_item!=groupName)
m_warn_on_change = false;
m_last_item = groupName;
})
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