Skip to content

Instantly share code, notes, and snippets.

@KristianP26
Last active July 16, 2024 17:03
Show Gist options
  • Select an option

  • Save KristianP26/da54152268e26b73893fa7792f04196f to your computer and use it in GitHub Desktop.

Select an option

Save KristianP26/da54152268e26b73893fa7792f04196f to your computer and use it in GitHub Desktop.
Tampermonkey Script: Button that will allow you to collape right sitebar in Jira issue view
// ==UserScript==
// @name Jira Collapse Sidebar Button
// @namespace https://gist.github.com/KristianP26/da54152268e26b73893fa7792f04196f
// @version 1.0
// @description Button that will allow you to collape right sitebar in Jira issue view
// @author Kristian Partl
// @homepage https://github.com/KristianP26
// @match https://*/browse/*
// @match https://*/projects/*/issues/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
function addCollapseButton() {
const toolsDiv = document.getElementById('opsbar-jira.issue.tools');
if (!toolsDiv) {
setTimeout(addCollapseButton, 300);
return;
}
const collapseButton = document.createElement('button');
collapseButton.textContent = 'Collapse';
collapseButton.classList.add('aui-button');
toolsDiv.appendChild(collapseButton);
const sidebarDiv = document.getElementById('viewissuesidebar');
collapseButton.addEventListener('click', () => {
if (sidebarDiv) {
if (sidebarDiv.classList.contains('aui-item')) {
sidebarDiv.style.display = 'none';
sidebarDiv.classList.remove('aui-item', 'issue-side-column');
collapseButton.textContent = 'Expand';
} else {
sidebarDiv.classList.add('aui-item', 'issue-side-column');
sidebarDiv.style.display = '';
collapseButton.textContent = 'Collapse';
}
}
});
}
addCollapseButton();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment