Skip to content

Instantly share code, notes, and snippets.

@AlbinoDrought
Created April 16, 2018 22:41
Show Gist options
  • Save AlbinoDrought/75f860058c5f7a360467b07d81e800bd to your computer and use it in GitHub Desktop.
Save AlbinoDrought/75f860058c5f7a360467b07d81e800bd to your computer and use it in GitHub Desktop.
Replace shitty Jira links with links to the backlog
// ==UserScript==
// @name Replace shitty Jira links with links to the backlog
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://*.atlassian.net/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
var regex = /(?:\/browse\/|\/project\/)(.*)/g;
function replaceLinkWithNotShit(element) {
var href = element.href;
if (!href) {
return;
}
if (!href.match(regex)) {
return;
}
element.href = href.replace(regex, '/secure/RapidBoard.jspa?projectKey=$1&rapidView=12&view=planning');
}
function stopTheHurting() {
var querySelectors = [
'#project-name-val',
'a[role="menuitem"]',
];
for (var i = 0; i < querySelectors.length; i += 1) {
var querySelector = querySelectors[i];
var elements = document.querySelectorAll(querySelector);
for (var o = 0; o < elements.length; o += 1) {
replaceLinkWithNotShit(elements[o]);
}
}
};
document.addEventListener('click', function (e) {
if (e.target && e.target.href) {
replaceLinkWithNotShit(e.target);
}
});
document.addEventListener('DOMNodeInserted', stopTheHurting);
window.addEventListener('load', stopTheHurting);
stopTheHurting();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment