-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfastmail-classic.js
53 lines (43 loc) · 1.36 KB
/
fastmail-classic.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
/*
Fluid App Userscript
FastMail classic web interface
URL pattern: *fastmail.com/html/*
*/
setTimeout(updateDockBadge, 3000);
setInterval(updateDockBadge, 10000);
INBOX_ONLY = false;
FILTERED = [ "Drafts", "Trash", "Junk Mail" ];
function updateDockBadge() {
var badge = 0;
var tree = document.getElementsByClassName("folder");
for (i = 0; i < tree.length; i++)
{
var folder = tree[i].getElementsByClassName("overflow")[0].childNodes[0].data.replace("\u200e","");
// console.log(folder);
if (! INBOX_ONLY || folder == "Inbox")
{
if (FILTERED.indexOf(folder) == -1)
{
var counts = tree[i].getElementsByClassName("messageCounts")[0].childNodes[0].data;
// console.log(counts);
if (counts)
{
var res = counts.match(/ \((\d+)/);
if (res && res.length > 1)
{
// console.log(folder + ": " + res[1]);
badge += parseInt(res[1]);
}
}
} else {
// console.log("filtered: " + folder);
}
}
}
if (badge)
{
window.fluid.dockBadge = badge;
} else {
window.fluid.dockBadge = "";
}
}