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:       ChatButtonsCollection                                       |
 * * Author:     Ozank Cx (ChatBlockButton) and Count of Howard (script)     |
 * * Description: This script adds useful buttons to the chat popup for a    |
 * user's pop-up window when clicked.                         |
 * * Description: This script adds useful buttons to the chat popup for a    |
 * user's pop-up window when clicked.                         |

(function ($, mw) {   if (mw.config.get("wgCanonicalSpecialPageName") !== "Chat") {        return;    }

var mwVariables = mw.config.get([       'wgSiteName',        'wgServer',        'wgArticlePath',        'wgUserLanguage'    ]);

var lang = mwVariables.wgUserLanguage; var i18n = { "en": { //English titleUP: 'User Page', PAC: 'Prevent account creation', talkPage: 'Prevent this user from editing their own talk page while blocked', headerExpires: 'Expires', headerReason: 'Reason', blockReason: 'Abusing multiple accounts', blockExpiry: 'infinite', blockPrompt: 'Block this user', blockCancel: 'Cancel', blockSuccess: ' has been blocked!', blockFail: 'Failed to block user: ', blockFailInline: 'Failed to block user: unknownerror', block: 'Block', from: 'from', promptGiving: 'Giving', promptCMR: 'Chat Moderator Rights', promptSure1: 'Are you sure you want to make', promptSure2: 'a Chat Moderator?', promptCancel: 'Cancel', promptPromote: 'Promote this user' }   };    var textContent = i18n.hasOwnProperty(lang) ? i18n[lang] : i18n.en;

var FormHTML = '\  \ \       ' + textContent.headerExpires + ' \ \          \ \       \        ' + textContent.headerReason + '\ \          \ \       \        ' + textContent.PAC + ' \ \       ' + textContent.talkPage + ' \ \   ',        blockReason = window.chatBlockReason || textContent.blockReason, blockExpiry = window.chatBlockExpiry || textContent.blockExpiry;

$.each(['show', 'hide'], function (i, ev) {       var el = $.fn[ev];        $.fn[ev] = function  {            this.trigger(ev);            el.apply(this, arguments);            return el;        };    });

$.attrHooks.viewbox = { set: function (elem, value, name) { elem.setAttributeNS(null, 'viewBox', value + ''); return value; }   };

$('#UserStatsMenu').on('show', function {        var username = $("#UserStatsMenu .info ul").children(".username").text.replace(/ /g, "_");        var address = mwVariables.wgServer + mwVariables.wgArticlePath.replace("$1", "User:" + username);        var userPageButton = $('.contribs').clone.addClass('userpage').removeClass('contribs');        $(userPageButton).prependTo('.regular-actions');        $('.userpage').wrap("");        $(".userpage a").attr("target", "_blank");        $(".userpage a").attr("href", address);        $(".userpage svg").attr("viewBox", "0 0 24 18");        $('.userpage path').attr("d", "M12 14c3.309 0 6-2.691 6-6V6c0-3.309-2.691-6-6-6S6 2.691 6 6v2c0 3.309 2.691 6 6 6zm5 2H7c-3.86 0-7 3.14-7 7a1 1 0 0 0 1 1h22a1 1 0 0 0 1-1c0-3.86-3.14-7-7-7z");        $('.userpage .label').text(textContent.titleUP);    });

$('#WikiChatList li').click(function {        $('.UserStatsMenu').on('DOMNodeInserted', function  { if (!$('.block-custom').length && $('.give-chat-mod').length) { mw.util.addCSS('.UserStatsMenu .actions ul li.block-custom .icon { background-position: -614px 0px}'); var blockButton = $('.kick').clone.addClass('block-custom').removeClass('kick');

$(this).children('.actions').children('.admin-actions').append(                   blockButton                ); $('.block-custom .label').text('Block');

$('.block-custom').click(function {                    var name = $(this).parents.eq(2).children('.info').children('ul').children('.username').text;                    $(this).remove;

function inlineAlert(msg) { mainRoom.model.chats.add(new models.InlineAlert({ text: msg }));                       $('[name="message"]').val('').removeAttr('disabled').focus; }

$.showCustomModal(textContent.block + " " + name + " " + textContent.from + " " + mwVariables.wgSiteName, FormHTML, {                       id: 'chat-admin-block',                        width: 400,                        buttons: [{                            message: textContent.blockCancel,                            handler: function  {                                $('#chat-admin-block').closeModal;                            }                        }, {                            message: textContent.blockPrompt,                            defaultButton: true,                            handler: function  {                                var block = {                                    action: 'block',                                    user: name,                                    expiry: document.getElementById('block-expiry').value || $('#block-expiry').attr('placeholder'), reason: document.getElementById('block-reason').value || $('#block-reason').attr('placeholder'), nocreate: '', allowusertalk: '', autoblock: 0, format: 'json', token: mw.user.tokens.values.editToken };

if (!document.getElementById('block-nocreate').checked) { delete block.nocreate; }

if (document.getElementById('block-restrtp').checked) { delete block.allowusertalk; }

$.ajax({                                   url: mw.util.wikiScript('api'),                                    type: "POST",                                    dataType: "JSON",                                    data: block,                                    success: function (d) {                                        if (!d.error) {                                            inlineAlert(name + textContent.blockSuccess);                                            mainRoom.kick({ name: name });                                       } else {                                            inlineAlert(textContent.blockFail + d.error.code);                                        }                                    },                                    error: function  {                                        inlineAlert(textContent.blockFailInline);                                    }                                }); $('#chat-admin-block').closeModal; }                       }]                    });                    $('#block-expiry').attr('placeholder', blockExpiry);                    $('#block-reason').attr('placeholder', blockReason);                }); }       });        $('.UserStatsMenu').on('DOMNodeInserted', function  { if ($('.give-chat-mod').length) { mw.util.addCSS('.UserStatsMenu .actions ul li.give-chat-mod-custom .icon { background-position: -304px 0px}'); $('.give-chat-mod').addClass('give-chat-mod-custom').removeClass('give-chat-mod');

$(".give-chat-mod-custom").click(function {                    var name = $(this).parents.eq(2).children('.info').children('ul').children('.username').text;                    $(this).remove;                    $.showCustomModal(textContent.promptGiving + ' ' + name + ' ' + textContent.promptCMR, ' ' + textContent.promptSure1 + ' ' + name + ' ' + textContent.promptSure2 + ' ', { id: 'give-chat-mod-prompt', width: 400, buttons: [{ message: textContent.promptCancel, handler: function { $('#give-chat-mod-prompt').closeModal; }                       }, {                            message: textContent.promptPromote, defaultButton: true, handler: function { mainRoom.giveChatMod({                                   name: name                                }); $('#give-chat-mod-prompt').closeModal; }                       }]                    });                });            }        });    }); })(this.jQuery, this.mediaWiki);

/**/ ///————————————————————— 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", "Flooding", "Disregarding the moderators", "Malicious intention", "Accessory before the fact", "Harassment", "False accusation", "Gaming the system", "Superiority complex", "Fraudulant Impersonation", "Unsolicited canvassing", "Cross-wiki drama", "Banditry", "Shock", "Sockpuppet", "Proxy offense (Sniper)", "Sharing illegal content", "Violating Wikia's Terms of Use", "Violating Wikia's Privacy Policy",

// QuickModTools Configuration window.QuickModTools = { quickreasons: [ "Misbehaving", "Social Disruption", "Troll.", "Spam", "Excessive Swearing", "Excessive capslock", "Excessive text", "Flooding", "Disregarding the moderators", "Malicious intention", "Accessory before the fact", "Harassment", "False accusation", "Gaming the system", "Superiority complex", "Fraudulant Impersonation", "Unsolicited canvassing", "Cross-wiki drama", "Banditry", "Shock", "Sockpuppet", "Proxy offense (Sniper)", "Sharing illegal content", "Violating Wikia's Terms of Use", "Violating Wikia's Privacy Policy", ], };

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

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

$(function {    importArticles({ type: "script", articles: [ "u:dev:MediaWiki:BlinkingTabAlert.js", "u:dev:MediaWiki:ChatButtonsCollectionDeluxe.js", "u:dev:MediaWiki:ChatEditTools/code.2.js", "u:dev:MediaWiki:ChatModHover/code.js", "u:dev:MediaWiki:FasterBanModule/code.js", "u:dev:MediaWiki:MessageBlocker/code.js", "u:dev:MediaWiki:QuickModTools/code.js", ]   }); });

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