botguard: first pass at full implementation. fingers crossed...
This commit is contained in:
parent
bbbc3493c9
commit
92aae954a8
@ -571,6 +571,7 @@ function boot() {
|
||||
}});
|
||||
|
||||
window.extractFromStock();
|
||||
window.iitc_bg.init(); //NOTE: needs to be early (before any requests sent), but after extractFromStock()
|
||||
window.setupIdle();
|
||||
window.setupTaphold();
|
||||
window.setupStyles();
|
||||
|
@ -40,7 +40,7 @@ iitc_bg.init = function() {
|
||||
// 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
|
||||
// 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_methods
|
||||
// a (smaller) list of methods for group a - in window.niantic_params.botguard_group_a_methods
|
||||
|
||||
|
||||
var botguard_key = B;
|
||||
@ -111,9 +111,14 @@ iitc_bg.process_key = function(key,serverEval) {
|
||||
// server wants us to eval some code! risky, and impossible to be certain we can do it safely
|
||||
// however... reports say that it only interacts with the botguard.bg code, so we might be fine just running it
|
||||
try {
|
||||
console.warn('Server-generated javascript eval requested:\n'+serverExec);
|
||||
debugger;
|
||||
if (!confirm('The server asked IITC to run (eval) some javascript. This may or may not be safe. Run and continue?\n\nScript:\n'+serverEval)) { console.error('server javascript eval cancelled') } else
|
||||
eval(serverEval);
|
||||
console.log('Server-generated javascript ran OK');
|
||||
} catch(e) {
|
||||
console.warn('Server-generated javascript - threw an exception');
|
||||
console.warn(e);
|
||||
caught = true;
|
||||
}
|
||||
}
|
||||
@ -135,7 +140,7 @@ iitc_bg.get_method_group = function(method) {
|
||||
// undefined for no group
|
||||
|
||||
if (window.niantic_params.botguard_protected_methods.indexOf(method) != -1) {
|
||||
if (window.niantic_params.botguard_group_methods.indexOf(method) != -1) {
|
||||
if (window.niantic_params.botguard_group_a_methods.indexOf(method) != -1) {
|
||||
return "group-a-actions";
|
||||
} else {
|
||||
return "group-b-actions";
|
||||
@ -198,7 +203,6 @@ iitc_bg.get_request_data = function(method) {
|
||||
|
||||
iitc_bg.dummy_botguard = function() {};
|
||||
iitc_bg.dummy_botguard.prototype.invoke = function(callback) {
|
||||
debugger;
|
||||
callback("dkxm");
|
||||
};
|
||||
|
||||
|
@ -451,9 +451,15 @@ window.chat.toggle = function() {
|
||||
|
||||
window.chat.request = function() {
|
||||
console.log('refreshing chat');
|
||||
var tab = chat.getActive();
|
||||
//TODO: add 'alerts' tab, and add the matching case in here
|
||||
if (tab == 'faction') {
|
||||
chat.requestFaction(false);
|
||||
} else {
|
||||
// the 'public', 'full' and 'compact' tabs are all based off the 'public' COMM data
|
||||
chat.requestPublic(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// checks if there are enough messages in the selected chat tab and
|
||||
|
@ -72,7 +72,7 @@ window.extractFromStock = function() {
|
||||
// botguard group-a or group-b, while the others is just a list of those in one group
|
||||
|
||||
window.niantic_params.botguard_protected_methods = [];
|
||||
window.niantic_params.botguard_group_methods = [];
|
||||
window.niantic_params.botguard_group_a_methods = [];
|
||||
|
||||
var countMethods = function(arr) {
|
||||
var methods = ['artifacts', 'getGameScore', 'getPlexts', 'getPortalDetails', 'redeemReward', 'sendInviteEmail', 'sendPlext'];
|
||||
@ -92,12 +92,12 @@ window.extractFromStock = function() {
|
||||
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
|
||||
// now store the longest in niantic_params.botguard_protected_methods, and 2nd longest in .niantic_params.botguard_group_a_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;
|
||||
window.niantic_params.botguard_group_a_methods = window.niantic_params.botguard_protected_methods;
|
||||
groupMethodsCount = protectedMethodsCount;
|
||||
|
||||
//... and set the longest
|
||||
@ -106,14 +106,14 @@ window.extractFromStock = function() {
|
||||
|
||||
} else if (arrCount > groupMethodsCount) {
|
||||
// 2nd longest - store
|
||||
window.niantic_params.botguard_group_methods = arr;
|
||||
window.niantic_params.botguard_group_a_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) {
|
||||
if (niantic_params.CURRENT_VERSION === undefined || window.niantic_params.botguard_protected_methods.length == 0 || window.niantic_params.botguard_group_a_methods == 0) {
|
||||
dialog({
|
||||
title: 'IITC Broken',
|
||||
html: '<p>IITC failed to extract the required parameters from the intel site</p>'
|
||||
|
@ -34,6 +34,7 @@ window.postAjax = function(action, data, successCallback, errorCallback) {
|
||||
|
||||
var onSuccess = function(data, textStatus, jqXHR) {
|
||||
window.requests.remove(jqXHR);
|
||||
iitc_bg.process_response_params(action,data);
|
||||
|
||||
// the Niantic server can return a HTTP success, but the JSON response contains an error. handle that sensibly
|
||||
if (data && data.error && data.error == 'out of date') {
|
||||
@ -64,7 +65,7 @@ window.postAjax = function(action, data, successCallback, errorCallback) {
|
||||
}
|
||||
|
||||
var versionStr = niantic_params.CURRENT_VERSION;
|
||||
var post_data = JSON.stringify($.extend({}, data, {v: versionStr, b: "", c: ""}));
|
||||
var post_data = JSON.stringify($.extend({}, data, {v: versionStr}, iitc_bg.extra_request_params(action)));
|
||||
|
||||
var result = $.ajax({
|
||||
url: '/r/'+action,
|
||||
|
Loading…
x
Reference in New Issue
Block a user