LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 07-04-2012, 10:57 AM   #1
danielbmartin
Senior Member
 
Registered: Apr 2010
Location: Apex, NC, USA
Distribution: Ubuntu
Posts: 1,167

Rep: Reputation: 306Reputation: 306Reputation: 306Reputation: 306
Modify Firefox pop-up menu


I may be browsing a web site and see a character string of particular interest. In this example it is a street address but it could be a person's name or something else.

I highlight the string and right click on it. This produces a pop-up menu like this:
Code:
Copy
Select All
Search Google For "13 Park Ave"
View Selection Source
Inspect Element
I want to add an optional action to launch my self-written application FV6 with the highlighted string as a parameter. The expanded pop-up menu would look like this
Code:
Copy
Select All
Search Google For "13 Park Ave"
View Selection Source
Inspect Element
Invoke FV6 with "13 Park Ave"
How should this be done? There are Firefox add-ons which claim to do something like this but I am reluctant to install them one-by-one until finding something suitable. Perhaps other LQers have blazed this trail and can give advice.

Daniel B. Martin

Last edited by danielbmartin; 07-04-2012 at 11:00 AM. Reason: Clarify subject line
 
Old 07-04-2012, 01:11 PM   #2
Slackyman
Member
 
Registered: Mar 2011
Location: Rome - Italy
Distribution: Slackware 13.1
Posts: 347

Rep: Reputation: 44
Can you give me the path to your application?
 
Old 07-04-2012, 02:19 PM   #3
danielbmartin
Senior Member
 
Registered: Apr 2010
Location: Apex, NC, USA
Distribution: Ubuntu
Posts: 1,167

Original Poster
Rep: Reputation: 306Reputation: 306Reputation: 306Reputation: 306
Quote:
Originally Posted by Slackyman View Post
Can you give me the path to your application?
The path is:
Code:
/home/daniel/Desktop/RexxScripts/fv6.rex
FV6 is a REXX program run with the regina interpreter. As things stand, to run the program I launch a terminal session and enter:
Code:
regina /home/daniel/Desktop/RexxScripts/fv6.rex
FV6 prompts the user for a search string but it could be passed as a parameter.

Daniel B. Martin
 
Old 07-04-2012, 02:28 PM   #4
Slackyman
Member
 
Registered: Mar 2011
Location: Rome - Italy
Distribution: Slackware 13.1
Posts: 347

Rep: Reputation: 44
I'm trying developing your firefox addons.
I'm now chatting in developers irc mozilla channel since I don't know how to run locally binary files.
Things are changed since I was used developing in XUL!
 
Old 07-04-2012, 02:29 PM   #5
firstfire
Member
 
Registered: Mar 2006
Location: Ekaterinburg, Russia
Distribution: Debian, Ubuntu
Posts: 640

Rep: Reputation: 375Reputation: 375Reputation: 375Reputation: 375
Hi, Daniel.

Is this what you are looking for?
 
1 members found this post helpful.
Old 07-04-2012, 03:07 PM   #6
danielbmartin
Senior Member
 
Registered: Apr 2010
Location: Apex, NC, USA
Distribution: Ubuntu
Posts: 1,167

Original Poster
Rep: Reputation: 306Reputation: 306Reputation: 306Reputation: 306
Quote:
Originally Posted by firstfire View Post
Is this what you are looking for?
Thank you, firstfire, for this pointer. It looks promising but I cannot dig into it just now. Other projects cry out for immediate attention!

Daniel B. Martin
 
Old 07-04-2012, 03:32 PM   #7
firstfire
Member
 
Registered: Mar 2006
Location: Ekaterinburg, Russia
Distribution: Debian, Ubuntu
Posts: 640

Rep: Reputation: 375Reputation: 375Reputation: 375Reputation: 375
Quote:
Originally Posted by danielbmartin View Post
Thank you, firstfire, for this pointer. It looks promising but I cannot dig into it just now. Other projects cry out for immediate attention!

Daniel B. Martin
No problem. My biggest project right now, which cries out for immediate attention, is to manage to sleep a bit before the work, as it is 1:32 AM here
 
Old 07-06-2012, 02:38 AM   #8
Slackyman
Member
 
Registered: Mar 2011
Location: Rome - Italy
Distribution: Slackware 13.1
Posts: 347

Rep: Reputation: 44
Fine!
Just register to Add-on Builder, create your own addon and use this code:
Code:
/* Slackyman Regina add-on for Firefox */

var contextMenu = require("context-menu"); /* create instance for handling context-menu */
var selection = require("selection"); /* create instance for handling selectiont */
const { Cc, Ci } = require('chrome'); /* required to access XPCOM components */
const proc = Cc["@mozilla.org/process/util;1"].createInstance(Ci.nsIProcess);
const ifile = Cc["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);  
ifile.initWithPath("/usr/bin/regina");  
proc.init(ifile);  
  
// Run the process.  
// If first param is true, calling thread will be blocked until  
// called process terminates.  
// Second and third params are used to pass command-line arguments  
// to the process.  

exports.main = function(options, callbacks) {
  console.log(options.loadReason);
 
  // Create a new context menu item.
  var menuItem = contextMenu.Item({
    label: "FV6 selected",
    // Show this item when a selection exists.
    context: contextMenu.SelectionContext(),
    // When this item is clicked, post a message to the item with the
    // selected text.
    contentScript: 'self.on("click", function () {' +
                   '  var text = window.getSelection().toString();' +
                   '  self.postMessage(text);' +
                   '});',
    // When we receive the message, call the regina interpreter with 
    // the path of the script and the selected text.
    onMessage: function (text) {
     var args = ['/home/daniel/Desktop/RexxScripts/fv6.rex', text]; 
    proc.run(false, args, args.length); 
    }
  });
};
 
1 members found this post helpful.
Old 07-08-2012, 09:54 PM   #9
danielbmartin
Senior Member
 
Registered: Apr 2010
Location: Apex, NC, USA
Distribution: Ubuntu
Posts: 1,167

Original Poster
Rep: Reputation: 306Reputation: 306Reputation: 306Reputation: 306
Quote:
Originally Posted by Slackyman View Post
Just register to Add-on Builder, create your own addon and use this code ...
Thank you, Slackyman, for writing this code. Please don't think I've ignored it. I registered to Add-on Builder which included establishing a password. Since that time I've been going roundy-round trying to create the add-on. It tells me the password is bad, so I reset it, and the password is still bad, etc. No doubt I've misread their instructions or botched an attempt to follow them. I'll keep trying.

Daniel B. Martin
 
  


Reply

Tags
firefox


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Pull down menu of File Manager in Opensuse 11.4 is almost transparent TigerLinux Suse/Novell 0 08-15-2011 09:14 PM
KDE 3.5.1 right click on menu items doesn't pull up submenu guitara Linux - Software 3 04-10-2006 04:08 PM
Fresh Install Of Distr From Network - Boot Menu, Need to pull up a menu of OS dist to SupermanInNY Linux - Distributions 0 01-22-2006 12:48 PM
pull-down menu items blank in java app mfeat Linux - Software 2 02-06-2005 12:48 PM
Perlscript doesn't read selected Pull-down Menu cccc Programming 12 05-27-2004 10:30 AM


All times are GMT -5. The time now is 09:34 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration