├── README.md └── multi_export.user.js /README.md: -------------------------------------------------------------------------------- 1 | # Ingress IITC Portal Multi Export 2 | This is a plugin to export portals to different formats. 3 | 4 | ## Features 5 | At the moment we support export of all portals in the current view, bookmarked portals by folders and portals inside a polygon 6 | 7 | As formats we currently got: GPX, CSV and export for Maxfield 8 | 9 | (check out http://www.ingress-maxfield.com/ for information about Maxfield) 10 | 11 | ## Requirements 12 | IITC needs to be installed. See this page for information: http://iitc.jonatkins.com/ 13 | 14 | Additionally the "Bookmarks for maps and portals" and "Keys" plugin are needed for full functionality but the plugin also runs without them 15 | 16 | ## Install 17 | For installation just click on this link: 18 | 19 | https://github.com/modkin/Ingress-IITC-Multi-Export/raw/master/multi_export.user.js 20 | 21 | Normally Tampermonkey (or the extension you are using for JS) should recognize the format and ask to install the plugin 22 | -------------------------------------------------------------------------------- /multi_export.user.js: -------------------------------------------------------------------------------- 1 | // ==UserScript== 2 | // @id iitc-plugin-portal-multi-export 3 | // @name IITC plugin: Portal Multi Export 4 | // @category Misc 5 | // @version 0.11 6 | // @namespace https://github.com/jonatkins/ingress-intel-total-conversion 7 | // @updateURL https://iitc.aradiv.de/plugin/37/multi_export.meta.js 8 | // @downloadURL https://iitc.aradiv.de/plugin/37/multi_export.user.js 9 | // @description Export portals from bookmarks, current view or polygon 10 | // @include http*://*intel.ingress.com/* 11 | // @match http*://*intel.ingress.com/* 12 | // @grant none 13 | // ==/UserScript== 14 | 15 | function wrapper(plugin_info) { 16 | // ensure plugin framework is there, even if iitc is not yet loaded 17 | if(typeof window.plugin !== 'function') window.plugin = function() {}; 18 | 19 | window.plugin.multiexport = function() {}; 20 | 21 | 22 | /*********** MENUE ************************************************************/ 23 | window.plugin.multiexport.createmenu = function() { 24 | var htmldata = "

Export from Current View , inside Polygon or Bookmarks to various formats by clicking the corresponding cell in the table.

" 25 | + "

Please note that the first drawn polygon will be choosen to export from.

" 26 | + "

BE AWARE: If you choose BKMRK all portals will be added to the default bookmarks folder.

" 27 | + "" 28 | + "" 29 | + "" 30 | + "" 31 | + "" 32 | + "" 33 | + ""; 34 | if(plugin.bookmarks){ 35 | htmldata += ""; 36 | } 37 | htmldata += ""; 38 | if(plugin.drawTools) { 39 | htmldata += "" 40 | + "" 41 | + "" 42 | + "" 43 | + "" 44 | + ""; 45 | if(plugin.bookmarks){ 46 | htmldata += ""; 47 | } 48 | htmldata += ""; 49 | } 50 | if(plugin.bookmarks) { 51 | htmldata += "" 52 | + "" 53 | + "" 54 | + "" 55 | + "" 56 | + "" 57 | + ""; 58 | } 59 | 60 | window.dialog({ 61 | title: "Multi Export Options", 62 | html: htmldata, 63 | dialogClass: 'ui-dialog-multiExport' 64 | }); 65 | 66 | }; 67 | 68 | /*********** HELPER FUNCTION ****************************************************/ 69 | window.plugin.multiexport.portalinpolygon = function(portal,LatLngsObjectsArray) 70 | { 71 | var portalCoords = portal.split(','); 72 | 73 | var x = portalCoords[0], y = portalCoords[1]; 74 | 75 | var inside = false; 76 | for (var i = 0, j = LatLngsObjectsArray.length - 1; i < LatLngsObjectsArray.length; j = i++) { 77 | var xi = LatLngsObjectsArray[i]['lat'], yi = LatLngsObjectsArray[i]['lng']; 78 | var xj = LatLngsObjectsArray[j]['lat'], yj = LatLngsObjectsArray[j]['lng']; 79 | 80 | var intersect = ((yi > y) != (yj > y)) 81 | && (x < (xj - xi) * (y - yi) / (yj - yi) + xi); 82 | if (intersect) inside = !inside; 83 | } 84 | 85 | return inside; 86 | }; 87 | 88 | /*********** BOOKMARK MENUE ****************************************************/ 89 | window.plugin.multiexport.bkmrkmenu = function(type) { 90 | var htmlcontent = '
'; 91 | var bookmarks = JSON.parse(localStorage[plugin.bookmarks.KEY_STORAGE]); 92 | for(var i in bookmarks.portals){ 93 | htmlcontent += "" + bookmarks.portals[i].label + ""; 95 | } 96 | htmlcontent += '
'; 97 | window.dialog({ 98 | title: "Multi Export Options", 99 | html: htmlcontent 100 | }).parent(); 101 | }; 102 | 103 | /*********** ABSTRACT EXPORT FUNCTION ******************************************/ 104 | window.plugin.multiexport.export = function(type, source, bkmrkFolder) 105 | { 106 | console.log(type); 107 | var o = []; 108 | var portals; 109 | var sourceTitle; 110 | var windowTitle; 111 | if(type === 'MF') 112 | { 113 | windowTitle = 'Maxfield Export'; 114 | } else { 115 | windowTitle = type + ' Export'; 116 | } 117 | if(localStorage['plugin-draw-tools-layer']) 118 | { 119 | var drawLayer = JSON.parse(localStorage['plugin-draw-tools-layer']); 120 | } 121 | if(source == 'BKMRK') { 122 | var bookmarks = JSON.parse(localStorage[plugin.bookmarks.KEY_STORAGE]); 123 | portals = bookmarks.portals[bkmrkFolder].bkmrk; 124 | } else 125 | { 126 | portals = window.portals; 127 | } 128 | switch(type){ 129 | case 'GPX': 130 | o.push(""); 131 | o.push(""); 137 | o.push("" 138 | +"" 139 | +"" 140 | ); 141 | break; 142 | case 'JSON': 143 | o.push("["); 144 | } 145 | for(var i in portals){ 146 | var keys = 0; 147 | if(source === 'BKMRK') 148 | { 149 | var name = bookmarks.portals[bkmrkFolder].bkmrk[i].label; 150 | var latlng = bookmarks.portals[bkmrkFolder].bkmrk[i].latlng; 151 | if(plugin.keys) 152 | { 153 | keys = plugin.keys.keys[bookmarks.portals[bkmrkFolder].bkmrk[i].guid]; 154 | } 155 | }else 156 | { 157 | var p = window.portals[i]; 158 | var name = p.options.data.title; 159 | var guid = p.options.guid; 160 | var latlng = p._latlng.lat + ',' + p._latlng.lng; 161 | var pimage = p.options.data.image; 162 | if(source === 'VIEWFIL') 163 | { 164 | var portalInPolygon = false; 165 | for(var dl in drawLayer){ 166 | if(drawLayer[dl].type === 'polygon'){ 167 | if(window.plugin.multiexport.portalinpolygon(latlng,drawLayer[dl].latLngs)){ 168 | portalInPolygon = true; 169 | break; 170 | } 171 | } 172 | } 173 | if (!portalInPolygon){ 174 | continue; 175 | } 176 | } 177 | 178 | if(plugin.keys){ 179 | keys = plugin.keys.keys[i]; 180 | } 181 | var b = window.map.getBounds(); 182 | // skip if not currently visible 183 | if (p._latlng.lat < b._southWest.lat || p._latlng.lng < b._southWest.lng || p._latlng.lat > b._northEast.lat || p._latlng.lng > b._northEast.lng) continue; 184 | } 185 | var lat = latlng.split(',')[0]; 186 | var lng = latlng.split(',')[1]; 187 | 188 | var iitcLink = "https://intel.ingress.com/intel?ll=" + latlng + "&z=16&pll=" + latlng; 189 | var gmapLink = "https://google.com/maps/place/" + latlng; 190 | 191 | switch(type){ 192 | case 'MF': 193 | o.push(name + ";" + iitcLink + ";" + keys); 194 | break; 195 | case 'CSV': 196 | o.push(guid + "," + JSON.stringify(name) + "," + lat + "," + lng 197 | ); 198 | break; 199 | case 'TSV': 200 | o.push(guid + "\t" + JSON.stringify(name) + "\t" + lat + "\t" + lng 201 | + "\t" + iitcLink + "\t" + gmapLink + "\t" + pimage 202 | ); 203 | break; 204 | case 'GPX': 205 | o.push("" 206 | +"" + name + "" 207 | +"\n\n" + 208 | + "Intel Link: " + iitcLink + "\n" 209 | + "GMap: " + gmapLink + "\n" 210 | + "guid: " + guid + "\n" 211 | + "image: " + pimage + "\n" 212 | +"\n" 213 | +"\n" 214 | +"" 215 | ); 216 | break; 217 | case 'JSON': 218 | var obj = { guid: guid, 219 | title: name, 220 | coordinates: {lat: lat, 221 | lng: lng}, 222 | link: { intel: iitcLink, gmap: gmapLink }, 223 | image: pimage 224 | }; 225 | o.push(JSON.stringify(obj) + ","); 226 | break; 227 | case 'BKMRK': 228 | if(!window.plugin.bookmarks.findByGuid(guid)){ 229 | plugin.bookmarks.addPortalBookmark(guid, latlng, name); 230 | } 231 | break; 232 | } 233 | } 234 | if(type == 'BKMRK'){ 235 | return; 236 | } 237 | var ostr = o.join("\n"); 238 | switch(type){ 239 | case 'GPX': 240 | ostr += ""; 241 | ostr = ostr.replace(/[&]/g, ''); 242 | break; 243 | case 'JSON': 244 | //remove the last "," 245 | if (ostr.length > 1) { 246 | ostr = ostr.slice(0, -1); 247 | } 248 | ostr += "]"; 249 | break; 250 | } 251 | 252 | var dialog = window.dialog({ 253 | title: windowTitle, 254 | dialogClass: 'ui-dialog-maxfieldexport', 255 | html: '' 256 | + '

Select all

' 257 | }).parent(); 258 | 259 | dialog.css("width", 630).css({ 260 | "top": ($(window).height() - dialog.height()) / 2, 261 | "left": ($(window).width() - dialog.width()) / 2 262 | }); 263 | 264 | $("#idmExport").val(ostr); 265 | }; 266 | 267 | 268 | /*********** PLUGIN SETUP *****************************************************/ 269 | // setup function called by IITC 270 | var setup = function() { 271 | $("#toolbox").append("Multi Export"); 272 | $('head').append(''); 278 | 279 | }; 280 | 281 | setup.info = plugin_info; //add the script info data to the function as a property 282 | if(!window.bootPlugins) window.bootPlugins = []; 283 | window.bootPlugins.push(setup); 284 | // if IITC has already booted, immediately run the 'setup' function 285 | if(window.iitcLoaded && typeof setup === 'function') setup(); 286 | } // wrapper end 287 | // inject code into site context 288 | var script = document.createElement('script'); 289 | var info = {}; 290 | if (typeof GM_info !== 'undefined' && GM_info && GM_info.script) info.script = { version: GM_info.script.version, name: GM_info.script.name, description: GM_info.script.description }; 291 | script.appendChild(document.createTextNode('('+ wrapper +')('+JSON.stringify(info)+');')); 292 | (document.body || document.head || document.documentElement).appendChild(script); 293 | --------------------------------------------------------------------------------
CSV TSV GPX Maxfield JSON BKMRK
Current View XXX XXX XXX XXX XXX XXX
Polygon XXX XXX XXX XXX XXX XXX
Bookmarks XXX XXX XXX XXX XXX