-
-
Save cvan/c0601676aa2cea62fc792fa95086f791 to your computer and use it in GitHub Desktop.
Export GitHub Labels as JSON (name, description, color)
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
// Remixed from original source: https://gist.github.com/MoOx/93c2853fee760f42d97f | |
// | |
// 1. Go to a GitHub Labels page. (e.g., https://github.com/cssnext/cssnext/labels) | |
// 2. Open your Dev Tools' Console and paste this script. | |
// 3. Now you have a dump of your labels. | |
// | |
// P.S. The JSON output can be later imported using a tool using https://github.com/popomore/github-labels | |
labels = []; | |
Array.prototype.forEach.call(document.querySelectorAll('.Box-row a[class^=IssueLabel]'), el => { | |
const row = el.closest('.Box-row'); | |
const name = el.textContent.trim(); | |
const description = row.querySelectorAll('div')[2].textContent.trim(); | |
const color = (el.getAttribute('style') || '').replace(/\s/g, '').toLowerCase().split(';').filter(item => item.startsWith('background-color'))[0].split(':')[1].substr(1); | |
labels.push({ name, description, color }); | |
}); | |
labels = JSON.stringify(labels, null, 2); | |
console.log(labels); | |
copy(labels); // Copy to your clipboard. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment