On 2016-05-10 05:59, 'Ben Stover' via greasemonkey-users wrote:
I setup a GM script with the following (simplyfied) meta tag:
// @include http://*.foobar.com/*
I thought that the trailing wildcard * should tell GM to apply script ONLY if
there is something (at least ONE char)
following the domain name but this is not the case.
* usually means zero or more characters, although the GM documentation
https://wiki.greasespot.net/Include_and_exclude_rules is somewhat
inconsistent:
The rules are URLs, which can have a "wildcard" asterisk (*), which
matches any string including the empty string.
The |*| serves as a wildcard that matches one or more of any character.
From your observations * does seem to match the empty string.
How can I setup the @include statement that
http://aaa.foobar.com/bbb/
http://foobar.com/ccc/ddd/eee/
http://fff.ggg.foobar.com/h
are alle matched but NOT
http://www.foobar.com
or
http://foobar.com
Options for limiting the GM script to pages other than the homepage
(untested):
1. Include/Exclude pairs
// @include http://*.foobar.com/*
// @exclude http://*.foobar.com/
2. Regular expressions
// @include /^http://.+\.foobar\.com/.+/
3. Check the path in the script and only execute code if matching the
desired pattern
// @include http://*.foobar.com/*
if (window.location.href matches desired pattern) {
// do something
}
PS. Your pattern would also match occurrences of .foobar.com/ elsewhere in the
URL, e.g. http://www.example.com/some/service/path.foobar.com/. The third
method can be used to restrict execution to certain domains also by checking
window.location.hostname.
--
Klaus Johannes Rusch
[email protected]
http://klausrusch.atmedia.net/
--
You received this message because you are subscribed to the Google Groups
"greasemonkey-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/greasemonkey-users.
For more options, visit https://groups.google.com/d/optout.