I need a way to process HTML before it's actually loaded and parsed by Mozilla. Is there any content listener that I can use in my Firefox extension?
Asked
Active
Viewed 745 times
2 Answers
0
Do you mean something like greasemonkey? Sorry, I don't know enough about Firefox extensions. The Greasemonkey website is blocked here in China and my VPN does not work at the moment, but maybe they are open source. Then you can see what they do, if writing a greasemonkey skript is not what you want.

erikbstack
- 12,878
- 21
- 81
- 115
-
Greasmonkey starts processing DOM model after "DOMContentLoaded" event is triggered. What I need is to intercept HTML content **before** Mozilla loads and parses it. But you're right, I need something similar to this extension, with the exception that it works at earlier stage. – Michael Spector Sep 27 '10 at 13:03
0
Add an Event Listener to the gBrowser global object, making sure to set usecapture to true. You could also intercept the response.

Fábio
- 3,291
- 5
- 36
- 49
-
BTW, nsIHttpChannel only allows to modify HTTP headers, not content. – Michael Spector Sep 27 '10 at 17:04
-
1The Http Channel also implements other interfaces, such as nsIRequest, which might do what you want. This took me a long time to realize. – Tyler Sep 28 '10 at 03:39
-
If you set usecapture to true the event will be fired before the browser process it. Like MatrixFrog said, nsIHttpChannel inherits from nsIRequest. – Fábio Aug 02 '11 at 11:17