Skip to content

Instantly share code, notes, and snippets.

@icodeforlove
Last active December 21, 2015 02:18
Show Gist options
  • Select an option

  • Save icodeforlove/6233788 to your computer and use it in GitHub Desktop.

Select an option

Save icodeforlove/6233788 to your computer and use it in GitHub Desktop.
logs out all stylesheets in chrome
Array.prototype.slice.call(document.styleSheets).forEach(function (stylesheet, index, array) {
if (!stylesheet.rules) return;
console.groupCollapsed("Stylesheet #%s", index);
Array.prototype.slice.call(stylesheet.rules).forEach(function (rule, index, array) {
var properties = rule.cssText.match(/\{\s+?(.+)\s+?\}/);
if (rule.type === 1) {
console.log('%s%c %s', rule.selectorText, 'font-weight: normal; color: #999', properties ? properties[1] : '');
} else if (rule.type === 7) {
console.log('@keyframes %s%c %s', rule.name, 'font-weight: normal; color: #999', rule.cssText.replace(/[^\{]*\{([\s\S]+)\}$/, '{$1}'));
}
});
console.groupEnd();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment