Created
February 1, 2014 16:54
-
-
Save chroder/8755101 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Fluid App Userscript | |
FastMail web interface | |
URL pattern: *fastmail.fm/mail/* | |
*/ | |
setTimeout(updateDockBadge, 3000); | |
setInterval(updateDockBadge, 5000); | |
INBOX_ONLY = true; | |
FILTERED = [ "Drafts", "Trash", "Spam" ]; | |
function updateDockBadge() { | |
var count = 0; | |
var tree = document.getElementsByClassName("FolderTree")[0]; | |
for (i = 0; i < tree.childNodes.length; i++) { | |
name = tree.childNodes[i].getElementsByClassName("name")[0].innerText; | |
badge = tree.childNodes[i].getElementsByClassName("badge")[0].innerText; | |
if (badge) { | |
if (!INBOX_ONLY || name == "Inbox") { | |
if (FILTERED.indexOf(name) == -1) { | |
count += parseInt(badge); | |
} | |
} | |
} | |
} | |
if (count > window.fluid.dockBadge) { | |
notification = { | |
title: "FastMail", | |
description: "You have " + count + " unread message(s)", | |
priority: 1, | |
sticky: false, | |
identifier: "fastmail", | |
icon: window.fluid.resourcePath + 'app.icns' | |
}; | |
window.fluid.showGrowlNotification(notification); | |
window.fluid.dockBadge = count; | |
} else if (count > 0) { | |
window.fluid.dockBadge = count; | |
} else { | |
window.fluid.dockBadge = ""; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment