User:Cheeseskates/chat.js

////////////////////////////////////////////////////////////////////////////////

/* -- -- */ ////////////////////////////////////////////////////////////////////////////////
 * * Name:       Global Chat JavaScript                                      |
 * * Author:     Sophiedp - Cheeseskates                                     |
 * * Description: This is my chat.js that can load on all wikis like         |
 * global.js can. It is thanks to Sophiedp's script you can   |
 * put in TamperMonkey.                                       |
 * https://openuserjs.org/scripts/LunarTwilight/Load_global.js_in_chat/source |
 * put in TamperMonkey.                                       |
 * https://openuserjs.org/scripts/LunarTwilight/Load_global.js_in_chat/source |
 * https://openuserjs.org/scripts/LunarTwilight/Load_global.js_in_chat/source |

//————————————————————————————————————————————————————————————————————————————// // Direct JavaScript code // //————————————————————————————————————————————————————————————————————————————//

/**/ ///————————————————————— Major Direct JavaScript code ———————————————————————/// /**/

/* -- -- */
 * * Name:       Slash commands                                              |
 * * Author:     Cheeseskates                                                |
 * * Description: Using slash commands, I can generate preset messages       |
 * through typing a short word or phrase that would be similar |
 * to the preset message. This helps send messages quickly    |
 * while taking action as fast as possible.                   |
 * e.g. warning and kicking.                                  |
 * while taking action as fast as possible.                   |
 * e.g. warning and kicking.                                  |

// Make it generate the message when I press Enter or Space $('[name="message"]').keypress(function (event) {   if (event.which == 32 || event.which == 13) {        switch (this.value) {

// Children's Online Privacy Protection Act (COPPA) case "/coppa": this.value = "COPPA - You must be 13 or older to legally have an account on Wikia."; break;

// Swearing case "/swear": this.value = "Please don't swear,"; break;

// Spamming case "/spam": this.value = "Please don't spam,"; break;

// Trolling case "/troll": this.value = "Please don't troll,"; break;

// Disruption case "/disrupt": this.value = "Please don't disrupt the chat,"; break;

// Caps lock warning case "/caps": this.value = "Please don't comment with excessive capslock characters,"; break;

// Derogatory terms case "/slur": this.value = "Please don't use slurs,"; break;

// Not safe for work content case "/nsfw": this.value = "Please don't post NSFW comments,"; break;

// Shocking content case "/shock": this.value = "Please don't post shocking content,"; break;

// Mini-modding case "/minimod": this.value = "Please don't mini-mod,"; break;

// Roleplay case "/rp": this.value = "Please don't roleplay on the main chat,"; break;

// Advertising case "/ad": this.value = "Please don't advertise unrelated content,"; break;

// Goodbye, user. case "/bye": this.value = "Take it easy."; break; }   } });

/* -- -- */
 * * Name:       ChatBinaryButton                                            |
 * * Author:     Count of Howard (Author),                                   |
 * code by Penguin-Pal, OneTwoThreeFall, らり牛ちゃん         |
 * * Description: ChatBinaryButton adds a "Binary!" button to the Chat's     |
 * message box, converting message text to binary.            |
 * * Changes:    Unstandardized partially                                    |
 * message box, converting message text to binary.            |
 * * Changes:    Unstandardized partially                                    |
 * * Changes:    Unstandardized partially                                    |

$(function {    if (mw.config.get('wgCanonicalSpecialPageName') == 'Chat') {        mw.util.addCSS( '.Write [name="message"] {' + 'width: calc(100% - 70px);' + '}' +           '#ChatBinaryButton {' + 'position: absolute;' + 'bottom: 25px;' + 'right: 50px;' + '}' +           'input + #ChatBinaryButton:last-child {' + 'bottom: 12px;' + 'right: 12px;' + '}'       );

var binaryValue; var binaryButton = $(' Binary! ');

function binary { var input = $('#Write textarea').val; var inputArray = input.split(""); var inputBinary = inputArray.map(mapArray); binaryValue = inputBinary.join(" "); }

function mapArray(a) { var b;           for (var i = 0; i < a.length; i += 1) { b = a.charCodeAt(i).toString(2); }           return b.length == 8 ? b : "0" + b;       }

binaryButton.click(function {            var iteration = $(this).data('iteration') || 1;            switch (iteration) {            case 1:                binary;                $('#Write textarea').val();                $('#Write textarea').val(binaryValue);                break;            case 2:                $('#Write textarea').val();                mainRoom.socket.send(new models.ChatEntry({                    roomId: this.roomId,                    name: wgUserName,                    text: binaryValue                }).xport);                break;            }            iteration += 1;            if (iteration > 2) {                iteration = 1;            }            $(this).data('iteration', iteration);        }); $('.Write').append(binaryButton); } });

/**/ ///————————————————————— Minor Direct JavaScript code ———————————————————————/// /**/

// Chat Slash Command $('[name="message"]').keypress(function(event) {   if (event.which == 32 || event.which == 13) {        switch (this.value) {            case "/coppa":                this.value = "COPPA - You must be 13 or older to legally have an account on Wikia.";                break;        }    } });

//// // ——————————————————— End Direct Import JavaScript Code ———————————————————— // ////

//————————————————————————————————————————————————————————————————————————————// // Script Configurations -// //————————————————————————————————————————————————————————————————————————————//

// ChatBlockButton Configuration chatBlockReason = "Misbehaving. (Appeal)", "Disruption. (Appeal)", "Spamming. (Appeal)", "Trolling. (Appeal)", "Banditry (e.g. raiding). (Appeal)", "Shock. (Appeal)", "Cross-wiki drama. (Appeal)", "Cross-wiki Vandal/troll.", "Vandal/spam bot.", "Sockpuppeting. (Appeal)", "Violating Wikia's ToU.",

// QuickModTools Configuration window.QuickModTools = { quickreasons: [ "Misbehaving. (Appeal)", "Disruption. (Appeal)", "Spamming. (Appeal)", "Trolling. (Appeal)", "Banditry (e.g. raiding). (Appeal)", "Shock. (Appeal)", "Cross-wiki drama. (Appeal)", "Cross-wiki Vandal/troll.", "Vandal/spam bot.", "Sockpuppet. (Appeal)", "Connection issues. (Appeal)", "Violating Wikia's ToU.", ],   defbanreason: "Misbehaving. Appeal.", defbanlength: "1200" };

//// // ——————————————————————— End Configuration Section ———————————————————————— // ////

//————————————————————————————————————————————————————————————————————————————// // Imports ---// //————————————————————————————————————————————————————————————————————————————//

$(function {    importArticles({ type: "script", articles: [ "u:dev:MediaWiki:BlinkingTabAlert.js", "u:dev:MediaWiki:ChatModHover/code.js", "u:dev:MediaWiki:ChatTimestamps/code.js", "u:dev:MediaWiki:FasterBanModule/code.js", "u:dev:MediaWiki:GiveChatModPrompt/code.js", "u:dev:MediaWiki:MessageBlocker/code.js", "u:dev:MediaWiki:QuickModTools/code.js", "u:steven-universe:User:Andrey Andrey/chat.js", "u:botcentral:User:Ditto Creeper Bot/beta", ]   }); });

//// // —————————————————— End ImportArticles section and page ——————————————————— // ////