mirror of
https://github.com/Classic7-Mod/Classic-Website.git
synced 2026-09-15 12:28:29 -07:00
25 lines
751 B
JavaScript
25 lines
751 B
JavaScript
const COUNTER_API = "https://classic7.kier.ovh";
|
|
|
|
async function loadCount() {
|
|
const el = document.querySelector(".download-count");
|
|
try {
|
|
const res = await fetch(`${COUNTER_API}/counter`);
|
|
const data = await res.json();
|
|
el.textContent = `${data.count.toLocaleString()} downloads`;
|
|
} catch {
|
|
el.textContent = "Download count unavailable at the moment.";
|
|
}
|
|
}
|
|
|
|
function trackDownloads() {
|
|
document.querySelectorAll(".mirror-links a").forEach(link => {
|
|
link.addEventListener("click", () => {
|
|
fetch(`${COUNTER_API}/download`, { keepalive: true }).catch(() => {});
|
|
});
|
|
});
|
|
}
|
|
|
|
document.addEventListener("DOMContentLoaded", () => {
|
|
loadCount();
|
|
trackDownloads();
|
|
}); |