Created
July 23, 2021 11:36
-
-
Save mangei/9bca02d43fcd1791ae7c029b08143534 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 Copy Ticket Info | |
// @namespace http://tampermonkey.net/ | |
// @version 1.0 | |
// @description try to take over the world! | |
// @author You | |
// @match https://jira.portal.at/browse/* | |
// @match https://jira.cloudflight.io/browse/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
var toolbar = document.getElementById('opsbar-jira.issue.tools'); | |
var actionBtn = createButton(); | |
actionBtn.addEventListener("click", buttonAction); | |
toolbar.appendChild(actionBtn); | |
function createButton() { | |
var actionBtn = document.createElement('a'); | |
var iconElement = document.createElement('span'); | |
iconElement.classList.add('aui-icon'); | |
iconElement.classList.add('aui-iconfont-copy'); | |
actionBtn.appendChild(iconElement); | |
actionBtn.appendChild(document.createTextNode(" Info")); | |
actionBtn.title = 'Copy ticket info into clipboard.'; | |
actionBtn.classList.add("aui-button"); | |
return actionBtn; | |
} | |
function buttonAction() { | |
var ticketNrText = document.getElementById('key-val').textContent; | |
var ticketSummaryText = document.getElementById('summary-val').textContent; | |
var ticketText = ticketNrText + ' ' + ticketSummaryText; | |
copyToClipboard(ticketText); | |
//alert(ticketText); | |
} | |
function copyToClipboard(text) { | |
var textArea = document.createElement("textarea"); | |
textArea.value = text; | |
document.body.appendChild(textArea); | |
textArea.select(); | |
document.execCommand("Copy"); | |
textArea.remove(); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment