Based on 's original script: https://gist.github.com/PaulKinlan/6283739 with a few changes:
* Takes into account styles for html and body.
* Finds matching styles for ::before and ::after pseudo elements.
* Merges all styles from rules with the same selector into one rule.
* And some other things. Look at the source if you really want to know.