tags:

views:

38

answers:

3

When a request is sent to a Web site, I'd like to edit some code to the returned page and the edited page is loaded to the browser. For example, when I send a request to statckoverflow.com, I'd like to change all the letter to upper case in the returned Web page, and then the edited page is loaded to my browser. (It's just an example to change the case.)

I'm thinking to use a proxy on my machine. Is there any implemented proxy that can do this? Or is there any other way?

The edition operation is going to be complicated. So, the proxy should be able to have some scripts deployed.

+1  A: 

You can do this with Squid. I recommend against implementing your own proxy.

Yes, a proxy is the right tool- you could also use a web browser extension.

Borealid
@Borealid, which browser extension works in my scenario?
Paul
@Paul Whatever you want to do could be done either with a hand-written extension or a GreaseMonkey script.
Borealid
+1  A: 

If you're running Windows, you can use Fiddler. Choose Customize Rules from the Tools menu and paste the following code into the onBeforeResponse function in order to replace ul tags with ol ones :

if (oSession.HostnameIs("www.example.com") && oSession.oResponse.headers.ExistsAndContains("Content-Type","text/html")){
  oSession.utilDecodeResponse();
  oSession.utilReplaceInResponse('<ul>','<ol>');
}

Here you can find more Fiddler Script examples.

If you're running *nix, you can use Privoxy

rjack
@rjack, by what do you mean *nix?
Paul
@Paul, *nix is a short and common way to refer to unix-like systems, including FreeBSD, NetBSD, OpenBSD, Darwin (i.e. Mac OS X), Linux, Minix, etc. (list would be endless). See http://en.wikipedia.org/wiki/Unix-like
rjack
+1  A: 

Yes, you can use a proxy to handle this for you. I'm the developer of yProxy, and I have to tell you that the #1 issue with using a proxy is configuring it.

For a web proxy, each web browser must be configured unless you have access to the gateway computer, then you can make it transparent (with something similar to Squid).

If you're using it for yourself or releasing it only to technically minded folk, that's great, but if you're going to release this to the masses, you'll have to make it very simple for the end user.

You might want to hook into a lower level, similar to firewall software, so that the user does not have to configure their browser.

Marcus Adams