Page 1 of 1

army and territory count bookmarklet

PostPosted: Sat Sep 29, 2007 8:42 pm
by registered_user
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:

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.

PostPosted: Sat Sep 29, 2007 8:47 pm
by gimil
if you use firefox theres a script that give these states on the in game window.

but its the thought that counts buddy :wink:

may be usful for those people who dont use FF

PostPosted: Sat Sep 29, 2007 8:56 pm
by registered_user
I also just noticed that it doesn't work in team games. It seems that the headlines are list items like the players. Oh well, it's not perfect. edit: fixed -- it now works in team games.

And yes, I've seen the FF add-ons. But I don't like Firefox, and when I do use it, I don't have any real use for Greasemonkey, so I'd just as soon keep the add-ons simple. :)

PostPosted: Sat Sep 29, 2007 8:56 pm
by PerkinsRooster
gimil wrote:
may be usful for those people who dont use FF


or those who use ajax like me

PostPosted: Sat Sep 29, 2007 9:34 pm
by registered_user
I hope you find it useful, Perkins.

Also, I just edited the original post. I fixed the script so that it works in team games.

PostPosted: Sun Sep 30, 2007 6:28 am
by philh
Works in Opera 9.2 as well.

Re: army and territory count bookmarklet

PostPosted: Sat May 03, 2008 2:18 pm
by psaxnoulis
Thanx, man! Saves you from counting... And fatal mistakes...

Re: army and territory count bookmarklet

PostPosted: Mon Jun 09, 2008 6:35 pm
by registered_user
Hey! Does this count towards a Special Contribution medal?

::begs for hand out::

Re: army and territory count bookmarklet

PostPosted: Sat Jun 14, 2008 4:54 pm
by t-o-m
i dont get this?

Re: army and territory count bookmarklet

PostPosted: Sat Jun 14, 2008 4:55 pm
by gdeangel
t-o-m wrote:i dont get this?

It seems to be a poor mans version of BoB... probably for people who don't have firefox / grease monkey.

I haven't tried it...

Re: army and territory count bookmarklet

PostPosted: Sat Oct 10, 2009 5:25 am
by psaxnoulis
just installed on firefox 3.5.3 - works ok

Re: army and territory count bookmarklet

PostPosted: Tue Aug 16, 2011 11:47 am
by Calidrmr
moved to archives by Calidrmr
reason: over 1 year since last post, appears obsolete
shadow topic left for 72 hours