Home > Enterprise >  Is there a way to turn off a Tampermonkey script on every website except for those I choose?
Is there a way to turn off a Tampermonkey script on every website except for those I choose?

Time:08-21

I have a Tampermonkey script that is enabled on all websites. How can I make this script only run on one or some websites? I went into the script settings and found the Includes/Excludes text fields there, what should I do next?

CodePudding user response:

If you want a script to only run on some sites, you should change the script's @include or @match blocks accordingly. For example, taken from GM's wiki:

// ==UserScript==
// @include     http://www.example.com/foo/*
// @include     http://www.example.org/*.bar
// @exclude     http://www.example.com/foo/baz
// ==/UserScript==

will run on example.com/foo/, and on example.com when bar is included in the rest of the URL - except when the path is foo/baz.

You can use either globs or regular expressions in @include. For regular expressions, surround the expression with a single slash, eg:

// @include    /^example\.com$/
  • Related