[Greasemonkey] "Error: No menu commaner" occurs if greasemonkey 0.5 is disabled

Bill Donnelly donnelly at snowcrest.net
Sun Aug 7 01:04:32 EDT 2005


For those that want to mess with code, the following "fixes" the
logged errors problem, but not necessarily the underlying problem,
whatever that is. The only change is a few lines in the middle of the
GM_BrowserUI.contentLoad() function to stop the logged message:

      //if (!commander) {
      //  throw new Error("No menu commaner found for URL: " + href);
      //}
      if (commander) {
         this.currentMenuCommander = commander;
         this.currentMenuCommander.attach();
      }

The file is browser.js in the Gm extension sub-directory, and here
is the function that needs to be (ex)changed:

/**
 * Gets called when a DOMContentLoaded event occurs somewhere in the 
browser.
 * If that document is in in the top-level window of the focused tab, find
 * it's menu items and activate them.
 */
GM_BrowserUI.contentLoad = function(e) {
  GM_log("> GM_BrowserUI.contentLoad");

  var unsafeTarget = new XPCNativeWrapper(e, "target").target;
  var unsafeWin = new XPCNativeWrapper(unsafeTarget, 
"defaultView").defaultView;
  var unsafeLoc = new XPCNativeWrapper(unsafeWin, "location").location;
  var href = new XPCNativeWrapper(unsafeLoc, "href").href;

  if (GM_isGreasemonkeyable(href)) {
    // if this content load is in the focused tab, attach the 
menuCommaander 
    if (unsafeWin == this.tabBrowser.selectedBrowser.contentWindow) {
      var commander = this.getCommander(unsafeWin);
   
      //if (!commander) {
      //  throw new Error("No menu commaner found for URL: " + href);
      //}
      if (commander) {
         this.currentMenuCommander = commander;
         this.currentMenuCommander.attach();
      }
    }
 
    GM_listen(unsafeWin, "unload", GM_hitch(this, "contentUnload"));
  }
 
  GM_log("< GM_BrowserUI.contentLoad");
}

That should hold a few who are irritated until a correction comes out.

-- 
Sometimes bad things happen to good people.
When that happens, those good people should
seek out and find some bad people.
And then do something bad to them.
Just to even things out.
It's only fair, after all.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mozdev.org/pipermail/greasemonkey/attachments/20050807/20c8a10f/attachment.htm


More information about the Greasemonkey mailing list