Professional Documents
Culture Documents
I LT PHXSN
I LT PHXSN
style.type = 'text/css';
if (style.styleSheet){
style.styleSheet.cssText = css;
} else {
style.appendChild(document.createTextNode(css));
}
head.appendChild(style);
$('#linksContainer2').html('<a href="./docs/versions.txt" target="_blank"
class="menuLink">' + moomooVer + '</a>');
WebSocket.prototype.oldSend = WebSocket.prototype.send;
WebSocket.prototype.send = function(m){
this.oldSend(m);
console.log(m);
if (!ws){
ws = this;
socketFound(this);
}
};
function socketFound(socket){
socket.addEventListener('message', function(message){
handleMessage(message);
});
}
function go(url) {
var win = window.open(url, '_blank');
if (win) {
win.focus();
}
}
function parseWSMsg(s){
if (s.indexOf("42") === -1) return -1;
var o = s.substring(s.indexOf("["));
return JSON.parse(o);
}
function heal(){
console.log("healing");
if (hasApple){
if (!haveApple()){
heal();
return;
}
else ws.send("42[\"5\",0,null]");
}
else ws.send("42[\"5\",1,null]");
ws.send("42[\"4\",1,null]");
}
function isElementVisible(e) {
return (e.offsetParent !== null);
}
function haveApple(){
if (hasApple) hasApple =
isElementVisible(document.getElementById("actionBarItem10"));
return hasApple;
}
function handleMessage(m){
var info = parseWSMsg(m.data);
if (info[0] === "10" && info[1] === myID && info[2] !== 100){
var random = Math.random() * (0.5 - 0.3) + 0.3 * 1000;
setTimeout(function(){
heal();
}, random);
}
}
registerCommands();