Tampermonkey. Copy JIRA issue title with issue key
// ==UserScript==
// @name Copy JIRA issue title with issue key
// @namespace https://tools.adidas-group.com/jira/browse/
// @include https://tools.adidas-group.com/jira/browse/*
// @version 1
// @grant none
// ==/UserScript==
function addLink(name) {
var newElement = document.createElement('a');
newElement.setAttribute('href', '#');
newElement.setAttribute('style', 'display: inline-block; line-height: 34px;');
newElement.appendChild(document.createTextNode(name));
var thisCopy = this;
return newElement;
};
var nfxpnk = {
ge: function(elementId) {
return document.getElementById(elementId);
},
appendInput: function(parentElement, value, style) {
var input = document.createElement('input');
input.type = 'text';
input.value = value;
console.log(typeof(style) != 'undefined')
if(typeof(style) != 'undefined') {
input.style.width = '80%';
}
input.onclick = function() {
input.select();
}
parentElement.parentNode.appendChild(input);
},
main: function() {
var issueKey = this.ge('key-val');
this.appendInput(issueKey, issueKey.textContent);
},
button: function() {
var issueKey = this.ge('key-val');
var summaryVal = this.ge('summary-val');
var btn = addLink('Create commit title');
btn.onclick = function(e) {
var team = prompt('Team', 'GL');
var comment = prompt('Comment', 'Styles');
var fullText = issueKey.textContent + ':' + team + ':' + summaryVal.textContent + '. ' + comment;
return nfxpnk.appendInput(summaryVal, fullText, true);
};
summaryVal.parentNode.appendChild(btn);
}
};
nfxpnk.main();
nfxpnk.button();