[英]Chrome Extension: Not allowed to load local resource
I'm creating a chrome extension to modify a website, and I'm having trouble loading a web-font. 我正在创建一个chrome扩展来修改网站,我在加载网络字体时遇到了问题。
After my webpack build, I generate a dist
folder. 在我的webpack构建之后,我生成了一个
dist
文件夹。 Inside this folder, I have a main.css
that contains this: 在这个文件夹里面,我有一个包含这个的
main.css
:
@font-face {
font-family: 'FontAwesome';
src: url(chrome://extensions/dilogbnjbadifdhdphnncpfndfocidle/fontawesome-webfont.eot);
src: url(chrome://extensions/dilogbnjbadifdhdphnncpfndfocidle/fontawesome-webfont.eot?#iefix&v=4.6.3) format('embedded-opentype'), url(chrome://extensions/dilogbnjbadifdhdphnncpfndfocidle/fontawesome-webfont.woff2) format('woff2'), url(chrome://extensions/dilogbnjbadifdhdphnncpfndfocidle/fontawesome-webfont.woff) format('woff'), url(chrome://extensions/dilogbnjbadifdhdphnncpfndfocidle/fontawesome-webfont.ttf) format('truetype'), url(chrome://extensions/dilogbnjbadifdhdphnncpfndfocidle/fontawesome-webfont.svg#fontawesomeregular) format('svg');
font-weight: normal;
font-style: normal;
}
This is my webpack publicPath
: 这是我的webpack
publicPath
:
chrome://extensions/dilogbnjbadifdhdphnncpfndfocidle
铬://扩展/ dilogbnjbadifdhdphnncpfndfocidle
All files are on the dist folder. 所有文件都在dist文件夹中。
This is my relevant manifest
configuration: 这是我的相关
manifest
配置:
"web_accessible_resources": [
"fontawesome-webfont.eot",
"fontawesome-webfont.svg",
"fontawesome-webfont.ttf",
"fontawesome-webfont.woff",
"fontawesome-webfont.woff2"
],
PS: I've tried everything on the web_accessible_resources
section, including *.[format]
, *.*
and others. PS:我已经尝试了
web_accessible_resources
部分的所有内容,包括*.[format]
, *.*
等。
This is the error I get: 这是我得到的错误:
Not allowed to load local resource: chrome://extensions/dilogbnjbadifdhdphnncpfndfocidle/fontawesome-webfont.woff2
不允许加载本地资源:chrome://extensions/dilogbnjbadifdhdphnncpfndfocidle/fontawesome-webfont.woff2
Screenshot: 截图:
This is the dist
folder I set as the extension root directory: 这是我设置为扩展根目录的
dist
文件夹:
What may I be doing wrong? 我可能做错了什么?
The correct scheme is chrome-extension://
. 正确的方案是
chrome-extension://
。
See also i18n API for the list of allowed constants in JS/CSS files: 另请参阅i18n API以获取JS / CSS文件中允许的常量列表:
The special message @@extension_id can be used in the CSS and JavaScript files, whether or not the extension or app is localized.
无论扩展程序或应用程序是否已本地化,都可以在CSS和JavaScript文件中使用特殊消息@@ extension_id 。 This message doesn't work in manifest files.
此消息在清单文件中不起作用。
@font-face {
font-family: 'FontAwesome';
src: url(chrome-extension://__MSG_@@extension_id__/fontawesome-webfont.eot);
/* ............. */
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.