MozillaZine

MenuManipulator 20140526

Talk about add-ons and extension development.
morat
 
Posts: 2358
Joined: February 3rd, 2009, 6:29 pm

Post Posted July 17th, 2012, 4:48 pm

@joshfeingold

Try to create a menuitem in the menupopup id="emailAddressPopup".

label: Search Email Address

oncommand:

Code: Select all
var eps = Components.classes["@mozilla.org/uriloader/external-protocol-service;1"].
  getService(Components.interfaces.nsIExternalProtocolService);
var ios = Components.classes["@mozilla.org/network/io-service;1"].
  getService(Components.interfaces.nsIIOService);
var ea = findEmailNodeFromPopupNode(document.popupNode, "emailAddressPopup").
  getAttribute("emailAddress");
eps.loadURI(ios.newURI("http://www.google.com/search?q=" + ea, null, null));

Edit:

Philip Chee wrote:emailNode.getAttribute("emailAddress") is for SeaMonkey and old Thunderbird.
emailNode.parentNode.parentNode.getAttribute("emailAddress") is for new Thunderbird with the silly message header pain er pane.
Last edited by morat on July 20th, 2012, 6:47 am, edited 1 time in total.

LewisR1
 
Posts: 13
Joined: October 16th, 2005, 2:19 pm
Location: New York, USA

Post Posted July 17th, 2012, 7:26 pm

That's quite elegant, indeed.

Any thoughts on the differences necessary to have that function under SeaMonkey vs TB/FF? Just curious. I haven;t looked closely enough to try to sort it out for myself.

TIA
Lewis
Lewis G Rosenthal, CNA, CLE, CLP, CWTS
Rosenthal & Rosenthal, LLC

Philip Chee

User avatar
 
Posts: 6475
Joined: March 1st, 2005, 3:03 pm

Post Posted July 18th, 2012, 2:02 am

LewisR1 wrote:That's quite elegant, indeed.

Any thoughts on the differences necessary to have that function under SeaMonkey vs TB/FF? Just curious. I haven;t looked closely enough to try to sort it out for myself.

TIA

Since SeaMonkey has a browser component, "http:" isn't an "external protocol". You should probably use openUILink() instead.
We also don't have findEmailNodeFromPopupNode()

From my addressContext (http://xsidebar.mozdev.org/modifiedmailnews.html#addresscontext) mod:
XUL:
Code: Select all
  <popup id="emailAddressPopup">
    <menuitem id="blah" label="&lookUpInBook.label;" oncommand="lookUpCard(document.popupNode);" />
  </popup>

JS:
Code: Select all
function lookUpCard(emailNode)
{
  if(emailNode){
    var email = emailNode.getAttribute("emailAddress") ||
                emailNode.parentNode.parentNode.getAttribute("emailAddress");
..........
  }
}

Then you probably want to do something like:
Code: Select all
openUILink("http://www.google.com/search?q=" + email);

Phil

Philip Chee

User avatar
 
Posts: 6475
Joined: March 1st, 2005, 3:03 pm

Post Posted July 18th, 2012, 2:37 am

Code: Select all
function lookUpCard(emailNode)
{
  if(emailNode){
    var email = emailNode.getAttribute("emailAddress") ||
                emailNode.parentNode.parentNode.getAttribute("emailAddress");
..........
  }
}

emailNode.getAttribute("emailAddress") is for SeaMonkey and old Thunderbird.
emailNode.parentNode.parentNode.getAttribute("emailAddress") is for new Thunderbird with the silly message header pain er pane.

Phil

morat
 
Posts: 2358
Joined: February 3rd, 2009, 6:29 pm

Post Posted July 18th, 2012, 6:50 am

@LewisR1

Firefox:

Step 1)

* create a menuitem in the menupopup id="contentAreaContextMenu"

label: Search Email Address

oncommand:

Code: Select all
var url = gContextMenu.linkURL;
var qmark = url.indexOf("?");
var email = qmark > 7 ? url.substring(7, qmark) : url.substr(7);
gBrowser.addTab("http://www.google.com/search?q=" + email);

note: 7 == length of "mailto:"

Step 2)

* insert the following line in the onpopupshowing attribute in the menupopup id="contentAreaContextMenu"

Code: Select all
  if (event.target != this)
    return true;
  gContextMenu = new nsContextMenu(this, gBrowser, event.shiftKey);
  if (gContextMenu.shouldDisplay)
    updateEditUIVisibility();
+ document.getElementById("__ID__").hidden = !gContextMenu.onMailtoLink;
  return gContextMenu.shouldDisplay;

note: replace __ID__ with the id attribute of the menuitem

note: might need to restart Firefox after editing the onpopupshowing attribute

http://www.w3schools.com/html/tryit.asp ... tml_mailto

LewisR1
 
Posts: 13
Joined: October 16th, 2005, 2:19 pm
Location: New York, USA

Post Posted July 18th, 2012, 7:57 am

Thanks. Actually, I think Phil hit on it more to the point (for me), as I was looking for a way of applying this to SeaMonkey. Still, all of these solutions for adding functions to the context menu for an email address and passing the address as a parameter are quite slick. I'm constantly amazed at how we need to use the tools we may know so well in different ways (I've had my head in some advanced Linux routing stuff for a new client, and I never would have even thought about doing things like this with packets before). ;-)

Thanks again...both of you!

Cheers
Lewis
Lewis G Rosenthal, CNA, CLE, CLP, CWTS
Rosenthal & Rosenthal, LLC

pohunohi

User avatar
 
Posts: 27
Joined: October 1st, 2010, 4:54 am

Post Posted July 29th, 2012, 10:22 am

Why is not visible MenuManipulator menu AppButton?

Image

dorando
 
Posts: 1203
Joined: January 9th, 2004, 9:57 am

Post Posted September 29th, 2012, 10:55 am

bazzacad wrote:I noticed that you've added this line to the "prefs.js"
Code: Select all
user_pref("menumanipulator.chrome://messenger/content/messenger.xul", "Node(\"id('folderPaneContext-rename')\"); Set('label','TM Rename'); Set('oncommand','alert(\"Hello World!\");'); ");
How could I take this user_pref & incorporate it into my add-on without all the extra functionality of your add-on?
MenuManipulator in essence does just
Code: Select all
var node document.getElementById("folderPaneContext-rename");
node.setAttribute("label","TM Rename");
node.setAttribute("oncommand",'alert("Hello World!");'); 
during the load event phase. Alternatively you could add
Code: Select all
<target id="folderPaneContext-rename" label="TM Rename" oncommand='alert("Hello World!");' /> 
to an overlay.

pohunohi wrote:Why is not visible MenuManipulator menu AppButton?
MenuManipulator can't currently edit the Firefox Button since it is not a proper menu, you can use Personal Menu (Personal Firefox Button) to edit it.
Support mozilla.dorando.at through donations/contributions.

Bernd S.
 
Posts: 95
Joined: January 22nd, 2010, 7:14 am

Post Posted January 25th, 2013, 8:51 am

I'm trying to define a short-cut to open the menu "customize" .
Code: Select all
cmd_CustomizeMailToolbar
doesn't seem to work at all.

TB 17.0.2
Win7 x86
MP 20110327

Thank you

Bernd
Last edited by Bernd S. on January 25th, 2013, 9:28 am, edited 1 time in total.

dorando
 
Posts: 1203
Joined: January 9th, 2004, 9:57 am

Post Posted February 6th, 2013, 11:55 am

Try
Code: Select all
CustomizeMailToolbar('mail-toolbox''CustomizeMailToolbar'); 
Support mozilla.dorando.at through donations/contributions.

Bernd S.
 
Posts: 95
Joined: January 22nd, 2010, 7:14 am

Post Posted February 6th, 2013, 2:16 pm

Thank you Dorando, that works.

troypst
 
Posts: 16
Joined: March 15th, 2013, 5:19 am

Post Posted April 18th, 2013, 12:03 pm

Hi dorando, I'd like to replace menueditor with menumanipulator, so before installing I tested it on a new profile, as unique extension. I edited the Edit menu and all was ok till I restarted and my changes were messed up. In the error console i found this:

"XUL box for _moz_generated_content_after element contained an inline #text child, forcing all its children to be wrapped in a block."

What am I doing wrong? I use FF19.02 on winXP.

Thanx.

troypst
 
Posts: 16
Joined: March 15th, 2013, 5:19 am

Post Posted April 20th, 2013, 5:27 am

Same thing happens with firefox 20.0.1. Also some separators return back to normal after being edited/hidden.

dorando
 
Posts: 1203
Joined: January 9th, 2004, 9:57 am

Post Posted April 21st, 2013, 6:32 am

troypst wrote:"XUL box for _moz_generated_content_after element contained an inline #text child, forcing all its children to be wrapped in a block."
Happens for me in a clean profile, should be harmless.
troypst wrote:Same thing happens with firefox 20.0.1. Also some separators return back to normal after being edited/hidden.
MenuManipulator apparently doesn't correctly initialize for new profiles since 12.0… I hope to release an update soon to fix that, but just setting menumanipulator.global.20110327 in about:config to
Code: Select all
SetID(); 
should fix it too.
Support mozilla.dorando.at through donations/contributions.

troypst
 
Posts: 16
Joined: March 15th, 2013, 5:19 am

Post Posted April 22nd, 2013, 9:51 am

That worked fine. Thanx.

Return to Extension Development


Who is online

Users browsing this forum: No registered users and 1 guest