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

/****************** 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:dev:AjaxBatchDelete/code.js',        'u:dev:AjaxBlock/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' ] });