MediaWiki:Gadget-SpecialPages.js/DoubleRedirects.js

// //( function ( mw, $ ) { if ( mw.config.get( 'wgCanonicalSpecialPageName' ) === 'DoubleRedirects' ) {    function fixDoublesRedirects( index, doubleRedirect, redirectTarget ) {      var writeRedirect = '#REDIRECT ' + redirectTarget + '';      new mw.Api.postWithToken( 'edit', { action: 'edit', title: doubleRedirect, minor: true, recreate: true, text: writeRedirect, summary: editSummary } ).done( function ( fixed ) { if ( fixed.edit.result === 'Success' ) { $( 'ol.special' ).find( 'li:eq( ' + index + ' )' ).html( $( 'ol.special' ).find( 'li:eq( ' + index + ' )' ).html.replace( 'Fix this redirect!', 'Fixed!' ) ); setTimeout( function { location.reload; }, 1500 ); } else { $( 'ol.special' ).find( 'li:eq( ' + index + ' )' ).html( $( 'ol.special' ).find( 'li:eq( ' + index + ' )' ).html.replace( 'Fix this redirect!', 'Something failed! Try again?' ) ); }     } );    }    var nextLink = $( '.mw-nextlink' ).html;    var limit = document.location.href.slice( document.location.href.search( 'limit=' ) + 6, document.location.href.search( '&' ) );    var editSummary = '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( i ) { var doubleRedirect = $( this ).find( 'a:first' ).attr( 'title' ); var redirectTarget = $( this ).find( 'a:last' ).attr( 'title' ); $( this ).append( ' (- Fix this redirect! -)' ); } ); } //} )( mediaWiki, jQuery ); //