User:Ozuzanna/oneClickKickBan.js

//one-click kick and ban buttons for every unique message (not continued messages) //@author Ozuzanna

if (mw.config.get('wgCanonicalSpecialPageName') !== "Chat" || !$("#WikiChatList #user-" + mw.config.get('wgUserName')).hasClass('chat-mod')) return;
 * (function($, mw) {

var config; //used for banning

//add CSS mw.util.addCSS('.quick-kick { color:orange;cursor:pointer;} .quick-ban { color:red;cursor:pointer;}');

//set event listener mainRoom.model.chats.bind("afteradd", function (child) {	if (!$('#entry-' + child.cid).hasClass('inline-alert') && !$('#entry-' + child.cid).hasClass('continued'))		$('#entry-' + child.cid).children('.username').append(' (Kick) (Ban) '); });

//perform kick $('#Chat_' + roomId).on('click', 'ul li .username .quick-kick', function {	mainRoom.kick({ name: $(this).parents.eq(1).attr('data-user') }); });

//perform ban $('#Chat_' + roomId).on('click', 'ul li .username .quick-ban', function {	config = new models.BanCommand({ userToBan: $(this).parents.eq(1).attr('data-user'), time: 7200, reason: 'Banned using oneClickKickBan' });	mainRoom.socket.socket.send(config.xport); });

}) (this.jQuery, this.mediaWiki);