Alexey Romanov
Alexey Romanov

Reputation: 170713

Test which browser a WebExtension is running in

I want to show some text on the option page which depends on whether my extension is running in Firefox or Chrome (namely, a warning that there is a relevant bug in Firefox and which version it's fixed in). What is the best way to test for it?

Upvotes: 1

Views: 270

Answers (1)

Paul Heil
Paul Heil

Reputation: 293

This is how I check.

// Hide option for Chrome
let isFirefox = navigator.userAgent.indexOf('Firefox') !== -1;
if (!isFirefox) {
    document.getElementById('CP_l').style.display = "none";
}

Upvotes: 2

Related Questions