Skip to content

Commit ec62bca

Browse files
authored
Add browser check (betaflight#778)
1 parent c306bb5 commit ec62bca

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/main.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import {
3131
validate,
3232
mouseNotification,
3333
getManifestVersion,
34+
isChromium,
3435
} from "./tools.js";
3536
import { PrefStorage } from "./pref_storage.js";
3637
import { makeScreenshot } from "./screenshot.js";
@@ -1729,6 +1730,12 @@ function BlackboxLogViewer() {
17291730
$(".btn-video-export").click(function (e) {
17301731
setGraphState(GRAPH_STATE_PAUSED);
17311732

1733+
// Video export is only supported in Chromium based browsers
1734+
if (!isChromium()) {
1735+
alert("Video export is only supported in Chromium based browsers.");
1736+
return;
1737+
}
1738+
17321739
const exportDialog = new VideoExportDialog($("#dlgVideoExport"), function(newConfig) {
17331740
videoConfig = newConfig;
17341741

src/tools.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,3 +484,17 @@ export function getManifestVersion(manifest) {
484484
export function escapeRegExp(string) {
485485
return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
486486
}
487+
488+
export function isChromium() {
489+
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Browser_detection_using_the_user_agent
490+
if (!navigator.userAgentData) {
491+
console.log(navigator.userAgent);
492+
return false;
493+
}
494+
495+
console.log(navigator.userAgentData);
496+
// https://learn.microsoft.com/en-us/microsoft-edge/web-platform/user-agent-guidance
497+
return navigator.userAgentData.brands.some((brand) => {
498+
return brand.brand == "Chromium";
499+
});
500+
}

0 commit comments

Comments
 (0)