Created
July 11, 2020 10:25
-
-
Save Ice3man543/22570d980200c6190859513593a40ad6 to your computer and use it in GitHub Desktop.
Export github labels from https://github.com/<user>/<repo>/issues/labels page
This file contains hidden or 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
// Forked from https://gist.github.com/MoOx/93c2853fee760f42d97f | |
// Only change i did was make it return proper color code | |
var labels = []; | |
[].slice.call(document.querySelectorAll(".js-label-link")) | |
.forEach(function(element) { | |
labels.push({ | |
name: element.textContent.trim(), | |
description: element.getAttribute("title"), | |
// using style.backgroundColor might returns "rgb(...)" | |
color: element.style.backgroundColor | |
.substring( 4, element.style.backgroundColor.length - 1 ) | |
.split( ',' ) | |
.reduce( ( hexValue, rgbValue ) => { | |
return ( | |
hexValue + | |
Number( rgbValue ).toString( 16 ) | |
.padStart( 2, '0' ) | |
); | |
}, '' ), | |
}) | |
}) | |
console.log(JSON.stringify(labels, null, 2)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A good default set of labels.