Greasemonkey/Tampermonkey @match for a page with parameters
According to the documentation for @match
, it doesn't appear that query string parameters are something the Greasemonkey engine will match on:
https://developer.chrome.com/extensions/match_patterns.html
@match
only works on the protocol/scheme, host, and pathname of a URL.
To trigger off the query parameters, you can either use @include
or use @match
and also test the URL yourself.
Note that the @match
approach performs faster.
With @include
, you can use a regex syntax. See, also Include and exclude rules.
In this case, use either:
...
// @include /^https?://example\.com/page\.php*key1=value1*/
// ==/UserScript==
**Or:**
...
// @match *://example.com/page.php*
// ==/UserScript==
if (/\bkey1=value1\b/.test (location.search) ) {
// DO YOUR STUFF HERE.
}