User:Enterprisey/rename-reason-fixer.js

Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
$( function () {
    $( "a[href^='https://meta.wikimedia.org/w/index.php'][href*='title=Special:GlobalRenameUser']" ).each( function ( index ) {
        var oldUrl = decodeURI( $( this ).attr( "href" ) );
        var serverName = mw.config.get( "wgServerName" );
        var newUrl = oldUrl.replace( /\[\[.+?\|/g, "[[:m:" +
            ( serverName === "meta.wikimedia.org" ? "" :
                mw.config.get( "wgServerName" ).split( "." )[1] + ":" +
                mw.config.get( "wgServerName" ).split( "." )[0] + ":" ) +
            "Special:Permalink/" + mw.config.get( "wgRevisionId" ) + "|" );
        $( this ).attr( "href", encodeURI( newUrl ) );
    } );
} );
Retrieved from "https://en.wikipedia.org/w/index.php?title=User:Enterprisey/rename-reason-fixer.js&oldid=951830600"