Skip to content

Instantly share code, notes, and snippets.

@stefnotch
Last active November 2, 2018 11:06
Show Gist options
  • Save stefnotch/79b88e54d0a36c1c92bdda06750b2ec3 to your computer and use it in GitHub Desktop.
Save stefnotch/79b88e54d0a36c1c92bdda06750b2ec3 to your computer and use it in GitHub Desktop.
Colorizes a YouTrack backlog
/**
* Open the browser console
* Copy paste the entire script
* Close the console and everything should work (until you reload the page)
*/
//No, that's not how I usually write JS. This is pretty much the definition of: "I spent a few minutes hacking something pretty together."
var targetNode = document.getElementsByClassName('yt-backlog-container')[0];
var colorize = () => {
if(!document.hasFocus()) return;
[...targetNode.getElementsByClassName("yt-agile-backlog-issue")]
.forEach(el => {
var color = "";
[...el.getElementsByClassName("yt-issue-custom-field")]
.forEach(e => {
if(e.getElementsByTagName("span")[0].innerHTML.includes("Epic")) { color = e.style.color = "red";}
if(e.getElementsByTagName("span")[0].innerHTML.includes("User Story")) { color = e.style.color = "blue";}
if(e.getElementsByTagName("span")[0].innerHTML.includes("Task")) { color = e.style.color = "green";}
});
if(color) {
el.style.boxShadow = "inset 5px 0px 0px 0px " + color;
}
});
};
colorize();
setInterval(colorize, 1000);
@stefnotch
Copy link
Author

stefnotch commented Oct 30, 2018

Priority colorizer:

/**
* Open the browser console
* Copy paste the entire script
* Close the console and everything should work (until you reload the page)
*/

var targetNode = document.getElementsByClassName('yt-backlog-container')[0];

var colorize = () => {
    if(!document.hasFocus()) return;
    [...targetNode.getElementsByClassName("yt-agile-backlog-issue")]
        .forEach(el => {
        var color = "";
    
        [...el.getElementsByClassName("yt-issue-custom-field")]
           .forEach(e => {
            if(e.getElementsByTagName("span")[0].innerHTML.includes("Critical")) { color = e.style.color = "red";} 
            if(e.getElementsByTagName("span")[0].innerHTML.includes("Major")) { color = e.style.color = "green";} 
            if(e.getElementsByTagName("span")[0].innerHTML.includes("Normal")) { color = e.style.color = "blue";} 
            if(e.getElementsByTagName("span")[0].innerHTML.includes("Minor")) { color = e.style.color = "black";} 
        });
        
        if(color) {
            el.style.boxShadow = "inset 5px 0px 0px 0px " + color;
        }
    });
};

colorize();

setInterval(colorize, 1000);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment