权限'<all_urls>'未知或URL模式格式不正确。

26

我是扩展程序开发新手
我尝试过使用以下权限 URL: "<all_urls> "*" "http://*/*", "https://*/*" 但没有一个匹配模式起作用

完整清单:

{
  "name": "Info",
  "description": "BS System Info",
  "version": "1.0",
  "manifest_version": 3,
  "background": {
    "service_worker": "background.js"
  },
  "content_scripts": [{
    "js": ["script.js"],
    "matches": ["http://*/*","https://*/*","<all_urls>"],
    "css" : []
}],
  "permissions": [
    "storage",
    "activeTab",
    "system.cpu",
    "system.memory",
    "system.storage",
    "system.display",
    "tabs",
    "scripting",
    "http://*/*", "https://*/*", "chrome-devtools://*/*"
],
  "action": {
    "default_popup": "index.html",
    "default_icon": {
        "16": "/images/icon_16.png",
        "32": "/images/icon_32.png",
        "48": "/images/icon_48.png",
        "128":"/images/icon_128.png"
      }
  }
}
2个回答

54

ManifestV3中的网站/ URL权限使用单独的密钥:host_permissions

  "host_permissions": [
    "*://*.example.org/"
  ],
  "permissions": [
    "storage"
  ],

官方迁移指南中了解更多信息,确保仔细研究。


10
"host_permissions": [":///*"], - Nabi K.A.Z.
1
@NabiK.A.Z. 哇!谢谢你!这是整个互联网上唯一一个我能找到如何允许所有主机的地方。 - Juan

1
"host_permissions": ["http://*/*", "https://*/*"],

5
请阅读[答案]并[编辑]您的答案,以包含有关此代码实际解决问题的说明。请记住,您不仅要解决问题,还要教育OP和任何未来读者。 - Adriaan

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接