I put a lot of stuff in searching an easy way to develop a Firefox extension, but I am unable to create an extension. Kindly tell me the file structure of Firefox extensions and an easy way to install the extension.
Firefox extension .xpi file structure: description, contents, creation, and installation
8.6k views Asked by roushan kumar Singh At
2
There are 2 answers
0
David
On
Generate a signed .xpi
- Install web-ext with NPM, maybe you will need root privileges:
npm install --global web-ext - Go to https://addons.mozilla.org/es/developers/addon/api/key/ and generate a new API KEY.
- Go to your extension folder, open a terminal and execute:
web-ext sign --api-key=$AMO_JWT_ISSUER --api-secret=$AMO_JWT_SECRETwhere $AMO_JWT_IUSSER and $AMO_JWT_SECRET are the keys you generated in the previous step.
Related Questions in GOOGLE-CHROME-EXTENSION
- How to send data from content.js to background.js
- How can I make an array in my extension using information from a webpage?
- Is it possible to manipuate 3rd party Chrome Extensions Network Reqeuests?
- How to call a function in javascript for google chrome extension?
- Creating Chrome extension, but display text from Javascript file is not showing up on HTML's display. The HTML is the InnerHTML of another HTML file
- Error received when sending message across JS files: Unchecked runtime.lastError: Could not establish connection. Receiving end does not exist
- How do I highlight email address strings through a chrome extension?
- How do i load a Chrome extension when manifest.json is in a subfolder (app) instead of main folder
- Chrome extension MV3: persistent service worker die after wake up from hibernation
- Attempting to Bundle a Require Command For a Chrome Extension
- Embedded google map throws net::ERR_BLOCKED_BY_CLIENT in chromium(Brave) browser
- Reading the user's console errors from a chrome extension
- Persistent Browser Extension Reinstalls Itself: How to Eradicate ‘YOfficeStop’ Permanently on Windows 7?
- Can be their an extension to save pages in as offline in the browser itself?
- How can I modify javascript native fetch function from an extension?
Related Questions in FIREFOX-ADDON
- Firefox extension background script terminated preemptively
- Can be their an extension to save pages in as offline in the browser itself?
- I'm building addon for firefox user can take screenshot, but browser.runtime.sendMessage returns undefined
- Detecting how much 'White' color there is, on an embedded video on a webpage
- How to programatically fast forward video on a website
- Convert code from manifest v2 to v3 chrome extension
- How to request host_permissions at install time with Manifest V3?
- How to store fetch headers in javacript from website I don't own?
- Firefox debugger server changes my search bar coloring
- How can the omnibox suggestions be styled in Firefox?
- How do I fix the following issues with my port of a manifest v2 browser extension to manifest v3?
- How Can I Edit the Body of an API Request With a Firefox Addon
- HTMLButtonElement.click() in content script doesn't work in second screen
- Error sending message to background script: Error: Could not establish connection. Receiving end does not exist (FireFox Extension Test)
- crossOrigin blocks requests for translate.google.com
Related Questions in FIREFOX-ADDON-SDK
- Cannot access tab DOM using React + Firefox extension
- How can I upload an image to a site with a userscript/extension?
- Uncaught (in promise) Error for a couple of cycles then stopping
- How to use Selenium to install Firefox browser add-on?
- How to write/create a local text file inside of a firefox profile through a firefox extension?
- how do I detect if the tab has changed or refreshed in a firefox addon
- How to reuse a javascript function between content script and service worker in MV2/MV3-compatible way?
- Firefox extension proxy
- Why doesn't the content script open a new window using the windows.create method of the JavaScript APIs for WebExtensions to develop Firefox add-ons?
- Firefox extension share async function with return gives => Error: Permission denied to access property "then"
- how set badge text after loaded site on my extensions firefox
- Rerun Firefox addon's script on URL dynamic change
- How to sleep in a firefox extension (old and native JS methods not working)?
- insert content from firefox webextension
- loading simple iframe from extension firefox
Related Questions in FIREFOX-ADDON-WEBEXTENSIONS
- Firefox extension background script terminated preemptively
- I'm building addon for firefox user can take screenshot, but browser.runtime.sendMessage returns undefined
- My service worker is not connecting to my content script in my Chrome extension. How do I fix this?
- How do I fix the following issues with my port of a manifest v2 browser extension to manifest v3?
- Delete all cookies in the browser using js?
- Changing src image with Firefox extension
- How to open a deeplink without creating a new tab or window in a web extension
- firefox extension, read background script variable from popup?
- WebExtensions : Can you access a JSON object that was fetched by the webpage
- browser.declarativeNetRequest property is undefined despite processing static DNR redirects
- Access Chrome APIs in a web application built with ReactJS
- WebExtension does not start content script on Android (geckoview)
- webRequest API not working with manifest v3 extension
- browser.webRequest.onBeforeRequest is not being triggered in my firefox extension
- How to cache storage in web extensions?
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
.xpifile format (Extension Packaging)The
.xpifiles that are used as containers for Mozilla (Firefox, Thunderbird, etc.) extensions are merely zip archives that have had the file extension changed to.xpiwith the files added to the archive using either "deflate" compression, or uncompressed. If you use any other type of compression, other than "deflate", or "store" (uncompressed), you will get an error like:The files start in the root directory of the zip compressed archive (i.e. there is not an empty first level directory which then contains the files).
The contents of the archive could be only a few files to any number of files. The files that must be included depend on the type of add-on which you are packaging. If you are planning on using the Add-on SDK, then you probably don't need to know the format for these files, as much of it is abstracted by using the
jpmtool. If you have no idea what I am talking about, you may want to read up on the different types of add-ons for Firefox (WebExtensions, Add-on SDK, Bootstrap/Restartless, and Overlay/Legacy/XUL).WebExtensions:
At a minimum, you will have a manifest.json file which describes the extension. You will, almost certainly, have additional files. The chrome.manifest, install.rdf, and package.json files used in other types of add-ons are not used in WebExtension add-ons. You should not have those files.
Add-on SDK:
The .xpi file for a Firefox Add-on SDK extension should be created by executing
jpm xpi. Add-on SDK extensions are described in a package.json file. When you runjpm xpiyour add-on is translated to being a Bootstrap/Restartless add-on. This is done by translating the package.json file into a install.rdf, creating a chrome.manifest file and adding some wrappers to the JavaScript. You should not try to perform this process yourself, unless doing so is necessary for your add-on to function (which would be quite rare).Bootstrap/Restartless and Overlay/legacy:
At a minimum, you have install.rdf, and chrome.manifest files. Bootstrap/Restartless add-ons will also have a bootstrap.js file. There will almost always be additional files. These types of add-ons do not use a package.json, nor a manifest.json.
My very simple Bootstrap/Restartless extension, Print Button is Print (changes the print button to print instead of print preview), has the following structure:
.pngfiles are the icon for this extension at various resolutions.Creating the .xpi file
You can use whatever method you desire to create the .zip file, which is renamed to .xpi. Keep in mind the requirement that the only compression method that is supported is "deflate", but files can also be added to the archive uncompressed. Your top level files (e.g. which ever you have of manifest.json (WebExtensions), or everything else: chrome.manifest, and install.rdf) should be in the root directory of the archive, not in a subdirectory.
To create the
.xpifile I use a batch file, which uses a combination of DOS and Unix/Linux (actually Cygwin) commands:mkxpi.bat:
This removes any old version of the
.xpifile. It then creates a new.xpifile using,-1, minimal compression (speed of access is more important than saving space), which forces only storing uncompressed or using "deflate". The new .xpi will contain all files and subdirectories*, but ignoring all the files in the xpi.ignore text file ([email protected]). Ignoring files is used because I have other things in the directory (e.g..gitdirectory,.bakfiles auto-created from editor, etc.). Once the.xpifile is created the script executespauseso I can verify which files were included, that there were no errors, etc., instead of just having the window disappear and assuming that everything is fine.My xpi.ignore file is a bit long, as it accumulates cruft from various projects and is rarely cleaned out:
Installing extensions
As normal extensions:
In order to install an extension as a normal add-on into a branded Release or Beta version of Firefox it must be signed by Mozilla. This is done by submitting it to AMO. You can install unsigned extensions as normal add-ons into other versions of Firefox (e.g. Firefox Developer Edition, Firefox Nightly, Unbranded Beta, or Unbranded Release) by setting
xpinstall.signatures.requiredtofalseinabout:config.If you choose, in a particular installation of Firefox, you can completely disable the add-on signing requirement. For more information, you can see my answer: How can I disable signature checking for Firefox add-ons?
Installing an extension (i.e. the
.xpifile) can be a simple matter of dragging and dropping it onto a Firefox window running the profile in which you desire it installed. For development/testing, you can have the extension be in a directory on your local drive by using a Firefox extension proxy file (create a file named as the extension's<em:id>(in install.rdf for Bootstrap/Restartless and Overlay/Legacy) in the profile's extensions directory containing one line with the complete path to the directory containing the extension's files). Depending on what your goal is (one profile, all profiles, all users, which OS, etc.), there are other options as to how to install extensions.As temporary add-ons:
The only type of extension which can not be installed as a temporary add-on is Overlay/Legacy. Such extensions require the browser to be restarted after the install prior to being functional. As such, they can not be temporary.
To install an extension as a temporary, navigate to
about:debugging. From that page, click on Load Temporary Add-on, then navigate popup to the appropriate folder and select either an .xpi file, or any file in the directory. If you select a file other than an .xpi file, it is assumed that the directory contains unpacked add-on files which will be automatically identified.