Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Read newly loaded page from a tab

4 views
Skip to first unread message

S.Hamel

unread,
Oct 23, 2006, 10:58:11 PM10/23/06
to
I'm stuck with the development of my extension and the problem is very
simple:
- I create a new Firefox sidebar extension (that works fine)
- When the sidebar is displayed, I want to monitor any web page being
loaded and parse the resulting DOM (not the source of the page)
- I know my javascript parser works from a Greasemonkey script, I'm
just missing the connection between the sidebar and the DOM loaded in
the window!

How do I get the hook to parse the DOM?

Here's some code abstract:

// Listen for page loading...
gBrowser.addProgressListener(something_urlBarListener,Components.interfaces.nsIWebProgress.NOTIFY_STATE_DOCUMENT);
...
// Detect when a page has completed loading
onStateChange: function(aProgress, aRequest, aFlag, aStatus)
{
if(aFlag & Components.interfaces.nsIWebProgressListener.STATE_STOP)
something.processNewURL(aRequest.URI);
},
...
// Then, in something.processNewURL() I do this:
// Check if the document is HTML
if(document.contentType == "text/html") {
// HOW DO I HOOK UP TO THE DOM???
// TRIED THE FOLLOWING WITHOUT SUCCESS:
//var fW = document.commandDispatcher.focusedWindow;
//var fW = window.document.commandDispatcher; // works!!!
//var winWrapper = new
XPCNativeWrapper(contentWindow,'document','getSelection()');
//var docWrapper = new XPCNativeWrapper(winWrapper.document, 'title');
//var fW = browser.contentWindow.document;
}

Thanks!

Nickolay Ponomarev

unread,
Oct 24, 2006, 12:23:18 PM10/24/06
to S.Hamel, dev-ext...@lists.mozilla.org
On 23 Oct 2006 19:58:11 -0700, S.Hamel <sham...@gmail.com> wrote:
> // Check if the document is HTML
> if(document.contentType == "text/html") {
> // HOW DO I HOOK UP TO THE DOM???
> // TRIED THE FOLLOWING WITHOUT SUCCESS:

content.document?

Nickolay

0 new messages