merge main

This commit is contained in:
vita10gy
2013-03-09 14:59:02 -06:00
106 changed files with 2827 additions and 1283 deletions

View File

@ -1,27 +1,9 @@
Plugins
=======
USER DOCUMENTATION MOVED!
=========================
Install
-------
Plugins are installed the same way the total conversion script is. Please see there for specific instructions for your browser.
Available Plugins
-----------------
- [**Compute AP Stats**](https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/compute-ap-stats.user.js) Shows the potential AP an agent could obtain by destroying and rebuilding all the portals in the current zoom area.
- [**Draw Tools**](https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/draw-tools.user.js) allows to draw circles and lines on the map to aid you with planning your next big field. [View screenshot](http://breunigs.github.com/ingress-intel-total-conversion/screenshots/plugin_draw_tools.png)
- [**Guess Player Level**](https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/guess-player-levels.user.js) looks for the highest placed resonator per player in the current view to guess the player level.
- [**Highlight Weakened Portals**](https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/show-portal-weakness.user.js) fill portals with red to indicate portal's state of disrepair. The brighter the color the more attention needed (recharge, shields, resonators). A dashed portal means a resonator is missing.
- [**Player Tracker**](https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/player-tracker.user.js) Draws trails for user actions in the last hour. At the last known location theres a tooltip that shows the data in a table. [View screenshot](http://breunigs.github.com/ingress-intel-total-conversion/screenshots/plugin_player_tracker.png).
- [**Render Limit Increase**](https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/render-limit-increase.user.js) increases render limits. Good for high density areas (e.g. London, UK) and faster PCs.
- [**Resonator Display Zoom Level Decrease**](https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/resonator-display-zoom-level-decrease.user.js) Resonator start displaying earlier.
- [**Show Portal Address**](https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/show-address.user.js) Shows portal address in the side panel.
### available only with the development version
[Read HACKING.md file](https://github.com/breunigs/ingress-intel-total-conversion/blob/gh-pages/HACKING.md#hacking) to learn how to build the development version yourself. If **and only if** [you have read how to report bugs](https://github.com/breunigs/ingress-intel-total-conversion/blob/gh-pages/HACKING.md#how-do-i-report-bugs), you may beta test the [nightly](https://www.dropbox.com/sh/lt9p0s40kt3cs6m/3xzpyiVBnF) version.
[The plugins list has been moved to the wiki. Please see there!](https://github.com/breunigs/ingress-intel-total-conversion/wiki/Plugins)
What follows is developer documentation only.

View File

@ -1,13 +1,13 @@
// ==UserScript==
// @id iitc-plugin-compute-ap-stats@Hollow011
// @name iitc: Compute AP statistics
// @version 0.2
// @version 0.3
// @namespace https://github.com/breunigs/ingress-intel-total-conversion
// @updateURL https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/compute-ap-stats.user.js
// @downloadURL https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/compute-ap-stats.user.js
// @description Tries to determine overal AP stats for the current zoom
// @include http://www.ingress.com/intel*
// @match http://www.ingress.com/intel*
// @include https://www.ingress.com/intel*
// @match https://www.ingress.com/intel*
// ==/UserScript==
function wrapper() {
@ -44,6 +44,21 @@ window.plugin.compAPStats.onPositionMove = function() {
+ '</table>');
}
window.plugin.compAPStats.missingResonatorAP = function(portal) {
var resAP = 0;
var missing_resonators = 0;
$.each(portal.resonatorArray.resonators, function(ind, reso) {
if(reso === null) {
missing_resonators++;
}
});
if(missing_resonators > 0) {
resAP = window.DEPLOY_RESONATOR * missing_resonators;
resAP += window.COMPLETION_BONUS;
}
return(resAP);
};
window.plugin.compAPStats.compAPStats = function() {
var totalAP_RES = 0;
@ -78,6 +93,9 @@ window.plugin.compAPStats.compAPStats = function() {
if(!field) return true;
allEnlFields.push(field);
});
totalAP_ENL += window.plugin.compAPStats.missingResonatorAP(d);
}
else if (getTeam(d) === TEAM_RES) {
totalAP_ENL += portalSum;
@ -91,6 +109,9 @@ window.plugin.compAPStats.compAPStats = function() {
if(!field) return true;
allResFields.push(field);
});
totalAP_RES += window.plugin.compAPStats.missingResonatorAP(d);
} else {
// it's a neutral portal, potential for both teams. by definition no fields or edges
totalAP_ENL += portalSum;

View File

@ -1,13 +1,13 @@
// ==UserScript==
// @id iitc-plugin-draw-tools@breunigs
// @name iitc: draw tools
// @version 0.2
// @version 0.2.2
// @namespace https://github.com/breunigs/ingress-intel-total-conversion
// @updateURL https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/draw-tools.user.js
// @downloadURL https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/draw-tools.user.js
// @description Allows you to draw things into the current map so you may plan your next move
// @include http://www.ingress.com/intel*
// @match http://www.ingress.com/intel*
// @include https://www.ingress.com/intel*
// @match https://www.ingress.com/intel*
// ==/UserScript==
function wrapper() {
@ -29,12 +29,15 @@ var DRAW_TOOLS_SHAPE_OPTIONS = {
window.plugin.drawTools = function() {};
window.plugin.drawTools.loadExternals = function() {
var base = 'http://breunigs.github.com/ingress-intel-total-conversion/dist';
var base = 'https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/dist';
//~ var base = 'http://0.0.0.0:8000/dist';
$('head').append('<link rel="stylesheet" href="'+base+'/leaflet.draw.0.1.6.css" />');
load(base+'/leaflet.draw.0.1.6.js').thenRun(window.plugin.drawTools.boot);
// overwrite default Leaflet Marker icon.
L.Icon.Default.imagePath = base + '/images';
// FIXME: this is currently manually included from
// external/leaflet.draw.0.1.6.css. It should either be loaded remotely
// automatically or the buildscript should include it here, similar to
// how it works for the main script.
$('head').append('<style>.leaflet-container .leaflet-control-draw {margin-left: 13px;margin-top: 12px;}.leaflet-control-draw a {background-position: 50% 50%;background-repeat: no-repeat;display: block;width: 22px;height: 22px;}.leaflet-control-draw a:hover {background-color: #fff;}.leaflet-touch .leaflet-control-draw a {width: 27px;height: 27px;}.leaflet-control-draw-polyline {background-image: url(https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/dist/images/draw-polyline.png);}.leaflet-control-draw-polygon {background-image: url(https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/dist/images/draw-polygon.png);}.leaflet-control-draw-rectangle {background-image: url(https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/dist/images/draw-rectangle.png);}.leaflet-control-draw-circle {background-image: url(https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/dist/images/draw-circle.png);}.leaflet-control-draw-marker {background-image: url(https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/dist/images/draw-marker-icon.png);}.leaflet-mouse-marker {background-color: #fff;cursor: crosshair;}.leaflet-draw-label {background-color: #fff;border: 1px solid #ccc;color: #222;font: 12px/18px "Helvetica Neue", Arial, Helvetica, sans-serif;margin-left: 20px;margin-top: -21px;padding: 2px 4px;position: absolute;white-space: nowrap;z-index: 6;}.leaflet-error-draw-label {background-color: #F2DEDE;border-color: #E6B6BD;color: #B94A48;}.leaflet-draw-label-single {margin-top: -12px}.leaflet-draw-label-subtext {color: #999;}.leaflet-draw-guide-dash {font-size: 1%;opacity: 0.6;position: absolute;width: 5px;height: 5px;}.leaflet-flash-anim {-webkit-animation-duration: 0.66s; -moz-animation-duration: 0.66s; -o-animation-duration: 0.66s; animation-duration: 0.66s;-webkit-animation-fill-mode: both; -moz-animation-fill-mode: both; -o-animation-fill-mode: both; animation-fill-mode: both;-webkit-animation-name: leaflet-flash; -moz-animation-name: leaflet-flash; -o-animation-name: leaflet-flash; animation-name: leaflet-flash;}@-webkit-keyframes leaflet-flash {0%, 50%, 100% { opacity: 1; }25%, 75% { opacity: 0.3; }}@-moz-keyframes leaflet-flash {0%, 50%, 100% { opacity: 1; }25%, 75% { opacity: 0.3; }}@-o-keyframes leaflet-flash {0%, 50%, 100% { opacity: 1; }25%, 75% { opacity: 0.3; }}@keyframes leaflet-flash {0%, 50%, 100% { opacity: 1; }25%, 75% { opacity: 0; }}</style>');
}

View File

@ -1,13 +1,13 @@
// ==UserScript==
// @id iitc-plugin-guess-player-levels@breunigs
// @name iitc: guess player level
// @version 0.2
// @version 0.3
// @namespace https://github.com/breunigs/ingress-intel-total-conversion
// @updateURL https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/guess-player-levels.user.js
// @downloadURL https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/guess-player-levels.user.js
// @description Tries to determine player levels from the data available in the current view
// @include http://www.ingress.com/intel*
// @match http://www.ingress.com/intel*
// @include https://www.ingress.com/intel*
// @match https://www.ingress.com/intel*
// ==/UserScript==
function wrapper() {
@ -43,7 +43,7 @@ window.plugin.guessPlayerLevels.setLevelTitle = function(dom) {
var text;
if (nick in playersNamed) {
text = 'Min player level: ' + playersNamed[nick];
if(playersNamed[nick] === window.MAX_XM_PER_LEVEL - 1) text += ' (guessed)';
if(playersNamed[nick] < window.MAX_XM_PER_LEVEL.length - 1) text += ' (guessed)';
} else {
text = 'Min player level unknown';
}
@ -88,23 +88,34 @@ window.plugin.guessPlayerLevels.guess = function() {
});
var s = 'the players have at least the following level:\n\n';
s += 'Resistance:\t&nbsp;&nbsp;&nbsp;\tEnlightenment:\t\n';
s += 'Resistance:\t&nbsp;&nbsp;&nbsp;\tEnlightened:\t\n';
var namesR = plugin.guessPlayerLevels.sort(playersRes);
var namesE = plugin.guessPlayerLevels.sort(playersEnl);
var totallvlR = 0;
var totallvlE = 0;
var max = Math.max(namesR.length, namesE.length);
for(var i = 0; i < max; i++) {
var nickR = namesR[i];
var lvlR = playersRes[nickR];
var lineR = nickR ? nickR + ':\t' + lvlR : '\t';
if(!isNaN(parseInt(lvlR)))
totallvlR += parseInt(lvlR);
var nickE = namesE[i];
var lvlE = playersEnl[nickE];
var lineE = nickE ? nickE + ':\t' + lvlE : '\t';
if(!isNaN(parseInt(lvlE)))
totallvlE += parseInt(lvlE);
s += lineR + '\t\t' + lineE + '\n';
s += '\n'+lineR + '\t' + lineE + '\n';
}
s += '\nTotal level :\t'+totallvlR+'\tTotal level :\t'+totallvlE;
s += '\nTotal player:\t'+namesR.length+'\tTotal player:\t'+namesE.length;
var averageR = 0, averageE = 0;
if (namesR.length > 0) averageR = (totallvlR/namesR.length);
if (namesE.length > 0) averageE = (totallvlE/namesE.length);
s += '\nAverage level:\t'+averageR.toFixed(2)+'\tAverage level:\t'+averageE.toFixed(2);
s += '\n\nIf there are some unresolved names, simply try again.'
console.log(s);
alert(s);

137
plugins/max-links.user.js Normal file
View File

@ -0,0 +1,137 @@
// ==UserScript==
// @id max-links@boombuler
// @name iitc: Max-Links-Plugin
// @version 0.2
// @updateURL https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/max-links.user.js
// @downloadURL https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/max-links.user.js
// @description Calculates how to link the portals to create the maximum number of fields.
// @include https://www.ingress.com/intel*
// @match https://www.ingress.com/intel*
// ==/UserScript==
function wrapper() {
// ensure plugin framework is there, even if iitc is not yet loaded
if(typeof window.plugin !== 'function')
window.plugin = function() {};
// PLUGIN START ////////////////////////////////////////////////////////
// use own namespace for plugin
window.plugin.maxLinks = function() {};
// const values
window.plugin.maxLinks.MAX_DRAWN_LINKS = 400;
window.plugin.maxLinks.MAX_DRAWN_LINKS_INCREASED_LIMIT = 1000;
window.plugin.maxLinks.STROKE_STYLE = {
color: '#FF0000',
opacity: 1,
weight:2,
clickable: false,
smoothFactor: 10
};
window.plugin.maxLinks._delaunayScriptLocation = 'https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/dist/delaunay.js';
window.plugin.maxLinks.layer = null;
window.plugin.maxLinks._updating = false;
window.plugin.maxLinks._renderLimitReached = false;
window.plugin.maxLinks.updateLayer = function() {
if (window.plugin.maxLinks._updating ||
window.plugin.maxLinks.layer === null ||
!window.map.hasLayer(window.plugin.maxLinks.layer))
return;
window.plugin.maxLinks._updating = true;
window.plugin.maxLinks.layer.clearLayers();
var locations = [];
var minX = 0;
var minY = 0;
$.each(window.portals, function(guid, portal) {
var loc = portal.options.details.locationE6;
var nloc = { x: loc.lngE6, y: loc.latE6 };
if (nloc.x < minX)
minX = nloc.x;
if (nloc.y < minY)
minY = nloc.y;
locations.push(nloc);
});
$.each(locations, function(idx, nloc) {
nloc.x += Math.abs(minX);
nloc.y += Math.abs(minY);
});
var triangles = window.delaunay.triangulate(locations);
var drawnLinks = 0;
window.plugin.maxLinks._renderLimitReached = false;
var renderlimit = window.USE_INCREASED_RENDER_LIMIT ?
window.plugin.maxLinks.MAX_DRAWN_LINKS_INCREASED_LIMIT :
window.plugin.maxLinks.MAX_DRAWN_LINKS;
$.each(triangles, function(idx, triangle) {
if (drawnLinks <= renderlimit) {
triangle.draw(window.plugin.maxLinks.layer, minX, minY)
drawnLinks += 3;
} else {
window.plugin.maxLinks._renderLimitReached = true;
}
});
window.plugin.maxLinks._updating = false;
window.renderUpdateStatus();
}
window.plugin.maxLinks.setup = function() {
load(window.plugin.maxLinks._delaunayScriptLocation).thenRun(function() {
window.delaunay.Triangle.prototype.draw = function(layer, divX, divY) {
var drawLine = function(src, dest) {
var poly = L.polyline([[(src.y + divY)/1E6, (src.x + divX)/1E6], [(dest.y + divY)/1E6, (dest.x + divX)/1E6]], window.plugin.maxLinks.STROKE_STYLE);
poly.addTo(layer);
};
drawLine(this.a, this.b);
drawLine(this.b, this.c);
drawLine(this.c, this.a);
}
window.plugin.maxLinks.layer = L.layerGroup([]);
window.addHook('checkRenderLimit', function(e) {
if (window.map.hasLayer(window.plugin.maxLinks.layer) &&
window.plugin.maxLinks._renderLimitReached)
e.reached = true;
});
window.addHook('portalDataLoaded', function(e) {
if (window.map.hasLayer(window.plugin.maxLinks.layer))
window.plugin.maxLinks.updateLayer();
});
window.map.on('layeradd', function(e) {
if (e.layer === window.plugin.maxLinks.layer)
window.plugin.maxLinks.updateLayer();
});
window.map.on('zoomend moveend', window.plugin.maxLinks.updateLayer);
window.layerChooser.addOverlay(window.plugin.maxLinks.layer, 'Maximum Links');
});
}
var setup = window.plugin.maxLinks.setup;
// PLUGIN END //////////////////////////////////////////////////////////
if(window.iitcLoaded && typeof setup === 'function') {
setup();
} else {
if(window.bootPlugins)
window.bootPlugins.push(setup);
else
window.bootPlugins = [setup];
}
} // wrapper end
// inject code into site context
var script = document.createElement('script');
script.appendChild(document.createTextNode('('+ wrapper +')();'));
(document.body || document.head || document.documentElement).appendChild(script);

View File

@ -1,13 +1,13 @@
// ==UserScript==
// @id iitc-plugin-player-tracker@breunigs
// @name iitc: player tracker
// @version 0.5
// @version 0.7
// @namespace https://github.com/breunigs/ingress-intel-total-conversion
// @updateURL https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/player-tracker.user.js
// @downloadURL https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/player-tracker.user.js
// @description draws trails for the path a user went onto the map. Only draws the last hour. Does not request chat data on its own, even if that would be useful.
// @include http://www.ingress.com/intel*
// @match http://www.ingress.com/intel*
// @include https://www.ingress.com/intel*
// @match https://www.ingress.com/intel*
// ==/UserScript==
function wrapper() {
@ -80,7 +80,8 @@ window.plugin.playerTracker.processNewData = function(data) {
// field was originally created. Therefore its not clear which
// portal the player is at, so ignore it.
if(markup[1].plain.indexOf('destroyed the Link') !== -1
|| markup[1].plain.indexOf('destroyed a Control Field') !== -1) {
|| markup[1].plain.indexOf('destroyed a Control Field') !== -1
|| markup[1].plain.indexOf('Your Link') !== -1) {
skipThisMessage = true;
return false;
}
@ -163,13 +164,14 @@ window.plugin.playerTracker.processNewData = function(data) {
}
window.plugin.playerTracker.getLatLngFromEvent = function(ev) {
var lats = $.map(ev.latlngs, function(ll) { return [ll[0]] });
var lngs = $.map(ev.latlngs, function(ll) { return [ll[1]] });
var latmax = Math.max.apply(null, lats);
var latmin = Math.min.apply(null, lats);
var lngmax = Math.max.apply(null, lngs);
var lngmin = Math.min.apply(null, lngs);
return L.latLng((latmax + latmin) / 2, (lngmax + lngmin) / 2);
var lats = 0;
var lngs = 0;
$.each(ev.latlngs, function() {
lats += this[0];
lngs += this[1];
});
return L.latLng(lats / ev.latlngs.length, lngs / ev.latlngs.length);
}
window.plugin.playerTracker.ago = function(time, now) {
@ -203,9 +205,9 @@ window.plugin.playerTracker.drawData = function() {
var evtsLength = playerData.events.length;
var last = playerData.events[evtsLength-1];
var ago = plugin.playerTracker.ago;
var color = playerData.team === 'ALIENS' ? '#029C02' : '#00789C';
var cssClass = playerData.team === 'ALIENS' ? 'enl' : 'res';
var title =
'<span style="font-weight:bold; color:'+color+'">' + playerData.nick + '</span>\n'
'<span class="nickname '+ cssClass+'" style="font-weight:bold;">' + playerData.nick + '</span>\n'
+ ago(last.time, now) + ' minutes ago\n'
+ last.name;
// show previous data in tooltip

View File

@ -1,13 +1,13 @@
// ==UserScript==
// @id iitc-plugin-render-limit-increase@jonatkins
// @name iitc: render limit increase
// @version 0.1
// @version 0.1.1
// @namespace https://github.com/breunigs/ingress-intel-total-conversion
// @updateURL https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/render-limit-increase.user.js
// @downloadURL https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/render-limit-increase.user.js
// @description Increase the render limits, so less likely to be hit in higher density areas
// @include http://www.ingress.com/intel*
// @match http://www.ingress.com/intel*
// @include https://www.ingress.com/intel*
// @match https://www.ingress.com/intel*
// ==/UserScript==
function wrapper() {
@ -29,7 +29,7 @@ window.plugin.renderLimitIncrease.setHigherLimits = function() {
// thing like that, Leaflet doc isnt too specific). Setting it too low
// makes the missing data on move/zoom out more obvious. Setting it too
// high causes too many items to be drawn, making drag&drop sluggish.
// default for iitc is 0.3. a lower value reduces overdraw
// default for iitc is 0.3. a lower value reduces overdraw
window.VIEWPORT_PAD_RATIO = 0.1;
@ -39,7 +39,7 @@ window.plugin.renderLimitIncrease.setHigherLimits = function() {
window.MAX_DRAWN_PORTALS = 3000;
window.MAX_DRAWN_LINKS = 1000;
window.MAX_DRAWN_FIELDS = 500;
window.USE_INCREASED_RENDER_LIMIT = true; // Used for other plugins
};
var setup = window.plugin.renderLimitIncrease.setHigherLimits;

View File

@ -1,13 +1,13 @@
// ==UserScript==
// @id iitc-plugin-reso-energy-pct-in-portal-detail@xelio
// @name iitc: reso energy pct in portal detail
// @version 0.1
// @version 0.1.1
// @namespace https://github.com/breunigs/ingress-intel-total-conversion
// @updateURL https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/reso-energy-pct-in-portal-detail.user.js
// @downloadURL https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/reso-energy-pct-in-portal-detail.user.js
// @description Show resonator energy percentage on resonator energy bar in portal detail panel.
// @include http://www.ingress.com/intel*
// @match http://www.ingress.com/intel*
// @include https://www.ingress.com/intel*
// @match https://www.ingress.com/intel*
// ==/UserScript==
function wrapper() {

View File

@ -1,13 +1,13 @@
// ==UserScript==
// @id iitc-plugin-resonator-display-zoom-level-decrease@xelio
// @name iitc: resonator display zoom level decrease
// @version 1.0
// @version 1.0.1
// @namespace https://github.com/breunigs/ingress-intel-total-conversion
// @updateURL https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/resonator-display-zoom-level-decrease.user.js
// @downloadURL https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/resonator-display-zoom-level-decrease.user.js
// @description Resonator start display earlier
// @include http://www.ingress.com/intel*
// @match http://www.ingress.com/intel*
// @include https://www.ingress.com/intel*
// @match https://www.ingress.com/intel*
// ==/UserScript==
function wrapper() {

48
plugins/scale-bar.user.js Normal file
View File

@ -0,0 +1,48 @@
// ==UserScript==
// @id iitc-plugin-scale-bar@breunigs
// @name iitc: scale bar
// @version 0.1
// @namespace https://github.com/breunigs/ingress-intel-total-conversion
// @updateURL https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/scale-bar.user.js
// @downloadURL https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/scale-bar.user.js
// @description shows scale bar on the map
// @include https://www.ingress.com/intel*
// @match https://www.ingress.com/intel*
// ==/UserScript==
function wrapper() {
// ensure plugin framework is there, even if iitc is not yet loaded
if(typeof window.plugin !== 'function') window.plugin = function() {};
// PLUGIN START ////////////////////////////////////////////////////////
// use own namespace for plugin
window.plugin.scaleBar = function() {};
window.plugin.scaleBar.setup = function() {
$('head').append('<style>.leaflet-control-scale { position: absolute; top: 2px; left: 40px; } </style>');
// Before you ask: yes, I explicitely turned off imperial units. Imperial units
// are worse than Internet Explorer 6 whirring fans combined. Upgrade to the metric
// system already.
window.map.addControl(new L.Control.Scale({position: 'topleft', imperial: false}));
};
var setup = window.plugin.scaleBar.setup;
// PLUGIN END //////////////////////////////////////////////////////////
if(window.iitcLoaded && typeof setup === 'function') {
setup();
} else {
if(window.bootPlugins)
window.bootPlugins.push(setup);
else
window.bootPlugins = [setup];
}
} // wrapper end
// inject code into site context
var script = document.createElement('script');
script.appendChild(document.createTextNode('('+ wrapper +')();'));
(document.body || document.head || document.documentElement).appendChild(script);

View File

@ -1,13 +1,13 @@
// ==UserScript==
// @id iitc-plugin-show-address@vita10gy
// @name iitc: show portal address in sidebar
// @version 0.2
// @version 0.2.1
// @namespace https://github.com/breunigs/ingress-intel-total-conversion
// @updateURL https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/show-address.user.js
// @downloadURL https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/show-address.user.js
// @description Portal address will show in the sidebar.
// @include http://www.ingress.com/intel*
// @match http://www.ingress.com/intel*
// @include https://www.ingress.com/intel*
// @match https://www.ingress.com/intel*
// ==/UserScript==
function wrapper() {

View File

@ -1,13 +1,13 @@
// ==UserScript==
// @id iitc-plugin-show-portal-weakness@vita10gy
// @name iitc: show portal weakness
// @version 0.2
// @version 0.6
// @namespace https://github.com/breunigs/ingress-intel-total-conversion
// @updateURL https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/show-portal-weakness.user.js
// @downloadURL https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/show-portal-weakness.user.js
// @description Uses the fill color of the portals to denote if the portal is weak (Needs recharging, missing a resonator, needs shields)
// @include http://www.ingress.com/intel*
// @match http://www.ingress.com/intel*
// @description Uses the fill color of the portals to denote if the portal is weak (Needs recharging, missing a resonator, needs shields) Red, needs energy and shields. Orange, only needs energy (either recharge or resonators). Yellow, only needs shields.
// @include https://www.ingress.com/intel*
// @match https://www.ingress.com/intel*
// ==/UserScript==
function wrapper() {
@ -21,60 +21,78 @@ if(typeof window.plugin !== 'function') window.plugin = function() {};
window.plugin.portalWeakness = function() {};
window.plugin.portalWeakness.portalAdded = function(data) {
var d = data.portal.options.details;
var portal_weakness = 0;
if(getTeam(d) != 0)
{
if(window.getTotalPortalEnergy(d)> 0 && window.getCurrentPortalEnergy(d) < window.getTotalPortalEnergy(d))
{
if(getTeam(d) !== 0) {
var only_shields = true;
var missing_shields = 0;
if(window.getTotalPortalEnergy(d) > 0 && window.getCurrentPortalEnergy(d) < window.getTotalPortalEnergy(d)) {
portal_weakness = 1 - (window.getCurrentPortalEnergy(d)/window.getTotalPortalEnergy(d));
only_shields = false;
}
//Ding the portal for every missing sheild.
$.each(d.portalV2.linkedModArray, function(ind, mod)
{
if(mod == null)
{
//Ding the portal for every missing sheild.
$.each(d.portalV2.linkedModArray, function(ind, mod) {
if(mod === null) {
missing_shields++;
portal_weakness += .03;
}
});
//Ding the portal for every missing resonator.
var resCount = 0;
$.each(d.resonatorArray.resonators, function(ind, reso)
{
if(reso == null) {
$.each(d.resonatorArray.resonators, function(ind, reso) {
if(reso === null) {
portal_weakness += .125;
}
else {
only_shields = false;
} else {
resCount++;
}
});
if(portal_weakness<0) {
if(portal_weakness < 0) {
portal_weakness = 0;
}
if(portal_weakness>1)
{
if(portal_weakness > 1) {
portal_weakness = 1;
}
if(portal_weakness>0)
{
var color = 'red';
var fill_opacity = Math.round((portal_weakness*.8 + .2)*100)/100;
var params = {fillColor: color, fillOpacity: fill_opacity, radius: data.portal.options.radius+1};
if(resCount<8)
{
}
if(portal_weakness > 0) {
var fill_opacity = portal_weakness*.7 + .3;
var color = 'orange';
if(only_shields) {
color = 'yellow';
//If only shields are missing, make portal yellow
// but fill more than usual since pale yellow is basically invisible
fill_opacity = missing_shields*.15 + .1;
} else if(missing_shields > 0) {
color = 'red';
}
fill_opacity = Math.round(fill_opacity*100)/100;
var params = {fillColor: color, fillOpacity: fill_opacity};
if(resCount < 8) {
// Hole per missing resonator
var dash = new Array(8-resCount + 1).join("1,4,") + "100,0"
params["dashArray"] = dash;
}
data.portal.setStyle(params);
} else {
data.portal.setStyle({color: COLORS[getTeam(data.portal.options.details)],
fillOpacity: 0.5,
dashArray: null});
}
}
}
window.plugin.portalWeakness.portalDataLoaded = function(data) {
$.each(data.portals, function(ind, portal) {
if(window.portals[portal[0]]) {
window.plugin.portalWeakness.portalAdded({portal: window.portals[portal[0]]});
}
});
}
var setup = function() {
window.addHook('portalAdded', window.plugin.portalWeakness.portalAdded);
window.addHook('portalDataLoaded', window.plugin.portalWeakness.portalDataLoaded);
window.COLOR_SELECTED_PORTAL = '#f0f';
}