Created
January 30, 2023 16:26
-
-
Save SmugZombie/21423bfc3c326d2b3d0912d49df56fab to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Jira - External Links Fixer | |
// @namespace https://github.com/smugzombie | |
// @version 0.1.0 | |
// @description Jira is dumb and opens all links in the same tab as the issue you are viewing.. causing you to lose the issue. This forces external links to open seperately | |
// @author SmugZombie (github.com/smugzombie | |
// @match https://*.atlassian.net/* | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=atlassian.net | |
// @grant none | |
// @downloadURL https://put.wtf/media/scripts/JiraLinks.js?version=0.1.0 | |
// @updateURL https://put.wtf/media/scripts/JiraLinks.js?version=0.1.0 | |
// ==/UserScript== | |
(function() { | |
let myLinks = document.getElementsByTagName("a"); // Grab all links on page | |
let ignoredHref = window.location.href.split("atlassian.net")[0] + "atlassian.net"; //Figure out the current atlassian url to ignore later | |
// Loop through all links | |
for (var i = myLinks.length - 1; i >= 0; i--) { | |
let linkhref = myLinks[i].href; | |
if(linkhref.includes(ignoredHref)){ | |
// If the link includes the ignoredHref, its local, don't open in new window | |
}else{ // Othgerwise, change the target to "_blank" so it opens in a new tab | |
myLinks[i].target = "_blank"; | |
} | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment