Last active
September 20, 2024 16:20
-
-
Save fabiancarlos/d52dd7dccc90b0cce44a37b7d34a5b87 to your computer and use it in GitHub Desktop.
Remove All Title Content
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 Remove Title and Change Favicon on WhatsApp Web | |
// @namespace http://tampermonkey.net/ | |
// @version 1.1 | |
// @description Remove the title and change the favicon on WhatsApp Web every 5 seconds | |
// @match https://web.whatsapp.com/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
function modifyTab() { | |
document.title = ''; | |
const faviconSize = 32; | |
const canvas = document.createElement('canvas'); | |
canvas.width = faviconSize; | |
canvas.height = faviconSize; | |
const ctx = canvas.getContext('2d'); | |
ctx.beginPath(); | |
ctx.arc(faviconSize / 2, faviconSize / 2, faviconSize / 2, 0, 2 * Math.PI); | |
ctx.fillStyle = '#28834a'; | |
ctx.fill(); | |
const faviconUrl = canvas.toDataURL('image/png'); | |
const linkElements = document.querySelectorAll("link[rel*='icon']"); | |
linkElements.forEach(link => link.parentNode.removeChild(link)); | |
const newFavicon = document.createElement('link'); | |
newFavicon.rel = 'icon'; | |
newFavicon.href = faviconUrl; | |
document.head.appendChild(newFavicon); | |
// remove badge on list messaages | |
const gridCells = document.querySelectorAll('[role="gridcell"]'); | |
gridCells.forEach(gridCell => { | |
const deepestParent = gridCell.querySelector('*'); | |
if (deepestParent) { | |
const lastChild = deepestParent.lastElementChild; | |
if (lastChild) { | |
if (lastChild.hasAttribute('style')) { | |
deepestParent.removeChild(lastChild); | |
} | |
} | |
} | |
}); | |
} | |
setInterval(modifyTab, 5000); | |
modifyTab(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment