Chrome扩展资产已被屏蔽

时间:2018-01-23 03:56:14

标签: google-chrome-extension

所以我在我的扩展程序中使用SVG精灵,它在Firefox中运行,但Chrome阻止了资产,因为它是跨域的。

enter image description here

enter image description here

并将其列为可访问网络的资源

"web_accessible_resources": [
    "svgs/*.svg"
],

我不明白为什么Chrome会阻止它。

要添加,我在<svg> / <use>元素中使用SVG精灵。 Chrome似乎阻止了这种情况,至少在使用HTTPS的网站上是这样: Unsafe attempt to load URL chrome-extension://ainfdhapdnpfbjbnjojoediompjnmkom/svgs/fa-regular.svg#clock

但是,Firefox不会以这种方式阻止使用SVG。我使用非SVG精灵文件测试了身体背景图像,如Savaratkar答案中所示,当Chrome阻止<svg> / <use>元素中使用的SVG精灵时,该文件有效

1 个答案:

答案 0 :(得分:0)

不,如果在web_accessible_resources中登记了Chrome,则Chrome永远不会阻止SVG文件加载。

请检查以下内容:

  • web_accessible_resources中提到的svg文件路径/正则表达式是正确的
  • 您正在通过chrome.runtime.getURL
  • 获取svg网址
  • 另外,检查chrome.runtime.getURL功能
  • 中的路径

问题是chrome总是给出相同的错误信息:

(index):1 Denying load of chrome-extension://pdlmeiogifooojmjbihodmcehpmjghho/Takkun.svg. Resources must be listed in the web_accessible_resources manifest key in order to be loaded by pages outside the extension.

...针对与web_accessible_resources相关的任何问题。

我有一些时间和怀疑,所以我在一个简单的chrome扩展测试它: https://github.com/sonalsavaratkar/chrome-extension-seed/tree/so-48393958

它将svg文件加载到body的任何网页的background-image元素。

相关问题