mirror of
https://github.com/azures04/crafatar.git
synced 2026-03-22 07:51:17 +01:00
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
This commit is contained in:
parent
442dee0280
commit
d6a9f7c71a
28
lib/public/javascript/mojang.js
Normal file
28
lib/public/javascript/mojang.js
Normal file
@ -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();
|
||||||
Loading…
x
Reference in New Issue
Block a user