Last active
August 29, 2015 14:21
-
-
Save nrutman/353bbe0b7f2c4c378962 to your computer and use it in GitHub Desktop.
A Fluid userscript to show the unread message count for a Google Inbox SSB.
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
/** | |
* A userscript for Fluid. This script updates the dock badge for a Google Inbox | |
* SSB to the number of unread messages in the current view. Note that the user | |
* must be navigated to the Inbox, and it will only count unread messages | |
* that are currently displayed on the screen. | |
*/ | |
initialization(); | |
function initialization() { | |
updateUnreadBadge(); | |
} | |
function getUnreadCount() { | |
// if we aren't on the inbox we don't know the current unread count | |
if (location.pathname != '/' || location.hash !== '') { | |
return '?'; | |
} | |
// we are on the inbox, so get the count | |
var els = document.getElementsByClassName('ss'); | |
return (els.length) ? els.length : ''; | |
} | |
function updateUnreadBadge() { | |
window.fluid.dockBadge = getUnreadCount(); | |
setTimeout(updateUnreadBadge, 1000); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment