Last active
September 1, 2016 04:18
-
-
Save esprehn/319d1db9ed833fca786691a5140aee3f to your computer and use it in GitHub Desktop.
Find all the pseudos
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
(function() { | |
var selectors = new Map(); | |
for (let sheet of Array.from(document.styleSheets)) { | |
for (let rule of Array.from(sheet.cssRules || [])) { | |
var text = rule.selectorText || ""; | |
for (let match of (text.match(/\:([a-zA-Z0-9\-]+)/g) || [])) | |
selectors.set(match, (selectors.get(match) || 0) + 1); | |
} | |
} | |
return [ | |
selectors, | |
// We need to allocate each one at least once, so subtract the set size. | |
Array.from(selectors.values()).reduce((total, value) => total + value, 0) - selectors.size, | |
]; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment