app: only show extension install banner on Chromium/Firefox

The dashboard nudge is useless on Safari and other browsers that cannot
run the WROLPi extension. Share detectBrowser and gate the banner with
isExtensionSupportedBrowser.
This commit is contained in:
Roland 2026-07-18 13:47:43 -06:00 • committed by lrnselfreliance
parent 46ba804a1b
commit db7603012e
4 changed files with 54 additions and 12 deletions

View file

@ -0,0 +1,23 @@
// Shared UA sniffing for the WROLPi browser extension UI.
// The extension only ships for Chromium (Chrome/Brave/Edge/Opera) and Firefox;
// Safari and other browsers should not be nudged to install it.
/**
* @returns {'firefox' | 'chromium' | 'unknown'}
*/
export function detectBrowser() {
if (typeof navigator === 'undefined') return 'unknown';
const ua = navigator.userAgent || '';
// Order matters: Edge / Brave / Opera all include 'Chrome' in their UA.
if (ua.includes('Firefox')) return 'firefox';
if (ua.includes('Edg/')) return 'chromium';
if (ua.includes('OPR/') || ua.includes('Opera')) return 'chromium';
if (ua.includes('Chrome')) return 'chromium';
return 'unknown';
}
/** True when the current browser can run the WROLPi extension. */
export function isExtensionSupportedBrowser() {
const browser = detectBrowser();
return browser === 'firefox' || browser === 'chromium';
}