5

コンテンツスクリプトをどのページに挿入するかを制御するのに問題があります。 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"); 

答えて

5

これはBug #100106です。 exclude_matchesが正しく機能しません。

この問題を解決するには、exclude_matchesの代わりにexclude_globsを使用してください。

また、お客様のexclude_matchesルールはhttp://news.ycombinator.com/にのみ一致します。
アスタリスクでパターン全体を一致させてください:http://news.ycombinator.com/*

参照:Match patterns

+0

今すぐ試してみると、違いはないようです。私はまだコンテンツスクリプトからのログを見る。実際には、 'exclude_matches'ディレクティブを' ["http:// */*"] 'に設定することができ、コンテンツスクリプトはすべてのhttpページで実行されます。 –

+0

@duckyfuzz参照してください。奇妙な。 'exclude_matches'の代わりに**' exclude_globs' **を使うことで問題は解決します。 –

+0

これは私が[ここ](http://stackoverflow.com/questions/20784654/excluding-domains-from-content-scripts-in-manifest-json-doesntwork- for-css-fil)である。 – herohuyongtao

関連する問題