Last active
September 29, 2015 21:27
-
-
Save q0rban/1671089 to your computer and use it in GitHub Desktop.
Fluid Userscript for Yammer
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
// ==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