-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmods.js
214 lines (214 loc) · 64.6 KB
/
mods.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
document.getElementById("helloContainer").style.display='none';var ourskins="0chan;18-25;1up;360nati0n;8ball;UmguwJ0;aa9skillz;ace;adamzonetopmarks;advertisingmz;agar youtube;agariomods.com;al sahim;alaska;albania;alchestbreach;alexelcapo;algeria;am3nlc;amoodiesqueezie;amway921wot;amyleethirty3;anarchy;android;angrybirdsnest;angryjoeshow;animebromii;anonymous;antvenom;aperture;apple;arcadego;assassinscreed;atari;athenewins;authenticgames;avatar;aviatorgaming;awesome;awwmuffin;aypierre;baka;balenaproductions;bandaid;bane;baseball;bashurverse;basketball;bateson87;batman;battlefield;bdoubleo100;beats;bebopvox;belarus;belgium;bender;benderchat;bereghostgames;bert;bestcodcomedy;bielarus;bitcoin;bjacau1;bjacau2;black widow;blackiegonth;blitzwinger;blobfish;bluexephos;bluh;blunty3000;bobross;bobsaget;bodil30;bodil40;bohemianeagle;boo;boogie2988;borg;bowserbikejustdance;bp;breakfast;breizh;brksedu;buckballs;burgundy;butters;buzzbean11;bystaxx;byzantium;calfreezy;callofduty;captainsparklez;casaldenerd;catalonia;catalunya;catman;cavemanfilms;celopand;chaboyyhd;chaika;chaosxsilencer;chaoticmonki;charlie615119;charmander;chechenya;checkpointplus;cheese;chickfila;chimneyswift11;chocolate;chrisandthemike;chrisarchieprods;chrome;chucknorris;chuggaaconroy;cicciogamer89;cinnamontoastken;cirno;cj;ckaikd0021;clanlec;clashofclansstrats;cling on;cobanermani456;coca cola;codqg;coisadenerd;cokacola;colombia;colombiaa;commanderkrieger;communitygame;concrafter;consolesejogosbrasil;controless ;converse;cookie;coolifegame;coookie;cornella;cornellà;coruja;craftbattleduty;creeper;creepydoll;criken2;criousgamers;crispyconcords;cristian4games;csfb;cuba;cubex55;cyberman65;cypriengaming;cyprus;czech;czechia;czechrepublic;d7297ut;d7oomy999;dagelijkshaadee;daithidenogla;darduinmymenlon;darksideofmoon;darksydephil;darkzerotv;dashiegames;day9tv;deadloxmc;deadpool;deal with it;deathly hallows;deathstar;debitorlp;deigamer;demon;derp;desu;dhole;diabl0x9;dickbutt;dilleron;dilleronplay;direwolf20;dissidiuswastaken;dnb;dnermc;doge;doggie;dolan;domo;domokun;donald;dong;donut;doraemon;dotacinema;douglby;dpjsc08;dreamcast;drift0r;drunken;dspgaming;dusdavidgames;dykgaming;ea;easports;easportsfootball;eatmydiction1;eavision;ebin;eeoneguy;egg;egoraptor;eguri89games;egypt;eksi;electrokitty;electronicartsde;elementanimation;elezwarface;eligorko;elrubiusomg;enzoknol;eowjdfudshrghk;epicface;ethoslab;exetrizegamer;expand;eye;facebook;fantabobgames;fast forward;fastforward;favijtv;fazeclan;fbi;fer0m0nas;fernanfloo;fgteev;fidel;fiji;finn;fir4sgamer;firefox;fishies;flash;florida;fnatic;fnaticc;foe;folagor03;forcesc2strategy;forocoches;frankieonpcin1080p;freeman;freemason;friesland;frigiel;frogout;fuckfacebook;fullhdvideos4me;funkyblackcat;gaben;gabenn;gagatunfeed;gamebombru;gamefails;gamegrumps;gamehelper;gameloft;gamenewsofficial;gameplayrj;gamerspawn;games;gameshqmedia;gamespot;gamestarde;gametrailers;gametube;gamexplain;garenavietnam;garfield;gassymexican;gaston;geilkind;generikb;germanletsfail;getinmybelly;getinthebox;ghostrobo;giancarloparimango11;gimper;gimperr;github;giygas;gizzy14gazza;gnomechild;gocalibergaming;godsoncoc;gogomantv;gokoutv;goldglovetv;gommehd;gona89;gonzo;gonzossm;grammar nazi;grayhat;grima;gronkh;grumpy;gtamissions;gtaseriesvideos;guccinoheya;guilhermegamer;guilhermeoss;gurren lagann;h2odelirious;haatfilms;hagrid;halflife;halflife3;halo;handicapped;hap;hassanalhajry;hatty;hawaii;hawkeye;hdluh;hdstarcraft;heartrockerchannel;hebrew;heisenburg;helix;helldogmadness;hikakingames;hikeplays;hipsterwhale;hispachan;hitler;homestuck;honeycomb;hosokawa;hue;huskymudkipz;huskystarcraft;hydro;iballisticsquid;iceland;ie;igameplay1337;ignentertainment;ihascupquake;illuminati;illuminatiii;ilvostrocarodexter;imaqtpie;imgur;immortalhdfilms;imperial japan;imperialists;imperialjapan;imvuinc;insanegaz;insidegaming;insidersnetwork;instagram;instalok;inthelittlewood;ipodmail;iron man;isaac;isamuxpompa;isis;isreal;itchyfeetleech;itsjerryandharry;itsonbtv;iulitm;ivysaur;izuniy;jackfrags;jacksepticeye;jahovaswitniss;jahrein;jaidefinichon;james bond;jamesnintendonerd;jamonymow;java;jellyyt;jeromeasf;jew;jewnose;jibanyan;jimmies;jjayjoker;joeygraceffagames;johnsju;jontronshow;josemicod5;joueurdugrenier;juegagerman;jumpinthepack;jupiter;kalmar union;kame;kappa;karamba728;kenny;keralis;kiloomobile;kingdomoffrance;kingjoffrey;kinnpatuhikaru;kirby;kitty;kjragaming;klingon;knekrogamer;knights templar;knightstemplar;knowyourmeme;kootra;kripparrian;ksiolajidebt;ksiolajidebthd;kuplinovplay;kurdistan;kwebbelkop;kyle;kyokushin4;kyrsp33dy;ladle;laggerfeed;lazuritnyignom;ldshadowlady;le snake;lenny;letsplay;letsplayshik;letstaddl;level5ch;levelcapgaming;lgbt;liberland;libertyy;liechtenstien;lifesimmer;linux;lisbug;littlelizardgaming;llessur;loadingreadyrun;loki;lolchampseries;lonniedos;love;lpmitkev;luigi;luke4316;m3rkmus1c;macedonia;machinimarealm;machinimarespawn;magdalenamariamonika;mahalovideogames;malena010102;malta;mario;mario11168;markipliergame;mars;maryland;masterball;mastercheif;mateiformiga;matroix;matthdgamer;matthewpatrick13;mattshea;maxmoefoegames;mcdonalds;meatboy;meatwad;meatwagon22;megamilk;messyourself;mickey;mike tyson;mike;miles923;minecraftblow;minecraftfinest;minecraftuniverse;miniladdd;miniminter;minnesotaburns;minnie;mkiceandfire;mlg;mm7games;mmohut;mmoxreview;mod3rnst3pny;moldova;morealia;mortalkombat;mr burns;mr.bean;mr.popo;mrchesterccj;mrdalekjd;mredxwx;mrlev12;mrlololoshka;mrvertez;mrwoofless;multirawen;munchingorange;n64;naga;namcobandaigameseu;nasa;natusvinceretv;nauru;nazi;nbgi;needforspeed;nepenthez;nextgentactics;nextgenwalkthroughs;ngtzombies;nick fury;nick;nickelodeon;niichts;nintendo;nintendocaprisun;nintendowiimovies;nipple;nislt;nobodyepic;node;noobfromua;northbrabant;northernlion;norunine;nosmoking;notch;nsa;obama;obey;officialclashofclans;officialnerdcubed;oficialmundocanibal;olafvids;omfgcata;onlyvgvids;opticnade;osu;ouch;outsidexbox;p3rvduxa;packattack04082;palau;paluten;pandaexpress;paulsoaresjr;pauseunpause;pazudoraya;pdkfilms;peanutbuttergamer;pedo;pedobear;peinto1008;peka;penguin;penguinz0;pepe;pepsi;perpetuumworld;pewdiepie;pi;pietsmittie;pig;piggy;pika;pimpnite;pinkfloyd;pinkstylist;pirate;piratebay;pizza;pizzaa;plagasrz;plantsvszombies;playclashofclans;playcomedyclub;playscopetrailers;playstation;playstation3gaminghd;pockysweets;poketlwewt;pooh;poop;popularmmos;potato;prestonplayz;protatomonster;prowrestlingshibatar;pt;pur3pamaj;quantum leap;question;rageface;rajmangaminghd;retard smile;rewind;rewinside;rezendeevil;reziplaygamesagain;rfm767;riffer333;robbaz;rockalone2k;rockbandprincess1;rockstar;rockstargames;rojov13;rolfharris;roomba;roosterteeth;roviomobile;rspproductionz;rss;rusgametactics;ryukyu;s.h.e.i.l.d;sah4rshow;samoa;sara12031986;sarazarlp;satan;saudi arabia;scream;screwattack;seal;seananners;serbia;serbiangamesbl;sethbling;sharingan;shell;shine;shofu;shrek;shufflelp;shurikworld;shuuya007;sinistar;siphano13;sir;skillgaming;skinspotlights;skkf;skull;skydoesminecraft;skylandersgame;skype;skyrim;slack;slovakia;slovenia;slowpoke;smash;smikesmike05;smoothmcgroove;smoove7182954;smoshgames;snafu;snapchat;snoop dogg;soccer;soliare;solomid;somalia;sp4zie;space ace;space;sparklesproduction;sparkofphoenix;spawn;speedyw03;speirstheamazinghd;spiderman;spongegar;spore;spqr;spy;squareenix;squirtle;ssohpkc;sssniperwolf;ssundee;stalinjr;stampylonghead;star wars rebel;starbucks;starchild;starrynight;staxxcraft;stitch;stupid;summit1g;sunface;superevgexa;superman;superskarmory;swiftor;swimmingbird941;syria;t3ddygames;tackle4826;taco;taltigolt;tasselfoot;tazercraft;tbnrfrags;tctngaming;teamfortress;teamgarrymoviethai;teammojang;terrorgamesbionic;tetraninja;tgn;the8bittheater;thealvaro845;theatlanticcraft;thebajancanadian;thebraindit;thecraftanos;thedanirep;thedeluxe4;thediamondminecart;theescapistmagazine;thefantasio974;thegaminglemon;thegrefg;thejoves;thejwittz;themasterov;themaxmurai;themediacows;themrsark;thepolishpenguinpl;theradbrad;therelaxingend;therpgminx;therunawayguys;thesims;theskylanderboy;thesw1tcher;thesyndicateproject;theuselessmouth;thewillyrex;thnxcya;thor;tintin;tmartn;tmartn2;tobygames;tomo0723sw;tonga;topbestappsforkids;totalhalibut;touchgameplay;transformer;transformers;trickshotting;triforce;trollarchoffice;trollface;trumpsc;tubbymcfatfuck;turkey;tv;tvddotty;tvongamenet;twitch;twitter;twosyncfifa;typicalgamer;uberdanger;uberhaxornova;ubisoft;uguu;ukip;ungespielt;uppercase;uruguay;utorrent;vanossgaming;vatican;venomextreme;venturiantale;videogamedunkey;videogames;vietnam;vikkstar123;vikkstar123hd;vintagebeef;virus;vladnext3;voat;voyager;vsauce3;w1ldc4t43;wakawaka;wales;walrus;wazowski;wewlad;white light;whiteboy7thst;whoyourenemy;wiiriketopray;willyrex;windows;wingsofredemption;wit my woes;woodysgamertag;worldgamingshows;worldoftanks;worldofwarcraft;wowcrendor;wqlfy;wroetoshaw;wwf;wykop;xalexby11;xbox;xboxviewtv;xbulletgtx;xcalizorz;xcvii007r1;xjawz;xmandzio;xpertthief;xrpmx13;xsk;yamimash;yarikpawgames;ycm;yfrosta;yinyang;ylilauta;ylilautaa;yoba;yobaa;yobaaa;yogscast2;yogscastlalna;yogscastsips;yogscastsjin;yoteslaya;youalwayswin;yourheroes;yourmom;youtube;zackscottgames;zangado;zazinombies;zeecrazyatheist;zeon;zerkaahd;zerkaaplays;zexyzek;zimbabwe;zng;zoella;zoidberg;zombey;zoomingames";var version=200;if(version!=localStorage.getItem("version")){localStorage.setItem("version",version);var benchmarks=["250mass","500mass","1000mass","2500mass","5000mass"];for(var i=0;i<benchmarks.length;i++){var a=localStorage.getItem("best_"+ benchmarks[i])
if(a!=null){a=a.split(":")}else{continue};if(a.length==2)localStorage.getItem("best_"+ benchmarks[i],((a[0]*60000)+(a[1]*1000)).toString());}};function preset(s,v){if(null==localStorage.getItem(s))localStorage.setItem(s,v)}
preset("chatEnabled","true");preset("settingShow_chart","true");preset("showt","true");var showsh=false;var showt=localStorage.getItem("showt")=="true";var chatEnabled=localStorage.getItem("chatEnabled")=="true";var extToggled=false;var rse=document.getElementById("region").cloneNode(true);window.server={ip:"",i:"",location:""};var ldown=false;var pload=0;var ptime=false;var showfps=false;var showpio=false;var showbio=false;window.addEventListener('message',function(e){if(e.data=="ScriptDisable"){extToggled=true;window.top.location=window.top.location;}},false);if(showt===null){localStorage.setItem("showt","true");showt=true;}
setInterval(function(){if(showsh)DrawStats(false);if(showt&&in_game)count();if(ptime)time(Date.now());},1000);var gamejs="",modBlocking=true;var tester=document.getElementsByTagName("script");var i=0;var W='';var Ja='';var b='';var sk='';var c3eg2='';var in_game=false;var pandb='';var bgmusic='';var tracks=['BotB 17936 Isolation Tank.mp3','BotB 17934 bubblybubblebubblingbubbles.mp3','BotB 17935 bloblobloblboblbolboblboblbobolbloblob.mp3','BotB 17937 Woofytunes.mp3','BotB 17938 slowgrow.mp3'];var ssfxlist=['spawn','gameover'];var ssfxs=[];for(i=0;i<ssfxlist.length;i++){var newsfx=new Audio("//skins.agariomods.com/botb/sfx/"+ ssfxlist[i]+".mp3");newsfx.loop=false;ssfxs.push(newsfx);}
function sfx_play(id){if(document.getElementById("sfx").value==0)return;var event=ssfxs[id];event.volume=document.getElementById("sfx").value;event.play();}
var pellets=[];var pellet=0;for(i=0;i<50;i++){newsfx=new Audio('data:audio/mp3;base64,SUQzAwAAAAAAIlRSQ0sAAAACAAAAOFRJVDIAAAAMAAAAQXVkaW8gVHJhY2v/8yTEAAcAQph5SRAAAMuAAnOc5z/mwmFwBgDA2TvWD4PyjpQ5vlHcH+9/fK8aWTj/8yTEBwlocqgBmtAA0HYmGCTgm37MUrTnLZjRhwJ0wNQRg5EY8gXae+xVQhZevYv/8yTEBAewXpghzwABX2fMStQ1DTRLaQUW0QkTU6o7CyvRX4gpvwQWTEFNRTMuOTn/8yTECAAAA0gAAAAALjOqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqo=');newsfx.loop=false;pellets.push(newsfx);}
function play_pellet(){if(document.getElementById("sfx").value==0)return;pellet++
if(pellet>49)pellet=0;pellets[pellet].volume=document.getElementById("sfx").value;pellets[pellet].play()}
var sfxlist=['split','eat','bounce','merge','virusfeed','virusshoot','virushit'];var sfxs=[];for(i=0;i<sfxlist.length;i++){var newsfx=new Audio("//skins.agariomods.com/botb/sfx/"+ sfxlist[i]+".mp3");newsfx.loop=false;newsfx.onended=function(){$(this).remove();}
sfxs.push(newsfx);}
function sfx_event(id){if(document.getElementById("sfx").value==0)return;var event=jQuery.clone(sfxs[id]);event.volume=document.getElementById("sfx").value;event.load();event.play();}
var test=0;var passed=0;var failed=0;var chart_update_interval=10;var chart=null;var chart_data=[];var chart_counter=0;var chart_s='';var chart_m='';var chart_G='';var chart_Na='';var chart_k='';var sd='';var mainout=window.location.protocol+"//agar.io/main_out.js";document.getElementsByClassName("agario-panel")[0].style.display="none";httpGet(mainout,function(data){winvar=data.substr(10,1);gamejs="window.agariomods = "+ data.replace("socket open","socket open (agariomods.com mod in place)");gamejs=gamejs.replace(/\n/g,"");sd=gamejs.substr(gamejs.search(/\w.send/),1);offset=gamejs.search("..=\"poland;");Ja=gamejs.substr(offset,2);offset=gamejs.search(".....src=\"skins");b=gamejs.substr(offset+2,1);offset=gamejs.search(/\w+\.indexOf\(.\)\?/);sk=gamejs.substr(offset,2);offset=gamejs.search(".."+b+"..src");W=gamejs.substr(offset,1);var components=/this\.(.)&&.\.strokeText/.exec(gamejs);pandb=components[1];var components=/strokeText\((.{1,14})\);/.exec(gamejs);c3eg2=components[1];var components=/\((.)\=..x,.\=..y,/.exec(gamejs);chart_s=components[1];var components=/\(.\=(.).x,.\=..y,/.exec(gamejs);chart_m=components[1];var components=/(.)\=Math.max\(.,..\(\)\);/.exec(gamejs);chart_G=components[1];var components=/.\=Math.max\(.,(..)\(\)\);/.exec(gamejs);chart_Na=components[1];var components=/(.)\[0\]\.name\&\&\(/.exec(gamejs);chart_k=components[1];agariomodsRuntimeInjection();});function httpGet(theUrl,callback){var xmlHttp=new XMLHttpRequest();xmlHttp.open("GET",theUrl,true);xmlHttp.send(null);xmlHttp.onreadystatechange=function(){if(xmlHttp.readyState==4&&xmlHttp.status==200){callback(xmlHttp.responseText);}};}
window.connect2=window.connect;function agariomodsRuntimeInjection(){var script=document.createElement("script");script.src='//cdnjs.cloudflare.com/ajax/libs/canvasjs/1.4.1/canvas.min.js';document.head.appendChild(script);var tester=document.getElementsByTagName("head");var oldhtml=tester[0].innerHTML;oldhtml=oldhtml.replace('#helloContainer,.connecting-panel{','#helloContainer{left:-2px;top:-6px;width:682px;');oldhtml=oldhtml.replace('width:94px;','margin-right:10px;');oldhtml=oldhtml.replace('#locationKnown','#locationKnown{height:40px}#locationKnown');oldhtml=oldhtml.replace('#region{width:100%','#region{width:300px;float:left');oldhtml=oldhtml.replace('.btn-spectate{','.btn-spectate{width:110px;');oldhtml=oldhtml.replace('margin-left:5px;width:275px','width:357px');oldhtml=oldhtml.replace('-webkit-transform:translate(-50%,-50%);','');oldhtml=oldhtml.replace('-ms-transform:translate(-50%,-50%);','');oldhtml=oldhtml.replace('transform:translate(-50%,-50%);','');oldhtml=oldhtml.replace('top:50%;left:50%;','margin:10px;');oldhtml=oldhtml.replace('width:100%;height:100%;','');oldhtml=oldhtml.replace('.agario-panel{','.agario-promo{display:none !important;}.connecting-panel{margin:0 0 !important;position:absolute;top:5px;right:5px;}.ui{pointerEvents:none}br+div:not([style]){height:35px;}#helloContainer>.agario-panel{float:left}#helloContainer>.side-container{float:right}.agario-panel{transform: none !important;');tester[0].innerHTML=oldhtml;var script=document.createElement("script");script.id="agariomods";agariomodsRuntimePatches();if(document.getElementById("agariomods")){alert("You are currently running multiple instances of Agariomods simultaneously!\nCheck that you dont have Tampermonkey Script and the Chrome Extension running at the same time if you're on Chrome;\nYou will see visual glicthes until YOU fix this.");}
script.innerHTML=gamejs;var oc=document.getElementById("canvas");var nc=document.createElement("canvas");nc.id="canvas";nc.width=oc.width;nc.height=oc.height;oc.parentNode.replaceChild(nc,oc);document.getElementById("region").parentNode.replaceChild(rse,document.getElementById("region"));document.head.appendChild(script);document.getElementsByClassName("agario-panel")[0].style.display="block";agariomodsRuntimeHacks();bgmusic=new Audio()
bgmusic.src="//skins.agariomods.com/botb/"+ tracks[Math.floor(Math.random()*tracks.length)];bgmusic.load();bgmusic.loop=false;bgmusic.onended=function(){var track=tracks[Math.floor(Math.random()*tracks.length)];bgmusic.src="//skins.agariomods.com/botb/"+ track;bgmusic.play();};$("#canvas").on('mousedown',function(event){event.preventDefault();});var tempa=document.getElementById("connecting").style;tempa.backgroundColor="rgba(0,0,0,0.6)";tempa.zIndex="199";document.getElementById("a300x250").style.backgroundImage="none";}
window.log=function(stuff){console.log(stuff);}
function agariomodsRuntimePatches(){gamejs_patch(/#partyToken/g,'.partyToken',"Change id selector to class selector.");gamejs_patch('console.log("socket close");','onwsclose();console.log("socket close");',"Simulate player death on unexpected socket close");gamejs_patch('.onclose=null;','.onclose=onwsclose;',"Simulate player death on intentional socket close.")
gamejs_patch(/\w>\w\/1\.1\?.*-50%\)"\);/,'',"fixing menu on resize");gamejs_patch(';reddit;',';reddit;'+ourskins+';',"add our skinlist to the original game skinlist.");gamejs_patch(b+'=this.name.toLowerCase();',b+'=this.name.toLowerCase();var agariomods="";var ourskins = "'+ourskins+'";if(('+b+'.length >0)&&(ourskins.split(";").indexOf('+b+')>-1)){agariomods="//skins.agariomods.com/i/"+'+b+'+".png";}else if('+b+'.substring(0,1)=="*"){if(!custom){agariomods="//connect.agariomods.com/img_"+this.name.substring(1)+".png";}}else if('+b+'.substring(0,2)=="i/"){if(!custom){agariomods="//i.imgur.com/"+this.name.substring(2)+".jpg";}}else if('+sk+'.indexOf('+b+')>-1){agariomods="//agar.io/skins/"+this.name.toLowerCase()+".png";}',"add check for which skin mode we are in. be it no skin, default skin, custom skin, or an agariomods skin.");gamejs_patch('=1E4,','=1E4,'+'zz=!1,yq=!1,xx=!1,xz=!1,ts=!1,custom=!1,opv=!1'+',',"adding variables");gamejs_patch(W+'['+b+'].src="skins/"+'+b+'+".png"',W+'['+b+'].src=agariomods',"check for agariomods img src variable");gamejs_patch("this."+pandb+"&&c.strokeText("+c3eg2+");c.fillText("+c3eg2+")","if (String(b).substring(0, 2) != \"i/\" || custom) {this."+pandb+"&&c.strokeText("+c3eg2+");c.fillText("+c3eg2+")}","add imgur skins check for hiding username when using imgur id aka c3eg2");gamejs_patch(b+"=this.name.toLowerCase();",b+"=this.name.toLowerCase(); if (("+b+".substring(0, 2) == \"i/\"||"+b+".substring(0, 1) == \"*\")&&!custom&&"+Ja+".indexOf("+b+")==-1) {"+Ja+".push("+b+")} ;","add imgur check #2.");gamejs=addKeyboardHook(gamejs);gamejs=addSkinHook(gamejs);gamejs=addChartHooks(gamejs);gamejs=addOnCellEatenHook(gamejs);gamejs=addTeamMassHook(gamejs);gamejs=addTeamSkinsHook(gamejs);gamejs=addCanvasBGHook(gamejs);gamejs=addVirusColorHook(gamejs);gamejs=addFunctions(gamejs);gamejs=addOnShowOverlayHook(gamejs);gamejs=addOnHideOverlayHook(gamejs);gamejs=addLeaderboardHook(gamejs);gamejs=addConnectHook(gamejs);gamejs=addRecieveHook(gamejs);gamejs=addOnSendHook(gamejs);gamejs=addOnDrawHook(gamejs);gamejs=gamejs.replace(/=\w\.innerHeight/g,'=opv&&'+winvar+'.innerHeight/'+winvar+'.innerWidth>=0.5625?('+winvar+'.innerWidth*0.5625):('+winvar+'.innerHeight)');gamejs=gamejs.replace(/=\w\.innerWidth/g,'=opv&&'+winvar+'.innerHeight/'+winvar+'.innerWidth<=0.5625?('+winvar+'.innerHeight/0.5625):('+winvar+'.innerWidth)');console.log("Testing complete, "+passed+" units passed and "+failed+" units failed.");if(failed)console.log(new Error("UNIT FAILED"));}
function gamejs_patch(search,replace,purpose){gamejs=gamejs.replace(search,replace);testCondition((-1!=gamejs.indexOf(replace)),test++,purpose);}
function testCondition(condition,id,comment){if(condition){console.log("test: #"+id+" PASSED - "+ comment);passed++;}else{console.error("test: #"+id+" FAILED - "+ comment);failed++;}}
function agariomodsRuntimeHacks(){jQuery('div.agario-panel:has(#locationUnknown)').css({width:'450px'});jQuery('div#settings div:has(#locationKnown)').css({float:'none'});var bg=document.getElementById("canvas");bg.style.backgroundSize='cover';bg.style.backgroundRepeat='no-repeat';bg.style.backgroundAttachment="fixed";document.body.style.backgroundColor="grey";var nodeDiv=document.createElement("div");var nodeDiv2=document.createElement("div");$(document).ready(function(){hd=document.getElementsByClassName("agario-panel")[0];cachedhd=hd.innerHTML;hd.innerHTML=cachedhd.replace("<center>Agar.io</center>","<a target=\"_blank\" style=\"position:absolute; padding-left:435px;top:-10px; z-index: -1; height:120px;\" href=\"https://www.reddit.com/r/Agario/\"><img src=\"//i.imgur.com/TkTWOrc.png\" height=\"120px\"/></a>");});document.getElementById("nick").placeholder="agariomods.com";nodeDiv.id="includedContent";nodeDiv.style.width="calc(100% + 10px)"
nodeDiv.style.backgroundColor="#000000";nodeDiv.style.zIndex=999;nodeDiv.style.position="relative";nodeDiv2.style.padding="8px";nodeDiv.style.borderRadius="5px";nodeDiv.style.color="#dddddd";nodeDiv2.style.color="#dddddd";nodeDiv.style.margin="3px -5px 8px";nodeDiv2.style.maxHeight="200px";nodeDiv2.style.width="calc(100% - 5px)";nodeDiv.style.overflow="none";nodeDiv2.style.overflow="auto";nodeDiv2.innerHTML+='1.9.9: <big style="font-weight:bold;">Sign-in to <a href="http://connect.agariomods.com">connect.agariomods.com</a> and activate chat on our Private Servers from your profile!!!</big><br> \
<b>Use custom skins with *ACCOUNTNAME</b><br><h3>Stage 3 is dawning upon us</h3><a href="http://connect.agariomods.com/" target="_blank"><font color="pink">Register now with agariomods connect because you will need it for some soon to be released exciting new features.</font></a><br>\
Go catch up with the <a target="_blank" href="http://agariomods.com/documentation.html">Documentation</a><br><h4><a href="http://www.agariomods.com/help.html" target="_blank"><font color="pink">CLICK HERE FOR HELP</font></a></h4>\
<div style="background-color: #ffffff; color: #000000; padding: 2px; margin: 0px;">\
<small><b>Disable ad blockers</b> - They are breaking the game and our modifications in random and unexpected ways.</small>\
</div>';nodeDiv.appendChild(nodeDiv2);jQuery(".form-group:first").replaceWith('<br>');var selector=jQuery('#region');var playBtn=jQuery('#playBtn');var nodeInput=document.createElement("span");var nodeSpan=document.createElement("span");var nodeBr=document.createElement("br");var nodeLinks=document.createElement("div");nodeLinks.innerHTML="<ul style='position:relative;left:-25px;width:450px;background-color:#428bca;text-align:center;font:16px bold,sans-serif;list-style-type:none;margin:6px 0 3px;padding:0;overflow:hidden;'><li style='float:left;'><a class='link' style='width:70px;' href='http://skins.agariomods.com' target='_blank'>SKINS</a><li style='float:left;'><a style='width:70px;' class='link' href='http://agariomods.com/chat.html' target='_blank'>CHAT</a><li style='float:left;'><a style='width:100px;' class='link' href='http://agariomods.com' target='_blank'>WEBSITE</a><li style='float:left;'><a style='width:110px;' class='link' href='http://agariomods.com/documentation.html' target='_blank'>FEATURES</a></li><li style='float:left;'><a style='width:100px;' class='link' style='border-right:0 !important' href onclick=\"alert('---HOTKEYS---\\nHold Z - Show Stats In-Game\\nConnect To Private Server - Alt+C\\nToggle Chat - C\\nInput Chat - Enter OR \\'/\\'\\nToggle Benchmarker - T\\nClear Benchmarks - Alt+T\\nTime On Page - Alt+1\\nFPS Counter - Alt+2\\nPackets In/Out Per Second - Alt+3\\nBytes In/Out Per Second - Alt+4\\nAttempt Lag Recovery - Alt+R'+(navigator.userAgent.match('Firefox')?'\\nTrue Fullscreen for Firefox - Ctrl+F\\nShow Menu While in Fullscreen - Delete':''));return false;\" target='_blank'>HOTKEYS</a></li></ul>";nodeLinks.style.marginLeft='10px';nodeSpan.className="glyphicon glyphicon-refresh btn btn-info";nodeSpan.style.fontSize="1.5em";nodeSpan.style.cssFloat="left";nodeSpan.style.paddingTop="2px";nodeSpan.style.width="15%";nodeSpan.style.height="33px";nodeInput.id="iphack"
nodeInput.style.width="85%";nodeInput.style.cssFloat="left";nodeInput.style.cssClear="right";nodeInput.style.padding="5px;";nodeInput.style.margin="5px;";nodeInput.style.border="2px solid green";jQuery('#locationUnknown').prepend(nodeLinks);jQuery('#locationUnknown').append(nodeDiv);$('.link').css({'display':'block','border-right':'1px solid #0077CC','padding':'4px 0','background-color':'#428bca','color':'white'});$('.link').hover(function(){$(this).css('background-color','#529bda');$(this).removeClass("active");},function(){$(this).css('background-color','#428bca');$(this).removeClass("active");});jQuery('.form-group:first').removeAttr("class");jQuery('.btn-play-guest').addClass("btn-danger");jQuery('.btn-play-guest').css('width',"208px");jQuery('.btn-play-guest').css('margin-left','0');jQuery('.btn-play-guest').removeClass("btn-success");jQuery('.btn-login').css("margin-right","4px");jQuery('.btn-login').css("width","140px");jQuery('#settings div:has(#locationKnown)').css("width","100%");var oldc=jQuery("#settings div:has(.btn-spectate)");jQuery(".btn-spectate").insertAfter($("#region"));oldc.remove();}
var chart_update_interval=10;var chart=null;var chart_data=[];var chart_counter=0;var stat_canvas=null;var stats=null;var my_cells=null;var my_color="#ff8888";var pie=null;var stats_chart;var display_chart=LS_getValue('display_chart','true')==='true';var display_stats=LS_getValue('display_stats','false')==='true';var g_stat_spacing=0;var g_display_width=220;var g_layout_width=g_display_width;function addKeyboardHook(script){var match=script.match(/onkeydown=function\(\w\){/);var split=script.split(match[0]);return split[0]+ match[0]+' if(isVisible()) return;'+ split[1];}
function addSkinHook(script){var match=script.match(/(\w+)=null:\w+=null;/);var split=script.split(match[0]);return split[0]+ match[1]+'=null:'+ match[1]+'=null;if(custom&&('+b+'.substring(0,2).match(/^(i\\/|\\*.)$/))){'+ match[1]+'=null;}'+ split[1];}
function addChartHooks(script){var match=script.match(/max\((\w+),(\w+)\(/);var high=match[1];var current=match[2];match=script.match(/1==(\w+)\.length&&\(/);var my_cells=match[1];var split=script.split(match[0]);script=split[0]+'1=='+my_cells+'.length&&(OnGameStart('+my_cells+'),'+ split[1];split=script.split(script.match(/\w\("score"\)\+": "\+~~\(\w+\/100\)/)[0]);match=split[1].match(/-(\d+)\)\);/);var subSplit=split[1].split(match[0]);split[1]=subSplit[0]+'-'+match[1]+'),('+my_cells+'&&'+my_cells+'[0]&&OnUpdateMass('+current+'())));'+ subSplit[1];return split[0]+'"Current: "+~~('+current+'()/100)+" High: "+~~('+high+'/100)'+ split[1];}
function addTeamSkinsHook(script){var match=script.match(/":teams"!=(\w)/);var split=script.split(match[0]);return split[0]+'(":teams"!='+match[1]+'||ts)'+split[1];}
function addTeamMassHook(script){var match=script.match(/":teams"!=(\w)/);var tvar=match[1];match=script.match(/this\.id&&(\w+)/);var split=script.split(match[0]);var c=match[1];script=split[0]+"this.id&&("+c+"||yq)"+split[1];var d=script.match(/\(!this\.\w\|\|this\.\w\)/);match=script.match(/(\w)=-1!=(\w)\.indexOf\(this\);/);split=script.split(match[0]);var a=match[1];var z=match[2];return split[0]+"if(-1!="+z+".indexOf(this)){"+a+"="+c+"}else if(yq&&"+z+"[0]&&"+tvar+"==':teams'&&this.size>20&&"+d+"&&this.color.substr("+z+"[0].color.search('ff'),2)=='ff'){"+a+"=true}"+split[1];}
function addFunctions(script){var match=script.match(/(\w+)\("#connecting"\)\.show\(\),(\w+)\(\)/);var one=match[1];var two=match[2];var match=script.match(/((\w)\.setAcid)/);var split=script.split(match[0]);return split[0]+match[2]+'.setR=function(){'+one+'("#connecting").show(),'+two+'()};'+match[2]+'.setMVR=function(a){opv=a;'+winvar+'.onresize()};'+match[2]+'.setTskins=function(a){ts=a};'+match[2]+'.setCustom=function(a){custom=a;};'+match[2]+'.setVColors=function(a){zz=a};'+match[2]+'.setTeamMass=function(a){yq=a};'+match[2]+'.setBG=function(a){xx=a;if(a){var url=localStorage.getItem("bgurl");if(url==null){url=""};var promp=prompt("Image URL",url);if(null==promp){jQuery("#bgimg").attr("checked",false);check(document.getElementById("bgimg"));xx=!a;return;}localStorage.setItem("bgurl",promp);jQuery("#acid").attr("checked",false);check(document.getElementById("acid"));document.getElementById("canvas").style.backgroundImage=\'url("\'+promp+\'")\';xz=confirm("Show Grid Lines?");}};'+match[1]+split[1]}
function addCanvasBGHook(script){var match=script.match(/(\w)\.clearRect\(0,0,(\w),(\w)\)/);var split=script.split(match[0]);script=split[0]+match[1]+'.clearRect(0,0,'+match[2]+','+match[3]+');xx&&!xz?'+match[1]+'.clearRect(0,0,'+match[2]+','+match[3]+'):'+split[1].substr(1);var match2=script.match(/BFF";/);var split=script.split(match2[0]);return split[0]+'BFF";xx&&xz?'+match[1]+'.clearRect(0,0,'+match[2]+','+match[3]+'):'+split[1];}
function addVirusColorHook(script){var match=script.match(/(\?\(\w\.fillStyle=")/);var split=script.split(match[0]);return split[0]+'||zz&&this.h'+match[1]+split[1]}
function addLeaderboardHook(script){var match=script.match(/(fillStyle="#FFAAAA")(.+)(\w+)(\+1\+"\. ")/);var split=script.split(match[0]);return split[0]+match[1]+',OnLeaderboard('+match[3]+'+1)'+match[2]+match[3]+match[4]+split[1]}
function addOnCellEatenHook(script){var match=script.match(/(\w+)&&(\w+)&&\((\w+)\.(\w+)/);var split=script.split(match[0]);return split[0]+ match[1]+'&&'+ match[2]+'&&(OnCellEaten('+match[1]+','+match[2]+'),'+ match[3]+'.'+ match[4]+ split[1];}
function addOnShowOverlayHook(script){var match=script.match(/\w+\("#overlays"\)\.fadeIn\((\w+)\?\w+:\w+\)/);var split=script.split(match[0]);return split[0]+ match[0]+',OnShowOverlay('+ match[1]+')'+ split[1];}
function addConnectHook(script){var match=script.match(/console\.log\("Connecting to "\+a\);/);var split=script.split(match[0]);return split[0]+('try{connect2("...")}catch(a){};')+ match[0]+'if(a.indexOf(window.server.ip)==-1){window.server = {ip:"",i:"",location:""};closeChat();}'+ split[1];}
function addRecieveHook(script){var match=script.match(/\w+\(new DataView\(..data\)\)/);var split=script.split(match[0]);return split[0]+ match[0]+';Recieve(a.data.byteLength);'+ split[1];}
function addOnSendHook(script){var match=script.match(/\w+\.send\(\w+\.buffer\)/);var split=script.split(match[0]);return split[0]+ match[0]+';OnSend(a.byteLength);'+ split[1];}
function addOnHideOverlayHook(script){var match=script.match(/\w+\("#overlays"\)\.hide\(\)/);var split=script.split(match[0]);return split[0]+ match[0]+';OnHideOverlay()'+ split[1];}
function addOnDrawHook(script){var match=script.match(/\w+\.width&&(\w+)\.drawImage\(\w+,\w+-\w+\.width-10,10\);/);var split=script.split(match[0]);return split[0]+ match[0]+'OnDraw('+ match[1]+');'+ split[1];}
var __STORAGE_PREFIX="mikeyk730__";function LS_getValue(aKey,aDefault){var val=localStorage.getItem(__STORAGE_PREFIX+ aKey);if(null===val&&'undefined'!=typeof aDefault)return aDefault;return val;}
function LS_setValue(aKey,aVal){localStorage.setItem(__STORAGE_PREFIX+ aKey,aVal);}
function GetRgba(hex_color,opacity)
{var patt=/^#([\da-fA-F]{2})([\da-fA-F]{2})([\da-fA-F]{2})$/;var matches=patt.exec(hex_color);return"rgba("+parseInt(matches[1],16)+","+parseInt(matches[2],16)+","+parseInt(matches[3],16)+","+opacity+")";}
function secondsToHms(d)
{d=Number(d);var h=Math.floor(d/3600);var m=Math.floor(d%3600/60);var s=Math.floor(d%3600%60);return((h>0?h+":"+(m<10?"0":""):"")+ m+":"+(s<10?"0":"")+ s);}
function tst(a){a?$("#chart-container-agariomods").css({"bottom":"5px","right":"5px","top":"","left":""}):$("#chart-container-agariomods").css({"bottom":"","right":"","top":"3px","left":"5px"});a?$("div#benchmarker").css({"bottom":"25px"}):$("div#benchmarker").css({"bottom":"10px"});}
jQuery(document).ready(function()
{jQuery('body').append('<div id="chart-container" class="ui" style="display:none; position:absolute; height:176px; width:300px; left:10px; bottom:44px"></div>\
<div id="chart-container-agariomods" class="ui" style="position:absolute; font-size:15px; right:5px; bottom:5px; /* -webkit-filter: invert(100%); filter: invert(100%); */"></div>\
<div id="debug" class="ui" style="position:absolute; top:5px; left:10px;">\
<div id="time-agariomods" style="color: white; display: none; background-color: rgba(0,0,0,.5); padding:0 4px;"><b>Page Time: </b><span>0</span></div>\
<div id="fps-agariomods" style="color: white; display: none; background-color: rgba(0,0,0,.5); padding:0 4px;"><b>Frame Rate: </b><span>0</span>/s</div>\
<div id="pi" class="pio-agariomods" style="color: white; display: none; background-color: rgba(0,0,0,.5); padding:0 4px;"><b>Packets In: </b><span>0</span>/s</div>\
<div id="po" class="pio-agariomods" style="color: white; display: none; background-color: rgba(0,0,0,.5); padding:0 4px;"><b>Packets Out: </b><span>0</span>/s</div>\
<div id="bi" class="bio-agariomods" style="color: white; display: none; background-color: rgba(0,0,0,.5); padding:0 4px;"><b>Download: </b><span>0</span> Bps</div>\
<div id="bo" class="bio-agariomods" style="color: white; display: none; background-color: rgba(0,0,0,.5); padding:0 4px;"><b>Upload: </b><span>0</span> Bps</div>\
</div>\
');jQuery('#instructions').remove();jQuery('.glyphicon-cog').addClass("glyphicon-refresh")
jQuery('.glyphicon-cog').removeClass("glyphicon-cog");jQuery('.btn-settings').attr('onclick','setR()');jQuery('.btn-login').attr('type','button');jQuery('.btn-settings').attr('type','button');jQuery('.btn-settings').css({'width':'15%','height':'35px'});jQuery('.btn-settings').removeClass("btn-settings");jQuery('#settings').show();var checkbox_div=jQuery('#settings input[type=checkbox]').closest('div');checkbox_div.append('<label><input type="checkbox" id="acid" onchange="setAcid($(this).is(\':checked\'));if($(this).is(\':checked\')){$(\'#bgimg\').attr(\'checked\',false);check(document.getElementById(\'bgimg\'));}">Acid</label>');checkbox_div.append('<label><input type="checkbox" onchange="if(this.checked){jQuery(\'#chart-container\').show()}else{jQuery(\'#chart-container\').hide()}">Show chart</label>');checkbox_div.append('<label><input type="checkbox" onchange="setVColors($(this).is(\':checked\'));">Colorless Viruses</label>');checkbox_div.append('<label><input id="custom" type="checkbox" onchange="setCustom($(this).is(\':checked\'));">No Custom Skins</label>');checkbox_div.append('<label><input type="checkbox" onchange="setTeamMass($(this).is(\':checked\'));">Show Teamed Mass</label>');checkbox_div.append('<label><input id="tskins" type="checkbox" onchange="setTskins($(this).is(\':checked\'));">Team Skins</label>');checkbox_div.append('<label><input id="bgimg" type="checkbox" onchange="setBG($(this).is(\':checked\'));">Set Background</label>');checkbox_div.append('<label><input type="checkbox" onchange="setMVR($(this).is(\':checked\'));">Maximize View</label>');checkbox_div.append('<label><input id="setChat" type="checkbox" onchange="$(document).trigger(jQuery.Event(\'keydown\',{ keyCode:\'67\',which:\'67\'}));">Ogar Chat Enabled</label>');checkbox_div.append('<div id="sliders" style="white-space:nowrap;display:inline;"><label>SFX<input id="sfx" type="range" value="0" step=".1" min="0" max="1"></label><label>BGM<input type="range" id="bgm" value="0" step=".1" min="0" max="1" oninput="volBGM(this.value);"></label></div>');jQuery('#overlays').append('<div id="stats" style="position: absolute; top:330px; left: 698px; width: 480px; display: none; background-color: #FFFFFF; border-radius: 15px; padding: 5px 15px 5px 15px; transform: translate(0,-50%); white-space: nowrap; overflow:hidden;"><div id="statArea" style="vertical-align:top; width:250px; display:inline-block;"></div><div id="pieArea" style="vertical-align: top; width:200px; height:150px; display:inline-block; vertical-align:top"> </div><div id="gainArea" style="width:500px; vertical-align:top"></div><div id="lossArea" style="width:500px; "></div><div id="chartArea" style="width:450px; display:inline-block; vertical-align:top"></div></div>');jQuery('#stats').hide(0);document.getElementById("options").style.fontSize="14px";});function ResetChart()
{chart=null;chart_data.length=0;chart_counter=0;jQuery('#chart-container').empty();}
function UpdateChartData(mass)
{chart_counter++;if(chart_counter%chart_update_interval>0)
return false;chart_data.push({x:chart_counter,y:mass/100});return true;}
function CreateChart(e,color,interactive)
{return new CanvasJS.Chart(e,{interactivityEnabled:interactive,title:null,axisX:{valueFormatString:" ",lineThickness:0,tickLength:0},axisY:{lineThickness:0,tickLength:0,gridThickness:2,gridColor:"white",labelFontColor:"white"},backgroundColor:"rgba(0,0,0,0.2)",data:[{type:"area",color:color,dataPoints:chart_data}]});}
function UpdateChart(mass,color)
{var diff=window.innerHeight-document.getElementById("canvas").height;if(diff!=0){jQuery("div:not(#chartArea)>.canvasjs-chart-container>.canvasjs-chart-canvas").css("bottom",-176+diff)};my_color=color;if(chart===null)
chart=CreateChart("chart-container",color,false);if(UpdateChartData(mass)&&document.getElementsByClassName(""))
chart.render();jQuery('.canvasjs-chart-credit').hide();};function ResetStats()
{stats={pellets:{num:0,mass:0},w:{num:0,mass:0},cells:{num:0,mass:0},viruses:{num:0,mass:0},birthday:Date.now(),time_of_death:null,high_score:0,top_slot:Number.POSITIVE_INFINITY,gains:{},losses:{},};}
function OnGainMass(me,other)
{var mass=other.size*other.size;if(other.h){stats.viruses.num++;if(document.getElementById("gamemode").value!=":teams")stats.viruses.mass+=mass;sfx_event(6);}
else if(Math.floor(mass)<=400&&!other.name){stats.pellets.num++;stats.pellets.mass+=mass;play_pellet();}
else if(!other.name&&mass<=1444&&(mass>=1369||(other.x==other.ox&&other.y==other.oy))){if(other.color!=me.color){stats.w.num++;stats.w.mass+=mass;}
sfx_event(1);}
else{var key=other.name+':'+ other.color;stats.cells.num++;stats.cells.mass+=mass;if(stats.gains[key]==undefined)
stats.gains[key]={num:0,mass:0};stats.gains[key].num++;stats.gains[key].mass+=mass;sfx_event(1);}}
function OnLoseMass(me,other)
{var mass=me.size*me.size;var key=other.name+':'+ other.color;if(stats.losses[key]==undefined)
stats.losses[key]={num:0,mass:0};;stats.losses[key].num++;stats.losses[key].mass+=mass;sfx_event(1);}
function DrawPie(pellet,w,cells,viruses)
{var total=pellet+ w+ cells+ viruses;pie=new CanvasJS.Chart("pieArea",{title:null,animationEnabled:false,legend:{verticalAlign:"center",horizontalAlign:"left",fontSize:12,fontFamily:"Helvetica"},theme:"theme2",data:[{type:"pie",startAngle:-20,showInLegend:true,toolTipContent:"{legendText} {y}%",dataPoints:[{y:100*pellet/total,legendText:"pellets"},{y:100*cells/total,legendText:"cells"},{y:100*w/total,legendText:"w"},{y:100*viruses/total,legendText:"viruses"},]}]});pie.render();}
function GetTopN(n,p)
{var r=[];var a=Object.keys(stats[p]).sort(function(a,b){return-(stats[p][a].mass- stats[p][b].mass)});for(var i=0;i<n&&i<a.length;++i){var key=a[i];var mass=stats[p][key].mass;var name=key.slice(0,key.length-8);if(!name)name="An unnamed cell";var color=key.slice(key.length-7);r.push({name:name,color:color,mass:Math.floor(mass/100)});}
return r;}
function AppendTopN(n,p,list)
{var a=GetTopN(n,p);for(var i=0;i<a.length;++i){var text='<bdi>'+a[i].name+'</bdi> ('+(p=='gains'?'+':'-')+ a[i].mass+' mass)';list.append('<li style="font-size: 12px; "><div style="width: 10px; height: 10px; border-radius: 50%; margin-right:5px; background-color: '+ a[i].color+'; display: inline-block;"></div>'+ text+'</li>');}
return a.length>0;}
function DrawStats(game_over)
{if(!game_over!=in_game)return;jQuery('#statArea').empty();jQuery('#pieArea').empty();jQuery('#gainArea').empty();jQuery('#lossArea').empty();jQuery('#chartArea').empty();jQuery('#stats').show();if(game_over){sfx_play(1);StopBGM();}
stats.time_of_death=Date.now();var time=stats.time_of_death?stats.time_of_death:Date.now();var seconds=(time- stats.birthday)/1000;var list=jQuery('<ul>');list.append('<li style="font-size: 12px; ">Game time: '+ secondsToHms(seconds)+'</li>');list.append('<li style="font-size: 12px; ">High score: '+~~(stats.high_score/100)+'</li>');if(stats.top_slot==Number.POSITIVE_INFINITY){list.append('<li style="font-size: 12px; ">You didn\'t make the leaderboard.'+'</li>');}
else{list.append('<li style="font-size: 12px; ">Leaderboard max: '+ stats.top_slot+'</li>');}
list.append('<li style="font-size: 12px; padding-top: 15px">'+ stats.pellets.num+" pellets eaten ("+~~(stats.pellets.mass/100)+' mass)</li>');list.append('<li style="font-size: 12px; ">'+ stats.cells.num+" cells eaten ("+~~(stats.cells.mass/100)+' mass)</li>');list.append('<li style="font-size: 12px; ">'+ stats.w.num+" masses eaten ("+~~(stats.w.mass/100)+' mass)</li>');list.append('<li style="font-size: 12px; ">'+ stats.viruses.num+" viruses eaten ("+~~(stats.viruses.mass/100)+' mass)</li>');var totalMass=(~~(stats.pellets.mass/100)+~~(stats.cells.mass/100)+~~(stats.w.mass/100)+~~(stats.viruses.mass/100));list.append('<li style="font-size: 12px; ">Total mass eaten: '+ totalMass+'</li>');jQuery('#statArea').append('<b>Game Summary</b>');jQuery('#statArea').append(list);DrawPie(stats.pellets.mass,stats.w.mass,stats.cells.mass,stats.viruses.mass);jQuery('#gainArea').append('<b>Top Gains</b>');list=jQuery('<ol>');if(AppendTopN(5,'gains',list))
jQuery('#gainArea').append(list);else
jQuery('#gainArea').append('<ul><li style="font-size: 12px; ">You have not eaten anybody</li></ul>');jQuery('#lossArea').append('<b>Top Losses</b>');list=jQuery('<ol>');if(AppendTopN(5,'losses',list))
jQuery('#lossArea').append(list);else
jQuery('#lossArea').append('<ul><li style="font-size: 12px; ">Nobody has eaten you</li></ul>');if(stats.time_of_death!==null){jQuery('#chartArea').width(450).height(150);stat_chart=CreateChart('chartArea',my_color,true);stat_chart.render();}
else{jQuery('#chartArea').width(450).height(0);}
jQuery('.canvasjs-chart-credit').hide();}
var styles={heading:{font:"20px Ubuntu",spacing:41,alpha:1},subheading:{font:"18px Ubuntu",spacing:31,alpha:1},normal:{font:"12px Ubuntu",spacing:21,alpha:0.6}}
function AppendText(text,context,style)
{context.globalAlpha=styles[style].alpha;context.font=styles[style].font;g_stat_spacing+=styles[style].spacing;var width=context.measureText(text).width;g_layout_width=Math.max(g_layout_width,width);context.fillText(text,g_layout_width/2- width/2,g_stat_spacing);}
function RenderStats(reset)
{if(reset)g_layout_width=g_display_width;if(!display_stats||!stats)return;g_stat_spacing=0;var gains=GetTopN(3,'gains');var losses=GetTopN(3,'losses');var height=30+ styles['heading'].spacing+ styles['subheading'].spacing*2+ styles['normal'].spacing*(4+ gains.length+ losses.length);stat_canvas=document.createElement("canvas");var scale=Math.min(g_display_width,.3*window.innerWidth)/ g_layout_width;stat_canvas.width=g_layout_width*scale;stat_canvas.height=height*scale;var context=stat_canvas.getContext("2d");context.scale(scale,scale);context.globalAlpha=.4;context.fillStyle="#000000";context.fillRect(0,0,g_layout_width,height);context.fillStyle="#FFFFFF";AppendText("Stats",context,'heading');var text=stats.pellets.num+" pellets eaten ("+~~(stats.pellets.mass/100)+")";AppendText(text,context,'normal');text=stats.w.num+" mass eaten ("+~~(stats.w.mass/100)+")";AppendText(text,context,'normal');text=stats.cells.num+" cells eaten ("+~~(stats.cells.mass/100)+")";AppendText(text,context,'normal');text=stats.viruses.num+" viruses eaten ("+~~(stats.viruses.mass/100)+")";AppendText(text,context,'normal');AppendText("Top Gains",context,'subheading');for(var j=0;j<gains.length;++j){text=(j+1)+". "+ gains[j].name+" ("+ gains[j].mass+")";context.fillStyle=gains[j].color;AppendText(text,context,'normal');}
context.fillStyle="#FFFFFF";AppendText("Top Losses",context,'subheading');for(var j=0;j<losses.length;++j){text=(j+1)+". "+ losses[j].name+" ("+ losses[j].mass+")";context.fillStyle=losses[j].color;AppendText(text,context,'normal');}}
jQuery(window).resize(function(){RenderStats(false);});window.OnGameStart=function(cells)
{initbench(false);in_game=true;my_cells=cells;ResetChart();ResetStats();RenderStats(true);DrawStats(false);if(kd==true){showsh=false;document.getElementById("overlays").style.display="none";document.getElementById("overlays").style.backgroundColor="rgba(0,0,0,.498039)";document.getElementById("overlays").style.pointerEvents="auto";document.getElementById("stats").style.opacity=0.85;document.getElementsByClassName("agario-panel")[0].style.display="block";kd=false;}
StartBGM();sfx_play(0);if(localStorage.getItem("played")===null){localStorage.setItem("played",0);}}
window.StartBGM=function()
{if(document.getElementById("bgm").value==0)return;if(bgmusic.src=="")bgmusic.src="//skins.agariomods.com/botb/"+ tracks[Math.floor(Math.random()*tracks.length)];bgmusic.volume=document.getElementById("bgm").value;bgmusic.play();}
window.StopBGM=function()
{if(document.getElementById("bgm").value==0)return;bgmusic.pause()
bgmusic.src="//skins.agariomods.com/botb/"+ tracks[Math.floor(Math.random()*tracks.length)];bgmusic.load()}
window.volBGM=function(vol)
{bgmusic.volume=document.getElementById("bgm").value;}
window.onwsclose=function(){in_game&&OnShowOverlay(false);}
window.OnShowOverlay=function(game_in_progress)
{tst(true);document.getElementById("benchmarker").style.bottom="25px";if(!game_in_progress)in_game=false;DrawStats(!game_in_progress);if(kd==true){document.getElementById("overlays").style.display="block";document.getElementById("overlays").style.backgroundColor="rgba(0,0,0,.498039)";document.getElementById("overlays").style.pointerEvents="auto";document.getElementById("stats").style.opacity=1;document.getElementsByClassName("agario-panel")[0].style.display="block";kd=false;}
if(in_game){showsh=true;canvas.onmousedown(0,0);}
else
{showsh=false;}}
var fired=false;window.OnHideOverlay=function()
{if(fired==true){fired=false;return;}else{fired=true;}
if(showsh==true)showsh=false;tst(showfps+showpio+showbio+ptime>0);}
window.OnUpdateMass=function(mass)
{stats.high_score=Math.max(stats.high_score,mass);UpdateChart(mass,GetRgba(my_cells[0].color,0.4));benchcheck(mass);}
window.OnCellEaten=function(predator,prey)
{if(!my_cells)return;if(my_cells.indexOf(predator)!=-1){OnGainMass(predator,prey);RenderStats(false);}
if(my_cells.indexOf(prey)!=-1){OnLoseMass(prey,predator);RenderStats(false);}}
window.OnLeaderboard=function(position)
{stats.top_slot=Math.min(stats.top_slot,position);}
window.OnDraw=function(context)
{if(showfps)document.getElementById("fps-agariomods").children[1].innerHTML=rate('FPS');display_stats&&stat_canvas&&context.drawImage(stat_canvas,10,10);}
window.Recieve=function(a)
{if(showbio)document.getElementById("bi").children[1].innerHTML=Math.floor(multirate('BI',a));if(showpio)document.getElementById("pi").children[1].innerHTML=rate('PI');}
window.OnSend=function(a)
{if(showbio)document.getElementById("bo").children[1].innerHTML=Math.floor(multirate('BO',a))
if(showpio)document.getElementById("po").children[1].innerHTML=rate('PO');}
function time(a)
{document.getElementById("time-agariomods").children[1].innerHTML=mToMs(a-pload);}
function rate(z){if(!rate[z]){rate[z]={};rate[z].lastLoop=(new Date()).getMilliseconds();rate[z].count=1;rate[z].packet=0;}
var currentLoop=(new Date()).getMilliseconds();if(rate[z].lastLoop>currentLoop){rate[z].packet=rate[z].count;rate[z].count=1;}else{rate[z].count+=1;}
rate[z].lastLoop=currentLoop;return rate[z].packet;};function multirate(z,v){if(!multirate[z]){multirate[z]={};multirate[z].lastLoop=(new Date()).getMilliseconds();multirate[z].count=v;multirate[z].packet=0;}
var currentLoop=(new Date()).getMilliseconds();if(multirate[z].lastLoop>currentLoop){multirate[z].packet=multirate[z].count;multirate[z].count=0;}else{multirate[z].count+=v;}
multirate[z].lastLoop=currentLoop;return multirate[z].packet;};window.onpageshow=function(){pload=Date.now();initbench(true);document.getElementById("bgimg").checked=false;$("div#options label").change(function(){$("div#options input:checkbox").each(function(){if(this.id=="bgimg")return;localStorage.setItem("setting"+$(this).parent().text().replace(" ","_"),this.checked);});$("div#options input[type=range]").each(function(){localStorage.setItem("setting"+$(this).parent().text().replace(" ","_"),this.value);});});$("div#options input").each(function(){if(this.id=="setChat")return;check(this);});document.getElementById("helloContainer").style.display='';}
window.check=function(elem){var evt=document.createEvent("HTMLEvents");evt.initEvent("change",false,true);elem.dispatchEvent(evt);}
$(document).ready(function(){$("div#options input:checkbox").each(function(){if(this.id=="bgimg")return;if(this.id=="setChat")document.getElementById("setChat").checked=chatEnabled;$(this).attr("checked",(localStorage.getItem("setting"+$(this).parent().text().replace(" ","_")))=="true");});$("div#options input[type=range]").each(function(){$(this).attr("value",(localStorage.getItem("setting"+$(this).parent().text().replace(" ","_"))));});});var kd=false;$(document).keydown(function(e){if(e.keyCode==90&&!jQuery('#chatinput').is(':visible')){if(kd==false&&document.getElementById("overlays").style.display=='none'){kd=true;document.getElementById("overlays").style.display="block";document.getElementById("overlays").style.backgroundColor="rgba(0,0,0,0)";document.getElementById("overlays").style.pointerEvents="none";document.getElementById("stats").style.opacity=1;document.getElementsByClassName("agario-panel")[0].style.display="none";showsh=true;DrawStats(false);}}
if(e.keyCode==84&&!e.altKey&&document.activeElement.type!="text"){showt=!showt;localStorage.setItem("showt",showt);document.getElementById("benchmarker").style.display=showt?"block":"none";}
if(e.keyCode==84&&e.altKey){deleteScores();}
if(e.keyCode==67&&!e.altKey&&document.activeElement.type!="text"){chatEnabled=!chatEnabled;document.getElementById("setChat").checked=chatEnabled;localStorage.setItem("chatEnabled",chatEnabled);if(server.ip.substr(-11)==".iomods.com")chatEnabled?openChat():closeChat();}
if(e.keyCode==67&&e.altKey){var a=localStorage.getItem("ip");var b=prompt("Ogar Connect - Connect to a Private Ogar Server\nEnter IP or URL",(a==null?"":a));if(b==null){return;}else if(b==""){alert("No IP/URL inputed")};b=b.split("ws://").join("");if(b.indexOf("/")==-1&&b.search(/:\d/)!==-1&&b.search(/[a-zA-Z0-9]\.[a-zA-Z0-9]/)!==-1&&encodeURI(b)==b){b="ws://"+b}else{alert("Invalid IP/URL");return;};try{connect(b,"")}catch(e){alert("Illegal IP/URL");return;};localStorage.setItem("ip",b);}
if(e.altKey&&e.keyCode==49){ptime=!ptime;document.getElementById("time-agariomods").style.display=ptime?"block":"none";ptime?time(Date.now()):document.getElementById("time-agariomods").children[1].innerHTML="";tst(showfps+showpio+showbio+ptime>0);}
if(e.altKey&&e.keyCode==50){showfps=!showfps;document.getElementById("fps-agariomods").style.display=showfps?"block":"none";tst(showfps+showpio+showbio+ptime>0);}
if(e.altKey&&e.keyCode==51){showpio=!showpio;$(".pio-agariomods").css("display",showpio?"block":"none");tst(showfps+showpio+showbio+ptime>0);}
if(e.altKey&&e.keyCode==52){showbio=!showbio;$(".bio-agariomods").css("display",showbio?"block":"none");tst(showfps+showpio+showbio+ptime>0);}
if(e.altKey&&e.keyCode==81&&in_game){return;jQuery("#overlays").show()
OnShowOverlay(false);Suicide();}
if(e.ctrlKey&&e.keyCode===70&&navigator.userAgent.match("Firefox")){e.preventDefault();if(document.mozFullScreenElement)
{document.mozCancelFullScreen();}
else
{document.getElementById("overlays").mozRequestFullScreen();}}
if(e.keyCode===46&&navigator.userAgent.match("Firefox")&&document.mozFullScreenElement&&document.activeElement.type!="text"){$(document).trigger(jQuery.Event('keydown',{keyCode:'27',which:'27'}));}
if(e.keyCode==82&&e.altKey){if(ldown)return;ldown=true
console.log("pausing");var currentTime=new Date().getTime();while(currentTime+ 500>=new Date().getTime()){}}});$(document).keyup(function(e){if(e.keyCode==90){if(kd==true){kd=false;document.getElementById("overlays").style.display="none";document.getElementById("overlays").style.backgroundColor="rgba(0,0,0,.498039)";document.getElementById("overlays").style.pointerEvents="auto";document.getElementById("stats").style.opacity=0.85;document.getElementsByClassName("agario-panel")[0].style.display="block";showsh=false;}}
if(e.keyCode==82&&e.altKey){if(ldown)ldown=false;}});var m,benchmarker;var benchmarks=["250mass","500mass","1000mass","2500mass","5000mass"];var mass_benchmarks=[250,500,1000,2500,5000];var massPrev=0;$("body").append('<div id="benchmarker"></div>');function initbench(first){$("div#benchmarker").css({"right":"7px","bottom":"25px","backgroundColor":"rgba(0,0,0,0.4)","opacity":"1.0","color":"white","fontFamily":"Ubuntu,Arial,sans-serif","position":"fixed","padding":"10px","text-align":"center","pointer-events":"none","z-index":"1000"});if(first){showt?$("div#benchmarker").css({"display":"block"}):$("div#benchmarker").css({"display":"none"});}else{tst(showfps+showpio+showbio+ptime>0);}
var newHTML='<table>'+'<h3>Benchmarker</h3>'+'<span>Time Elapsed: --:--</span>'+'<tr><th>Benchmark</th><th>Time</th><th>Best</th></tr>'+'<tr id="250mass"><td>250 Mass</td><td class="time">-----</td><td class="best">-----</td></tr>'+'<tr id="500mass"><td>500 Mass</td><td class="time">-----</td><td class="best">-----</td></tr>'+'<tr id="1000mass"><td>1000 Mass</td><td class="time">-----</td><td class="best">-----</td></tr>'+'<tr id="2500mass"><td>2500 Mass</td><td class="time">-----</td><td class="best">-----</td></tr>'+'<tr id="5000mass"><td>5000 Mass</td><td class="time">-----</td><td class="best">-----</td></tr>'+'</table>';$("div#benchmarker").html(newHTML);for(var i=0;i<benchmarks.length;i++){if(localStorage.getItem("best_"+ benchmarks[i])){$("#"+ benchmarks[i]+" .best").html(mToMs(localStorage.getItem("best_"+ benchmarks[i])));}}
$("table").css({"margin":"8px","padding":"8px"});$("div#benchmarker h3").css("text-align","center");$("div#benchmarker span").css({"text-align":"center","display":"inline-block"});$("td,th").css({"padding":"5px","text-align":"left"});$("div#benchmarker h3").css({"margin-top":"4px"});}
function count(){$("div#benchmarker span").html("Time Elapsed: "+ mToMs(Date.now()- stats.birthday));}
function mToMs(millis){var minutes=Math.floor(millis/60000);var seconds=((millis%60000)/ 1000).toFixed(0);return minutes+":"+(seconds<10?'0':'')+ seconds;}
function snp(y){return y.replace(/[^0-9]+/g,'');}
function logBenchmark(benchmark,time){if($("#"+ benchmark+" .time").html()=="-----"){console.log("Benchmark set: "+ benchmark+" at "+ mToMs(time));$("#"+ benchmark+" .time").html(mToMs(time));if(localStorage.getItem('best_'+ benchmark)==null||(time<localStorage.getItem('best_'+ benchmark))){console.log("Best time set: "+ benchmark+" at "+ mToMs(time));$("#"+ benchmark+" .best").html(mToMs(time));localStorage.setItem("best_"+ benchmark,time);}}}
function deleteScores(){var prompt=confirm("Are you sure you want to delete your best times?");if(prompt==true){for(var i=0;i<benchmarks.length;i++){localStorage.removeItem("best_"+ benchmarks[i]);$("#"+ benchmarks[i]+" .best").html("-----");}}}
function benchcheck(mass){mass=Math.floor(mass/100);for(var i=0;i<mass_benchmarks.length;i++){if((massPrev<mass_benchmarks[i])&&(mass>=mass_benchmarks[i])){logBenchmark(mass_benchmarks[i]+"mass",Date.now()- stats.birthday);}}}
var st=document.createElement("style");st.innerHTML=".serveritem {display:block;border-bottom:1px solid #ccc;padding:4px;}.serveritem:hover{text-decoration:none;background-color:#E9FCFF;}.overlay{line-height:1.2;margin:0;font-family:sans-serif;text-align:center;position:absolute;top:0;left:0;width:100%;height:100%;z-index:1000;background-color:rgba(0,0,0,0.2)}.popupbox{position:absolute;height:100%;width:60%;left:20%;background-color:rgba(255,255,255,0.95);box-shadow:0 0 20px #000}.popheader{position:absolute;top:0;width:100%;height:50px;background-color:rgba(200,200,200,0.5)}.browserfilter{position:absolute;padding:5px;top:50px;width:100%;height:60px;background-color:rgba(200,200,200,0.5)}.scrollable{position:absolute;border-top:#eee 1px solid;border-bottom:#eee 1px solid;width:100%;top:50px;bottom:50px;overflow:auto}.popupbuttons{background-color:rgba(200,200,200,0.4);height:50px;position:absolute;bottom:0;width:100%}.popupbox td,th{padding:5px}.popupbox tbody tr{border-top:#ccc solid 1px}#tooltip{display:inline;position:relative}#tooltip:hover:after{background:#333;background:rgba(0,0,0,.8);border-radius:5px;bottom:26px;color:#fff;content:attr(title);left:20%;padding:5px 15px;position:absolute;z-index:98;width:220px}#chat{z-index:2000;width:500px;position:absolute;right:15px;bottom:25px}#chatinput{bottom:0;position:absolute;opacity:.8}#chatlines a{color:#086A87}#chatlines{pointer-events:none;position:absolute;bottom:40px;width:500px;color:#333;word-wrap:break-word;box-shadow:0 0 10px #111;background-color:rgba(0,0,0,0.1);border-radius:5px;padding:5px;height:200px;overflow:auto}.listing>span{display:block;font-size:11px;font-weight:400;color:#999}.list{padding:0 0;list-style:none;display:block;font:12px/20px 'Lucida Grande',Verdana,sans-serif}.listing{border-bottom:1px solid #e8e8e8;display:block;padding:10px 12px;font-weight:700;color:#555;text-decoration:none;cursor:pointer;line-height:18px}li:last-child > .listing{border-radius:0 0 3px 3px}.listing:hover{background:#e5e5e5}";document.head.appendChild(st);var fontawesome=document.createElement("link");fontawesome.setAttribute("rel","stylesheet");fontawesome.setAttribute("type","text/css");fontawesome.setAttribute("href","http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css");document.head.appendChild(fontawesome);var socketscript=document.createElement('script');socketscript.setAttribute("type","text/javascript");socketscript.setAttribute("src","https://cdn.socket.io/socket.io-1.3.5.js");(document.body||document.head||document.documentElement).appendChild(socketscript);var socket;jQuery(document).keydown(function(e){if(e.keyCode==13||e.keyCode==191){if(jQuery('#chatinput').is(':visible')&&e.keyCode!=191){sendMSG();}
else if(document.activeElement.type!="text"){e.preventDefault();tChat();jQuery('#chatinputfield').focus();}}});window.connectPrivate=function(location,i){var ip=location.toLowerCase().split(" ").join("")+'.iomods.com';var port=(1500+parseInt(i));server.ip=ip;server.i=i;server.location=location;connect("ws://"+ ip+":"+ port,"");openChat();}
function openChat(){apikey=getCookie("apikey");if(chatEnabled){var i=server.i;var ip=server.ip;var location=server.location;socket=io.connect("http://"+ip+":"+(12040+parseInt(i)),{forceNew:true,reconnection:false});socket.on('disconnect',function(){});socket.on('connect',function(){socket.emit("auth",{key:apikey});});socket.on('init',function(){jQuery('#chat').fadeIn();jQuery('#chatlines').empty();addServer("<b>You are now connected to: "+ location+' #'+ i+"</b>");});socket.on('chat',function(data){addLine(data);});socket.on('info',function(data){addServer(data.msg);});}}
function getCookie(cname){var name=cname+"=";var ca=document.cookie.split(';');for(var i=0;i<ca.length;i++){var c=ca[i];while(c.charAt(0)==' ')c=c.substring(1);if(c.indexOf(name)==0)return c.substring(name.length,c.length);}
return"";}
window.closeChat=function(){jQuery('#chat').fadeOut();socket&&socket.disconnect();}
function addServer(msg){jQuery('#chatlines').append(' *** '+ msg+'<br>');jQuery("#chatlines").animate({scrollTop:$("#chatlines")[0].scrollHeight});}
function addLine(data){if(data.name=="")
data.name="Unnamed";var escapedname=$("<div>").text(data.name).html();var escapedmsg=$("<div>").text(data.text).html();jQuery('#chatlines').append('<b><a href="#">'+ escapedname+'</a>:</b> <span>'+escapedmsg+'</span><br>');jQuery("#chatlines").animate({scrollTop:$("#chatlines")[0].scrollHeight});}
window.sendMSG=function(){if($('#chatinputfield').val().trim()==""){tChat(!0);return}
var msg=jQuery('#chatinputfield').val();jQuery('#chatinputfield').val('');socket.emit('chat',{text:msg});tChat(!0);}
window.tChat=function(a){a?jQuery('#chatinput').fadeOut("fast"):jQuery('#chatinput').fadeIn("fast")};window.isVisible=function(){if(jQuery('#chatinput').is(':visible'))
return true;else
return false;}
window.onload=handleHash;function handleHash(){if(window.location.hash=='#'||window.location.hash=='')return;var api=window.location.hash.substr(1);history.replaceState('agar.io','Agar.io','/');if(getCookie("apikey")==api){alert("You already have this account linked with Agariomods.");return;}
if(api.search(/^{agariomods.com:\d+:[a-f0-9]{8}:[a-zA-Z0-9=]+:[a-zA-Z0-9=]+}$/)==0){var userid=api.split(":")[1];jQuery.ajax({url:"http://connect.agariomods.com/json/nodechatcheck.php?u="+api,dataType:'json',success:function(data){if(getCookie("apikey")!==""){if(!confirm("You already have an account account linked with Agariomods!\nLinking this account will unlink the currently linked account.\nDo you want to continue?"))return;}
if(data.error!='0'){alert("A Server Error Occured! Error Code: "+(data.error===null?"-1":data.error));}
else if(data.user_id==userid){document.cookie="apikey="+api;alert("Welcome "+data.username+", you can now chat in our private servers, press C to bring up chat, and press Enter to start typing.\nThe page will now reload.");extToggled=true;window.location=window.location;}
else{alert("Error: Incorrect API Key");}},error:function(){alert("Error: Failed to establish connection to connect.agariomods.com");}});}else{alert("Error: Invalid API Key")}}
window.openServerbrowser=function(a){var b=window.openServerbrowser.loading;if(b)return;b=true;jQuery("#rsb").prop("disabled",true);a||jQuery('#serverBrowser').fadeIn();getServers();}
window.closeServerbrowser=function(){jQuery('#serverBrowser').fadeOut();}
var locations=new Array("Amsterdam","Amsterdam Beta","Atlanta Beta","Frankfurt Alpha","Frankfurt","London","Quebec","Paris","Atlanta","Chicago","Dallas","Los Angeles","Miami","New Jersey","Seattle","Silicon Valley","Sydney","Tokyo");locations.sort();locations[0]=[locations[2],locations[2]=locations[1],locations[1]=locations[0]][0];locations[1]=[locations[3],locations[3]=locations[2],locations[2]=locations[1]][0];function getServers(){jQuery('#serverlist1').empty();jQuery('#serverlist2').empty();var latencylist=Array();jQuery.each(locations,function(index,value){for(var i=1;i<=2;i++){serverid=value.toLowerCase().split(" ").join("")+ i;$('#serverlist'+i).append('<a href class="serveritem" id="'+ serverid+'" onclick="connectPrivate(\''+value+'\', \''+i+'\');closeServerbrowser();return false;"><b style="color: #222">'+ value+' #'+ i+'</b><br>\
<i style="color: #999"><span id="player">fetching data...</span> <i style="color: #ccc" class="fa fa-users" /> | <span id="game"></span> | </i><span id="latency"><i class="fa fa-signal"></i> <span id="latencyres"></span></span></a>');latencylist.push(new Array(value.toLowerCase().split(" ").join(""),i));};});serverinfo(latencylist,0);}
function serverinfo(list,index){if(index>=list.length){window.openServerbrowser.loading=false;jQuery("#rsb").prop("disabled",false);return;}
value=list[index];started=Date.now();statsurl='http://'+ value[0]+'.iomods.com:'+(8080+ value[1]);jQuery.ajax({url:statsurl,dataType:'json',timeout:5000,success:function(data){$('#'+(value[0]+ value[1])+' #player').text(data.current_players+"/"+ data.max_players);$('#'+(value[0]+ value[1])+' #game').text(data.gamemode);latency=(Date.now()- started);if(latency<100){jQuery('#'+(value[0]+ value[1])+' #latency').css("color","#19A652");}
else if(latency<250){jQuery('#'+(value[0]+ value[1])+' #latency').css("color","#E1BD2C");}
else{jQuery('#'+(value[0]+ value[1])+' #latency').css("color","#F00");}
jQuery('#'+(value[0]+ value[1])+' #latencyres').text(latency+"ms");},error:function(data,err,ngut){jQuery('#'+(value[0]+ value[1])+' #player').parent().css("display","none");jQuery('#'+(value[0]+ value[1])+' #latency').css("color","#f00");var errc='';if(err=="error"){errc="Connection Failed"}else if(err=="timeout"){errc="Connection Timed Out"}else{"Error: "+err.charAt(0).toUpperCase()+err.substr(1)};jQuery('#'+(value[0]+ value[1])+' #latency').text(errc);},complete:function(data){document.getElementById("serverBrowser").style.display=="none"||serverinfo(list,index+1);}});}
jQuery(document).ready(function(){jQuery('body').append('<div id="serverBrowser" class="overlay" style="display:none"><div class="valign"><div class="popupbox"><div class="popheader"><h3>Agariomods Ogar Server Browser</h3></div>\
<div class="scrollable"><center style="border-right:1px solid #e8e8e8;float:left;width:50%;"><div id="serverlist1"></div></center><center style="float:right;width:50%;"><div id="serverlist2"></div></center></div><div class="popupbuttons"><button onclick="closeServerbrowser()" type="button" style="transform:translateX(72%);margin:4px"\
class="btn btn-danger">Back</button><button id="rsb" onclick="openServerbrowser(true)" class="btn btn-info" type="button" style="float:right;margin:4px;">Refresh <i class="glyphicon glyphicon-refresh"></i></button></div></div></div></div>');jQuery('#settings').prepend('<button type="button" id="opnBrowser" onclick="openServerbrowser();" style="position:relative;top:-8px;width:100%" class="btn btn-success">Agariomods Private Servers</button><br>');jQuery('body').append('<div id="chat" style="display:none"><div id="chatlines"></div><div id="chatinput" style="display:none" class="input-group">\
<input type="text" id="chatinputfield" class="form-control" maxlength="120" onblur="tChat(!0)"><span class="input-group-btn">\
<button onclick="sendMSG()" class="btn btn-default" type="button">Send</button></span></div></div>');});