Skip to content

Instantly share code, notes, and snippets.

@wpeterson
Last active June 30, 2017 15:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wpeterson/5371900 to your computer and use it in GitHub Desktop.
Save wpeterson/5371900 to your computer and use it in GitHub Desktop.

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