Skip to content

Instantly share code, notes, and snippets.

@ginpei
Last active August 2, 2018 05:02
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 ginpei/422d588fc686202f0af2226a697c95e4 to your computer and use it in GitHub Desktop.
Save ginpei/422d588fc686202f0af2226a697c95e4 to your computer and use it in GitHub Desktop.
Object.entries(Array.from(document.querySelectorAll('*'))
.reduce((list, el) => {
const styles = window.getComputedStyle(el);
Object.values(styles).forEach((prop) => {
const value = styles[prop];
if (prop.toLowerCase().includes('color')) {
(value.match(/rgba?\(\d+, \d+, \d+(, \d+(.\d+)?\))?/g) || [])
.map(s => (s.match(/\d+(.\d+)?/g) || []).join(', '))
.forEach((color) => {
if (!(color in list)) {
list[color] = [];
}
if (!list[color].includes(el)) {
list[color].push(el)
}
});
}
});
return list;
}, {}))
.forEach(([sCodes, els]) => console.log(`%c ${sCodes} (${els.length}) `, `background-color: ${sCodes.length === 3 ? 'rgb' : 'rgba'}(${sCodes}); text-shadow: 1px 1px #fff`));
// EOF
@ginpei
Copy link
Author

ginpei commented Aug 2, 2018

This may take so long time that your browser gets stuck. 🐘

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment