Curiosity is bliss    Archive    Feed    About    Search

Julien Couvreur's programming blog and more

XmlHttpRequest Debugging (Firefox 1.5 update)

 

Here's XmlHttpRequest - Debugging (version 1.2), an update on the original.
The script now works in Firefox 1.5 with Greasemonkey 0.6.4.

Thanks to the readers who reported the problem for their help and patience.


The problem was caused by Greasemonkey's new injection system, which doesn't allow the userscript to access the XMLHttpRequest object in the page anymore.

As a workaround, the script escapes the Greasemonkey sandbox by eval'ing itself in the context of the page.
On the downside, it means that the injected code loses the ability to call Greasemonkey functions such as GM_getValue, GM_setValue or GM_registerMenuCommand. This means that the console won't remember its state (position, settings,...) between page loads and I also had to disable the "hide" functionality.

Here's the essence of the change:

function injectMe() {
  ... original userscript ...
}
unsafeWindow.eval(injectMe.toString());
unsafeWindow.eval("injectMe();");

Update (2005/01/12): According to Aaron Boodman (Greasemonkey creator) on the mailing list, unsafeWindow.XMLHttpRequest should still be available from the userscript. I'll investigate a bit more, but at least the script is working again now.

Update (2005/05/12): I just ported this script to IE, using a bookmarklet.

______________________________________

I get a "Config is not defined" error on line 117 of the greasemonkey.js script... ?

Posted by: Ryan (March 5, 2006 05:27 PM) ______________________________________

Thanks for your XMLHttpRequest Debugging v1.2

Actually v1.0 disappointed me but v1.2 is awesome.

I deeply appreciate your working.

Sincerely Eric.

====================================
Simple life High Thinking
at blog.naver.com/jinoxst
====================================

Posted by: Eric (March 6, 2006 12:46 AM) ______________________________________

Ryan,
This seems to be a problem with Greasemonkey itself. I googled the error you pasted ("Config is not defined") and found some info on the Greaseblog. I didn't get the time to go through the details, but I think you'll find some tips on fixing this there.

http://greaseblog.blogspot.com/
Here's a comment thread where this error is mentioned:
http://www.blogger.com/comment.g?blogID=11645460&postID=113598526711842205

Posted by: Julien Couvreur (March 6, 2006 09:39 AM) ______________________________________

Firefox 1.5.0.2
Greasemonkey 0.6.4

When I attempt to install XmlHttpRequest - Debugging (version 1.2), I get an alert:

Error installing user script:
[Exception... "Component returned failure code: 0x80520012 (NS_ERROR_FILE_NOT_FOUND) [nsIChannel.open]" nsresult: "0x80520012 (NS_FILE_NOT_FOUND)" location: "JS frame :: chrome://greasemonkey/content/utils.js :: getContents :: line 167" data: no]

Any ideas as to what is wrong?

Posted by: Gary Krajci (April 25, 2006 11:51 AM) ______________________________________

Hi,

I've installed greasemonkey.

I'm using Firefox 1.5.0.6.

When I enter a website to monitor and navigate to the site, the debugging screen pops up, but nothing ever happens when I enter search criteria (ex: www.google.com/webhp).

Posted by: David Johnson (August 6, 2006 09:37 AM)
comments powered by Disqus