forked from IITC-CE/ingress-intel-total-conversion
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into areasUnderAttack
- Loading branch information
Showing
5 changed files
with
70 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// ==UserScript== | ||
// @id iitc-plugin-cache-details-on-map@jonatkins | ||
// @name IITC plugin: Cache viewed portal details and always show them on the map | ||
// @category Cache | ||
// @version 0.1.0.@@DATETIMEVERSION@@ | ||
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion | ||
// @updateURL @@UPDATEURL@@ | ||
// @downloadURL @@DOWNLOADURL@@ | ||
// @description [@@BUILDNAME@@-@@BUILDDATE@@] Cache the details of recently viewed portals and use this to populate the map when possible | ||
// @include https://www.ingress.com/intel* | ||
// @include http://www.ingress.com/intel* | ||
// @match https://www.ingress.com/intel* | ||
// @match http://www.ingress.com/intel* | ||
// @include https://www.ingress.com/mission/* | ||
// @include http://www.ingress.com/mission/* | ||
// @match https://www.ingress.com/mission/* | ||
// @match http://www.ingress.com/mission/* | ||
// @grant none | ||
// ==/UserScript== | ||
|
||
@@PLUGINSTART@@ | ||
|
||
// PLUGIN START //////////////////////////////////////////////////////// | ||
|
||
|
||
// use own namespace for plugin | ||
window.plugin.cachePortalDetailsOnMap = function() {}; | ||
|
||
window.plugin.cachePortalDetailsOnMap.MAX_AGE = 12*60*60; //12 hours max age for cached data | ||
|
||
window.plugin.cachePortalDetailsOnMap.portalDetailLoaded = function(data) { | ||
window.plugin.cachePortalDetailsOnMap.cache[data.guid] = { loadtime: Date.now(), ent: data.ent }; | ||
}; | ||
|
||
window.plugin.cachePortalDetailsOnMap.entityInject = function(data) { | ||
var maxAge = Date.now() - window.plugin.cachePortalDetailsOnMap.MAX_AGE*1000; | ||
|
||
var ents = []; | ||
for (var guid in window.plugin.cachePortalDetailsOnMap.cache) { | ||
if (window.plugin.cachePortalDetailsOnMap.cache[guid].loadtime < maxAge) { | ||
window.plugin.cachePortalDetailsOnMap.cache.delete(guid); | ||
} else { | ||
ents.push(window.plugin.cachePortalDetailsOnMap.cache[guid].ent); | ||
} | ||
} | ||
data.callback(ents); | ||
}; | ||
|
||
|
||
window.plugin.cachePortalDetailsOnMap.setup = function() { | ||
|
||
window.plugin.cachePortalDetailsOnMap.cache = {}; | ||
|
||
addHook('portalDetailLoaded', window.plugin.cachePortalDetailsOnMap.portalDetailLoaded); | ||
addHook('mapDataEntityInject', window.plugin.cachePortalDetailsOnMap.entityInject); | ||
}; | ||
|
||
var setup = window.plugin.cachePortalDetailsOnMap.setup; | ||
|
||
// PLUGIN END ////////////////////////////////////////////////////////// | ||
|
||
@@PLUGINEND@@ |