soscripted / sox

Stack Overflow Extras: a userscript for the Stack Exchange websites to add a bunch of optional toggle-able features
http://stackapps.com/q/6091/
MIT License
72 stars 15 forks source link

Improve sites' regex and fix bug with meta sites #427

Closed double-beep closed 4 years ago

double-beep commented 5 years ago
  1. There's no Programmers Stack Exchange site anymore. It has been replaced to Software Engineering and its URL is 'softwareengineering.stackexchange.com' which is already caught by the regex.
  2. The Bitcoin site's URL is 'bitcoin.stackexchange.com' and not 'bitcoin.com', therefore it is already caught by that regex.
  3. Mathoverflow is a special site, but it doesn't end in '.com', but in '.net', therefore it is moved to the second alternative
  4. Positive lookahead is added to '.com' because the function is called to get the site name to use it in the API and API doesn't require '.com' at the end of sitenames. However, API doesn't accept 'meta.mathoverflow', but only 'meta.mathoverflow.net', so '.net' in second alternative doesn't have (?=).

The userscript, before, automatically added the prefix 'meta.' to every site to make an API call with it being the sitename. However, that's not true for non-special sites, where the 'meta' should come after the name and before the 'stackexchange'.

Since API also accepts the name of the site + the meta prefix, here, we replace 'stackexchange' with 'meta' instead of having more complex ways to add it after the name and before 'stackexchange'. If it is a special site, add naturally the 'meta.' prefix.