MediaWiki:FastDelete.js

/** * Ajax Fast Delete * * @author Splarka * @author Uberfuzzy * @author Grunny * * @version 2.6 */   window.dev = (window.dev || {}); // Don't load twice... if (window.dev.ajaxFastDelete !== undefined) { return false; }   var conf = mw.config.get([            'wgNamespaceNumber',            'wgPageName',            'wgVersion'        ]), isUCP = conf.wgVersion !== '1.19.24'; function init { var self = { version: '2.6', init: function { if (                   conf.wgNamespaceNumber === -1 ||                    !window.fdButtons ||                    (conf.wgNamespaceNumber === 2 && isUCP && $(".noarticletext").length) ||                    (conf.wgNamespaceNumber != 2 && isUCP && !$('#ca-delete').length) ||                    !isUCP && !$('#ca-delete').length                ) return; var deleteButtons = '', $profile; if (isUCP) { $profile = $('.ns-2 .page-header__contribution-buttons'); } else { $profile = $('.UserProfileActionButton'); }               var deleteBtns = window.fdButtons.map(function(b) {                    var sum = b.summary,                        cssBtns;                    if (isUCP) {                        cssBtns = 'wds-button';                    } else {                        cssBtns = $profile.length ? 'wikia-button' : 'wds-button';                    }                    return '' + b.label + '';                }).join(' '); deleteButtons = ' ' + deleteBtns + ' '; if ($profile.length) { $profile.append(deleteButtons); } else if (!isUCP && $('.page-header__subtitle-blog-post').length) { $('.page-header__subtitle-blog-post').append(deleteButtons); $('.page-header__blog-post-details').css('margin-right', '5px'); } else { $('#cosmos-header-articleHeader').append(deleteButtons); mw.util.addCSS('a[data-id="fastdelete"]:nth-child(1){margin-left:5px}'); mw.util.addCSS('#cosmos-header-articleHeader #FastDeleteBtns > a:not(:first-child) {margin-left: -5px;}'); }               if ($('a[data-id="fastdelete"]').length) { $('a[data-id="fastdelete"]').click(function {                       if (window.FastDeleteNoConfirm || confirm('Are you sure you want to delete this page?') === true) {                            self.deletePage($(this).attr('data-summary'));                        } else {                            return;                        }                    }); }               mw.hook('fastdelete.init').fire(deleteButtons); },           deletePage: function(deleteReason) { (new mw.Api) .post({                       action: 'delete',                        title: conf.wgPageName,                        reason: deleteReason,                        token: mw.user.tokens.get(isUCP ? 'csrfToken' : 'editToken')                   }) .done(function(res) {                       location.reload;                    }); }       };        window.dev.ajaxFastDelete = self; mw.loader.using(['mediawiki.util', 'mediawiki.api'], function {           $(self.init);        }); }   init; })(jQuery, mediaWiki, window);
 * (function($, mw, window) {