Created
July 16, 2022 19:05
-
-
Save abdmmar/efb8bf7d7c11b1d6f8576fc9aafaa0fb to your computer and use it in GitHub Desktop.
Get Tailwind Colors
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
| const colorsValue = Array.from(document.querySelectorAll("div.px-0\\.5.md\\:flex.md\\:justify-between.md\\:space-x-2.\\32 xl\\:space-x-0.\\32 xl\\:block")).map(node => node.textContent) | |
| const colorsName = Array.from(document.querySelectorAll('.text\\-sm.font\\-semibold.text\\-slate\\-900.dark\\:text\\-slate\\-200')).map(node => node.textContent) | |
| let colorsValueCount = 0 | |
| let colorsNameIndex = 0 | |
| let colors = {} | |
| const setColor = (name, value) => { | |
| let [valueNum, valueRGB] = value.split("#") | |
| colors[name.toLowerCase()][valueNum] = `#${valueRGB}` | |
| } | |
| for (let value of colorsValue) { | |
| let name = colorsName[colorsNameIndex] | |
| if(colorsValueCount === 0) { | |
| colors[name.toLowerCase()] = {} | |
| } | |
| if(colorsValueCount === 9) { | |
| setColor(name, value) | |
| colorsValueCount = 0 | |
| colorsNameIndex++ | |
| } else { | |
| setColor(name, value) | |
| colorsValueCount++ | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment