Restore the Modern, Red Unread Icon in Gmail using ViolentMonkey or TamperMonkey
This file contains 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
// ==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