In order to add new functionality to existing Firefox clients, do I need to create an extension or a plugin? - firefox

More specifically, the idea is to allow the user to open Firefox, highlight a word on a web page, right click on it, and have an additional option that, when selected, calls c++ code that does something with the input string (must call C++ code, unfortunately), and displays a dialog box showing the result.
I'm still not sure if in order to implement this functionality I need to create a Firefox plugin or an extension. Can someone point me in the right direction?
Also, if someone can show me sample code in order to get me started that would be appreciated. (XPCOM, which I'm not even sure is what I should be using, seems a bit complicated for this seemingly simple project.)

You need a regular Firefox extension. It can add an item to the context menu, NPAPI plugins cannot do this. When it is clicked it can get the selected text and send it to your binary library. The best way to call functions in this library is js-ctypes, XPCOM is not required.

Related

where can I download this code

I find a interesting website:http://www.brightpointinc.com/interactive/political_influence/
I want to learn its visualization using d3.
But when I download it, using right click button-------- save as The download page seems does not work. It seems lack some data, so I get back to the website to download some data, but it lacks some of them, can anyone send me an work version? thanks
As Lars says, your best bet is to look at the source code. To do this, you can use something like Chrome Developer Tools or Firebug for Firefox. I use the latter, so I'll take that as an example.
First, I'd right-click on the visualization itself, and click on Inspect Element with Firebug. This will pull up the HTML, which is only semi-helpful, since it only shows the output rather than the JavaScript code which created it.
To get at the JavaScript, you can use Firebug's Script tab. Most websites have more than one script, so you can hunt through the scripts being used by browsing through the dropdown menu in the second toolbar. The _buildChords.js script looks the most promising; that has some recognizable d3 code in it. You could check out the others to see what else they're calling (since it looks like there might be others - data.js, events.js, and so on).
Happy learning.

Modify contents of Firefox download dialog from add-on kit

I'd like to be able to add an option to the download dialog that pops-up in Firefox when starting a file download. Is it possible to do so using the new add-on SDK or do I have to do it the old way?
edit: Obviously, if the new option is selected, I need a way to know it and execute code based on it.
That's something you would use XUL overlays for. I guess that the dialog you are talking about is chrome://mozapps/content/downloads/downloads.xul - the download manager. AFAIK doing this isn't possible with the Add-on SDK, it only provides the most common UI integration points. You could create a traditional extension however, it can overlay any dialog.
There is no existing module that will help you that I know of, so you would have to create one, or wait for one to be made by someone else. But the main idea to extending browser UI is simple, and goes like this:
When the addon is loaded, scan for open windows of the type that you wish to extend.
extend the open windows by adding xul elements and javascript to the page.
listen for newly opened windows, and test that they are the type that you are looking for once they open
extend newly opened windows while your addon is active
Clean up after yourself when windows close or when your addon is disabled/uninstalled.
The last step is the most important and never matter with old school extensions which were not restartless.
Some for the built-in modules that you can look at that do this are the widget module, the context menu module, and the hotkeys module, all of which you can find here.
I've made a couple myself which are the toolbar button module, the xulkeys module, the menuitems module, and a few others, all of which you can find here.
Recently I wrote an extension do the same things. A bootstrap extension, not using addon-sdk.
I already submit it on AMO, but wait for review
https://addons.mozilla.org/en-US/firefox/addon/download-dialog-tweak/
And the source code
https://github.com/muzuiget/download_dialog_tweak

Tool to grab items from a Listbox in external app

I need to grab text items from a listbox in an application. I know for sure that the control is a ListBox. I've seen many tools that could do this, but I cannot remember their names. And I cannot find the right words to google for it. Does anybody know such tool?
You just get hold of the window handle of the list box and send some LB_GETTEXT messages. As far as tools go you might be thinking of Spy.
I couldn't find anything and ended up writing a small C# application using System.Windows.Automation. Just several lines of code.

How to make a site-lookup addon for Firefox?

I'd like to create an addon for Firefox that would enable me to search a particular site by selecting text on one site and choosing to search another site by selecting that option in the context menu.
I already have an extension like that in my browser - the Wikipedia Lookup extension. Basically, I want the exact same functionality but which will send the search text to a different site.
I'm completely new to Firefox addons, so can somebody tell me what's involved in this? Or point me at a site with a list of instructions to do a plugin like this? I can see examples on how to make a Hello World kind of plugin but I can't see how to extend that example into what I need. Thanks.
Have you considered opening the Wikipedia extension source and modifying the pointer from wikipedia.com to the other search site? This is assuming you're using Windows Vista or higher. The source code should be located at:
C:\Users\YourUserName\AppData\Roaming\Mozilla\Firefox\Profiles\xxxxxxxx.default\extensions\something#wikipedia.com\chrome\content
You would then have to modify the source code inside to change the pointer, and the POST variables string to match that of the site you will be using.
I hope this at least points you in the general direction!
-Alex

How to add GtkMozEmbed browser into a tab with Ruby/Glade/GtK?

I am trying to add a browser using GtkMozEmbed into a gui I am designing using Glade. I want the browser to take up a tab in a notebook widget, but I cannot figure out how to actually do this. I am wondering what container to use to put the browser in, and the associated ruby code to actually embed the browser in this container. Any help would be appreciated thanks!
What I ended up doing eventually was to insert a window element into the tab, and in the ruby code associated with the glade file configure the GTKMozEmbed there. I do not think it is possible to get it setup using the Glade GUI, so you will have to get down into the code for this.
To add a new tab with any widget use this.

Resources