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:       ChatEditTools                                               |
 * * Author:     BlackZetsu, Doork, and Ditto Creeper Bot                    |
 * * Description: This script allows the user to execute commands that affect |
 * the wiki poutside the chat from the chat.                  |
 * * Description: This script allows the user to execute commands that affect |
 * the wiki poutside the chat from the chat.                  |

function inlineAlert(a) { mainRoom.model.chats.add(new models.InlineAlert({text:a})); $('[name="message"]').val("").removeAttr("disabled").focus; } $('[name="message"]').keypress(function(a) { if (13 === a.which) {    var b = this.value;    b.trim || (a.preventDefault, $('[name="message"]').val("").removeAttr("disabled").focus);    /!help/i.test(b) && !0 === mainRoom.active && (a.preventDefault, inlineAlert("Commands: !category, !delete, !talkpage, !quickdelete, !protect, !block, !message"));  } }); function commands { $('[name="message"]').keydown(function(a) {   13 === a.which && "!category" === $(this).val.substr(0, 9) && (command = $(this).val.split("|"), page = command[1], category = "\n", $(this).unbind("keypress").val(""), commandsAPI.category);  }); $('[name="message"]').keydown(function(a) {   13 === a.which && "!delete" === $(this).val.substr(0, 7) && (command = $(this).val.split("|"), page = command[1], reason = command[2], $(this).unbind("keypress").val(""), commandsAPI["delete"]);  }); $('[name="message"]').keydown(function(a) {   13 === a.which && "!block" === $(this).val.substr(0, 6) && (command = $(this).val.split("|"), username = command[1], duration = command[2], blockReason = command[3], $(this).unbind("keypress").val(""), commandsAPI.block);  }); $('[name="message"]').keydown(function(a) {   13 === a.which && "!protect" === $(this).val.substr(0, 8) && (command = $(this).val.split("|"), page = command[1], protecttype = command[2], protectexpiry = command[3], protectreason = command[4], $(this).unbind("keypress").val(""), commandsAPI.protect);  }); $('[name="message"]').keydown(function(a) {   13 === a.which && "!quickdelete" === $(this).val.substr(0, 12) && (command = $(this).val.split("|"), page = command[1], reason = command[2], content = "", $(this).unbind("keypress").val(""), commandsAPI.quickdelete);  }); $('[name="message"]').keydown(function(a) {   13 === a.which && "!talkpage" === $(this).val.substr(0, 9) && (command = $(this).val.split("|"), user = command[1], title = command[2], message = command[3], $(this).unbind("keypress").val(""), commandsAPI.talkpage);  }); $('[name="message"]').keydown(function(a) {   13 === a.which && "!message" === $(this).val.substr(0, 8) && (command = $(this).val.split("|"), user = command[1], title = command[2], content = command[3], $(this).unbind("keypress").val(""), commandsAPI.message);  }); } var commandsAPI = {"delete":function { $.post(mw.util.wikiScript("api"), {format:"json", action:"delete", reason:reason, title:page, token:mw.user.tokens.get("editToken"), success:alert("Done!")}); }, block:function { $.post(mw.util.wikiScript("api"), {format:"json", action:"block", user:username, expiry:duration, nocreate:0, autoblock:0, reason:blockReason, token:mw.user.tokens.get("editToken"), success:alert("Done!")}); }, protect:function { $.post(mw.util.wikiScript("api"), {format:"json", action:"protect", expiry:protectexpiry, protections:protecttype, watchlist:"nochange", title:page, reason:protectreason, token:mw.user.tokens.get("editToken"), success:alert("Done!")}); }, category:function { $.post(mw.util.wikiScript("api"), {format:"json", action:"edit", summary:prompt("Type a summary please."), title:page, appendtext:category, token:mw.user.tokens.get("editToken"), success:alert("Done!")}); }, quickdelete:function { $.post(mw.util.wikiScript("api"), {format:"json", action:"edit", summary:"Admins,this page needs deletion because " + reason + ".", title:page, prependtext:content, token:mw.user.tokens.get("editToken"), success:alert("Done!")}); }, talkpage:function { $.post(mw.util.wikiScript("api"), {format:"json", action:"edit", summary:"Adding message: " + title, title:"User_talk:" + user, section:"new", sectiontitle:title, text:message, token:mw.user.tokens.get("editToken"), success:alert("Done!")}); }, message:function { $.nirvana.sendRequest({controller:"WallExternal", method:"postNewMessage", type:"POST", data:{body:command[3], pagetitle:"Message_Wall:" + command[1], messagetitle:command[2], token:mw.user.tokens.values.editToken}}); inlineAlert("Message sent to: " + command[1] + " (Title:" + command[1] + ") (Message:" + command[3] + ")"); }}; $(commands);

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

/* -- -- */ // Load up the ping color var PING_COLOR = "#F00";
 * * Name:       PICCOLO                                                     |
 * * Author:     Akivirus                                                    |
 * * Description: User blog:Akrivus/Akri's Amazing Script                    |
 * * Description: User blog:Akrivus/Akri's Amazing Script                    |
 * * Description: User blog:Akrivus/Akri's Amazing Script                    |

// Loads the styles for the script. importArticles({   type: "style",    articles: [        "u:akrivus:User:Akrivus/chat.css",        "User:Akrivus/chat.css"    ] });

// Load the script up itself. importArticles({   type: "script",    articles: [        "u:akrivus:User:Akrivus/chat.js"    ] });

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

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

// ChatBlockButton Configuration chatBlockReason = "Misbehaving", "Social Disruption", "Troll.", "Spam", "Excessive Swearing", "Excessive capslock", "Excessive text", "Flood", "Disregarding the moderators", "Malicious intention", "Accessory before the fact", "Accessory after the fact", "Harassment", "Gaming the system", "Victim complex", "God complex", "Canvassing", "Cross-wiki drama", "Banditry", "Shock", "Sockpuppetry", "Sockpuppet", "Violation",

// QuickModTools Configuration window.QuickModTools = { quickreasons: [ "Misbehaving", "Social Disruption", "Troll.", "Spam", "Excessive Swearing", "Excessive capslock", "Excessive text", "Flood", "Disregarding the moderators", "Malicious intention", "Accessory before the fact", "Accessory after the fact", "Harassment", "Gaming the system", "Victim complex", "God complex", "Canvassing", "Cross-wiki drama", "Banditry", "Shock", "Sockpuppetry", "Sockpuppet", "Violation", ], };

//// // ——————————————————————— 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:ChatUserPageButton.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", ]   }); });

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