var ManageFoldersPlugin = (function() 
{
  var folderNodeId;
  
  var MFP = {
    init : function MFP_init()
    {
      var contextMenu = document.getElementById("placesContext");
      if (contextMenu)
        contextMenu.addEventListener("popupshowing",
                                     MFP.showHideMenuItem, false);
    },
    
    showHideMenuItem : function MFP_showHideMenuItem()
    {
      var popup = document.popupNode
      if (popup) {
        var isFolder = PlacesUtils.nodeIsFolder(popup.node);
        if (isFolder) folderNodeId = popup.node.itemId;
        // show or disable the 'manage folder' menu item every time the menu is rendered
        document.getElementById("placesContext_manageFolder").hidden = !isFolder;
      }
    },
    
    showOrganizer : function MFP_showOrganizer(event)
    {
      // check to see if organizer already open or open it. Needs to stay consistent
      // with the actual window opening calls found in browser-places.js
      // http://mxr.mozilla.org/firefox/source/browser/base/content/browser-places.js#544
      var wm = Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator);
      var organizer = wm.getMostRecentWindow("Places:Organizer");
      
      function selectFolder() {
        // The tree object, aka organizer.PlacesOrganizer._places (vai places.js)
        var places = organizer.document.getElementById("placesList");
        places.selectItems([folderNodeId]) ;
      }
      
      if (!organizer) {
        // once organizer window is loaded, postpone folder selection until after
        // the organizer init method is executed (see places.js)
        function selectOnLoad() {
          setTimeout(selectFolder, 1);
          organizer.removeEventListener("load", selectOnLoad, false);
        }
        
        organizer = openDialog("chrome://browser/content/places/places.xul", 
                               "", "chrome,toolbar=yes,dialog=no,resizable");
        organizer.addEventListener("load", selectOnLoad, false);
      }
      else 
        selectFolder()
    }
  }
  return MFP
})()

window.addEventListener("load", ManageFoldersPlugin.init, false);

@@ -10,22 +10,16 @@
 eFolders
-Plugin
  = (func
@@ -63,17 +63,16 @@
   var MF
-P
  = %7B%0D%0A  
@@ -91,17 +91,16 @@
 ction MF
-P
 _init()%0D
@@ -291,17 +291,16 @@
       MF
-P
 .showHid
@@ -363,25 +363,24 @@
  function MF
-P
 _showHideMen
@@ -385,16 +385,21 @@
 enuItem(
+event
 )%0D%0A    %7B
@@ -414,36 +414,50 @@
 var 
-popup = document.popup
+node = event.target._view.selected
 Node%0D%0A
+%0D%0A
     
@@ -462,21 +462,20 @@
     if (
-popup
+node
 ) %7B%0D%0A   
@@ -519,22 +519,16 @@
 sFolder(
-popup.
 node);%0D%0A
@@ -568,14 +568,8 @@
 d = 
-popup.
 node
@@ -805,17 +805,16 @@
 ction MF
-P
 _showOrg
@@ -2141,17 +2141,16 @@
 eturn MF
-P
 %0D%0A%7D)()%0D%0A
@@ -2200,14 +2200,8 @@
 ders
-Plugin
 .ini

drop the "Plugin" naming showHideMenuItem : now works on tree items in the sidebar as well as menu items in toolbar