|
// ==UserScript== |
|
// @id IITC-neutralized_marker_style |
|
// @name IITC: Neutralized marker style |
|
// @author ozero |
|
// @category Misc |
|
// @version 0.25.1.20190426.01 |
|
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion |
|
// @updateURL none |
|
// @downloadURL none |
|
// @description neutralized marker style |
|
// @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== |
|
|
|
function wrapper(plugin_info) { |
|
// ensure plugin framework is there, even if iitc is not yet loaded |
|
if (typeof window.plugin !== 'function') window.plugin = function() {}; |
|
|
|
/* |
|
|
|
usage: |
|
|
|
*/ |
|
|
|
|
|
// PLUGIN START //////////////////////////////////////////////////////// |
|
// use own namespace for plugin |
|
window.plugin.smallMarkerStyle = function() {}; |
|
|
|
|
|
window.plugin.smallMarkerStyle.setup = function() { |
|
|
|
//Override window.portalMarkerScale to set portal marker resize setting |
|
if (!window.L_PREFER_CANVAS) { |
|
//portalMarkerScale doesn't work well on canvas rendering (Issue #311) |
|
window.portalMarkerScale = function() { |
|
var zoom = map.getZoom(); |
|
var scale = zoom >= 17 ? 1 : zoom >= 16 ? 0.7 : 0.5; |
|
return scale; |
|
} |
|
} |
|
|
|
//Override window.getMarkerStyleOptions to set portal marker radius/weight |
|
window.getMarkerStyleOptions = function(details) { |
|
var scale = window.portalMarkerScale(); |
|
var LEVEL_TO_WEIGHT = []; |
|
var LEVEL_TO_RADIUS = []; |
|
if (!window.L_PREFER_CANVAS) { |
|
LEVEL_TO_WEIGHT = [2, 1, 1, 1, 1, 1, 1, 1, 1]; |
|
LEVEL_TO_RADIUS = [24, 7, 7, 7, 8, 8, 9, 10, 11]; |
|
} |
|
else { |
|
LEVEL_TO_WEIGHT = [2, 2, 2, 2, 2, 2, 2, 2, 2]; |
|
LEVEL_TO_RADIUS = [12, 6, 6, 6, 6, 6, 6, 7, 8]; |
|
} |
|
|
|
var level = Math.floor(details.level || 0); |
|
|
|
var lvlWeight = LEVEL_TO_WEIGHT[level] * Math.sqrt(scale); |
|
var lvlRadius = LEVEL_TO_RADIUS[level] * scale; |
|
|
|
var dashArray = null; |
|
// thinner and dashed outline for placeholder portals |
|
if (details.team != TEAM_NONE && level == 0) { |
|
lvlWeight = 1; |
|
dashArray = [1, 2]; |
|
} |
|
|
|
var options = { |
|
radius: lvlRadius, |
|
stroke: true, |
|
color: COLORS[details.team], |
|
weight: lvlWeight, |
|
opacity: 1, |
|
fill: true, |
|
fillColor: COLORS[details.team], |
|
fillOpacity: 0.5, |
|
dashArray: dashArray, |
|
mod: 'yes' //mod |
|
}; |
|
|
|
return options; |
|
} |
|
|
|
//Override L.LayerGroup.prototype.addLayer to set linkWeight=1 |
|
L.LayerGroup.prototype.addLayer = function(layer) { |
|
var id = this.getLayerId(layer); |
|
if (layer.options) { |
|
if (!layer.options.radius) { |
|
if (layer.options.weight) { |
|
layer.options.weight = 1; |
|
} |
|
} |
|
} |
|
this._layers[id] = layer; |
|
if (this._map) { |
|
this._map.addLayer(layer); |
|
} |
|
return this; |
|
} |
|
|
|
|
|
} |
|
|
|
var setup = function() { |
|
window.addHook('iitcLoaded', window.plugin.smallMarkerStyle.setup); |
|
} |
|
|
|
|
|
// PLUGIN END ////////////////////////////////////////////////////////// |
|
|
|
|
|
setup.info = plugin_info; //add the script info data to the function as a property |
|
if (!window.bootPlugins) window.bootPlugins = []; |
|
window.bootPlugins.push(setup); |
|
// if IITC has already booted, immediately run the 'setup' function |
|
if (window.iitcLoaded && typeof setup === 'function') setup(); |
|
} // wrapper end |
|
// inject code into site context |
|
var script = document.createElement('script'); |
|
var info = {}; |
|
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 |
|
}; |
|
script.appendChild(document.createTextNode('(' + wrapper + ')(' + JSON.stringify(info) + ');')); |
|
(document.body || document.head || document.documentElement).appendChild(script); |
Before:

After:
