User:Mario&LuigiBowser'sInsideStory/global.js

// chat count script (function {   if (mw.config.get('wgCanonicalSpecialPageName') !== "Chat" || window.chatCountLoaded) return;    window.chatCountLoaded = true;    $('.Rail .public').before('Chat count ');    $('.checkChatCount').click(function { var count = typeof includeMe !== "undefined" && includeMe === false ? mainRoom.model.users.length - 1 : mainRoom.model.users.length; $.showCustomModal('Chat count', 'There is currently ' + count + ' users online!', {           id: 'chatCount',            buttons: [                {                    id: 'logCount',                    defaultButton: true,                    message: 'Log',                    handler: function{                        localStorage.setItem('chatcount', count);                    }                }, {                    id: 'getCount',                    defaultButton: true,                    message: 'Previous count',                    handler: function{                        var storageChatCount = localStorage.getItem('chatcount') ? localStorage.getItem('chatcount') + ' was previously reorded.' : 'There is no recorded chat count.';                        $.showCustomModal('Latest logged count', storageChatCount, { id: 'recordedCount', buttons: [ {                                   id: 'reset', defaultButton: true, message: 'Clear', handler: function{ $.showCustomModal('Confirm', 'Are you sure you want to reset this data?', {                                           id: 'confirmForReset',                                            buttons: [                                                {                                                    id: 'yes',                                                    defaultButton: true,                                                    message: 'Confirm',                                                    handler: function{                                                        localStorage.removeItem('chatcount');                                                        $('#confirmForReset').closeModal;                                                    }                                                }, {                                                    id: 'no', defaultButton: false, message: 'Cancel', handler: function{ $('#confirmForReset').closeModal; }                                               }                                            ]                                        });                                    }                                }, {                                    id: 'close',                                    message: 'Close',                                    defaultButton: false,                                    handler: function{                                        $('#recordedCount').closeModal;                                    }                                }                            ]                        }); }               }, {                    id: 'close', defaultButton: false, message: 'Close', handler: function{ $('#chatCount').closeModal; }               }            ]        });    }); }); // chat block defaults var chatBlockReason = "Sockpuppetry"; var chatBlockExpiry = "infinite"; // AjaxRC window.ajaxSpecialPages = ["Recentchanges", "WikiActivity", "Log"]; window.ajaxIndicator = 'https://images2.wikia.nocookie.net/__cb20100609110347/software/images/a/a9/Indicator.gif'; window.ajaxRefresh = 60000; window.AjaxRCRefreshText = 'Auto-refresh'; // create userpage $(function { $('.toolbar .tools').append(       $(' ').html( $('', {               title: "Automatically create your userpage.",                class: "createUserPage",                text: "Create userpage",                css: {                    cursor: 'pointer'                }            }) ).click(function { // Prevent accidental clicking from creating userpage $.showCustomModal('Create userpage', 'Do you wish to do that?', {               id: 'userpageModal',                width: 300,                height: 150,                buttons: [                    {                        id: 'yes',                        defaultButton: true,                        message: 'Confirm',                        handler: function {                            $.ajax({ type: 'POST', url: mw.util.wikiScript('api'), dataType: 'json', data: { action: 'edit', title: 'User:Mario&LuigiBowser\'sInsideStory', text: '', summary: 'Creating userpage (script)', minor: true, format: 'json', token: mw.user.tokens.get('editToken') },                               success: function (data){ if (!data.error) new BannerNotification("Userpage has been successfully creaed!", "confirm").show; else new BannerNotification("An error occured while creating userpage: " + data.error.info, "error").show; },                               error: function{ new BannerNotification("An API error occured.", "error").show; }                           });                            $('#userpageModal').closeModal;                        }                    },                    {                        id: 'no',                        defaultButton: false,                        message: 'Cancel',                        handler: function {                            $('#userpageModal').closeModal;                        }                    }                ]            }); })   ); });

// Chat scripts

if (mw.config.get('wgCanonicalSpecialPageName') === "Chat") { $(document).on('click', 'li.User', function{       $('.UserStatsMenu').each(function{ if ($(this).css('display') === "block" && !$(this).find('.mention').length) { $(this).find('.regular-actions').append(                   $('', { class: 'mention', text: "Mention", click: function{ document.querySelector('textarea[name="message"]').value += ' ' + $(this).parents('.UserStatsMenu').find('li.username').text; $(this).parents('.UserStatsMenu').hide; },                       css: { 'cursor' : 'pointer' }                   })                );            }        });    });    importArticles({        type: 'script',        articles: [            'u:dev:MediaWiki:ChatBlockButton/code.js',        ]    }); window.chatSendButtons = JSON.parse(localStorage.getItem('chatSendButtons')); }

$(window).load(function{   if (mw.config.get('wgWikiaChatUsers')) {        $('a.start-a-chat-button').replaceWith( $(' ', {               class: 'wds-is-secondary wds-button wds-is-squished',                text: mw.messages.get(mw.config.get('wgWikiaChatUsers').length === 0 ? 'chat-start-a-chat' : 'chat-join-the-chat'),               click: function{                    window.open('/wiki/Special:Chat', 'Chat_' + wgCityId).addEventListener('load',  function{ this.importScriptPage("User:Mario&LuigiBowser'sInsideStory/global.js", "community"); });               },                css: {                    'cursor' : 'pointer'                }            }) );   } });

// Import importArticles({   type: "script",    articles: [      'u:dev:MediaWiki:FindAndReplace/code.js',      'u:dev:MediaWiki:MessageBlocker/code.js',      'u:dev:NewMessageCount.js',      'u:dev:MediaWiki:PrivateMessageAlert/code.js',      'u:dev:MediaWiki:AjaxRC/code.js',      'u:electroboom:MediaWiki:ChatSendButtons.js',      'u:dev:MediaWiki:QuickDiff/code.js'    ] });