-
-
Save johanoloflindberg/b70e869525d7ea9e26dfdc471337b1bb to your computer and use it in GitHub Desktop.
- Removed duplicate timers
- Added a remove badge option
- Added (Advanced) Growl Notifications, # of new emails and # of unread messages.
- Only notify when email counter goes up not down
- Added sound notification
This file contains hidden or 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
window.fluid.dockBadge = ''; | |
function updateDockBadge() { | |
console.log('check new messages'); | |
var navigation = document.querySelector('[role=navigation]') | |
var doc = navigation.contentDocument || navigation.ownerDocument; | |
if (!doc) { return; } | |
var anchors = [].slice.call(doc.querySelectorAll('a')) | |
var result = anchors.reduce(function(prev, curr, i) { | |
var match = curr.innerText.match(/\s*Inbox\s*\((\d+)\)[^\d]*/) | |
if (match) return match; | |
else return prev; | |
}, null); | |
if (result && result[1]) { | |
if (window.fluid.dockBadge < result[1]) { | |
var extraess = "", extraessb = ""; | |
if (result[1] != 1) { extraess = "s"; } | |
var extramessages = result[1] - window.fluid.dockBadge; | |
if (extramessages > 1) { extraessb = "s"; } | |
window.fluid.showGrowlNotification({ | |
title: extramessages+" New Email"+extraessb, | |
description: "You have "+result[1]+" unread message"+extraess, | |
sticky: false, | |
onclick: function() { | |
console.log("Show Window"); //doesnt work | |
}, | |
identifier: "gmail" | |
}); | |
window.fluid.playSound("Purr"); | |
} | |
window.fluid.dockBadge = result[1]; | |
} else { | |
window.fluid.dockBadge = ''; | |
} | |
} | |
setInterval(updateDockBadge, 10000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment