From 7e0cfd0159ddabf684e1d013d728113ac7870bc8 Mon Sep 17 00:00:00 2001 From: fkloft Date: Tue, 3 Dec 2013 16:15:17 +0100 Subject: [PATCH] Fix ipas-link --- plugins/broken/ipas-link.user.js | 111 ------------------------------- plugins/ipas-link.user.js | 105 ++++++++++++++++++++++++++++- 2 files changed, 102 insertions(+), 114 deletions(-) delete mode 100644 plugins/broken/ipas-link.user.js diff --git a/plugins/broken/ipas-link.user.js b/plugins/broken/ipas-link.user.js deleted file mode 100644 index 02db5180..00000000 --- a/plugins/broken/ipas-link.user.js +++ /dev/null @@ -1,111 +0,0 @@ -// ==UserScript== -// @id iitc-plugin-ipas-link@graphracer -// @name IITC Plugin: simulate an attack on portal -// @category Portal Info -// @version 0.2.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* -// @grant none -// ==/UserScript== - -@@PLUGINSTART@@ - -// 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) { - if (reso) { - hashParts.push(reso.level + "," + reso.distanceToPortal + "," + reso.energyTotal); - } else { - hashParts.push("1,20,0"); - } - }); - var resos = hashParts.join(";"); - - hashParts = []; - $.each(d.portalV2.linkedModArray, function (ind, mod) { - // s - shields - // h - heat sink - // i - intentionally left in - // t - turret - // - // f - force amp - // m - multi-hack - // l - link-amp - // - var modCodes = { - "RES_SHIELD": "s", - "HEATSINK": "h", - "TURRET": "t", - "FORCE_AMP": "f", - "MULTIHACK": "m", - "LINK_AMPLIFIER": "l" - } - - var mc = "0"; - if (mod) { - if (mod.type in modCodes) { - mc = modCodes[mod.type] + mod.rarity.charAt(0).toLowerCase(); - - //special for shields to distinguish old/new mitigation - if (mod.type == "RES_SHIELD") { - mc += mod.stats.MITIGATION; - } - } - } - hashParts.push(mc); - }); - var shields = hashParts.join(","); - - var linkParts = []; - var edges = d.portalV2.linkedEdges; - - var portalL = new L.LatLng(d.locationE6.latE6 / 1E6, d.locationE6.lngE6 / 1E6) - $.each(edges, function (ind, edge) { - //calc distance in m here - var distance = 1; //default to 1m, so a low level portal would support it - - //Try to find other portals details - var guid = edge.otherPortalGuid - if (window.portals[guid] !== undefined) { - //get other portals details as o - var o = window.portals[guid].options.details; - var otherPortalL = new L.LatLng(o.locationE6.latE6 / 1E6, o.locationE6.lngE6 / 1E6); - var distance = Math.round(portalL.distanceTo(otherPortalL)); - } - - if (!(edge.isOrigin)) { - distance = distance * -1; - } - linkParts.push(distance); - }); - var links = linkParts.join(","); - - return resos + "/" + shields + "/" + links; //changed with IPAS 1.1 to / instead of | - } - -var setup = function () { - window.plugin.ipasLink.setupCallback(); -} - -// PLUGIN END ////////////////////////////////////////////////////////// - -@@PLUGINEND@@ diff --git a/plugins/ipas-link.user.js b/plugins/ipas-link.user.js index 06352f63..cab444d6 100644 --- a/plugins/ipas-link.user.js +++ b/plugins/ipas-link.user.js @@ -1,15 +1,114 @@ // ==UserScript== // @id iitc-plugin-ipas-link@graphracer // @name IITC Plugin: simulate an attack on portal -// @category Deleted -// @version 0.2.0.@@DATETIMEVERSION@@ +// @category Portal Info +// @version 0.2.1.@@DATETIMEVERSION@@ // @namespace https://github.com/xosofox/IPAS // @updateURL @@UPDATEURL@@ // @downloadURL @@DOWNLOADURL@@ -// @description PLUGIN CURRENTLY UNAVAILABLE +// @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* // @grant none // ==/UserScript== + +@@PLUGINSTART@@ + +// 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(p) { + $('.linkdetails').append(''); +} + +window.plugin.ipasLink.getHash = function (p) { + var details = p.portalDetails; + + var hashParts = []; + $.each(details.resonatorArray.resonators, function (ind, reso) { + if (reso) + hashParts.push(reso.level + "," + reso.distanceToPortal + "," + reso.energyTotal); + else + hashParts.push("1,20,0"); + }); + var resos = hashParts.join(";"); + + hashParts = []; + $.each(details.portalV2.linkedModArray, function (ind, mod) { + // s - shields + // h - heat sink + // i - intentionally left in + // t - turret + // + // f - force amp + // m - multi-hack + // l - link-amp + // + var modCodes = { + "RES_SHIELD": "s", + "HEATSINK": "h", + "TURRET": "t", + "FORCE_AMP": "f", + "MULTIHACK": "m", + "LINK_AMPLIFIER": "l" + } + + var mc = "0"; + if (mod) { + if (mod.type in modCodes) { + mc = modCodes[mod.type] + mod.rarity.charAt(0).toLowerCase(); + + //special for shields to distinguish old/new mitigation + if (mod.type == "RES_SHIELD") + mc += mod.stats.MITIGATION; + } + } + hashParts.push(mc); + }); + var shields = hashParts.join(","); + + var linkParts = []; + var portalLL = p.portal.getLatLng(); + var edges = getPortalLinks(p.guid); + edges["in"].forEach(function (guid) { + //calc distance in m here + var distance = 1; //default to 1m, so a low level portal would support it + + //Try to find other portals details + var o = window.portals[guid]; + if (o) + distance = Math.round(portalLL.distanceTo(o.getLatLng())); + + linkParts.push(distance); + }); + edges["out"].forEach(function (guid) { + //calc distance in m here + var distance = 1; //default to 1m, so a low level portal would support it + + //Try to find other portals details + var o = window.portals[guid]; + if (o) + distance = Math.round(portalLL.distanceTo(o.getLatLng())); + + linkParts.push(-distance); // "-" to mark outgoing links + }); + var links = linkParts.join(","); + + return resos + "/" + shields + "/" + links; //changed with IPAS 1.1 to / instead of | +} + +var setup = function () { + window.plugin.ipasLink.setupCallback(); +} + +// PLUGIN END ////////////////////////////////////////////////////////// + +@@PLUGINEND@@