Nico Schlömer
Nico Schlömer

Reputation: 58951

chrome-extension:// in Firefox add-on

I'm porting a Chrome extension to Firefox. In the Chrome extension, I refer to resources under "chrome-extension://" + chrome.runtime.id,

foobar = {
  config: {
    fontURL: "chrome-extension://" + chrome.runtime.id + "/fonts" 
  } 
};

How to translate this to Firefox?

Upvotes: 0

Views: 84

Answers (1)

woxxom
woxxom

Reputation: 73866

Firefox randomizes the id so even if you write moz-extension:// it won't help you.

Use chrome.runtime.getURL as explained in web_accessible_resources documentation:

let foobar = {
  config: {
    fontURL: chrome.runtime.getURL("/fonts")
  } 
};

chrome namespace works both in Firefox and Chrome.

More info on porting Chrome extensions and incompatibilities: MDN.

Upvotes: 1

Related Questions