attempt to detect the request munge set that's active by searching through the stock site functions

This commit is contained in:
Jon Atkins 2013-08-31 16:40:28 +01:00
parent 5b6ed4ce50
commit 043690f99b

View File

@ -94,9 +94,8 @@ window.digits = function(d) {
return (d+"").replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1 ");
}
// niantic now add some munging to the request parameters. so far, only two sets of this munging have been seen
window.requestDataMunge = function(data) {
var requestMunges = [
window.requestParameterMunges = [
// set 0
{
method: '4kr3ofeptwgary2j',
@ -141,8 +140,36 @@ window.requestDataMunge = function(data) {
factionOnly: '37okcr7gvd5yn2lj'
},
];
window.activeRequestMungeSet = undefined;
var activeMunge = requestMunges[1];
// attempt to guess the munge set in use, by looking therough the functions of the stock intel page for one of the munged params
window.detectActiveMungeSet = function() {
for (var m in window) {
// try and find the stock page functions
if (typeof window[m] == 'function' && m.length <= 3) {
var stockFunc = window[m].toString();
for (var i in window.requestParameterMunges) {
if (stockFunc.indexOf (window.requestParameterMunges[i]['id']) >= 0) {
console.log('IITC: found request munge set '+i+' in stock intel function "window.'+m+'()"');
window.activeRequestMungeSet = i;
}
}
}
}
if (window.activeRequestMungeSet===undefined) {
console.error('IITC: failed to find request munge set - IITC will likely fail');
window.activeRequestMungeSet = 0;
}
}
// niantic now add some munging to the request parameters. so far, only two sets of this munging have been seen
window.requestDataMunge = function(data) {
if (window.activeRequestMungeSet===undefined) {
window.detectActiveMungeSet();
}
var activeMunge = window.requestParameterMunges[window.activeRequestMungeSet];
function munge(obj) {
if (Object.prototype.toString.call(obj) === '[object Array]') {