Block YouTube Ads

pi-hole-yt-blocks.sh is design to run on systems that already have pi-hole installed.

pi-hole-yt-blocks.sh main purpose is to STOP all discovered/known yt Ads sub-domains in the youtube videos you watch, the script will instantly set the block. Will also restart/reload the db in use after its applied.

pi-hole-yt-blocks.sh for YouTube Ad blocking:

Remix of below discussion:

Installation

Use the main script (pi-hole-yt-blocks.sh) to block all or partially block Ads displayed in YT (youtube) Save to any location in your *nix system that has permission to run under a cron job or system account:

wget https://raw.githubusercontent.com/angelperezleon/pi-hole-yt-blocks.sh/main/pi-hole-yt-blocks.sh
chmod +x pi-hole-yt-blocks.sh
nano pi-hole-yt-blocks.sh
#change path to which ever path you are using:
path="/my/path/to/script"
#Run by:
sudo bash /my/path/to/script/pi-hole-yt-blocks.sh

Cron job

#Run pi-hole-yt-blocks.sh every Monday at 00:05
5 0 * * 1 /my/path/to/script/pi-hole-yt-blocks.sh >> /my/path/to/script/yt-blocks_$(date +\%d\%b\%Y-\%H\%M\%S).log 2>&1

Todo

  • add discovered subdomain into an array filename rather than have the values added into array
  • Fix a ways to run to exec or combine all into one file when doing exec bash $yt1 for example.

Troubleshooting

Why does ads still apply even do I have done my new blocks?

  • Maybe a case of restarting your pi-hole to flush/reload the changes through.

I found new ad sub-domains to block

  • You can apply these tot he finger print within the main script and run again to apply.