mirror of
https://github.com/betaflight/betaflight-configurator.git
synced 2025-07-26 01:35:28 +03:00
Update browser check (#4214)
This commit is contained in:
parent
79907af99c
commit
0ae4af9775
1 changed files with 53 additions and 29 deletions
|
@ -1,33 +1,57 @@
|
||||||
export function checkBrowserCompatibility() {
|
export function isChromium() {
|
||||||
|
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Browser_detection_using_the_user_agent
|
||||||
|
if (!navigator.userAgentData) {
|
||||||
|
console.log(navigator.userAgent);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(navigator.userAgentData);
|
||||||
|
// https://learn.microsoft.com/en-us/microsoft-edge/web-platform/user-agent-guidance
|
||||||
|
return navigator.userAgentData.brands.some((brand) => {
|
||||||
|
return brand.brand == "Chromium";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function checkBrowserCompatibility() {
|
||||||
const compatible = "serial" in navigator;
|
const compatible = "serial" in navigator;
|
||||||
|
|
||||||
if (!compatible) {
|
if (isChromium() && compatible) {
|
||||||
const errorMessage = "Betaflight app requires Chrome, Chromium, Edge or Vivaldi browser.";
|
return true;
|
||||||
const newDiv = document.createElement("div");
|
|
||||||
|
|
||||||
$('body')
|
|
||||||
.empty()
|
|
||||||
.css({
|
|
||||||
"height": "100%",
|
|
||||||
"display": "grid",
|
|
||||||
"background-image": "url(../images/osd-bg-1.jpg",
|
|
||||||
"background-size": "cover",
|
|
||||||
"background-repeat": "no-repeat",
|
|
||||||
})
|
|
||||||
.append(newDiv);
|
|
||||||
|
|
||||||
$('div')
|
|
||||||
.append(errorMessage)
|
|
||||||
.css({
|
|
||||||
"font-size": "16px",
|
|
||||||
"background-color": "var(--surface-200)",
|
|
||||||
"color": "var(--text)",
|
|
||||||
"padding": "1rem",
|
|
||||||
"margin": "auto",
|
|
||||||
"border-radius": "0.75rem",
|
|
||||||
"border": "2px solid var(--surface-500)",
|
|
||||||
});
|
|
||||||
|
|
||||||
throw new Error("No compatible browser found.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let errorMessage = "";
|
||||||
|
if (!isChromium()) {
|
||||||
|
errorMessage = "Betaflight app requires a Chromium based browser (Chrome, Chromium, Edge).";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!compatible) {
|
||||||
|
errorMessage += " Web Serial API support is disabled.";
|
||||||
|
}
|
||||||
|
|
||||||
|
const newDiv = document.createElement("div");
|
||||||
|
|
||||||
|
$('body')
|
||||||
|
.empty()
|
||||||
|
.css({
|
||||||
|
"height": "100%",
|
||||||
|
"display": "grid",
|
||||||
|
"background-image": "url(../images/osd-bg-1.jpg",
|
||||||
|
"background-size": "cover",
|
||||||
|
"background-repeat": "no-repeat",
|
||||||
|
})
|
||||||
|
.append(newDiv);
|
||||||
|
|
||||||
|
$('div')
|
||||||
|
.append(errorMessage)
|
||||||
|
.css({
|
||||||
|
"font-size": "16px",
|
||||||
|
"background-color": "var(--surface-200)",
|
||||||
|
"color": "var(--text)",
|
||||||
|
"padding": "1rem",
|
||||||
|
"margin": "auto",
|
||||||
|
"border-radius": "0.75rem",
|
||||||
|
"border": "2px solid var(--surface-500)",
|
||||||
|
});
|
||||||
|
|
||||||
|
throw new Error("No compatible browser found.");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue