// ==UserScript==
// @name Insert msgs into JIRA comment
// @namespace https://jira.ontrq.com/browse/
// @include https://jira.ontrq.com/browse/*
// @version 1
// @grant none
// ==/UserScript==
var nfxpnk = {
ge: function(elementId) {
return document.getElementById(elementId);
},
author: 'Thanks,\n[~eac_RudchSer]',
comments: [
{
name: 'Add the comment for the BE team',
msg: 'Hi [~hbpt-be], please have a look at the issue.\n'
},
{
name: 'Add the comment for the QA team',
msg: 'Hi [~hbpt-qa], .\n'
}
],
addLink: function (name, msg) {
var newElement = document.createElement('a');
newElement.setAttribute('href', '#');
newElement.setAttribute('style', 'margin:0 5px;');
newElement.onclick = function(e) {
return nfxpnk.addComment(msg);
};
newElement.appendChild(document.createTextNode(name));
return newElement;
},
addComment: function(msg) {
var commentTextBlock = this.ge('comment');
commentTextBlock.value = msg + this.author;
return false;
},
main: function() {
var i, commentLink,
iLength = this.comments.length,
fieldTools = document.getElementsByClassName('field-tools')[0];
for(i = 0; i < iLength; i++) {
commentLink = this.addLink(this.comments[i].name, this.comments[i].msg)
fieldTools.append(commentLink);
};
}
};
nfxpnk.main();