Search code examples
google-chrome-extensioncontainscontent-scriptcontain

Chrome Extension: content_scripts - matches - contains


I looked at match patterns documentation, but can't find a way to have matches to contain a text.

E.g. how to make it work only for links that contains test/22?

Tried:

"content_scripts": [
    {
        "matches": ["https://*/test/22*"]
    }
}

and many others, no luck.


Solution

  • Each section of the url match should be defined (scheme, host, path), you may use * for the parts that may contain any value:

    "https://*/*test/22*"
             ^ ^
          host |
               path starts here