-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmcserver.html
52 lines (43 loc) · 2.08 KB
/
mcserver.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<input type="text" id="ipserver" value="myzvuqv.mc.in.th:26480"><br>
<button onclick="fetchserverstatus()">FETCH</button>
<p id="resultContainer"></p>
<div id="playername"></div>
<script>
async function fetchserverstatus() {
document.getElementById("playername").innerHTML = "";
const parameterValue = document.getElementById('ipserver').value;
const mcAPI = `https://api.mcsrvstat.us/3/${parameterValue}`;
fetch(mcAPI).then(responseMcStatus => {
if (!responseMcStatus.ok) {
throw new Error(`Network response was not ok: ${responseMcStatus.status}`);
}
return responseMcStatus.json();
}).then(mcAPI => {
document.getElementById("resultContainer").innerHTML = "Player Online "+ mcAPI.players.online + "/" + mcAPI.players.max + "<br>PlayerList :"
const playerInfoDiv = document.getElementById('playername');
mcAPI.players.list.forEach(player => {
const playerName = player.name;
const playerUUID = player.uuid;
const playerInfoParagraph = document.createElement('p');
// Log or use the player information as needed
playerInfoParagraph.textContent = playerName
playerInfoDiv.appendChild(playerInfoParagraph);
console.log(playerName);
console.log("--------------------------");
})
const mcbanner = document.getElementById('mcbanner');
mcbanner.src = `https://namemc.com/server/${parameterValue}/embed`;
})
}
</script>
<iframe style="width:728px;height:90px;max-width:100%;border:none;display:block;margin:auto" id="mcbanner" src="" width="728" height="90"></iframe>
</body>
</html>