MediaWiki:NotabilityMove/code.js

/*
 * NotabilityMove
 * @description Allows for quick moving of pages deemed non-notable.
 * @authors "The JoTS", "Ozuzanna"
 * Based off of
 * w:c:dev:AjaxRedirect by Ozuzanna
 * w:c:dev:AjaxRedirect by Ozuzanna

if ($('#ca-ncu').length // already exists || mw.config.get('wgCanonicalNamespace') === "Thread"  || mw.config.get('wgCanonicalNamespace') === "File"  || mw.config.get('wgCanonicalNamespace') === "MediaWiki"  || mw.config.get('wgCanonicalSpecialPageName')) return;
 * (function($, mw) {

if (({"oasis": 1, "wikia": 1})[mw.config.get('skin')] === 1) { $('#WikiaPageHeader > .wikia-menu-button > .WikiaMenuElement > li:last-child').after(     $('').append('NCU move')    ); } else if (mw.config.get('wgNamespaceNumber') !== -1 && mw.config.get('wgAction') === 'view') { $('#p-cactions > .pBody > ul > li:last-child').after(     $('').append('NCU move')    ); } function respHandler (res) { if (res === true) { console.log('Move successfully made!'); new BannerNotification('Move succesful!','confirm').show; setTimeout((function { window.location.reload; }), 3000);   } else { console.log('Failed to move page!'); new BannerNotification('Failed to move page!','error').show; } }

$('#ca-ncu').click(function {   var targUser = prompt('Please enter the target user:'),      api;    if (!targUser) {      console.log('You need to specify the target user!');      return;    }    var fullPageName = mw.config.get('wgPageName');    var basePageName = /^(?:[A-Za-z]*:)?([^\/]+)(?:\/.+)?$/.exec(fullPageName)[1];    api = new mw.Api;    api.post({ action: 'move', from: fullPageName, to: 'User:' + targUser + '/' + basePageName, noredirect: '', reason: 'Does not meet notability guidelines.', token: mw.user.tokens.get('editToken') }).done(function(d) { respHandler(!d.error); }).fail(function { respHandler(false); }); }); })(this.jQuery, this.mediaWiki);