Attack timings/labelling script - all worlds & all browsers

Discussion in 'Scripts & Independent Tools' started by SlowTarget, Sep 19, 2008.

Share This Page

  1. SlowTarget

    SlowTarget Non-stop Poster

    Joined:
    Aug 10, 2007
    Messages:
    472
    Likes Received:
    0
    Here is the script that everyone needs to start off with... it needs to be installed in your quickbar - and yes you need a premium account for it to work...

    It works in chrome, firefox, opera & ie7 browsers...

    It labels the attack as '{unit} ({coords}) {player} F{distance} {sent}' although this can be changed pretty easily...

    to use it..

    copy the code below
    Code:
    javascript:theFormat='{unit} ({coords}) {player} F{distance} {sent}';function c(){var a=document;if(window.frames.length>0)a=window.main.document;var b=a.createElement('script');b.type='text/javascript';b.src='http://legion.problemsolver.co.uk/SlowTarget/labelAttacksStable.js';a.getElementsByTagName('head')[0].appendChild(b);}c();
    Goto Edit QuickBar - add new link and Paste (Ctrl-V) the code into the target URL box

    When you have an attack incoming go to the attack detail screen (not the overview) and click on your quickbar link...

    It generates something like this and only works on the attack detail page...

    [​IMG]

    Here's the full uncompacted version for anyone who wants to see it...labelAttacksStable.js

    You might want to change the following at the beginning of the script - it is a template for labelling your attack
    '{unit} ({coords}) {player} F{distance} {sent}'
    change this to suit your requirements... the bits in curly brackets get replaced by the script.

    The following variables are available...

    • {unit} the troop type that you think the attack is
    • {coords} 'xxx|yyy' of the attacks origin
    • {player} attacking player name
    • {distance} the number of fields away
    • {sent} the date & time the attack was sent (depends on the unit chosen)
    • {duration} hhh:mm:ss (depends on the unit)
    • {arrival} the date and time (including milliseconds) that the attack will land
    • {origin} 'name (xxx|yyy) Knn' of the attacking village
    • {destination} 'name (xxx|yyy) Knn' of the target village
    • {destinationxy} 'xxx|yyy' of the target village

    so if you want the name, then swap coords with origin - and if you don't want the distance then just edit it out...

    e.g. you might want to change it to
    theFormat='{unit} {origin} {player} {sent}';

    for simplicity or even
    theFormat='[player]{player}[/player] attacking [village]{destinationxy}[/village] at {arrival} at {unit} speed';

    for handy forum posting...

    All dates/times are formatted as hh:mm:ss.ttt dd/mm
     
    Last edited: Jan 10, 2009
  2. dbagmcgee

    dbagmcgee Contributing Poster

    Joined:
    Nov 12, 2007
    Messages:
    2,481
    Likes Received:
    1
    Can't get it working... no idea why.
     
  3. SlowTarget

    SlowTarget Non-stop Poster

    Joined:
    Aug 10, 2007
    Messages:
    472
    Likes Received:
    0
    it only works on the attack detail screen... not the overview...

    what browser are you using?
     
  4. dbagmcgee

    dbagmcgee Contributing Poster

    Joined:
    Nov 12, 2007
    Messages:
    2,481
    Likes Received:
    1
    Firefox 3 but maybe I wasn't on the attack detail page. I'm under incomings tab.
     
  5. kalkoenvet

    kalkoenvet Contributing Poster

    Joined:
    Jan 11, 2008
    Messages:
    1,687
    Likes Received:
    6
    Thank you for this Slowtarget, but I have a problem. When I want to label an attack and press on the link I have on the quickbar, it makes my tw screen smaller. How to make this not happen?
     
  6. Piaf

    Piaf Non-stop Poster

    Joined:
    Mar 16, 2008
    Messages:
    368
    Likes Received:
    0
    no w9?
     
  7. dbagmcgee

    dbagmcgee Contributing Poster

    Joined:
    Nov 12, 2007
    Messages:
    2,481
    Likes Received:
    1
    K I do not know where the attack details button is.
     
  8. sacredfool

    sacredfool Part of the Furniture

    Joined:
    Jun 13, 2007
    Messages:
    5,402
    Likes Received:
    8
    It's when you click an incomming. You have to run it for every single attack.
     
  9. dbagmcgee

    dbagmcgee Contributing Poster

    Joined:
    Nov 12, 2007
    Messages:
    2,481
    Likes Received:
    1
    Yeah it still bring me to a blank page.
     
  10. Cleostine

    Cleostine Active Member

    Joined:
    Jan 10, 2008
    Messages:
    43
    Likes Received:
    0
    It is working great for me in W15 and Opera - thanks!
     
  11. SlowTarget

    SlowTarget Non-stop Poster

    Joined:
    Aug 10, 2007
    Messages:
    472
    Likes Received:
    0
    have another look - the second lot of code...
     
  12. SlowTarget

    SlowTarget Non-stop Poster

    Joined:
    Aug 10, 2007
    Messages:
    472
    Likes Received:
    0
    it gets rid of ALL table width restrictions while you are labelling the attack... it makes it look better on screen imho - post up a screen shot of before and after, so I can see the prob - when you go to the next screen it should all be ok again...

    I have posted up an alternate W10 script in the top post which you can run alongside your existing one - let me know which you prefer. I'll send you a few attacks for you to run it against :)
     
  13. cooled ice

    cooled ice Contributing Poster

    Joined:
    Aug 23, 2007
    Messages:
    1,681
    Likes Received:
    0
    is this legal?
     
  14. SlowTarget

    SlowTarget Non-stop Poster

    Joined:
    Aug 10, 2007
    Messages:
    472
    Likes Received:
    0
    I have asked...
     
  15. iulian28ti

    iulian28ti New Member

    Joined:
    Jul 11, 2008
    Messages:
    1
    Likes Received:
    0
    I would like to know too if it's legal.
     
  16. fleece93

    fleece93 Well-Known Member

    Joined:
    Jul 9, 2008
    Messages:
    84
    Likes Received:
    0
    ofc it is,it just give you the times,you still have to choose when it was sent
     
  17. SlowTarget

    SlowTarget Non-stop Poster

    Joined:
    Aug 10, 2007
    Messages:
    472
    Likes Received:
    0
    imho it is legal... but until Eechen makes a decision you have to make your own mind up.... install it and evaluate what it does - if you think that it does anything that is against the rules then stop using it and uninstall it...

    Appreciate that many players are using it and think that its fine... but you have to make your own mind up.
     
  18. strato75

    strato75 New Member

    Joined:
    Jul 6, 2008
    Messages:
    1
    Likes Received:
    0
    I just found your script and tested it, really great, thanks :)

    For my part, I don't think either that it does anything against the rules. Just given an easy way to rename an attack, thing that I normally do manually.

    You always need to know when the attack has started and time needed to cross the distance.

    If it will marked as no legal, then I'll stop to use it.
     
  19. kebabe8

    kebabe8 Contributing Poster

    Joined:
    Mar 24, 2008
    Messages:
    2,169
    Likes Received:
    2
    If im not confused then i think i can help :)

    At TEST(W23) we use PP's Attack Renamer. Here it is fresh of our forums :icon_razz:

    Attack Renamer - This will without question save your ass
    at some point. I have a video showing how it is used as well.
    VIDEO LINK

    Code:
    javascript:var tm;t=document.getElementsByTagName('table');for(var i=0;i<t.length;i++){if(t[i].className=='main'){tm=t[i].getElementsByTagName('tbody')[0];break;}}ts=tm.getElementsByTagName('table');for(var j=0;j<ts.length;j++){if(ts[j].className='vis'){tv=ts[j].getElementsByTagName('tbody')[0];sp=ts[j].getElementsByTagName('span');for(var k=0;k<sp.length;k++){if(sp[k].getElementsByTagName('input').length>0){se=sp[k];}}z=tv.getElementsByTagName('tr');a=z[1].getElementsByTagName('td')[2].getElementsByTagName('a')[0].innerHTML;s=z[2].getElementsByTagName('td')[1].getElementsByTagName('a')[0].firstChild.nodeValue;g=z[4].getElementsByTagName('td')[1].getElementsByTagName('a')[0].firstChild.nodeValue;for(k=z.length-2;k>2;--k){if(z[k].getElementsByTagName('td')[0].firstChild.nodeValue=='Ankomst om:'){Dauer=z[k].getElementsByTagName('td')[1].innerHTML;}else{tv.removeChild(z[k]);}}break;}}h=s.split('(');s=h[h.length-1];h=s.split(')');s=h[0];h=g.split('(');g=h[h.length-1];h=g.split(')');g=h[0];wx=0;wy=0;Typ=s.split(':');if (Typ.length==3){StKo=s.split(':');ZiKo=g.split(':');wx=Math.abs(((StKo[0]% 10)*50+(StKo[1]% 10)*5+StKo[2]%5)-((ZiKo[0]% 10)*50+(ZiKo[1]% 10)*5+ZiKo[2]%5));wy=Math.abs((Math.floor(StKo[0]/10)*50+Math.floor(StKo[1]/10)*5+Math.floor(StKo[2]/5))-(Math.floor(ZiKo[0]/10)*50+Math.floor(ZiKo[1]/10)*5+Math.floor(ZiKo[2]/5)));}else{StKo=s.split('|');ZiKo=g.split('|');wx=Math.abs(StKo[0]-ZiKo[0]);wy=Math.abs(StKo[1]-ZiKo[1]);}w=Math.sqrt(wx*wx+wy*wy);tv.width='470';nr=document.createElement('tr');nh=document.createElement('th');nc=document.createElement('td');nc.colSpan='2';nc.innerHTML='Distance:';nr.appendChild(nc.cloneNode(true));nc.removeAttribute('colSpan');nc.innerHTML=w.toFixed(2)+' Fields';nr.appendChild(nc);nc=nc.cloneNode(false);tv.insertBefore(nr.cloneNode(true),z[z.length-1]);nc.height='10';nc.colSpan='3';nr.innerHTML='';nr.appendChild(nc);tv.appendChild(nr);nr=nr.cloneNode(false);nc=document.createElement('td');nr.appendChild(nc);nr=document.createElement('tr');nh.innerHTML='Unit';nr.appendChild(nh.cloneNode(true));nh.innerHTML='Duration';nr.appendChild(nh.cloneNode(true));nh.innerHTML='Name to';nr.appendChild(nh.cloneNode(true));tv.appendChild(nr);ie=tv.getElementsByTagName('input')[0].cloneNode(true);ib=tv.getElementsByTagName('input')[1].cloneNode(true);e=new Array('Scout','LC','HC','Axe','Sword','Ram','Noble');n=new Array('SCOUT','LC','HC','AXE','SWORD','RAMS','**NOBLE**');l=new Array(7.5,8.33,9.17,15,18.33,25,29.17);ie.size='36';for(var i=0;i<e.length;i++){t3=new Array();es=Math.round(l[i]*60*w);te='';t3[0]=Math.floor(es/3600);t3[1]=Math.floor(es/60)% 60;t3[2]=es% 60;for(var j=0;j<3;j++){if(t3[j]<10){te+='0';}te+=t3[j]+':';}te=te.slice(0,te.length-1);ie.value=n[i]+' ('+s+') '+a+' F'+w.toFixed(1);nr=document.createElement('tr');nc=document.createElement('td');nc.innerHTML=e[i];nr.appendChild(nc.cloneNode(true));nc.innerHTML=te;nr.appendChild(nc);nc=document.createElement('td');ie.id='editInput'+i;nc.appendChild(ie.cloneNode(true));ii=ib.cloneNode(true);ii.onmousedown=new Function('document.getElementById(\'editInput\').value=document.getElementById(\'editInput'+i+'\').value;');nc.appendChild(ii);nr.appendChild(nc);tv.appendChild(nr);}s();
     
  20. SlowTarget

    SlowTarget Non-stop Poster

    Joined:
    Aug 10, 2007
    Messages:
    472
    Likes Received:
    0
    thanks for posting the video link - the script in the OP is an improvement of this script...

    The differences between this one and that are

    1. easier to adjust times between worlds
    2. Sent times shown
    3. Some bugfixes
    4. Works in IE!