|
-
Apr 24th, 2010, 10:32 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] WebBrowser Block ads
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
-
Apr 24th, 2010, 10:45 AM
#2
Re: WebBrowser Block ads
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.
-
Apr 24th, 2010, 11:18 AM
#3
Thread Starter
Fanatic Member
Re: WebBrowser Block ads
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.
-
Apr 24th, 2010, 12:02 PM
#4
Re: WebBrowser Block ads
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.
Last edited by FireXtol; Apr 24th, 2010 at 12:10 PM.
-
Apr 24th, 2010, 12:05 PM
#5
Re: WebBrowser Block ads
Check out AdBlock Plus addon for firefox, examine how it works, notice the AD lists it uses to 'detect' ads.
Last edited by baja_yu; Apr 24th, 2010 at 12:09 PM.
-
Apr 24th, 2010, 12:26 PM
#6
Re: WebBrowser Block ads
 Originally Posted by BenJones
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. ...
That is what I assumed, and it is what my suggestion was based on.
-
Apr 24th, 2010, 10:54 PM
#7
Thread Starter
Fanatic Member
Re: WebBrowser Block 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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|