Last active
January 20, 2022 21:22
-
-
Save Braunson/1286ea8ff8eda73b66164184926fe980 to your computer and use it in GitHub Desktop.
Tapermonkey / Greasyfork: Open JIRA links within the text description in a new tab
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 Open link in new | |
// @namespace braunson.jira.open.links.in.new.tab | |
// @version 1.0.1 | |
// @description Adds target="_blank" to any links within a card's text description | |
// @supportURL https://gist.github.com/Braunson/1286ea8ff8eda73b66164184926fe980 | |
// @author Braunson Yager (geekybeaver.ca) | |
// @match https://*.atlassian.net/* | |
// @grant none | |
// ==/UserScript== | |
const isExternalLink = (url) => { | |
const tmp = document.createElement('a'); | |
tmp.href = url; | |
return tmp.host !== window.location.host; | |
}; | |
(function() { | |
setInterval(() => { | |
let links = document.querySelectorAll("[data-test-id='issue.views.field.rich-text.description'] a[href]"); | |
for (let link of links) { | |
if (! isExternalLink(link.getAttribute("href"))) { | |
continue; | |
} | |
link.setAttribute('target', '_blank'); | |
} | |
}, 2000); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment