Tampermonkey (for most browsers) and Greasemonkey (for Firefox) support both @match
and @include
directives.
When I started to read about the difference between them, it turned out that @match
is somewhat stricter: userscript will not be launched on some addresses, which could be considered as potentially dangerous or just unwanted.
From this arose the question:
a) Is there any potential risk to launch my own userscripts on all addresses (i.e. @match *://*/*
and the same for @include
)?
Or, b) the limitations of launching userscripts on some addresses are relevant for only 3rd-party userscripts, i.e. userscripts which were downloaded from some sites and therefore potentially containing some malicious code?
Is there any potential risk to run your own userscript on all addresses? Yes, a small one; see below.
The main reasons (currently) not to run your own userscript on all pages are:
$(".someclass").remove();
code only effects X pages -- until it doesn't. Head scratching, and optional cursing ensues...$.get( "frbyPlay.me/pics?user=admin&pw=1234"...
, in non sandboxed code and the wrong sites can see it (or the AJAX).Note that reasons 1 and 2 are also why you should use @match
as much as possible instead of @include
. @match
parses web addresses faster and is also very much less likely to trigger on unwanted/unexpected sites.
(And, in Tampermonkey, @match
adds those little site icons in the Tampermonkey Dashboard.)