diff options
Diffstat (limited to '.scripts/adblock')
-rwxr-xr-x | .scripts/adblock | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/.scripts/adblock b/.scripts/adblock index 3fdbb97..a6d7c44 100755 --- a/.scripts/adblock +++ b/.scripts/adblock @@ -1,9 +1,21 @@ #!/bin/bash -if grep -Fxq "##START" /etc/hosts; then - sudo sed -i "/##START/,/##END/s/#\(.\)/\1/" /etc/hosts +if grep -xq "^##START" /etc/hosts; then + echo "enabling..." + sudo sed -i "/^##START/,/^##END/s/#\(.\)/\1/" /etc/hosts + sudo mv /etc/opensnitchd/adblock/stevenblack /etc/opensnitchd/adblock/stevenblack.txt + while true; do + sleep 0.5s + dig adservice.google.com &>/dev/null || break + done notify-send "Enabled adblock!" else - sudo sed -i "/#START/,/#END/s/./#&/" /etc/hosts + echo "disabling..." + sudo sed -i "/^#START/,/^#END/s/./#&/" /etc/hosts + sudo mv /etc/opensnitchd/adblock/stevenblack.txt /etc/opensnitchd/adblock/stevenblack + while true; do + sleep 0.5s + dig adservice.google.com &>/dev/null && break + done notify-send "Disabled adblock!" fi |