Skip to content

Instantly share code, notes, and snippets.

@langpavel
Created April 12, 2022 11:12
Show Gist options
  • Save langpavel/cc86b9fcd9e382da72def5584615ae48 to your computer and use it in GitHub Desktop.
Save langpavel/cc86b9fcd9e382da72def5584615ae48 to your computer and use it in GitHub Desktop.
filter all CSS rules
function* cssRulesIterator() {
for(const stylesheet of window.document.styleSheets) {
for (const rule of stylesheet.cssRules) {
yield rule.cssText;
}
}
}
[...cssRulesIterator()].filter(ruleText => true)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment