From 9ab6bea90d4b0ac4f74d42df877274ff89d19e3a Mon Sep 17 00:00:00 2001 From: Jon Atkins Date: Thu, 14 Aug 2014 23:54:36 +0100 Subject: [PATCH] first pass at extracting version code from the minified javascript still needs some work, but will get something working in the test builds for now... --- code/boot.js | 1 + code/extract_niantic_parameters.js | 22 ++++++++++++++++++++++ code/map_data_calc_tools.js | 24 ++++-------------------- code/send_request.js | 2 +- code/utils_misc.js | 7 ------- main.js | 10 +--------- 6 files changed, 29 insertions(+), 37 deletions(-) create mode 100644 code/extract_niantic_parameters.js diff --git a/code/boot.js b/code/boot.js index 9e97ca62..1712ac39 100644 --- a/code/boot.js +++ b/code/boot.js @@ -570,6 +570,7 @@ function boot() { popupAnchor: new L.Point(1, -34), }}); + window.extractFromStock(); window.setupIdle(); window.setupTaphold(); window.setupStyles(); diff --git a/code/extract_niantic_parameters.js b/code/extract_niantic_parameters.js new file mode 100644 index 00000000..704b52af --- /dev/null +++ b/code/extract_niantic_parameters.js @@ -0,0 +1,22 @@ +// as of 2014-08-14, Niantic have returned to minifying the javascript. This means we no longer get the nemesis object +// and it's various member objects, functions, etc. +// so we need to extract some essential parameters from the code for IITC to use + + +window.niantic_params = {} + + +window.extractFromStock = function() { + + //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 re = new RegExp('[a-z]=[a-z].getData\\(\\);[a-z].v="([a-f0-9]{40})";'); + var func = od.prototype.vg.toString(); + var match = re.exec(func); + niantic_params.CURRENT_VERSION = match[1]; + + +} diff --git a/code/map_data_calc_tools.js b/code/map_data_calc_tools.js index c5adef2a..e45610ce 100755 --- a/code/map_data_calc_tools.js +++ b/code/map_data_calc_tools.js @@ -11,27 +11,11 @@ window.getMapZoomTileParameters = function(zoom) { - // attempt to use the values from the stock site. this way, if they're changed, IITC should continue to work - // however, if Niantic rename things, it would fail, so we'll fall back to the current known values - var ZOOM_TO_TILES_PER_EDGE, MAX_TILES_PER_EDGE, ZOOM_TO_LEVEL; - try { - ZOOM_TO_TILES_PER_EDGE = nemesis.dashboard.mercator.Tile.ZOOM_TO_NUM_TILES_PER_EDGE_; - if (ZOOM_TO_TILES_PER_EDGE === undefined) throw('ZOOM_TO_TILES_PER_EDGE not found'); - MAX_TILES_PER_EDGE = nemesis.dashboard.mercator.Tile.MAX_NUM_TILES_PER_EDGE_; - if (MAX_TILES_PER_EDGE === undefined) throw('MAX_TILES_PER_EDGE not found'); - ZOOM_TO_LEVEL = nemesis.dashboard.zoomlevel.ZOOM_TO_LOD_; - if (ZOOM_TO_LEVEL === undefined) throw('ZOOM_TO_LEVEL not found'); - } catch(e) { - console.warn(e); - // known correct as of 2014-03-19 - ZOOM_TO_TILES_PER_EDGE = [32, 32, 32, 32, 256, 256, 256, 1024, 1024, 1536, 4096, 4096, 6500, 6500, 6500]; - MAX_TILES_PER_EDGE = 9000; - ZOOM_TO_LEVEL = [8, 8, 8, 8, 7, 7, 7, 6, 6, 5, 4, 4, 3, 2, 2, 1, 1]; - - // for developers, let's stop in the debugger - debugger; - } + // known correct as of 2014-08-14 + ZOOM_TO_TILES_PER_EDGE = [64, 64, 64, 64, 256, 256, 256, 1024, 1024, 1536, 4096, 4096, 6500, 6500, 6500]; + MAX_TILES_PER_EDGE = 9000; + ZOOM_TO_LEVEL = [8, 8, 8, 8, 7, 7, 7, 6, 6, 5, 4, 4, 3, 2, 2, 1, 1]; return { diff --git a/code/send_request.js b/code/send_request.js index 767a1bb0..0c41762f 100644 --- a/code/send_request.js +++ b/code/send_request.js @@ -63,7 +63,7 @@ window.postAjax = function(action, data, successCallback, errorCallback) { return; } - var versionStr = nemesis.dashboard.config.CURRENT_VERSION; + var versionStr = niantic_params.CURRENT_VERSION; var post_data = JSON.stringify($.extend({}, data, {v: versionStr, b: "", c: ""})); var result = $.ajax({ diff --git a/code/utils_misc.js b/code/utils_misc.js index ea6d6b9f..4dcb3aa4 100644 --- a/code/utils_misc.js +++ b/code/utils_misc.js @@ -414,13 +414,6 @@ window.clampLatLngBounds = function(bounds) { return new L.LatLngBounds ( clampLatLng(bounds.getSouthWest()), clampLatLng(bounds.getNorthEast()) ); } -// avoid error in stock JS -if(goog && goog.style) { - goog.style.setElementShown = goog.style.showElement = function(a, b) { - if(a && a.style) - a.style.display = b ? "" : "none" - }; -} // Fix Leaflet: handle touchcancel events in Draggable L.Draggable.prototype._onDownOrig = L.Draggable.prototype._onDown; diff --git a/main.js b/main.js index bc08c25a..d94819c9 100644 --- a/main.js +++ b/main.js @@ -122,15 +122,7 @@ function wrapper(info) { // (not the full GM_info - it contains the ENTIRE script source!) window.script_info = info; -// disabling of some cruft left behind by the stock site -try { - goog.events.removeAll(); - goog.Timer.clear(); -} catch(e) { - console.warn('Exception from trying to clear stock site stuff'); - console.warn(e); - debugger; // debugger break -} + // LEAFLET PREFER CANVAS ///////////////////////////////////////////////