Top Related Projects
A black hole for Internet advertisements
Network-wide ads & trackers blocking DNS server
🔒 Consolidating and extending hosts files from several well-curated sources. Optionally pick extensions for porn, social media, and other categories.
Automatically updated, moderated and optimized lists for blocking ads, trackers, malware and other garbage
Curated and well-maintained hostfile to block ads, tracking, cryptomining, and more! Updated regularly. ⚡🔒
Quick Overview
The kboghdady/youTube_ads_4_pi-hole repository is a collection of scripts and lists designed to block YouTube advertisements when using Pi-hole, a network-wide ad blocker. It aims to enhance the ad-blocking capabilities of Pi-hole specifically for YouTube content, improving user experience by reducing interruptions from ads.
Pros
- Specifically targets YouTube ads, which can be challenging to block
- Regularly updated to keep up with changes in YouTube's ad delivery system
- Compatible with Pi-hole, a popular and effective network-wide ad blocker
- Open-source project allowing for community contributions and improvements
Cons
- May occasionally block legitimate content or features on YouTube
- Requires manual updates and maintenance to stay effective
- Effectiveness can vary depending on YouTube's frequent changes to ad delivery
- May not work for all types of YouTube ads, especially newer formats
Getting Started
-
Clone the repository:
git clone https://github.com/kboghdady/youTube_ads_4_pi-hole.git
-
Add the blocklists to your Pi-hole configuration:
- Go to Pi-hole admin interface
- Navigate to "Adlists"
- Add the following URLs:
https://raw.githubusercontent.com/kboghdady/youTube_ads_4_pi-hole/master/youtubelist.txt https://raw.githubusercontent.com/kboghdady/youTube_ads_4_pi-hole/master/crowed_list.txt
-
Update your gravity list:
pihole -g
-
(Optional) Set up automatic updates using the provided script:
chmod +x youtube.sh ./youtube.sh
-
Add a cron job to run the script periodically:
crontab -e 0 */12 * * * /path/to/youtube.sh
Competitor Comparisons
A black hole for Internet advertisements
Pros of Pi-hole
- More comprehensive ad-blocking solution for entire network
- Actively maintained with regular updates and community support
- Offers additional features like DHCP server and DNS caching
Cons of Pi-hole
- Requires more setup and configuration
- May occasionally block legitimate content, requiring whitelist adjustments
- Not specifically optimized for YouTube ad blocking
Code Comparison
Pi-hole (gravity.sh):
gravity_ShowStatusBefore() {
local str="Neutrino emissions detected..."
printf "%s %s\n" "${INFO}" "${str}"
}
YouTube_ads_4_pi-hole (youtube.sh):
youtube_regex='r[0-9]+---sn-[a-z0-9]+\.googlevideo\.com'
grep -E $youtube_regex | awk '{print $2}' | sort | uniq >> "${youtube_file}"
The Pi-hole code snippet shows a function for displaying status messages, while the YouTube_ads_4_pi-hole code focuses on regex pattern matching for YouTube ad domains. Pi-hole's codebase is more extensive and modular, reflecting its broader functionality, whereas YouTube_ads_4_pi-hole is more specialized for YouTube ad blocking.
Network-wide ads & trackers blocking DNS server
Pros of AdGuardHome
- More comprehensive ad-blocking solution with DNS-level filtering
- User-friendly web interface for easy configuration and management
- Supports multiple platforms and devices beyond just Pi-hole
Cons of AdGuardHome
- May require more system resources compared to youTube_ads_4_pi-hole
- Potentially more complex setup process for users new to DNS-level ad blocking
Code Comparison
youTube_ads_4_pi-hole:
def download_file(url):
local_filename = url.split('/')[-1]
with requests.get(url, stream=True) as r:
with open(local_filename, 'wb') as f:
shutil.copyfileobj(r.raw, f)
return local_filename
AdGuardHome:
func (d *DNSFilter) handleDNSRequest(ctx context.Context, req *dns.Msg) (*dns.Msg, error) {
if len(req.Question) != 1 {
return d.Resolver.Resolve(ctx, req)
}
// ... (additional logic)
}
The code snippets show different approaches: youTube_ads_4_pi-hole focuses on downloading files for blocklists, while AdGuardHome handles DNS requests directly. AdGuardHome's code is more complex, reflecting its broader functionality.
🔒 Consolidating and extending hosts files from several well-curated sources. Optionally pick extensions for porn, social media, and other categories.
Pros of hosts
- Broader scope: Blocks a wide range of ads, trackers, and malware across various websites and services
- Regularly updated: Maintained by a large community, ensuring frequent updates and additions
- Customizable: Offers different variants (e.g., unified, social, gambling) to suit user preferences
Cons of hosts
- Less focused: May not be as effective for YouTube-specific ad blocking
- Potential over-blocking: Could inadvertently block legitimate content due to its comprehensive nature
- Resource-intensive: Larger blocklist may consume more system resources
Code comparison
hosts:
0.0.0.0 0.0.0.0
0.0.0.0 1phads.com
0.0.0.0 2mdn.net
0.0.0.0 2o7.net
0.0.0.0 4dsply.com
youTube_ads_4_pi-hole:
r1---sn-4g5ednsl.googlevideo.com
r1---sn-4g5ednsr.googlevideo.com
r1---sn-4g5ednsz.googlevideo.com
r1---sn-4g5ednee.googlevideo.com
r1---sn-4g5edn7e.googlevideo.com
The hosts project uses a more general approach, blocking various domains, while youTube_ads_4_pi-hole specifically targets YouTube ad servers. This focused approach may be more effective for YouTube ad blocking but less versatile for general ad blocking across different platforms.
Automatically updated, moderated and optimized lists for blocking ads, trackers, malware and other garbage
Pros of hosts-blocklists
- More comprehensive blocking list, covering a wider range of domains and trackers
- Regular updates and maintenance, ensuring up-to-date protection
- Suitable for general ad and tracker blocking across various platforms
Cons of hosts-blocklists
- May cause over-blocking, potentially affecting some legitimate services
- Not specifically optimized for YouTube ad blocking
- Requires more system resources due to larger blocklist size
Code Comparison
hosts-blocklists:
0.0.0.0 0.fls.doubleclick.net
0.0.0.0 0.gvt0.com
0.0.0.0 1-1.b.cdn13.com
0.0.0.0 1-cl0ud.com
0.0.0.0 1.bp.blogspot.com
youTube_ads_4_pi-hole:
r1---sn-4g5e6ns7.googlevideo.com
r1---sn-4g5edne7.googlevideo.com
r1---sn-5hne6ns6.googlevideo.com
r1---sn-5hnekn7l.googlevideo.com
r1---sn-5uaezn6y.googlevideo.com
The hosts-blocklists repository uses a more traditional hosts file format, blocking a wide range of domains. In contrast, youTube_ads_4_pi-hole focuses specifically on YouTube ad-serving domains, using a different format tailored for Pi-hole configurations.
Pros of GoodbyeAds
- Broader scope, blocking ads across multiple platforms and apps
- More frequently updated, with regular commits and releases
- Larger community and more contributors
Cons of GoodbyeAds
- May be overly aggressive, potentially blocking non-ad content
- Requires more setup and configuration for specific use cases
- Less focused on YouTube ads compared to youTube_ads_4_pi-hole
Code Comparison
youTube_ads_4_pi-hole:
def download_file(url):
local_filename = url.split('/')[-1]
with requests.get(url, stream=True) as r:
with open(local_filename, 'wb') as f:
shutil.copyfileobj(r.raw, f)
return local_filename
GoodbyeAds:
#!/bin/bash
echo "Downloading and processing hosts files..."
curl -sS https://raw.githubusercontent.com/jerryn70/GoodbyeAds/master/Hosts/GoodbyeAds.txt | grep -v "#" | sort -u > GoodbyeAds.txt
echo "Hosts file updated successfully!"
The code snippets show different approaches: youTube_ads_4_pi-hole uses Python for file downloading, while GoodbyeAds employs a bash script for downloading and processing hosts files. This reflects the broader scope and more general-purpose nature of GoodbyeAds compared to the more focused approach of youTube_ads_4_pi-hole.
Curated and well-maintained hostfile to block ads, tracking, cryptomining, and more! Updated regularly. ⚡🔒
Pros of blacklist
- More comprehensive, covering a wider range of ad domains beyond YouTube
- Regularly updated with community contributions
- Includes separate lists for different purposes (e.g., Facebook, tracking, crypto)
Cons of blacklist
- May block some legitimate content, requiring more manual whitelisting
- Not specifically optimized for YouTube ads
- Potentially higher risk of false positives due to broader coverage
Code comparison
youTube_ads_4_pi-hole:
#!/bin/bash
# YouTube ads blocking script for Pi-hole
curl -s https://raw.githubusercontent.com/kboghdady/youTube_ads_4_pi-hole/master/black.list | sudo tee -a /etc/pihole/blacklist.txt > /dev/null
pihole -g
blacklist:
#!/bin/bash
# Add domains from anudeepND's blacklist to Pi-hole
curl -s https://raw.githubusercontent.com/anudeepND/blacklist/master/adservers.txt | sudo tee -a /etc/pihole/blacklist.txt > /dev/null
pihole -g
The code snippets show similar approaches for adding domains to Pi-hole's blacklist, but youTube_ads_4_pi-hole focuses specifically on YouTube ad domains, while blacklist includes a broader range of ad servers.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Blocking status :white_check_mark: --Blocking Working good )
Buy me a coffee via paypal
Buy me Coffee with XLM GDQP2KPQGKIHYJGXNUIYOMHARUARCA7DJT5FO2FFOOKY3B2WSQHG4W37
Buy me Coffee with BitCoin 36fD957SDWHJYYzuH2xmceJ6T2qE9vNiV4
Buy me Coffee with XRP rw2ciyaNshpHe7bCHo4bRWq6pqqynnWKQg
Buy me Coffee with BAT 0xb9f4845dbEd1FB1Dae90D8e203037B5623B66666
Buy me Coffee with XMR
46RGtwR2gS3UsjCtmzX7mGAXsXj6ui4ZbiwRhbeMuB7jHYUHhxot5JgRVwVT3dpnQqRk9qsd4N6NXhsjREKhfMmCUTMffLq
Script to add YouTube Ads DNS to Pi-hole black list
You can add this link to your gravity list by going to
http://piholeIPAddress/admin/groups-adlists.php
https://raw.githubusercontent.com/kboghdady/youTube_ads_4_pi-hole/master/youtubelist.txt
and the list added by the crowed Keep in mind the crowd list it is all DNS gathered by the crowd WITHOUT filtering the block DNS
https://raw.githubusercontent.com/kboghdady/youTube_ads_4_pi-hole/master/crowed_list.txt
Also, add script to update the gravity list containing these lines :
pihole -g
sudo pihole restartdns
if you experience youtube loops or blocking to the actual video while using the gravity
Please clear the gravity domain list as it sometimes keep the ignore list :
/usr/bin/sqlite3 /etc/pihole/gravity.db "delete from gravity where domain like '%googlevideo.com%' "
pihole -g
How the script works
- It will get the black.list from my github which is updated daily or every two days
- It will update both the black.list and blacklist.txt files where the blocking of pihole happens
- It will remove any dupiclates
it will be more effective if you add it the crontab
Steps:
1- Download the script from github using this command :
git clone https://github.com/kboghdady/youTube_ads_4_pi-hole.git
cd youTube_ads_4_pi-hole
2- Change where the repo directory in youtube.sh
repoDir='/pi/youTube_ads_4_pi-hole'
3- Make the script executable
sudo chmod a+x youtube.sh
4- Create a scheduled task to run the script:
sudo crontab -e
5-Add this line to make it runs every 1 hour, but you can change it to whatever you like
0 */1 * * * sudo /home/pi/youTube_ads_4_pi-hole/youtube.sh >/dev/null
Where the script location is /home/pi/youTube_ads_4_pi-hole/youtube.sh
more information about crontab https://crontab.guru
if you want to delete all blacklist from your database in case of issues
/usr/bin/sqlite3 /etc/pihole/gravity.db "delete from domainlist where domain like '%googlevideo.com%' "
NOTE : if you are using the default pihole gravity make sure to whitelit s.youtube.com which blocks the videos
this default list has it : https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts
Top Related Projects
A black hole for Internet advertisements
Network-wide ads & trackers blocking DNS server
🔒 Consolidating and extending hosts files from several well-curated sources. Optionally pick extensions for porn, social media, and other categories.
Automatically updated, moderated and optimized lists for blocking ads, trackers, malware and other garbage
Curated and well-maintained hostfile to block ads, tracking, cryptomining, and more! Updated regularly. ⚡🔒
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot