Last active
November 15, 2024 21:21
-
-
Save ian4kasablancas/8058949ef684dd04e90ccc65995b9aff to your computer and use it in GitHub Desktop.
TamperMonkey Script - YT no notifications.
This file contains hidden or 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 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