OGame: serverData

OGame: stores serverData on the client

Ten skrypt nie powinien być instalowany bezpośrednio. Jest to biblioteka dla innych skyptów do włączenia dyrektywą meta // @require https://update.greatest.deepsurf.us/scripts/4441/14624/OGame%3A%20serverData.js

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name OGame: serverData
// @namespace https://greatest.deepsurf.us/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);
}