Hello there,

You should take a deeper look at the source code Honza mentioned. That code
works also for older versions of IE so, considering that you only want
Chrome support you may ignore that ActiveXObject parts.

2011/10/7 aslan <[email protected]>

> Sounds quite simple but when I try to do that it only works for xhr
> fired from my chrome extension and not from website i am browsing:
> for example i want to report xhr to console:
> ------------------------------
> var XMLHttpRequestWrapper = function(activeXObject){
>    console.log("xhr!!!!!!!!!!!");
>    new XMLHttpRequest();
> }
>

This code is incomplete and won't work properly because the wrapper does not
have the open(), send() and other methods. But I suppose you already know
that and this is just a sample code to demonstrate what you are trying to
do.


>
> var _XMLHttpRequest = XMLHttpRequest;
> window.XMLHttpRequest = function()
>    {
>        return new XMLHttpRequestWrapper();
>    };
> -------------------------------
> it only fires on my own xhrs not on those from website.
>

Chrome extension runs in a sandboxed environment, which means that if you
execute the wrapper in the sandbox only XHR calls made inside the sandbox
will be tracked. That's the behavior you are seeing.

If you want to listen for XHR calls made by the page, you need to inject a
script at the page and then use a "Content Script" to communicate with it:

http://code.google.com/chrome/extensions/content_scripts.html#host-page-communication

The communication between the page, the content scripts, and the background
page can be tricky so I suggest you to read the documentation very
carefully.

I hope I have helped you a little bit. If you need more help, feel free to
ask us here.

regards,

Pedro Simonetti.



>
> Maybe You know why?
> Great thanks for help. I really appreciate.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Firebug" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/firebug?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Firebug" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/firebug?hl=en.

Reply via email to