User:Doork/common.js

var token = mw.user.tokens.get('editToken'), Api = new mw.Api, page = mw.config.get('wgPageName'), FormHTML = '\  \ \     Type of protection: \  \ All \ Autoconfirmed \ Admin \ \     \      Expiry of protection: \  \ \     Reason of protection: \  \ \     Reason of delete: \  \ \   \  ';    // Button Placement. var button = 'PowerDelete' var dropdown = $('.WikiaMenuElement') if(!dropdown.exists) { var dropdown = $('.page-header__contribution-buttons .wds-list'); }    dropdown.append(button); // Function itself. function del { $.showCustomModal('PowerDelete', FormHTML, {           id: 'form-powerdel',            width: 500,            buttons: [{                message: 'Cancel',                handler: function {                    $('#form-powerdel').closeModal;                }            }, {                id: 'startButton',                message: 'Execute',                defaultButton: true,                handler: function {                    realdel;                }            }]        }); }   function realdel { Api.post({           action: 'delete',            reason: $('#delete-reason').val,            title: page,            token: token        }).done(function(d) {            if (d.error) {                console.log('API error in deletion: ' + d.error.code);            } else {                Api.post({ action: 'protect', expiry: $('#protect-expiry').val || $('#protect-expiry').attr('placeholder'), protections: $('#protect-type').val, watchlist: 'nochange', title: page, reason: $('#protect-reason').val, token: token }).done(function(d) { if (d.error) { console.log('API error in protection: ' + d.error.code); } else { alert('Done!'); window.location.reload; }               });            }        });    }