Created
November 16, 2017 03:12
-
-
Save isnot/8d377604d94f550fcea9b91490b38396 to your computer and use it in GitHub Desktop.
IITC plugin: Highlighter Supplement Seeker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @id iitc-plugin-portal-highlighter-supplement-seeker@isnot | |
// @name IITC plugin: Highlighter Supplement Seeker | |
// @category Highlighter | |
// @version 0.1 | |
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion | |
// @updateURL none | |
// @downloadURL none | |
// @description [iitc-plugins] Supplement Seeker | |
// @auther isnot | |
// @include https://*.ingress.com/intel* | |
// @include http://*.ingress.com/intel* | |
// @match https://*.ingress.com/intel* | |
// @match http://*.ingress.com/intel* | |
// @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() {}; | |
// PLUGIN START //////////////////////////////////////////////////////// | |
// use own namespace for plugin | |
window.plugin.suppSeeker = function() {}; | |
window.plugin.suppSeeker.ORDER = [ | |
{ | |
'type': 'LessMods', | |
'color': '#b0c4de', // | |
'opacity': '0.8' | |
}, | |
{ | |
'type': 'LessReso', | |
'color': '#808080', // thin gray | |
'opacity': '0.7' | |
}, | |
{ | |
'type': 'VR', | |
'color': '#f0e68c', // thin khaki | |
'opacity': '0.7' | |
}, | |
{ | |
'type': 'P8', | |
'color': '#ffffff', // white | |
'opacity': '0.85' | |
}, | |
{ | |
'type': 'RHS', // thin pink | |
'color': '#ff69b4', | |
'opacity': '0.6' | |
}, | |
{ | |
'type': 'RMH', // thin red | |
'color': '#ff4444', | |
'opacity': '0.6' | |
}, | |
{ | |
'type': 'VRHS', | |
'color': '#ff00ff', // shocking pink | |
'opacity': '0.8' | |
}, | |
{ | |
'type': 'VRMH', | |
'color': '#ff4444', // red | |
'opacity': '0.9' | |
}, | |
{ | |
'type': 'FRACK', | |
'color': '#ffe259', // strong yellow | |
'opacity': '0.9' | |
}, | |
{ | |
'type': 'unknown', | |
'color': '#000000', | |
'opacity': '0.5' | |
} | |
]; | |
window.plugin.suppSeeker.highlight = function(data) { | |
var portal = data.portal.options; | |
var exists = {}, modsDetail = '', numMods = 0, color = '', opacity = '0.8'; | |
window.plugin.suppSeeker.ORDER.forEach(function(ss) { | |
exists[ss.type] = 0; | |
}); | |
// check portal map data | |
if (portal.level === 8) { | |
exists.P8 = 1; | |
} | |
if ((portal.team !== TEAM_NONE) && portal.data.hasOwnProperty('resCount') && (portal.data.resCount < 8)) { | |
exists.LessReso = 1; | |
} | |
if (portal.data.hasOwnProperty('ornaments') && (portal.data.ornaments.join('').indexOf('peFRACK') !== -1)) { | |
exists.FRACK = 1; | |
} | |
// check portal details | |
var d = window.portalDetail.get(portal.guid); | |
if (d) { | |
d.mods.forEach(function(obj) { | |
if (obj && (typeof obj === 'object')) { | |
numMods++; | |
modsDetail = modsDetail + '|' + obj.rarity + obj.name; | |
} | |
}); | |
} | |
if ((portal.team !== TEAM_NONE) && d && numMods < 4) { | |
exists.LessMods = 1; | |
} | |
if (modsDetail.indexOf('|VERY_RARE') !== -1) { | |
exists.VR = 1; | |
} | |
if (modsDetail.indexOf('|RAREMulti-hack') !== -1) { | |
exists.RMH = 1; | |
} | |
if (modsDetail.indexOf('|RAREHeat Sink') !== -1) { | |
exists.RHS = 1; | |
} | |
if (modsDetail.indexOf('|VERY_RAREMulti-hack') !== -1) { | |
exists.VRMH = 1; | |
} | |
if (modsDetail.indexOf('|VERY_RAREHeat Sink') !== -1) { | |
exists.VRHS = 1; | |
} | |
// find color | |
window.plugin.suppSeeker.ORDER.forEach(function(co) { | |
if (exists[co.type]) { | |
color = co.color; | |
opacity = co.opacity; | |
} | |
}); | |
// override | |
if (exists.VRHS && exists.VRMH) { | |
color = '#9a5bdc'; // darkviolet | |
opacity = '0.8'; | |
} | |
if (color) { | |
data.portal.setStyle({'fillColor': color, 'fillOpacity': opacity}); | |
} | |
}; | |
var setup = function() { | |
window.addPortalHighlighter('Supplement Seeker', window.plugin.suppSeeker.highlight); | |
}; | |
// 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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment