Extensions Menu Button

No replies
Joined: 10/26/2007
Posts: 58
User offline. Last seen 1 year 18 weeks ago.

Buttons

These are multi-purpose extension management buttons.

Left clicking on the either of the main buttons opens the extension manager (normally or in the sidebar, dependant on the button).

Left clicking on the drop-marker for either button opens a menu of extensions with options dialogues, clicking on one of the extensions dialogues in the menu opens the options dialogue for that extension.

Right clicking the button shows the context menu which contains some more extension management related items, these/some of these may require MR Tech's Toolkit (a.k.a. Local Install).

Extensions Menu Button
Compatibility: 

Minefield Firefox 3.0.* Firefox 2.0.* Firefox 1.5.* Flock Thunderbird 3.* Thunderbird 2.*

Author(s): 
rawny, SCClockDr, and LouCypher
Description & info:

Behavior

Action Behavior

Left

("Extensions" button:)
  • Opens extensions manager.

Left

("Extensions in sidebar" button:)
  • Opens extensions manager in the sidebar.

Middle or Ctrl+Left

(Both buttons:)
  • Opens extensions manager in a new tab.

Left

On Button Drop-Marker

(Both buttons:)
  • Opens menu of extensions with options dialogues, clicking on one of the extensions dialogues in the menu opens the options dialogue for that extension.

Right

(Both buttons:)
  • Shows context menu.

Revisions

Revision செயல்பாடுகள்
03/14/2009 - 06:54 by rawny

Updated button(s) to correct interaction with AIOS and added behaviour and description information.

current revision
03/12/2009 - 16:51 by SCClockDr

Modified to accommodate AIOS

03/12/2009 - 15:51 by SCClockDr

Updated Extensions Button as well

03/12/2009 - 15:47 by SCClockDr

Adde3d a button that opens in the Sidebar

03/02/2009 - 08:12 by admin

update compatibility field

02/27/2009 - 19:46 by SCAdmin
02/25/2009 - 17:04 by rawny
02/25/2009 - 01:38 by makondo
02/25/2009 - 01:38 by makondo

Moved Post

Code

javascript: Copy To Clipboard
/*Code*/
/* -------------------------------------------------------------
   Extensions Menu
   Based on snippet by onemen
   http://forums.mozillazine.org/viewtopic.php?p=1774082#1774082
   Modified by LouCypher (aka Zoolcar9)
   ------------------------------------------------------------- */
// if ( !event.ctrlKey ) {
//	if ( typeof aios_getObjects == "function" ) {
//		toggleSidebar("viewAddonsSidebar");
//	} else {
//		let title = "Extensions in Sidebar"
//		let link = "chrome://mozapps/content/extensions/extensions.xul";
//		if (/Extensions \[/.test( document.getElementById('sidebar-title').getAttribute('value') ) ) {
//			toggleSidebar();
//		} else {
//			if (/extensions\.xul$/.test( link )) {
//				toggleSidebar('viewWebPanelsSidebar', true);
//				document.getElementById('sidebar').setAttribute('src', link );
//				document.getElementById('sidebar-title').setAttribute('value', title );
//			} else {
//				openWebPanel( title, link );
//			}
//		}
//	}
// } else {
//	gBrowser.selectedTab = gBrowser.addTab('chrome://mozapps/content/extensions/extensions.xul?type=extensions');
// }
 
if( typeof BrowserOpenAddonsMgr == "function" )
  BrowserOpenAddonsMgr();
else
  BrowserOpenExtensions( "extensions" );
 
 
// =============================================================================

Init

javascript: Copy To Clipboard
/*Initialization code*/
const Cb = custombuttons;
const EXTENSION = Ci.nsIUpdateItem.TYPE_EXTENSION;
 
function prop( aElement, aString ) {
  var emRDF = "http://www.mozilla.org/2004/em-rdf#";
  var arc = RDFService.GetResource(emRDF+ aString);
  var target = extensionDS.GetTarget(aElement, arc, true);
  if(target instanceof Ci.nsIRDFLiteral) return target.Value;
  if(target instanceof Ci.nsIRDFInt) return target.Value;
  return null;
}
 
var mPopup = this.appendChild(document.createElement("menupopup"));
mPopup.setAttribute("oncommand", "event.stopPropagation()");
 
var RDFService  = Cc["@mozilla.org/rdf/rdf-service;1"].getService(Ci.nsIRDFService);
var Container   = Cc["@mozilla.org/rdf/container;1"].getService(Ci.nsIRDFContainer);
var extensionDS = Cc["@mozilla.org/extensions/manager;1"].getService(Ci.nsIExtensionManager).datasource;
 
var root;
try {
  root = RDFService.GetResource("urn:mozilla:item:root");
} catch(err) {
  root = RDFService.GetResource("urn:mozilla:extension:root");
}
 
Container.Init(extensionDS,root);
 
var elements = Container.GetElements();
var extensionArray = [];
var i = -1;
while(elements.hasMoreElements()) {
  i++;
  var element=elements.getNext();
  element.QueryInterface(Components.interfaces.nsIRDFResource);
  var prop_OptionsURL = prop(element, "optionsURL");
  if(prop(element, "type") == EXTENSION &&  prop_OptionsURL) {
    var prop_name = prop(element, "name");
    extensionArray[i] = [];
    extensionArray[i] [0] = prop_name.charAt(0).toUpperCase() + prop_name.substr(1);
    extensionArray[i] [1] = prop_OptionsURL;
    extensionArray[i] [2] = prop(element, "userDisabled");
    extensionArray[i] [3] = prop(element, "version");
    extensionArray[i] [4] = prop(element, "iconURL");
    if(!extensionArray[i] [4])
      extensionArray[i] [4] = "chrome://mozapps/skin/xpinstall/xpinstallItemGeneric.png";
  }
}
 
extensionArray.sort();
 
var features = "chrome, dialog = 0, resizable, titlebar, toolbar, centerscreen";
 
var extCommand = "window.openDialog('ZZZ', '', '" + features + "');";
 
for(var i = 0; i < extensionArray.length; i++) {
  var extArray = extensionArray[i];
  try {
    var mItem = document.createElement("menuitem");
    mItem.setAttribute("label", extArray[0] + " " + extArray[3]);
    if(extArray[4]) {
      mItem.setAttribute("class", "menuitem-iconic bookmark-item");
      mItem.setAttribute("image", extArray[4]);
    }
    if(extArray[1])
      mItem.setAttribute("oncommand", extCommand.replace("ZZZ", extArray[1]));
    if(extArray[2]) mItem.setAttribute("disabled", true);
    mPopup.appendChild(mItem);
  } catch(e) {
  }
}
 
this.type = "menu-button";
 
if(typeof Local_Install != "object") return;
 
var test = document.getElementById("cbContext-extensions");
if(test) test.parentNode.removeChild(test);
 
var cbPopup = document.getElementById("custombuttons-contextpopup-subCall").cloneNode(true); // Cb context
 
// var subPopup = document.createElement("menupopup");
 
// subPopup.appendChild(cbPopup);
// subPopup.appendChild(cbPopup.lastChild);
 
var subMenu = document.createElement("menu");
subMenu.setAttribute("label", "Custom Button");
subMenu.setAttribute("image", Cb.defaultImg() );
subMenu.appendChild(cbPopup.lastChild);
 
var extensionsPopup = document.getElementById("emb-context");
var popup = extensionsPopup.cloneNode(true);
popup.id = "cbContext-extensions";
popup.appendChild(document.createElement("menuseparator"));
popup.appendChild(subMenu);
//popup.appendChild(subPopup);
 
extensionsPopup.parentNode.appendChild(popup);
 
this.setAttribute("context", popup.id);
this.onclick = function(aEvent) {
  custombuttons.Dump("onclick called");
  if(aEvent.button === 1) gBrowser.selectedTab = gBrowser.addTab('chrome://mozapps/content/extensions/extensions.xul?type=extensions');
}
/*---------------------- Show Focus Block Start ------------------------*/
 
this.style.opacity = '.65';
this.setAttribute( 'onmouseover', 'custombuttons.ButtonBrt(event);' );
this.setAttribute(  'onmouseout', 'custombuttons.ButtonDim(event);' );
 
/*----------------------- Show Focus Block End -------------------------*/
/*--------------- Custom Buttons2 Attributes Block Start ----------------*/
this.setAttribute("author","LouCypher, SCClockDr, rawny");
this.setAttribute("version","20090314.02");
this.setAttribute('dependency','Fx 2.0.0.4 - 3.2a1pre, Tb 2.0.0.19 - Tb 3.0b2pre, Calendar 1.0pre , CB2 2.0.0*');
this.setAttribute("status","complete");
this.setAttribute('public',true);
this.setAttribute('homepage', 'http://custombuttons2.com/forum/buttons/buttons-database/extensions-menu-button.html');

Help

**********************************************************************
 
 Left Click =
     Load the Extensions Dialog into a new tab.
 
 Left Click on the menu dropmarker = 
     Pop up the Extensions options select list menu.
       Selecting an extension from this list will
       popup its options dialog.
 
 Right Click =
     Pop up the button's Context menu.
       From this menu you can select various extension menu options
       or the Custom Buttons context menuitem.
 
 Credits:
   LouCypher - Original Concept and coding.
   SCClockdr - Button enhancemants related to Custom Buttons.

Details

Button Categories: 
Top