Created
October 20, 2011 13:57
-
-
Save eojthebrave/1301201 to your computer and use it in GitHub Desktop.
Userscript: provide a Fluid.app dock badge for yammer.com unread messages.
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
// ==UserScript== | |
// @name fluid-dock-badge | |
// @namespace http://fluidapp.com | |
// @description Dock badge for unread messages on Yammer.com | |
// @include * | |
// @author Joe Shindelar (eojthebrave) | |
// ==/UserScript== | |
(function ($) { | |
if (window.fluid) { | |
setInterval(dockBadge, 5000); | |
} | |
function dockBadge() { | |
var msg = jQuery('.yj-new-messages-link:visible span:last').html(); | |
if (msg != null) { | |
var count = msg.replace(/.*\s([0-9]*)\s.*/, '$1'); | |
if (count.length) { | |
window.fluid.dockBadge = count; | |
} | |
else { | |
window.fluid.dockBadge = ""; | |
} | |
// Clear the badge immediatly when someone clicks the banner. | |
jQuery('.yj-new-messages-link:visible span:last').click(function() { | |
window.fluid.dockBadge = ""; | |
}) | |
} | |
else { | |
window.fluid.dockBadge = ""; | |
} | |
} | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment