Skip to content

Instantly share code, notes, and snippets.

@ian4kasablancas
Last active November 15, 2024 21:21
Show Gist options
  • Save ian4kasablancas/8058949ef684dd04e90ccc65995b9aff to your computer and use it in GitHub Desktop.
Save ian4kasablancas/8058949ef684dd04e90ccc65995b9aff to your computer and use it in GitHub Desktop.
TamperMonkey Script - YT no notifications.
// ==UserScript==
// @name Hide YouTube Notifications
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Hides YouTube notifications and removes notification count from the tab title.
// @author Ian_Blancasa
// @match https://www.youtube.com/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
// Hide notification icon
const hideNotificationIcon = () => {
const notificationIcon = document.querySelector('#notification-count');
if (notificationIcon) {
notificationIcon.style.display = 'none';
}
};
// Remove notification count from the tab title
const removeNotificationCountInTitle = () => {
const title = document.title;
const notificationPattern = /^\(\d+\)\s*/;
if (notificationPattern.test(title)) {
document.title = title.replace(notificationPattern, '');
}
};
// Run the functions every second to ensure they work on dynamic content
setInterval(() => {
hideNotificationIcon();
removeNotificationCountInTitle();
}, 1000);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment