// ==UserScript== // @id ingress-intel-total-conversion@Hzllaga // @name IITC: Ingress intel map total conversion // @version 0.26.0.20181111 // @namespace https://github.com/jonatkins/ingress-intel-total-conversion // @updateURL https://raw.githubusercontent.com/Hzllaga/IITC_TW/master/total-conversion-build.user.js // @downloadURL https://raw.githubusercontent.com/Hzllaga/IITC_TW/master/total-conversion-build.user.js // @description [Release-2018-06-17-164403] Total conversion for the ingress intel map. // @include https://*.ingress.com/intel* // @include http://*.ingress.com/intel* // @match https://*.ingress.com/intel* // @match http://*.ingress.com/intel* // @include https://*.ingress.com/mission/* // @include http://*.ingress.com/mission/* // @match https://*.ingress.com/mission/* // @match http://*.ingress.com/mission/* // @grant none // ==/UserScript== // REPLACE ORIG SITE /////////////////////////////////////////////////// if(document.getElementsByTagName('html')[0].getAttribute('itemscope') != null) throw('Ingress Intel 網站關閉了, 不是 IITC userscript 的問題.'); window.iitcBuildDate = '2017-02-10-164403'; // disable vanilla JS window.onload = function() {}; document.body.onload = function() {}; //originally code here parsed the '; var gmaps = 'Google Maps'; var bingmaps = 'Bing Maps'; var osm = 'OpenStreetMap'; var latLng = '<' + lat + ',' + lng +'>'; dialog({ html: '
' + qrcode + script + gmaps + '; ' + bingmaps + '; ' + osm + '
' + latLng + '
', title: name, id: 'poslinks' }); } } window.isTouchDevice = function() { return 'ontouchstart' in window // works on most browsers || 'onmsgesturechange' in window; // works on ie10 }; window.androidCopy = function(text) { if(typeof android === 'undefined' || !android || !android.copy) return true; // i.e. execute other actions else android.copy(text); return false; } window.androidPermalink = function() { if(typeof android === 'undefined' || !android || !android.intentPosLink) return true; // i.e. execute other actions var center = map.getCenter(); android.intentPosLink(center.lat, center.lng, map.getZoom(), "Selected map view", false); return false; } window.getMinPortalLevel = function() { var z = map.getZoom(); z = getDataZoomForMapZoom(z); return getMapZoomTileParameters(z).level; } // returns number of pixels left to scroll down before reaching the // bottom. Works similar to the native scrollTop function. window.scrollBottom = function(elm) { if(typeof elm === 'string') elm = $(elm); return elm.get(0).scrollHeight - elm.innerHeight() - elm.scrollTop(); } window.zoomToAndShowPortal = function(guid, latlng) { map.setView(latlng, 17); // if the data is available, render it immediately. Otherwise defer // until it becomes available. if(window.portals[guid]) renderPortalDetails(guid); else urlPortal = guid; } window.selectPortalByLatLng = function(lat, lng) { if(lng === undefined && lat instanceof Array) { lng = lat[1]; lat = lat[0]; } else if(lng === undefined && lat instanceof L.LatLng) { lng = lat.lng; lat = lat.lat; } for(var guid in window.portals) { var latlng = window.portals[guid].getLatLng(); if(latlng.lat == lat && latlng.lng == lng) { renderPortalDetails(guid); return; } } // not currently visible urlPortalLL = [lat, lng]; map.setView(urlPortalLL, 17); }; String.prototype.capitalize = function() { return this.charAt(0).toUpperCase() + this.slice(1).toLowerCase(); } // http://stackoverflow.com/a/646643/1684530 by Bergi and CMS if (typeof String.prototype.startsWith !== 'function') { String.prototype.startsWith = function (str){ return this.slice(0, str.length) === str; }; } // escape a javascript string, so quotes and backslashes are escaped with a backslash // (for strings passed as parameters to html onclick="..." for example) window.escapeJavascriptString = function(str) { return (str+'').replace(/[\\"']/g,'\\$&'); } //escape special characters, such as tags window.escapeHtmlSpecialChars = function(str) { var div = document.createElement(div); var text = document.createTextNode(str); div.appendChild(text); return div.innerHTML; } window.prettyEnergy = function(nrg) { return nrg> 1000 ? Math.round(nrg/1000) + ' k': nrg; } window.setPermaLink = function(elm) { var c = map.getCenter(); var lat = Math.round(c.lat*1E6)/1E6; var lng = Math.round(c.lng*1E6)/1E6; var qry = 'll='+lat+','+lng+'&z=' + map.getZoom(); $(elm).attr('href', '/intel?' + qry); } window.uniqueArray = function(arr) { return $.grep(arr, function(v, i) { return $.inArray(v, arr) === i; }); } window.genFourColumnTable = function(blocks) { var t = $.map(blocks, function(detail, index) { if(!detail) return ''; var title = detail[2] ? ' title="'+escapeHtmlSpecialChars(detail[2]) + '"' : ''; if(index % 2 === 0) return ''+detail[1]+''+detail[0]+''; else return ' '+detail[0]+''+detail[1]+''; }).join(''); if(t.length % 2 === 1) t + ''; return t; } // converts given text with newlines (\n) and tabs (\t) to a HTML // table automatically. window.convertTextToTableMagic = function(text) { // check if it should be converted to a table if(!text.match(/\t/)) return text.replace(/\n/g, '
'); var data = []; var columnCount = 0; // parse data var rows = text.split('\n'); $.each(rows, function(i, row) { data[i] = row.split('\t'); if(data[i].length > columnCount) columnCount = data[i].length; }); // build the table var table = ''; $.each(data, function(i, row) { table += ''; $.each(data[i], function(k, cell) { var attributes = ''; if(k === 0 && data[i].length < columnCount) { attributes = ' colspan="'+(columnCount - data[i].length + 1)+'"'; } table += ''+cell+''; }); table += ''; }); table += '
'; return table; } // Given 3 sets of points in an array[3]{lat, lng} returns the area of the triangle window.calcTriArea = function(p) { return Math.abs((p[0].lat*(p[1].lng-p[2].lng)+p[1].lat*(p[2].lng-p[0].lng)+p[2].lat*(p[0].lng-p[1].lng))/2); } // Update layerGroups display status to window.overlayStatus and localStorage 'ingress.intelmap.layergroupdisplayed' window.updateDisplayedLayerGroup = function(name, display) { overlayStatus[name] = display; localStorage['ingress.intelmap.layergroupdisplayed'] = JSON.stringify(overlayStatus); } // Read layerGroup status from window.overlayStatus if it was added to map, // read from cookie if it has not added to map yet. // return 'defaultDisplay' if both overlayStatus and cookie didn't have the record window.isLayerGroupDisplayed = function(name, defaultDisplay) { if(typeof(overlayStatus[name]) !== 'undefined') return overlayStatus[name]; convertCookieToLocalStorage('ingress.intelmap.layergroupdisplayed'); var layersJSON = localStorage['ingress.intelmap.layergroupdisplayed']; if(!layersJSON) return defaultDisplay; var layers = JSON.parse(layersJSON); // keep latest overlayStatus overlayStatus = $.extend(layers, overlayStatus); if(typeof(overlayStatus[name]) === 'undefined') return defaultDisplay; return overlayStatus[name]; } window.addLayerGroup = function(name, layerGroup, defaultDisplay) { if (defaultDisplay === undefined) defaultDisplay = true; if(isLayerGroupDisplayed(name, defaultDisplay)) map.addLayer(layerGroup); layerChooser.addOverlay(layerGroup, name); } window.removeLayerGroup = function(layerGroup) { if(!layerChooser._layers[layerGroup._leaflet_id]) throw('Layer was not found'); // removing the layer will set it's default visibility to false (store if layer gets added again) var name = layerChooser._layers[layerGroup._leaflet_id].name; var enabled = isLayerGroupDisplayed(name); map.removeLayer(layerGroup); layerChooser.removeLayer(layerGroup); updateDisplayedLayerGroup(name, enabled); }; window.clampLat = function(lat) { // the map projection used does not handle above approx +- 85 degrees north/south of the equator if (lat > 85.051128) lat = 85.051128; else if (lat < -85.051128) lat = -85.051128; return lat; } window.clampLng = function(lng) { if (lng > 179.999999) lng = 179.999999; else if (lng < -180.0) lng = -180.0; return lng; } window.clampLatLng = function(latlng) { return new L.LatLng ( clampLat(latlng.lat), clampLng(latlng.lng) ); } window.clampLatLngBounds = function(bounds) { return new L.LatLngBounds ( clampLatLng(bounds.getSouthWest()), clampLatLng(bounds.getNorthEast()) ); } window.getGenericMarkerSvg = function(color) { var markerTemplate = '\n\n\n \n \n \n\n \n\n'; return markerTemplate.replace(/%COLOR%/g, color); } window.getGenericMarkerIcon = function(color,className) { return L.divIcon({ iconSize: new L.Point(25, 41), iconAnchor: new L.Point(12, 41), html: getGenericMarkerSvg(color), className: className || 'leaflet-iitc-divicon-generic-marker' }); } window.createGenericMarker = function(ll,color,options) { options = options || {}; var markerOpt = $.extend({ icon: getGenericMarkerIcon(color || '#a24ac3') }, options); return L.marker(ll, markerOpt); } // Fix Leaflet: handle touchcancel events in Draggable L.Draggable.prototype._onDownOrig = L.Draggable.prototype._onDown; L.Draggable.prototype._onDown = function(e) { L.Draggable.prototype._onDownOrig.apply(this, arguments); if(e.type === "touchstart") { L.DomEvent.on(document, "touchcancel", this._onUp, this); } } } // end of wrapper // inject code into site context var script = document.createElement('script'); var info = { buildName: 'Release', dateTimeVersion: '20170210.164403' }; if (this.GM_info && this.GM_info.script) info.script = { version: GM_info.script.version, name: GM_info.script.name, description: GM_info.script.description }; script.appendChild(document.createTextNode('('+ wrapper +')('+JSON.stringify(info)+');')); (document.body || document.head || document.documentElement).appendChild(script);