Manifest v3 资源必须列在 web_accessible_resources 中 [英] Manifest v3 Resources must be listed in the web_accessible_resources

查看:85
本文介绍了Manifest v3 资源必须列在 web_accessible_resources 中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

即使image/copy.svg"我也收到这个错误在 manifest.json 中正确声明

I get this error even if "image/copy.svg" is properly declared in the manifest.json

拒绝加载chrome-extension://pofbdjeepddggbelfghnndllidnalpde/images/copy.svg.资源必须列在 web_accessible_resources 清单键中以便由扩展程序外的页面加载.

Denying load of chrome-extension://pofbdjeepddggbelfghnndllidnalpde/images/copy.svg. Resources must be listed in the web_accessible_resources manifest key in order to be loaded by pages outside the extension.

如果我去 chrome-extension://pofbdjeepddggbelfghnndllidnalpde/images/copy.svg 我可以成功看到加载的图像.

If I go to chrome-extension://pofbdjeepddggbelfghnndllidnalpde/images/copy.svg I can successfully see the loaded image.

css/style.css

.copy-icon{
    content:url('chrome-extension://__MSG_@@extension_id__/images/copy.svg');
    height: 16px;
    width: auto;
    margin-right: 0px;
}

html

<button alt="Copy to clipboard" class="clipboard" data-clipboard-text="TEXT">
  <img class="copy-icon"></img>
</button> 

manifest.json

manifest.json

    "manifest_version": 3,
    "content_scripts": [
    {
      "matches": ["https://*.example.com/*"], 
      "js": ["contents/results.js"],
      "css": ["css/style.css"],
      "run_at": "document_end"
    }
  ],
    "web_accessible_resources": [{
        "resources": ["images/copy.svg"],
        "matches": [],
       "extension_ids": []
      }], 

推荐答案

matches 键应指定在何处公开这些资源.
您可以使用 <all_urls> 在任何地方公开它们.

The matches key should specify where to expose these resources.
You can use <all_urls> to expose them everywhere.

"web_accessible_resources": [{
  "resources": ["images/copy.svg"],
  "matches": ["<all_urls>"],
}],

这篇关于Manifest v3 资源必须列在 web_accessible_resources 中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆