Skip to content

Instantly share code, notes, and snippets.

@ryasmi
Last active October 18, 2017 07:38
Show Gist options
  • Save ryasmi/7f1feda9324391f3a3c5 to your computer and use it in GitHub Desktop.
Save ryasmi/7f1feda9324391f3a3c5 to your computer and use it in GitHub Desktop.
Creates labels for status, type, and priority.
javascript:!function(){var e="#e11d21",t="#eb6420",n="#009800",c=function(e,t){return{name:e,colour:t}},o=function(o,u,r,i){return[c(o+":"+u,n),c(o+":"+r,t),c(o+":"+i,e)]},u=o("type","question","enhancement","bug"),r=o("status","archived","unconfirmed","confirmed"),i=o("priority","low","medium","high"),a=u.concat(r).concat(i),l=document.querySelector(".issues-listing button.js-details-target");l.click();var m=function(e){var t=document.getElementById("label-"),n=document.getElementById("edit-label-color-new"),c=document.querySelector(".new-label-actions button.btn.btn-primary");t.value=e.name,n.value=e.colour,c.click()};a.map(m)}();
(function () {
var highColour = '#e11d21';
var mediumColour = '#eb6420';
var lowColour = '#009800';
var label = function (name, colour) {
return {name: name, colour: colour};
};
var colouredLabels = function (prefix, low, med, high) {
return [
label(prefix + ':' + low, lowColour),
label(prefix + ':' + med, mediumColour),
label(prefix + ':' + high, highColour),
];
};
var typeLabels = colouredLabels('type', 'question', 'enhancement', 'bug');
var statusLabels = colouredLabels('status', 'archived', 'unconfirmed', 'confirmed');
var priorityLabels = colouredLabels('priority', 'low', 'medium', 'high');
var labels = typeLabels.concat(statusLabels).concat(priorityLabels);
var newLabel = document.querySelector('.issues-listing button.js-details-target');
newLabel.click();
var createLabel = function (label) {
var input = document.getElementById('label-name-');
var colour = document.getElementById('label-color-');
var createLabel = document.querySelector('#new_label button.btn.btn-primary');
input.value = label.name;
colour.value = label.colour;
createLabel.click();
};
labels.map(createLabel);
})();
(function () {
var breakColour = '#b60205';
var releaseColour = '#fbca04';
var noReleaseColour = '#0e8a16';
var label = function (name, colour) {
return {name: name, colour: colour};
};
var labels = [
label('breaking change', breakColour),
label('feat', releaseColour),
label('fix', releaseColour),
label('perf', releaseColour),
label('docs', noReleaseColour),
label('style', noReleaseColour),
label('refactor', noReleaseColour),
label('test', noReleaseColour),
label('build', noReleaseColour),
label('ci', noReleaseColour),
label('chore', noReleaseColour),
].reverse();
var newLabel = document.querySelector('.issues-listing button.js-details-target');
newLabel.click();
var createLabel = function (label) {
var input = document.getElementById('label-name-');
var colour = document.getElementById('label-color-');
var createLabel = document.querySelector('#new_label button.btn.btn-primary');
input.value = label.name;
colour.value = label.colour;
createLabel.click();
};
labels.map(createLabel);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment