This project provides a simple, self-hosted solution to block ads on YouTube by embedding videos in a locally hosted player. It consists of:
- A browser extension that detects YouTube video links and redirects them to the embedded player.
- A local Flask server that hosts and plays the video without ads.
✅ Ad-Free YouTube Videos - Watch videos without interruptions.
✅ Privacy-Focused - No third-party extensions tracking your data.
✅ Lightweight & Fast - Minimal setup, just a few lines of code.
✅ Runs Locally - No external dependencies or API calls.
git clone https://github.com/yourusername/youtube-adblocker.git
cd youtube-adblocker/serverYou have two options to set up the local server: manual installation or Docker.
Ensure you have Python installed, then run:
pip install flask flask-corsIf you prefer using Docker, you can build and run the server in a container. To build the server side code. Docker must be running.
make buildTo run the server
python server.pymake runBy default, the server runs on http://localhost:5000.
If using Docker, the server will already be running in the container.
- Open your browser and go to
chrome://extensions/(or Edge's equivalent). - Enable Developer Mode (top-right corner).
- Click Load Unpacked and select the
extension/folder. - The extension is now active! 🎉
- Open any YouTube video.
- The extension detects the link, closes the tab, and opens the ad-free embedded player.
- Enjoy a seamless, uninterrupted viewing experience! 🎥
- Other features like like, subscribe, comments, and related video's are not present.
- The browser extension listens for YouTube video links.
- When a video is opened, it automatically redirects it to the localhost server.
- The Flask server embeds the video that comes without ads and serves it locally.
Since YouTube doesn’t display ads on embedded videos, this trick effectively blocks them. 🚀
The extension is designed for Chromium-based browsers (Chrome, Edge, Brave, etc.).
This project is for educational purposes only. Use at your own discretion.
YouTube updates its platform frequently. While this method works now, it may require future tweaks.
This project is licensed under the MIT License.
Feel free to fork this repository, submit pull requests, or open issues for improvements. Let’s make it even better! 🚀
Special thanks to the open-source community for making learning and innovation possible! ❤️