User:Ditto Duck Penguin/global.js

// Pinglist. // Using '\\b' is a barrier: word\b would trigger on forword but not on wordgame, etc. Other regex flags work on this. // Don't forget to double-slash, since single slashes in JS break things. var PING_LIST = [ "Ditto", "Alex(?:2|)", "\\Ditto Creeper Bot\\d", "(?:p)(?:i)(?:n)(?:g)4", "Mohammad(?:2|)", "Orion(?:2|)", "Titan(?:2|)" ]; // Ping sound. // Needs to be a valid URL to an .ogg file. var PING_SOUND = 'https://dl.dropboxusercontent.com/s/hutnj03xg47tvr1/pingas.mp3'; // Ping color. // Needs to be a valid HTML color code. var PING_COLOR = "purple"; // Ask our end-user if we want notifications for the script. Notification.requestPermission; // Function itself. $(function {   if (mw.config.get('wgCanonicalSpecialPageName') == 'Chat') {        console.log("Pingchecking activated!");        $('.Chat').on('DOMNodeInserted', function(e) { var msg = $.parseHTML(e.target.innerHTML)[7]; 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) { 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 notification = 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; }				}				// 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 '/crules':            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 '/rules': this.value = 'You can read the Wikia\'s rules here.'; break; case '/tou': this.value = 'Wikia\'s Terms of Use can be found here.'; break; case '/lightswears': this.value = 'Under Article 4, Section 2, Point 1 of the Steven Universe Wikia Chatroom Rules! Lightswears are allowed but not to be used as an insult or used excessively'; break; case '/minimodding': this.value = 'Under Article 4, Section 1, Point 1 of the Steven Universe Wikia Chatroom Rules! Do not enforce the rules on the chat. This is commonly referred to as "mini-modding". Staff members of the wiki are appointed for this reason.'; break; case '/unnoticed': this.value = 'Under Article 4, Section 1, Point 2 of the Steven Universe Wikia Chatroom Rules! If you a feel a user who is breaking rules is going unnoticed, please \'ping\' a moderator by saying their full username or another one of their ping phrases.'; break; case '/modcommand': this.value = 'Under Article 4, Section 1, Point 3 of the Steven Universe Wikia Chatroom Rules! Please know that if you use the "!mods" command for a reason other than gaining the attention of a moderator or administrator to deal with a rule breaker or using the command too often, you may be kicked or banned from the chat depending on the situation or amount of use the command has seen. ';           break; case '/modless': this.value = 'Under Article 4, Section 1, Point 4 of the Steven Universe Wikia Chatroom Rules! If no moderators or administrators are present within the chatroom, please leave a message on a chat moderator or administrator\'s message wall or the ask the staff board with evidence, preferably a screenshot, of the rule breaking. Do NOT take it upon yourself to take the matter into your own hands'; break; case '/pm': this.value = 'Under Article 4, Section 1, Point 5 of the Steven Universe Wikia Chatroom Rules! PM is mostly a no-rule zone, however if you are found to be harassing and/or sending NSFW content without consent from the other user with evidence from them, it is grounds for a ban or block. ';           break; case '/caps': this.value = 'Under Article 4, Section 1, Point 6 of the Steven Universe Wikia Chatroom Rules! Using all-caps messages, emoticons, or big size messages longer than six words/emotes will issue a warning followed by a kick. (1 letter words such as "I" or "A" do not count towards this maximum)'; break; case '/lines': this.value = 'Under Article 4, Section 1, Point 7 of the Steven Universe Wikia Chatroom Rules! Messages that are longer than 5 line-breaks must be warned for prior to sending.'; break; case '/chattags': this.value = 'Under Article 4, Section 1, Point 8 of the Steven Universe Wikia Chatroom Rules! Certain chat tags such as coloured text and italics are alright to use past 6 words, however, if a moderator thinks that you are abusing them you will need to stop.'; break; case '/linking': this.value = 'Under Article 4, Section 1, Point 9-10 of the Steven Universe Wikia Chatroom Rules! Linking to any dangerous websites will result in a two week ban minimum. We wish to keep user\’s computers safe. Linking to jump-scares will result in an immediate day ban minimum.'; break; case '/lies': this.value = 'Under Article 4, Section 1, Point 11 of the Steven Universe Wikia Chatroom Rules! Using false evidence or spreading malicious lies about another user will result in a kick or ban.'; break; case '/drama': this.value = 'Under Article 4, Section 1, Point 12 of the Steven Universe Wikia Chatroom Rules! If an admin or mod feels like a user is purposefully trying to disrupt the chat, troll or purposefully upset other users, they may issue a warning followed by a kick and eventually a ban.'; break; case '/leaks': this.value = 'Under Article 4, Section 1, Point 13 of the Steven Universe Wikia Chatroom Rules! Posting about or discussing leaked Steven Universe content or fake Steven Universe leaks is prohibited within the main chat room.'; break; case '/swears': this.value = 'Under Article 4, Section 2, Point 2-4 of the Steven Universe Wikia Chatroom Rules! Swear abbreviations are not allowed and will result to either a warning with a kick and eventually a ban'; break; case '/nsfw': this.value = 'Under Article 4, Section 3, Point 1 of the Steven Universe Wikia Chatroom Rules! NSFW (not safe for work, or things you don\’t want to be seen looking at in school or work) is not permitted to be discussed or linked to in main chat. If a user is disturbing you with them in the Private Message section, please report to a Mod or Admin in order to warn the user about his behavior.'; break; case '/topics': this.value = 'Under Article 4, Section 4, Point 1 of the Steven Universe Wikia Chatroom Rules! Be courteous. While it is suggested you avoid topics that make others uncomfortable (politics, religion, mortality, ect), if you do discuss these topics do so in a polite, respectful manner. If staff requests or another user states they are uncomfortable and asks that you stop talking about such topics, stop or take it to PM. ';           break; case '/ads': this.value = 'Under Article 4, Section 5, Point 1-2 of the Steven Universe Wikia Chatroom Rules! Linking to other wiki chats is not allowed in main chat though advertising to view your Steven Universe content on other websites is fine'; break; case '/rp': this.value = 'Under Article 4, Section 6, Point 1-2 of the Steven Universe Wikia Chatroom Rules! While role-playing is allowed, please keep in mind that role-playing can alienate users from chatting and can clutter the chat. Please understand that Roleplaying inappropraitely will not be tolererated and should be taken to the Private Message room'; break; case '/rp1': this.value = 'Under Article 4, Section 7, Point 3 of the Steven Universe Wikia Chatroom Rules! You cannot “own” a character from Steven Universe. Any arguments that result from this will result in a kick for any user involved.'; 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 = 'Reverted Revert</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:navid:MediaWiki:BadWords.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: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:MediaWiki:FasterBanModule/code.js', 'u:dev:FastDelete/code.js' ] });

importScriptPage('MediaWiki:Rollback/code.js', 'dev');