Last active
October 18, 2020 14:46
-
-
Save atomgomba/3a03ed4a10e5709f98a5 to your computer and use it in GitHub Desktop.
IITC plugin: Export visible portals to JSON
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
// ==UserScript== | |
// @id iitc-plugin-portal-export | |
// @name IITC plugin: Export visible portals to JSON | |
// @category Info | |
// @version 0.1.0.@@DATETIMEVERSION@@ | |
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion | |
// @updateURL @@UPDATEURL@@ | |
// @downloadURL @@DOWNLOADURL@@ | |
// @description [@@BUILDNAME@@-@@BUILDDATE@@] Display a list of all localized portals by level and faction. | |
// @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== | |
// PLUGIN START //////////////////////////////////////////////////////// | |
// use own namespace for plugin | |
window.plugin.portalexport = {}; | |
window.plugin.portalexport.export = function () { | |
var data = [], | |
displayBounds = map.getBounds(); | |
$.each(window.portals, function(i, portal) { | |
var loc = portal.getLatLng(); | |
if(!displayBounds.contains(loc)) return true; | |
data.push({ | |
"guid": portal.options.guid, | |
"location": { | |
"lat": loc.lat, | |
"lng": loc.lng | |
} | |
}); | |
}); | |
var json = JSON.stringify(data); | |
console.log("Exported: " + data.length, json); | |
window.exportedPortals = json; | |
} | |
var setup = function() { | |
$('#toolbox').append(' <a onclick="window.plugin.portalexport.export()" title="Export visible portals to JSON">To JSON</a>'); | |
}; | |
if(!window.bootPlugins) { | |
window.bootPlugins = []; | |
} | |
window.bootPlugins.push(setup); | |
if(window.iitcLoaded && typeof setup === 'function') { | |
setup(); | |
} | |
// PLUGIN END ////////////////////////////////////////////////////////// |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment