Parsing HTML before rendering and loading

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

Parsing HTML before rendering and loading

Post by addoner »

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?

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

Re: Parsing HTML before rendering and loading

Post by udfalkso »

I would also love to hear if anyone has figured this out.
brody
Posts: 890
Joined: October 20th, 2003, 1:24 pm

Re: Parsing HTML before rendering and loading

Post by brody »

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.
Bloodeye
Posts: 582
Joined: July 12th, 2004, 7:20 pm

Re: Parsing HTML before rendering and loading

Post by Bloodeye »

http://www.softwareishard.com/blog/fire ... 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"
viewtopic.php?f=19&t=984665
addoner
Posts: 2
Joined: January 9th, 2009, 4:02 am

Re: Parsing HTML before rendering and loading

Post by addoner »

thanks guys for replying.
i will definitely post if this task is completed.
leska
Posts: 128
Joined: January 20th, 2008, 4:04 am
Contact:

Re: Parsing HTML before rendering and loading

Post by leska »

Do you have any results? I have the same task.
vaer
Posts: 24
Joined: March 20th, 2009, 2:34 pm

Re: Parsing HTML before rendering and loading

Post by vaer »

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

I have a lot of reading to do now :P
globalplayer
Posts: 231
Joined: November 23rd, 2009, 10:37 am

Re: Parsing HTML before rendering and loading

Post by globalplayer »

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.
Post Reply