-
-
Save errogaht/c8409ac0266d1c68b56fb32da61304d6 to your computer and use it in GitHub Desktop.
Add button "Copy task name" to JIRA (version for suxx new JIRA interface)
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 Copy jira task name | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description try to take over the world! | |
// @author You | |
// @match https://kafoodle.atlassian.net/browse/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
window.addEventListener("load", function(){ | |
setTimeout(function(){ | |
var i = document.querySelectorAll('[name="ajs-issuekey"]').item(0).getAttribute('content'); | |
const copyToClipboard = str => { | |
const el = document.createElement('textarea'); | |
el.value = str; | |
el.setAttribute('readonly', ''); | |
el.style.position = 'absolute'; | |
el.style.left = '-9999px'; | |
document.body.appendChild(el); | |
el.select(); | |
document.execCommand('copy'); | |
document.body.removeChild(el); | |
}; | |
const copyTaskName = () => { | |
var d = document.querySelectorAll('#jira-frontend h1').item(0).innerText; | |
var desc = i + " " + d; | |
copyToClipboard(desc); | |
}; | |
var btn = document.createElement("button"); | |
btn.onclick = copyTaskName; | |
btn.innerText = "Copy task name"; | |
btn.style = "margin-left: 10px;"; | |
document.evaluate('//span[text()="' + i + '"]', document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE).snapshotItem(0).parentElement.parentElement.parentElement.append(btn); | |
}, 1000); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment