Is is possible to modify the html before it is loaded/executed in the browser?
To add functions to a web site out of my control I want to change a javascript from the original to my own.
E.g: in the html the browser load I would like to change:
<script src="/java.js" type="text/javascript"></script>
to:
<script src="http://mysite/java.js" type="text/javascript"></script>
I can not just load my own page as I need to login to the site for it to work and the site use cookies to check im logged in.
I load the modifyed code like this:
Var
aStream : TMemoryStream;
begin
if Assigned(WebBrowser1.Document) then
begin
aStream := TMemoryStream.Create;
try
aStream.LoadFromFile(Root + 'main.htm');
aStream.Seek(0, soFromBeginning);
(WebBrowser1.Document as IPersistStreamInit).Load(TStreamAdapter.Create(aStream));
finally
aStream.Free;
Timer1.Enabled := True;
end;
HTMLWindow2 := (WebBrowser1.Document as IHTMLDocument2).parentWindow;
end;
This used to work, but the site added a login and now the requests the javascript do get access denied. I have tried to navigate to the login and login before I load my own code, but I still get access denied.