-
Notifications
You must be signed in to change notification settings - Fork 0
/
jira.user.js
48 lines (39 loc) · 1.31 KB
/
jira.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// ==UserScript==
// @name Copy JIRA issue title with issue key
// @namespace https://jira.ontrq.com/browse/
// @include https://jira.ontrq.com/browse/*
// @version 3
// @grant none
// ==/UserScript==
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;
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');
var text = this.ge('summary-val');
var issueType = this.ge('type-val').innerText;
var messageType = issueType.match(/Bug/) ? 'Fix' : 'Feature';
var fullText = messageType + ': ' + issueKey.textContent + ' - ' + text.textContent;
this.appendInput(issueKey, issueKey.textContent);
this.appendInput(text, fullText, true);
var summary = text.textContent.toLowerCase().replace(/[^ \w]+/g, '');
summary = summary.replace(/ +/g, '-');
//summary = summary.substring(0, 40);
var branchName = messageType.toLowerCase() + '/' + issueKey.textContent + '-' + summary;
this.appendInput(text, branchName, true);
}
};
nfxpnk.main();