コンテンツスクリプトをどのページに挿入するかを制御するのに問題があります。 chrome extension developer guideは、manifest.json
に「exclude_matches」指示文を使用して特定のページをインジェクションから除外できると指定しています。manifest.jsonのexclude_matchesは何もしませんか?
しかし、これは効果がないようです。私のコンテンツスクリプトは、私が無視して指定したページでも実行されます。
steps to reproduce in a Gistを入れました。コードはavailable on Githubです。
私が間違っていることは何ですか?
manifest.jsonを
{
"name": "Testing Extension",
"version": "1.0",
"description": "Test the chrome extensions exclude_matches.",
"content_scripts": [{
"matches": ["http://*/*", "https://*/*"],
"exclude_matches": ["http://news.ycombinator.com/"],
"js": ["content.js"]
}]
}
content.js
console.log("hello from the content script");
今すぐ試してみると、違いはないようです。私はまだコンテンツスクリプトからのログを見る。実際には、 'exclude_matches'ディレクティブを' ["http:// */*"] 'に設定することができ、コンテンツスクリプトはすべてのhttpページで実行されます。 –
@duckyfuzz参照してください。奇妙な。 'exclude_matches'の代わりに**' exclude_globs' **を使うことで問題は解決します。 –
これは私が[ここ](http://stackoverflow.com/questions/20784654/excluding-domains-from-content-scripts-in-manifest-json-doesntwork- for-css-fil)である。 – herohuyongtao