加载脚本到谷歌浏览器扩展程序 [英] loading script to google chrome extension
本文介绍了加载脚本到谷歌浏览器扩展程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试创建新的扩展,但是在包含JavaScript时遇到了问题:
I'm trying to create new extensions but I'm having a problem when I include the JavaScript:
{
"name": "<name>",
"version": "1.0",
"description": "<description>",
"default_icon": "icon.png",
"content_scripts": [
{
"matches": ["http://*.com"],
"js": ["script.js"]
}
],
"permissions": [
"http://*.com/"
]
}
我遇到此错误:
could not load extension from <path>
Invaild value for 'content_scripts[0].matches[0]':Empty path
推荐答案
您有无效的matches
URL-内容脚本匹配模式需要一个方案, host 和一个 path .该路径包括主机后的第一个斜杠/
(在本例中为*.co.il
).
Chrome浏览器在抱怨您没有路径,因此您必须添加一个.
You have a invalid matches
URL - content script match patterns need a scheme, host, and a path. The path includes the first slash /
after the host (in this case, *.co.il
).
Chrome is complaining that you do not have a path, so you have to add one.
- 如果您只想匹配
http://*.co.il
,只需将其更改为http://*.co.il/
. - 如果要匹配所有路径,请将其更改为
http://*.co.il/*
.
- If you want to match only
http://*.co.il
, just change it tohttp://*.co.il/
. - If you want to match all paths change it to
http://*.co.il/*
.
这篇关于加载脚本到谷歌浏览器扩展程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文