Created
July 29, 2024 07:14
-
-
Save marcello3d/88e06a6141976b4213108748e31c6b4a to your computer and use it in GitHub Desktop.
Tampermonkey script to hide
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 skipped jobs on github | |
// @version 0.0.1 | |
// @match https://github.com/descriptinc/*/actions/runs/* | |
// @match https://github.com/descriptinc/*/pull/* | |
// @description | |
// ==/UserScript== | |
// Inspired by https://github.com/orgs/community/discussions/18001#discussioncomment-6532796 | |
// Used ChatGPT 4o for mutation observer code | |
"use strict"; | |
// Create a new MutationObserver instance and pass a callback function to handle changes | |
const observer = new MutationObserver((mutationsList) => { | |
for (let mutation of mutationsList) { | |
// Check if the mutation type is 'childList', which indicates changes to child elements | |
if (mutation.type === "childList") { | |
// Call the function to remove skipped jobs whenever child elements change | |
removeSkippedJobs(); | |
} | |
} | |
}); | |
// Start observing the target node (document.body) for configured mutations | |
observer.observe(document.body, { childList: true, subtree: true }); | |
// Function to remove elements with specific classes indicating skipped jobs | |
function removeSkippedJobs() { | |
let count = 0; | |
document | |
.querySelectorAll(".merge-status-item > .merge-status-icon > .octicon-skip") | |
.forEach((node) => { | |
node.parentElement.parentElement.remove(); | |
count++; | |
}); | |
document | |
.querySelectorAll(".ActionListItem-visual > span > div > .octicon-skip") | |
.forEach((node) => { | |
node.parentElement.parentElement.parentElement.parentElement.parentElement.remove(); | |
count++; | |
}); | |
if (count > 0) { | |
console.log(`Filtered Skipped Jobs, removed ${count}`); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment