mirror of
https://github.com/betaflight/betaflight-configurator.git
synced 2025-07-26 09:45: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,8 +1,33 @@
|
||||||
|
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() {
|
export function checkBrowserCompatibility() {
|
||||||
const compatible = "serial" in navigator;
|
const compatible = "serial" in navigator;
|
||||||
|
|
||||||
|
if (isChromium() && compatible) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
let errorMessage = "";
|
||||||
|
if (!isChromium()) {
|
||||||
|
errorMessage = "Betaflight app requires a Chromium based browser (Chrome, Chromium, Edge).";
|
||||||
|
}
|
||||||
|
|
||||||
if (!compatible) {
|
if (!compatible) {
|
||||||
const errorMessage = "Betaflight app requires Chrome, Chromium, Edge or Vivaldi browser.";
|
errorMessage += " Web Serial API support is disabled.";
|
||||||
|
}
|
||||||
|
|
||||||
const newDiv = document.createElement("div");
|
const newDiv = document.createElement("div");
|
||||||
|
|
||||||
$('body')
|
$('body')
|
||||||
|
@ -29,5 +54,4 @@ export function checkBrowserCompatibility() {
|
||||||
});
|
});
|
||||||
|
|
||||||
throw new Error("No compatible browser found.");
|
throw new Error("No compatible browser found.");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue