11// ==UserScript== 
22// @name        DG utilities 
33// @namespace   devhex 
4- // @version     0.3.0009  
4+ // @version     0.3.0010  
55// @description   various minor improvements of DG interface 
66// @match       https://beta.darkgalaxy.com/ 
77// @match       https://beta.darkgalaxy.com/* 
1010
1111/* Config start */ 
1212var  nap_ally  =  [  "[ALLY1]" ,  "[ALLY2]"  ] ;  // Which alliances you want to be color coded as NAP. Note the brackets. 
13- var  custom_style  =  "COLOR: #FFD54F ;" ;  // Color specified for NAP 
13+ var  custom_style  =  "COLOR: #FFE66F ;" ;  // Color specified for NAP 
1414/* Config end */ 
1515
1616/* Common counters & pointers */ 
@@ -170,12 +170,10 @@ if (location.href.includes('/fleet/')&&document.querySelector('.nextPrevFleet, .
170170  Original concept by Mordread 
171171  Refactored by Arcopix 
172172*/ 
173- var  numberWithCommas ; 
174173var  line ; 
175174var  availablePopulation ,  occupiedPopulation ; 
176175var  planets ; 
177176if  ( location . href . includes ( '/planet/' ) )  { 
178-     numberWithCommas  =  ( x )  =>  x . toString ( ) . replace ( / \B (? = ( \d { 3 } ) + (? ! \d ) ) / g,  "," ) ; 
179177    line  =  document . getElementsByClassName ( 'resource' ) [ 3 ] ; 
180178    availablePopulation  =  line . getElementsByTagName ( 'span' ) [ 0 ] . innerText . split ( ' / ' ) [ 0 ] ; 
181179    occupiedPopulation  =  line . getElementsByTagName ( 'span' ) [ 2 ] . innerText . replace ( '(' ,  '' ) . replace ( ' occupied)' ,  '' ) 
@@ -207,15 +205,17 @@ for (i=0; i<coords.length; i++)
207205{ 
208206    let  c  =  coords [ i ] ; 
209207    /* In planet details there is no span on the planer coordinates */ 
210-     if  ( ! location . href . includes ( '/planet/' ) )  { 
211-         c  =  c . getElementsByTagName ( 'span' ) [ 0 ] ; 
208+     let  __c  =  c . getElementsByTagName ( 'span' ) [ 0 ] ; 
209+     if  ( __c )  { 
210+         c  =  __c ; 
212211    } 
213212
214213    /* Don't bother with home planets */ 
215214    if  ( typeof  c  !==  'undefined'  &&  typeof  c . innerText  !==  'undefined'  &&  c . innerText == '0.0.0' )  { 
216215        continue ; 
217216    } 
218-     if  ( c  &&  c . innerText . match ( / [ 0 - 9 ] + \. [ 0 - 9 ] + \. [ 0 - 9 ] + / g) )  { 
217+ 
218+     if  ( c  &&  c . innerText . match ( / ^ [ 0 - 9 ] + \. [ 0 - 9 ] + \. [ 0 - 9 ] + $ / g) )  { 
219219        let  p  =  c . innerText . split ( '.' ) ; 
220220        c . innerHTML  =  '<a href="/navigation/'  +  p [ 0 ]  +  '/'  +  p [ 1 ]  +  '/">'  +  c . innerHTML  +  '</a>' ; 
221221    } 
@@ -242,10 +242,17 @@ if (location.href.includes('/radar/')) {
242242            fleetRow [ j ] . parentNode . removeChild ( fleetRow [ j ] ) ; 
243243        } 
244244
245+         n  =  0 ; 
245246        /* For every possible TICK, reducing output the rows */ 
246247        for  ( m = 24 ;  m >= 0 ;  m -- )  { 
247248            for  ( j = crow . length - 1 ;  j >= 0 ;  j -- )  { 
248-                 if  ( crow [ j ] && parseInt ( crow [ j ] . getElementsByClassName ( 'turns' ) [ 0 ] . innerText ) == m )  { 
249+                 if  ( crow [ j ] && crow [ j ] . getElementsByClassName ( 'turns' ) [ 0 ] && parseInt ( crow [ j ] . getElementsByClassName ( 'turns' ) [ 0 ] . innerText ) == m )  { 
250+                     if  ( n  =  ( ( n + 1 ) % 2 ) )  { 
251+                         crow [ j ] . className  =  "opacBackground lightBorderBottom entry" ; 
252+                     }  else  { 
253+                         crow [ j ] . className  =  "opacLightBackground lightBorderBottom entry" ; 
254+                     } 
255+                     //alert(crow[j].className); 
249256                    radars [ i ] . appendChild ( crow [ j ] ) ; 
250257                    /* Nullify the row so we would not have to search it by class, text and so on */ 
251258                    crow [ j ]  =  0 ; 
@@ -310,10 +317,10 @@ if (location.href.includes('/comms/')) {
310317} 
311318
312319/* Request confirmation when kicking people from alliance */ 
313- if  ( location . href . includes ( '/alliances/' ) )   { 
320+ if  ( window . location . pathname == '/alliances/' )   {      
314321    k  =  document . querySelectorAll ( 'input[type=submit]' ) ; 
315322    for  ( i = 0 ;  i <= k . length ;  i ++ )  { 
316-         if  ( k [ i ] . value == 'Kick Member' )  { 
323+         if  ( k [ i ] && k [ i ] . value == 'Kick Member' )  { 
317324            l = k [ i ] ; 
318325            /* Get the player name. This is a bit ugly, but oh well... */ 
319326            let  playerName  =  l . parentNode . parentNode . parentNode . querySelector ( 'div.name' ) . innerText ; 
0 commit comments