User:Alexis Jazz/RedirectCommonsRedirects

When looking at a file page that doesn't exist as a file locally but exists as a redirect on Commons, add ?redirect=no to the url to see the page as if the Commons redirect doesn't exist, showing deletion logs or a local non-file page which is otherwise inaccessible. This also acts as a workaround for Phabricator: An image redirect from a foreign shared File Repository overrides local wiki page.

Plenty of links on User:Alexis Reggae/The Real Slim ShadyCommons to test the effect.

For reference:
 * You open a file page that does not exist locally but is a redirect on Commons. The target exists as a file on Commons but not locally. You are shown the Commons target file but the URL doesn't change and has become desynchronized. This script adds ?redirect=no.
 * You open a local file page that is a redirect on Commons. The target exists as a file on Commons but not locally. See above.
 * You open a local file page that is a redirect on Commons. The target exists locally. You are redirected to the local target. This script redirects you back.
 * You open a local file page that is a local redirect. The target exists locally. You are redirected to the local target. This script redirects you back.

That last case isn't actually a Commons redirect, but there's no way to distinguish the two (well, not without making the script substantially bigger) and if you got redirected you should update the source link anyway.

This script can be loaded globally safely, it detects when you are on Commons and disables itself.