Results 1 to 7 of 7

Thread: [RESOLVED] WebBrowser Block ads

  1. #1

    Thread Starter
    Fanatic Member BenJones's Avatar
    Join Date
    Mar 2010
    Location
    Wales UK
    Posts
    814

    Resolved [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

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    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.

  3. #3

    Thread Starter
    Fanatic Member BenJones's Avatar
    Join Date
    Mar 2010
    Location
    Wales UK
    Posts
    814

    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.

  4. #4
    Fanatic Member FireXtol's Avatar
    Join Date
    Apr 2010
    Posts
    874

    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.

  5. #5
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    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.

  6. #6
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: WebBrowser Block ads

    Quote Originally Posted by BenJones View Post
    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.

  7. #7

    Thread Starter
    Fanatic Member BenJones's Avatar
    Join Date
    Mar 2010
    Location
    Wales UK
    Posts
    814

    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:
    1. 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)
    2.     'Change ads to what ever you can to cancel out eg doubleclick
    3.     If InStr(1, URL, "ads", vbTextCompare) Then
    4.         Cancel = True
    5.     Else
    6.         Cancel = False
    7.     End If
    8. 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
  •  



Click Here to Expand Forum to Full Width