NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name ColorLabels4Jira // @namespace Slavomir Garaj // @description Highlight labels in Jira Kanban board // @include https://jira.nike.sk/secure/RapidBoard.jspa?rapidView=48* // @copyright 2018, 0101001101000111 (https://openuserjs.org/users/0101001101000111) // @license MIT // @grant none // @version 0.1 // ==/UserScript== // Wait for page is loaded window.setTimeout(ColorLabels, 500); function ColorLabels() { var labelStyle = {}; var c = 0; var arFields = document.getElementsByClassName("ghx-extra-field"); for (var i=0; i < arFields.length; i++) { var elField = arFields[i]; // only labels if(elField.getAttribute("data-tooltip").startsWith("Label")) { // Parse labels var myStringArray = elField.getAttribute("data-tooltip").substring(8).split(','); for (var s in myStringArray) { var label = myStringArray[s].trim(); if(label != "None") { // Pick style class if(!labelStyle[label]) { labelStyle[label] = "ghx-label-" + ((c%9) + 1); //there are 9 predefined Epic styles in Jira ghx-label-1..9 c++; } //console.log('>>> Label: ' + label + ' styled as: ' + labelStyle[label]); // Create new span var mySpan = document.createElement('span'); mySpan.className += "aui-label"; mySpan.innerHTML = label; mySpan.className += " " + labelStyle[label]; elField.appendChild(mySpan); } } // Hide original (comma separated) label field var arFieldContents = elField.getElementsByClassName("ghx-extra-field-content"); for (var j=0; j < arFieldContents.length; j++) { var elFieldContent = arFieldContents[j]; elFieldContent.style.display = "none"; } } } }