我建立了一个chrome扩展程序,我想让它在我看一些特定的网站时自动工作,说" Youtube",我怎么能做到?任何帮助将不胜感激。
{
"manifest_version": 2,
"name": "My extension",
"description": "bla bla",
"version": "1.0",
"browser_action": {
"default_icon": "gjx.png",
"default_popup": "popup.html"
},
"permissions": [
"http://localhost/*",
"tabs",
"cookies",
"storage"
],
"background":["crawler.js"],
"content_scripts":[{
"matches": ["*://*.youtube.com/*"],
"js": ["crawler.js"]
}]
}
答案 0 :(得分:0)
例如,此处script.js
将自动在您所在的Youtube页面上执行。
manifest.json
:
{
"content_scripts": [{
"matches": ["https://www.youtube.com/*"],
"js": ["script.js"]
}],
"permissions": [
"tabs", "http://*/*"
]
}
答案 1 :(得分:0)
您需要将所需的网址格式添加到permissions
中的manifest.json
。
你有:
"permissions": [
"http://localhost/*",
"tabs",
"cookies",
"storage"
]
您必须添加所需的网址格式,例如:
"permissions": [
"http://localhost/*",
"tabs",
"cookies",
"storage",
"*://*.youtube.com/*
]