Last active
March 19, 2019 12:00
-
-
Save israelst/67a944fd25f05014998ff4d01a1e4985 to your computer and use it in GitHub Desktop.
Get all colors used in a webpage.
This file contains 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 els = document.querySelectorAll('*'); | |
const isColorProperty = property => property.toLowerCase().indexOf('color') > -1; | |
colors = new Set(); | |
for(el of els) | |
for(property in getComputedStyle(el)) | |
if(isColorProperty(property)) | |
colors.add(getComputedStyle(el)[property]) | |
console.dir(colors.entries()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment