Archive for July, 2009
Convert adblock rule list to regular expressions
Here’s the script convert EasyList and ChinaList to regex lines, which may be used in some web browsers or proxy programs.
#!/bin/sh
ADLIST=”http://adblock-chinalist.googlecode.com/svn/trunk/adblock.txt http://easylist.adblockplus.org/easylist.txt”
echo -n > /tmp/adblock.txt
for URL in $ADLIST
do
echo Fetching $URL …
curl $URL | grep -v ^$ | grep -v # | grep -v ^[!|@] | grep -v \$ | sed ’s/./\./g’ | sed s/*/.*/g | sed ’s/|/\|/g’ | grep -v ‘Adblock Plus 1′ >> /tmp/adblock.txt
done
Note this will generate >1000 regexp lines, which might impact performance of your web browser.