// go on you labels pages | |
// eg https://github.com/cssnext/cssnext/labels | |
// paste this script in your console | |
// copy the output and now you can import it using https://github.com/popomore/github-labels ! | |
var labels = []; | |
[].slice.call(document.querySelectorAll(".label-link")) | |
.forEach(function(element) { | |
labels.push({ | |
name: element.textContent.trim(), | |
// 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 comment has been minimized.
This comment has been minimized.
Awesome! Saved me a lot of time :) |
This comment has been minimized.
This comment has been minimized.
Another approach to import github labels via console command https://gist.github.com/Isaddo/7efebcb673a0957b9c6f07cd14826ea4 |
This comment has been minimized.
This comment has been minimized.
@MoOx: Thank you so much mate! |
This comment has been minimized.
This comment has been minimized.
This script doesn't work on Safari |
This comment has been minimized.
This comment has been minimized.
Great, thank you ! |
This comment has been minimized.
This comment has been minimized.
I just used the following which was quick and easy https://github.com/jvandemo/copy-github-labels-cli (I was linked to this after the fact) |
This comment has been minimized.
This comment has been minimized.
Hi, you can add one line and also get the description:
|
This comment has been minimized.
This comment has been minimized.
and this function to download function saveJSON(data, filename) {
const blob = new Blob([JSON.stringify(data, undefined, 4)], { type: 'text/json' });
const e = document.createEvent('MouseEvents');
const a = document.createElement('a');
a.download = filename;
a.href = window.URL.createObjectURL(blob);
a.dataset.downloadurl = ['text/json', a.download, a.href].join(':');
e.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
a.dispatchEvent(e);
} examplesaveJSON(labels, 'labels.json') |
This comment has been minimized.
This comment has been minimized.
Thanks for this! Very helpful |
This comment has been minimized.
This comment has been minimized.
Adding support for
Support for
|
This comment has been minimized.
This comment has been minimized.
The HTML of the
with:
|
This comment has been minimized.
This comment has been minimized.
Here my code example that includes changes to CSS classname and captures the label's description. 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.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 comment has been minimized.
This comment has been minimized.
Thanks for the original script and thanks @jamesperrin for the update!! |
This comment has been minimized.
Useful! Thank you.