Created
December 13, 2024 17:47
-
-
Save gartnera/03bfc1bee6c7220c4e2f018febf4794e to your computer and use it in GitHub Desktop.
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 remove annoying automated comment spam from github PRs | |
// @namespace agartner.com | |
// @match https://github.com/*/pull/* | |
// @grant none | |
// @version 1.0 | |
// @description 12/12/2024, 1:34:32 PM | |
// ==/UserScript== | |
const annoyingComments = [ | |
"GitGuardian has uncovered", | |
"Thank you for using CodeRabbit", | |
"nosec detected in the following files", | |
"Codecov Report", | |
]; | |
(function() { | |
'use strict'; | |
function deleteComments() { | |
const comments = document.querySelectorAll('.js-timeline-item'); | |
for (const comment of comments) { | |
const commentText = comment.innerText; | |
let shouldRemove = false; | |
for (const annoyingComment of annoyingComments) { | |
if (commentText.includes(annoyingComment)) { | |
shouldRemove = true; | |
break; | |
} | |
} | |
if (shouldRemove) { | |
comment.remove(); | |
} | |
} | |
} | |
// Initial deletion | |
deleteComments(); | |
// Create a MutationObserver to watch for new comments | |
const observer = new MutationObserver((mutations) => { | |
mutations.forEach((mutation) => { | |
if (mutation.type === 'childList') { | |
deleteComments(); | |
} | |
}); | |
}); | |
// Start observing the document with the configured parameters | |
observer.observe(document.querySelector(".js-discussion"), { childList: true, subtree: true }); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment