Created
July 24, 2024 09:33
-
-
Save ephraimduncan/eb33eff75950680dec13949aadc0978f to your computer and use it in GitHub Desktop.
Selectively hide bot activities and deployments from GitHub timeline while preserving important information
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 GitHub Timeline Cleaner | |
| // @namespace http://tampermonkey.net/ | |
| // @version 0.6 | |
| // @description Selectively hide bot activities and deployments from GitHub timeline while preserving important information | |
| // @match https://github.com/* | |
| // @grant none | |
| // ==/UserScript== | |
| (function() { | |
| 'use strict'; | |
| const botsToHide = ['vercel', 'github-actions', 'coderabbitai']; | |
| const keywordsToPreserve = ['feat:', 'fix:', 'docs:', 'style:', 'refactor:', 'test:', 'chore:']; | |
| function shouldHideItem(item) { | |
| const isBotActivity = item.querySelector('.Label--secondary[title="bot"]'); | |
| const actorLink = item.querySelector('.author'); | |
| const isSpecificBot = actorLink && botsToHide.includes(actorLink.textContent.trim().toLowerCase()); | |
| const isDeployment = item.textContent.includes('deployed to') || item.textContent.includes('had a problem deploying'); | |
| // Check if the item contains any of the keywords to preserve | |
| const containsKeyword = keywordsToPreserve.some(keyword => item.textContent.toLowerCase().includes(keyword)); | |
| // Hide the item if it's a bot activity, specific bot, or deployment, but not if it contains a keyword to preserve | |
| return (isBotActivity || isSpecificBot || isDeployment) && !containsKeyword; | |
| } | |
| function hideTimelineItems() { | |
| const timelineItems = document.querySelectorAll('.TimelineItem'); | |
| timelineItems.forEach(item => { | |
| if (shouldHideItem(item)) { | |
| item.style.display = 'none'; | |
| } else { | |
| item.style.display = ''; // Reset display if it was previously hidden | |
| } | |
| }); | |
| } | |
| // Run on page load | |
| hideTimelineItems(); | |
| // Use MutationObserver for dynamically loaded content | |
| const observer = new MutationObserver(hideTimelineItems); | |
| observer.observe(document.body, { childList: true, subtree: true }); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment