[Greasemonkey] How to specify script injection time

Aaron Boodman zboogs at gmail.com
Sat Jul 16 17:12:57 EDT 2005


> Pardon me if this has been suggested before, but might it be possible to
> inject user scripts into the byte stream of a loading page?  Looking at
> this digram:
> 
> http://www.mozilla.org/docs/url_load.html
> 
> It seems like there might be a few possibilities, the most obvious would
> be to replace the stock nsHTTPHandler with a custom version. 

Yep, that's exactly what I tried to do, and is definitely the sexiest
solution. I'll have to post the code at some point. Basically what I
did was wrap try to wrap the stream coming off the server and a new
nsIMemoryStream in nsIMultiplexStream. It should have been fast, even
implemented in JS because the real work continues being done in the
native C++ stream. Only a tiny bit of work at the very end gets done
in JavaScript.

Anyway, it didn't work; it crashed FF when loading Gmail. Tracked
through the C++ in a debugger and it was in an infinite loop trying to
close tags.

Once we get this release out, I will revisit it. With any luck it's
already been fixed in DeerPark :-)

- a


More information about the Greasemonkey mailing list