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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
07-04-2012, 09:57 AM
|
#1
|
|
Member
Registered: Apr 2010
Location: Apex, NC, USA
Distribution: Ubuntu
Posts: 752
Rep: 
|
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 10:00 AM.
Reason: Clarify subject line
|
|
|
|
07-04-2012, 12:11 PM
|
#2
|
|
Member
Registered: Mar 2011
Location: Rome - Italy
Distribution: Slackware 13.1
Posts: 347
Rep:
|
Can you give me the path to your application?
|
|
|
|
07-04-2012, 01:19 PM
|
#3
|
|
Member
Registered: Apr 2010
Location: Apex, NC, USA
Distribution: Ubuntu
Posts: 752
Original Poster
Rep: 
|
Quote:
Originally Posted by Slackyman
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
|
|
|
|
07-04-2012, 01:28 PM
|
#4
|
|
Member
Registered: Mar 2011
Location: Rome - Italy
Distribution: Slackware 13.1
Posts: 347
Rep:
|
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! 
|
|
|
|
07-04-2012, 01:29 PM
|
#5
|
|
Member
Registered: Mar 2006
Location: Ekaterinburg, Russia
Distribution: Debian, Ubuntu
Posts: 576
|
Hi, Daniel.
Is this what you are looking for?
|
|
|
1 members found this post helpful.
|
07-04-2012, 02:07 PM
|
#6
|
|
Member
Registered: Apr 2010
Location: Apex, NC, USA
Distribution: Ubuntu
Posts: 752
Original Poster
Rep: 
|
Quote:
Originally Posted by firstfire
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
|
|
|
|
07-04-2012, 02:32 PM
|
#7
|
|
Member
Registered: Mar 2006
Location: Ekaterinburg, Russia
Distribution: Debian, Ubuntu
Posts: 576
|
Quote:
Originally Posted by danielbmartin
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 
|
|
|
|
07-06-2012, 01:38 AM
|
#8
|
|
Member
Registered: Mar 2011
Location: Rome - Italy
Distribution: Slackware 13.1
Posts: 347
Rep:
|
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.
|
07-08-2012, 08:54 PM
|
#9
|
|
Member
Registered: Apr 2010
Location: Apex, NC, USA
Distribution: Ubuntu
Posts: 752
Original Poster
Rep: 
|
Quote:
Originally Posted by Slackyman
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
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 05:53 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|