User:Dsm.wiki/gadget-RedirectCommons.js

From Wikimedia Incubator

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
/* Redirect images to Commons
 * Copied and adapted from [[fr:MediaWiki:Gadget-RedirectCommons.js]] (oldid=18757551)
 *
 * Author : [[fr:User:Darkdadaah]]
 * Adaptation : [[en:User:Vvs-dm]]
 *
 * 2017-03-29 -- last modified by Vvs-dm
 */
jQuery(function RedirectCommonsFile() {
    if ( mw.config.get( 'wgNamespaceNumber' ) === 6 ) {
    	var url = $( '.sharedUploadNotice a.external' ).attr( 'href' );
    	if ( url !== null && url !== undefined ) {
    		window.location = url;
    	}
    }
});