De-obfuscation of CSS
Here is a little command line fu I worked today, it seemed post worthy.
I found a site I wanted to emulate so I checked out the CSS file only to see a “obfuscated” version, missing new lines and spaces. Â I whipped up this little sequence of sed commands to de-obfuscate the CSS.
cat site.css |sed “s|}|}\n|g”|sed “s|;|;\n|g”|sed “s|{|{\n|g”|sed “s|^\([^}]\)| Â \1|g”|sed “s|^ *\([^{]*\){|\1{|g” > out.css
List each line of the CSS file, add a new line after all }, { and ; characters. Â Add 2 spaces to all lines, then remove the spaces from lines that have a { at the end. Â This results in some pretty readable code.