Last active
July 12, 2023 21:28
-
-
Save happiness801/befab4ef3bd1495beb2acfff7cfee447 to your computer and use it in GitHub Desktop.
Cleanup Jira for Architecture
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 Clean-up Jira for Architecture | |
// @namespace http://onai.net/ | |
// @version 0.2 | |
// @description Simplifies interface for Jira for CHG arch team | |
// @author Kevin Gwynn | |
// @match https://chghealthcare.atlassian.net/jira/software/* | |
// @match https://chghealthcare.atlassian.net/browse/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
const addObservers = function() { | |
// Callback function to execute when mutations are observed | |
const observeBodyMutation = (mutationList, observer) => { | |
for (const mutation of mutationList) { | |
if (mutation.type === "childList") { | |
for (const node of mutation.addedNodes) { | |
console.log('KAG: node: ', node); | |
if (node.classList.contains('atlaskit-portal')) { | |
setTimeout(removeCruft, 250); | |
setTimeout(removeCruft, 1500); | |
} else if (node.getAttribute('data-component-selector') === 'jira-issue-field-heading-field-heading-title') { | |
setTimeout(removeCruft, 250); | |
setTimeout(removeCruft, 1500); | |
} | |
} | |
} | |
} | |
}; | |
// Create an observer instance linked to the callback function | |
new MutationObserver(observeBodyMutation).observe(document.body, { childList: true, subtree: true }); | |
}; | |
const removeCruft = function() { | |
console.log('KAG: Jira Cleanup'); | |
document.querySelector('A[href$="/roadmap"')?.remove(); | |
document.querySelector('A[href$="/components"')?.remove(); | |
document.querySelector('A[href$="report-page"')?.remove(); | |
document.querySelector('A[href$="/on-call-schedule"')?.remove(); | |
document.querySelectorAll('A[href*="tempo"')?.forEach(e => e.remove()); | |
document.querySelectorAll('DIV[role="alert"]')?.forEach(e => e.remove()); | |
document.querySelectorAll('H2[data-component-selector="jira-issue-field-heading-field-heading-title"]')?.forEach(e => { | |
switch(e.innerText.trim()) { | |
case 'Development': | |
case 'Automation': | |
case 'Sentry': | |
case 'Releases': | |
case 'Resources': | |
case 'PXT': | |
case 'Application': | |
case 'Team Name': | |
case 'Release Date': | |
case 'Story Points': | |
case 'Sprint': | |
case 'Fix versions': | |
case 'Account': | |
case 'Zendesk Support': | |
e.parentElement.parentElement.remove(); | |
} | |
}); | |
document.querySelector('div[data-testid*="secondary-context"]')?.remove(); | |
document.querySelector('div[data-testid*="tempo"]')?.remove(); | |
} | |
setTimeout(removeCruft, 500); | |
setTimeout(removeCruft, 1000); | |
setTimeout(removeCruft, 2500); | |
setTimeout(addObservers, 2500); | |
setTimeout(removeCruft, 5000); | |
setTimeout(removeCruft, 10000); | |
setTimeout(removeCruft, 15000); | |
})(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment