The “webextensions-examples” repository is a collection of simple but complete and installable WebExtensions.

We’re really happy to accept contributions, either as new examples or as improvements to the existing examples. This file lists some general guidelines to help contributors write useful examples.

Types of contribution

There are many ways you can help improve this repository! For example:

Guidelines for examples

Examples should:

Code style

If you’re editing an existing file, code style should be consistent with the rest of the code in the file. Otherwise, code style should follow the style for WebExtensions code itself: https://wiki.mozilla.org/WebExtensions/Hacking#Code_Style.

Updating examples.json

Note: people contributing examples don’t have to update examples.json: this can be left up to the project maintainers. The documentation in this section is primarily aimed at maintainers, not contributors.

This repository contains a JSON file at the root called “examples.json”. It contains a machine-readable description of the examples the repository contains. For each example, the JSON file contains:

This file is used to generate links from MDN pages to examples. Specifically, it’s read by 2 different KumaScript macros:

If you add a new example extension, or update an existing one to change the WebExtension APIs that it calls, you should update examples.json.

Also, it would be helpful to force https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Examples and any other relevant pages to re-evaluate their KumaScript, so they can pick up the changes. To do this, shift-refresh the page while logged into MDN.

Licensing

Please note that the examples are all made available under the Mozilla Public License 2.0, so any contributions must be compatible with that license. If you’re not sure about that, just ask.

Getting help

If you need help with writing a WebExtension, email the dev-addons mailing list or contact the WebExtensions team in the #webextensions IRC channel on irc.mozilla.org.