Advertisement
Guest User

Untitled

a guest
Mar 28th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @id             iitc-plugin-CSV@pad
  3. // @name           IITC plugin: Ingress CSV Exporter
  4. // @category       Keys
  5. // @version        1.0.20150105.02
  6. // @namespace      https://github.com/jonatkins/ingress-intel-total-conversion
  7. // @description    Exports portals currently in view for use XMyHide
  8. // @include        https://www.ingress.com/intel*
  9. // @include        http://www.ingress.com/intel*
  10. // @match          https://www.ingress.com/intel*
  11. // @match          http://www.ingress.com/intel*
  12. // @grant          none
  13. // ==/UserScript==
  14.  
  15. function wrapper() {
  16.     // in case IITC is not available yet, define the base plugin object
  17.     if (typeof window.plugin !== "function") {
  18.         window.plugin = function() {};
  19.     }
  20.  
  21.     // base context for plugin
  22.     window.plugin.ingressCSVexporter = function() {};
  23.     var self = window.plugin.ingressCSVexporter;
  24.     // custom dialog wrapper with more flexibility
  25.    
  26.     self.portalInScreen = function portalInScreen( p ) {
  27.         return map.getBounds().contains(p.getLatLng());
  28.     }
  29.    
  30.     self.gen = function gen() {
  31.         var o = [];
  32.         var inBounds = function( portal ) {
  33.             return self.portalInScreen( portal );
  34.         };
  35.         var string = "Portal selection based on screen boundaries.";
  36.         for (var x in window.portals) {
  37.             var p = window.portals[x];
  38.             if (inBounds(p)) {
  39.                 o.push(p.options.data.title + 'µ' +p._latlng.lat+'µ'+p._latlng.lng+'µ'+p.options.guid+'µ');
  40.             }
  41.         }
  42.         var dialog = window.dialog({
  43.             title: "Ingress CSV Exporter",
  44.             // body must be wrapped in an outer tag (e.g. <div>content</div>)
  45.             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>'
  46.         }).parent();
  47.  
  48.         $(".ui-dialog-buttonpane", dialog).remove();
  49.         dialog.css("width", "600px")
  50.             .css("top", ($(window).height() - dialog.height()) / 2)
  51.             .css("left", ($(window).width() - dialog.width()) / 2);
  52.         $("#idCSVexporter").val(o.join("\n"));
  53.         return dialog;
  54.     };
  55.     // setup function called by IITC
  56.     self.setup = function init() {
  57.         // add controls to toolbox
  58.         var link = $("<a onclick=\"window.plugin.ingressCSVexporter.gen();\" title=\"Generate CSV list of portals and locations.\">CSV Export</a>");
  59.         $("#toolbox").append(link);
  60.         // delete setup to ensure init can't be run again
  61.         delete self.setup;
  62.     };
  63.     // IITC plugin setup
  64.     if (window.iitcLoaded && typeof self.setup === "function") {
  65.         self.setup();
  66.     } else if (window.bootPlugins) {
  67.         window.bootPlugins.push(self.setup);
  68.     } else {
  69.         window.bootPlugins = [self.setup];
  70.     }
  71. }
  72. // inject plugin into page
  73. var script = document.createElement("script");
  74. script.appendChild(document.createTextNode("(" + wrapper + ")();"));
  75. (document.body || document.head || document.documentElement).appendChild(script);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement