-
-
Notifications
You must be signed in to change notification settings - Fork 573
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Plugins] Content Blocker Plugin that automatically detects and remove any Ad, Tracker, Malicious, Adult content from HTML #378
Comments
Hi @abhinavsingh, I’ve recently been considering putting together an ad-blocker for AppleTV and other devices to block things like YouTube and Twitch ads. I came across proxy.py and have been reading about the plugin framework and this looks to be a good way to do this. I thought I’d review the issues to see if anyone else was working on this, and found this issue. :-) My thoughts were to do something along the lines of:
Looking at the plugin syntax, I think I can come up with a proof of concept plugin, however the only part that isn’t immediately straightforward to me is how to enable/disable TLS interception on a per request basis... Are you able to point me in the right direction here? Any other thoughts/ideas? Thanks! |
Is it as easy as changing |
Hi @mikenye Welcome and thanks for considering Unfortunately, as of today, proxy.py/proxy/http/proxy/server.py Lines 283 to 305 in 1b0ed92
To enable selective TLS interception, we will have to modify above block of code. There are a couple of strategies we can follow:
Let me know what you think of above. Thank you!!! |
I think the plugin callback is the best method, as it is more versatile. I'd love to help with implementing this, but I'm not sure where to start as my python isn't anywhere near as strong as yours! |
@mikenye Makes sense. Do you want to initiate the content blocker plugin? If yes, let's kick start one in the current state i.e. all requests will be intercepted. I'll revisit it in a week or so to add ad-hoc TLS interception capabilities. Not much will change from plugin perspective. Plugin can simply return I have opened a separate issue to track ad-hoc TLS interception capability. #391 |
Yes! I’ll start working on this when I get home from work. :-) |
@abhinavsingh how's this for a first attempt at providing basic functionality: https://github.com/mikenye/proxy.py/blob/develop/proxy/plugin/filter_by_url_regex.py I've tested it and it works quite well, obviously the filter list will need to be hugely updated. It blocks most video ads on twitch.tv however it does cause twitch to buffer (future problem to look at). My thoughts are:
Keen for your feedback! If you're happy with this I can submit a pull request. |
@mikenye This looks perfect to start with.
Going forward we can look into stripping out ad code blocks from the response chunks (I believe this is what most adblocker plugins do, needs more investigation). By stripping out the ad code, browsers won't make any outgoing request for ads. If we return an error code for ad requests, users can experience unexpected behavior on the browser (e.g. video buffering). We'll of-course find out more as we use this plugin in real world scenario :)
👍 As this list becomes huge we can even use an underlying data structure to hold the rule list, reducing number of comparisons made per request.
I'll recommend we use industry standard schema as source of truth. If necessary, we can transform them into a convenient data structure to speed up things. I created a separate issue to add cron style feature, see #392 Thoughts here were that ad blocker plugin can configure a cron job that downloads the rule list every N hour or so. For starter, we can perform a one time download on startup or after every N requests served.
Let's do it. Happy to get this in and make this plugin robust over time. |
|
I've submitted the pull request. There are lots of commits (mostly as I was figuring out how things work), so I fully understand if you'd like me to tidy this up and resubmit. Just let me know. |
Closing this for now.
|
Describe the solution you'd like
Enabling this plugin will automatically strip any ad, tracking pixels or malicious content from HTML pages.
This plugin will asynchronously download ad block rules used for content blocking.
The text was updated successfully, but these errors were encountered: