#!/bin/sh

# adaway_hosts.sh
# 2023-11-05
# by Gernot Walzl

# This script is used to block advertisements on Android phones.
# It does the same as running AdAway with root privileges but without giving
# root privileges to the app.
# https://adaway.org/

# To enable developer options on the phone, tap the Build Number seven times
# under Settings > About. USB debugging (and root debugging) can then
# be enabled under System > Developer Options.
# https://developer.android.com/studio/debug/dev-options

# AdAway official hosts
# https://adaway.org/hosts.txt
#
# Pete Lowe blocklist hosts
# https://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&showintro=0&mimetype=plaintext

# To install adb on Debian-based distributions, run the following command:
# sudo apt install adb

adb root
adb remount
adb shell "
if [ ! -f /etc/hosts.orig ]; then
  mv /etc/hosts /etc/hosts.orig
fi
curl https://adaway.org/hosts.txt -o /etc/hosts
"