Skip to content

Instantly share code, notes, and snippets.

@beevk
Last active December 23, 2019 14:17
Show Gist options
  • Save beevk/a3edce3480d835795b8effd1f0227aab to your computer and use it in GitHub Desktop.
Save beevk/a3edce3480d835795b8effd1f0227aab to your computer and use it in GitHub Desktop.
javascript: (function () {
function AddTaskId() {
var project = document.getElementsByClassName('TopbarPageHeaderStructure-title')[0].textContent;
project = project.replace("BCHU ", "")
.replace("Runway", "STORE")
.toUpperCase()
.replace("IOS APP", "iOS");
var d = new Date();
var month = ('0' + (d.getMonth() + 1)).slice(-2);
var day = ('0' + d.getDate()).slice(-2);
var prefix = String(month) + day;
var pattern = /\[[0-9]*\-[A-Z]*\]/g;
var possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
var suffix = '';
for (var i = 0; i < 3; i++) {
suffix += possible.charAt(Math.floor(Math.random() * possible.length));
} /*and end removing here*/
var taskString = '[' + project + '-' + prefix + '-' + suffix + ']';
var element = document.activeElement;
if (!element.value.match(pattern)) {
element.value = taskString + ' ' + element.value;
}
}
if (document.activeElement.nodeName === 'INPUT' || document.activeElement.nodeName === 'TEXTAREA') {
AddTaskId();
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment