chrome-extension:// 在 Firefox 附加组件中
chrome-extension:// in Firefox add-on
我正在将 Chrome 扩展移植到 Firefox。在 Chrome 扩展中,我参考了 "chrome-extension://" + chrome.runtime.id
、
下的资源
foobar = {
config: {
fontURL: "chrome-extension://" + chrome.runtime.id + "/fonts"
}
};
如何将其翻译成 Firefox?
Firefox 将 id 随机化,因此即使您编写 moz-extension://
它也无济于事。
使用 chrome.runtime.getURL
,如 web_accessible_resources
documentation 中所述:
let foobar = {
config: {
fontURL: chrome.runtime.getURL("/fonts")
}
};
chrome
命名空间在 Firefox 和 Chrome.
中均有效
有关移植 Chrome 扩展和不兼容性的更多信息:MDN。
我正在将 Chrome 扩展移植到 Firefox。在 Chrome 扩展中,我参考了 "chrome-extension://" + chrome.runtime.id
、
foobar = {
config: {
fontURL: "chrome-extension://" + chrome.runtime.id + "/fonts"
}
};
如何将其翻译成 Firefox?
Firefox 将 id 随机化,因此即使您编写 moz-extension://
它也无济于事。
使用 chrome.runtime.getURL
,如 web_accessible_resources
documentation 中所述:
let foobar = {
config: {
fontURL: chrome.runtime.getURL("/fonts")
}
};
chrome
命名空间在 Firefox 和 Chrome.
有关移植 Chrome 扩展和不兼容性的更多信息:MDN。