diff --git a/code/boot.js b/code/boot.js index 1712ac39..cf811d91 100644 --- a/code/boot.js +++ b/code/boot.js @@ -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(); diff --git a/code/botguard_interface.js b/code/botguard_interface.js index 9eb53ffe..2ef30b90 100644 --- a/code/botguard_interface.js +++ b/code/botguard_interface.js @@ -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"); }; diff --git a/code/chat.js b/code/chat.js index f8e43895..00a7d192 100644 --- a/code/chat.js +++ b/code/chat.js @@ -451,8 +451,14 @@ window.chat.toggle = function() { window.chat.request = function() { console.log('refreshing chat'); - chat.requestFaction(false); - chat.requestPublic(false); + 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); + } } diff --git a/code/extract_niantic_parameters.js b/code/extract_niantic_parameters.js index 25f862c8..db8de381 100644 --- a/code/extract_niantic_parameters.js +++ b/code/extract_niantic_parameters.js @@ -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: '

IITC failed to extract the required parameters from the intel site

' diff --git a/code/send_request.js b/code/send_request.js index 0c41762f..f0da8098 100644 --- a/code/send_request.js +++ b/code/send_request.js @@ -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,