Skip to content

Instantly share code, notes, and snippets.

@corse32
Created December 13, 2017 00:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save corse32/c74b3b178cefe9dc4171f18816f8351e to your computer and use it in GitHub Desktop.
Save corse32/c74b3b178cefe9dc4171f18816f8351e to your computer and use it in GitHub Desktop.
JS (ES 6) one liner for extracting CSS rules from a DOM element
//blah is a reference to the dom node in question, e.g. const blah = document.getElementById('popover882889')
Array.from(window.getMatchedCSSRules(blah)).reduce((acc, rule) => `${acc} \n ${rule.cssText}`)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment