-
-
Save Der-Schubi/967a7fceed8c360a6b71 to your computer and use it in GitHub Desktop.
This file contains hidden or 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-ingressdualmap-exporter@OllieTerrance | |
| // @name IITC plugin: Ingress Dual Map Exporter | |
| // @category Keys | |
| // @version 0.0.0.1 | |
| // @namespace https://github.com/jonatkins/ingress-intel-total-conversion | |
| // @description Exports portals currently in view as a CSV list for use with Ingress Dual Map. | |
| // @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== | |
| function wrapper() { | |
| // in case IITC is not available yet, define the base plugin object | |
| if (typeof window.plugin !== "function") { | |
| window.plugin = function() {}; | |
| } | |
| // base context for plugin | |
| window.plugin.ingressdualmap = function() {}; | |
| var self = window.plugin.ingressdualmap; | |
| // custom dialog wrapper with more flexibility | |
| self.gen = function gen() { | |
| var o = []; | |
| for (var x in window.portals) { | |
| var p = window.portals[x]; | |
| o.push(p._latlng.lng + "," + p._latlng.lat + "," + p.options.data.title.replace(/\"/g, "\"\"")); | |
| } | |
| var dialog = window.dialog({ | |
| title: "Ingress Dual Map: CSV export", | |
| // body must be wrapped in an outer tag (e.g. <div>content</div>) | |
| html: '<span>Save the CSV data below to a text file and place it on your phone at <code>/sdcard/IngressDualMap/</code>.</span>' | |
| + '<textarea id="idmCSVExport" rows="30" style="width: 100%;"></textarea>' | |
| }).parent(); | |
| $(".ui-dialog-buttonpane", dialog).remove(); | |
| dialog.css("width", "600px") | |
| .css("top", ($(window).height() - dialog.height()) / 2) | |
| .css("left", ($(window).width() - dialog.width()) / 2); | |
| $("#idmCSVExport").val(o.join("\n")); | |
| return dialog; | |
| } | |
| // setup function called by IITC | |
| self.setup = function init() { | |
| // add controls to toolbox | |
| var link = $("<a onclick=\"window.plugin.ingressdualmap.gen();\" title=\"Generate a CSV list of portals and locations for use with Ingress Dual Map.\">IDM Export</a>"); | |
| $("#toolbox").append(link); | |
| // delete setup to ensure init can't be run again | |
| delete self.setup; | |
| } | |
| // IITC plugin setup | |
| if (window.iitcLoaded && typeof self.setup === "function") { | |
| self.setup(); | |
| } else if (window.bootPlugins) { | |
| window.bootPlugins.push(self.setup); | |
| } else { | |
| window.bootPlugins = [self.setup]; | |
| } | |
| } | |
| // inject plugin into page | |
| var script = document.createElement("script"); | |
| script.appendChild(document.createTextNode("(" + wrapper + ")();")); | |
| (document.body || document.head || document.documentElement).appendChild(script); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment