ideadapt / jira-ui

// ==UserScript==
// @name         jira-ui
// @namespace    srg.srf
// @version      0.2
// @description  try to take over the world!
// @author       ueli kunz
// @match        https://srgssr-ch.atlassian.net/jira/*
// @grant        none
// @license      MIT
// ==/UserScript==

/**
 * Add a stylesheet rule to the document (it may be better practice
 * to dynamically change classes, so style information can be kept in
 * genuine stylesheets and avoid adding extra elements to the DOM).
 * Note that an array is needed for declarations and rules since ECMAScript does
 * not guarantee a predictable object iteration order, and since CSS is
 * order-dependent.
 * @param {Array} rules Accepts an array of JSON-encoded declarations
 * @example
addStylesheetRules([
  ['h2', // Also accepts a second argument as an array of arrays instead
    ['color', 'red'],
    ['background-color', 'green', true] // 'true' for !important rules
  ],
  ['.myClass',
    ['background-color', 'yellow']
  ]
]);
*/
function addStylesheetRules(rules) {
  const styleEl = document.createElement("style");

  // Append <style> element to <head>
  document.head.appendChild(styleEl);

  // Grab style element's sheet
  const styleSheet = styleEl.sheet;

  for (let i = 0; i < rules.length; i++) {
    let j = 1,
      rule = rules[i],
      selector = rule[0],
      propStr = "";
    // If the second argument of a rule is an array of arrays, correct our variables.
    if (Array.isArray(rule[1][0])) {
      rule = rule[1];
      j = 0;
    }

    for (let pl = rule.length; j < pl; j++) {
      const prop = rule[j];
      propStr += `${prop[0]}: ${prop[1]}${prop[2] ? " !important" : ""};\n`;
    }

    // Insert CSS Rule
    styleSheet.insertRule(
      `${selector}{${propStr}}`,
      styleSheet.cssRules.length,
    );
  }
}

(function() {
    'use strict';
    console.log('TAMPERMONKEY jira-ui');

    addStylesheetRules([
        ['[data-testid="platform-board-kit.common.ui.column-header.header.column-header-container"]',
         ['height', '30px']
        ],

        ['[data-fullscreen-id="fullscreen-board-breadcrumbs"] ~ div:last-child',
         ['margin-top', '0']
        ],

        ['[data-fullscreen-id="fullscreen-board-breadcrumbs"] ~ div:last-child > div',
         ['margin-bottom', '8px']
        ],

        ['div:has(>[data-fullscreen-id="fullscreen-board-breadcrumbs"])',
          ['margin', '0']
        ],
        ['[data-testid="platform-board-kit.ui.swimlane.swimlane-wrapper"] div:nth-child(3)',
          ['height', 'initial'] //['top', '19px', true]
        ],
        ['[data-component-selector="platform-board-kit.ui.column.draggable-column"]:first-child [data-test-id="platform-card.ui.card.focus-container"] [class*="_cardColorInner"]',
          ['width', '0']
        ]
    ]);

    console.log("TAMPERMONKEY jira-ui done");
})();