I have a few scripts that add user script commands via the GM_registerMenuCommand API call. Frequently I notice that these menu items are getting duplicated in the user script command list. Only the bottom-most one works so the other entries are bogus. I had this problem under GM 0.8.1, but it also occurs under 0.8.2.
I notice there is protection against creating duplicate entries in menucommanders.js, but for whatever reason that doesn't work. Either that or multiple menu commanders are somehow getting attached to the same window. I did notice that the number of objects in the menuCommanders's array in browser.js did not match the number of open tabs. Many of there objects contained null win objects or win objects with missing locations. Basically they shouldn't have been there. Since I never open more than 1 browser for the most part, there should only be 1 menuCommander object anyway. It seems to be a timing issue though since when I used the Javascript debugger to trace through the code after I saw the issue, everything worked fine. I think one of the problems may be the way the menu command is added/ removed. The menu commander is added and attached on a contentLoad, removed and detached on a contentUnload and attached/detached on an onLocationChange evernt. When going to a new page by following a link or typing an URL in the address bar two events fire in the order specified: onLocationChange and contentLoad. onLocataionChange detaches the menu commander from the tab and then reattached it then contentLoad attaches it again. So basically the menucommander is attached again when it's already attached. This doesn't always result in two entries being added (not sure why exactly), but since it's doing an appendChild for the same exact element twice in a row to the same menu popup it's hard to tell exactly what will happen in that case. I think preventing the code from attaching an already attached menu command might help with this problem. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "greasemonkey-users" 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/greasemonkey-users?hl=en -~----------~----~----~----~------~----~------~--~---
