Razzi's guide to Firefox Extensions
Firefox allows writing your own extensions and provides the web-ext tool to work on them.
Read about the extensions I’ve written here.
install web-ext
npm install --global web-ext
start with an extension template
You can see their documentation for Your first extension or go to the github repository that has their extension examples.
Their tutorial leads you to build a simple one called borderify. You can type it yourself or clone the examples and go to its directory.
Test the extension with web-ext run:
$ git clone https://github.com/mdn/webextensions-examples
$ cd webextensions-examples/borderify/
borderify $ web-ext run
Running web extension from /Users/razzi/forks/webextensions-examples/borderify
Use --verbose or --devtools to see logging
Installed /Users/razzi/forks/webextensions-examples/borderify as a temporary add-on
The extension will reload if any source file changes
Press R to reload (and Ctrl-C to quit)
If you’re happy with that as a starting point, you can copy that code to another directory and initialize a repository there.
files for a minimal extension
Here is the absolute minimum of files you need to have an extension that runs javascript:
manifest.json
{
"manifest_version": 2,
"name": "example",
"version": "0",
"background": {
"scripts": ["script.js"]
}
}
script.js
browser.tabs.create({
"url": "http://example.com"
})
It uses a “background” script which doesn’t run in any particular tab. To have javascript run in the context of a particular page, see their borderify example.
That should be enough to get you started!