Rob--W / browser-action-jplib

Jetpack module to add a Browser action badge to the toolbar, using the chrome.browserAction syntax from Chromium
21 stars 9 forks source link

OBSOLETE

This module is no longer maintained, and non-functional as of Firefox 38. Use the sdk/ui module instead.

If you are interested in using Chrome extension APIs in Firefox, follow the following bug and its linked bugs: https://bugzilla.mozilla.org/show_bug.cgi?id=1161828

chrome.browserAction API for Firefox Add-ons

This Jetpack module provides an API which is almost identical to Google Chrome's chrome.browserAction API for creating badges on the toolbar.
Identical in terms of API, identical in terms of appearance!

Usage

If you're familiar with the chrome.browserAction API, using this module is a breeze.
To add a browser action button to your Firefox add-on, copy-paste the browser_action section from your Chrome extension's manifest file to your add-ons background page. After running the following code, a browser action button will appear at the right of the location bar.

var badge = require('browserAction').BrowserAction({
    default_icon: 'images/icon19.png', // optional
    default_title: 'Badge title',      // optional; shown in tooltip
    default_popup: 'popup.html'        // optional
});

Extra features over the chrome.browserAction API.

Missing features

Installation

You can add the module globally (in the packages directory under the SDK root), to make it available to all of your Jetpack projects, or add it to a single project (in the packages directory under your add-on's root).

The official documentation contains a tutorial on installing third-party modules, which suggests to download and extract an archive.
I strongly recommend to use git for this purpose, because it makes package management a lot easier. For example:

# Go to the packages directory of the SDK's root.
cd /opt/addon-sdk/packages
# Clone the repository (creates a directory "browser-action-jplib")
git clone git://github.com/Rob--W/browser-action-jplib.git
# Done! You may want to update and view the documentation...
addon-sdk && cfx sdocs
# Later, when you want to update the package to the latest version...
cd /opt/addon-sdk/packages/browser-action-jplib
git pull

After installing the module, declare the dependency in package.json:

    ...
    "dependencies": ["browser-action"],
    ...

Dependencies

The only external dependency is the toolbarwidget Jetpack module.

Change log

0.2.4

0.2.2

0.2.0

0.1.4

Credits

Created by Rob Wu gwnRob@gmail.com.

Released under a MIT license.