Skip to content

Instantly share code, notes, and snippets.

@shunix
Created August 22, 2013 14:48
Show Gist options
  • Save shunix/6308203 to your computer and use it in GitHub Desktop.
Save shunix/6308203 to your computer and use it in GitHub Desktop.
var url = require('url');
var http = require('http');
exports.index = function(req, res){
res.render('index', { title: 'Ingress Shanghai' });
};
exports.getAll = function(req, res){
var data = JSON.stringify({
"desiredNumItems": 1000,
"minLatE6": 30400000,
"minLngE6": 120510000,
"maxLatE6": 31530000,
"maxLngE6": 122120000,
"minTimestampMs": -1,
"maxTimestampMs": -1,
"method": "dashboard.getPaginatedPlextsV2"
});
var cookie = 'Put Your cookie here';
var headers = {
'Cookie': cookie,
'Content-Type': 'application/json',
'Content-Length': Buffer.byteLength(data, 'utf-8'),
'X-Requested-With':'XMLHttpRequest',
'X-CSRFToken': 'Your CSRF Token'
};
var options = {
'host': 'www.ingress.com',
'port': 80,
'method': 'POST',
'headers': headers,
'path': '/rpc/dashboard.getPaginatedPlextsV2'
};
callback = function(response) {
var data = '';
var array = new Array();
response.on('data', function(chunk) {
data += chunk;
});
response.on('end', function() {
var obj = JSON.parse(data);
for(var i = 0; i < obj.result.length; i++) {
array.push(obj.result[i][2].plext.text);
}
res.render('all', {
title: 'Ingress Shanghai Log',
items: array
})
res.end();
});
}
var req = http.request(options, callback);
req.write(data);
req.end();
req.on('error', function(err) {
console.log(err);
});
}
exports.getFaction = function(req, res) {
var data = JSON.stringify({
"desiredNumItems": 1000,
"minLatE6": 30400000,
"minLngE6": 120510000,
"maxLatE6": 31530000,
"maxLngE6": 122120000,
"minTimestampMs": -1,
"maxTimestampMs": -1,
"factionOnly": true,
"method": "dashboard.getPaginatedPlextsV2"
});
var cookie = 'Put Your cookie here';
var headers = {
'Cookie': cookie,
'Content-Type': 'application/json',
'Content-Length': Buffer.byteLength(data, 'utf-8'),
'X-Requested-With':'XMLHttpRequest',
'X-CSRFToken': 'Your CSRF Token'
};
var options = {
'host': 'www.ingress.com',
'port': 80,
'method': 'POST',
'headers': headers,
'path': '/rpc/dashboard.getPaginatedPlextsV2'
};
callback = function(response) {
var data = '';
var array = new Array();
response.on('data', function(chunk) {
data += chunk;
});
response.on('end', function() {
var obj = JSON.parse(data);
for(var i = 0; i < obj.result.length; i++) {
array.push(obj.result[i][2].plext.text);
}
res.render('all', {
title: 'Ingress Englightened Chat',
items: array
})
res.end();
});
}
var req = http.request(options, callback);
req.write(data);
req.end();
req.on('error', function(err) {
console.log(err);
});
}
exports.getAllJson = function(req, res) {
var data = JSON.stringify({
"desiredNumItems": 1000,
"minLatE6": 30400000,
"minLngE6": 120510000,
"maxLatE6": 31530000,
"maxLngE6": 122120000,
"minTimestampMs": -1,
"maxTimestampMs": -1,
"method": "dashboard.getPaginatedPlextsV2"
});
var cookie = 'Put Your cookie here';
var headers = {
'Cookie': cookie,
'Content-Type': 'application/json',
'Content-Length': Buffer.byteLength(data, 'utf-8'),
'X-Requested-With':'XMLHttpRequest',
'X-CSRFToken': 'Your CSRF Token'
};
var options = {
'host': 'www.ingress.com',
'port': 80,
'method': 'POST',
'headers': headers,
'path': '/rpc/dashboard.getPaginatedPlextsV2'
};
callback = function(response) {
var data = '';
response.on('data', function(chunk) {
data += chunk;
});
response.on('end', function() {
res.writeHead(200, {'Content-Type': 'application/json; charset=utf8'});
res.write(data);
res.end();
});
}
var req = http.request(options, callback);
req.write(data);
req.end();
req.on('error', function(err) {
console.log(err);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment