new plugin ipas-link

For opening a portal in IPAS - Ingress Portal Attack Simulator
This commit is contained in:
Peter Dietrich 2013-04-04 11:18:49 +02:00
parent e396d7df1d
commit 711fc74ed6
2 changed files with 61 additions and 0 deletions

1
.gitignore vendored
View File

@ -2,3 +2,4 @@ mobile/IngressIntelTC/bin
build
localbuildsettings.py
*.pyc
*.swp

60
plugins/ipas-link.user.js Normal file
View File

@ -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('<aside><a href="http://ipas.graphracer.com/index.html#' + window.plugin.ipasLink.getHash(d.portalDetails) + '" target="ipaswindow">attack!</a></aside>');
}
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);