Last active
July 11, 2023 23:07
-
-
Save happiness801/8560613afb17a1e8c61efa18079273b3 to your computer and use it in GitHub Desktop.
Fix ridiculous Confluence bug to create Jira Issue
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 Fix ridiculous Confluence bug to create Jira Issue | |
// @namespace http://onai.net/ | |
// @version 0.1 | |
// @description Fixes bug where Confluence says a field is required so you can't create an issue, but the field actually has a default so it's fine | |
// @author Kevin Gwynn | |
// @match https://chghealthcare.atlassian.net/wiki/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
const addObservers = function() { | |
console.log('KAG: Fix ridiculous Confluence bug to create Jira Issue...'); | |
// 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) { | |
if (node.id === 'inline-dialog-create-issue-dialog') { | |
const form = document.getElementById('jira-content-create-issue-form'); | |
new MutationObserver(observeFormMutation).observe(form, { childList: true, subtree: true }); | |
} | |
} | |
} | |
} | |
}; | |
// Observe mutations within the inline form | |
const observeFormMutation = (mutationList, observer) => { | |
for (const mutation of mutationList) { | |
if (mutation.type === 'childList') { | |
for (const node of mutation.addedNodes) { | |
if (node.classList.contains('error-message-create-issue-form')) { | |
const form = document.getElementById('jira-content-create-issue-form'); | |
// Hide the messages panel | |
const messages = form.getElementsByClassName('messages')[0]; | |
messages.classList.remove('single-error'); | |
messages.classList.add('hidden'); | |
// Show the issue-content part of the form | |
document.getElementById('issue-content').classList.remove('hidden'); | |
// Re-enable the submit button | |
form.getElementsByClassName('create-issue-submit')[0].removeAttribute('disabled'); | |
} | |
} | |
} | |
} | |
}; | |
// Create an observer instance linked to the callback function | |
new MutationObserver(observeBodyMutation).observe(document.body, { childList: true, subtree: false }); | |
} | |
setTimeout(addObservers, 5000); | |
})(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment