GitHub notifications are overwhelming in large organizations with 100+ repositories.
当前为
// ==UserScript==
// @name No more GitHub notifications
// @namespace http://tampermonkey.net/
// @version 2025-03-24
// @description GitHub notifications are overwhelming in large organizations with 100+ repositories.
// @author mxt-mischa
// @match https://github.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=github.com
// @license AGPL-3.0
// ==/UserScript==
(function() {
'use strict';
function waitForElement(parent, selector) {
return new Promise((resolve) => {
console.debug(`Looking for element: ${selector}`);
const element = parent.querySelector(selector);
if (element) {
console.debug(`Element ${selector} found immediately`);
resolve(element);
return;
}
const observer = new MutationObserver((mutations, obs) => {
const element = parent.querySelector(selector);
if (element) {
console.debug(`Element ${selector} found via MutationObserver`);
obs.disconnect();
clearTimeout(timeoutId);
clearInterval(pollId);
resolve(element);
}
});
observer.observe(parent, {
childList: true,
subtree: true,
attributes: true
});
});
}
async function main() {
const indicator = await waitForElement(document, `notification-indicator`);
if (indicator) {
indicator.remove();
} else {
alert("Notifications where?");
}
}
function onUrlChange() {
console.debug('URL changed:', location.href);
if (location.href.includes('github.com')) {
// Small delay to let GitHub finish its initial rendering
setTimeout(main, 500);
}
}
let currentUrl = location.href;
new MutationObserver(() => {
if (currentUrl !== location.href) {
currentUrl = location.href;
onUrlChange();
}
}).observe(document, { subtree: true, childList: true });
// Initial run - no setTimeout needed
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', main);
} else {
main();
}
})();