work in progress: intel site 'botguard' interface.
not yet complete. initialisation is probably right - but need to check/complete the request param creation, and implement the response processing
This commit is contained in:
@ -5,13 +5,12 @@
|
||||
window.extractFromStock = function() {
|
||||
window.niantic_params = {}
|
||||
|
||||
//TODO: need to search through the stock intel minified functions/data structures for the required variables
|
||||
// just as a *very* quick fix, test the theory with hard-coded variable names
|
||||
|
||||
|
||||
// extract the former nemesis.dashboard.config.CURRENT_VERSION from the code
|
||||
var reVersion = new RegExp('[a-z]=[a-z].getData\\(\\);[a-z].v="([a-f0-9]{40})";');
|
||||
|
||||
// we also extract all top-level arrays of strings, for botguard
|
||||
var arrays = [];
|
||||
|
||||
var minified = new RegExp('^[a-zA-Z][a-zA-Z0-9]$');
|
||||
|
||||
@ -19,8 +18,8 @@ window.extractFromStock = function() {
|
||||
if (minified.test(topLevel)) {
|
||||
// a minified object - check for minified prototype entries
|
||||
|
||||
// the object has a prototype - iterate through the properties of that
|
||||
if (window[topLevel] && window[topLevel].prototype) {
|
||||
// the object has a prototype - iterate through the properties of that
|
||||
for (var secLevel in window[topLevel].prototype) {
|
||||
if (minified.test(secLevel)) {
|
||||
|
||||
@ -44,17 +43,86 @@ window.extractFromStock = function() {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// finding the required method names for the botguard interface code
|
||||
if (window[topLevel] && Object.prototype.toString.call(window[topLevel]) == "[object Array]") {
|
||||
// look for all arrays in the top-level namespace
|
||||
|
||||
var arr = window[topLevel];
|
||||
var onlyStrings = true;
|
||||
if (arr.length > 0) {
|
||||
for (var i in arr) {
|
||||
if (Object.prototype.toString.call(arr[i]) != "[object String]") {
|
||||
onlyStrings = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (onlyStrings) {
|
||||
arrays.push(arr);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// we extracted a list of string arrays. now, we need to find which ones we want to use
|
||||
// there are two. both contain a list of method names - one is the list of methods protected by either
|
||||
// botguard group-a or group-b, while the others is just a list of those in one group
|
||||
|
||||
if (niantic_params.CURRENT_VERSION === undefined) {
|
||||
window.niantic_params.botguard_protected_methods = [];
|
||||
window.niantic_params.botguard_group_methods = [];
|
||||
|
||||
var countMethods = function(arr) {
|
||||
var methods = ['artifacts', 'getGameScore', 'getPlexts', 'getPortalDetails', 'redeemReward', 'sendInviteEmail', 'sendPlext'];
|
||||
var count = 0;
|
||||
for (var j in arr) {
|
||||
if (methods.indexOf(arr[j]) != -1) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
var protectedMethodsCount = 0;
|
||||
var groupMethodsCount = 0;
|
||||
|
||||
for (var i in arrays) {
|
||||
var arr = arrays[i];
|
||||
var arrCount = countMethods(arr);
|
||||
|
||||
// now store the longest in niantic_params.botguard_protected_methods, and 2nd longest in .niantic_params.botguard_group_methods
|
||||
|
||||
if (arrCount > protectedMethodsCount) {
|
||||
// longest found - copy any existing longest to the 2nd longest
|
||||
|
||||
window.niantic_params.botguard_group_methods = window.niantic_params.botguard_protected_methods;
|
||||
groupMethodsCount = protectedMethodsCount;
|
||||
|
||||
//... and set the longest
|
||||
window.niantic_params.botguard_protected_methods = arr;
|
||||
protectedMethodsCount = arrCount;
|
||||
|
||||
} else if (arrCount > groupMethodsCount) {
|
||||
// 2nd longest - store
|
||||
window.niantic_params.botguard_group_methods = arr;
|
||||
groupMethodsCount = arrCount;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (niantic_params.CURRENT_VERSION === undefined || window.niantic_params.botguard_protected_methods.length == 0 || window.niantic_params.botguard_group_methods == 0) {
|
||||
dialog({
|
||||
title: 'IITC Broken',
|
||||
html: '<p>IITC failed to extract the required varsion parameter from the intel site</p>'
|
||||
html: '<p>IITC failed to extract the required parameters from the intel site</p>'
|
||||
+'<p>This can happen after Niantic update the standard intel site. A fix will be needed from the IITC developers.</p>',
|
||||
});
|
||||
|
||||
console.log('Discovered parameters');
|
||||
console.log(JSON.stringify(window.niantic_params,null,2));
|
||||
|
||||
throw('Error: IITC failed to extract CURRENT_VERSION string - cannot continue');
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user