async function getUserData() {
  const info = {
    "Browser": navigator.userAgent,
    "Language": navigator.language,
    "Platform": navigator.platform,
    "Cookies Enabled": navigator.cookieEnabled,
    "Screen Resolution": `${screen.width} x ${screen.height}`,
    "Timezone": Intl.DateTimeFormat().resolvedOptions().timeZone,
    "Device Memory (GB)": navigator.deviceMemory || "Not available",
    "CPU Cores": navigator.hardwareConcurrency || "Not available",
    "Plugins": Array.from(navigator.plugins).map(p => p.name),
  };

  try {
    const res = await fetch('https://api.ipify.org?format=json');
    const data = await res.json();
    info["IP Address"] = data.ip;
  } catch (e) {
    info["IP Address"] = "Could not retrieve";
  }

  try {
    const battery = await navigator.getBattery();
    info["Battery Level"] = `${Math.round(battery.level * 100)}%`;
    info["Charging"] = battery.charging ? "Yes" : "No";
    info["Charging Time (s)"] = battery.chargingTime;
    info["Discharging Time (s)"] = battery.dischargingTime;
  } catch (e) {
    info["Battery Info"] = "Not available";
  }

  document.getElementById('info').textContent = JSON.stringify(info, null, 2);
}