botguard groups: rather than emulating the now removed group_a_methods array, we create an object containing the a/b flag
this way, if a method isn't found - we correctly fail to send a request, rather than falling back to assuming it's group-b
This commit is contained in:
parent
39de236459
commit
7cc8480467
@ -41,8 +41,6 @@ iitc_bg.init = function() {
|
|||||||
// to initialise, we need four things
|
// to initialise, we need four things
|
||||||
// B - a key(?). set in the main web page HTML, name isn't changed on site updates
|
// B - a key(?). set in the main web page HTML, name isn't changed on site updates
|
||||||
// CS - initialisation data for botguard - again in the main page, again name is constant
|
// CS - initialisation data for botguard - again in the main page, again name is constant
|
||||||
// a list of method names to protect. varies on site updates (sometimes) - in window.niantic_params.botguard_protected_methods
|
|
||||||
// a (smaller) list of methods for group a - in window.niantic_params.botguard_group_a_methods
|
|
||||||
|
|
||||||
|
|
||||||
var botguard_key = B;
|
var botguard_key = B;
|
||||||
@ -143,7 +141,11 @@ iitc_bg.get_method_group = function(method) {
|
|||||||
// return -1 != ig.indexOf(a) ? "group-a-actions" : "group-b-actions";
|
// return -1 != ig.indexOf(a) ? "group-a-actions" : "group-b-actions";
|
||||||
//}
|
//}
|
||||||
|
|
||||||
if (window.niantic_params.botguard_group_a_methods.indexOf(method) != -1) {
|
if (window.niantic_params.botguard_method_group_flag[method] === undefined) {
|
||||||
|
throw 'Error: method '+method+' not found in the botguard_method_group_flag object';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (window.niantic_params.botguard_method_group_flag[method]) {
|
||||||
return "ingress-a-actions";
|
return "ingress-a-actions";
|
||||||
} else {
|
} else {
|
||||||
return "ingress-b-actions";
|
return "ingress-b-actions";
|
||||||
|
@ -4,9 +4,8 @@
|
|||||||
|
|
||||||
window.extractFromStock = function() {
|
window.extractFromStock = function() {
|
||||||
window.niantic_params = {}
|
window.niantic_params = {}
|
||||||
window.niantic_params.botguard_group_a_methods = [];
|
|
||||||
|
|
||||||
var methods = ['artifacts', 'getGameScore', 'getPlexts', 'getPortalDetails', 'redeemReward', 'sendInviteEmail', 'sendPlext'];
|
window.niantic_params.botguard_method_group_flag = {};
|
||||||
|
|
||||||
// extract the former nemesis.dashboard.config.CURRENT_VERSION from the code
|
// 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})";');
|
var reVersion = new RegExp('[a-z]=[a-z].getData\\(\\);[a-z].v="([a-f0-9]{40})";');
|
||||||
@ -56,90 +55,25 @@ window.extractFromStock = function() {
|
|||||||
}
|
}
|
||||||
} //end 'if .prototype'
|
} //end 'if .prototype'
|
||||||
|
|
||||||
|
|
||||||
// finding the required method names for the botguard interface code
|
// finding the required method names for the botguard interface code
|
||||||
if(topObject && Object.getPrototypeOf(topObject) == requestPrototype) {
|
if(topObject && typeof topObject == "object" && Object.getPrototypeOf(topObject) == requestPrototype) {
|
||||||
var methodKey = Object
|
var methodKey = Object
|
||||||
.keys(topObject)
|
.keys(topObject)
|
||||||
.filter(function(key) { return typeof key == "string"; })[0];
|
.filter(function(key) { return typeof key == "string"; })[0];
|
||||||
|
|
||||||
for(var secLevel in topObject) {
|
for(var secLevel in topObject) {
|
||||||
if(typeof topObject[secLevel] == "boolean" && topObject[secLevel]) {
|
if(typeof topObject[secLevel] == "boolean") {
|
||||||
window.niantic_params.botguard_group_a_methods.push(topObject[methodKey]);
|
window.niantic_params.botguard_method_group_flag[topObject[methodKey]] = topObject[secLevel];
|
||||||
}
|
|
||||||
if(typeof topObject[secLevel] == "boolean" && !topObject[secLevel]) {
|
|
||||||
console.info("b-action:", topObject[methodKey]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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
|
if (niantic_params.CURRENT_VERSION === undefined || Object.keys(window.niantic_params.botguard_method_group_flag).length == 0) {
|
||||||
// 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
|
|
||||||
|
|
||||||
// window.niantic_params.botguard_protected_methods = [];
|
|
||||||
|
|
||||||
//var countMethods = function(arr) {
|
|
||||||
// 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);
|
|
||||||
//
|
|
||||||
// if (arrCount > protectedMethodsCount) {
|
|
||||||
// // longest found - copy any existing longest to the 2nd longest
|
|
||||||
//
|
|
||||||
// window.niantic_params.botguard_group_a_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_a_methods = arr;
|
|
||||||
// groupMethodsCount = arrCount;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
if (niantic_params.CURRENT_VERSION === undefined || window.niantic_params.botguard_group_a_methods.length == 0) {
|
|
||||||
dialog({
|
dialog({
|
||||||
title: 'IITC Broken',
|
title: 'IITC Broken',
|
||||||
html: '<p>IITC failed to extract the required parameters from the intel site</p>'
|
html: '<p>IITC failed to extract the required parameters from the intel site</p>'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user