User:Dorumin/global.js

/* test (yes, again) */ if ( wgCanonicalSpecialPageName == 'Chat' ) { alert('Loaded through global.js'); }

// EditCount (function($, mw) {   if (!$ || !mw || !$('.tally').length) return;    mw.util.addCSS('.editCount {z-index:100;position:fixed;}');    $(document).mousemove(function(e) { window.pos = {x: e.clientX, y: e.clientY, el: e.target}; });   var $tally = $('.tally');    $tally.hover(function { var html; var wait; $.get('/wiki/Special:EditCount/' + wgTitle, function(d) {           html = $(d).find('.TablePager').parent.html;            if (wait && ($(pos.el).is('.tally') || $(pos.el).closest('.tally').length)) {                $('').html(html).appendTo('body');            }        }); window.editCountTimeout = setTimeout(function {           if (!html) wait = true;            else if ($(pos.el).is('.tally') || $(pos.el).closest('.tally').length) {                $('').html(html).appendTo('body');            }        }, 700); }, function { setTimeout(function {           var $el = $(pos.el);            var $ec = $('.editCount');            if ($el.is('.editCount') || $el.closest('.editCount').length) {                $ec.hover($.noop, function { $ec.remove; });           } else {                $ec.remove;                clearTimeout(window.editCountTimeout);            }        }, 100); }); }) (window.jQuery, window.mediaWiki);

// Redirect to base page if ends with '/' if (window.location.href.match("/$")) { window.location.href = window.location.href.slice(0, -1); }

// Get special page UL as OL (+ raw js ;^>) if (document.getElementsByTagName('body')[0].className.split(/ /g).indexOf('ns-special') != -1) { if (document.querySelector('#mw-content-text ul:first-of-type') !== null) { document.querySelector('#mw-content-text ul:first-of-type').outerHTML = document.querySelector('#mw-content-text ul:first-of-type').outerHTML.replace(/<(\/?)ul>/g, '<$1ol>'); } }

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

// 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', 'Posting/Discussing leaked content': 'Leaks' },   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 {   if (document.getElementsByTagName('body')[0].className.split(/ /g).indexOf('ns-special') != -1) {        if (document.querySelector('#mw-content-text ul:first-of-type') !== null) {            document.querySelector('#mw-content-text ul:first-of-type').outerHTML = document.querySelector('#mw-content-text ul:first-of-type').outerHTML.replace('', '').replace('', '');        }    }    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); } });

// No Videos window.NoImageLightbox = { novideo: true };

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

$(function {    if ( wgPageName == 'User:Dorumin/RC' && wgAction == 'view' ) {        var $doc = $(window);        var rcid = "RecentChangesMultiple-autorefresh-" + mw.config.get("wgPageName");        $doc.click(function(e) { if ($(e.target).is('a') || $(e.target).parents('a').length ) { $(e.target).parents('a').attr('target', '_blank'); $(e.target).attr('target', '_blank'); }       });        $doc.focus(function { if (window.stopResponsive) return; var $checkbox = $('.rcm-autoRefresh-checkbox'); if ($checkbox.length) { $checkbox.prop('checked', false); $checkbox[0].dispatchEvent(new Event('click')); }           localStorage.setItem(rcid, false); if (window.latestRCMNotification) { latestRCMNotification.close; }       });        $doc.blur(function { if (window.stopResponsive) return; var $checkbox = $('.rcm-autoRefresh-checkbox'); if ($checkbox.length) { $checkbox.prop('checked', true); $checkbox[0].dispatchEvent(new Event('click')); }           localStorage.setItem(rcid, true); });       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; });       setInterval(function { if (window.throttleForRCM || !$('.rc-conntent > div').length || !$('.rc-conntent > div > table').length) return; if (!window.lastTableHTML) { window.lastTableHTML = $('.rc-conntent > div > table:first .mw-enhanced-rc:first').html; return; }           if ( window.lastTableHTML != $('.rc-conntent > div > table:first .mw-enhanced-rc:first').html ) { window.lastTableHTML = $('.rc-conntent > div > table:first .mw-enhanced-rc:first').html; if (!document.hasFocus) { blinkTitle('New edits!'); // Display desktop notification. window.latestRCMNotification = new Notification("New edits!"); }           }        }, 3000);    } });

/****************** Import scripts ******************/ importArticles({   type: 'script',    articles: [        'u:starmanw:User:Dorumin/QuickLogs',        'u:starmanw:MultiUpload/code.js',        'u:starmanw:QuickCreateUserPage/code.js',        'u:kocka:AjaxCommentDelete/code.js',        'u:kocka:AjaxThreadDelete/code.js',        'u:dev:AjaxBatchDelete/code.js',        'u:dev:AjaxBlock/code.js',        'u:dev:AjaxDelete/code.js',        'u:dev:AjaxPatrol/code.js',        'u:dev:AjaxRC/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:FileUsageAuto-update/code.js',        'u:dev:FindAndReplace/code.js',        'u:dev:ListFiles/code.js', //      'u:dev:MassCategorization/code.js', testing new beta        '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', testing new beta 'u:dev:ViewRemoved/code.js', 'u:dev:User:Dorumin/wikia.js' // betas here ] });