[Greasemonkey] Re: GreaseMonkey 0.3

Scott R. Turner srt at aero.org
Fri Apr 15 10:04:25 EDT 2005


I posted a problem I was having yesterday.  I did some more digging
and figured out what was going on.

It was something of an unusual situation.  I'm running Win2K with a
roaming profile, and it looks like my profile only got partially
updated after installing 0.3.  The effect was that the next time I
logged in, my scripts got "restored" to the old naming scheme.  As a
result, Greasemonkey was unable to load the scripts.

Renaming fixed the problem for me, but it pointed out a more serious
problem.  As it stands right now if there's an error in loading a
script, Greasemonkey silently fails, stopping the whole script loading
in its tracks.  This is probably not the correct behavior :-).

Here's a quick fix:

function getContents(aURL){
   var ioService=Components.classes["@mozilla.org/network/io-service;1"]
     .getService(Components.interfaces.nsIIOService);
   var scriptableStream=Components
     .classes["@mozilla.org/scriptableinputstream;1"]
     .getService(Components.interfaces.nsIScriptableInputStream);
   try {
     var channel=ioService.newChannel(aURL,null,null);
     var input=channel.open();
     scriptableStream.init(input);
     var str=scriptableStream.read(input.available());
     scriptableStream.close();
     input.close();
     return str;
   } catch (e) {
     alert("Unable to find the "+aURL+" GreaseMonkey script.  Try re-installing the script.");
     return "";
   };
}

However, I note this is a problem in the handling of the Edit button,
and maybe elsewhere as well.

 	  -- Scott


More information about the Greasemonkey mailing list