MuteCommands

Adds commands to mute and unmute people. /mute <username> /unmute <username> /ignore <username> /unignore <username> /mute all will mute all of chat until you type /unmute all

// ==UserScript==
// @name            MuteCommands
// @namespace       skyboy@kongregate
// @author          skyboy
// @version         1.6.0
// @description     Adds commands to mute and unmute people. /mute <username> /unmute <username> /ignore <username> /unignore <username> /mute all will mute all of chat until you type /unmute all
// @include         http://www.kongregate.com/games/*/*
// @homepage        http://userscripts.org/scripts/show/73346
// ==/UserScript==
if (/^\/?games\/[^\/]+\/[^\/?]+(\?.*)?$/.test(window.location.pathname))
setTimeout(function() {
	window.location.assign("javascript:$$('head')[0].insert(\"<style>.mute_chat_icon{background-position:0px -69px;width:13px;height:11px;overflow:hidden;}.unmute_chat_icon{background-position:0px -84px!important;}#kong_game_ui .mute_room_container{float:left;padding:4px 10px 3px}</style>\");$$('#chat_window').each(function(e){e.down('.chat_actions_container').insert({before:new Element('div', {'class':'mute_room_container'}).update('<span class=\"spritegame spriteall mute_chat_icon\" title=\"Mute Chat\">Mute Chat</span><span class=\"spritegame spriteall mute_chat_icon unmute_chat_icon\" style=\"display: none;\" title=\"Unmute Chat\">Unmute Chat</span>')})});void(0)");
	window.location.assign("javascript:(function(){ChatRoom.prototype.isAdmin=function(b){var a=this.user(b);return a?a.variables.admin:!1;};})();(function(){ChatRoom.prototype.refreshUsers=function(e){var d=0,b,a=e.length;for(;d<a;d++){b=this.user(e[d]);if(!!b){this.userChanged({data:{user:b,force:true}});}}};})();(function(){ChatRoom.prototype.user=function(u){if(typeof u=='string'){var a=this._users,i;if(!!a[u])return a[u];u=u.toLowerCase();for(i in a){if(i.toLowerCase()==u){return a[i];}}}return!1;};})();void(0)");
	window.location.assign("javascript:(function(){window.deencode=function(a){return eval('(function(){'+Base64.decode(a)+'})');};})();(function(){window.skyWriteMutedArray=function(a){return(\"window.deencode('\"+(Base64.encode(('/*window.open(\"\", \"Mwnd\").close();*/var Mwnd = window.open(\"\", \"Mwnd\", \"status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=1,scrollbars=0,height=\"+holodeck.height()+\",width=320\");var wnd=Mwnd.document;var MwndHTML1 = \"\\\\x3chtml>\\\\x3chead>\\\\x3ctitle>Kongregate Chat :: Muted Messages\\\\x3c/title>\" + $$(\"head\")[0].innerHTML.match(/script>s*(\\\\x3clink[^>]+)/i)[0] + \\'\\\\x3c/head>\\\\x3cbody style=\"overflow:hidden;\">\\\\x3cdiv id=\"kong_game_ui\" align=\"center\" style=\"position:fixed;top:0;left:0;background-color:#000;height:100%;width:100%;min-width:300px;min-height:300px;\">\\\\x3cdiv class=\"chat_room_template\" style=\"height:99%;width:98%;\">\\\\x3cdiv class=\"chat_message_window\" style=\"height:100%;overflow:auto\" id=\"wnd\">\\';var MwndHTML2 = \\'\\\\x3c/div>\\\\x3c/div>\\\\x3c/div>\\\\x3cscript type=\"text/javascript\">window.onresize = function (){document.getElementById(\"wnd\").style.height=(document.body.clientHeight-6)+\"px\";}\\\\x3c/script>\\\\x3c/body>\\\\x3c/html>\\';wnd.write(MwndHTML1 + \"'+(a.join('\\\\n').replace(/\"/g,'\\\\\"').replace(/\\x3c/g,\"\\\\x3c\"))+'\" + MwndHTML2);wnd.close();wnd.title=\"Kongregate Chat :: Muted Messages\";Mwnd.focus();')))+\"')\");};})();void(0)");
	window.location.assign("javascript:void(document.observe('holodeck:ready',function(){var o={r:/^\\/(?:un)?(?:mute|ignore)\\s*([a-z0-9_]{4,16}|all)/i,e:function(b){b.activeDialogue().kongBotMessage('Enter a username between four and sixteen characters long or \\\"all\\\".');},u:function(n,b){var g;b.chatWindow()._rooms.values().each(function(f){if(!g){g=f.user(n);if(g){g=g.username;throw $break;}}});if(!g){g=new Ajax.Request('/api/user_info.json?username='+n,{asynchronous:false,method:'get'}).transport.responseText;if(g){g=g.match(/\"username\":\"([a-zA-Z0-9_]+)\"/);if(g){g=g[1];}}if(!g){this.m(b,n+' does not exist or is permanently banned.');}}return g;},m:function(b,n){b.activeDialogue().displayUnsanitizedMessage('Kong Bot',n,{'class':'whisper received_whisper'},{'non_user':true});},url:function(b){return'/accounts/'+b.username()+'/muted_users';}},mute=(function(b,d){d=(d.match(this.r)||[0,0])[1];if(d!=0){if(d.toLowerCase()=='all'){if(!b.activeDialogue().hasOwnProperty('insert')){this.m(b,'Muted Room.');d=b.activeDialogue();d.mmsgs=[];b=new Element('div');d.insert=function(m){b.update('').insert(m);d.mmsgs.push(b.innerHTML);}}return!1;}d=this.u(d,b);if(d){b.addMuting(d);new Ajax.Request(this.url(b)+'?username='+d+'&from_chat=true',{asynchronous:true,evalScripts:true,method:'post'});this.m(b,'Muted '+d);}}else{this.e(b);}return!1;}).bind(o),umute=(function(b,d){d=(d.match(this.r)||[0,0])[1];if(d!=0){if(d.toLowerCase()=='all'){d=b.activeDialogue();if(d.hasOwnProperty('insert')){delete d.insert;this.m(b,'Unmuted Room. \\x3ca href=\\'javascript:void(0)\\' onclick=\\\"eval((this.onclick=\\'return false\\',this.href=\\'javascript:(\\' + '+window.skyWriteMutedArray(d.mmsgs)+'+\\')()\\'))\\\">Click here\\x3c/a> to view sent messages.');}return!1;}d=this.u(d,b);if(d){b.removeMuting(d);new Ajax.Request(this.url(b)+'/'+d+'?from_chat=true',{asynchronous:true,evalScripts:true,method:'delete'});this.m(b,'Unmuted '+d);}}else{this.e(b);}return!1;}).bind(o);var p=ChatDialogue.prototype,i=p.initialize;p.initialize=function(){var t=this;i.apply(t,arguments);var m='/mute all',mr=$('chat_window').down('.mute_room_container').childElements(),ur=mr[1];(mr=mr[0]).observe('click',function(){mute(t._holodeck,m);mr.hide();ur.show();});ur.observe('click',function(){umute(t._holodeck,m);ur.hide();mr.show();});};holodeck.addChatCommand('mute',mute);holodeck.addChatCommand('ignore',mute);holodeck.addChatCommand('unmute',umute);holodeck.addChatCommand('unignore',umute);}))");
}, 1250);