Last active
January 31, 2026 05:17
-
-
Save phpwalter/05963329536ce71c2fea87cac9ee14c8 to your computer and use it in GitHub Desktop.
Export Github Labels
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
| /* | |
| Before running: | |
| 1. go to your LABELS page | |
| [yourname/your_project/labels/] | |
| 2. Opn browser console | |
| 3. paste and run the script | |
| 4. Copy results [already in clipboard] into file and save | |
| */ | |
| const rgbToHex = (rgb) => { | |
| const rgbValues = rgb.match(/\d+/g); | |
| if (!rgbValues || rgbValues.length < 3) return ""; | |
| return "#" + rgbValues.slice(0, 3) | |
| .map(x => parseInt(x).toString(16).padStart(2, '0')) | |
| .join('').toUpperCase(); | |
| }; | |
| // 1. Target containers that START with the module name | |
| const containers = document.querySelectorAll('[class^="Description-module__container"]'); | |
| const labelData = Array.from(containers).map(row => { | |
| // 2. Use wildcard (*) to find elements containing specific keywords | |
| const token = row.querySelector('[class*="TokenBase"]'); | |
| const labelEl = row.querySelector('[class*="Text-Text"]'); | |
| const descEl = row.querySelector('[class*="labelRowDescriptionItemDescription"]'); | |
| const rawColor = token ? window.getComputedStyle(token).backgroundColor : ""; | |
| return { | |
| label: labelEl?.innerText.trim() || "Not Found", | |
| description: descEl?.innerText.trim() || "", | |
| color: rawColor ? rgbToHex(rawColor) : "No Color" | |
| }; | |
| }); | |
| if (labelData.length === 0) { | |
| console.error("Still returning empty. Try inspecting the page to see if the structure changed!"); | |
| } else { | |
| console.log(labelData); | |
| copy(JSON.stringify(labelData, null, 2)); | |
| console.log("Success! Data copied to clipboard."); | |
| } | |
| console.log("Labels copied to clipboard in HEX format!"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment