Skip to content

Instantly share code, notes, and snippets.

@mattandrews
Created July 6, 2016 13:05
Show Gist options
  • Save mattandrews/20d9f594e1a989c5d339a8de305dfec0 to your computer and use it in GitHub Desktop.
Save mattandrews/20d9f594e1a989c5d339a8de305dfec0 to your computer and use it in GitHub Desktop.
var allStylesheets = document.styleSheets;
var classesUsed = [];
[].forEach.call(allStylesheets, function(sheet) {
for (var i = 0; i < allStylesheets.length; i++) {
try {
var sheet = allStylesheets[i];
for (var j = 0; j < sheet.cssRules.length; j++) {
classesUsed.push(sheet.cssRules[j].selectorText);
}
} catch(e) {
if (e.name !== "SecurityError") {
throw e;
}
}
}
});
console.log(classesUsed);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment