【发布时间】:2015-08-25 14:48:22
【问题描述】:
我正在尝试编写我的第一个 chrome 扩展程序,但无法正确加载内容脚本。我希望它只加载到 You Tube 的主页(即https://www.youtube.com/);但是,我不希望它为任何其他页面加载,例如,在用户搜索之后(即https://www.youtube.com/results?search_query=programming)。这是我所拥有的:
"content_scripts": [
{
"matches": ["*://*.youtube.com/*"],
"exclude_matches": ["*://*.youtube.com/"],
"js": ["jquery.js", "content.js"]
}
]
使用上面的代码,content.js 根本不加载;但是,如果我取出“exclude_matches”,内容脚本会加载到https://www.youtube.com/。
【问题讨论】: