User:Mario&LuigiBowser'sInsideStory/wikia.js

$(document).click(function(e){   var $target = $(e.target);    if (e.shiftKey && $target.is('.edited-by a')) {        window.location.href = $target.attr('href');        return false;    }    if ($target.is('.edited-by a')) {        var $usr = $target.attr('href').replace(new RegExp(window.location.origin + '/wiki/Message_Wall:', 'g'), '').replace(/_/g, ' '),        $href = encodeURIComponent($usr);        $.showCustomModal('For ' + $usr, 'Choose what you wish to do.', { id: 'actionsModal', width: 440, height: 140, buttons: [ {                   id: 'usrpage', defaultButton: true, message: 'Profile', handler: function { window.location.href = '/wiki/User:' + $href; $('#actionsModal').closeModal; }               },                {                    id: 'messagewall', defaultButton: true, message: 'Wall', handler: function { window.location.href = '/wiki/Message_Wall:' + $href; $('#actionsModal').closeModal; }               },                {                    id: 'contributions', defaultButton: true, message: 'Contributions', handler: function { window.location.href = '/wiki/Special:Contributions/' + $href; $('#actionsModal').closeModal; }               },                {                    id: 'editcount', defaultButton: true, message: 'Edits', handler: function { window.location.href = '/wiki/Special:Editcount/' + $href; $('actionsModal').closeModal; }               },                {                    id: 'block', defaultButton: true, message: 'Block', handler: function { if (/(bureaucrat|sysop|staff|global-discussion-moderator|vstf)/m.test(mw.config.get('wgUserGroups').join(' ')) === false) { $.showCustomModal('Error', 'You do not have enough permissions to block that user.', {                               id: 'nopermission',                                width: 340,                                height: 140,                                buttons: [                                    {                                        id: 'close',                                        defaultButton: false,                                        message: 'Close',                                        handler: function {                                            $('#nopermission').closeModal;                                        }                                    }                                ]                            }); return; }                       $('#actionsModal').closeModal; var Api = new mw.Api; var formHTML = ' Use the form below to block this user or IP address.\ Expiry:  Other  \  \ Reason:  Other  \  \  Prevent this user from posting on their message wall \  Automatically block all IPs used by this user \  Override any blocks already in effect '; setTimeout(function{                           Api.get({ action: 'query', meta: 'allmessages', ammessages: 'Ipboptions|Ipbreason-dropdown' }, function(g){ var tmes = g.query.allmessages[0]['*'].split(','); var reasons = g.query.allmessages[1]['*'].split('\n'); for (var d = 0; d < reasons.length; d++){ reasons[d] = reasons[d].replace(/\*\* |\*\*/g, ''); if (reasons[d].charAt(0) === '*') { $('select[name="reason"]').append(''); d++; }                                   $('select[name="reason"]').append(('' + reasons[d].replace(/\*\* |\*\*/g, )  + ' ').replace(/ <\/option>/g, '')); }                               for (var c = 0; c < tmes.length; c ++){ tmes[c] = tmes[c].split(':'); $('select[name="expiry"]').append('' + tmes[c][0] + ' '); }                           });                        }, 1);                        $.showCustomModal('Block user: ' + $usr, formHTML, {                            id: 'blockUserModal',                            buttons: [                                {                                    id: 'block',                                    defaultButton: true,                                    message: 'Block',                                    handler: function{                                        var config = {                                            action: 'block',                                            user: $usr,                                            expiry: $('select[name="expiry"]').val !== "other" ? $('select[name="expiry"]').val : $('input[name="other-expiry"]').val,                                            reason: $('select[name="reason"]').val !== "other" ? $('input[name="other-reason"]').val !== '' ? $('select[name="reason"]').val + ': ' + $('input[name="other-reason"]').val : $('select[name="reason"]').val : $('input[name="other-reason"]').val, token: mw.user.tokens.get('editToken') };                                       if ($('input[name="autoblock"]').is(':checked')) config.autoblock = 1; if (!$('input[name="nousertalk"]').is(':checked')) config.allowusertalk = 1; if ($('input[name="reblock"]').is(':checked')) config.reblock = 1; $('#blockUserModal').closeModal; Api.post(config).done(function(d){                                           if (!d.error) {                                                new BannerNotification($usr + ' has been successfully blocked!', 'confirm').show;                                            }                                            else {                                                new BannerNotification('An error occurred while blocking ' + $usr + ': ' + d.error.info, 'error').show;                                            }                                        }); }                               },                                {                                    id: 'cancel', defaultButton: false, message: 'Cancel', handler: function{ $('#blockUserModal').closeModal; }                               }                            ]                        });                    }                },                {                    id: 'cancel',                    defaultButton: false,                    message: 'Cancel',                    handler: function {                        $('#actionsModal').closeModal;                    }                }            ]        }); return false; } });