User:Alexis Jazz/RedirectCommonsRedirects.js

//small script that redirects from file pages that show a Commons redirect to what you'd see if the Commons redirect didn't exist. Also un-redirects you from followed redirects. See description page for reference. if ( mw.config.get('wgDBname') != 'commonswiki' ) { var filename = window.location.href.replace( /.*title=/, ).replace( /\?.*/,  ).replace( /\&.*/g, ).replace( /.*\//g, ).replace( /:/g, '%3A'); if ( mw.config.get('wgNamespaceNumber') == 6 && mw.config.get('wgArticleId') == 0 && mw.config.get('wgAction') == 'view' && encodeURIComponent(mw.config.get('wgPageName')) != filename && window.location.href.search( 'redirect=no') == -1 ) { var redirecturl = mw.config.get('wgServer') + mw.config.get('wgArticlePath').replace( '$1', filename) + '?redirect=no'; window.setTimeout(function { window.location = redirecturl }, 1000 ); }	if ( $('.mw-redirectedfrom')[0] && mw.config.get('wgNamespaceNumber') == 6 ) { window.setTimeout(function { window.location = $('.mw-redirectedfrom a')[0].href }, 1000 ); } }//