User:StrawberryMaster/global.js

/* FastDelete script configuration. * See w:c:dev:FastDelete for info & attribution. */ var fdButtons = []; fdButtons[fdButtons.length] = { 'summary': 'spam', 'label': 'S' };

fdButtons[fdButtons.length] = { 'summary': 'vandalism', 'label': 'V' };

fdButtons[fdButtons.length] = { 'summary': 'Housekeeping', 'label': 'HK' }; fdButtons[fdButtons.length] = { 'summary': 'Cleanup', 'label': 'C' }; fdButtons[fdButtons.length] = { 'summary': 'Unused', 'label': 'U' };

fdButtons[fdButtons.length] = { 'summary': 'Unofficial/not-needed/irrelevant', 'label': 'UNI' };

fdButtons[fdButtons.length] = { 'summary': 'Other reason', 'label': 'Other' };

// More flexible AjaxUndo jQuery(document).ready(function($) {   "use strict";    function createUndoLink(diffUndoUrl) {        var $ajaxUndoLink = $('').text('AJAX Undo').attr('href', '#').click(function { var $ajaxUndoLinkob = $(this), undoIdRegex = /&undo=([^&]*)/, undoId = undoIdRegex.exec(diffUndoUrl)[1], editToken, etUrl = wgServer + wgScriptPath + '/api.php?action=query&prop=info|revisions&intoken=edit&titles=' + encodeURIComponent(wgPageName) + '&format=json', usrUnd = $('#mw-diff-ntitle2 .mw-userlink').html, smry = prompt('Undo summary', 'Undo revision ' + undoId + ' by ' + usrUnd + ' (talk)'); if (smry === null) return; else if (!smry) smry = 'Undo revision ' + undoId + ' by ' + usrUnd + ' (talk)'; $ajaxUndoLinkob.html(' '); $.getJSON(etUrl, function(data) {               editToken = data.query.pages[wgArticleId].edittoken;                $.ajax({ url: wgScriptPath + '/api.php?', data: 'action=edit&format=json&title=' + encodeURIComponent(wgPageName) + '&undo=' + encodeURIComponent(undoId) + '&bot=1&summary=' + encodeURIComponent(smry) + '&token=' + encodeURIComponent(editToken), dataType: 'json', type: 'POST', success: function(data) { if (data.edit && data.edit.result === 'Success') { $ajaxUndoLinkob.text('(undone)'); } else if (data.error && data.error.code === 'undofailure') { $ajaxUndoLinkob.text('(error)'); alert(data.error.info); } else { $ajaxUndoLinkob.text('(error)'); alert('Error: Unknown result from API.'); }                   },                    error: function { $ajaxUndoLinkob.text('(error)'); }               });            });        });        return $ajaxUndoLink;    }    if ($('.mw-history-undo > a').length && wgAction === 'history') {        $('.mw-history-undo > a').each(function { var diffUndoUrl = $(this).attr('href'), $ajaxUndoLink = createUndoLink(diffUndoUrl); $(this).replaceWith($ajaxUndoLink); });   } else if ($('table.diff').length && typeof $.getUrlVar('diff') !== 'undefined') {        var $diffUndoLink = $('table.diff').find('.diff-ntitle > #mw-diff-ntitle1 a:last'),            diffUndoUrl = $diffUndoLink.attr('href'),            $ajaxDiffUndoLink = createUndoLink(diffUndoUrl);        $diffUndoLink.replaceWith($ajaxDiffUndoLink);    } });

// AjaxBlock beta /* * AjaxBlock (w:c:dev:AjaxBlock) * * @author: Dorumin * @scope: Personal use * @description: Allows user blocking without leaving the current page. */ var ug = mw.config.get('wgUserGroups'); if (ug.indexOf('sysop') + ug.indexOf('vstf') + ug.indexOf('staff') + ug.indexOf('helper') > -4) { var obj = window.AjaxBlock || {}; obj.check = obj.check || {}; // Quick Block Expiry times obj.expiryTimes = obj.expiryTimes || { '2 hours': '2 hours', '5 hours': '5 hours', '1 day': '1 day', '3 days': '3 days', '5 days': '5 days', '1 week': '1 week', '2 weeks': '2 weeks', '1 month': '1 month', '3 months': '3 months', '6 months': '6 months', '1 year': '1 year', '2 years': '2 years', '3 years': '3 years', 'infinite': 'infinite', 'indefinite': 'indefinite', };   // Quick Block reasons obj.blockReasons = obj.blockReasons || { 'Vandalism': 'Vandalism', 'Spam': 'Spam', 'Repeated policy violations': 'Repeated violations', 'Sockpuppetry/ban evasion': 'Sockpuppetry', 'Removing content/blanking pages': 'Page blanking', 'Inserting false information or nonsense': 'Gibberish', 'Intimidating behaviour/harassment/trolling': 'Troll/harassment', 'Unacceptable username, avatar, or global masthead': 'Name/avatar', 'Under the legal age': 'COPPA' };   obj.check.creation = obj.check.creation || true; obj.check.talk = obj.check.talk || false; obj.check.autoBlock = obj.check.autoBlock || true; obj.check.override = obj.check.override || false; // Ajax Block $(document).click(function(e) {       if ($(e.target).is('a[href^="/wiki/Special:Block')) {            if (e.ctrlKey || e.shiftKey) return;            e.preventDefault;            var usr = $(e.target).attr('href').split('Special:Block/')[1],                token = mw.user.tokens.get('editToken'),                Api = new mw.Api;            // Show the block modal            $.showCustomModal('Ajax Block: ' + usr, 'Expiry: Other   Reason: Other    Prevent account creation  Prevent from posting on message wall  Block all IPs from this user (AutoBlock)  Override any blocks already in effect ', { id: 'ajaxBlockModal', callback: function { // Auto checks checkboxes (customizable) if (obj.check.creation) $('#accountCreation').attr('checked', true); if (obj.check.talk) $('#disableWall').attr('checked', true); if (obj.check.autoBlock) $('#autoBlock').attr('checked', true); if (obj.check.override) $('#overrideBlock').attr('checked', true); var $expirySelect = $('#AjaxBlockExpirySelect'); var $reasonSelect = $('#AjaxBlockReasonSelect'); // Adds the common times and reasons (customizable) $.each(obj.expiryTimes, function(key, value) {                       $expirySelect                            .append($('  ') .attr('value', key) .text(value));                   }); $.each(obj.blockReasons, function(key, value) {                       $reasonSelect                            .append($('  ') .attr('value', key) .text(value));                   }); },               buttons: [{ // Block button id: 'ajaxBlockBlock', defaultButton: true, message: 'Block this user', handler: function { var blockDuration = ($('#AjaxBlockExpirySelect').val == 'other') ? $('#AjaxBlockCustomExpiry').val.toLowerCase : $('#AjaxBlockExpirySelect').val.toLowerCase; var blockReason = ($('#AjaxBlockReasonSelect').val == 'other') ? $('#AjaxBlockCustomReason').val : $('#AjaxBlockReasonSelect').val + (($('#AjaxBlockCustomReason').val.trim !== ) ? ':' + $('#AjaxBlockCustomReason').val : ); // Creates the base block object var config = { action: 'block', user: usr, expiry: blockDuration, reason: blockReason, bot: true, token: token };                       // Set object values if certain checkboxes are checked if ($('#accountCreation').is(':checked')) config.nocreate = 1; if ($('#autoBlock').is(':checked')) config.autoblock = 1; if (!$('#disableWall').is(':checked')) config.allowusertalk = 1; if ($('#overrideBlock').is(':checked')) config.reblock = 1; Api.post(config).done(function(d) { // Does the actual blocking                           if (!d.error) {                                new BannerNotification(usr + ' has been blocked successfully!', 'confirm').show;                            } else {                                new BannerNotification('Block for ' + usr + ' failed: ' + d.error.code, 'error').show;                            }                        }).fail(function {                            new BannerNotification('Block for ' + usr + ' has failed.', 'error').show;                        }); $('#ajaxBlockModal').closeModal; // Close the modal setTimeout(function {                           if (wgCanonicalSpecialPageName == 'Contributions') {                                window.location.reload; // Refresh (to check if its correct, or if something went wrong)                            }                        }, 2000); }               }, { // Cancel button id: 'ajaxBlockCancel', defaultButton: true, message: 'Cancel', handler: function { $('#ajaxBlockModal').closeModal; }               }]            });            // Ajax Unblock        } else if ( $(e.target).is('a[href^="/wiki/Special:Unblock/') ) {            if (e.ctrlKey || e.shiftKey) return;            e.preventDefault;            var usr = $(e.target).attr('href').split('Special:Unblock/')[1],                token = mw.user.tokens.get('editToken'),                Api = new mw.Api;            // Show the block modal            $.showCustomModal('Ajax Unblock: ' + usr, 'Reason: ', {                id: 'ajaxUnblockModal',                buttons: [{ // Unblock button                    id: 'ajaxBlockUnblock',                    defaultButton: true,                    message: 'Unblock this user',                    handler: function {                        var unblockReason = $('#AjaxUnblockReason').val;                        Api.post({ // Does the actual unblocking action: 'unblock', user: usr, reason: unblockReason, token: token })                           .done(function(d) { if (!d.error) { new BannerNotification(usr + ' has been unblocked successfully!', 'confirm').show; } else { new BannerNotification('Unblock for ' + usr + ' failed: ' + d.error.code, 'error').show; }                           })                            .fail(function { new BannerNotification('Unblock for ' + usr + ' has failed.', 'error').show; });                       $('#ajaxUnblockModal').closeModal; // Close the modal                        setTimeout(function { if (wgCanonicalSpecialPageName == 'Contributions') { window.location.reload; }                       }, 2000);                    }                }, { // Cancel button                    id: 'ajaxUnblockCancel',                    defaultButton: true,                    message: 'Cancel',                    handler: function {                        $('#ajaxUnblockModal').closeModal;                    }                }]            }); }   }); }

/* Auto updating recent changes opt-in. * Something I found on Dorumin's global.js.  * See w:c:dev:AjaxRC for info & attribution. */ window.ajaxPages = ["Blog:Recent_posts", "Special:RecentChanges", "Special:WikiActivity", "Special:Chat", "Special:Watchlist", "Special:Log", "Special:Log/upload", "Special:Contributions"]; window.ajaxIndicator = 'http://vignette2.wikia.nocookie.net/dev/images/8/82/Facebook_throbber.gif'; window.ajaxRefresh = 30000; window.AjaxRCRefreshText = 'Auto-refresh'; window.AjaxRCRefreshHoverText = 'Automatically refresh the page';

/* Create userpage script. * See w:c:dev:QuickCreateUserPage for info & attribution. */

var qtUserPageTemplate = ''; var qtEnableUserPageOverwrite = true;

/* Vector skin configuration. * See w:c:dev:Pseudo-Vector JS for info & attribution. */ window.pseudoVector = { loadCss: true, addReadTab: true, addContributionsTab: true, disableWatchIcon: false, newDiffStyle: true };

/* Removes backlinks from pages. * See w:c:dev:Linksweeper for info & attirbution. */ window.linkSweepConfirmation = true; window.LinkSweeperDelay = 1000;

/* Places "QuickToolsv2" button on the "My Tools" section. * Something I found on Zmario's global.js. <c:User:Zmario/global.js> * See w:c:dev:QuickToolsv2 for info & attribution. */ var QuickToolsAdvancedtop = false;

/* Import JavaScript and Stylesheet articles from any wiki. * See <github.com/Wikia/app/blob/dev/resources/wikia/wikia.wikibits.js> for info & attribution. */

importArticles({	type: 'script',	articles: [           // ...            'u:dev:MediaWiki:AjaxRC/code.js',            'u:dev:MediaWiki:AjaxBatchDelete/code.2.js',            'u:dev:MediaWiki:AjaxBatchUndelete.js',            'u:dev:MediaWiki:AjaxPatrol/code.js',            'u:dev:MediaWiki:ArchiveTool/code.js',            'u:dev:MediaWiki:DisplayClock/code.js',            'u:dev:MediaWiki:FastDelete/beta.js',            'u:dev:MediaWiki:Linksweeper/code.js',            'u:dev:MediaWiki:MassBlock/code.js',            'u:dev:MediaWiki:MassCategorization/code.js',            'u:dev:MediaWiki:MassProtect/code.js',            'u:dev:MediaWiki:MassRename/code.js',            'u:dev:MediaWiki:MassUserRights/code.js',            'u:dev:MediaWiki:Pseudo-Vector.js',            'u:dev:MediaWiki:QuickCreateUserPage/code.js',            'u:dev:Mediawiki:QuickToolsv2/code.js',            'u:dev:MediaWiki:WHAM/code.2.js', // ...	] });