In Tampermonkey (and all Chrome-style userscript managers) the header lines that decide where a script should run (@match, @include, @exclude, …) are nothing more than string patterns.
They don’t “normalize” the URL for you, so if the address bar literally contains extra segments such as
code
https://example.com/././some/page
then your @match / @include line has to contain those same characters (or a wildcard that can swallow them).
────────────────────────────────────────
Why your current line probably fails
────────────────────────────────────────
Most people write something like
but it does not match the literal dot-segments, because:
• In a Chrome-style match pattern, the asterisk in the path (/*) expands to “any number of characters except /”.
• The /./ introduces an extra slash, a dot, and another slash – none of which are matched by that single *.
────────────────────────────────────────
2. Quick fixes
────────────────────────────────────────
A. If you just need it to work everywhere on that hostname, the simplest, bullet-proof header is:
javascript
// ==UserScript==
// @name My script
// @match *://example.com/* /* ← works on normal URLs */
// @match *://example.com/./* /* ← catches one “/./” segment */
// @match *://example.com/././* /* ← two segments, and so on… */
// ==/UserScript==
Yes, you can stack as many @match lines as you need.
If the page sometimes has three or four “/./” in a row, keep adding lines (or jump to the “regex” solution below).
B. Match any site as long as “/./” appears in the path:
javascript
// @match *://*/./*
That says: “any scheme, any hostname, then /./, then anything”.
────────────────────────────────────────
3. A tidier, one-liner solution with @include + RegExp
────────────────────────────────────────
@include (or @match starting with /^...$/, Tampermonkey 4.19+) lets you use full regular expressions:
Break-down of the pattern:
• https?:// → http or https
• example\.com/ → your host
• (?:\./)* → zero or more literal “./” segments
• .* → anything after that
One line, matches
– https://example.com/foo
– https://example.com/./foo
– https://example.com/././foo/bar
────────────────────────────────────────
4. Things not to worry about
────────────────────────────────────────
• You do not need to add a \. to escape dots inside the path when you use ordinary @match. Only RegExp (@include /^...$/) needs escaping.
• @run-at has no influence on whether the script is injected; it only changes when it runs once it matches.
────────────────────────────────────────
5. Checklist if it still doesn’t run
────────────────────────────────────────
☑ Is the userscript enabled in Tampermonkey’s dashboard?
☑ Did you save the file after editing the header?
☑ After saving, did you refresh the target tab (or open it again) so the new header is evaluated?
☑ Open the page, click the Tampermonkey icon → “Dashboard” → “Activated scripts”. Your script should appear in that list.
────────────────────────────────────────
6. TL;DR 🚀
────────────────────────────────────────
Match patterns are literal; “/./” in the URL must appear (or be covered by a wildcard/regex) in the header.
Add more specific @match lines, or switch to an @include regular expression, and the script will fire on those quirky URLs.