ingress-intel-total-conversion/plugins/portal-highlighter-portals-my-level.user.js

58 lines
2.2 KiB
JavaScript

// ==UserScript==
// @id iitc-plugin-highlight-portals-my-level@vita10gy
// @name IITC plugin: highlight portals by my level
// @category Highlighter
// @version 0.1.2.@@DATETIMEVERSION@@
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion
// @updateURL @@UPDATEURL@@
// @downloadURL @@DOWNLOADURL@@
// @description [@@BUILDNAME@@-@@BUILDDATE@@] Use the portal fill color to denote if the portal is either at and above, or at and below your level.
// @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==
@@PLUGINSTART@@
// PLUGIN START ////////////////////////////////////////////////////////
// use own namespace for plugin
window.plugin.portalHighlighterPortalsMyLevel = function() {};
window.plugin.portalHighlighterPortalsMyLevel.belowLevel = function(data) {
window.plugin.portalHighlighterPortalsMyLevel.colorLevel(true,data);
}
window.plugin.portalHighlighterPortalsMyLevel.aboveLevel = function(data) {
window.plugin.portalHighlighterPortalsMyLevel.colorLevel(false,data);
}
window.plugin.portalHighlighterPortalsMyLevel.colorLevel = function(below,data) {
var portal_level = data.portal.options.level;
// as portal levels can never be higher than L8, clamp the player level to this for highlight purposes
var player_level = Math.min(PLAYER.level,8);
var opacity = .6;
if((below && portal_level <= player_level) ||
(!below && portal_level >= player_level)) {
data.portal.setStyle({fillColor: 'red', fillOpacity: opacity});
}
}
var setup = function() {
window.addPortalHighlighter('Below My Level', window.plugin.portalHighlighterPortalsMyLevel.belowLevel);
window.addPortalHighlighter('Above My Level', window.plugin.portalHighlighterPortalsMyLevel.aboveLevel);
}
// PLUGIN END //////////////////////////////////////////////////////////
@@PLUGINEND@@