Created
January 14, 2019 12:13
-
-
Save bitst0rm/565b1936c7e331ef15684f2eee366120 to your computer and use it in GitHub Desktop.
Import/Export GithHub labels via browser console command
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
/* Export GitHub labels | |
* src: https://gist.github.com/Isaddo/7efebcb673a0957b9c6f07cd14826ea4 | |
* | |
* Go on your labels page (https://github.com/user/repo/labels) | |
* Paste this script in your browser javascript console | |
* Press Enter!! | |
*/ | |
function addLabel(label) { | |
if (!updateLabel(label)) addNewLabel(label); | |
} | |
var labels = []; | |
[].slice.call(document.querySelectorAll('.label-link')).forEach(function(element) { | |
labels.push({ | |
name: element.textContent.trim(), | |
description: element.getAttribute('aria-label'), | |
// using style.backgroundColor might returns "rgb(...)" | |
color: element | |
.getAttribute('style') | |
.replace('background-color:', '') | |
.replace(/color:.*/, '') | |
.trim() | |
// github wants hex code only without # or ; | |
.replace(/^#/, '') | |
.replace(/;$/, '') | |
.trim() | |
}); | |
}); | |
console.log(JSON.stringify(labels, null, 2)); |
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
/* Import GitHub labels | |
* src: https://gist.github.com/Isaddo/7efebcb673a0957b9c6f07cd14826ea4 | |
* | |
* Go on your labels page (https://github.com/user/repo/labels) | |
* Paste this script in your browser javascript console | |
* Press Enter!! | |
*/ | |
[ | |
{ | |
"name": "bug", | |
"description": null, | |
"color": "d73a4a" | |
}, | |
{ | |
"name": "conflict", | |
"description": null, | |
"color": "f4aa64" | |
}, | |
{ | |
"name": "docs", | |
"description": null, | |
"color": "1852e2" | |
}, | |
{ | |
"name": "duplicate", | |
"description": null, | |
"color": "cfd3d7" | |
}, | |
{ | |
"name": "enhancement", | |
"description": null, | |
"color": "6ad2dd" | |
}, | |
{ | |
"name": "feature", | |
"description": null, | |
"color": "6ad2dd" | |
}, | |
{ | |
"name": "help-wanted", | |
"description": null, | |
"color": "c912bd" | |
}, | |
{ | |
"name": "in-progress", | |
"description": "Work In Progress and should not be merged", | |
"color": "e590de" | |
}, | |
{ | |
"name": "invalid", | |
"description": null, | |
"color": "f9822c" | |
}, | |
{ | |
"name": "keep-unlocked", | |
"description": null, | |
"color": "0e8a16" | |
}, | |
{ | |
"name": "more-information-needed", | |
"description": null, | |
"color": "c912bd" | |
}, | |
{ | |
"name": "offtopic", | |
"description": null, | |
"color": "1852e2" | |
}, | |
{ | |
"name": "plugin:beautify", | |
"description": "3rd party plugin related", | |
"color": "006b75" | |
}, | |
{ | |
"name": "plugin:config", | |
"description": "3rd party plugin related", | |
"color": "006b75" | |
}, | |
{ | |
"name": "plugin:dependency", | |
"description": "3rd party plugin related", | |
"color": "006b75" | |
}, | |
{ | |
"name": "plugin:i/o", | |
"description": "3rd party plugin related", | |
"color": "006b75" | |
}, | |
{ | |
"name": "plugin:minify", | |
"description": "3rd party plugin related", | |
"color": "006b75" | |
}, | |
{ | |
"name": "plugin:syntax", | |
"description": "3rd party plugin related", | |
"color": "006b75" | |
}, | |
{ | |
"name": "priority:high", | |
"description": null, | |
"color": "b60205" | |
}, | |
{ | |
"name": "question", | |
"description": null, | |
"color": "1852e2" | |
}, | |
{ | |
"name": "request", | |
"description": null, | |
"color": "1852e2" | |
}, | |
{ | |
"name": "scope:api", | |
"description": "Application related: API", | |
"color": "fbca04" | |
}, | |
{ | |
"name": "scope:cli", | |
"description": "Application related: CLI", | |
"color": "fbca04" | |
}, | |
{ | |
"name": "scope:config", | |
"description": "Application related: Configuration", | |
"color": "fbca04" | |
}, | |
{ | |
"name": "scope:dependency", | |
"description": "Application related: Dependencies", | |
"color": "fbca04" | |
}, | |
{ | |
"name": "scope:i/o", | |
"description": "Application related: Input/Output, Logging", | |
"color": "fbca04" | |
}, | |
{ | |
"name": "scope:performance", | |
"description": "Application related: Memory, Performance", | |
"color": "fbca04" | |
}, | |
{ | |
"name": "timeout", | |
"description": "Locked due to age", | |
"color": "000000" | |
}, | |
{ | |
"name": "type:external", | |
"description": "This is not an issue with Formatter, it’s an issue with external software", | |
"color": "eadf04" | |
}, | |
{ | |
"name": "wontfix", | |
"description": "This will not be worked on", | |
"color": "000000" | |
} | |
].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('.js-new-label-name-input').value = label.name; | |
element.querySelector('.js-new-label-description-input').value = label.description; | |
element.querySelector('.js-new-label-color-input').value = '#' + label.color; | |
element.querySelector('.js-edit-label-cancel ~ .btn-primary').click(); | |
} | |
}); | |
return flag; | |
} | |
function addNewLabel(label) { | |
document.querySelector('.js-new-label-name-input').value = label.name; | |
document.querySelector('.js-new-label-description-input').value = label.description; | |
document.querySelector('.js-new-label-color-input').value = '#' + label.color; | |
document.querySelector('.js-details-target ~ .btn-primary').disabled = false; | |
document.querySelector('.js-details-target ~ .btn-primary').click(); | |
} | |
function addLabel(label) { | |
if (!updateLabel(label)) addNewLabel(label); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment