User:Dorumin/global.js

/* test (again) */ if ( wgCanonicalSpecialPageName == 'Chat' ) { alert('Loaded through global.js'); } // Redirect to base page if ends with '/' if (window.location.href.match("/$")) { window.location.href = window.location.href.slice(0, -1); }

// Remove MPC without muting tab '3' if ( $(".youtubeplayer").length ) { $('ul.tools li:first-child:not(.tools-menu li)').after('Remove MPC'); $(".removeMPC").click(function {       $(".youtubeplayer").remove;        $(".removeMPC").remove;    }); } // Quick Access to EditCount if ( $('.tally').length ) { var $tally = $('.tally'); $tally.attr('title', 'EditCount'); $tally.click(function {       window.location.href = wgServer + '/wiki/Special:EditCount/' + $('h1[itemprop="name"]').text;    }); }

// Ajax Block settings AjaxBlock = { 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', 'Failing to comply with the File Policy.': 'File Policy' },   check: { creation: true, talk: true, autoBlock: true, override: true } };

// Delay Settings batchDeleteDelay = 600; massCategorizationDelay = 600; nullEditDelay = 600; WHAMDelay = 600; massRenameDelay = 600;

// AjaxRC window.ajaxPages = ["Blog:Recent_posts","Special:Chat","Special:WikiActivity","Special:RecentChanges","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';

// Quick Deletion var fdButtons = []; fdButtons[fdButtons.length] = { 'summary': 'Housekeeping', 'label': 'HK'}; $(window).load(function {   $('#EditPageHeader').remove;    importScriptPage('User:Dorumin/WHAM', 'starmanw');    if ( $("#backtotop").length ) { // Damn back to top button        mw.util.addCSS('#displayTimer { position: absolute;  margin-left: 700px; }');    }    switch( wgCanonicalNamespace ) {        case 'User':        case 'User_talk':        $('.UserProfileActionButton .wikia-menu-button').css('margin-left','24px').appendTo('.UserProfileActionButton');        break;    }    $('.UserProfileActionButton .wikia-button').show; });

// QuickCreateUserPage var qtUserPageTemplate = ''; var qtEnableUserPageOverwrite = true; massRenameSummary = 'automatic';

// 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); } });

// add link to RC in WikiActivity if ( wgPageName == 'Special:WikiActivity' ) $('ul.tools li:first-child:not(.tools-menu li)').before('Advanced RC'); // Stuff (function {var original = document.title;if (typeof blinkInterval === 'undefined') {window.blinkInterval = 1000;}var timeout;window.blinkTitle = function(newMsg) {function step {document.title = (document.title == original) ? newMsg : original;timeout = setTimeout(step, blinkInterval);}cancelBlinkTitle(timeout);step;};window.cancelBlinkTitle = function {clearTimeout(timeout);document.title = original;};});

$(window).focus(function {   cancelBlinkTitle; });

$(window).load(function {    if ( wgPageName == 'User:Dorumin/RC' && wgAction == 'view' ) {        Notification.requestPermission;        window.onbeforeunload = function(e) {            return 'Man you must be out of your mind!';        };        $('#WikiaPageHeader, #WikiHeader').remove;        $('.rcm-options legend').click(function{ $('.rcm-options').remove; });       importScriptPage('MediaWiki:Novasis14/code.js', 'dev');        $('#globalNavigation').toggleClass('global-navigation').addClass('hidden');        $('.WikiaSiteWrapper').css('padding-top', '0');        mw.util.addCSS('#globalNavigation.inverse #novasis-label { background: #fff !important; } #novasis-label { position: fixed !important; top: 0 !important; } .global-navigation-container { display: none; } .novasis-navbar-forced .global-navigation-container { display: block !important; }');        var target = document.querySelector('#globalNavigation'),            lngth = $('.novasis-navbar-forced').length;        var observer = new MutationObserver(function(mutations) { mutations.forEach(function(mutation) {               if ($('.novasis-navbar-forced').length > lngth) {                    lngth = $('.novasis-navbar-forced').length;                    $('#globalNavigation').addClass('global-navigation');                    $('#novasis-label').attr('style', 'top: 46px !important;');                }                else if ($('.novasis-navbar-forced').length < lngth) {                    lngth = $('.novasis-navbar-forced').length;                    $('#globalNavigation').removeClass('global-navigation');                    $('#novasis-label').attr('style', 'top: 0 !important;');                }            }); });       var config = {            attributes: true,            childList: false,            characterData: true        };        observer.observe(target, config);        setInterval(function { if ( $('.rcm-status button:not(.old)').length ) { $('.rcm-status button').addClass('old'); $('.rc-conntent a[href]').attr('target', '_blank'); }           if ( $('.modalToolbar:not(.old)').length ) { // Rollback $('.modalToolbar').addClass('old'); var ttl = $('#rcm-diff-viewer h1').text; ttl = ttl.substring(0, ttl.length - 14); $.getJSON('/api.php?action=query&prop=revisions&rvtoken=rollback&titles=' + ttl + '&format=json', function(data2) {                   var code = JSON.stringify(data2);                    Usrnm = code.substring( code.lastIndexOf(',"user":"') + 9,code.lastIndexOf('","timestamp":') ).replace(/\s/g, '+');                    RBTokn = encodeURI( code.substring( code.lastIndexOf('"rollbacktoken":') + 17,code.lastIndexOf('\\"}]}}}}') ) ).replace('+', '%2B');                    $('.modalToolbar a').first.before('Rollback');                });            } // End of Rollback            if ( $('.rcm-previouslyLoaded:not(.old)').length ) {                $('.rcm-previouslyLoaded').addClass('old');                if (!document.hasFocus) { blinkTitle('New edits!'); // Display desktop notification. var notification = new Notification("New edits!"); }           }        }, 3000);    } });

// 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' };   // 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   <input id="accountCreation" type="checkbox"> <label for="accountCreation">Prevent account creation <input id="disableWall" type="checkbox"> <label for="disableWall">Prevent from posting on message wall <input id="autoBlock" type="checkbox"> <label for="autoBlock">Block all IPs from this user (AutoBlock) <input id="overrideBlock" type="checkbox"> <label for="overrideBlock">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:<input id="AjaxUnblockReason" type="text" size="50"> ', {                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;                    }                }]            }); }   }); } /****************** Import scripts ******************/ importArticles({ type: 'script', articles: [ //       'u:starmanw:User:Dorumin/QuickLogs', temp 'u:starmanw:MultiUpload/code.js', 'u:starmanw:QuickCreateUserPage/code.js', 'u:kocka:AjaxCommentDelete/code.js', 'u:dev:AjaxBatchDelete/code.js', 'u:dev:AjaxRC/code.js', 'u:dev:AjaxThreadUnfollow/code.js', 'u:dev:AnchoredRollback/code.js', 'u:dev:AutoEditDropdown/code.js', 'u:dev:ChatTimestamps/code.js', 'u:dev:DisplayTimer/code.js', 'u:dev:DupImageList/code.js', 'u:dev:FastDelete/code.js', 'u:dev:FindAndReplace/code.js', 'u:dev:ListFiles/code.js', 'u:dev:MassCategorization/code.js', 'u:dev:MassNullEdit/code.js', 'u:dev:PrivateMessageAlert/code.js', 'u:dev:QuickComments/code.js', "u:dev:RecentChangesMultiple/code.2.js", 'u:dev:RedirectManagement/code.js', 'u:dev:ViewRemoved/code.js' ] });