diff --git a/.gitignore b/.gitignore index 40577945..0642e5d0 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ mobile/IngressIntelTC/bin build localbuildsettings.py *.pyc +*.swp diff --git a/plugins/ipas-link.user.js b/plugins/ipas-link.user.js new file mode 100644 index 00000000..e4ce2d59 --- /dev/null +++ b/plugins/ipas-link.user.js @@ -0,0 +1,60 @@ +// ==UserScript== +// @id iitc-plugin-ipas-link@graphracer +// @name IITC Plugin: simulate an attack on portal +// @version 0.1.0.@@DATETIMEVERSION@@ +// @namespace https://github.com/xosofox/IPAS +// @updateURL @@UPDATEURL@@ +// @downloadURL @@DOWNLOADURL@@ +// @description [@@BUILDNAME@@-@@BUILDDATE@@] Adds a link to the portal details to open the portal in IPAS - Ingress Portal Attack Simulator on http://ipas.graphracer.com +// @include https://www.ingress.com/intel* +// @include http://www.ingress.com/intel* +// @match https://www.ingress.com/intel* +// @match http://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.ipasLink = function() {}; + +window.plugin.ipasLink.setupCallback = function() { + addHook('portalDetailsUpdated', window.plugin.ipasLink.addLink); +} + +window.plugin.ipasLink.addLink = function(d) { + $('.linkdetails').append(''); +} + +window.plugin.ipasLink.getHash = function(d) { + var hashParts=[]; + $.each(d.resonatorArray.resonators, function(ind, reso) { + hashParts.push(reso.level + "," + reso.distanceToPortal + "," + reso.energyTotal); + }); + return hashParts.join(";")+"|" + "0,0,0,0"; //shields not implemented yet +} + +var setup = function() { + window.plugin.ipasLink.setupCallback(); +} + +// 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); +