Created
February 14, 2013 07:07
-
-
Save itod/4951085 to your computer and use it in GitHub Desktop.
Fluid Gmail Userscript
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
window.fluid.dockBadge = ''; | |
setTimeout(updateDockBadge, 1000); | |
setTimeout(updateDockBadge, 3000); | |
setInterval(updateDockBadge, 5000); | |
function updateDockBadge() { | |
var newBadge = ''; | |
// loop thru anchor tags | |
var anchorEls = document.getElementsByTagName('a'); | |
//console.log('anchors: ' + anchorEls.length); | |
var regex = /\s*Inbox\s*\((\d+)\)[^\d]*/; | |
for (var i = 0; i < anchorEls.length; i++) { | |
var anchorEl = anchorEls[i]; | |
//console.log('anchorEl: '+ anchorEl); | |
var text = '' + anchorEl.innerText; | |
if (!text.length) continue; | |
if (-1 == text.indexOf('(')) continue; | |
var res = text.match(regex); | |
if (res && res.length > 1) { | |
//console.log('res: '+ res); | |
newBadge = res[1]; | |
break; | |
} | |
} | |
window.fluid.dockBadge = newBadge; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment