简体   繁体   English

将 Chrome MV3 扩展导出到 Firefox MV3

[英]Export Chrome MV3 extension to Firefox MV3

I've created a test extension using manifest V3 that works in chrome我已经使用在 chrome 中工作的清单 V3 创建了一个测试扩展

manifest.json : manifest.json

{
  "manifest_version": 3,
  "name": "test",
  "version": "0.0.1",
  "content_scripts": [
    {
      "matches": ["*://*/*"],
      "js": ["content.js"]
    }
  ]
}

content.js : content.js

alert('test')

I tried running我试过跑步

web-ext run --firefox-preview

A browser window opens, but the extension is not working... Using the --verbose option I find these errors浏览器 window 打开,但扩展程序不起作用...使用--verbose选项我发现了这些错误

 Firefox stderr: [Parent 14212, IPC I/O Parent] WARNING: file /builds/worker/checkouts/gecko/ipc/chromium/src/base/process_util_win.cc:167
 Firefox stderr: JavaScript error: resource://gre/modules/XULStore.jsm, line 58: Error: Can't find profile directory.
 Firefox stdout: console.error: services.settings:
 Firefox stdout: main/whats-new-panel Signature failed  InvalidSignatureError: Invalid content signature (main/whats-new-panel)
 Firefox stdout: console.error: services.settings:
 Firefox stdout: main/whats-new-panel local data was corrupted
console.warn: services.settings: main/whats-new-panel Signature verified failed. Retry from scratch
 Firefox stdout: console.error: services.settings:
 Firefox stdout: main/addons-manager-settings Signature failed again InvalidSignatureError: Invalid content signature (main/addons-manager-settings)
 Firefox stdout: console.error: services.settings:
 Firefox stdout: Message: InvalidSignatureError: Invalid content signature (main/addons-manager-settings)
  Stack:
    InvalidSignatureError@resource://services-settings/RemoteSettingsClient.jsm:169:5
_validateCollectionSignature@resource://services-settings/RemoteSettingsClient.jsm:977:13

As it's stated in this article,正如本文所述,
"The issue is about host permissions, in MV3, they're not granted automatically on install, but instead user needs to grant them at some point. Depending on what's appropriate for your extension, you could ask the user using promise.request(), or they can grant it by going to about:addons, selecting your addon, and flipping the toggle in the permissions tab." “问题是关于主机权限,在 MV3 中,它们不会在安装时自动授予,而是用户需要在某个时候授予它们。根据适合您的扩展的内容,您可以使用 promise.request() 询问用户,或者他们可以通过转到 about:addons,选择你的插件,然后在权限选项卡中切换开关来授予它。”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM