10

私のマッチスキーム:

"content_scripts" : [
 {
   "matches" : [
     "https://stackoverflow.com/questions#epic*"
   ],
   "js" : ["silly.js"]
 }
],

したがって、ユーザーが Web ページ ( https://stackoverflow.com/questionsなど) にアクセスした場合、追加#epicするとhttps://stackoverflow.com/questions#epicに移動しますが#epic、URL の末尾にあるため、アクティブになりますコンテンツ スクリプトsilly.js

それが起こるはずですが、うまくいきません。

4

1 に答える 1

20

コンテンツ スクリプト、マッチ パターンを参照してください。一致パターンは、URL のフラグメント部分では
機能しません。

コンテンツ スクリプトを特定のハッシュに制限するにはinclude_globsand/orexclude_globsプロパティを使用します。

たとえば、この場合、次のように使用できます。

"content_scripts" :     [ {
    "matches" :         [
        "*://stackoverflow.com/questions/*"
    ],
    "include_globs" :   ["*#epic*"],
    "js" :              ["silly.js"]
} ],
于 2013-04-11T23:01:28.120 に答える