Skip to content

Instantly share code, notes, and snippets.

@chsh
Created February 28, 2012 04:25
Show Gist options
  • Save chsh/1929462 to your computer and use it in GitHub Desktop.
Save chsh/1929462 to your computer and use it in GitHub Desktop.
UserScripts for Wunderkit.app made by Fluid.
window.fluid.dockBadge = '';
setTimeout(updateDockBadge, 1000);
setTimeout(updateDockBadge, 3000);
setInterval(updateDockBadge, 5000);
function updateDockBadge() {
var newBadge = '';
var totalCount = 0;
var badgesRoot = document.getElementById('wk-notifications');
var badgeElms = badgesRoot.getElementsByClassName('wk-badge');
for (i = 0; i < badgeElms.length; i++) {
var elm = badgeElms[i];
if (elm.style.display != 'none') {
totalCount += parseInt(elm.innerHTML);
}
}
var numUnreads = totalCount + "";
if (numUnreads != '0') {
newBadge = numUnreads;
}
 
window.fluid.dockBadge = newBadge;
}
@chsh
Copy link
Author

chsh commented Feb 28, 2012

BUG: Hmm..., it periodically show/hide badge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment