User:Sophiedp/global.js

/* Chat stuff */ importScriptURI('http://embercastle.wikia.com/index.php?title=User:Sophiedp/chat.js&action=raw&ctype=text/javascript');

/* Quick Access to EditCount */ if ( $('.tally').length ) { var $tally = $('.tally'); $tally.attr('title', 'EditCount'); $tally.click(function {       window.location.href = wgServer + '/wiki/Special:EditCount/' + wgPageName.split('User:')[1];    }); }

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

/* MessageBlock settings */ var MessageBlock = { title : 'Block', message : 'You have been blocked for $2 because you have $1', autocheck : true };

/* Sine settings */ Sine = { spacer: '' };

/* Cache check settings */ window.topLevelCat = '';

/* Fast delete settings */ window.fdButtons = []; window.fdButtons.push(   {        summary: 'Housekeeping',        label: 'Clean-up'    },    {        summary: 'Vandalism',        label: 'Vandalism'    },    {        summary: 'Spam',        label: 'Spam'    },    {        summary: 'Unused',        label: 'Unused'    },    {        summary: 'Inappropriate content',        label: 'Content'    } );

/* QuickModTools settings */ window.QuickModTools = { quickreasons: [ "Misbehaving in chat-please see the Chat guideines", "Spam/Flooding Chat", "Swearing", "Overusing Caps", "Trolling", "Intimidating behaviour/harassment/trolling", "Posting/Discussing leak content/topics", "Ban Evasion", "Underaged", "Hate speech/Slur", "Linking NSFW content", "Sockpuppetry", "Connection problem, please fix it and leave a message on my message wall" ],	defbanreason: "Misbehaving in chat", defbanlength: "1200" };

/* AutoEditDropdown settings */ window.AutoEditDropdownConfig = { expandedAreaContribute: true, expandedAreaEdit: false };

/* AdvancedOasisUI settings */ window.AdvancedOasisUI = { accountNavFollowedPages: true, accountNavWatchlist: true, categoryRedlink: true, RCHeader: true, DefaultSourceMode: true, lightbox: true, randomPageLimitedTo: '', activity2RC: false, userLang: true, };

/* RCMultiple Stuff */ /* Author: Dorumin */ (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' ) {        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 ( $('.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');                $('img[alt="+"]').each(function { $(this).click; });               if (!document.hasFocus) {                    blinkTitle('New edits!');                    // Display desktop notification.                    var notification = new Notification("New edits!");                }            } else if ( $('.rcm-noNewChanges:not(.old)').length ) {                $('.rcm-noNewChanges').addClass('old');                $('img[alt="+"]').each(function { $(this).click; });           }            if(document.querySelector(this.modID+" .rcm-autoRefresh-checkbox").checked) {                if ( $('.rcm-noNewChanges:not(.old)').length ) {                    $('.rcm-rcm-noNewChanges').addClass('old');                    setTimeout(function{ if (!document.hasFocus) { $('.rcm-status button').click; }                   }, 15000);                }            }        }, 3000);    } });

/* Reverting stuff */ (function (mw, $) {   if (mw.config.get('wgAction') !== 'history' && mw.util.getParamValue('diff') === null) {        return;    }    $('.tools').append('');    var node = document.createElement('a');    node.id = 'ajax-revert-link';    node.textContent = 'Revert';    node.addEventListener('click', function  { continueOperation; $(this).prepend(''); });   $('#ajax-revert').append($(node));    function continueOperation {        (new mw.Api).get({ action: 'query', prop: 'revisions', titles: mw.config.get('wgPageName'), rvprop: 'user|ids', rvlimit: '50', format: 'json' }).done(function (result) { var i = 0, currentrev, lastcleanrev, revisions = result.query.pages[mw.config.get('wgArticleId')].revisions; // Iterate over the revisions authored by the same user and cache the first clean rev & the current one do { i++; } while (revisions[i].user === revisions[i - 1].user); currentrev = revisions[0].revid; lastcleanrev = revisions[i].revid; // Edit the page (new mw.Api).post({               action: 'edit',                undo: currentrev,                undoafter: lastcleanrev,                title: mw.config.get('wgPageName'),                token: mw.user.tokens.get('editToken')            }).done(function  {                $('#ajax-throbber').hide;                $('#ajax-revert').html('Complete');            }); });   } }(mediaWiki, jQuery));

/* */ // Reverting tools V6.6 Gold (Original coding by VegaDark, modified by Ajraddatz and Manyman) function getElementsByClass(searchClass,node,tag) { // Function from http://www.dustindiaz.com/getelementsbyclass/ var classElements = new Array; if ( node == null ) node = document; if ( tag == null ) tag = '*'; var els = node.getElementsByTagName(tag); var elsLen = els.length; var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)"); for (i = 0, j = 0; i < elsLen; i++) { if ( pattern.test(els[i].className) ) { classElements[j] = els[i]; j++; } }  return classElements; } // _GET code from NoGray JS Library http://www.nogray.com/new_site/ var _GET = new Array; var _uri = location.href; var _temp_get_arr = _uri.substring(_uri.indexOf('?')+1, _uri.length).split("&"); var _temp_get_arr_1 = new Array; for(_get_arr_i=0; _get_arr_i<_temp_get_arr.length; _get_arr_i++){ _temp_get_arr_1 = _temp_get_arr[_get_arr_i].split("="); _GET[decodeURI(_temp_get_arr_1[0])] = decodeURI(_temp_get_arr_1[1]); } delete _uri; delete _temp_get_arr; delete _temp_get_arr_1; function getMessage (where, user1, user2) { var message = prompt ('Enter undo message below:', ''); window.location = 'http://'+ location.hostname + '/index.php?title=' + _GET['title'] + '&action=edit&oldid=' + _GET['oldid'] + '&'+where+'=2&user1='+user1+'&user2='+user2+'&message='+message; } function AGFMessage (where, user1, user2) { var message = prompt ('Enter undo message below:', ''); window.location = 'http://'+ location.hostname + '/index.php?title=' + _GET['title'] + '&action=edit&oldid=' + _GET['oldid'] + '&'+where+'=3&user1='+user1+'&user2='+user2+'&message='+message; } addOnloadHook(function { if (location.href.match(/diff=/)) {    // Get username of submitter    var user1 = getElementsByClass('diff-otitle',null,'td'); user1 = user1[0].getElementsByTagName('a')[2].innerHTML;    var user2 = getElementsByClass('diff-ntitle',null,'td'); user2 = user2[0].getElementsByTagName('a')[3].innerHTML;    $('#mw-content-text').prepend(' ');    document.getElementById('vda-cont').innerHTML = 'Reverted Revert Revert (Vandalism) </b> <a class="wikia-button" href="http://'+ location.hostname + '/index.php?title=' + _GET['title'] + '&action=edit&oldid=' + _GET['oldid'] + '&revert=6&user1='+user1+'&user2='+user2+'">Revert (Good faith)</a> </b> <a class="wikia-button" href="http://'+ location.hostname + '/index.php?title=' + _GET['title'] + '&action=edit&oldid=' + _GET['oldid'] + '&revert=4&user1='+user1+'&user2='+user2+'">Revert (Spam)</a> </b>' + ''; } else if (location.href.match(/revert=1/)) {    document.getElementById('wpSummary').value = 'Reverted vandalism by '+_GET['user2']+' using VDA';    document.getElementById('editform').submit;  } else if (location.href.match(/revert=6/)) {    document.getElementById('wpSummary').value = 'Reverted good faith edits by '+_GET['user2']+' using VDA';    document.getElementById('editform').submit;  } else if (location.href.match(/revert=3/)) {    document.getElementById('wpSummary').value = 'Reverted edits by '+_GET['user2']+' using VDA';    document.getElementById('editform').submit;  } else if (location.href.match(/revert=2/)) {    document.getElementById('wpSummary').value = 'Reverted edits by ' + _GET['user2'] + ' (' +_GET['message']+ ') using VDA'; document.getElementById('editform').submit; } else if (location.href.match(/revert=4/)) { document.getElementById('wpSummary').value = 'Reverted spam by '+_GET['user2']+' to the last version by '+_GET['user1']+' using VDA'; document.getElementById('editform').submit; } }); /* */

/* Inport for various scripts */ importArticles({   type: "script",    articles: [        'u:dev:PurgeButton/code.js',        'u:dev:ColoredColors/code.js',        'u:dev:DisplayClock/code.js',        'u:dev:View_Source/code.js',        'u:dev:ViewRemoved/code.js',        'u:dev:MediaWiki:AjaxUndo/code.js',        'u:dev:NullEditButton/code.js',        'u:dev:MediaWiki:QuickModTools/loader.js',        'u:dev:MediaWiki:Wikimarks/code.js',        'u:dev:RevealAnonIP/usercode.js',        'u:dev:WallGreetingButton/code.js',        'u:dev:MediaWiki:AjaxPatrol/code.js',        'u:dev:QuickCreateUserPage/code.js',        'u:dev:MediaWiki:PrivateMessageAlert/code.js',        'u:dev:MediaWiki:ChatModHover/code.js',        'u:dev:QuickThreads/code.js',        'u:dev:RecentChangesMultiple/code.2.js',        'u:dev:Sine/code.js',        'u:dev:CacheCheck/code.js',        'u:dev:QQX/code.js',        'u:dev:MessageBlocker/code.js',        'u:dev:Message/code.js', 'u:dev:MediaWiki:Rollback/code.js', 'u:dev:SignatureCheck/code.js', 'u:dev:MessageBlock/code.js', 'u:dev:AutoEditDropdown/code.js', 'u:dev:AdvancedOasisUI/code.js', 'u:dev:FastDelete/code.js', 'u:dev:MediaWiki:RedirectManagement/code.js' ] });