Skip to content

Instantly share code, notes, and snippets.

@Braunson
Last active January 20, 2022 21:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Braunson/1286ea8ff8eda73b66164184926fe980 to your computer and use it in GitHub Desktop.
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
// ==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