From e6305a0aa97d5da658720cae046d3f07ed25d298 Mon Sep 17 00:00:00 2001 From: Jon Atkins Date: Sat, 23 Nov 2013 09:01:22 +0000 Subject: [PATCH 1/8] getAvgResDist - return a small, but non-zero, value for zero distance resonator deployments (zero is already assumed to be no resonators deployed) portal-highlighter-bad-deployment-distance: highlight colour based on resonatror range: purple: likely 0m deployment (spoofer?), red <10m, orange under 24m, yellow under 36m otherwise no highlight --- code/portal_info.js | 4 +++- ...portal-highlighter-bad-deployment-distance.user.js | 11 +++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/code/portal_info.js b/code/portal_info.js index 569f8f0f..fd27b4ee 100644 --- a/code/portal_info.js +++ b/code/portal_info.js @@ -91,7 +91,9 @@ window.getAvgResoDist = function(d) { var sum = 0, resos = 0; $.each(d.resonatorArray.resonators, function(ind, reso) { if(!reso) return true; - sum += parseInt(reso.distanceToPortal); + var resDist = parseInt(reso.distanceToPortal); + if (resDist == 0) resDist = 0.01; // set a non-zero but very small distance for zero deployment distance. allows the return value to distinguish between zero deployment distance average and zero resonators + sum += resDist; resos++; }); return resos ? sum/resos : 0; diff --git a/plugins/portal-highlighter-bad-deployment-distance.user.js b/plugins/portal-highlighter-bad-deployment-distance.user.js index 2f44eb32..73c0cc3b 100644 --- a/plugins/portal-highlighter-bad-deployment-distance.user.js +++ b/plugins/portal-highlighter-bad-deployment-distance.user.js @@ -2,7 +2,7 @@ // @id iitc-plugin-highlight-bad-deployment-distance@cathesaurus // @name IITC plugin: highlight badly-deployed portals // @category Highlighter -// @version 0.1.0.@@DATETIMEVERSION@@ +// @version 0.1.1.@@DATETIMEVERSION@@ // @namespace https://github.com/jonatkins/ingress-intel-total-conversion // @updateURL @@UPDATEURL@@ // @downloadURL @@DOWNLOADURL@@ @@ -25,12 +25,15 @@ window.plugin.portalHighlighterBadDeploymentDistance.highlight = function(data) var d = data.portal.options.details; var portal_deployment = 0; if(getTeam(d) !== 0) { - if(window.getAvgResoDist(d) > 0 && window.getAvgResoDist(d) < window.HACK_RANGE*0.9) { - portal_deployment = (window.HACK_RANGE - window.getAvgResoDist(d))/window.HACK_RANGE; + var avgDist = window.getAvgResoDist(d); + if(avgDist > 0 && avgDist < window.HACK_RANGE*0.9) { + portal_deployment = (window.HACK_RANGE - avgDist)/window.HACK_RANGE; } if(portal_deployment > 0) { var fill_opacity = portal_deployment*.85 + .15; - color = 'red'; + // magenta for *exceptionally* close deployments (spoofing? under 1m average), then shades of + // red, orange and yellow for further out + color = avgDist < 1 ? 'magenta' : avgDist < (window.HACK_RANGE*.25) ? 'red' : avgDist < (window.HACK_RANGE*.6) ? 'orange' : 'yellow'; var params = {fillColor: color, fillOpacity: fill_opacity}; data.portal.setStyle(params); } From 44ee4c7200c8d8e318732323d2d515118731b247 Mon Sep 17 00:00:00 2001 From: Jon Atkins Date: Sun, 24 Nov 2013 01:03:45 +0000 Subject: [PATCH 2/8] request munging: call the stock site nemesis.dashboard.requests.normalizeParamCount function, to add in dummy parameters to requests for #656 number 1 --- code/munge.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/code/munge.js b/code/munge.js index 9641cc16..56fe5a96 100644 --- a/code/munge.js +++ b/code/munge.js @@ -326,6 +326,16 @@ window.requestDataMunge = function(data) { }; var newdata = munge(data); + + try { + newdata = nemesis.dashboard.requests.normalizeParamCount(newdata); + } catch(e) { + if (!window._mungeHaveLoggedError) { + console.warn('Failed to call the stock site normalizeParamCount() function: '+e); + window._mungeHaveLoggedError = true; + } + } + return newdata; } From 1501f98f9ba5bb3c154045c003b3f573f5e7a868 Mon Sep 17 00:00:00 2001 From: Jon Atkins Date: Sun, 24 Nov 2013 01:04:45 +0000 Subject: [PATCH 3/8] limit the number of player names resolved in one go, to prevent excessive requests for #656 number 4 --- code/player_names.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/code/player_names.js b/code/player_names.js index 7914c706..e9475a03 100644 --- a/code/player_names.js +++ b/code/player_names.js @@ -66,6 +66,12 @@ window.resolvePlayerNames = function() { //limit per request. stock site is never more than 13 (8 res, 4 mods, owner) //testing shows 15 works and 20 fails var MAX_RESOLVE_PLAYERS_PER_REQUEST = 15; + var MAX_RESOLVE_REQUESTS = 8; + + if (window.playersToResolve.length > MAX_RESOLVE_PLAYERS_PER_REQUEST*MAX_RESOLVE_REQUESTS) { + console.log('Warning: player name resolve queue had '+window.playersToResolve.length+' entries. Limiting to the first '+MAX_RESOLVE_PLAYERS_PER_REQUEST*MAX_RESOLVE_REQUESTS+' to prevent excessive requests'); + window.playersToResolve = playersToResolve.slice(0,MAX_RESOLVE_PLAYERS_PER_REQUEST*MAX_RESOLVE_REQUESTS); + } var p = window.playersToResolve.slice(0,MAX_RESOLVE_PLAYERS_PER_REQUEST); window.playersToResolve = playersToResolve.slice(MAX_RESOLVE_PLAYERS_PER_REQUEST); From d58ba079b8fd91b36fba100074168781e22c9373 Mon Sep 17 00:00:00 2001 From: Jon Atkins Date: Sun, 24 Nov 2013 01:32:46 +0000 Subject: [PATCH 4/8] COMM: correctly use the ascendingTimestampOrder flag when retrieving new COMM messages. this matches the stock intel site, and prevents gaps occuring when filling in entries after resuming from idle related to #656 no 2 --- code/chat.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/code/chat.js b/code/chat.js index fc88c670..2c3779fa 100644 --- a/code/chat.js +++ b/code/chat.js @@ -106,6 +106,9 @@ window.chat.genPostData = function(isFaction, storageHash, getOlderMsgs) { // Currently this edge case is not handled. Let’s see if this is a // problem in crowded areas. $.extend(data, {minTimestampMs: min}); + // when requesting with an acutal minimum timestamp, request oldest rather than newest first. + // this matches the stock intel site, and ensures no gaps when continuing after an extended idle period + if (min > -1) $.extend(data, {ascendingTimestampOrder: true}); } return data; } From 1bfe89c041281135074f383f6835d06f3e093c8e Mon Sep 17 00:00:00 2001 From: Jon Atkins Date: Sun, 24 Nov 2013 01:34:13 +0000 Subject: [PATCH 5/8] reduce the number of 'all' comm messages retrieved in one go to 50 at a time related to #656 no 2 --- main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.js b/main.js index c0645c7b..3600df45 100644 --- a/main.js +++ b/main.js @@ -142,7 +142,7 @@ window.CHAT_MIN_RANGE = 6; window.VIEWPORT_PAD_RATIO = 0.3; // how many items to request each query -window.CHAT_PUBLIC_ITEMS = 200; +window.CHAT_PUBLIC_ITEMS = 50; window.CHAT_FACTION_ITEMS = 50; // how many pixels to the top before requesting new data window.CHAT_REQUEST_SCROLL_TOP = 200; From 47d453793c95fb1a68c45d800d0dd61ada7c6f97 Mon Sep 17 00:00:00 2001 From: Jon Atkins Date: Sun, 24 Nov 2013 01:48:00 +0000 Subject: [PATCH 6/8] re-order the common method name & version parameters in the JSON requests to match the stock intel site for #656 --- code/utils_misc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/utils_misc.js b/code/utils_misc.js index 7933f3bc..f4c0d8c7 100644 --- a/code/utils_misc.js +++ b/code/utils_misc.js @@ -146,7 +146,7 @@ window.postAjax = function(action, data, success, error) { // and of the 'version' parameter (we assume it's a version - if missing/wrong that's what the error refers to) versionStr = mungeOneString(versionStr); - var post_data = JSON.stringify(window.requestDataMunge($.extend({method: methodName, version: versionStr}, data))); + var post_data = JSON.stringify(window.requestDataMunge($.extend({}, data, {method: methodName, version: versionStr}))); var remove = function(data, textStatus, jqXHR) { window.requests.remove(jqXHR); }; var errCnt = function(jqXHR) { window.failedRequestCount++; window.requests.remove(jqXHR); }; var result = $.ajax({ From f22d185b5b90330b41391557ac5673e650e7ace4 Mon Sep 17 00:00:00 2001 From: Jon Atkins Date: Sun, 24 Nov 2013 04:59:41 +0000 Subject: [PATCH 7/8] updates to the portal detail level handling - iitc now defaults to lower detail than the standard intel site when zoomed out - it loads much faster, shows more than enough for general use, and is less likely to trigger 'excessive requests' issues - show more portals plugin: updated for interface changes - show-less-portals-zoomed-out: deleted (this is now the IITC default) - new plugin: default-intel-detail - restores the original IITC behaviour on zoom to portal detail level mapping. not recommended for #656 number 3 --- code/map_data_request.js | 4 +- code/request_handling.js | 8 +-- code/utils_misc.js | 35 +++----------- plugins/default-intel-detail.user.js | 51 ++++++++++++++++++++ plugins/show-less-portals-zoomed-out.user.js | 49 ++----------------- plugins/show-more-portals.user.js | 25 ++++------ 6 files changed, 74 insertions(+), 98 deletions(-) create mode 100644 plugins/default-intel-detail.user.js diff --git a/code/map_data_request.js b/code/map_data_request.js index cc9ab868..64ea0d2c 100644 --- a/code/map_data_request.js +++ b/code/map_data_request.js @@ -91,7 +91,7 @@ window.MapDataRequest.prototype.mapMoveStart = function() { window.MapDataRequest.prototype.mapMoveEnd = function() { var bounds = clampLatLngBounds(map.getBounds()); - var zoom = getPortalDataZoom(); + var zoom = map.getZoom(); if (this.fetchedDataParams) { // we have fetched (or are fetching) data... @@ -180,7 +180,7 @@ window.MapDataRequest.prototype.refresh = function() { var bounds = clampLatLngBounds(map.getBounds()); - var zoom = getPortalDataZoom(); + var zoom = map.getZoom(); var minPortalLevel = getMinPortalLevelForZoom(zoom); //DEBUG: resize the bounds so we only retrieve some data diff --git a/code/request_handling.js b/code/request_handling.js index 4ae1d3fb..7dac5a55 100644 --- a/code/request_handling.js +++ b/code/request_handling.js @@ -67,13 +67,7 @@ window.startRefreshTimeout = function(override) { window.requests._quickRefreshPending = false; t = REFRESH*1000; - // new getThinnedEntitiesV4 involves a LOT more requests when zoomed out above a data level of 13 - // so, to give the refresh a chance to complete (and also reduce load on niantic servers), boost the refresh interval - // in this case - // (TODO: complete rewrite of refresh+request handling. don't start timer until complete, and retry error=TIMEOUT requests) - if (getPortalDataZoom() <=12 ) t = t*4; - - var adj = ZOOM_LEVEL_ADJ * (18 - getPortalDataZoom()); + var adj = ZOOM_LEVEL_ADJ * (18 - map.getZoom()); if(adj > 0) t += adj*1000; } var next = new Date(new Date().getTime() + t).toLocaleTimeString(); diff --git a/code/utils_misc.js b/code/utils_misc.js index 2a860341..11ed6545 100644 --- a/code/utils_misc.js +++ b/code/utils_misc.js @@ -276,41 +276,20 @@ window.androidPermalink = function() { } -window.getPortalDataZoom = function() { - var mapZoom = map.getZoom(); - - // make sure we're dealing with an integer here - // (mobile: a float somehow gets through in some cases!) - var z = parseInt(mapZoom); - - // limiting the maximum zoom level for data retrieval reduces the number of requests at high zoom levels - // (as all portal data is retrieved at z=17, why retrieve multiple z=18 tiles when fewer z=17 would do?) - // very effective along with the new cache code - if (z > 17) z=17; - - //sanity check - should never happen - if (z < 0) z=0; - - return z; -} - - window.getMinPortalLevelForZoom = function(z) { - // try to use the zoom-to-level mapping from the stock intel page, if available - var ZOOM_TO_LEVEL; - try { - ZOOM_TO_LEVEL = nemesis.dashboard.zoomlevel.ZOOM_TO_LOD_; - } catch(e) { - //based on code from stock gen_dashboard.js - ZOOM_TO_LEVEL = [8, 8, 8, 8, 7, 7, 6, 6, 5, 4, 4, 3, 3, 2, 2, 1, 1]; - } + + // these values are from the stock intel map. however, they're too detailed for reasonable speed, and increasing + // detail at a higher zoom level shows enough detail still, AND speeds up IITC considerably +//var ZOOM_TO_LEVEL = [8, 8, 8, 8, 7, 7, 6, 6, 5, 4, 4, 3, 3, 2, 2, 1, 1]; + var ZOOM_TO_LEVEL = [8, 8, 8, 8, 8, 8, 7, 7, 6, 5, 4, 4, 3, 2, 2, 1, 1]; + var l = ZOOM_TO_LEVEL[z] || 0; return l; } window.getMinPortalLevel = function() { - var z = getPortalDataZoom(); + var z = map.getZoom(); return getMinPortalLevelForZoom(z); } diff --git a/plugins/default-intel-detail.user.js b/plugins/default-intel-detail.user.js new file mode 100644 index 00000000..8bcc0ef2 --- /dev/null +++ b/plugins/default-intel-detail.user.js @@ -0,0 +1,51 @@ +// ==UserScript== +// @id iitc-plugin-default-intel-detail@jonatkins +// @name IITC plugin: Default intel detail level +// @category Tweaks +// @version 0.1.0.@@DATETIMEVERSION@@ +// @namespace https://github.com/jonatkins/ingress-intel-total-conversion +// @updateURL @@UPDATEURL@@ +// @downloadURL @@DOWNLOADURL@@ +// @description [@@BUILDNAME@@-@@BUILDDATE@@] Use the portal level detail levels from the standard intel site. By default, IITC shows less detail when zoomed out, as this is enough for general use, is more friendly to the niantic servers, and loads much faster. This plugin restores the default zoom level to portal level mapping. Note: using this plugin causes a larger number of requests to the intel server, and at high resolutions can cause excessive requests to be made (yes: the default intel site also has this problem!), so it is not recommended except for low resolution screens. +// @include https://www.ingress.com/intel* +// @include http://www.ingress.com/intel* +// @match https://www.ingress.com/intel* +// @match http://www.ingress.com/intel* +// @grant none +// ==/UserScript== + +@@PLUGINSTART@@ + +// PLUGIN START //////////////////////////////////////////////////////// + + +// use own namespace for plugin +window.plugin.defaultIntelDetail = function() {}; + +window.plugin.defaultIntelDetail.setup = function() { + + var stockIntelDetail = nemesis.dashboard.zoomlevel.ZOOM_TO_LOD_; + + // save the original function - so we can chain to it for levels we don't modify + var origGetMinPortalLevelForZoom = window.getMinPortalLevelForZoom; + + // replace the window.getMinPortalLevelForZoom function - modify behaviour when L1+ or L3+ portals are shown + + window.getMinPortalLevelForZoom = function(z) { + // for the further out zoom levels, use the stock intel site detail levels + if (z <= 11) { + return stockIntelDetail[z]; + } + // for the closer zoom levels, stock intel and IITC default is the same. falling back + // in this case allows this plugin to work alongside show-more-portals + return origGetMinPortalLevelForZoom(z); + } + + +}; + +var setup = window.plugin.defaultIntelDetail.setup; + +// PLUGIN END ////////////////////////////////////////////////////////// + +@@PLUGINEND@@ diff --git a/plugins/show-less-portals-zoomed-out.user.js b/plugins/show-less-portals-zoomed-out.user.js index c701f7a7..ddace55d 100644 --- a/plugins/show-less-portals-zoomed-out.user.js +++ b/plugins/show-less-portals-zoomed-out.user.js @@ -1,12 +1,12 @@ // ==UserScript== // @id iitc-plugin-show-less-portals@jonatkins // @name IITC plugin: Show less portals when zoomed out -// @category Tweaks -// @version 0.1.4.@@DATETIMEVERSION@@ +// @category Deleted +// @version 0.2.0.@@DATETIMEVERSION@@ // @namespace https://github.com/jonatkins/ingress-intel-total-conversion // @updateURL @@UPDATEURL@@ // @downloadURL @@DOWNLOADURL@@ -// @description [@@BUILDNAME@@-@@BUILDDATE@@] Decrease the portal detail level used when zoomed out. This can speed up map loading, decrease the amount of data used, and solve excessive request issues. Only applies when zoomed out to show no closer than L3 portals. May stop display of the smaller links/fields. +// @description [@@BUILDNAME@@-@@BUILDDATE@@] IITC now defaults to showing fewer portals when zoomed out, making this plugin unnecessary // @include https://www.ingress.com/intel* // @include http://www.ingress.com/intel* // @match https://www.ingress.com/intel* @@ -14,46 +14,3 @@ // @grant none // ==/UserScript== -@@PLUGINSTART@@ - -// PLUGIN START //////////////////////////////////////////////////////// - - -// use own namespace for plugin -window.plugin.showLessPortals = function() {}; - -window.plugin.showLessPortals.setup = function() { - - // save the original function - so we can chain to it for levels we don't modify - var origGetPortalDataZoom = window.getPortalDataZoom; - - // replace the window.getPortalDataZoom function - modify behaviour when zoomed close - - window.getPortalDataZoom = function() { - var mapZoom = map.getZoom(); - - // the latest intel site update, as of 2013-10-16, requests a silly number of map tiles at the larger zoom levels - // IITC matches the behaviour by default, but it makes sense to reduce the detail level sooner - - // at the largest scale zooms - move back two levels - if (mapZoom <= 7) { - return Math.max(mapZoom-2,0); - } - - // intermediate zoom levels - move back one - if (mapZoom <= 11) { - return Math.max(mapZoom-1,0); - } - - // otherwise revert to default behaviour - return origGetPortalDataZoom(); - } - - -}; - -var setup = window.plugin.showLessPortals.setup; - -// PLUGIN END ////////////////////////////////////////////////////////// - -@@PLUGINEND@@ diff --git a/plugins/show-more-portals.user.js b/plugins/show-more-portals.user.js index 443e9d09..11cc5d99 100644 --- a/plugins/show-more-portals.user.js +++ b/plugins/show-more-portals.user.js @@ -2,11 +2,11 @@ // @id iitc-plugin-show-more-portals@jonatkins // @name IITC plugin: Show more portals // @category Tweaks -// @version 0.1.5.@@DATETIMEVERSION@@ +// @version 0.1.6.@@DATETIMEVERSION@@ // @namespace https://github.com/jonatkins/ingress-intel-total-conversion // @updateURL @@UPDATEURL@@ // @downloadURL @@DOWNLOADURL@@ -// @description [@@BUILDNAME@@-@@BUILDDATE@@] Boost the detail level of portals shown so that unclaimed portals are visible when normally L1+ portals would be shown, and L2+ are visible when normally L3+ are shown +// @description [@@BUILDNAME@@-@@BUILDDATE@@] Boost the detail level of portals shown so that unclaimed portals are visible when normally L1+ portals would be shown, and L2+ are visible when normally L3+ are shown. Recent protocol changes by Niantic means this no longer sends more requests than the standard intel site, and can mean fewer requests. // @include https://www.ingress.com/intel* // @include http://www.ingress.com/intel* // @match https://www.ingress.com/intel* @@ -25,29 +25,24 @@ window.plugin.showMorePortals = function() {}; window.plugin.showMorePortals.setup = function() { // save the original function - so we can chain to it for levels we don't modify - var origGetPortalDataZoom = window.getPortalDataZoom; + var origGetMinPortalLevelForZoom = window.getMinPortalLevelForZoom; - // replace the window.getPortalDataZoom function - modify behaviour when zoomed close + // replace the window.getMinPortalLevelForZoom function - modify behaviour when L1+ or L3+ portals are shown - window.getPortalDataZoom = function() { - var mapZoom = map.getZoom(); + window.getMinPortalLevelForZoom = function(z) { + var level = origGetMinPortalLevelForZoom(z); // as of 2013-10-16... // the stock site uses the same tile size for both L1+ portals and all portals // therefore, changing the L1+ zoom levels into all portals zoom level is not unfriendly to the servers + // and the same applies for L2+ and L3+ detail levels // (in some ways it's nicer, as IITC caches better) - if (mapZoom >= 15) { - return 17; - } - // and, the same scale for L2+ and L3+ portals. again, forcing the level down isn't unfriendly to the servers - // (ditto on the caching) - if (mapZoom >= 12) { - return 13; - } + if (level == 1) level = 0; + if (level == 3) level = 2; - return origGetPortalDataZoom(); + return level; } From 01cfda107778e74bae294792e63b8d0aed99a018 Mon Sep 17 00:00:00 2001 From: Jon Atkins Date: Sun, 24 Nov 2013 21:17:10 +0000 Subject: [PATCH 8/8] bumpped jquery + jqueryui versions. now the stock intel site no longer includes any version of these there are no advantages to non-current releases --- code/boot.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/boot.js b/code/boot.js index f9953a46..f359934b 100644 --- a/code/boot.js +++ b/code/boot.js @@ -600,8 +600,8 @@ try { console.log('Loading included JS now'); } catch(e) {} try { console.log('done loading included JS'); } catch(e) {} //note: no protocol - so uses http or https as used on the current page -var JQUERY = '//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js'; -var JQUERYUI = '//ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/jquery-ui.min.js'; +var JQUERY = '//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js'; +var JQUERYUI = '//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js'; // after all scripts have loaded, boot the actual app load(JQUERY).then(JQUERYUI).thenRun(boot);