【发布时间】:2011-11-25 16:14:01
【问题描述】:
我想根据当前选择的页面和选项卡加载不同的内容脚本。现在,我有三个内容脚本。我想将其中两个用于一页,第三个用于另一页。
属于第1页:
content_script.js
load_content_script.js
属于page2:
newtab_content_script.js
现在我的清单看起来像这样
{
"name": "A plugin for AdData express. Generate an instant excel document from the brands you check mark.",
"version": "1.0",
"background_page": "background.html",
"permissions": [
"cookies",
"tabs",
"http://*/*", "https://", "*", "http://*/*", "https://*/*",
"http://www.addataexpress.com", "http://www.addataexpress.com/*"
],
"content_scripts": [
{
"matches": ["<all_urls>","http://*/*","https://*/*"],
"js": ["load_content_script.js", "content_script.js", "newtab_content_script.js", "jquery.min.js", "json.js"]
}
],
"browser_action": {
"name": "AdData Express Plugin",
"default_icon": "icon.png",
"js": "jquery.min.js",
"popup": "popup.html"
}
}
我将如何在清单或其他地方构建它?
【问题讨论】:
-
您也可以使用 'chrome.declarativeContent.RequestContentScript' 如本答案所述:stackoverflow.com/a/26677279/176140
-
您是否考虑过让Darin's answer 成为公认的答案?这似乎是最直接的解决方案。
标签: javascript google-chrome permissions google-chrome-extension manifest