army and territory count bookmarklet
Posted: Sat Sep 29, 2007 8:42 pm
Here's a quick bookmarklet script that may or may not be useful to you folks. I keep it in my bookmarks bar. Basically, you hit the bookmarklet, and the browser shows an alert that contains the players' names and how many armies and territories they have.
To use it, you create a bookmark and change the URL to this:
It's not terribly exciting, and it may have been done before. I hope y'all find it useful. I tested in Safari 2 and Firefox 2.
enjoy.
edit: fixed the script to work in team games.
edit2: conflicted with the attack to drop-down, so I adjusted it, and I removed whitespace and shortened variable names.
To use it, you create a bookmark and change the URL to this:
- Code: Select all
javascript:var np=document.getElementById("players").getElementsByTagName("li").length;var te=new Array();var ar=new Array();var players=new Array();var skip=0;for(var i=0;i<np;i++){te[i]=0;ar[i]=0;var s=document.getElementById("players").getElementsByTagName("li")[i].getElementsByTagName("a")[0]; if(s){players.push(s.getElementsByTagName("span")[0].innerHTML);}else{skip++;}}np=np-skip;var aa=document.getElementById('armies').innerHTML.split(',');for(var i=0;i<aa.length;i++){var seg=aa[i].split("-");ar[seg[0]-1]=(ar[seg[0]-1]*1)+(seg[1]*1);te[seg[0]-1]++;}var output="There are "+np+" players\n---------------\n";for(var i=0;i<np;i++){output+=players[i]+"\n\tTotal Armies: "+ar[i]+"\n\tTotal Territories: "+te[i]+"\n\n";}alert(output);
It's not terribly exciting, and it may have been done before. I hope y'all find it useful. I tested in Safari 2 and Firefox 2.
enjoy.
edit: fixed the script to work in team games.
edit2: conflicted with the attack to drop-down, so I adjusted it, and I removed whitespace and shortened variable names.