"web_accessible_resources": [ "images/my-image.png" ]
For example, the "beastify" example extension used in the walkthrough tutorial replaces images in a web page with images of some beasts, by setting the
src attribute of any
<img> elements. The images are packaged with the extension, and for the web page to be able to load them, they must be made web accessible.
web_accessible_resources key lists all packaged resources that you want to make available to web pages in this way. You specify them as paths relative to the manifest.json file.
The files will then be available using a URL like: "moz-extension://<random-UUID>/<path/to/resource>".
This UUID is randomly generated for every browser instance and is not your extension's ID. This prevents websites from fingerprinting the extensions a user has installed.
For example, consider an entry like this:
If the random UUID is
944cfddf-7a95-3c47-bd9a-663b3ce8d699, then this resource will be available at the following URL:
Entries can contain wildcards, for example:
Will also work.
The easiest way to get this URL is to use the
browser.extension.getURL API, and give it the path relative to manifest.json:
Note that content scripts don't need to be listed as web accessible resources.
Make the file at "images/my-image.png" web accessible.