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
0
votes
0 answers

How to access file metadata using webextensions?

I am new to webextensions, and I am having trouble following the documentation. What is the way to access file metadata such as file size for a file stored on disk? I see there is Mozilla documentation on OS.File modules, with features such as…
Cam U
  • 340
  • 3
  • 10
0
votes
1 answer

Error: Not allowed to define cross-origin object as property on [Object] or [Array] XrayWrapper

How can I avoid the following error and why do I get it? Edit: Maybe I have to ask how I can make objects from a privileged scope visible to a less privileged scope. My goal is to export/return dynamically created objects to the page script as a…
0
votes
0 answers

WebExtension how to send data from popup.html to content scripts

i am using the following codes to send a variable/message from the popup toolbar to the content scripts. however, i am not able to retrieve anything from the content scripts. When i send 'asdf' over to the content scripts, i am able to see…
jona
  • 592
  • 1
  • 4
  • 16
0
votes
0 answers

Simple 3-line browser extension - tons of warnings for no reason? No debugging possible

I just tried to write an incredibly simple browser extension. It simply displays a github cookie: background-script.js browser.cookies.get({url:"https://github.com/",name:"logged_in"}) .then(console.log) .catch(console.error) manifest.json { …
0
votes
1 answer

Given a moz-extension:// URL opened by bookmark, how can I switch to tab using extension code?

This is related to some other questions I am working on. Say, for whatever reason, a user has bookmarked a page (call it pageURL of the pattern moz-extensions://MY-OWN-WEBEXT-ID/*) intended to be opened from a browser action context menu, and opened…
user2895783
0
votes
3 answers

Firefox Native Messaging runtime.LastError not giving any errors in case of no Native application installed on Connectnative

I am trying to check whether the Native app is installed or not , If it is not I have to prompt the user to download it from the webpage. For chrome I used to achieve by checking the error messages from runtime.LastError. However in case of Firefox…
rohan
  • 161
  • 1
  • 1
  • 10
0
votes
1 answer

Listen in Content Script for when AJAX response changes textarea val

I'm writing a WebExtension for a text editor. When the user clicks a button, format the editor fires an ajax request and then returns the formatted text. I need my addon to listen for a change in the textarea. I've tried using onchange or oninput,…
0
votes
1 answer

Firefox WebExtensions: How to open a background page as a unique tab?

The question: In Firefox WebExtensions, from arbitrary background origins, how can I open an arbitrary page in a tab, uniquely? Requirements: 1) Arbitrary background origins. My initial use case is from browser_action contextMenus. However, the…
user2895783
0
votes
1 answer

tab.openerTabId undefined in Firefox WebExtension

I have this code in background script of my Firefox WebExtension, but it prints : "OPENER ID: undefined" each time new tab is created: chrome.tabs.onCreated.addListener(function (tab) { console.log("OPENER ID: " + tab.openerTabId); }); What is…
0
votes
1 answer

Can't successfully run executeScript from the background script unless I load the popup page/script first

I've trying to run execute script from my background script using keyboard shortcuts, it doesn't work and returns: Error: No window matching {"matchesHost":[]} But if I just open the popup page, close it, and do the same, everything works. I've…
0
votes
1 answer

Using the same page (and JS) as the background and the popup in FireFox webextension without it reloading

I'm coding a web extension for FF. Currently I'm using the same page as the popup (browser_action) and the background: "background": { "page": "popup/index.html" }, "browser_action": { "default_icon": "icons/index32.png", …
0
votes
0 answers

How to get url as string from JSON when sending messages in Firefox or Chrome?

For a Firefox (or Chrome) addon, I want a content script to send messages containing text IDs and urls to a background script. I want the background script to output the IDs and urls as simple strings using console.log(), but the urls are coming out…
Cam U
  • 340
  • 3
  • 10
0
votes
2 answers

Modify javascript to expose a function-scoped variable

I would like to be able to expose a function-scoped variable that is part of a website's (not mine) javascript. Here's a simplified example: function addHooks(e, t, n, i) { var props = { // Would like to expose this …
Guru Prasad
  • 4,053
  • 2
  • 25
  • 43
0
votes
1 answer

Can I use Services.prefs in WebExtensions for Firefox or is there an alternative?

I am using Firefox preferences/service API to set preferences in an Extension. Specifically I am using Services.prefs.setIntPref("network.proxy.type", 2); and Services.prefs.setCharPref("network.proxy.autoconfig_url", value); I want to re-implement…
The Surrican
  • 29,118
  • 24
  • 122
  • 168
0
votes
1 answer

Firefox API equivalence for Browser.management.onInstalled

I am porting over a Chrome plugin to Firefox as a Webextension. I have gotten almost all the way through my rather large codebase and switched things that were incompatible, however a management.onInstalled and .onUninstalled, onEnabled and…