Created
May 30, 2013 03:26
-
-
Save dpogue/5675554 to your computer and use it in GitHub Desktop.
PhantomJS script for capturing screenshots of the Ingress Intel map.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var page= require('webpage').create(), | |
system = require('system'); | |
var url = 'http://www.ingress.com/intel'; | |
var date = (new Date()).toISOString(); | |
var output = '{{PATH}}' + date + '.png'; | |
phantom.addCookie({ | |
name: 'ACSID', | |
value: '{{ACSID}}', | |
domain: 'www.ingress.com', | |
path: '/', | |
httponly: true, | |
expires: 'Tue, 19 Feb 2013 05:30:24 GMT' | |
}); | |
phantom.addCookie({ | |
name: 'csrftoken', | |
value: '{{TOKEN}}', | |
domain: 'www.ingress.com', | |
path: '/', | |
expires: 'Tue, 04 Feb 2014 05:30:42 GMT' | |
}); | |
phantom.addCookie({ | |
name: 'ingress.intelmap.lat', | |
value: '{{LATITUDE}}', | |
domain: 'www.ingress.com', | |
path: '/' | |
}); | |
phantom.addCookie({ | |
name: 'ingress.intelmap.lng', | |
value: '{{LONGITUDE}}', | |
domain: 'www.ingress.com', | |
path: '/' | |
}); | |
phantom.addCookie({ | |
name: 'ingress.intelmap.zoom', | |
value: '11', | |
domain: 'www.ingress.com', | |
path: '/' | |
}); | |
page.viewportSize = { width: 1600, height: 1024 }; | |
function takeMapshot(i) { | |
if (i >= 5) { | |
console.error('Failing after 5 tries'); | |
phantom.exit(); | |
return; | |
} | |
page.open(url, function(st) { | |
if (st !== 'success') { | |
console.log('Failed to open page'); | |
phantom.exit(); | |
} else { | |
var hasMap = page.evaluate(function() { | |
return document.querySelector('#map_canvas'); | |
}); | |
if (hasMap) { | |
window.setTimeout(function() { | |
page.evaluate(function() { | |
var comm, pstats, geosearch, redeem, header; | |
if (comm = document.querySelector('#comm')) { | |
comm.style.display = 'none'; | |
} | |
if (pstats = document.querySelector('#player_stats')) { | |
pstats.style.display = 'none'; | |
} | |
if (geosearch = document.querySelector('#geocode_search')) { | |
geosearch.style.display = 'none'; | |
} | |
if (redeem = document.querySelector('#redeem_reward')) { | |
redeem.style.display = 'none'; | |
} | |
if (header = document.querySelector('#header')) { | |
header.style.display = 'none'; | |
} | |
var nl = document.querySelectorAll('.gmnoprint'); | |
for (var i = 0, ii = nl.length; i < ii; ++i) { | |
nl.item(i).style.display = 'none'; | |
} | |
}); | |
window.setTimeout(function() { | |
page.render(output); | |
phantom.exit(); | |
}, 60000); | |
}, 60000); | |
} else { | |
/* recurse */ | |
console.log('Attempt ' + i); | |
takeMapshot(i + 1); | |
} | |
} | |
}); | |
} | |
takeMapshot(0); |
Oh... I didn't see this and made a tool like this ๐. It's here. My way was harder ๐, I authenticate user and then capture screenshots, without using cookies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Now it's just render picture with 'Loading...'
How to force it to render portals?
I try to take mobile intel pictures...