MediaWiki:AjaxRedirect/code.js

/*
 * Ajax Redirect
 * @description Redirects the current page quickly.
 * @author Ozuzanna

$('#WikiaPageHeader > .wikia-menu-button > .WikiaMenuElement > li:last-child').after( $('').append('Redirect') );

$('#a-redir').click(function { var redir = prompt('Please enter the page you want to redirect to:');  if (!redir) {    console.log('You need to specify the page to redirect to!');    window.GlobalNotification.show('You need to specify the page to redirect to!','error');    return;  }  new mw.Api.post({ action: 'edit', watchlist: 'nochange', title: mw.config.get('wgPageName'), text: '#REDIRECT '+redir+'', token: mw.user.tokens.get('editToken') }) .done(function(d) { if (!d.error) { console.log('Redirect successfully made!'); window.GlobalNotification.show('Redirect successfully made!','confirm'); setTimeout((function { location.reload; }), 3000);	     }    else { console.log('Failed to edit page: '+ d.error.code); window.GlobalNotification.show('Failed to edit page: '+ d.error.code,'error'); }		 })  .fail(function { console.log('Failed to edit page!'); window.GlobalNotification.show('Failed to edit page!','error'); }); });