Merge branch 'gh-pages' of https://github.com/breunigs/ingress-intel-total-conversion into gh-pages
This commit is contained in:
45
main.js
45
main.js
@ -1,7 +1,7 @@
|
||||
// ==UserScript==
|
||||
// @id ingress-intel-total-conversion@breunigs
|
||||
// @name intel map total conversion
|
||||
// @version 0.3-@@BUILDDATE@@
|
||||
// @version 0.4-@@BUILDDATE@@
|
||||
// @namespace https://github.com/breunigs/ingress-intel-total-conversion
|
||||
// @updateURL https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/total-conversion-build.user.js
|
||||
// @downloadURL https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/total-conversion-build.user.js
|
||||
@ -28,6 +28,19 @@ for(var x in scr) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if(!d) {
|
||||
// page doesn’t have a script tag with player information.
|
||||
if(document.getElementById('header_email')) {
|
||||
// however, we are logged in.
|
||||
setTimeout('location.reload();', 10*1000);
|
||||
throw('Page doesn’t have player data, but you are logged in. Reloading in 10s.');
|
||||
}
|
||||
// FIXME: handle nia takedown in progress
|
||||
throw('Couldn’t retrieve player data. Are you logged in?');
|
||||
}
|
||||
|
||||
|
||||
for(var i = 0; i < d.length; i++) {
|
||||
if(!d[i].match('var PLAYER = ')) continue;
|
||||
eval(d[i].match(/^var /, 'window.'));
|
||||
@ -36,7 +49,6 @@ for(var i = 0; i < d.length; i++) {
|
||||
// player information is now available in a hash like this:
|
||||
// window.PLAYER = {"ap": "123", "energy": 123, "available_invites": 123, "nickname": "somenick", "team": "ALIENS||RESISTANCE"};
|
||||
|
||||
|
||||
// remove complete page. We only wanted the user-data and the page’s
|
||||
// security context so we can access the API easily. Setup as much as
|
||||
// possible without requiring scripts.
|
||||
@ -50,7 +62,7 @@ document.getElementsByTagName('head')[0].innerHTML = ''
|
||||
document.getElementsByTagName('body')[0].innerHTML = ''
|
||||
+ '<div id="map">Loading, please wait</div>'
|
||||
+ '<div id="chatcontrols" style="display:none">'
|
||||
+ ' <a>expand</a><a>automated</a><a>public</a><a class="active">faction</a>'
|
||||
+ ' <a>◢◣</a><a>automated</a><a>public</a><a class="active">faction</a>'
|
||||
+ '</div>'
|
||||
+ '<div id="chat" style="display:none">'
|
||||
+ ' <div id="chatfaction"></div>'
|
||||
@ -58,6 +70,7 @@ document.getElementsByTagName('body')[0].innerHTML = ''
|
||||
+ ' <div id="chatautomated"></div>'
|
||||
+ '</div>'
|
||||
+ '<form id="chatinput" style="display:none"><time></time><span>tell faction:</span><input type="text"/></form>'
|
||||
+ '<a id="sidebartoggle">◣<br>◤</a>'
|
||||
+ '<div id="scrollwrapper">' // enable scrolling for small screens
|
||||
+ ' <div id="sidebar" style="display: none">'
|
||||
+ ' <div id="playerstat">t</div>'
|
||||
@ -65,9 +78,11 @@ document.getElementsByTagName('body')[0].innerHTML = ''
|
||||
+ ' <input id="geosearch" placeholder="Search location…" type="text"/>'
|
||||
+ ' <div id="portaldetails"></div>'
|
||||
+ ' <input id="redeem" placeholder="Redeem code…" type="text"/>'
|
||||
+ ' <div id="updatestatus"></div>'
|
||||
+ ' </div>';
|
||||
+ '</div>';
|
||||
+ ' <div id="toolbox"><a onmouseover="setPermaLink(this)">permalink</a></div>'
|
||||
+ ' <div id="spacer"></div>'
|
||||
+ ' </div>'
|
||||
+ '</div>'
|
||||
+ '<div id="updatestatus"></div>';
|
||||
|
||||
// putting everything in a wrapper function that in turn is placed in a
|
||||
// script tag on the website allows us to execute in the site’s context
|
||||
@ -114,6 +129,9 @@ var MAX_DRAWN_FIELDS = 200;
|
||||
var COLOR_SELECTED_PORTAL = '#f00';
|
||||
var COLORS = ['#FFCE00', '#0088FF', '#03FE03']; // none, res, enl
|
||||
var COLORS_LVL = ['#000', '#FECE5A', '#FFA630', '#FF7315', '#E40000', '#FD2992', '#EB26CD', '#C124E0', '#9627F4'];
|
||||
var COLORS_MOD = {VERY_RARE: '#F78AF6', RARE: '#AD8AFF', COMMON: '#84FBBD'};
|
||||
|
||||
|
||||
// circles around a selected portal that show from where you can hack
|
||||
// it and how far the portal reaches (i.e. how far links may be made
|
||||
// from this portal)
|
||||
@ -125,7 +143,7 @@ var RANGE_INDICATOR_COLOR = 'red';
|
||||
var RESO_NRG = [0, 1000, 1500, 2000, 2500, 3000, 4000, 5000, 6000];
|
||||
var MAX_XM_PER_LEVEL = [0, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000];
|
||||
var MIN_AP_FOR_LEVEL = [0, 10000, 30000, 70000, 150000, 300000, 600000, 1200000];
|
||||
var HACK_RANGE = 35; // in meters, max. distance from portal to be able to access it
|
||||
var HACK_RANGE = 40; // in meters, max. distance from portal to be able to access it
|
||||
var OCTANTS = ['E', 'NE', 'N', 'NW', 'W', 'SW', 'S', 'SE'];
|
||||
var DEFAULT_PORTAL_IMG = 'http://commondatastorage.googleapis.com/ingress/img/default-portal-image.png';
|
||||
var DESTROY_RESONATOR = 75; //AP for destroying portal
|
||||
@ -137,10 +155,19 @@ var NOMINATIM = 'http://nominatim.openstreetmap.org/search?format=json&limit=1&q
|
||||
var DEG2RAD = Math.PI / 180;
|
||||
var TEAM_NONE = 0, TEAM_RES = 1, TEAM_ENL = 2;
|
||||
var TEAM_TO_CSS = ['none', 'res', 'enl'];
|
||||
var TYPE_UNKNOWN = 0, TYPE_PORTAL = 1, TYPE_LINK = 2, TYPE_FIELD = 3, TYPE_PLAYER = 4, TYPE_CHAT = 5, TYPE_RESONATOR = 6;
|
||||
// make PLAYER variable available in site context
|
||||
var PLAYER = window.PLAYER;
|
||||
var CHAT_SHRINKED = 60;
|
||||
|
||||
// Minimum zoom level resonator will display
|
||||
var RESONATOR_DISPLAY_ZOOM_LEVEL = 17;
|
||||
|
||||
// Constants for resonator positioning
|
||||
var SLOT_TO_LAT = [0, Math.sqrt(2)/2, 1, Math.sqrt(2)/2, 0, -Math.sqrt(2)/2, -1, -Math.sqrt(2)/2];
|
||||
var SLOT_TO_LNG = [1, Math.sqrt(2)/2, 0, -Math.sqrt(2)/2, -1, -Math.sqrt(2)/2, 0, Math.sqrt(2)/2];
|
||||
var EARTH_RADIUS=6378137;
|
||||
|
||||
// STORAGE ///////////////////////////////////////////////////////////
|
||||
// global variables used for storage. Most likely READ ONLY. Proper
|
||||
// way would be to encapsulate them in an anonymous function and write
|
||||
@ -161,7 +188,11 @@ var portalsLayers, linksLayer, fieldsLayer;
|
||||
window.portals = {};
|
||||
window.links = {};
|
||||
window.fields = {};
|
||||
window.resonators = {};
|
||||
|
||||
// plugin framework. Plugins may load earlier than iitc, so don’t
|
||||
// overwrite data
|
||||
if(typeof window.plugin !== 'function') window.plugin = function() {};
|
||||
|
||||
|
||||
@@INJECTHERE@@
|
||||
|
Reference in New Issue
Block a user