Last active
March 18, 2016 00:13
-
-
Save ekzhang/3e487883cc973e8136dc to your computer and use it in GitHub Desktop.
Run this code at ALL TIMES while playing mafia, and DO NOT REFRESH. You may run this code via the address bar, a bookmark, or the browser console.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function hashCode(e){var s,a,t,o=0;if(0===e.length)return o;for(s=0,t=e.length;t>s;s++)a=e.charCodeAt(s),o=(o<<5)-o+a,o|=0;return o}var players="",playing=!1,night=!1,dead=!1,my_name=$("div.message-wrapper.is-me")[0].children[0].innerHTML.trim().slice(0,-1),god="eygmath",voted=!1,_send=Classroom.send,new_send=function(e){e.message.toLowerCase().startsWith("->join")&&(e.message="->join|"+hashCode(my_name+"_join")),_send(e)},_onPluginMessage=Classroom.socket.onPluginMessage,newmsg=function(e){var s=e.message;if(my_name=my_name.toLowerCase(),"undefined"!=typeof e.message&&0===e.message.indexOf("->")){if(e.message=e.message.substring(5),e.speaker===god)if(e.message.toLowerCase().startsWith("players"))-1!==e.message.toLowerCase().indexOf(my_name)&&(playing=!0,players=e.message.substring(8));else if(e.message.toLowerCase().startsWith("end"))playing=!1,dead=!1;else if(e.message.toLowerCase().startsWith("toggle")){if(night=!night,voted=!1,night&&!dead){for(var a=prompt("Who would you like to target?");-1===players.indexOf(a);)a=prompt("Sorry, please check case and spelling. Who would you like to target?");Classroom.send({action:"public-message","room-id":"971",message:"->role "+a})}}else e.message.toLowerCase().startsWith("all")?(e.message=e.message.substring(4),_onPluginMessage(e)):e.message.toLowerCase().startsWith(my_name)?(e.message=e.message.substring(my_name.length+1),_onPluginMessage(e)):e.message.toLowerCase().startsWith("kill")?-1!==e.message.indexOf(my_name)&&(dead=!0):e.message.toLowerCase().startsWith("transfer")&&(e.message=e.message.substring(9),god=e.message.trim());else if(e.speaker===my_name&&!dead){if(e.message.toLowerCase().startsWith("vote")){if(""==e.message.substring(5).trim()||!voted){for(var t=prompt("Who would you like to lynch?");-1===players.indexOf(t);)t=prompt("Sorry, please check case and spelling. Who would you like to lynch?");voted=!0,Classroom.send({action:"public-message","room-id":"971",message:"->vote "+t})}}else e.message.toLowerCase().startsWith("kill")?alert("Oops! There is no kill command. You will be prompted during the night, and type ->vote during the day."):e.message.toLowerCase().startsWith("list")?alert("Players: "+playerlist):e.message.toLowerCase().startsWith("help")&&alert("->help, ->join, ->list, ->role, and ->vote are valid actions.");_onPluginMessage(e)}}else!playing||night||dead?playing||dead||_onPluginMessage(e):-1!==players.indexOf(e.speaker)&&(e.message=s,_onPluginMessage(e))};Classroom.send=new_send,Classroom.socket.onPluginMessage=newmsg; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment