Warfacts Starlog Real dates

Changes time and date for war-facts.com starlog to real. For the new game interface.

Tendrás que instalar una extensión para tu navegador como Tampermonkey, Greasemonkey o Violentmonkey si quieres utilizar este script.

You will need to install an extension such as Tampermonkey to install this script.

Necesitarás instalar una extensión como Tampermonkey o Violentmonkey para instalar este script.

Necesitarás instalar una extensión como Tampermonkey o Userscripts para instalar este script.

Necesitará instalar una extensión como Tampermonkey para instalar este script.

Necesitarás instalar una extensión para administrar scripts de usuario si quieres instalar este script.

(Ya tengo un administrador de scripts de usuario, déjame instalarlo)

Necesitará instalar una extensión como Stylus para instalar este estilo.

Necesitará instalar una extensión como Stylus para instalar este estilo.

Necesitará instalar una extensión como Stylus para instalar este estilo.

Necesitará instalar una extensión del gestor de estilos de usuario para instalar este estilo.

Necesitará instalar una extensión del gestor de estilos de usuario para instalar este estilo.

Necesitará instalar una extensión del gestor de estilos de usuario para instalar este estilo.

(Ya tengo un administrador de estilos de usuario, déjame instalarlo)

// ==UserScript==
// @name        Warfacts Starlog Real dates
// @namespace   https://github.com/guardian21
// @description Changes time and date for war-facts.com starlog to real. For the new game interface.
// @include     *.war-facts.com/starlog.php*
// @version     3
// @grant       none
// ==/UserScript==




/* Configuration Settings */



/* Script */


//Set Time zone Difference
var currentdate = new Date(); 
var timeZoneDiff = currentdate.getTimezoneOffset() / 60;	// Difference between user time and UTC time in hours
	timeZoneDiff = -timeZoneDiff;	// I want to know user compared to utc, not utc compared to user
	timeZoneDiff += 5;	//Difference between UTC and EST (server is in EST)






//Each starlog entry is a div, grab them all
var divs = document.getElementById("midcolumn").getElementsByTagName("div")[0].getElementsByTagName("div");
var i;
var current_div;
var realTimeEST;
var timetext;
var timeDateSpan;
var temp;




//For each starlog entry
 for (i = 3; i < divs.length; i+=3) {	//i=3 because first are headers 




    current_div = divs[i].children[0];


    temp = current_div.getElementsByTagName("span");
    timeDateSpan = temp[0];



    realTimeEST = timeDateSpan.title;




    //Process real time. Add the timezone diffrence, change Date if needed
    var thehours = parseInt(realTimeEST.substr(0,2));
    var dateString =  realTimeEST.substr(9,2);  
    thedate  = parseInt(dateString);
    thehours += timeZoneDiff;

    if (thehours >= 24) {
    	thehours -= 24;
    	thedate ++ ;
    	//Normally I would also need to check if month changes etc, but will not bother as it doesn't causes problem

    	dateString = thedate.toString();
    	if (thedate < 10) {
    		dateString = "0" + dateString;
     	}

    }

    var hoursString = thehours.toString();
    if (thehours < 10) {
    	hoursString = "0" + hoursString;
    }

//    var myTimeDate = hoursString + realTimeEST.substring(2,9) + dateString + realTimeEST.substring(11,19);    //hour - date format
    var myTimeDate = dateString + realTimeEST.substring(11,19) + "  " + hoursString + realTimeEST.substring(2,8);

 

    var myp = document.createElement("p");
    myp.style.color="yellow";
    myp.innerHTML = myTimeDate;

 
    current_div.appendChild(myp);
	
}