Last active
December 18, 2015 17:59
-
-
Save m0rff/5822771 to your computer and use it in GitHub Desktop.
IITC Highlight New Mods Plugin
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-highlight-newmods@morth | |
// @name IITC plugin: highlight new mods on portals | |
// @category Highlighter | |
// @version 0.1 | |
// @namespace http://morth.q1cc.net/ | |
// @updateURL http://morth.q1cc.net/portal-highlight-newmods.user.js | |
// @downloadURL http://morth.q1cc.net/portal-highlight-newmods.user.js | |
// @description Uses the fill color of the portals to denote portals if they have new Special Mods | |
// @include https://www.ingress.com/intel* | |
// @include http://www.ingress.com/intel* | |
// @match https://www.ingress.com/intel* | |
// @match http://www.ingress.com/intel* | |
// @grant none | |
// ==/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.portalHighligherNewMods = function() {}; | |
window.plugin.portalHighligherNewMods.highlight = function(data) { | |
var d = data.portal.options.details; | |
var portal_weakness = 0; | |
var color = 'red'; | |
var opacity = .7; | |
var newMods = false; | |
$.each(d.portalV2.linkedModArray, function(ind, mod) { | |
if(mod && mod.type !== "RES_SHIELD") { | |
newMods = true; | |
} else { | |
return false; | |
} | |
}); | |
if(newMods) { | |
data.portal.setStyle({fillColor: color, fillOpacity: opacity}); | |
} | |
window.COLOR_SELECTED_PORTAL = '#f0f'; | |
} | |
var setup = function() { | |
//Don't list it if it isn't applicable yet | |
window.addPortalHighlighter('New Mods', window.plugin.portalHighligherNewMods.highlight); | |
} | |
// 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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment