Year of the Dragon: Through May 28th, claim free Expansion Pack (excluding Vecna Unleashed) or a Greater Elixir of Discovery! Speak to Xatheral in the Hall of Heroes. edit
Game mechanics • Newbie guide • In development • DDO Store • Social Media
Challenges • Classes • Collectables • Crafting • Enhancements • Epic Destinies • Favor • Feats
Glossary • Items • Maps • Monsters • Places • Quests • Races • Reincarnation • Skills • Spells
Please create an account or log in to build a reputation and unlock more editing privileges, and then visit DDO wiki's IRC Chat/Discord if you need any help!
User:Technical 13/SandBox/DoubleRedirectFixer.js
< User:Technical 13 | SandBox
Jump to navigation
Jump to search
Note: After saving, you may have to bypass your browser's cache to see the changes, you can click here or try one of the methods below..
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl+F5 or Ctrl+r (⌘ Command+r on a Mac)
- Google Chrome: Press Ctrl+⇧ Shift+R (⌘ Command+⇧ Shift+R on a Mac)
- Internet Explorer: Hold Ctrl while clicking Refresh, or press Ctrl+F5
- Konqueror: Click Reload or press F5
- Opera: Clear the cache in Tools ‣ Preferences
// [[Special:DoubleRedirects]]
//<nowiki>
//( 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' ) {
$( '#row-' + index ).html( $( '#row-' + index ).html().replace( 'Fix this redirect!', 'Fixed!' ) );
$( '#row-' + index ).attr( { href: '#reload', title: 'Reload the page!', onclick: 'setTimeout( function() { location.reload(); }, 500 );' } );
} else {
$( '#row-' + index ).html( $( '#row-' + 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 [[MediaWiki:Gadget-SpecialPages.js/DoubleRedirects.js|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' ).replace( /'/g, '\\\'' );
// var redirectTarget = $( this ).find( 'a:last' ).attr( 'title' ).replace( /'/g, '\\\'' );
var redirectTitle = $( this ).find( 'a:last' ).attr( 'title' ).replace( /'/g, '\\\'' );
var redirectTarget = new mw.Api().get( {
action: 'query',
prop: [ 'revisions', 'info' ],
rvprop: 'content',
titles: doubleRedirect
} ).done( function ( redirectContent ) {
$( this ).append( ' (- <a href="#' + redirectTarget + '" id="row-' + i + '" onClick="fixDoublesRedirects( ' + i + ', \'' + doubleRedirect + '\', \'' + redirectTarget + '\' )">Fix this redirect!</a> -)' );
} );
} );
}
//} )( mediaWiki, jQuery );
//</nowiki>[[Category:Gadgets]]