User:Dorumin/global.js

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

// EditCount $(function {   if (!$ || !mw || !$('.tally').length || window.HoverEditCountInit) return;    window.HoverEditCountInit = true;    var obj = {        css:'.editCount {              \                z-index:100;           \                position:fixed;        \            }                          \            .ecrowcenter {             \                text-align:center;     \            }                          \            .ecrowright {              \                text-align:right;      \            }                          \            .TablePager,               \            .TablePager td,            \            .TablePager th {           \                padding:0.20em 0.15em; \            }',        x: 0,        y: 0,        t: 0, // For the timeout, not for placing the div.        html: false,        wait: false,        elem: false,        name: $('[itemprop="name"]').text, $div: $(' '), $tally: $('.tally'), delay: window.hoverEditCountDelay || 300, addDiv: function { $('.editCount').remove; this.$div.css({               top: this.y,                left: this.x            }) .html(self.html) .appendTo(document.body); },       isHover: function(el) { return Boolean($(el).closest('.tally, .editCount').length); },       getEdits: function { var self = this; if (self.html) return; $.get('/wiki/Special:EditCount/' + self.name, function(d) {               self.html = $(d).find('.TablePager').parent.html;                if ( self.wait && self.isHover(self.elem) )                     self.addDiv;            }); },       hover: function { var self = obj; if ($('.editCount').length) return; self.getEdits; self.t = setTimeout(function {               if (!self.html) self.wait = true;                else if (self.isHover(self.elem))                    self.addDiv;            }, self.delay); },       unhover: function { var self = obj; setTimeout(function {              if (self.isHover(self.elem)) {                   self.$div.hover($.noop, self.unhover);               } else {                   self.$div.remove;                   clearTimeout(self.t);               }            }, 100); },       init: function { window.self = this; mw.util.addCSS(self.css); $(document).mousemove(function(e) {               self.x    = e.clientX;                self.y    = e.clientY;                self.elem = e.target;            }); self.$tally.hover(self.hover, self.unhover); }   };    obj.init; });

// 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', 'Moved to a new account': 'Moved', '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.push({   '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 (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); } })(window.jQuery);

// 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");        $('head').append('');        $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 ] });