From d6a9f7c71ae5690278c5290e060aa1f61095a077 Mon Sep 17 00:00:00 2001 From: jomo Date: Tue, 28 Jul 2015 23:58:48 +0200 Subject: [PATCH] add JS to check mojang's server status does CORS request to status.mojang.com/check and figures out if 'uuid', 'name' or 'both' are affected not doing anything yet --- lib/public/javascript/mojang.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 lib/public/javascript/mojang.js diff --git a/lib/public/javascript/mojang.js b/lib/public/javascript/mojang.js new file mode 100644 index 0000000..2cad271 --- /dev/null +++ b/lib/public/javascript/mojang.js @@ -0,0 +1,28 @@ +var xhr = new XMLHttpRequest(); + +xhr.onload = function() { + var response = JSON.parse(xhr.responseText); + var status = {}; + response.map(function(elem) { + var key = Object.keys(elem)[0]; + status[key] = elem[key]; + }); + + var textures = status["textures.minecraft.net"] !== "green"; + var session = status["sessionserver.mojang.com"] !== "green"; + var skins = status["skins.minecraft.net"] !== "green"; + var error = null; + + if (textures || session && skins) { + error = "both"; + } else if (skins) { + error = "name"; + } else if (session) { + error = "uuid"; + } + + console.log(error); +}; + +xhr.open("GET", "https://status.mojang.com/check", true); +xhr.send(); \ No newline at end of file