Created
July 6, 2016 13:05
-
-
Save mattandrews/20d9f594e1a989c5d339a8de305dfec0 to your computer and use it in GitHub Desktop.
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
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