Questions tagged [firefox-addon-webextensions]

WebExtensions are a way to write Firefox extensions that are compatible with other browsers such as Google Chrome and Opera. Microsoft plans to bring support to their Edge browser soon. Questions requiring a MCVE (i.e. debugging questions) should include your manifest.json file in addition to all other files needed to duplicate the problem.

WebExtensions are a new way to write Firefox extensions. It is available in all current versions of Firefox (version 48.0+).

The WebExtensions API is designed for cross-browser compatibility. To a large extent, the API is compatible with the extension API supported by Google Chrome and Opera, with Microsoft Edge following soon.

The documentation for Firefox WebExtensions can be found at MDN :: Add-ons - WebExtensions.

The WebExtensions API is under active development. What is supported improves in each newer version of Firefox. You should pay attention to the Browser Compatibility section on the API documentation page for any part of the API you are using to verify the portions of the API you are using are supported in the version of Firefox you are using. You may want to strongly consider testing your extension with either Firefox Developer Edition, or Firefox Nightly.

Minimal, Complete, and Verifiable Examples will almost always need a manifest.json file in order to be complete, in addition to any other files needed. The manifest.json file contains key information which is necessary in many situations to determine why an extension is not working.

For more information on Firefox Add-on types see the full documentation on Mozilla Developer Network: Add-ons.

1541 questions
6
votes
2 answers

Shared vuex state in a web-extension (dead object issues)

I'm trying to use a shared vue.js state in a web extension. The state is stored in the background script's DOM and rendered in a popup page. First attempt My first attempt was to use a simple store without vuex: background.js var store = { count:…
mickael9
  • 456
  • 2
  • 12
6
votes
2 answers

firefox pick page action icon for dark / light themes

I'm writing a web extension works on firefox. I want my icon works similar to the behavior of Firefox built in "Take a screenshot". The screenshot icon appeared in different colors when it shown in light theme / dark theme / in the menu. I just…
tsh
  • 4,263
  • 5
  • 28
  • 47
6
votes
2 answers

Firefox Extension API - permissions.request may only be called from a user input handler?

I'm using the Firefox permissions API documented HERE I'm having a problem with the request method, wherein all of my permissions requests result in: Error: permissions.request may only be called from a user input handler You can produce this in…
6
votes
0 answers

Can I make a browser extension return a custom response for a web request?

In a Firefox or Chrome(1) extension (using WebExtensions), is it possible to interrupt a request and return an alternate response instead, preventing the network request? What I'd like to do is store some html data (dynamically) using the storage…
6
votes
2 answers

How to unittest Firefox 57 WebExtensions?

The older Firefox "Add-ons" API had a built-in unittest layer sdk/test that allowed testing. This doesn't seem to be available any more. Additionally the use of "package/require" allowed code to be separated into "js code-only" packages that were…
Greg
  • 2,549
  • 2
  • 24
  • 30
6
votes
1 answer

How to check if a Firefox WebExtension is installed or not with page JavaScript?

I have developed a WebExtension for Firefox and my website works with the extension as a prerequisite. I need to check programmatically whether the extension is installed or not and if not ask the user to install it. I am not able to find a way how…
6
votes
2 answers

Does a web extension need to explicitly load content scripts?

I'm trying to write a simple Web Extension. Currently I'm following the various tutorials and trying to understand the architecture. Interaction with specific tabs is done with content_scripts that are injected into the source code of a website. It…
6
votes
2 answers

Cognito: is it possible to host UI on my domain and redirect to my domain too?

I want to use Cognito for my WebExtension for Chromium and Firefox. I have two problems. 1) Hosted UI from Cognito not at my domain - so users may think why: For branding and security I want to host UI from Cognito on my domain. Because my product…
6
votes
1 answer

Firefox WebExtention API: TypeError: browser.browserAction is undefined

While migrating my old Firefox add-on to WebExtension API, failed to understand while I am getting this error: TypeError: browser.browserAction is undefined Here is the manifest.json: { "manifest_version": 2, "name": "My Login", "version":…
Racoon
  • 951
  • 3
  • 14
  • 32
6
votes
4 answers

Inject scripts error: Script returned non-structured-clonable data on Firefox extension

I want to inject script from firefox web extension to tabId thought browser.tabs.executeScript API. I have a file Browser.js MyFunc.Browser = (function() { var self; function Browser() { self = this; } Browser.getExtensionURI =…
Tam Vo
  • 301
  • 4
  • 13
6
votes
2 answers

Firefox WebExtension, isolated HTML overlay

I'm looking for a way to display an isolated overlay on some websites using WebExtensions. An iframe would seem like the way to go for this as it provides a whole separate scope for css, js and the DOM. And another neat thing is that the target…
6
votes
1 answer

Firefox WebExtensions: can not get canceled request data

During playing with Firefox WebExtensions I've created a simple add-on that cancels certain POST request and reads its params: manifest.json { "description": "Canceled webRequests data", "manifest_version": 2, "name": "webRequest-demo", …
6
votes
1 answer

How to properly override Content-Type header in Firefox Web Extension?

Suppose HTML files coming from a server have these headers: Content-Type: application/octet-stream Content-Disposition: attachment; I would like to alter the headers in a web extension (so that the HTML file is displayed as a regular web…
6
votes
1 answer

Firefox WebExtension settings page

I have a settings page on my WebExtension, but I dont know how to acces the values of the settings with javascript. Current .xul-File:
6
votes
2 answers

Need workaround for calling alert() from background script

Calling alert() from the background script is allowed in Google's Chrome, but not in Firefox (WebExtensions) which I am porting my Chrome extension to. So, I need a workaround to get an alert dialog up. I'm not asking for anything else other than…
AlJo
  • 161
  • 1
  • 13