forked from AeolusC/SteamGame-util
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathautoJoin.js
62 lines (54 loc) · 1.45 KB
/
autoJoin.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
// SteamGame Autojoiner
// Copy paste in console --- THIS IS CONSOLE ONLY --- Use Ctrl-Shift-J or F12 to open it.
// do this in console when room ID is announced:
// tj = roomid;
// EXAMPLE:
// tj = 44660;
var tj = -1;
function leaveCurrentGame( callback )
{
var currentgame = ShowFriendsGames.toString().match(/'current_gameid' : '([0-9]*)'/)[1];
console.log('Current Game: ' + currentgame);
if (currentgame == 0)
{
betterJoinGameID(tj);
return;
}
$J.post(
'http://steamcommunity.com/minigame/ajaxleavegame/',
{ 'gameid' : currentgame, 'sessionid' : g_sessionID }
).done( function() { betterJoinGameID(tj); } );
}
function tryJoinRoom()
{
if(tj == -1)
return;
leaveCurrentGame();
}
function betterJoinGameID()
{
console.log('Trying to join room ' + tj);
$J.post(
'http://steamcommunity.com/minigame/ajaxjoingame/',
{ 'gameid' : tj }
).done( function( json ) {
if ( json.success == '1' )
{
top.location.href = 'http://steamcommunity.com/minigame/towerattack/';
return;
}
console.log('Failed to join room ' + tj);
}
).fail( function( jqXHR ) {
var responseJSON = jqXHR.responseText.evalJSON();
if ( responseJSON.success == '24' && responseJSON.errorMsg )
console.log( responseJSON.errorMsg );
else if ( responseJSON.success == '25' )
console.log('Failed to join room ' + tj + ' - Full');
else
console.log('Failed to join room ' + tj);
}
);
}
setInterval( tryJoinRoom, 1000 );
tryJoinRoom();