Sfoglia il codice sorgente

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
jomo 10 anni fa
parent
commit
d6a9f7c71a
1 ha cambiato i file con 28 aggiunte e 0 eliminazioni
  1. 28 0
      lib/public/javascript/mojang.js

+ 28 - 0
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();