I am creating a webview which loads some sites. I want to block the ads in these sites from appearing in the webview. I want it for both http and https sites. Actually i am able to do it for http sites by javascript injection.But this method will not work for https. Is there any way to do this?
Access the website(www.adwaresite.com) using some proxy server that you own. You can create one very easily in Google app engine.
Prefetch the html of www.adwaresite.com on your server and add the base tag of www.adwaresite.com at the top of the html and send it to the android webview over http
<head>
<base href="http://www.w3schools.com/images/" target="_blank">
</head>
<body>
<img src="stickman.gif" width="24" height="39" alt="Stickman">
<a href="http://www.w3schools.com">W3Schools</a>
</body>
Note the base tag in above code. Base tag helps to add domain to the relative urls inside html. So instead of picking the domain from the address bar , it uses this base domain specified at the top
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With