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...
This commit is contained in:
Jon Atkins 2014-08-14 23:54:36 +01:00
parent aa01bcf66f
commit 9ab6bea90d
6 changed files with 29 additions and 37 deletions

View File

@ -570,6 +570,7 @@ function boot() {
popupAnchor: new L.Point(1, -34), popupAnchor: new L.Point(1, -34),
}}); }});
window.extractFromStock();
window.setupIdle(); window.setupIdle();
window.setupTaphold(); window.setupTaphold();
window.setupStyles(); window.setupStyles();

View File

@ -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];
}

View File

@ -11,27 +11,11 @@
window.getMapZoomTileParameters = function(zoom) { 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 // known correct as of 2014-08-14
ZOOM_TO_TILES_PER_EDGE = [32, 32, 32, 32, 256, 256, 256, 1024, 1024, 1536, 4096, 4096, 6500, 6500, 6500]; 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; 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]; 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;
}
return { return {

View File

@ -63,7 +63,7 @@ window.postAjax = function(action, data, successCallback, errorCallback) {
return; 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 post_data = JSON.stringify($.extend({}, data, {v: versionStr, b: "", c: ""}));
var result = $.ajax({ var result = $.ajax({

View File

@ -414,13 +414,6 @@ window.clampLatLngBounds = function(bounds) {
return new L.LatLngBounds ( clampLatLng(bounds.getSouthWest()), clampLatLng(bounds.getNorthEast()) ); 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 // Fix Leaflet: handle touchcancel events in Draggable
L.Draggable.prototype._onDownOrig = L.Draggable.prototype._onDown; L.Draggable.prototype._onDownOrig = L.Draggable.prototype._onDown;

10
main.js
View File

@ -122,15 +122,7 @@ function wrapper(info) {
// (not the full GM_info - it contains the ENTIRE script source!) // (not the full GM_info - it contains the ENTIRE script source!)
window.script_info = info; 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 /////////////////////////////////////////////// // LEAFLET PREFER CANVAS ///////////////////////////////////////////////