Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @id iitc-plugin-CSV@pad
- // @name IITC plugin: Ingress CSV Exporter
- // @category Keys
- // @version 1.0.20150105.02
- // @namespace https://github.com/jonatkins/ingress-intel-total-conversion
- // @description Exports portals currently in view for use XMyHide
- // @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.ingressCSVexporter = function() {};
- var self = window.plugin.ingressCSVexporter;
- // custom dialog wrapper with more flexibility
- self.portalInScreen = function portalInScreen( p ) {
- return map.getBounds().contains(p.getLatLng());
- }
- self.gen = function gen() {
- var o = [];
- var inBounds = function( portal ) {
- return self.portalInScreen( portal );
- };
- var string = "Portal selection based on screen boundaries.";
- for (var x in window.portals) {
- var p = window.portals[x];
- if (inBounds(p)) {
- o.push(p.options.data.title + 'µ' +p._latlng.lat+'µ'+p._latlng.lng+'µ'+p.options.guid+'µ');
- }
- }
- var dialog = window.dialog({
- title: "Ingress CSV Exporter",
- // body must be wrapped in an outer tag (e.g. <div>content</div>)
- html: '<span>Save the data below to a CSV file and import it on <code> https://www.google.com/maps/d </code>.</span><textarea id="idCSVexporter" 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);
- $("#idCSVexporter").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.ingressCSVexporter.gen();\" title=\"Generate CSV list of portals and locations.\">CSV 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);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement