Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
window.fluid.dockBadge = '';
setTimeout(updateDockBadge, 1000);
setTimeout(updateDockBadge, 3000);
setInterval(updateDockBadge, 5000);
function updateDockBadge() {
var navigation = document.querySelector('[role=navigation]')
var doc = navigation.contentDocument || navigation.ownerDocument;
if (!doc) { return; }
var anchors = []'a'))
var result = anchors.reduce(function(prev, curr, i) {
var match = curr.innerText.match(/\s*Inbox\s*\((\d+)\)[^\d]*/)
if (match) return match;
else return prev;
}, null);
if (result && result[1]) {
window.fluid.dockBadge = result[1];
Copy link

dserodio commented Oct 15, 2013

Does this still work? I'll buy Fluid App if it does, but wanted to check first. Thanks.

Copy link

dserodio commented Oct 18, 2013

I bought Fluid App and verified it still works. Thanks a lot.

Copy link

jguernon commented Jun 11, 2014

Be aware that if you are not in english you have to change line 16
ex.: in french it will be ->
16. var match = curr.innerText.match(/\s_Boîte de réception\s_((\d+))[^\d]*/)

Copy link

rcourtna commented Aug 27, 2015

If you are using Priority Inbox, which reports in the format ($countPriorityUnread : $countOtherUnread), you want the badge to only report the unread priority emails, and you also don't want the badge to report "0", then change line 16:

var match = curr.innerText.match(/\s*Inbox\s*\(([1-9][0-9]*) : \d+\)*/)

Copy link

piranha commented Jan 2, 2016

Just in case anybody looks at this: loop at line 15 is really inefficient and something like this will eat much less CPU.

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