Community Central
Community Central

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
/* ChatRail thing by ChaoticShadow
/* Special Thanks to: Slyst, Shining-Armour, RansomTime and others
/*
/* Minimum Requirements to run this:
/* - Potato PC
/*
/* Features
/* - Kick, Ban, AutoKick (Mod only)
/* - Music
/* - User Info blah blah blah
/*
*/

$(document).ready(function(){
    if(wgCanonicalSpecialPageName == 'Chat') {
        //Rail
        var rail = $('<section id="WikiaPage" class="WikiaPage" style="left: 10px !important; right: 90% !important; width: 160px !important;"></section>');
     
        var searchbar = $('' +
        '<div style="overflow: hidden; height: 35px; position:relative; margin-top: -46px; margin-right: 165px; float: right;">' +
            '<form name="searchbox" id="searchbox" class="searchbox" action="/wiki/Special:Search" target="_blank">' +
                '<input class="searchboxInput" name="search" type="text" value="" placeholder="" size="30">' +
                '&nbsp;' +
                '<input type="submit" name="go" class="searchboxGoButton" value="Try exact match">' +
                '&nbsp;' +
                '<input type="submit" name="fulltext" class="searchboxSearchButton" value="Search full text">' +
            '</form>' +
        '</div>');
     
        var switchrail = $('' +
        '<table style="width:100%;">' +
            '<tr>' +
                '<td style="width:50%;">' +
                    '<button onclick="switchMT()" style="width:100%;">Mod Tools</button>' +
                '</td>' +
                '<td style="width:50%;">' +
                    '<button onclick="switchUI()" style="width:100%">User Info</button>' +
                '</td>' +
            '</tr>' +
            '<tr>' +
                '<td colspan="2">' +
                    '<hr />' +
                '</td>' +
            '</tr>' +
        '</table>');
     
        var mtrail = $('' +
        '<table style="width:100%;" id="mtrail">' +
            '<tr>' +
                '<td><input type="text" id="userinput" value="" style="width:calc(100% - 5px);"></td>' +
            '</tr>' +
            '<tr>' +
                '<td><button onclick="kick()" id="kickbutton" style=width:100%;">Kick</button></td>' +
            '</tr>' +
            '<tr>' +
                '<td><button onclick="ban()" id="banbutton" style=width:100%;">Ban</button></td>' +
            '</tr>' +
            '<tr>' +
                '<td><button onclick="autokick()" id="autokickbutton" style=width:100%;">AutoKick</button></td>' +
            '</tr>' +
        '</table>');
     
        var uirail = $('' +
        '<table style="width:100%;" id="uirail">' +
            '<tr>' +
                '<td><input type="text" id="userinfo" value="" style="width:calc(100% - 5px);"></td>' +
            '</tr>' +
            '<tr>' +
                '<td><button onclick="userpage()" id="userpage" style=width:100%;">User Page</button></td>' +
            '</tr>' +
            '<tr>' +
                '<td><button onclick="talkpage()" id="talkpage" style=width:100%;">Talk Page</button></td>' +
            '</tr>' +
            '<tr>' +
                '<td><button onclick="blog()" id="blog" style=width:100%;">Blog</button></td>' +
            '</tr>' +
            '<tr>' +
                '<td><button onclick="contribs()" id="contribution" style=width:100%;">Contributions</button></td>' +
            '</tr>' +
            '<tr>' +
                '<td><button onclick="banlog()" id="banlog" style=width:100%;">Ban Log</button></td>' +
            '</tr>' +
            '<tr>' +
                '<td><button onclick="blocklog()" id="blocklog" style=width:100%;">Block Log</button></td>' +
            '</tr>' +
            '<tr>' +
                '<td><button onclick="log()" id="publiclogs" style=width:100%;">Logs</button></td>' +
            '</tr>' +
        '</table>');
     
        var aboutbutton = $('<table style="width:100%; position:absolute; bottom:0;"><tr><td><button onclick="about()" style="width:100%;">About</button></td></tr></table>');
     
     
        //Credit goes to author in Wikipedia
        function userIsInGroup(group) {
            if (wgUserGroups) {
                if ( !group || group.length == 0 ) {
                    group = '*';
                }
    		for(var i in wgUserGroups)
    			if (wgUserGroups[i]==group) return true;
            }
            return false;
        }
        //Thanks to RansomTime, with some modifications
        function exist (variable) {
            if (variable == ""){
                return false;
            }
            return true;
        }
     
        function switchMT() {
            uirail.hide();
            if(userIsInGroup('sysop') || userIsInGroup('bureaucrat') || userIsInGroup('chatmoderator') || userIsInGroup('VSTF')) {
                mtrail.show();
            }
            else {
                $.showCustomModal( 'Insuficient rights', 'Your current rights: ' + wgUserGroups.toString() + '<br />Only users with one or more of the following rights can use these functions (Kick, Ban, Autokick): bureaucrat,sysop,chatmoderator,vstf');
            }
        }
     
        function switchUI() {
            mtrail.hide();
            uirail.show();
        }
     
        //Thanks S-A for clearing this up and explaining
        function kick() {
            var user = $('#userinput').val();
            if (exist(user) === true ) {
                mainRoom.kick({
                    name: user
                });
            }
        }
     
        function ban() {
            var user = $('#userinput').val();
            if (exist(user) === true ) {
                mainRoom.ban({
                    name: user
                });
            }
        }
     
        function autokick() {
            alert('Do not use');
            var user = $('#userinput').val();
            if (exist(user) === true ) {
                $.showCustomModal()
                mainRoom.kick({
                    name: user
                });
            }
        }
     
        //Idk what happens if I don't define user every time
        //I swear slyst pretty much wrote the whole thing: {
        function userpage() {
            var user = $('#userinfo').val();
            var open = '/wiki/User:' + user;
            if (exist(user)) {
                window.open(open, 'blank');
            }
        }
     
        function talkpage() {
            var user = $('#userinfo').val();
            var open = '/wiki/User_talk:' + user;
            if (exist(user)) {
                window.open(open, 'blank');
            }
        }
     
        function blog() {
            var user = $('#userinfo').val();
            var open = '/wiki/User_blog:' + user;
            if (exist(user)) {
                window.open(open, 'blank');
            }
        }
     
        function contribs() {
            var user = $('#userinfo').val();
            var open = '/wiki/Special:Contributions/' + user;
            if (exist(user)) {
                window.open(open, 'blank');
            }
        }
     
        function banlog() {
            var user = $('#userinfo').val();
            var open = '/wiki/Special:Log/chatban?page=User:' + user;
            if (exist(user)) {
                window.open(open, 'blank');
            }
        }
     
        function blocklog() {
            var user = $('#userinfo').val();
            var open = '/wiki/Special:Log/block?page=User:' + user;
            if (exist(user)) {
                window.open(open, 'blank');
            }
        }
     
        function log() {
            var user = $('#userinfo').val();
            var open = '/wiki/Special:Log/' + user;
            if (exist(user)) {
                window.open(open, 'blank');
            }
        }
        // }
     
        function about() {
            $.showCustomModal('About', '' +
            '<div style="text-align:center">' +
                'ChatRail α by <a href="http://www.c.wikia.com/wiki/User:ChaoticShadow" target="_blank">ChaoticShadow</a>' +
                '<br />' +
                'With lots of help from: Slyst, RansomTime, Shining-Armor, and many more, along with other fantastic scripts other users have made.' +
            '</div>' +
            '<hr />' +
            '<h2>Features</h2>' +
                '<ul>' +
                    '<li><span style="font-weight:bold">Mod Only:</span> Kick, Ban, Autokick</li>' +
                    '<li><span style="font-weight:bold">General Usage:</span> Search Bar, User Info (User Page, Talk Page, Blog, Contributions, Chat Ban Log, Block Log, Public Logs)</li>' +
                '</ul>' +
            '', {
                id: 'aboutmodal',
                width: 500
            });
            $('#aboutmodal ul').css({
                'display': 'block',
                'list-style-type': 'disc',
                'margin-bottom': '1 em',
                'margin-left': '0',
                'margin-right': '0',
                'padding-left': '40px'
            });
            $('ol').css({
                'display': 'block',
                'list-style-type': 'decimal',
                'margin-bottom': '1em',
                'margin-left': '0',
                'margin-right': '0',
                'padding-left': '40px' 
            });
        }
     
        $('.WikiaPage').css('left', '176px');
        searchbar.insertAfter($('.ChatHeader .wordmark'));
     
        rail.append(aboutbutton);
        rail.append(switchrail);
        rail.append(mtrail);
        rail.append(uirail);
     
        /* Making sure regular users don't get kick/ban/autokick functions */
        if(userIsInGroup('sysop') || userIsInGroup('bureaucrat') || userIsInGroup('chatmoderator') || userIsInGroup('VSTF')) {
            uirail.hide();
        }
        else {
            mtrail.hide();
        }
        rail.insertAfter($('.ChatWindow #WikiaPage'));
        console.log('ChatRail Loaded');
    }
});