Return a 200 HTTP status code with a dummy document for the application

Ad Slayer

New Member
In Google News, online newspaper articles have advertisements here and there, that are successfully blocked; however, the locations of the advertisements are replaced by 404 error pages when they were expected to be loaded in an iframe:

Screenshot_2022-02-08-21-58-28-276_com.google.android.apps.magazines.jpg

The same article, loaded in a web browser doesn't have this problem, as AdGuard additionally applies element hiding to it, getting rid of the advertisement container:

Screenshot_2022-02-08-21-58-54-518_com.android.chrome.jpg

I think there is a solution to it, that would be returning a 200 HTTP status code and delivering to the requesting application a dummy file (blank web page, blank image, etc...). From the documentation, it looks like the empty modifier would do the trick, in this case, it would have to be enabled by default. Thank you! :)
 

Boo Berry

Moderator + Beta Tester
Moderator
Since AG for Android can't perform cosmetic filtering in apps except web browsers, this is to be expected when it's being blocked by DNS filtering.

Bottom line, there's nothing that can be done to hide those 404 error messages in apps when ads are blocked, nor is it possible to remove those ad placeholders.
 

Ad Slayer

New Member
If I understand, DNS filtering is performed by Adguard (in-between the Google News app and the Internet), as it acts as a VPN. In this case, instead of returning a 404 error message to the app, AdGuard could redirect the request to a local web server that would return a blank page with a 200 HTTP status. What do you think? This is what I did when I blocked web sites at the DNS level on my PC a few years ago, I had a C:\Windows\System32\drivers\etc\hosts file that contained a list of domain names redirecting to the local host 127.0.0.1 with a lightweight local web server. It should probably work a similar way on Android (I hope!), I know it's also feasible on Linux at least. At that time, if I shut down my local web browser and tried to open a social network web site, I would get a 404 error page, otherwise the local web server, when requested, always served a white page instead of the remote web page. Here's a sample of a /etc/hosts file that I have in mind:

Code:
# Blacklist of domain names
# redirected to the local host.
# Local web server returns a blank
# page with a 200 OK header status.

127.0.0.1    twitter.com
127.0.0.1    facebook.com
127.0.0.1    instagram.com
What do you think?
 
Top