0
votes

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?

1

1 Answers

1
votes

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.