ingress-intel-total-conversion/plugins/reso-energy-pct-in-portal-detail.user.js
Jon Atkins 380bbfda32 more build tweaks
- make update URLS https - required by firefox+greasemonkey
- add build name + date/time to description of all plugins, and moved to front for main IITC
- ensure all plugins have a A.B.C. version number format - required now they append the date+time digits
- no smooth upgrade path from current 'dist' folder - so changed to 'release'. users will have to manually update this time, but will be fine fron now onwards (in theory!)
2013-03-20 04:34:16 +00:00

61 lines
2.1 KiB
JavaScript

// ==UserScript==
// @id iitc-plugin-reso-energy-pct-in-portal-detail@xelio
// @name IITC plugin: reso energy pct in portal detail
// @version 0.1.2.@@DATETIMEVERSION@@
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion
// @updateURL @@UPDATEURL@@
// @downloadURL @@DOWNLOADURL@@
// @description [@@BUILDNAME@@-@@BUILDDATE@@] Show resonator energy percentage on resonator energy bar in portal detail panel.
// @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.resoEnergyPctInPortalDetal = function() {};
window.plugin.resoEnergyPctInPortalDetal.updateMeter = function(data) {
var meterLevel = $("span.meter-level");
meterLevel
.css('top','0px')
.css('left','5px')
.css('margin-left','0px')
.css('font-size','80%')
.css('line-height','18px');
meterLevel.each(function() {
var matchResult = $(this).parent().attr('title').match(/\((\d*\%)\)/);
if(matchResult) {
var newMeterContent = 'L' + $(this).html() + '  ' + matchResult[1];
$(this).html(newMeterContent);
}
});
}
var setup = function() {
window.addHook('portalDetailsUpdated', window.plugin.resoEnergyPctInPortalDetal.updateMeter);
}
// 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);