Skip to content

Instantly share code, notes, and snippets.

@israelst
Last active March 19, 2019 12:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save israelst/67a944fd25f05014998ff4d01a1e4985 to your computer and use it in GitHub Desktop.
Save israelst/67a944fd25f05014998ff4d01a1e4985 to your computer and use it in GitHub Desktop.
Get all colors used in a webpage.
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