accidentally commited old version of guess-player script. Likely it didn’t work at all. Fixes #65
This commit is contained in:
parent
dcb7075dda
commit
6fabe5c5b0
@ -11,16 +11,20 @@
|
|||||||
// ==/UserScript==
|
// ==/UserScript==
|
||||||
|
|
||||||
function wrapper() {
|
function wrapper() {
|
||||||
console.log('hello from plugin');
|
// ensure plugin framework is there, even if iitc is not yet loaded
|
||||||
|
|
||||||
if(typeof window.plugin !== 'function') window.plugin = function() {};
|
if(typeof window.plugin !== 'function') window.plugin = function() {};
|
||||||
|
|
||||||
console.log('window.plugin now is:');
|
|
||||||
console.log(window.plugin);
|
|
||||||
|
|
||||||
|
// PLUGIN START ////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// use own namespace for plugin
|
||||||
|
window.plugin.guessPlayerLevels = function() {};
|
||||||
|
|
||||||
window.plugin.guessPlayerLevels = function() {
|
window.plugin.guessPlayerLevels.setupCallback = function() {
|
||||||
|
$('#toolbox').append('<a onclick="window.plugin.guessPlayerLevels.guess()">guess player levels</a> ');
|
||||||
|
}
|
||||||
|
|
||||||
|
window.plugin.guessPlayerLevels.guess = function() {
|
||||||
var players = {};
|
var players = {};
|
||||||
$.each(window.portals, function(ind, portal) {
|
$.each(window.portals, function(ind, portal) {
|
||||||
var r = portal.options.details.resonatorArray.resonators;
|
var r = portal.options.details.resonatorArray.resonators;
|
||||||
@ -37,19 +41,30 @@ window.plugin.guessPlayerLevels = function() {
|
|||||||
playersNamed[getPlayerName(guid)] = level;
|
playersNamed[getPlayerName(guid)] = level;
|
||||||
});
|
});
|
||||||
|
|
||||||
var s = '';
|
var s = 'the players have at least the following level:\n\n';
|
||||||
$.each(Object.keys(playersNamed).sort, function(ind, playerName) {
|
$.each(Object.keys(playersNamed).sort(), function(ind, playerName) {
|
||||||
s += playerName + ': ' + level;
|
var level = playersNamed[playerName];
|
||||||
|
var nick = (playerName + ': ').slice(0, 20);
|
||||||
|
s += nick + '\t' + level + '\n';
|
||||||
});
|
});
|
||||||
|
|
||||||
|
s += '\n\nIf there are some unresolved names, simply try again.'
|
||||||
|
|
||||||
alert(s);
|
alert(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var setup = window.plugin.guessPlayerLevels.setupCallback;
|
||||||
|
|
||||||
console.log('window.plugin.guessPlayerLevels now is:');
|
// PLUGIN END //////////////////////////////////////////////////////////
|
||||||
console.log(window.plugin.guessPlayerLevels);
|
|
||||||
|
|
||||||
|
|
||||||
|
if(window.iitcLoaded && typeof setup === 'function') {
|
||||||
|
setup();
|
||||||
|
} else {
|
||||||
|
if(window.bootPlugins)
|
||||||
|
window.bootPlugins.push(setup);
|
||||||
|
else
|
||||||
|
window.bootPlugins = [setup];
|
||||||
|
}
|
||||||
} // wrapper end
|
} // wrapper end
|
||||||
// inject code into site context
|
// inject code into site context
|
||||||
var script = document.createElement('script');
|
var script = document.createElement('script');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user