Last active
May 9, 2017 23:22
-
-
Save wenqingyu/2f51bbf11edb0460d339cd826c8557cf to your computer and use it in GitHub Desktop.
JavaScript snippet to create Airplake standard Github labels set
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"name": "Epic: Airplake Guideline", | |
"color": "5319e7" | |
}, | |
{ | |
"name": "Magt: Salary Checked", | |
"color": "0052cc" | |
}, | |
{ | |
"name": "Priority: Blocked", | |
"color": "B71C1C" | |
}, | |
{ | |
"name": "Priority: Critical", | |
"color": "E53935" | |
}, | |
{ | |
"name": "Priority: High", | |
"color": "EF5350" | |
}, | |
{ | |
"name": "Priority: Low", | |
"color": "FFEBEE" | |
}, | |
{ | |
"name": "Priority: Medium", | |
"color": "EF9A9A" | |
}, | |
{ | |
"name": "Status: Backlog", | |
"color": "5319e7" | |
}, | |
{ | |
"name": "Status: Done", | |
"color": "33691E" | |
}, | |
{ | |
"name": "Status: In progress", | |
"color": "AED581" | |
}, | |
{ | |
"name": "Status: In review", | |
"color": "7CB342" | |
}, | |
{ | |
"name": "Status: QA", | |
"color": "006b75" | |
}, | |
{ | |
"name": "Type: Bug", | |
"color": "FFFF00" | |
}, | |
{ | |
"name": "Type: Enhancement", | |
"color": "FFD600" | |
}, | |
{ | |
"name": "Type: Question", | |
"color": "FFFF8D" | |
}, | |
{ | |
"name": "Type: Task", | |
"color": "FFEA00" | |
} | |
].forEach(function(label) { | |
addLabel(label) | |
}) | |
function updateLabel (label) { | |
var flag = false; | |
[].slice.call(document.querySelectorAll(".labels-list-item")) | |
.forEach(function(element) { | |
if (element.querySelector('.label-link').textContent.trim() === label.name) { | |
flag = true | |
element.querySelector('.js-edit-label').click() | |
element.querySelector('.label-edit-name').value = label.name | |
element.querySelector('.color-editor-input').value = '#' + label.color | |
element.querySelector('.new-label-actions .btn-primary').click() | |
} | |
}) | |
return flag | |
} | |
function addNewLabel (label) { | |
document.querySelector('.new-label input#label-').value = label.name | |
document.querySelector('.new-label input#edit-label-color-new').value = '#' + label.color | |
document.querySelector('.new-label-actions .btn-primary').click() | |
} | |
function addLabel (label) { | |
if (!updateLabel(label)) addNewLabel(label) | |
} | |
undefined |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To use this label auto generator
Clear out all your labels on Github, and open your browser console on label page, copy and paste this whole piece of js code into console and enter to run. All the label will be added into this repo.
通过标签自动生成器添加标签
去labels页面,先删除所有的标签,然后打开浏览器console,复制粘贴整段js代码,直接回车运行,所有标准化label就会生成。