User:Dorumin/global.js

/* This page is just a huge mess. Feel free to take anything. My wallet is probably in there, too. */

/* test (yes, 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); }

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

// Hover over sexy profile pick and open dropdown. Same for notifs. $('.wds-global-navigation__user-menu, .wds-global-navigation__notifications-menu').hover(function {    $(this).children.click; });

// 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 window.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 } };

window.AjaxDelete = {noUndelete: true}; // Nope

// 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 || $ajaxUndoLinkob.closest('li').find('.mw-userlink').html || 'nil',                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;    }    // For Cheese; adds support for QuickDiff. If this doesn't work I s2g I'm going to pitch a fit.    $(window).click(function(e) { var $this = $(e.target); if ($.find.matchesSelector($this[0], '#quickdiff-modal a[data-action="undo"]')) { e.preventDefault; var $link = $(this), undoURL = $link.attr('href'), undoIdRegex = /&undo=([^&]*)/, undoId = undoIdRegex.exec(undoURL)[1], token, url = wgServer + wgScriptPath + '/api.php?action=query&prop=info|revisions&intoken=edit&titles=' + encodeURIComponent(wgPageName) + '&format=json', user = $('#quickdiff-modal .diff-ntitle .mw-userlink').html || 'nil', smry = prompt('Undo summary', 'Undo revision ' + undoId + ' by ' + user + ' (talk)'); if (smry === null) return; else if (!smry) smry = 'Undo revision ' + user + ' by ' + user + ' (talk)'; $link.html(' '); $.getJSON(url, function(data) {               token = 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') { $link.text('(undone)'); } else if (data.error && data.error.code === 'undofailure') { $link.text('(error)'); alert(data.error.info); } else { $link.text('(error)'); alert('Error: Unknown result from API.'); }                   },                    error: function { $link.text('(error)'); }               });            });        }    });

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 }; window.preloadEditCount = 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);    } });

// Take a guess $(".message-removed.hide").removeClass("hide");

// Fandom $('.wds-global-navigation__logo-fandom') .html('<path d="M100.6,58.8V0h13.2v33l3.5-4.4l7.4-8.8h18.9L128,35.2l16.5,23.7h-17.2l-9-14.9l-4.6,4.3v10.5H100.6z M51.8,20.1l-5,26.4l-6.4-26.4h-6h-0.3h-2.7h-0.3h-6l-6.4,26.4l-5-26.4H0l10.1,38.8h17.7l5-20.4l5,20.4h17.7l10.1-38.8H51.8z M217.1,47.5l0.7,11.3h-12.1l-0.9-4.2c-2.8,2.9-6.2,5.4-12.3,5.4c-11,0-17-7.1-17-20.6c0-13.5,6-20.6,17-20.6c6.1,0,9.5,2.4,12.3,5.4l0.9-4.2h12.1l-0.7,11.3V47.5z M203.9,34.4c-1.7-2.2-4.3-3.7-7.8-3.7c-4,0-7.1,2.6-7.1,8.7c0,6.1,3.2,8.7,7.1,8.7c3.5,0,6.1-1.5,7.8-3.7V34.4zM79.8,0.2c-4.2,0-7.6,3.4-7.6,7.6c0,4.2,3.4,7.6,7.6,7.6c4.2,0,7.6-3.4,7.6-7.6C87.4,3.6,84,0.2,79.8,0.2 M91.2,27.8v-8.3h-5.7H72.2v13.4v12.5v13.1v0.3h19v-8.2h-5.9V27.8H91.2z M153.7,7.8c0,4.2,3.4,7.6,7.6,7.6c4.2,0,7.6-3.4,7.6-7.6c0-4.2-3.4-7.6-7.6-7.6C157.1,0.2,153.7,3.6,153.7,7.8 M155.8,27.8v22.8h-5.9v8.2h19v-0.3V45.4V32.9V19.5h-13.2h-5.7v8.3H155.8z" fill="#000"/>') .attr('viewBox', '0 0 244 56') .css('width', '130px') .css('padding-bottom', '15px') .parent .css('flex', '0 0 130px');

/****************** 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',              global.js is ded in chat        '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:HoverEditCount/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',         global.js is ded in chat '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 ] });