Skip to content

Instantly share code, notes, and snippets.

@wpeterson wpeterson/
Last active Jun 30, 2017

What would you like to do?

How to Fix Unread Favicon in GMail for Chrome

  • Ensure Labs => Unread Message Icon feature enabled
  • Install "TamperMonkey" chrome plugin
  • Add the javascript included in this gist (fix_gmail_unread_favicon.js)

Thanks to Bertrand Schneider for the code snippet and fix.

Why did the favicon break?

It looks like there was a regression that causes two favicon link elements to be generated in the GMail markup, causing only the first to take precedence for the page (the default favicon) and the smart favicon with the unread count not to be shown.

Work-around for old GMail (on Google Apps domain)

  • Change the match string in the JavaScript only to match your public gmail account, for example* if your public GMail is your first logged in google account.
// ==UserScript==
// @name Fix GMail Unread Favicon
// @version 0.1
// @description Fixes GMail favicon to include unread message count properly
// @match*
// @copyright 2012+, Bertrand Schneider
// ==/UserScript==
var favicon = undefined;
var nodeList = document.getElementsByTagName("link");
for (var i = 0; i < nodeList.length; i++)
if((nodeList[i].getAttribute("rel") == "shortcut icon"))
element = nodeList[i];
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.