MediaWiki:Gadget-SpecialPages.js/DoubleRedirects.js

// if ( mw.config.get( 'wgCanonicalSpecialPageName' ) === 'DoubleRedirects' ) { var succeeded = false; var editToken = mw.user.tokens.get( 'editToken' ).replace( /\+\\$/g, '%2B%5C' ); var nextLink = $( '.mw-nextlink' ).html; var limit = document.location.href.slice( document.location.href.search( 'limit=' )+6, document.location.href.search( '&' ) ); var editSummary = encodeURIComponent( 'Fixing Special:DoubleRedirects using Double redirect fixer' ); if ( nextLink !== null && ( !$.isNumeric( limit ) || limit === '' ) ) { limit = document.location.href.slice( document.location.href.search( 'limit=' )+6 ); } else if ( nextLink !== null && limit !== 1000 ) { setTimeout( function { location = '?limit=1000' }, 1 ); } $( 'ol.special' ).find( 'li' ).each(function {    var doubleRedirect = $( this ).find( 'a:first' ).attr( 'title' );    var redirectTarget = $( this ).find( 'a:last' ).attr( 'title' );    var writeRedirect = encodeURIComponent( '#REDIRECT ' + redirectTarget + '\n\n' );    $.ajax({ url: mw.config.get( 'wgScriptPath' ) + '/api.php?action=edit&title=' + encodeURIComponent(doubleRedirect) + '&summary=' + editSummary + '&minor=1&recreate=1&bot=1&text=' + writeRedirect + '&token=' + editToken, type: 'POST', success: function { succeeded = true; }   });  }); } //