Warfacts Starlog Real dates

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

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==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);
	
}