User:Dorumin/commands.​js

// Chat commands for stuff I do often.  importArticle({   type: 'script',    article: 'u:dev:MediaWiki:Chat-js.js' });

mw.hook('dev.chat.render').add(function {   function getCurrentRoom {        return mainRoom.chats.privates[mainRoom.activeRoom] || mainRoom;    }

window.ChatCommands = $.extend(window.ChatCommands, {       // Aliases        shrugs: 'shrug',        godwin: 'hitler',        boyz: 'pepper',        peper: 'pepper',        pepermint: 'pepper',        cube: 'cubes',        brits: 'tea',        british: 'tea',        // Constants        cubes: 'https://imgur.com/a/7vUyv',        oof: 'https://i.imgur.com/UUzGtDK.jpg',        pepper: 'https://i.imgur.com/NX3GZbj.png',        metric: 'https://i.imgur.com/sKwJhkD.png',        easy: 'https://youtu.be/wTuP83UiW6w',        everytime: 'https://youtu.be/pjvQFtlNQ-M',        11: 'https://youtu.be/uMSV4OteqBE',        tea: 'https://youtu.be/JTsZLBmjdYk',        trans: 'http://fandom.wikia.com/articles/otome-romance-sims-helped-me-realize-im-a-trans-guy',        chatjs: 'chat.js',        chatcss: 'chat.css',        hitler: 'https://en.wikipedia.org/wiki/Godwin\'s_law', coppa: 'http://coppa.org', rules: 'rules', shrug: '¯\\_(ツ)_/¯', lenny: '( ͡° ͜ʖ ͡°)', // Useful functions banlog: function(name) { return 'https://community.wikia.com/wiki/Special:Log/chatban?page=User:' + encodeURIComponent(name); },       private: function(name) { // No group PM support because XPM should handle that if (mainRoom.model.users.findByName(name) && name != wgUserName) { mainRoom.openPrivateChat([name]); } else { dev.chat.inlineAlert('Don\'t PM yourself, stupid'); }       },        fake: function(text) { if (!text.trim.length) return; var s = text.split(' '), name = s[0], i = 1, user; while (!(user = mainRoom.model.users.findByName(name))) { if (i > s.length) { name = wgUserName; i = 0; } else { name = s.slice(0, i++); }           }            var text = s.slice(i).join(' '), room = getCurrentRoom; room.model.chats.add(new models.ChatEntry({ roomId: room.roomId, name: name, text: text, avatarSrc: user.get('avatarSrc'), timeStamp: Date.now, id: -1, maxCharacterLimit: 1000 }));       }    });

mainRoom.viewDiscussion.getTextInput.on('keydown', function(e) {       if (e.which == 13 && !e.shiftKey) {            var v = e.target.value;            if (v[0] != '/') return;            var key = v.slice(1).split(' ')[0].toLowerCase,            slice = v.slice(key.length + 2),            command = ChatCommands[key];            if (!command || !key) return;            if (typeof command == 'string') {                command = ChatCommands[command] || command;            }            var result = typeof command == 'function' ? command(slice) : slice + ' ' + command;            if (result === true) return e.preventDefault;            if (!result) result = '';            e.target.value = result;        }    }); });