Parsing HTML before rendering and loading

Talk about add-ons and extension development.
Posts: 2
Joined: January 9th, 2009, 4:02 am

Post Posted January 9th, 2009, 4:12 am

Hi all,

I want to develop an add-on which will
parse the html received from server --> Change the html --> and give it to firefox rendering engine for rendering and loading.

I want the page to load only once.
For this to happen ,is there a position where i can get that html before loading?
Can anyone guide me to achieve this?


Posts: 1
Joined: January 9th, 2009, 11:04 am

Post Posted January 9th, 2009, 11:05 am

I would also love to hear if anyone has figured this out.

Posts: 890
Joined: October 20th, 2003, 1:24 pm

Post Posted January 10th, 2009, 3:52 am

I would think that you would have to do something like:
1. Catch the initial page request (probably via a request observer).
2. Cancel the initial request and all of the requests associated with it (using the request's loadGroup).
3. Load the page via XMLHTTPRequest.
4. Modify the page html.
5. Store the modified page to the cache (I am unsure how).
6. Tell the browser to load the page from the cache (using aBrowser.loadURI with the appropriate flags set).
7. All requests for page content (images,etc.) should automatically be initiated when you load the modified page if the content is not already present in the cache.

Posts: 582
Joined: July 12th, 2004, 7:20 pm

Post Posted January 10th, 2009, 7:35 pm ... p-traffic/

I think this link is what your after. I have not played with it myself so I'm not sure how effective\efficient it is.

Here's a post on it...not much info though.
"nsITraceableChannel fragmentation - Mozilla Firefox 3.0.4"

Posts: 2
Joined: January 9th, 2009, 4:02 am

Post Posted January 10th, 2009, 8:55 pm

thanks guys for replying.
i will definitely post if this task is completed.

Posts: 128
Joined: January 20th, 2008, 4:04 am

Post Posted January 19th, 2009, 6:03 am

Do you have any results? I have the same task.

Posts: 24
Joined: March 20th, 2009, 2:34 pm

Post Posted March 20th, 2009, 2:43 pm

Thanks Bloodeye, I've been wondering how to do this :)

I have a lot of reading to do now :P

Posts: 231
Joined: November 23rd, 2009, 10:37 am

Post Posted June 29th, 2010, 2:51 pm

I could need this too, namely to remove some stupid and poorly programmed JavaScripts. (but they're inline, thus not implemented via src="....js")

This humble code (obviously) does not work:

Code: Select all
var scr3node = content.document.getElementsByTagName("script")[2];
var scr3data = null;
if (scr3node != undefined)
      scr3data = scr3node.innerHTML;
      // trying to treat the innerHTML as random text (since DOM functions do not work [no HTML])
      // check for inline javascript and make our transformations!
        var scr3datanew = scr3data.replace (/callRoutine\(\'1\'\)/, "alert (\"just a test\")");
        scr3node.innerHTML = scr3datanew;

Well I thought it could work, since it's no auto-executed JavaScript but invoked via onClick() on a button later, so I *was* quite sure you could replace some lines there. But that was not the case...the JS was always in initial state.

Another huge "problem" is that Honza decided to close the blog comments (sorry, but WHAT a stupid idea is this!)

So nobody can give any hints, bug fixes nor anything else.
Nor could he add a post with a sample add-on which will eventually help us all.

Return to Extension Development

Who is online

Users browsing this forum: No registered users and 2 guests