OGame: serverData

OGame: stores serverData on the client

Script này sẽ không được không được cài đặt trực tiếp. Nó là một thư viện cho các script khác để bao gồm các chỉ thị meta // @require https://update.greatest.deepsurf.us/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 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.

(Tôi đã có Trình quản lý tập lệnh người dùng, hãy cài đặt nó!)

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