forked from rchern/StackExchangeScripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SEChatFaviconNotification.user.js
133 lines (113 loc) · 14.7 KB
/
SEChatFaviconNotification.user.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
// ==UserScript==
// @name Stack Overflow Chat Favicon Notifier
// @namespace yijiang
// @description Watches the SO Chat for new messages, and changes the Favicon accordingly
// @include http://chat.stackoverflow.com/rooms/*
// @include http://chat.meta.stackoverflow.com/rooms/*
// @include http://chat.stackexchange.com/rooms/*
// @include http://chat.askubuntu.com/rooms/*
// @exclude http://chat.stackoverflow.com/rooms/info/*
// @exclude http://chat.meta.stackoverflow.com/rooms/info/*
// @exclude http://chat.stackexchange.com/rooms/info*
// @exclude http://chat.askubuntu.com/rooms/info/*
// ==/UserScript==
(function(){
function getLink () {
return document.querySelectorAll('head link[rel*=shortcut]')[0];
}
var title = document.title,
iconURL = getLink().href,
img = new Image(),
canvas = document.createElement('canvas'),
ctx = canvas.getContext('2d'),
host = window.location.hostname,
sites = {
gaming: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAXklEQVQ4jWNgoBa4z8HxHx0TI0e5AdgkScFEG/D7yZP/v588GUADkA2iyACKXYBhwFUGBrb9DAwcJGp8R1Q6wInZ2b+TlCKR8FOykjQM3+PgeE3QAGyGkaSJqgYQAwBdcz9MXASc9AAAAABJRU5ErkJggg==',
cooking: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAA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AAAAAElFTkSuQmCC'
};
canvas.width = 16;
canvas.height = 16;
ctx.font = "bold 8px Ubuntu, 'Segoe UI', Tahoma, Arial, 'sans serif'";
ctx.textAlign = 'center';
// Find the correct favicon to use
if(host.indexOf('chat.stackoverflow') === 0) {
img.src = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABnElEQVQ4jWNgwAMaGBiYHqdqT36SpvP/carOgdueKuz41OM2JE177ZM0nf+PUrUXkmwAAwMDw91QJf7HKTqnn6Tp/H+UplNNUMOrqaw5r6ew1D2fxCAKE3uYpKv0OEX3KdQlETg1P+5j4Hw9he3q66ls/19NZX35agpLzcsJDOIMDAwMj5O1zR6n6P54nKb942GqpgtWAxoaGJheTWVQeTeNqe31VJbPUINev5rB0ny/gUHgSbaqz5Mk/T+Pk3UbCXrlQT+D5NupTE3vpjG9fTOV9f+racxvXvZzND0tk/JrYGBgwtCwqtCSc3WFQ/GqEqfAZYWO2vMTFDgYGBgYrjaI8jybyFn0bhrTo3fTmf6/mc4gjdXGVcW2WmsrHP/D8OpypzcrS10OrC53bN1QaRVypFkj6FaPSCROJ88sd+FfV2YdtKHCrmV9he3ODeW29zZU2P1fX2H/f2254//VZU7/VxY72WFozM3J+Z+bk/Mfq6HFviJzy31tFld4payscJ44s8BdEkM9sgCMjQtjtZCqBhADcBpAKqaKAQB1iiloT36niAAAAABJRU5ErkJggg==';
} else if(host.indexOf('chat.meta.stackoverflow') === 0) {
img.src = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABWklEQVQ4ja2QvUpDQRCFLykkhYhFkGApVj6AlVhZikiw8AEsbxpDGiPu2Znd2CQEkXAJ3DuzeQAfwNLa2tpCLERSWaWQtUlAMNcfcODAsMz55uwkyTcFoOKcu/beR+fcHYCl7+ZLId77G+99ZObxnwEzyIpz7n6W5OxHg4ikInIxGo1qnyAbzPzsvY9EdFxqVtWqiDyoalTVFxE5z7JsLUmSxDm3zcxT59yUmffK4lbyPN9U1UsReVPVKCKvIQQeDAar3W53n4jeicj++JXhcFgPIbCqTmaJJnmec7/fPwBQWbS9CuAUwCGALQDVGWi5KIrT8Xj8FEKIRVGsl8XfstbGuYwxE2PMnTHGM/NRr9drZFlWfsBms7kCoAHAE9GttfaRiCIRRWttBBAB7H4xpmka0zSNi6CtVqvW6XR2AJwAuGq32/Uv858f5n2ZFi78V8BvqhTwV/0L4AMhxDwD8Y9esAAAAABJRU5ErkJggg==';
} else {
var smallIconUrl = document.querySelectorAll('#sidebar-menu .small-site-logo')[0].src,
found = false;
for(var i in sites){
if(smallIconUrl.indexOf(i) !== -1) {
img.src = sites[i];
found = true;
break;
}
}
if(!found) {
img.src = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAA5ElEQVQ4jWNggIKG/ftZFt19l7Ho9rtKvPjuu4yG/ftZGNDBkrvvtqx88OE/MXjqjTerMQxYee/DT2I0T7/55n/LxRffMAygGBQf+PIfHw7d/PG/2dL3cEySAeiasRpAMUiceec/OnZovvpfNvcsVkzQAHyasRpAMUho3vwkuW3bf6ecZf8VAqfhxfKBUz+LOkzlQTEgqXnLa2I0QwyY9kfGvU8IxQD7rEW+CgHTTsoHTDsDx4FTrysETP2BZsAtuYApsUR7DU1zBslhoxA47b9CwNSP8v5TsknWDDNAzneKNi55AC2gU1dDOLAVAAAAAElFTkSuQmCC';
}
}
// Start title watching process
setInterval(function(){
if(title !== document.title) {
title = document.title;
var times, mention = false, ctitle = title, url;
if(title.indexOf('(') === 0){
ctitle = title.substring(1, title.indexOf(')'));
if(ctitle.indexOf('*') > -1){
mention = true;
if(ctitle.length === 1){
times = 0;
} else {
times = parseInt(ctitle, 10);
}
} else {
times = parseInt(ctitle, 10);
}
} else {
times = 0;
}
if(times > 0 || mention) {
// Draw ma circlez!
ctx.clearRect(0, 0, 16, 16);
ctx.fillStyle = mention ? "rgba(63, 175, 7, 0.8)" : "rgba(200, 0, 30, 0.6)";
ctx.drawImage(img, 0, 0);
ctx.beginPath();
ctx.arc(11, 11, 5, 0, Math.PI*2, true);
ctx.fill();
ctx.fillStyle = "#fff";
if(times < 10){
ctx.fillText(times, 11, 13);
} else if(times < 100){
ctx.fillText(~~(times/10), 9, 13);
ctx.fillText((times%10), 13, 13);
} else {
ctx.fillText('+', 11, 13);
}
url = canvas.toDataURL("image/png");
} else {
url = iconURL;
}
var linkEle = getLink(),
newLink = document.createElement('link'),
head = document.getElementsByTagName('head')[0];
newLink.rel = 'shortcut icon';
newLink.type = 'image/png';
newLink.href = url;
head.removeChild(linkEle);
head.appendChild(newLink);
}
}, 500);
})();