Jira: Toggle right sidebar in tickets via keyboard shortcut

Hide/show the right sidebar with ticket details to maximize the content width. Toggle via keyboard "]".

  1. // ==UserScript==
  2. // @name Jira: Toggle right sidebar in tickets via keyboard shortcut
  3. // @namespace https://gf.qytechs.cn/users/1238704
  4. // @version 0.1.4
  5. // @description Hide/show the right sidebar with ticket details to maximize the content width. Toggle via keyboard "]".
  6. // @author Matthias Hagmann
  7. // @match *://jira.*/browse/*
  8. // @match https://*.atlassian.net/browse/*
  9. // @match https://*.atlassian.net/jira/*
  10. // @match https://*.atlassian.com/browse/*
  11. // @match https://*.atlassian.com/jira/*
  12. // @grant none
  13. // @license MIT
  14. // @homepage https://gf.qytechs.cn/scripts/483015
  15. // ==/UserScript==
  16.  
  17. (function() {
  18. 'use strict';
  19.  
  20. function toggleSidebar() {
  21. // new
  22. const sidebarTestId = 'issue.views.issue-details.issue-layout.container-right';
  23. const sidebarElement = document.querySelector(`[data-testid="${sidebarTestId}"]`);
  24. if (sidebarElement) {
  25. sidebarElement.style.display = (sidebarElement.style.display === 'none') ? '' : 'none';
  26. }
  27.  
  28. // old
  29. const sidebar = document.querySelector('#viewissuesidebar');
  30. if (sidebar) {
  31. sidebar.style.display = (sidebar.style.display === 'none') ? '' : 'none';
  32. }
  33. }
  34.  
  35. // Add a keyboard shortcut "]" to toggle the sidebar
  36. document.addEventListener('keydown', function(event) {
  37. if (event.key === ']') {
  38. toggleSidebar();
  39. }
  40. });
  41.  
  42. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址