NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript==
// @name csgorage.com bot
// @version 0.2
// @description new version ... should work on Firefox and solves the problem with inactive browser tab JS timing
// @author mik13ST (ЖНИК)
// @match http://csgorage.com/*
// @grant none
// ==/UserScript==
function arr_diff(a1, a2) {
var a=[], diff=[];
for(var i=0;i<a1.length;i++)
a[a1[i]]=true;
for(var e=0;e<a2.length;e++)
if(a[a2[e]]) delete a[a2[e]];
else a[a2[e]]=true;
for(var k in a)
diff.push(k);
return diff;
}
refreshtime=10;
backup_timer=setTimeout(function(){window.location.assign("http://csgorage.com/free-raffles?time=today");}, 1000*60*(refreshtime+2));
if (!$(".nickname").length==0) {
text1="everythin'z alright<br />reloadin' in:<br />";
text2="m & ";
text3="s";
if (window.location.pathname=="/free-raffles") {
slots_all=[];
slots_full=[];
slots_free=[];
[].forEach.call($(".btn.btn-warning.orange_gradient.shadow1:not('.deposit'):not('.nickname')"), function (item) {
if (!item.parentNode.innerHTML.includes("RIBBON")){
url=item.parentNode.href;
rid=Math.abs(parseInt(url.slice(url.length-5,url.length)));
$.ajax({url:item.parentNode.href, type: "GET", complete:function(r) {
page=r.responseText;
token=(r.responseText.slice(r.responseText.indexOf("hide tok")+20,r.responseText.indexOf("hide tok")+19+41));
console.log(url+" "+rid+" "+token);
slotscount=item.parentNode.childNodes[9].childNodes[1].innerHTML.slice(item.parentNode.childNodes[9].childNodes[1].innerHTML.indexOf("/")+2,item.parentNode.childNodes[9].childNodes[1].innerHTML.length);
for (var i = 0; i <= slotscount; i++) {
slots_all.push(i);
}
slot_begin = slotscount-240;
$.ajax({url:"/slots",type:"POST", data:{rid: rid, last:slot_begin, _token: token}, complete: function(r){
slots_full=r.responseText.match(/\d+.:/g);
slots_full.forEach(function (item, index) {slots_full[index]=((parseInt(item)));});
var slots_temp=[];
for (var o = slot_begin; o <= slot_begin+240; o++) {
slots_temp.push(o);
}
slots_free.push(arr_diff(slots_full,slots_temp));
slots_free=slots_free[0];
slot=parseInt(slots_free[Math.floor(Math.random() *slots_free.length)]);
var xmlhttp;
if (window.XMLHttpRequest) {xmlhttp=new XMLHttpRequest();}
xmlhttp.open("POST","/getslotfree?rid="+rid+"&slots%5B%5D="+slot+"&_token="+token,true);
xmlhttp.send();
location.reload();
}});
}});
} else {
reloadstart_timestamp=Date.now();
setTimeout(function(){location.reload();},1000*60*refreshtime);
}
});
if ($(".btn.btn-warning.orange_gradient.shadow1:not('.deposit'):not('.nickname')").length==0) {
refreshtime=1;
text1="kinda weird,<br />I see nothin'<br />reloadin' in: ";
text2="m & ";
text3="s";
reloadstart_timestamp=Date.now();
setTimeout(function(){window.location.reload();},1000*60*refreshtime);
}
} else {
if (window.location.pathname.includes("/raffle")) {
refreshtime=1;
text1="damn you!<br />what U think U R doin'?<br />put meh back or I'm gonna go there myself!<br />(in: ";
text2="m & ";
text3="s)";
reloadstart_timestamp=Date.now();
setTimeout(function(){window.location.assign("http://csgorage.com/free-raffles?time=today");},1000*60*refreshtime);
} else {
refreshtime=2;
text1="somethin'z wrong<br />redirect in: ";
text2="m & ";
text3="s";
reloadstart_timestamp=Date.now();
setTimeout(function(){window.location.assign("http://csgorage.com/free-raffles?time=today");},1000*60*refreshtime);
}
}
document.body.innerHTML+='<div id="info" style="opacity:.90;z-index: 10000;position: fixed;right: 20px;top: 20px;background-color: darkcyan;width: 200px;text-align: center;border-radius: 20px; padding:10px; display: flex;align-items: center;justify-content: center;">nothing interesting</div>';
infoupdater=setInterval(function() {$("#info")[0].innerHTML=text1+Math.floor((refreshtime)-(Date.now()-reloadstart_timestamp)/1000/60)+text2+(Math.floor((((refreshtime)-(Date.now()-reloadstart_timestamp)/1000/60)-Math.floor((refreshtime)-(Date.now()-reloadstart_timestamp)/1000/60))*60))+text3;},1000);
} else {
document.body.innerHTML+='<div id="info" style="opacity:.90;z-index: 10000;position: fixed;right: 20px;top: 20px;background-color: darkcyan;width: 200px;text-align: center;border-radius: 20px; padding:10px; display: flex;align-items: center;justify-content: center;">nothing interesting</div>';
$("#info")[0].innerHTML="you need to be logged in through Steam, man";
}