Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
A Fluid userscript to show the unread message count for a Gmail SSB.
* A userscript for Fluid. This script updates the dock badge for a Gmail SSB
* to the number of unread messages in the Inbox.
* NOTE: For best results, make sure the User Agent is set to a Safari agent.
function initialize() {
function getUnreadBadge() {
var regex = /\s*Inbox\s*\((\d+)\)[^\d]*/;
var inboxLink = document.querySelectorAll('[role=navigation] a');
if (!inboxLink.length) {
return '';
var matches = inboxLink[0].innerText.match(regex);
if (!matches || matches.length < 2) {
return '';
return matches[1];
function updateDockBadge() {
window.fluid.dockBadge = getUnreadBadge();
setTimeout(updateDockBadge, 1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.