diff --git a/plugins/dynamic-scoreboard.user.js b/plugins/dynamic-scoreboard.user.js deleted file mode 100644 index fa4fbe21..00000000 --- a/plugins/dynamic-scoreboard.user.js +++ /dev/null @@ -1,310 +0,0 @@ -// ==UserScript== -// @id iitc-plugin-dynamic-scoreboard@Costaspap -// @name IITC plugin: Create a local scoreboard -// @category Info -// @version 0.1.0.20140524.214738 -// @namespace https://github.com/jonatkins/ingress-intel-total-conversion -// @updateURL https://secure.jonatkins.com/iitc/release/plugins/dynamic-scoreboard.meta.js -// @downloadURL https://secure.jonatkins.com/iitc/release/plugins/dynamic-scoreboard.user.js -// @description Display a scoreboard about all visible portals with statistics about both teams,like average portal level,link & field counts etc. -// @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== - - -// A plug in by Costaspap and harisbitsakou -function wrapper(plugin_info) { - // ensure plugin framework is there, even if iitc is not yet loaded - if(typeof window.plugin !== 'function') window.plugin = function() {}; - - //PLUGIN AUTHORS: writing a plugin outside of the IITC build environment? if so, delete these lines!! - //(leaving them in place might break the 'About IITC' page or break update checks) - plugin_info.buildName = 'jonatkins'; - plugin_info.dateTimeVersion = '20140524.214738'; - plugin_info.pluginId = 'dynamic-scoreboard'; - //END PLUGIN AUTHORS NOTE - - // PLUGIN START // - - // use own namespace for plugin - window.plugin.scoreboard = function() {}; - - - - - - //gets data of all the visible portals on the screen - window.plugin.scoreboard.getPortals = function() { - - var retval=false; - - var displayBounds = map.getBounds(); - - - window.plugin.scoreboard.enlP = 0; - window.plugin.scoreboard.resP = 0; - window.plugin.scoreboard.enlEightLevelP = 0; - window.plugin.scoreboard.resEightLevelP = 0; - window.plugin.scoreboard.enlPorLevels = 0; - window.plugin.scoreboard.resPorLevels = 0; - window.plugin.scoreboard.maxEnl=0; - window.plugin.scoreboard.maxRes=0; - window.plugin.scoreboard.healthEnl = 0; - window.plugin.scoreboard.healthRes = 0; - - - //get all portals on screen - $.each(window.portals, function(i, portal) { - // eliminate offscreen portals (selected, and in padding) - if(!displayBounds.contains(portal.getLatLng())) return true; - //if there are any portals return true - retval=true; - - //variable that contains portal data - var d = portal.options.data; - - //variable that contains each portal's team value - var teamN = portal.options.team; - - switch (teamN) { - case TEAM_RES: //if the portal is captured by the resistance,increase each counter's value for resistance counters - window.plugin.scoreboard.healthRes += d.health; - window.plugin.scoreboard.resP++; - window.plugin.scoreboard.resPorLevels = window.plugin.scoreboard.resPorLevels + portal.options.level; - if(portal.options.level===8){window.plugin.scoreboard.resEightLevelP++;} - if(portal.options.level>window.plugin.scoreboard.maxRes){window.plugin.scoreboard.maxRes = portal.options.level;} - break; - case TEAM_ENL: //if the portal is captured by the enlightened,increase each counter's value for enlightened counters - window.plugin.scoreboard.healthEnl += d.health; - window.plugin.scoreboard.enlP++; - window.plugin.scoreboard.enlPorLevels = window.plugin.scoreboard.enlPorLevels + portal.options.level; - if(portal.options.level===8){window.plugin.scoreboard.enlEightLevelP++;} - if(portal.options.level>window.plugin.scoreboard.maxEnl){window.plugin.scoreboard.maxEnl = portal.options.level;} - break; - } - - - - - - - }); - - return retval; - } - - // The final function that displays the scoreboard by calling the portalTable function - window.plugin.scoreboard.displayScoreboard = function() { - var html = ''; - - // If there are not portals on screen,display "Nothing to show!" - if (window.plugin.scoreboard.getPortals()) { - html += window.plugin.scoreboard.portalTable(); - } else { - html = '
Nothing to show!
'; - }; - - if(window.useAndroidPanes()) { - $('
' + html + '
').appendTo(document.body); - } else { - dialog({ - html: '
' + html + '
', - dialogClass: 'ui-dialog-scoreboard', - title: 'Scoreboard', - id: 'Scoreboard', - width: 700 - }); - } - } - - - - //---- function that gets all visible enlightened links on screen - window.plugin.scoreboard.getEnlLinks = function() { - var displayBounds = map.getBounds(); - window.plugin.scoreboard.enlL=0; - // now every link that starts/ends at a point on screen - $.each(window.links, function(guid, link) { - // only consider links that start/end on-screen - var points = link.getLatLngs(); - if (displayBounds.contains(points[0]) || displayBounds.contains(points[1])) { - if (link.options.team === TEAM_ENL) { - window.plugin.scoreboard.enlL++; - } - } - }); - return window.plugin.scoreboard.enlL; - } - - - //----function that gets all visible resistance links on screen - window.plugin.scoreboard.getResLinks = function() { - var displayBounds = map.getBounds(); - window.plugin.scoreboard.resL=0; - // now every link that starts/ends at a point on screen - $.each(window.links, function(guid, link) { - // only consider links that start/end on-screen - var points = link.getLatLngs(); - if (displayBounds.contains(points[0]) || displayBounds.contains(points[1])) {// boroume na kanoume ta 2 if ena - if (link.options.team === TEAM_RES) { - window.plugin.scoreboard.resL++; - } - } - }); - return window.plugin.scoreboard.resL; - } - - - - - - //----function that gets all visible enlightened fields on screen - window.plugin.scoreboard.getEnlFields = function() { - var displayBounds = map.getBounds(); - window.plugin.scoreboard.enlF=0; - // and now all fields that have a vertex on screen - $.each(window.fields, function(guid, field) { - // only consider fields with at least one vertex on screen - var points = field.getLatLngs(); - if (displayBounds.contains(points[0]) || displayBounds.contains(points[1]) || displayBounds.contains(points[2])) { - if (field.options.team === TEAM_ENL) { - window.plugin.scoreboard.enlF++; - } - } - }); - return window.plugin.scoreboard.enlF; - } - - - - //----function that gets all visible resistance fields on screen - window.plugin.scoreboard.getResFields = function() { - var displayBounds = map.getBounds(); - window.plugin.scoreboard.resF=0; - // and now all fields that have a vertex on screen - $.each(window.fields, function(guid, field) { - // only consider fields with at least one vertex on screen - var points = field.getLatLngs(); - if (displayBounds.contains(points[0]) || displayBounds.contains(points[1]) || displayBounds.contains(points[2])) { - if (field.options.team === TEAM_RES) { - window.plugin.scoreboard.resF++; - } - } - }); - return window.plugin.scoreboard.resF; - } - - - - // A function that creates the html code for the scoreboard table - window.plugin.scoreboard.portalTable = function() { - - - // html variable declaration - var html = ""; - // Create the header - html += '' - + '' - + '' - + '' - + '' - + '\n'; - - // if blocks to avoid division by zero - if(window.plugin.scoreboard.enlP!=0){ - var avgEnl = window.plugin.scoreboard.enlPorLevels/window.plugin.scoreboard.enlP; - avgEnl = avgEnl.toFixed(1); - var avgHealthEnl = window.plugin.scoreboard.healthEnl/window.plugin.scoreboard.enlP; - avgHealthEnl = avgHealthEnl.toFixed(1) - } else{ - var avgEnl = '-'; - var avgHealthEnl = '0'; - } - - if(window.plugin.scoreboard.resP!=0){ - var avgRes = window.plugin.scoreboard.resPorLevels/window.plugin.scoreboard.resP; - avgRes = avgRes.toFixed(1); - var avgHealthRes = window.plugin.scoreboard.healthRes/window.plugin.scoreboard.resP; - avgHealthRes = avgHealthRes.toFixed(1); - } else { - var avgRes = '-'; - var avgHealthRes = '0'; - } - - - - // Get field-link count and assign them to variables - var enlCountOfLinks= window.plugin.scoreboard.getEnlLinks(); - var resCountOfLinks= window.plugin.scoreboard.getResLinks(); - var enlCountOfFields= window.plugin.scoreboard.getEnlFields(); - var resCountOfFields= window.plugin.scoreboard.getResFields(); - - // Creation of the html code - html += ''+''+'' - +''+''+'' - +''+''+'' - +''+''+'' - +''+''+'' - +''+''+'' - +''+''+''; - - - - html += '
MetricsEnlightenedResistance
Number of Portals' - +window.plugin.scoreboard.enlP+''+window.plugin.scoreboard.resP+'
Average Portal Level' - +avgEnl+''+avgRes+'
Number of Level 8 Portals' - +window.plugin.scoreboard.enlEightLevelP+''+window.plugin.scoreboard.resEightLevelP+'
Max Portal Level' - +window.plugin.scoreboard.maxEnl+''+window.plugin.scoreboard.maxRes+'
Number of Links' - +enlCountOfLinks+''+resCountOfLinks+'
Number of Fields' - +enlCountOfFields+''+resCountOfFields+'
Average portal Health' - +avgHealthEnl+'%'+avgHealthRes+'%
'; - - html += '
Zoom in for a more accurate scoreboard!
'; - - return html; - } - - - - var setup = function() { - if(window.useAndroidPanes()) { // use android panes,texture and style - android.addPane("plugin-Scoreboard", "Scoreboard", "ic_action_paste"); - addHook("paneChanged", window.plugin.scoreboard.onPaneChanged); - } else { - $('#toolbox').append(' Scoreboard'); - } - - $('head').append(''); - } - - - // PLUGIN END ////////////////////////////////////////////////////////// - - - setup.info = plugin_info; //add the script info data to the function as a property - if(!window.bootPlugins) window.bootPlugins = []; - window.bootPlugins.push(setup); - // if IITC has already booted, immediately run the 'setup' function - if(window.iitcLoaded && typeof setup === 'function') setup(); -} // wrapper end -// inject code into site context -var script = document.createElement('script'); -var info = {}; -if (typeof GM_info !== 'undefined' && GM_info && GM_info.script) info.script = { version: GM_info.script.version, name: GM_info.script.name, description: GM_info.script.description }; -script.appendChild(document.createTextNode('('+ wrapper +')('+JSON.stringify(info)+');')); -(document.body || document.head || document.documentElement).appendChild(script); - \ No newline at end of file diff --git a/plugins/scoreboard.user.js b/plugins/scoreboard.user.js index 52ee4d9b..a969499e 100644 --- a/plugins/scoreboard.user.js +++ b/plugins/scoreboard.user.js @@ -1,15 +1,310 @@ // ==UserScript== -// @id iitc-plugin-scoreboard@vita10gy +// @id iitc-plugin-scoreboard@Costaspap // @name IITC plugin: show a localized scoreboard. -// @category Deleted -// @version 0.1.9.@@DATETIMEVERSION@@ +// @version 0.2.0.@@DATETIMEVERSION@@ +// @category Info // @namespace https://github.com/jonatkins/ingress-intel-total-conversion // @updateURL @@UPDATEURL@@ // @downloadURL @@DOWNLOADURL@@ -// @description This plugin is no longer available, as Niantic optimisations have removed the data it needed. +// @description [@@BUILDNAME@@-@@BUILDDATE@@] Display a scoreboard about all visible portals with statistics about both teams,like average portal level,link & field counts etc. // @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== + + +// A plug in by Costaspap and harisbitsakou +function wrapper(plugin_info) { + // ensure plugin framework is there, even if iitc is not yet loaded + if(typeof window.plugin !== 'function') window.plugin = function() {}; + + //PLUGIN AUTHORS: writing a plugin outside of the IITC build environment? if so, delete these lines!! + //(leaving them in place might break the 'About IITC' page or break update checks) + plugin_info.buildName = 'jonatkins'; + plugin_info.dateTimeVersion = '20140524.214738'; + plugin_info.pluginId = 'scoreboard'; + //END PLUGIN AUTHORS NOTE + + // PLUGIN START // + + // use own namespace for plugin + window.plugin.scoreboard = function() {}; + + + + + + //gets data of all the visible portals on the screen + window.plugin.scoreboard.getPortals = function() { + + var retval=false; + + var displayBounds = map.getBounds(); + + + window.plugin.scoreboard.enlP = 0; + window.plugin.scoreboard.resP = 0; + window.plugin.scoreboard.enlEightLevelP = 0; + window.plugin.scoreboard.resEightLevelP = 0; + window.plugin.scoreboard.enlPorLevels = 0; + window.plugin.scoreboard.resPorLevels = 0; + window.plugin.scoreboard.maxEnl=0; + window.plugin.scoreboard.maxRes=0; + window.plugin.scoreboard.healthEnl = 0; + window.plugin.scoreboard.healthRes = 0; + + + //get all portals on screen + $.each(window.portals, function(i, portal) { + // eliminate offscreen portals (selected, and in padding) + if(!displayBounds.contains(portal.getLatLng())) return true; + //if there are any portals return true + retval=true; + + //variable that contains portal data + var d = portal.options.data; + + //variable that contains each portal's team value + var teamN = portal.options.team; + + switch (teamN) { + case TEAM_RES: //if the portal is captured by the resistance,increase each counter's value for resistance counters + window.plugin.scoreboard.healthRes += d.health; + window.plugin.scoreboard.resP++; + window.plugin.scoreboard.resPorLevels = window.plugin.scoreboard.resPorLevels + portal.options.level; + if(portal.options.level===8){window.plugin.scoreboard.resEightLevelP++;} + if(portal.options.level>window.plugin.scoreboard.maxRes){window.plugin.scoreboard.maxRes = portal.options.level;} + break; + case TEAM_ENL: //if the portal is captured by the enlightened,increase each counter's value for enlightened counters + window.plugin.scoreboard.healthEnl += d.health; + window.plugin.scoreboard.enlP++; + window.plugin.scoreboard.enlPorLevels = window.plugin.scoreboard.enlPorLevels + portal.options.level; + if(portal.options.level===8){window.plugin.scoreboard.enlEightLevelP++;} + if(portal.options.level>window.plugin.scoreboard.maxEnl){window.plugin.scoreboard.maxEnl = portal.options.level;} + break; + } + + + + + + + }); + + return retval; + } + + // The final function that displays the scoreboard by calling the portalTable function + window.plugin.scoreboard.displayScoreboard = function() { + var html = ''; + + // If there are not portals on screen,display "Nothing to show!" + if (window.plugin.scoreboard.getPortals()) { + html += window.plugin.scoreboard.portalTable(); + } else { + html = '
Nothing to show!
'; + }; + + if(window.useAndroidPanes()) { + $('
' + html + '
').appendTo(document.body); + } else { + dialog({ + html: '
' + html + '
', + dialogClass: 'ui-dialog-scoreboard', + title: 'Scoreboard', + id: 'Scoreboard', + width: 700 + }); + } + } + + + + //---- function that gets all visible enlightened links on screen + window.plugin.scoreboard.getEnlLinks = function() { + var displayBounds = map.getBounds(); + window.plugin.scoreboard.enlL=0; + // now every link that starts/ends at a point on screen + $.each(window.links, function(guid, link) { + // only consider links that start/end on-screen + var points = link.getLatLngs(); + if (displayBounds.contains(points[0]) || displayBounds.contains(points[1])) { + if (link.options.team == TEAM_ENL) { + window.plugin.scoreboard.enlL++; + } + } + }); + return window.plugin.scoreboard.enlL; + } + + + //----function that gets all visible resistance links on screen + window.plugin.scoreboard.getResLinks = function() { + var displayBounds = map.getBounds(); + window.plugin.scoreboard.resL=0; + // now every link that starts/ends at a point on screen + $.each(window.links, function(guid, link) { + // only consider links that start/end on-screen + var points = link.getLatLngs(); + if (displayBounds.contains(points[0]) || displayBounds.contains(points[1])) {// boroume na kanoume ta 2 if ena + if (link.options.team == TEAM_RES) { + window.plugin.scoreboard.resL++; + } + } + }); + return window.plugin.scoreboard.resL; + } + + + + + + //----function that gets all visible enlightened fields on screen + window.plugin.scoreboard.getEnlFields = function() { + var displayBounds = map.getBounds(); + window.plugin.scoreboard.enlF=0; + // and now all fields that have a vertex on screen + $.each(window.fields, function(guid, field) { + // only consider fields with at least one vertex on screen + var points = field.getLatLngs(); + if (displayBounds.contains(points[0]) || displayBounds.contains(points[1]) || displayBounds.contains(points[2])) { + if (field.options.team == TEAM_ENL) { + window.plugin.scoreboard.enlF++; + } + } + }); + return window.plugin.scoreboard.enlF; + } + + + + //----function that gets all visible resistance fields on screen + window.plugin.scoreboard.getResFields = function() { + var displayBounds = map.getBounds(); + window.plugin.scoreboard.resF=0; + // and now all fields that have a vertex on screen + $.each(window.fields, function(guid, field) { + // only consider fields with at least one vertex on screen + var points = field.getLatLngs(); + if (displayBounds.contains(points[0]) || displayBounds.contains(points[1]) || displayBounds.contains(points[2])) { + if (field.options.team == TEAM_RES) { + window.plugin.scoreboard.resF++; + } + } + }); + return window.plugin.scoreboard.resF; + } + + + + // A function that creates the html code for the scoreboard table + window.plugin.scoreboard.portalTable = function() { + + + // html variable declaration + var html = ""; + // Create the header + html += '' + + '' + + '' + + '' + + '' + + '\n'; + + // if blocks to avoid division by zero + if(window.plugin.scoreboard.enlP!=0){ + var avgEnl = window.plugin.scoreboard.enlPorLevels/window.plugin.scoreboard.enlP; + avgEnl = avgEnl.toFixed(1); + var avgHealthEnl = window.plugin.scoreboard.healthEnl/window.plugin.scoreboard.enlP; + avgHealthEnl = avgHealthEnl.toFixed(1) } + else{ + var avgEnl = '-'; + var avgHealthEnl = '0'; + } + + if(window.plugin.scoreboard.resP!=0){ + var avgRes = window.plugin.scoreboard.resPorLevels/window.plugin.scoreboard.resP; + avgRes = avgRes.toFixed(1); + var avgHealthRes = window.plugin.scoreboard.healthRes/window.plugin.scoreboard.resP; + avgHealthRes = avgHealthRes.toFixed(1); + } + else{ + var avgRes = '-'; + var avgHealthRes = '0'; + } + + + // Get field-link count and assign them to variables + var enlCountOfLinks= window.plugin.scoreboard.getEnlLinks(); + var resCountOfLinks= window.plugin.scoreboard.getResLinks(); + var enlCountOfFields= window.plugin.scoreboard.getEnlFields(); + var resCountOfFields= window.plugin.scoreboard.getResFields(); + + // Creation of the html code + html += ''+''+'' + +''+''+'' + +''+''+'' + +''+''+'' + +''+''+'' + +''+''+'' + +''+''+''; + + + + html += '
MetricsEnlightenedResistance
Number of Portals' + +window.plugin.scoreboard.enlP+''+window.plugin.scoreboard.resP+'
Average Portal Level' + +avgEnl+''+avgRes+'
Number of Level 8 Portals' + +window.plugin.scoreboard.enlEightLevelP+''+window.plugin.scoreboard.resEightLevelP+'
Max Portal Level' + +window.plugin.scoreboard.maxEnl+''+window.plugin.scoreboard.maxRes+'
Number of Links' + +enlCountOfLinks+''+resCountOfLinks+'
Number of Fields' + +enlCountOfFields+''+resCountOfFields+'
Average portal Health' + +avgHealthEnl+'%'+avgHealthRes+'%
'; + + html += '
Zoom in for a more accurate scoreboard!
'; + + return html; + } + + + + var setup = function() { + if(window.useAndroidPanes()) { // use android panes,texture and style + android.addPane("plugin-Scoreboard", "Scoreboard", "ic_action_paste"); + addHook("paneChanged", window.plugin.scoreboard.onPaneChanged); + } else { + $('#toolbox').append(' Scoreboard'); + } + + $('head').append(''); + } + + + // PLUGIN END ////////////////////////////////////////////////////////// + + + setup.info = plugin_info; //add the script info data to the function as a property + if(!window.bootPlugins) window.bootPlugins = []; + window.bootPlugins.push(setup); + // if IITC has already booted, immediately run the 'setup' function + if(window.iitcLoaded && typeof setup === 'function') setup(); +} // wrapper end +// inject code into site context +var script = document.createElement('script'); +var info = {}; +if (typeof GM_info !== 'undefined' && GM_info && GM_info.script) info.script = { version: GM_info.script.version, name: GM_info.script.name, description: GM_info.script.description }; +script.appendChild(document.createTextNode('('+ wrapper +')('+JSON.stringify(info)+');')); +(document.body || document.head || document.documentElement).appendChild(script); + \ No newline at end of file