-
Notifications
You must be signed in to change notification settings - Fork 1
/
fastmail.js
48 lines (36 loc) · 1.18 KB
/
fastmail.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
/*
Userscript for Fluid app
FastMail web interface
URL pattern: *.fastmail.com/mail/*
*/
setTimeout(updateDockBadge, 3000);
setInterval(updateDockBadge, 10000);
INBOX_ONLY = false;
FILTERED = ['Drafts', 'Trash', 'Spam'];
function updateDockBadge() {
var tree = document.getElementsByClassName('v-FolderTree')[0];
if (!tree)
return;
var count = 0;
for (i = 0; i < tree.childNodes.length; i++) {
name = tree.childNodes[i].getElementsByClassName('v-FolderSource-name')[0].innerText;
badge = tree.childNodes[i].getElementsByClassName('v-FolderSource-badge')[0].innerText;
// console.log('name: ' + name + ', badge: ' + badge);
if (!badge)
continue;
if (INBOX_ONLY && name == 'Inbox') {
count += parseInt(badge);
break;
}
if (FILTERED.indexOf(name) != -1) {
// console.log('filtered: ' + name);
continue;
}
count += parseInt(badge);
}
// console.log('current count: ' + window.fluid.dockBadge + ', new count: ' + count);
if (count > 0)
window.fluid.dockBadge = count;
else
window.fluid.dockBadge = '';
}