OGame: serverData

OGame: stores serverData on the client

ეს სკრიპტი არ უნდა იყოს პირდაპირ დაინსტალირებული. ეს ბიბლიოთეკაა, სხვა სკრიპტებისთვის უნდა ჩართეთ მეტა-დირექტივაში // @require https://update.greasyfork.org/scripts/4441/14624/OGame%3A%20serverData.js.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name OGame: serverData
// @namespace https://greasyfork.org/users/4668-black-cat
// @description OGame: stores serverData on the client
// @version 5.3
// @creator Black Cat
// @include http://*.ogame.gameforge.com/game/index.php?page=overview*
// ==/UserScript==

var strFunc = (function(){

	var ogTime = parseInt(document.querySelector("meta[name=ogame-timestamp]").getAttribute("content"));
	var xmlTime = parseInt(localStorage.getItem("serverData.time") || "0");
	if (ogTime > xmlTime + 86400) {
		$.get(
			"/api/serverData.xml",
			function (xml) {
				var data = {};
				var sd = xml.childNodes[0];
				xmlTime = sd.getAttribute("timestamp");
				localStorage.setItem("serverData.time", xmlTime);
				var elements = sd.childNodes;
				for (var i=0; i<elements.length; i++) {
					var tag = elements[i].tagName;
					data[tag] = elements[i].textContent;
				}
				localStorage.setItem("serverData", JSON.stringify(data));
			},
			"xml"
		);
	}
}).toString();

if (!document.getElementById("serverData_script")) {
	var script = document.createElement("script");
	script.id = "serverData_script";
	script.setAttribute("type","text/javascript");
	script.text = "(" + strFunc + ")();";
	document.body.appendChild(script);
}