forked from AAAAAYTFN/MineXLauncher-Beta
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserverlist.js
119 lines (101 loc) · 3.55 KB
/
serverlist.js
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
document.addEventListener("DOMContentLoaded", () => {
setupProfile();
setupServerEmbeds();
});
// Initialize profile based on cookies
function setupProfile() {
const profileNameElem = document.getElementById("profile-name");
const username = getCookie("username");
if (username) {
profileNameElem.textContent = username;
}
const modMakerKitEnabled = getCookie("modMakerKitEnabled");
const modMakerItem = document.getElementById("modMakerItem");
const apiItem = document.getElementById("apiItem");
if (modMakerKitEnabled === "true") {
modMakerItem.style.display = "flex";
apiItem.style.display = "flex";
} else {
modMakerItem.style.display = "none";
apiItem.style.display = "none";
}
}
// Setup server embeds with lazy loading
function setupServerEmbeds() {
const servers = [
"wss://zentic.cc",
"mc.arch.lol",
"wss://mc.zyth.me",
"wss://asianf4rmer.minecraft.pe",
"wss://hoosiertransfer.xyz",
"wss://eg.cloudwars.club",
"wss://mc.firenetwork.lol",
"wss://deercraft.ddns.net",
"wss://sus.shhnowisnottheti.me",
"wss://mc.asspixel.net/",
"wss://aeon-network.net/1.8",
];
const embedContainer = document.getElementById("embed");
embedContainer.style.display = "flex";
embedContainer.style.flexWrap = "wrap";
const fragment = document.createDocumentFragment();
servers.forEach(server => {
const serverDiv = createServerEmbed(server);
fragment.appendChild(serverDiv);
lazyLoadServerEmbed(serverDiv, server);
});
embedContainer.appendChild(fragment);
}
// Create a server embed div
function createServerEmbed(server) {
const serverDiv = document.createElement("div");
serverDiv.className = "server-embed";
const serverInfoDiv = document.createElement("div");
serverInfoDiv.style.display = "flex";
serverInfoDiv.style.flexDirection = "row";
serverInfoDiv.style.alignItems = "center";
serverInfoDiv.style.marginBottom = "10px";
const ipSpan = document.createElement("span");
ipSpan.textContent = `${server} (Server Embed Below) ↓`;
const copyButton = document.createElement("button");
copyButton.textContent = "Copy IP";
copyButton.classList.add("minecraft-button");
copyButton.addEventListener("click", () => copyServerIP(server));
serverInfoDiv.appendChild(ipSpan);
serverInfoDiv.appendChild(copyButton);
serverDiv.appendChild(serverInfoDiv);
return serverDiv;
}
// Lazy load server embed
function lazyLoadServerEmbed(serverDiv, server) {
const observer = new IntersectionObserver((entries, observer) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
new ServerEmbed(serverDiv, "75%").ping(server);
observer.unobserve(entry.target);
}
});
}, { threshold: 0.1 });
observer.observe(serverDiv);
}
// Copy server IP to clipboard
function copyServerIP(server) {
navigator.clipboard.writeText(server)
.then(() => {
alert("IP address copied to clipboard: " + server);
})
.catch(err => {
console.error("Failed to copy: ", err);
});
}
// Get cookie value by name
function getCookie(name) {
const cookieArr = document.cookie.split(";");
for (let i = 0; i < cookieArr.length; i++) {
const cookiePair = cookieArr[i].split("=");
if (name === cookiePair[0].trim()) {
return decodeURIComponent(cookiePair[1]);
}
}
return null;
}