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
10
votes
4 answers

"Error: Missing host permission for the tab" on view-source: URLs

I rewrote my extension to WebExtensions for Firefox and Google Chrome, and it works fine for HTTP/HTTPS. However, it no longer works on URLs with the view-source: scheme. (These URLs are the HTML source code of web pages shown by CTRL+U.) Firefox 57…
Andrew
  • 1,619
  • 3
  • 19
  • 24
10
votes
3 answers

How get raw response body inside a Web Extension for Firefox 55?

I try to get the raw response body inside a Web Extension using Firefox 55.0.3. Only "solutions" I have seen for now: Repeat the request (I absolutly don't want to repeat the request) Using Javascript to get innerHTML attribute of HTML tags such as…
Benoît Zu
  • 1,217
  • 12
  • 22
10
votes
1 answer

chrome.tabs.executeScript(): How to get result of content script?

According to the documentation for chrome.tabs.executeScript (MDN), the callback function accepts an "array of any result" result set from the execution of the script(s). How exactly do you use this to get results? All of my attempts end up with…
10
votes
2 answers

In chrome extension, how to send a cross-origin message from a parent content script to a content script in specific child iframe

I am developing a Chrome extension with a manifest that, for now, enables access to all hosts. The background script injects content scripts into all frames. After the DOM is loaded, the content script in the top page/frame begins to walk the DOM…
10
votes
2 answers

Firefox WebExtensions and Cross-domain privileges

I am trying to port a chrome extension to firefox using the relatively new WebExtensions from Firefox. I always getting the following error Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at ....…
Chris
  • 101
  • 1
  • 4
9
votes
0 answers

Firefox can't load temporary addon: Error: Can't find profile directory

I'm starting to work on a small firefox plugin, it's a basic js script, no problem on this side. I've made a few successfull tests, and had a a few satisfying results. But starting yesterday, i'm unable to laod any temporary addons in…
Carpette
  • 191
  • 1
  • 3
9
votes
1 answer

How do I use Wasm in the content script of a Firefox web extension?

I am building a Firefox addon using Rust. I am trying to insert HTML and do stuff on specific pages. Apparently, a content script is the thing I want to use. My content script is: import("../crate/pkg").then(({ Addon }) => { const addon =…
9
votes
1 answer

Firefox fetch API: How to omit the "origin" header in the request?

If you make a fetch request in a Firefox WebExtension, it will automatically set the "origin" header. For example, when I run this code inside a WebExtensions ... fetch('http://example.com/') ... the resulting request contains the header: "origin:…
Philipp Claßen
  • 41,306
  • 31
  • 146
  • 239
9
votes
3 answers

How do I install WebExtension that developed by myself to Firefox Nightly?

I already know the way to temporarily install an add-on for debugging. However, I want to install it persistently. I do not want to upload it to AMO, because I've developed it for use by myself only. How do I install it on Firefox…
KiYugadgeter
  • 3,796
  • 7
  • 34
  • 74
9
votes
2 answers

tabs.getCurrent() result is undefined?

Not sure why I cannot retrieve info about current tab using getCurrent() when I navigate to, say, amazon.com or google.com and hit the browser icon for a browser action. Any hints on what I am missing? MANIFEST: { "name": "testGetCurrentTab", …
Cam U
  • 340
  • 3
  • 10
9
votes
1 answer

Save Data URI as file using downloads.download() API

Update I have solved this problem (thanks to @DanielHerr) by using a Blob URL / Object-URL (URL.createObjectURL(blob)), however I am still curious to why this error exists when using data: URLs I am creating a extension using the WebExtensions API,…
9
votes
3 answers

Is there a FF equivalent to chrome.declarativeContent.onPageChanged?

I'm porting a Chrome extension to Firefox WebExtensions and I'm stuck on finding a workaround for chrome.declarativeContent.onPageChanged. My FF Webextension contains a Page Action that must be shown when navigating on certain websites. However,…
9
votes
3 answers

chrome.webrequest.onbeforerequest.addlistener for Firefox?

Google Chrome contains some functionality in its chrome.webrequest API (e.g., http://developer.chrome.com/extensions/samples.html#12a7bf1490a26359eadf10917e37c5b9 ) that can be used to redirect certain URLs to a specified web page. The Chrome…
8
votes
1 answer

Transfer/synchronize WebExtension data between Firefox Desktop and Firefox Android

I'm making a WebExtension (for Firefox) that tracks lists for the user. The user can add/remove elements from a list, or switch an element from one list to another, which means the extension needs the most recent version of the lists to work…
8
votes
1 answer

Override JavaScript function from browser extension

I am creating a web extension to help detecting postMessage activity in websites. Therefore, I want to detect it when a page attaches a message event listener, for example by calling this code: window.addEventListener("message", ...) Apparently it…