Cross-browser extension boilerplate - barebones template with Parcel 2, options handler and auto-publishing.
Screenshot of extension options:
- Uses Manifest v3
- Use npm dependencies thanks to Parcel 2.
- Auto-syncing options.
- Auto-publishing with auto-versioning and support for manual releases.
- Click Use this template to make a copy of your own. ๐
Note: When you create a repository from the template, the Template Cleanup workflow will be triggered to delete and edit template-specific resources. Wait a moment until the workflow finishes (you will see a commit pushed with 'Template cleanup' message).
- Checkout the copied repository to your local machine eg. with
git clone https://github.com/my-username/my-awesome-extension/
- Run
npm install
to install all required dependencies - Run
npm run build
The build step will create the distribution
folder, this folder will contain the generated extension.
Using web-ext is recommended for automatic reloading and running in a dedicated browser instance. Alternatively you can load the extension manually (see below).
- Run
npm run watch
to watch for file changes and build continuously - Run
npm install --global web-ext
(only only for the first time) - In another terminal, run
web-ext run -t chromium
- Check that the extension is loaded by opening the extension options (in Firefox or in Chrome).
You can also load the extension manually in Chrome or Firefox.
- For example, edit source\manifest.json to
"name": "My Awesome Extension",
- Go back to your browser, reload and see the change take effect
Note: Firefox will automatically reload content scripts when the extension is updated, Chrome requires you to reload the page to reload the content scripts.
Here are some websites you should refer to:
- Parcelโs Web Extension transformer documentation
- Chrome extensionsโ API list
- A lot more links in my Awesome WebExtensions list
The extension doesn't target any specific ECMAScript environment or provide any transpiling by default. The extensions output will be the same ECMAScript you write. This allows us to always target the latest browser version, which is a good practice you should be following.
Being based on Parcel 2 and its WebExtension transformer, you get all the good parts:
- Browserlist-based code transpiling (which defaults to just the latest Chrome and Firefox versions)
- Automatically picks up any new file specified in
manifest.json
Options are managed by fregante/webext-options-sync, which auto-saves and auto-restores the options form, applies defaults and runs migrations.
It's possible to automatically publish to both the Chrome Web Store and Mozilla Addons at once by adding these secrets on GitHub Actions:
CLIENT_ID
,CLIENT_SECRET
, andREFRESH_TOKEN
from Google APIs.WEB_EXT_API_KEY
, andWEB_EXT_API_SECRET
from AMO.
Also include EXTENSION_ID
in the secrets (how to find it) and add Mozillaโs gecko.id
to manifest.json
.
The GitHub Actions workflow will:
- Build the extension
- Create a version number based on the current UTC date time, like
19.6.16
and sets it in the manifest.json - Deploy it to both stores
Thanks to the included GitHub Action Workflows, if you set up those secrets in the repo's Settings, the deployment will automatically happen:
- on a schedule, by default every week (but only if there are any new commits in the last tag)
- manually, by clicking "Run workflow" in the Actions tab.
Extension icon made by Freepik from www.flaticon.com is licensed by CC 3.0 BY.
- notlmn/copy-as-markdown - Browser extension to copy hyperlinks, images, and selected text as Markdown.
This browser extension template is released under CC0 and mentioned below. There is no license
file included in here, but when you clone this template, you should include your own license file for the specific license you choose to use.