What's the @include
sequence that most accurately lists all the SE sites for Greasemonkey/ userscript hacking purposes?
2 Answers
// All Main and Meta Stack Exchange Sites:
// @include https://stackoverflow.com/*
// @include https://meta.stackoverflow.com/*
// @include https://superuser.com/*
// @include https://meta.superuser.com/*
// @include https://serverfault.com/*
// @include https://meta.serverfault.com/*
// @include https://askubuntu.com/*
// @include https://meta.askubuntu.com/*
// @include https://mathoverflow.net/*
// @include https://meta.mathoverflow.net/*
// @include https://stackapps.com/*
// @include https://*.stackexchange.com/*
//
// Exclude non-standard Stack Exchange sites & pages (eg. chat):
// @exclude https://chat.stackexchange.com/*
// @exclude https://api.*.stackexchange.com/*
// @exclude https://data.stackexchange.com/*
// @exclude https://area51.stackexchange.com/*
// @exclude https://*/reputation
-
1I'm attempting to be as future proof as possible by including upcoming sites :)– badpCommented Oct 16, 2010 at 13:39
-
6
*.stackexchange.com
includes all the metas already (and the chats as well, for that matter). The asterisk doesn't care about dots. Commented Oct 16, 2010 at 16:48 -
also,
*.stackexchange.com
will also include all future beta sites. Commented Dec 12, 2010 at 17:23 -
-
1S[OFU], Ask ubuntu, Stackapps and OnStartups are the only Stack Exchange 2.0 sites with an own domain. The other sites are not found, or redirect to the stackexchange.com domain. If you still want to stich to
@include
rules, I recommend to excludehttp://api.*.com/*
andhttp://chat.*.com/*
, so that non-SE domain sites are also excluded.– Rob WCommented Feb 27, 2012 at 21:38
@match
rules are preferred over @include
, because Chrome will show "This script runs on all domains" when trying to install a Userscript in Chrome. This syntax is also compatible with both Greasemonkey, and Tampermonkey.
The following rules match all Stack Exchange 2.0 Q&A websites:
// @match https://stackoverflow.com/*
// @match https://meta.stackoverflow.com/*
// @match https://superuser.com/*
// @match https://meta.superuser.com/*
// @match https://serverfault.com/*
// @match https://meta.serverfault.com/*
// @match https://askubuntu.com/*
// @match https://meta.askubuntu.com/*
// @match https://mathoverflow.net/*
// @match https://meta.mathoverflow.net/*
// @match https://*.stackexchange.com/*
// @match https://stackapps.com/*
// @exclude https://data.stackexchange.com/*
// @exclude https://area51.stackexchange.com/*
Instead of adding more specific rules to disable the script for /reputation
, https://api.*
or https://chat.*
, I recommend to use a simple check to filter these:
if ( !/^(api|chat)\./.test(location.host) && location.pathname.indexOf('/reputation') === -1) {
// Actual code
}
If you want to only target questions, use /questions/*
at the end of each @match
rule. In this case, there's no need to check for api
, chat
, reputation
, data
or area51
, because /questions/
does not exist on these subdomains.
-
Note: All Stack Exchange Q&A sites support the
api.
prefix. The only exception is OnStartups: The API for this site is available athttp://api.onstartups.stackexchange.com/
– Rob WCommented Feb 27, 2012 at 21:30