-
Notifications
You must be signed in to change notification settings - Fork 53
/
ice.js
160 lines (134 loc) · 5.7 KB
/
ice.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
/* SETTINGS */
var l = ''; //google login or email
var p = ''; //google password
var area = 'https://www.ingress.com/intel?ll=53.22792,50.203829&z=16';
var v = 30000; //Delay between capturing screenshots, in milliseconds (1000 ms = 1 s)
var width = 900; //Picture width
var height = 500; //Picture height
/* SGNITTES */
var page = require('webpage').create();
var system = require('system');
var twostep = 0;
var fs = require('fs');
var max = 0;
var val, message;
fs.list('.').forEach(function (e) {
if(e.substring(0,3) == 'Ice') {
val = e.substring(3,Infinity).replace('.png', '');
val = +val;
if (val > max) {max=val};
};
});
var V = max + 1;
var Version = '1.1.0'
var version = Version + '\n';
page.viewportSize = {
width: width + 42,
height: height + 167
};
function s() {
console.log('Capturing screen #' + V + '...');
page.render('Ice' + V + '.png');
V++;
};
function quit(err) {
if (err) {
console.log('\nICE crashed. Reason: ' + err + ' :('); //nice XD
} else {
console.log('Quit');
};
phantom.exit();
};
if (!l | !p) {
quit('you haven\'t entered your login and/or password');
};
console.log('\n ___ _______ _______ \n| | | || |\n| | | || ___|\n| | | || |___ \n| | | _|| ___|\n| | | |_ | |___ \n|___| |_______||_______|\n\n Welcome to ICE v' + Version + ', automated screenshooter for Ingress Intel!\n\n Press Ctrl + C or Ctrl + D to exit\n\n Author: Nikitakun (Nikita Bogdanov), MIT License\n\n Project Homepage: https://github.com/nibogd/ingress-ice\n\n\nLog:\nConnecting...');
page.open('https://raw.githubusercontent.com/nibogd/ingress-ice/version-check/version', function(){
var serverversion = page.evaluate(function() {
return document.body.textContent;
});
if (serverversion !== version){console.log('New version of the script is available at https://github.com/nibogd/ingress-ice')};
});
window.setTimeout(function () {page.open('https://www.ingress.com/intel', function (status) {
if (status !== 'success') {quit('cannot connect to remote server')};
var inglink = page.evaluate(function () {
return document.getElementsByTagName('a')[0].href;
});
console.log('Got a login link. Logging in...');
page.open(inglink, function () {
page.evaluate(function (l) {
document.getElementById('Email').value = l;
}, l);
page.evaluate(function (p) {
document.getElementById('Passwd').value = p;
}, p);
page.evaluate(function () {
document.querySelector("input#signIn").click();
});
page.evaluate(function () {
document.getElementById('gaia_loginform').submit(); // Not using POST because the URI may change
});
window.setTimeout(function () {
console.log('URI is now ' + page.url.substring(0,40) + '... .\nVerifying login...');
if (page.url.substring(0,40) == 'https://accounts.google.com/ServiceLogin') {quit('login failed: wrong email and/or password')};
if (page.url.substring(0,40) == 'https://appengine.google.com/_ah/loginfo') {
console.log('Accepting appEngine request...');
page.evaluate(function () {
document.getElementById('persist_checkbox').checked = true;
document.getElementsByTagName('form').submit();
});
};
if (page.url.substring(0,40) == 'https://accounts.google.com/SecondFactor') {
console.log('Using two-step verification, please enter your code:');
twostep = system.stdin.readLine();
};
if (twostep) {
page.evaluate(function (code) {
document.getElementById('smsUserPin').value = code;
}, twostep);
page.evaluate(function () {
document.getElementById('gaia_secondfactorform').submit();
});
};
window.setTimeout(function () {
page.open(area, function () {
console.log('Authenticated successfully, starting screenshotting every ' + v + 'ms...');
setInterval(function () {
page.evaluate(function () {
document.querySelector('#filters_container').style.display = 'none';
document.querySelector('#comm').style.display = 'none';
document.querySelector('#player_stats').style.display = 'none';
document.querySelector('#game_stats').style.display = 'none';
document.querySelector('#geotools').style.display = 'none';
document.querySelector('#bottom_right_stack').style.display = 'none';
document.querySelector('#header').style.display = 'none';
document.querySelector('#footer').style.display = 'none';
document.querySelector('#snapcontrol').style.display = 'none';
//document.querySelector('div.gm-style-cc:nth-child(8)').style.display = 'none';
});
page.evaluate(function () {
var hide = document.querySelectorAll('.gmnoprint');
for (index = 0; index < hide.length; ++index) {
hide[index].style.display = 'none';
}});
var mySelector = "#map_canvas";
var elementBounds = page.evaluate(function(selector) {
var clipRect = document.querySelector(selector).getBoundingClientRect();
return {
top: clipRect.top,
left: clipRect.left,
width: clipRect.width,
height: clipRect.height
};
}, mySelector);
var oldClipRect = page.clipRect;
page.clipRect = elementBounds;
s();
page.reload();
}, v);
});
}, 10000);
},5000);
});
});
}, 5000);