summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorportix <portix@gmx.net>2011-11-23 17:40:09 +0100
committerportix <portix@gmx.net>2011-11-23 17:40:09 +0100
commit5522d09c35731e2a512710c9dfb2c6e9e9ee4a9b (patch)
treee8d803cbb92ee165df18a8e42f149ee322fd4659 /examples
parent26b4f8bf67a6f479253ec67f4b280055ba53a51f (diff)
downloaddwb-5522d09c35731e2a512710c9dfb2c6e9e9ee4a9b.zip
Resolving merge that broke everything
--HG-- branch : develop
Diffstat (limited to 'examples')
-rwxr-xr-xexamples/grab_adblocker27
1 files changed, 18 insertions, 9 deletions
diff --git a/examples/grab_adblocker b/examples/grab_adblocker
index 4486e0bd..dffecfb7 100755
--- a/examples/grab_adblocker
+++ b/examples/grab_adblocker
@@ -2,24 +2,33 @@
URL=${1:-https://easylist-downloads.adblockplus.org/easylist.txt}
-UNSUPPORTED="[\$,~]{1}(object|xbl|ping|xmlhttprequest|dtd|subdocument|document|elemhide|other|collapse|donottrack)(,|$)"
+UNSUPPORTED="[\$,~]{1}(object|xbl|ping|xmlhttprequest|dtd|document|subdocument|elemhide|other|collapse|donottrack)(,|$)"
CONFIG=${XDG_CONFIG_HOME}/dwb/settings
-DEST=( $(sed '/adblocker-filterlist/!d;s/^.*=//' ${CONFIG}) )
-if [[ ! ${DEST} ]]; then
- echo "No setting 'adblocker-filterlist' found, exiting."
- exit 1
+TMP=$(mktemp)
+wget -O ${TMP} ${URL} &>/dev/null
+declare PROFILE
+while read; do
+ if [[ ${REPLY} =~ ^\[ ]]; then
+ PROFILE=${REPLY:1:$((${#REPLY}-2))}
+ fi
+ if [ "${PROFILE}" = "default" ] && [[ ${REPLY} =~ ^adblocker-filterlist ]]; then
+ DEST=${REPLY//*=/}
+ break
+ fi
+done < ${CONFIG}
+
+if [ ! ${DEST} ]; then
+ DEST=${XDG_CONFIG_HOME}/dwb/adblock_default
+ echo "No setting 'adblocker-filterlist' found for profile default, using '${DEST}'"
+ sed -i "0,/adblocker-filterlist/s#^adblocker-filterlist=.*#adblocker-filterlist=${DEST}#" ${CONFIG}
fi
echo "Saving filterlist as ${DEST}"
-TMP=$(mktemp)
-wget -O ${TMP} ${URL} &>/dev/null
BEFORE=( $(wc -l "${TMP}") )
sed -r "/${UNSUPPORTED}/d" "${TMP}" > ${DEST}
rm ${TMP}
-
AFTER=( $(wc -l "${DEST}") )
-
printf "Removed $((${BEFORE} - ${AFTER})) unsupported of ${BEFORE} filters\n"