User:Sophiedp/global.js

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

/* Chat Slash Commands */ //@author-Shining $('[name="message"]').keypress(function (e) {   if (e.which == 32 || e.which == 13) {        switch (this.value) {        case '/refresh':            this.value = 'Read this: https://en.wikipedia.org/wiki/Wikipedia:REFRESH';            break;        case '/blocks':            this.value = wgSiteName + ' chat is not the place to discuss blocks/bans on this or another wiki. Also, please read this if you have any problems: Special:Contact/blocked';            break;        case '/rules':            this.value = 'Please read the chatroom rules.';            break;        case '/change':            this.value = 'If you would like to request that your account be renamed please see Help:Changing your username';            break;        case '/greet':            this.value = 'Hello and welcome to ' + wgSiteName + ' chat!';            break;        case '/logs': this.value = 'You can view the logs here.'; break; case '/emotes': this.value = 'You can view the emoticons here.'; break; case '/tou': this.value = 'Wikia\'s Terms of Use can be found here.'; break; case '/facedesk': this.value = '/me = https://gph.to/1QdqzIp'; break; case '/whatthe': this.value = '/me = https://bit.ly/1WzeNiH'; break; }   } });

//@author-Pince(ss) Platinum $('[name="message"]').keypress(function (e) {   if (e.which == 13) {        var test = "/google";        if (this.value.indexOf(test) > -1 && this.value.indexOf(test) < 8) {            var query = this.value.replace('/google ', '');            var query = query.replace(/ /g, "+");            this.value = "http://www.lmgtfy.com/?q=" + query        }    } });

/* LightBlock */ //Created by Shining //Modified by Doru $(function {   if (mw.config.get('wgCanonicalSpecialPageName') !== 'Chat') return;    if ( localStorage.getItem('chatBlocked') === null ) localStorage.setItem('chatBlocked', '[]');    if ( localStorage.getItem('chatBlocked') ) {        var usrs = JSON.parse(localStorage.getItem('chatBlocked')).join('"], li[data-user="');        mw.util.addCSS('li[data-user="' + usrs + '"] { display: none; }');    }    $('[name="message"]').keypress(function (e) { if (e.which == 13) { var val = this.value; if ( /^(!|\/|\\)blocklist/i.test(val) ) { this.value = ''; mainRoom.viewDiscussion.chatUL.append('Blocked users: ' + JSON.parse(localStorage.getItem('chatBlocked')).join(', ') + '.'); } else if ( /^(!|\/|\\)block/i.test(val) ) { this.value = ''; var toBlock = val.slice(7).trim; var arr = JSON.parse(localStorage.getItem('chatBlocked')); var idx = arr.indexOf(toBlock); if ( idx === -1) { arr.push(toBlock); localStorage.setItem('chatBlocked', JSON.stringify(arr)); mw.util.addCSS('li[data-user="' + toBlock + '"] { display: none; }'); mainRoom.viewDiscussion.chatUL.append('' + toBlock + ' Has been blocked. Blocked users: ' + JSON.parse(localStorage.getItem('chatBlocked')).join(', ') + '.'); } else { mainRoom.viewDiscussion.chatUL.append('' + toBlock + ' Is already blocked. Blocked users: ' + JSON.parse(localStorage.getItem('chatBlocked')).join(', ') + '.'); }           } else if ( /^(!|\/|\\)unblock/i.test(val) ) { this.value = ''; var toUnblock = val.slice(9).trim; var array = JSON.parse(localStorage.getItem('chatBlocked')); var index = array.indexOf(toUnblock); if (index > -1) { array.splice(index, 1); localStorage.setItem('chatBlocked', JSON.stringify(array)); mw.util.addCSS('li[data-user="' + toUnblock + '"] { display: block !important; }'); mainRoom.viewDiscussion.chatUL.append('' + toUnblock + ' Has been unblocked. Blocked users: ' + JSON.parse(localStorage.getItem('chatBlocked')).join(', ') + '.'); } else { mainRoom.viewDiscussion.chatUL.append('' + toUnblock + ' Isn\'t blocked; can\'t unblock.'); }           }        }    }); });

/* Add Buttons */ function addButtons { if ($('#chatOptionsButton').length === 0) { setTimeout(addButtons, 250); } else if ($('.chat-button').length === 0) { $('#chatOptionsButton').after(dayNightButton, clearChatText); importScriptPage('MediaWiki:Emoticons/code.js', 'kocka'); setTimeout(function {           $('.kockaEmoticonsSpan').wrap(' ');        }, 2500); } } /* Clear chat */ function clearChatText { var $clearDiv = $(' ').addClass('chat-button'); var $clearLink = $('').addClass('wikia-button').text('Clear chat'); $clearDiv.html($clearLink); $clearLink.click(function {       $('.Chat li').remove;    }); return $clearDiv; } /* Day/Night Switch Feature */ function dayNightButton { var dayText = 'Day theme'; var nightText = 'Night theme'; var $dayNightButton = $(' ').addClass('chat-button'); var $dayNightLink = $('').addClass('wikia-button').text(dayText); var $body = $('body'); $dayNightButton.html($dayNightLink); $dayNightLink.click(function {       $body.toggleClass('day');        $body.toggleClass('night');        $(this).text(function(index, text) { return text === dayText ? nightText : dayText; });   });    $body.addClass('night'); return $dayNightButton; } window.onload = addButtons;

// KockaEmoticons help text change window.kockaEmoticons = { help: 'Choose an emoticon by clicking on it. Full list.' };

/* Adds link to userpage in account naviagtion menu */ $(function { $('User page</a></li>').insertBefore('.AccountNavigation .subnav li:first'); });

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

/* Adds button on toolbar to mute all MPC templates on page */ if ( $(".youtubeplayer").length ) { $('ul.tools li:first-child:not(.tools-menu li)').after('<li class="removeMPC">Remove MPC</a></li>'); $(".removeMPC").click(function {       $(".youtubeplayer").remove;        $(".removeMPC").remove;    }); }

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

/* Chat Tags settings */ var chatags = { images: true, videos: true };

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

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

);

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

/* QuickCreateUserPage settings */ var qtEnableUserPageOverwrite = true;

/* ChatAnnounnce settings */ chatAnnouncementsAll = true;

/* Makes username template work */ function userNameReplace { "use strict"; var disableUsernameReplace; if (disableUsernameReplace || mw.config.get('wgUserName') === null) { return; }   $("span.insertusername").html(mw.config.get('wgUserName')); } addOnloadHook(userNameReplace);

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

/* AjaxBlock 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 } };

/* Update site staff avatars */ window.avatars = {}; function getURL(user) { $.get("/wiki/Special:Contributions/" + user + "?useskin=oasis", function(data) {       window.avatars[user] = /<img src=\"(.*)\/scale-to-width-down\/150" itemprop=\"image\" class=\"avatar\">/ig.exec(data)[1] + '';    }); } if ( wgPageName == "Navid_Wikia:Site_Staff" || wgPageName == "Rd's_Personal_Wikia:Contact_Staff" || wgPageName == "Rosie043_Land_Wikia:Site_Staff" ) { $(window).load(function {       $('.wikinav2 .WikiaPageHeader').css('padding-right', '0');        $('#WikiaPageHeader .comments').after( '<button class="wikia-button" id="update-avatars" title="Replace old avatar links with up-to-date ones">Update avatars ' );       $('#update-avatars').click(function { var usrs = []; var matches; var PC; var pageNewContent; $('.staff-usr-template').each(function {               usrs.push($(this).text.trim);            }); var API = new mw.Api; API.get({               action: 'query',                prop: 'revisions',                rvprop: 'content',                titles: wgPageName            }).done(function(data) {                for (var i in data.query.pages) {                    PC = data.query.pages[i].revisions[0]['*'];                    page = data.query.pages[Object.keys(data.query.pages)[0]];        		}                matches = PC.match(/\|(\s+|)link(\s+|)=(\s+|).+/gi);                pageNewContent = PC;                for (var i in matches) {                    matches[i] = matches[i].split('=')[1].trim;                }                for (var i in usrs) {                    if (usrs[i] !== '') {                        getURL(usrs[i]);                    }                }                setTimeout(function { for (var i in usrs) { if (usrs[i] !== '') { usrs[i] = window.avatars[usrs[i]]; usrs[i] = usrs[i].replace('static', 'images1') + '/scale-to-width-down/' + matches[i].split('/scale-to-width-down/')[1]; }                   }                    for (var i in usrs) { if (usrs[i] !== '') { pageNewContent = pageNewContent.replace(matches[i], usrs[i]); }                   }                    if ( PC != pageNewContent ) { var config = { 'minor': 'yes', 'bot': 'yes', 'summary': 'Updating user avatars. (automatic)', 'action': 'edit', 'title': wgPageName, 'token': mw.user.tokens.get('editToken'), 'text': pageNewContent };                       $.ajax({                            url: mw.util.wikiScript('api'),                            data: config,                            dataType: 'json',                            type: 'POST',                            success: function(d) {                                if (!d.error) {                                    new BannerNotification('Avatars successfully updated!', 'confirm').show;                                } else {                                    new BannerNotification('Failed while updating avatars: ' + d.error.code, 'error').show;                                }                            }                        }); } else { new BannerNotification('No avatars to update.', 'error').show; }               }, 7000);            });        });    }); }

// IC's vestige if ( wgNamespaceNumber === 1200 ) { $('', {       id: 'ImageWarn',        style: 'cursor:pointer;',    }).html('Image Warning</a>') .prependTo('.toolbar .tools') .click(function {       files = prompt('File names (separate with ", " (space comma space))');        if (!files) return;        files = files.split(' , ');        title = prompt('title', 'Uncategorized Images');        if (!title) return;        blockDuration = prompt('block duration (leave blank if just warning)');        blockReason = prompt('Block reason', 'failing to comply with image policy.');        if ( blockDuration !==  && blockDuration !== null && blockReason !==  && blockReason !== null) {            var usrToBlock = wgPageName.split('Message_Wall:')[1],            token = mw.user.tokens.get("editToken"),            Api = new mw.Api;            Api.post({ action: 'block', user: usrToBlock, expiry: blockDuration, nocreate: 0, autoblock: 0, reason: blockReason, bot: true, token: token })           .done(function(d) { if (!d.error) { console.log(usrToBlock + ' has been blocked successfully! Length: ' + blockDuration); } else { alert('Failed to block ' + usrToBlock + ': ' + d.error.code); }           });        }        console.log('almost there');        $('#wall-new-message #WallMessageTitle').val(title);        var strb = (blockDuration) ? '|b=' + blockDuration + '}}' : '}}';        $('#wall-new-message #WallMessageBody').val('{{UC|' + files.join('|') + strb);        $('#WallMessageSubmit').click    }); }

/* Reverting stuff */ (function (mw, $) {   if (mw.config.get('wgAction') !== 'history' && mw.util.getParamValue('diff') === null) {        return;    }    $('.tools').append('<li id="ajax-revert" class="overflow"></li>');    var node = document.createElement('a');    node.id = 'ajax-revert-link';    node.textContent = 'Revert';    node.addEventListener('click', function  { continueOperation; $(this).prepend('<img id="ajax-throbber" src="http://images2.wikia.nocookie.net/__cb20120926174803/dev/images/8/82/Facebook_throbber.gif" />'); });   $('#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</a>');            }); });   } }(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</a> <b>Revert</a></b> <b>Revert (Vandalism)</a> </b> <b>Revert (Good faith)</a> </b> <b>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; } }); /* */

//—————————————————————————————— ! ! ! ———————————————————————————————// /* Import scripts. NOTE: Place scripts configurations above this line */

/* These must import/load or the world will end */ $(window).load(function {   importArticles({ type: "script", articles: [ 'u:dev:MediaWiki:ColoredColors/code.js', 'u:dev:MediaWiki:ViewRemoved/code.js', 'u:dev:MediaWiki:Sine/code.js', 'u:dev:MediaWiki:AdvancedOasisUI/code.js', 'u:dev:MediaWiki:Rollback/code.js', 'u:dev:MediaWiki:Wikimarks/code.js' ]   }); });				/* Important imports/scripts */ $(window).load(function {   importArticles({ type: "script", articles: [ 'u:dev:MediaWiki:View_Source/code.js', 'u:dev:MediaWiki:WallGreetingButton/code.js', 'u:dev:MediaWiki:PurgeButton/code.js' ]   }); });

/* Semi-important imports/scripts */ $(window).load(function {   importArticles({ type: "script", articles: [ 'u:dev:MediaWiki:RecentChangesMultiple/code.2.js', 'u:dev:MediaWiki:NullEditButton/code.js', 'u:dev:MediaWiki:SignatureCheck/code.js', 'u:dev:MediaWiki:QQX/code.js', 'u:dev:MediaWiki:FastDelete/code.js', 'u:dev:MediaWiki:DupImageList/code.js', 'u:dev:MediaWiki:RevealAnonIP/usercode.js', 'u:dev:MediaWiki:AutoEditDropdown/code.js', 'u:dev:MediaWiki:AnchoredRollback/code.js', 'u:dev:MediaWiki:DisplayClock/code.js' ]   }); });

/* Do I even use these? */ $(window).load(function {   importArticles({ type: "script", articles: [ 'u:dev:MediaWiki:Nuke/code.js', 'u:dev:MediaWiki:WHAM/code.2.js', 'u:dev:MediaWiki:ExternalImageLoader/code.js', 'u:dev:MediaWiki:CacheCheck/code.js', 'u:dev:MediaWiki:RedirectManagement/code.js', 'u:dev:MediaWiki:ListFiles/code.js', 'u:dev:MediaWiki:FixWantedFiles/code.js', 'u:dev:MediaWiki:MultipleFileDelete/code.js', 'u:dev:MediaWiki:FileUsageAuto-update/code.js', 'u:dev:MediaWiki:MessageBlock/code.js', 'u:dev:MediaWiki:CategoryRenameAuto-update/code.js', 'u:dev:MediaWiki:MarkForDeletion/code.js', 'u:dev:MediaWiki:PageRenameAuto-update/code.js', 'u:dev:MediaWiki:QuickComments/code.js', 'u:dev:MediaWiki:UnsafeScripts/code.js', 'u:dev:MediaWiki:QuickDelete/code.js', 'u:dev:MediaWiki:QuickThreads/code.js', 'u:dev:MediaWiki:AntiUnicruft/code.js' ]   }); });

/* Chat imports */ $(window).load(function {   importArticles({ type: "script", articles: [ 'u:runescape:User:Joeytje50/tabinsert.js', 'u:shining-armor:MediaWiki:ChatTags/code.js', 'u:dev:MediaWiki:ChatAnnouncements/code.js', 'u:dev:MediaWiki:ChatOptions/code.js', 'u:dev:MediaWiki:ChatTimestamps/code.js', 'u:dev:MediaWiki:PrivateMessageAlert/code.js', 'u:dev:MediaWiki:QuickModTools/loader.js', 'u:dev:MediaWiki:MessageBlocker/code.js' ]   }); });

/* Ajax and Mass imports/scripts */ $(window).load(function {   importArticles({ type: "script", articles: [ 'u:dev:MediaWiki:AjaxUndo/code.js', 'u:dev:MediaWiki:AjaxPatrol/code.js', 'u:dev:MediaWiki:AjaxBlock/code.js', 'u:dev:MediaWiki:AjaxRename/code.js', 'u:dev:MediaWiki:AjaxBatchUndelete/code.js', 'u:dev:MediaWiki:AjaxRedirect/code.js', 'u:dev:MediaWiki:AjaxPatrol/code.js', 'u:dev:MediaWiki:AjaxBatchDelete/code.js', 'u:dev:MediaWiki:AjaxThreadUnfollow/code.js', 'u:dev:MediaWiki:MassRedirect/code.1.js', 'u:dev:MediaWiki:MassCategorization/code.js', 'u:dev:MediaWiki:MassNullEdit/code.js', 'u:dev:MediaWiki:MassBlock/code.js', 'u:dev:MediaWiki:MassProtect/code.js', 'u:dev:MediaWiki:MassUserRights/code.js', 'u:dev:MediaWiki:MassRenameRevert/code.js' ]   }); });