-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathfaster.js
62 lines (57 loc) · 2.04 KB
/
faster.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
/**
Author: ironmaniiith
Date Created: 22 July 2016
Website: https://github.com/ironmaniiith
Description: Faster script for winning the mi.com Pair 2 win (http://www.mi.com/in/events/2ndanniversary/playgame/)
Play here: http://mobile.mi.com/in/events/2ndanniversary/playgame/level/
*/
/** Cache some methods */
var slice = Array.prototype.slice,
splice = Array.prototype.splice,
sort = Array.prototype.sort;
var jsonpCallback = function(){};
/** The gameWinner object */
var gameWinner = {
endgame: function(stage, e){
console.log('Ending stage: ' + stage);
var data = e.data,
graph_id = data.graph_id,
graph = Array.prototype.sort.call(slice.call(data.graph)).join('');
t = (new Date()).getTime(),
URL = 'http://hd.global.mi.com/in/sec/endgame?from=mb&stage=' + stage + '&use_time=0&graph_id=' + graph_id + '&path=' + graph + '&_=' + t + '&jsonpcallback=jsonpCallback';
XIAOMI.app.getAjax({
url: URL,
type: 'GET',
dataType: 'jsonp',
success: function(e) {
gameWinner.startgame(++stage, e);
},
error: function(e) {
/** Doesn't matter, hahhahaa :P */
gameWinner.startgame(++stage, e);
}
})
},
startgame: function(stage, e) {
console.log('Starting stage: ' + stage);
if (stage > 50) {
return ;
}
var t = (new Date()).getTime(),
URL = 'http://hd.global.mi.com/in/sec/startgame?from=mb&stage=' + stage
+ '&_=' + t + '&jsonpcallback=jsonpCallback';
/** Have some gap between two consecutive games */
setTimeout(function(){
XIAOMI.app.getAjax({
url: URL,
type: 'GET',
dataType: 'jsonp',
success: function(e) {
gameWinner.endgame(stage, e);
}
});
}, 100);
}
}
/** Yeah B-) */
gameWinner.startgame(1, null);