User:Sophiedp/global.js

/* Chat stuff */ // Pinglist. // Using '\\b' is a barrier: word\\b would trigger on forword but not on wordgame, etc. Other regex flags work on this. var PING_LIST = [ "Special:Chat", "Soph", "Zach", "\\b!", ]; // Swearing crap var SWEAR_LIST = [ "fuck", "shit", "fag", "bitch", "cunt", "coon", "\\bcum", "nigg", "niglet", "whore", "gtfo", "stfu", "wtf", "idfk", "idfc", "\\bidgaf\\b", "jfc", "\\bomf", "\\bbs\\b", "\\bffs\\b", "milf", "***",	"w t f", "wt*", "sh*t", "s***", "s**t", "f*ck", "f***", "f**k" ]; // Ping sound. // Needs to be a valid URL to an .ogg file. var PING_SOUND = 'http://images.wikia.com/monchbox/images/0/01/Beep-sound.ogg'; // Ping color. // Needs to be a valid HTML color code. var PING_COLOR = "red"; var tempMessageValue = ''; var lmt = {}; // Ask our end-user if we want notifications for the script. Notification.requestPermission; // Send function var send = function (m) { mainRoom.socket.send(new models.ChatEntry({ roomId: this.roomId, name: mw.config.get('wgUserName'), text: m   }).xport); }; // Is after $.fn.isAfter = function(sel) { return this.prevAll(sel).length !== 0; }; // Function itself. $(function {   if (mw.config.get('wgCanonicalSpecialPageName') == 'Chat') {        console.log("Pingchecking activated!");        $('.Chat').on('DOMNodeInserted', function(e) { if (! $('#' + e.target.id).isAfter('.inline-alert') ) { return; }           var msg = $.parseHTML(e.target.innerHTML)[7]; var nmg = msg.innerHTML; var mee = $(".User .username").html; var mid = e.target.id; var usr = e.target.getAttribute('data-user'); if (usr == mee) return; if (msg !== void 0) { if ( $('#Chat_' + mainRoom.roomId + ' li').length > 400 ) { $('#Chat_' + mainRoom.roomId + ' li').first.remove; // Lag }               for (var i = 0; i < PING_LIST.length; i++) { if (new RegExp(PING_LIST[i], "mi").test(msg.innerHTML) === true) { // Play the sound. $(' ', {                           id: 'ping',                            src: PING_SOUND,                            autoplay: true                        }).appendTo('body'); // Display desktop notifications. if (Notification.permission === 'granted') { var notificationMention = new Notification(usr + " mentioned you!", {                               body: msg.innerHTML.replace(/(<(img src[^>]*|(?:\/|)a[^>]*|(?:\/|)span[^>]*)>)/g, ""),                                icon: $("#" + mid + " .avatar").attr('src')                            }); }                       // Change the look of the triggered message. $("#" + mid + " .message").html("" + msg.innerHTML + "<\/span>"); break; }               }                for (var v = 0; v < SWEAR_LIST.length; v++) { if (new RegExp(SWEAR_LIST[v], "mi").test(msg.innerHTML) === true) { // Play the sound. $(' ', {                           id: 'ping',                            src: PING_SOUND,                            autoplay: true                        }).appendTo('body'); // Display desktop notifications. if (Notification.permission === 'granted') { var notificationSwear = new Notification(usr + " swore!", {                               body: msg.innerHTML.replace(/(<(img src[^>]*|(?:\/|)a[^>]*|(?:\/|)span[^>]*)>)/g, ""),                                icon: $("#" + mid + " .avatar").attr('src')                            }); }                       // Change the look of the triggered message. $("#" + mid + " .message").html("" + msg.innerHTML + "<\/span>"); break; }               }                if (String(nmg.replace(/(\(.+?\)|(http:|https:)[\s\S]+?(\s|$))/g, '').match(/\b[A-Z]{2,}\b/g)).split(',').length > 6) { send(usr + ', please don\'t write messages longer than 6 words in caps!'); if (lmt[usr] === undefined || isNaN(lmt[usr])) { lmt[usr] = 1; }                   else if (lmt[usr] > 1) { mainRoom.kick({                           name: usr                        }); }                   else if (typeof lmt[usr] === 'number') { lmt[usr]++; }                   setTimeout(function {                        if (lmt[usr] > 0) {                            lmt[usr]--;                        }                    }, 20000); // Play the sound. $(' ', {                       id: 'ping',                        src: PING_SOUND,                        autoplay: true                    }).appendTo('body'); // Display desktop notifications. if (Notification.permission === 'granted') { var notificationCaps = new Notification(usr + " used too many caps!", {                           body: nmg.replace(/(<(img src[^>]*|(?:\/|)a[^>]*|(?:\/|)span[^>]*)>)/g, ""),                            icon: $("#" + mid + " .avatar").attr('src')                        }); }                   // Change the look of the triggered message. $("#" + mid + " .message").html("" + nmg + "<\/span>"); }               if (new RegExp('(aa|bb|cc|dd|ee|ff|gg|hh|ii|jj|kk|ll|mm|nn|oo|pp|qq|rr|ss|tt|uu|vv|ww|xx|yy|zz){11,}', "mi").test(msg.innerHTML) === true) { send(userToKick + ', please don\'t stretch text!'); // Play the sound. $(' ', {                       id: 'ping',                        src: PING_SOUND,                        autoplay: true                    }).appendTo('body'); // Display desktop notifications. if (Notification.permission === 'granted') { var notificationStretch = new Notification(usr + " stretched text!", {                           body: msg.innerHTML.replace(/(<(img src[^>]*|(?:\/|)a[^>]*|(?:\/|)span[^>]*)>)/g, ""),                            icon: $("#" + mid + " .avatar").attr('src')                        }); }                   // Change the look of the triggered message. $("#" + mid + " .message").html("" + msg.innerHTML + "<\/span>"); }               if (new RegExp('\n{20,}', "mi").test(msg.innerHTML) === true) { mainRoom.kick({                       name: usr                    }); }               if ( e.target.className == 'inline-alert' || e.target.className == 'continued inline-alert' ) { if ( $('.inline-alert').last.find('a').length > 1 ) { userr = $('.inline-alert:not(.old)').last.find('a').first.text; $('.inline-alert').last.addClass('old'); $('.inline-alert').last.append('(Quick Ban)'); // Play the sound. $(' ', {                           id: 'ping',                            src: PING_SOUND,                            autoplay: true                        }).appendTo('body'); // Display desktop notifications. if (Notification.permission === 'granted') { var notificationBot = new Notification("Someone was kick'd!", {                               body: 'Ban them quick man!'                            }); }                   }                }                // Terminate the sound. setTimeout(function {                   if ($('#ping').length) $('#ping').remove;                }, 1000); }

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

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

$('[name="message"]').keypress(function (e) {   if (e.which == 13) {        var test = "/facedesk";        if (this.value.indexOf(test) > -1 && this.value.indexOf(test) < 8) {            var query = this.value.replace('/facedesk');            this.value = "/me = https://gph.to/1QdqzIp"        }    } });

/* Hide/Show chat rail */ $('.User').first.before(' 150 ? &quot;0px&quot; : &quot;150px&quot;;$(&quot;.Chat, .Write&quot;).css({right:toggleWidth});var txt = ($(&quot;.HideRailButton&quot;).text == &quot;Hide Rail&quot;) ? &quot;Show Rail&quot; : &quot;Hide Rail&quot;;$(&quot;.HideRailButton&quot;).text(txt);">Hide Rail ');

/* Adds link to userpage in account naviagtion menu */ $(function { $('User page').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];    }); }

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

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

/* 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 = '<a class="wikia-button" href="javascript:var message = getMessage(\'revert\', \+user1+'\', \+user2+'\');">Reverted</a> <b><a class="wikia-button" href="http://'+ location.hostname + '/index.php?title=' + _GET['title'] + '&action=edit&oldid=' + _GET['oldid'] + '&revert=3&user1='+user1+'&user2='+user2+'">Revert</a></b> <b><a class="wikia-button" href="http://'+ location.hostname + '/index.php?title=' + _GET['title'] + '&action=edit&oldid=' + _GET['oldid'] + '&revert=1&user1='+user1+'&user2='+user2+'">Revert (Vandalism)</a> </b> <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> <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:MediaWiki:ChatAnnouncements/code.js',        'u:runescape:User:Joeytje50/tabinsert.js',        'u:dev:MediaWiki:ChatOptions/code.js',        'u:shining-armor:MediaWiki:ChatTags/code.js',        'u:dev:ChatTimestamps/code.js',        'u:dev:MediaWiki:UnsafeScripts/code.js',        'u:dev:PurgeButton/code.js',        'u:dev:ColoredColors/code.js',        'u:dev:DisplayClock/code.js',        'u:dev:MassRedirect/code.1.js',        'u:dev:View_Source/code.js',        'u:dev:ViewRemoved/code.js',        'u:dev:MarkForDeletion/code.js',        'u:dev:MediaWiki:AjaxUndo/code.js',        'u:dev:NullEditButton/code.js',        'u:dev:QuickDelete/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:ListFiles/code.js', 'u:dev:MassCategorization/code.js', 'u:dev:MassNullEdit/code.js', 'u:dev:QuickThreads/code.js', 'u:dev:RecentChangesMultiple/code.2.js', 'u:dev:Sine/code.js', 'u:dev:MediaWiki:AntiUnicruft/code.js', 'u:dev:MediaWiki:AnchoredRollback/code.js', 'u:dev:MediaWiki:AjaxRedirect/code.js', 'u:dev:FixWantedFiles/code.js', 'u:dev:CacheCheck/code.js', 'u:dev:DupImageList/code.js', 'u:dev:MediaWiki:ExternalImageLoader/code.js', 'u:dev:MediaWiki:DupImageList/code.js', 'u:dev:AjaxThreadUnfollow/code.js', 'u:dev:QQX/code.js', 'u:dev:MediaWiki:AjaxPatrol/code.js', 'u:dev:MediaWiki:MultipleFileDelete/code.js', 'u:dev:MediaWiki:FileUsageAuto-update/code.js', 'u:dev:MediaWiki:RedirectManagement/code.js', 'u:dev:MediaWiki:WHAM/code.2.js', 'u:dev:MessageBlocker/code.js', 'u:dev:PageRenameAuto-update/code.js', 'u:dev:AjaxBatchDelete/code.js', 'u:dev:MassBlock/code.js', 'u:dev:MassProtect/code.js', 'u:dev:MassUserRights/code.js', 'u:dev:AjaxRename/code.js', 'u:dev:AjaxBatchUndelete/code.js', 'u:dev:QuickComments/code.js', 'u:dev:MediaWiki:Nuke/code.js', 'u:dev:Message/code.js', 'u:dev:MessageBlocker/code.js', 'u:dev:MediaWiki:Rollback/code.js', 'u:dev:MassRenameRevert/code.js', 'u:dev:MediaWiki:CategoryRenameAuto-update/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' ] });