Tampermonkey® by Jan Biniok

@connect

This tag defines the domains (no top-level domains) including subdomains which are allowed to be retrieved by GM_xmlhttpRequest

// @connect <value>

<value> can be:

  • a domain name like example.com (this will also allow all subdomains).
  • a subdomain name like subdomain.example.com.
  • self to whitelist the domain the script is currently running at.
  • localhost to access the localhost.
  • an IP address like 1.2.3.4.
  • *.

If it's not possible to declare all domains a userscript might connect to then it's a good practice to do the following:

  1. Declare all known or at least all common domains that might be connected by the script to avoid the confirmation dialog for most users.
  2. Additionally add @connect * to the script to allow Tampermonkey to offer an "Always allow all domains" button.

Users can also whitelist all requests by adding * to the user domain whitelist at the script settings tab.

Notes:

  • Both, the initial and the final URL will be checked!
  • For backward compatibility to Scriptish @domain tags are interpreted as well.
  • Multiple tag instances are allowed.

More examples:

// @connect tmnk.net
// @connect www.tampermonkey.net
// @connect self
// @connect localhost
// @connect 8.8.8.8
// @connect *