This is a template for firefox web extensions using the firefox APIs. The template is for manifest V2.
The following features are implemented:
- A content script that has the ability to send messages to the background script. The manifest has been configured to run on
google.com
using the["content_scripts"][0]["matches"]
property in the provided manifest file. It also includes the needed permissions in["permissions"][1]
property of the manifest file. These can be configured to run on a different host. It is important to note that the URLs for permissions should not include a port number. If a port number is present, then the permission will silently fail. For example,*://localhost:8000/*
is incorrect. It should instead be*://localhost/*
. - A background script, that has the ability to receive command messages, message from the content script and messages from the action menu. The command is by default bound to
ALT+R
. This is specified in the manifest["commands"]["example_shortcut"]["suggested_key"]["default"]
property. This can be changed by the user by going through the menu, clicking add-ons and themes, clicking extensions, clicking the cogwheel and finally clicking manage extension shortcuts. More information can be found here. - An action menu script, that requests the message currently stored in the background script and displays them. The background script responds to this request with the list of stored messages. This request is performed each time the user clicks the action menu to open it.
- Icons, that are displayed in various places. The icons are expected to be in specific formats and these should be specified in the
["icons"]
property of the manifest file. Generally, the icon sizes that may be expected are 16x16, 32,x32, 48x48 and 128x128. Icons for the action menu are specified separately in["browser_action"]["default_icon"]
.
In the context of a content script, the console.log function will print to the browser console.
In the context of a background script or action menu script, the console.log function will print to the background console. The background console can be accessed through about:debugging
, then clicking This Firefox
, the finding the extension and clicking the Inspect
button. Note that this is the same place that temporary addons are loaded by clicking the Load Temporary Add-on
button.