gpt4 book ai didi

javascript - Chrome 扩展 : load different content scripts

转载 作者:行者123 更新时间:2023-12-01 11:38:39 25 4
gpt4 key购买 nike

我想根据当前选择的页面和选项卡加载不同的内容脚本。现在,我有三个内容脚本。我想将其中两个用于一页,第三个用于另一页。

属于第1页:
content_script.jsload_content_script.js
属于第2页:
newtab_content_script.js
现在我的 list 看起来像这样

{
"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"
}
}

我将如何在 list 或其他地方构建它?

最佳答案

为了完整起见,您从 list 中执行此操作的方式是拥有尽可能多的 matches根据需要在“content_scripts”下的 block :

"content_scripts": [
{
"matches": ["http://www.google.com/*"],
"css": ["mygooglestyles.css"],
"js": ["jquery.js", "mygooglescript.js"]
},
{
"matches": ["http://www.yahoo.com/*"],
"css": ["myyahoostyles.css"],
"js": ["jquery.js", "myyahooscript.js"]
}
],

关于javascript - Chrome 扩展 : load different content scripts,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7563379/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com