Last active
January 27, 2025 19:28
-
-
Save Hypfer/97fe1fc29e9ec3804a598e074d7da816 to your computer and use it in GitHub Desktop.
This Userscript hides the AI spam that is Coderabbit AI comments. It has been AI-Generated :-)
This file contains 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 CodeRabbit Comments | |
// @namespace Violentmonkey Scripts | |
// @match https://github.com/** | |
// @grant none | |
// @version 1.0 | |
// @author - | |
// @description 5/1/2025, 14:01:37 | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
function hideCodeRabbitComments() { | |
// Find all author links that point to coderabbit | |
const codeRabbitAuthors = document.querySelectorAll('a.author[href="/apps/coderabbitai"]'); | |
codeRabbitAuthors.forEach(author => { | |
// Find the parent TimelineItem and hide it | |
const timelineItem = author.closest('.TimelineItem'); | |
if (timelineItem) { | |
timelineItem.style.display = 'none'; | |
} | |
}); | |
} | |
// Debounce function | |
function debounce(func, wait) { | |
let timeout; | |
return function executedFunction(...args) { | |
const later = () => { | |
clearTimeout(timeout); | |
func(...args); | |
}; | |
clearTimeout(timeout); | |
timeout = setTimeout(later, wait); | |
}; | |
} | |
// Debounced version of hideCodeRabbitComments | |
const debouncedHide = debounce(hideCodeRabbitComments, 100); | |
// Observer for the main container to detect any DOM changes | |
const observer = new MutationObserver(() => { | |
debouncedHide(); | |
}); | |
// Start observing the main container | |
const mainContainer = document.querySelector('body'); | |
if (mainContainer) { | |
observer.observe(mainContainer, { | |
childList: true, | |
subtree: true | |
}); | |
} | |
// Initial run | |
hideCodeRabbitComments(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment