Forum Moderators: open

Message Too Old, No Replies

how to insert htmlcode in browser

ie or moz

         

Xuefer

2:24 am on Dec 1, 2002 (gmt 0)

10+ Year Member



in client site
IE allow me to use a custom CSS for every page i browse
is there any way that i can insert custom HTMLcode?

do i have to write a proxy between my browser and http-servers, and insert HTMLcode with it?

or a plugin for browser?

tedster

6:08 am on Dec 1, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



No, as far as I know you cannot modify the HTML of a page on the web so that your browser uses the customized version rather than what the server sends.

andreasfriedrich

2:03 pm on Dec 1, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There sure are ways to do that. You suggest two possibilities yourself: a proxy server or a browser plugin.

This is a proxy server that will replace all occurences of Aaron on a web page with Nick ;)

#!/usr/bin/perl -w 
#
use strict;
use HTTP::Daemon;
use HTTP::Status;
use LWP::UserAgent;
#
my $ua = new LWP::UserAgent;
my $server = HTTP::Daemon->new(LocalPort => 8080)
or die "Couldnīt start server\n";
#
while (my $client = $server->accept) {
CONNECTION:
while (my $answer = $client->get_request) {
if ($answer->method eq 'GET' and $answer->uri =~ /http:/) {
my $rq = new HTTP::Request('GET', $answer->url, $answer->headers);
my $r = $ua->request($rq);
if ($r->headers->header('Content-Type') =~ 'text/html') {
my $html = $r->content;
$html =~ s/Aaron/Nick/g;
$r->content($html);
}
$client->send_response($r);
} else {
$client->send_error(RC_FORBIDDEN);
}
}
$client->close;
undef $client;
}

Xuefer

2:49 pm on Dec 1, 2002 (gmt 0)

10+ Year Member



cool~
i was able to imagine how a proxy do this work.
but thought it would be complex to write using script, but... it's really simple by perl+some package given by your sample

but any tips about how a plugin do it? i did lookup msnd but didn't noticed anyting about inserting htmlcode/script by plugin.

andreasfriedrich

10:48 pm on Dec 1, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



A real production strength proxy would need to fork children to handle requests concurrently and it would need to handle other request methods than just GET. But the basic idea is very simple and even with those additions it will not get terribly complex.

As for the browser plugin I donīt really remember how to do it, but I think I remember that there is a way to register a callback that get called prior to rendering the html code in IE. I tried to find some code where I used that feature and that I wrote two years ago but couldnīt find it. I know there is something about that in MSDN but donīt have the time to look.

Sorry that I canīt be of more help.

Andreas