Omair Shamshir
Omair Shamshir

Reputation: 2136

Google chrome extension include_globs not working

In my google chrome extension i want to insert a JS file in a wild card url using the include_globs but it is not working

"content_scripts": [
{
  "matches": [
    "http://stackoverflow.com/*"
  ],
  "include_globs": [
    "*google*"
]

  "js": [
    "scripts/content-scripts/utils.js",

  ]
},

This script is inserted in stackoverflow but not in google.

Upvotes: 0

Views: 1530

Answers (1)

Xan
Xan

Reputation: 77531

You misunderstand how globs work.

They offer additional filtering after matches filter is applied.

include_globs
array of string
Optional. Applied after matches to include only those URLs that also match this glob. Intended to emulate the @include Greasemonkey keyword. See Match patterns and globs below for more details.

So your manifest applies to https://stackoverflow.com/questions/tagged/google-chrome-extension but not https://www.google.com/ or http://stackoverflow.com/

I understand your desire to use a glob: you basically want a google.* pattern. That's not allowed due to inherent security risks attached.

You can see the question Match pattern for all google search pages to see why and what are the possible workarounds.

Upvotes: 1

Related Questions