Skip to content

Instantly share code, notes, and snippets.

@shellscape
Last active January 30, 2018 03:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shellscape/17270cbaa6175d15c59858b778c150a7 to your computer and use it in GitHub Desktop.
Save shellscape/17270cbaa6175d15c59858b778c150a7 to your computer and use it in GitHub Desktop.
Restore the Modern, Red Unread Icon in Gmail using ViolentMonkey or TamperMonkey
// ==UserScript==
// @name Gmail Count Red
// @namespace Violentmonkey Scripts
// @match *://mail.google.com/*
// @grant none
// ==/UserScript==
function fix (link) {
const href = link.getAttribute('href');
link.setAttribute('href', href.replace('-b', '_2x'));
}
const iconInterval = setInterval(() => {
const link = document.querySelector('link[rel=icon]');
if (link) {
clearInterval(iconInterval);
fix(link);
const observer = new MutationObserver(((mutations) => {
mutations.forEach((mutation) => {
const nodes = mutation.addedNodes || [];
const child = mutation.type === 'childList';
if (child && nodes.length && nodes[0].nodeName === 'LINK') {
fix(nodes[0])
}
});
}));
observer.observe(document.head, {
attributes: true,
childList: true,
characterData: true
});
}
}, 100);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment