This commit is contained in:
stefan.tollkuehn committed 2026-10-07 14:22:24 +02:00
1 parent e352a15ce8
commit 92ed91f63d
3 files changed
+60 -57

No files matched your search

+51 -56
View File
@@ -793,6 +793,7 @@
</div>
</div>
<script src="assets/ua-parser.min.js"></script>
<script>
"use strict";
@@ -1636,41 +1637,60 @@
* ============================================================
*/
/*
* Einmal parsen (assets/ua-parser.min.js).
* Fällt die Bibliothek aus, bleibt die Seite bedienbar.
*/
const uaResult =
typeof UAParser === "function"
? new UAParser().getResult()
: { os: {}, browser: {} };
/*
* UAParser-Namen -> interne Kürzel.
* iPadOS meldet sich als macOS – Touchpunkte gelten als iOS.
*/
const OS_NAMES = {
Android: "android",
iOS: "ios",
Windows: "windows",
macOS: "macos",
Linux: "linux",
Ubuntu: "linux",
Debian: "linux",
Fedora: "linux",
Mint: "linux",
CentOS: "linux",
openSUSE: "linux",
Raspbian: "linux"
};
const BROWSER_NAMES = {
Edge: "edge",
"Mobile Edge": "edge",
Firefox: "firefox",
"Mobile Firefox": "firefox",
Chrome: "chrome",
"Mobile Chrome": "chrome",
"Chrome Headless": "chrome",
"Chrome WebView": "chrome",
"Samsung Internet": "chrome",
Safari: "safari",
"Mobile Safari": "safari"
};
function detectOperatingSystem() {
const ua = navigator.userAgent;
/* iPhone / iPad / iPod */
/*
* iPadOS tarnt sich als macOS.
*/
if (
/iPhone|iPad|iPod/i.test(ua) ||
(
navigator.platform === "MacIntel" &&
navigator.maxTouchPoints > 1
)
uaResult.os.name === "macOS" &&
navigator.maxTouchPoints > 1
) {
return "ios";
return OS_NAMES.iOS;
}
/* Android */
if (/Android/i.test(ua)) {
return "android";
}
/* Windows */
if (/Windows/i.test(ua)) {
return "windows";
}
/* macOS */
if (/Macintosh|Mac OS X/i.test(ua)) {
return "macos";
}
/* Linux */
if (/Linux/i.test(ua)) {
return "linux";
}
return "unknown";
return OS_NAMES[uaResult.os.name] || "unknown";
}
/* ============================================================
@@ -1679,32 +1699,7 @@
*/
function detectBrowser() {
const ua = navigator.userAgent;
if (/Edg\//i.test(ua)) {
return "edge";
}
if (/Firefox\//i.test(ua)) {
return "firefox";
}
if (
/Chrome\//i.test(ua) &&
!/Edg\//i.test(ua)
) {
return "chrome";
}
if (
/Safari\//i.test(ua) &&
!/Chrome\//i.test(ua) &&
!/Chromium\//i.test(ua)
) {
return "safari";
}
return "unknown";
return BROWSER_NAMES[uaResult.browser.name] || "unknown";
}
/* ============================================================