Skip to content

Instantly share code, notes, and snippets.

@fabiancarlos
Last active September 20, 2024 16:20
Show Gist options
  • Save fabiancarlos/d52dd7dccc90b0cce44a37b7d34a5b87 to your computer and use it in GitHub Desktop.
Save fabiancarlos/d52dd7dccc90b0cce44a37b7d34a5b87 to your computer and use it in GitHub Desktop.
Remove All Title Content
// ==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