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
Parsing HTML before rendering and loading
-
- Posts: 1
- Joined: January 9th, 2009, 11:04 am
Re: Parsing HTML before rendering and loading
I would also love to hear if anyone has figured this out.
-
- Posts: 890
- Joined: October 20th, 2003, 1:24 pm
Re: Parsing HTML before rendering and loading
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.
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
Re: Parsing HTML before rendering and loading
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
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
-
- Posts: 2
- Joined: January 9th, 2009, 4:02 am
Re: Parsing HTML before rendering and loading
thanks guys for replying.
i will definitely post if this task is completed.
i will definitely post if this task is completed.
-
- Posts: 128
- Joined: January 20th, 2008, 4:04 am
- Contact:
Re: Parsing HTML before rendering and loading
Do you have any results? I have the same task.
-
- Posts: 24
- Joined: March 20th, 2009, 2:34 pm
Re: Parsing HTML before rendering and loading
Thanks Bloodeye, I've been wondering how to do this
I have a lot of reading to do now
I have a lot of reading to do now
-
- Posts: 231
- Joined: November 23rd, 2009, 10:37 am
Re: Parsing HTML before rendering and loading
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:
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.
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.