/* | |
Go on your labels page (https://github.com/user/repo/labels) | |
Edit the following label array | |
or | |
Use this snippet to export github labels (https://gist.github.com/MoOx/93c2853fee760f42d97f) | |
and replace it | |
Paste this script in your console | |
Press Enter!! | |
*/ | |
[ | |
{ | |
"name": "bugfix", | |
"color": "eb6420" | |
}, | |
{ | |
"name": "feature", | |
"color": "0e8a16" | |
}, | |
{ | |
"name": "hotfix", | |
"color": "e11d21" | |
} | |
].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) | |
} |
This comment has been minimized.
This comment has been minimized.
mqklin
commented
Oct 21, 2017
With some changes in github classnames:
|
This comment has been minimized.
This comment has been minimized.
Merovex
commented
Dec 2, 2017
Very nice. Thanks! |
This comment has been minimized.
This comment has been minimized.
lgelfan
commented
Jan 26, 2018
•
Trying it again recently, I needed to add |
This comment has been minimized.
This comment has been minimized.
NillerMedDild
commented
Sep 24, 2018
•
I added two lines so the script now also works with descriptions. This includes Igelfan's fix.// append this to the array returned from the label getter at the bottom
Getting the labels from source repo, with descriptions:
|
This comment has been minimized.
This comment has been minimized.
TreONeill
commented
Oct 10, 2018
Thanks for this! Very helpful |
This comment has been minimized.
This comment has been minimized.
priom
commented
Feb 16, 2019
Amazing! Thank you! |
This comment has been minimized.
This comment has been minimized.
cdlhub
commented
Feb 18, 2019
Thanks a lot. I have added my own labels to add priority labels and change some default GitHub label color: |
This comment has been minimized.
This comment has been minimized.
dallinca
commented
Sep 8, 2019
Hey all, very helpful. When I tried the updates to include the descriptions the code wasn't quite working (getting null for all descriptions). I only slightly modified the code for getting the labels from the source repo. The following code worked for me.
|
This comment has been minimized.
hisabimbola commentedSep 14, 2016
Nice, works well. It is possible to add a flag to clear all existing flags before importing new ones