Create a gist now

Instantly share code, notes, and snippets.

@wpeterson /README.md
Last active Dec 16, 2015

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 https://mail.google.com/mail/u/0/* 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 https://mail.google.com/*
// @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];
element.parentNode.removeChild(element);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment