diff --git a/code/boot.js b/code/boot.js index 8ebce5b0..abcd1ec6 100644 --- a/code/boot.js +++ b/code/boot.js @@ -176,6 +176,11 @@ function boot() { window.PLAYER['nickMatcher'] = new RegExp('\\b('+n+')\\b', 'ig'); $('#sidebar').show(); + + if(window.bootPlugins) + $.each(window.bootPlugins, function(ind, ref) { ref(); }); + + window.iitcLoaded = true; } // this is the minified load.js script that allows us to easily load diff --git a/main.js b/main.js index fa09fa8e..91b5ecde 100644 --- a/main.js +++ b/main.js @@ -65,6 +65,8 @@ document.getElementsByTagName('body')[0].innerHTML = '' + ' ' + '
' + ' ' + + ' ' + + ' ' + ' ' + ' '; + ''; @@ -162,6 +164,9 @@ window.portals = {}; window.links = {}; window.fields = {}; +// plugin framework. Plugins may load earlier than iitc, so don’t +// overwrite data +if(typeof window.plugin !== 'function') window.plugin = function() {}; @@INJECTHERE@@ diff --git a/plugins/README.md b/plugins/README.md new file mode 100644 index 00000000..1b872227 --- /dev/null +++ b/plugins/README.md @@ -0,0 +1,22 @@ +Plugins +======= + +Install +------- +Plugins are installed the same way the total conversion script is. Please see there for specific instructions for your browser. + + +Available Plugins +----------------- + +- [**Guess Player Level**](https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/guess-player-levels.user.js) looks for the highest placed resonator per player in the current view to guess the player level. + + +Hacking +------- + +Plugins may be developed in the same way as the total conversion script. Plugins may provide features tailored to specific needs and are allowed to change things as they see fit. You can provide them separately oder submit a pull request to have them managed in this repository. There are currently no hooks that allow integration with the main script, but I will add those if the need arises. Simply open a bug report. + +You can use the guess player level script as an example to get you started. Just update the names and the part between `// PLUGIN START` and `// PLUGIN END` and you should be able to develop your plugin. The other code ensures your plugin is executed after the main script. + +If you happen the write general purpose functions for your plugin, consider adding them to the main script instead. For example, if you write a `getResoCountFromPortal(details)` function it may be very well added to `code/portal_info.js`. diff --git a/plugins/guess-player-levels.user.js b/plugins/guess-player-levels.user.js new file mode 100644 index 00000000..898621f5 --- /dev/null +++ b/plugins/guess-player-levels.user.js @@ -0,0 +1,57 @@ +// ==UserScript== +// @id iitc-plugin-guess-player-levels@breunigs +// @name iitc: guess player level +// @version 0.1 +// @namespace https://github.com/breunigs/ingress-intel-total-conversion +// @updateURL https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/guess-player-levels.user.js +// @downloadURL https://raw.github.com/breunigs/ingress-intel-total-conversion/gh-pages/plugins/guess-player-levels.user.js +// @description Tries to determine player levels from the data available in the current view +// @include http://www.ingress.com/intel* +// @match http://www.ingress.com/intel* +// ==/UserScript== + +function wrapper() { +console.log('hello from plugin'); + +if(typeof window.plugin !== 'function') window.plugin = function() {}; + +console.log('window.plugin now is:'); +console.log(window.plugin); + + + +window.plugin.guessPlayerLevels = function() { + var players = {}; + $.each(window.portals, function(ind, portal) { + var r = portal.options.details.resonatorArray.resonators; + $.each(r, function(ind, reso) { + if(!reso) return true; + var p = reso.ownerGuid; + var l = reso.level; + if(!players[p] || players[p] < l) players[p] = l; + }); + }); + + var playersNamed = {}; + $.each(players, function(guid, level) { + playersNamed[getPlayerName(guid)] = level; + }); + + var s = ''; + $.each(Object.keys(playersNamed).sort, function(ind, playerName) { + s += playerName + ': ' + level; + }); + + alert(s); +} + + +console.log('window.plugin.guessPlayerLevels now is:'); +console.log(window.plugin.guessPlayerLevels); + + +} // 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); diff --git a/style.css b/style.css index f0432e50..683c2963 100644 --- a/style.css +++ b/style.css @@ -35,12 +35,6 @@ body { overflow-x:hidden; } -#redeem { - /* cheap hack to prevent sidebar content being overlayed by the map - * status box */ - margin-bottom: 55px; -} - .enl { color: #03fe03 !important; @@ -489,6 +483,17 @@ aside:nth-child(odd) span { width: 140px; } +#toolbox { + padding: 4px; + font-size:90%; +} + +#spacer { + /* cheap hack to prevent sidebar content being overlayed by the map + * status box */ + height: 55px; +} + /* a common portal display takes this much space (prevents moving * content when first selecting a portal) */