上传时出现Chrome扩展名.json文件错误 [英] Chrome extension .json file error when uploading
问题描述
我有一个 manifest.json
这样的文件:
I have a manifest.json
file like this:
{
"name": "YouTube Trending to Paid promotion!",
"manifest_version": 2,
"version": "1.0",
"description": "Change Trending to Paid promotion!",
"permissions": ["tabs", "*://*.youtube.*/*"],
"browser_action": {
"default_icon": "icon.png"
},
"content_scripts": [
{
"matches": ["*://*.youtube.*/*"],
"js": ["popup.js"]
}
]
}
对于我的JS扩展,它找到了第41个< span>
并重命名了这些内容。当我直接注入它时,它工作正常。但是当我尝试上传它时,Chrome给了我这个错误消息:'content_scripts [0] .matches [0]'的值无效:主机通配符无效。
For my JS extension that just finds the 41st <span>
and renames the contents. And when I inject it directly, it works fine. But when I try to upload it, Chrome gives me this error message: Invalid value for 'content_scripts[0].matches[0]': Invalid host wildcard.
我的JS如下:
My JS is following:
document.getElementsByTagName("span")[39].textContent="Paid promotion!";
任何人都知道导致错误的是什么?
Anyone got an idea whats causing the error ?
推荐答案
似乎内容脚本匹配略有不同。
Seems Content Script matches are slightly different.
请参阅chrome https://developer.chrome.com/extensions/match_patterns
See the matterns are allowed in chrome https://developer.chrome.com/extensions/match_patterns
"content_scripts": [
{
"matches": ["*://*.youtube.com/*"],
"js": ["popup.js"]
}
]
或使用matches:[< all_urls>]
请参阅 Chrome扩展清单匹配已经由stackoverflow讨论过。
Refer : Chrome Extension Manifest 'Matches' already discussed by stackoverflow.
这篇关于上传时出现Chrome扩展名.json文件错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!