I been working on own makeing my own Web Browser, and would like to know how whould I go about blocking ads, just wondering is there any examples around, or can someone give me some ideas
Thanks
Printable View
I been working on own makeing my own Web Browser, and would like to know how whould I go about blocking ads, just wondering is there any examples around, or can someone give me some ideas
Thanks
Rather than loading the page directly in the webbrowser control, save it to a file, then load the file as text (using Open etc) and edit out the parts that you consider to be ad's, save the file, and finally load that edited file in the webbrowser control.
I need to block the ads from ever loading on the page, I am useing the Web Browser control in VB, sorry I should have pointed that out first. I can block popup windows, but I need to block ads like loading on the pages. banners and things.
I suggest you use the hosts file. You can block IPs, and you can even add entries to it with a little VB I/O.
This is probably the only way you're going to completely block ads from ever loading in the IE/webbrowser control.
There's also PeerGuardian, which has an advertisement block list. PeerGuardian works pretty much exactly like a hosts file, make lists of IP, and it blocks them.
With my hosts and Peerguardian IPs combined, I'm probably blocking about 800 million IPs. :)
What's great, is both these methods are system-wide blocks. Not per browser, or whatever. No matter what application I use, the connections are blocked either incoming or outgoing.
If you're looking for a good ad-blocking browser, Opera is great. It has built-in content blocking with works on specific URLs, not just IPs. And often it restructures the page to 'remove' the gaps left by the AD-void.
The webbrowser control is kind of a joke.... It's basically IE, stripped down.
Check out AdBlock Plus addon for firefox, examine how it works, notice the AD lists it uses to 'detect' ads.
Think I found a way how to sort of doing using BeforeNavigate2 I tested it on a ads and it seemed to remove it from the page.
Anyway I left the code below incase someone else ever needs to do something like this.
vb Code:
Private Sub WebView1_BeforeNavigate2(ByVal pDisp As Object, URL As Variant, Flags As Variant, TargetFrameName As Variant, PostData As Variant, Headers As Variant, Cancel As Boolean) 'Change ads to what ever you can to cancel out eg doubleclick If InStr(1, URL, "ads", vbTextCompare) Then Cancel = True Else Cancel = False End If End Sub
Thanks for all the help, I also check out that hosts idea to.