Created
September 1, 2012 20:05
-
-
Save 0x46616c6b/3585720 to your computer and use it in GitHub Desktop.
Privoxy Filter from Adblock Plus
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
URL="http://adblockplus.mozdev.org/easylist/easylist.txt" | |
ACTION=/root/user.action | |
FILTER=/root/user.filter | |
FILE=$(basename ${URL}) | |
LIST=${FILE%\.*} | |
wget -qO ${FILE} ${URL} | |
echo -e "{ +block{${LIST}} }" > ${ACTION} | |
sed '/^!.*/d;1,1 d;/^@@.*/d;/\$.*/d;/#/d;s/\./\\./g;s/\?/\\?/g;s/\*/.*/g;s/(/\\(/g;s/)/\\)/g;s/\[/\\[/g;s/\]/\\]/g;s/\^/[\/\&:\?=_]/g;s/^||/\./g;s/^|/^/g;s/|$/\$/g;/|/d' ${FILE} >> ${ACTION} | |
echo "FILTER: ${LIST} Tag filter of ${LIST}" > ${FILTER} | |
sed '/^#/!d;s/^##//g;s/^#\(.*\)\[.*\]\[.*\]*/s|<([a-zA-Z0-9]+)\\s+.*id=.?\1.*>.*<\/\\1>||g/g;s/^#\(.*\)/s|<([a-zA-Z0-9]+)\\s+.*id=.?\1.*>.*<\/\\1>||g/g;s/^\.\(.*\)/s|<([a-zA-Z0-9]+)\\s+.*class=.?\1.*>.*<\/\\1>||g/g;s/^a\[\(.*\)\]/s|<a.*\1.*>.*<\/a>||g/g;s/^\([a-zA-Z0-9]*\)\.\(.*\)\[.*\]\[.*\]*/s|<\1.*class=.?\2.*>.*<\/\1>||g/g;s/^\([a-zA-Z0-9]*\)#\(.*\):.*[:[^:]]*[^:]*/s|<\1.*id=.?\2.*>.*<\/\1>||g/g;s/^\([a-zA-Z0-9]*\)#\(.*\)/s|<\1.*id=.?\2.*>.*<\/\1>||g/g;s/^\[\([a-zA-Z]*\).=\(.*\)\]/s|\1^=\2>||g/g;s/\^/[\/\&:\?=_]/g;s/\.\([a-zA-Z0-9]\)/\\.\1/g' ${FILE} >> ${FILTER} | |
echo "{ +filter{${LIST}} }" >> ${ACTION} | |
echo "*" >> ${ACTION} | |
echo "{ -block }" >> ${ACTION} | |
sed '/^@@.*/!d;s/^@@//g;/\$.*/d;/#/d;s/\./\\./g;s/\?/\\?/g;s/\*/.*/g;s/(/\\(/g;s/)/\\)/g;s/\[/\\[/g;s/\]/\\]/g;s/\^/[\/\&:\?=_]/g;s/^||/\./g;s/^|/^/g;s/|$/\$/g;/|/d' ${FILE} >> ${ACTION} | |
echo "{ -block +handle-as-image }" >> ${ACTION} | |
sed '/^@@.*/!d;s/^@@//g;/\$.*image.*/!d;s/\$.*image.*//g;/#/d;s/\./\\./g;s/\?/\\?/g;s/\*/.*/g;s/(/\\(/g;s/)/\\)/g;s/\[/\\[/g;s/\]/\\]/g;s/\^/[\/\&:\?=_]/g;s/^||/\./g;s/^|/^/g;s/|$/\$/g;/|/d' ${FILE} >> ${ACTION} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Very fine job! Unfortunately with newer versions of sed it gives out an error
"sed: character class syntax is [[:space:]], not [:space:]"
I able to trace it back to the .[:[^:]][^:] section in the filter, but I was unable to fix it. Commenting this line out creates properly the Action file, but obviously Filter file does not get created. Please take a look at it if possible