views:

42

answers:

4

For each of the modern browsers are there well known hooks I can tie into so that I can write an Internet filter while browsing, like an interface where I can write implementations for these types of events:

OnBeginSurf(URL) {
    // check URL to see if goes to porn site
}    
OnContentFinishedDownloading(HTML) {
    // check HTML for "bad" content
}

I imagine for IE that I'd write some COM code? I assume Firefox and Safari have some well known interfaces for these things?

Can anyone point me to some web pages that describe this? I couldn't find much by Googling...

+2  A: 

Don't try to hook into the browsers to write a content filter.

Write a proxy server. Each browser will HAVE to request web content through your proxy server which will be able to inspect and filter content before it returns to the browser. You get to write your code once and have it work on anything that requests web content.

Justin Niessner
This is the only reasonable approach, individual plugins would quadruple the amount of work (the OP overlooked chrome which has a bigger market share than safari).
mikerobi
If I write a proxy server, what's to stop kids from re-configuring the proxy settings to bypass it or something? Is there something lower in the operating system so that all TCP/IP traffic has to go through it?
Pete Alvin
@Pete Alvin - Lock down the OS so the kids can't access the proxy server settings. Remember, you're only going to stop the ones that don't want to try to get around you. There is no perfect way to stop everybody from getting places they shouldn't go. If you're trying to filter traffic for kids, why not check out one of the commercial filtering packages?
Justin Niessner
+1  A: 

For IE these are the BeforeNavigate2, NavigateComplete2 and DocumentComplete events on the DWebBrowserEvents2 dispinterface of the web browser control.

Franci Penov
One thing to watch out for: when the user refreshes the page in IE, you don't get another complete set of navigation events.
jeffamaphone
That is correct. Unfortunately, IE events model is broken in refresh. It's possible to hook on refresh by using ProgressChange(0,0), but it's not possible to distinguish between refresh and navigate on that event.
Franci Penov
A: 

Mozilla Developer Center

Rob
RTFM isn't a good answer, and the MDC is especially hard to find stuff in without some sort of guidence.
jeffamaphone
Didn't say that, and he said he only Googled for the info but not looked at the MDC. For those who find the web difficult to use, links to this topic and all references are at the bottom. Use the mouse wheel and scroll down. Then click the left button to find your area of interest. Or, you can do what I did, and enter the search topic in the search box. For more information on how to do this, ask any 12 year old child.
Rob
@jeffamaphone, I gave far more help than you have.
Rob
A: 

While I agree with Justin Niessner, that a proxy server is the way to go, but if you goal is protecting children from porn, I think you would probably be better served by using an existing product.

A lot of time and energy has gone into engineering web filters. In addition to compiling large database of prohibited sites, you will need to develop heuristics to guess if an unknown site is safe, advanced filters also do image analysis to determine if an image contains nudity. You also need heavy testing to make sure that the protect can't be easily disabled or circumvented, and constant updates to deal with new sources of adult content.

Unless you have a teem of developers, or plan on working full time for several years, you will have a hard time offering the level of protection of off the shelf solutions.

mikerobi