Skip to content

Commit f62226d

Browse files
committed
Add mozilla check
1 parent 374e960 commit f62226d

3 files changed

Lines changed: 27 additions & 1 deletion

File tree

EnvironmentalOptions.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,25 @@ async function isMobile() {
2424
return platformInfo.os === "android";
2525
}
2626

27+
/**
28+
* Returns whether the current browser is from Mozilla.
29+
*
30+
* This includes Firefox and Thunderbird e.g.
31+
*
32+
* @private
33+
* @returns {Promise<bool>}
34+
*/
35+
async function isMozilla() {
36+
const browserInfo = await browser.runtime.getBrowserInfo();
37+
38+
return browserInfo.vendor === "Mozilla";
39+
}
40+
2741
/**
2842
* Returns whether the current browser is Firefox.
2943
*
44+
* This does not include Thunderbird!
45+
*
3046
* @private
3147
* @returns {Promise<bool>}
3248
*/
@@ -58,6 +74,12 @@ export function init() {
5874
}
5975
document.querySelector("body").classList.add("firefox");
6076
});
77+
isMozilla().then((isCurrentlyMozilla) => {
78+
if (!isCurrentlyMozilla) {
79+
return;
80+
}
81+
document.querySelector("body").classList.add("mozilla");
82+
});
6183

6284
return Promise.all([isMobile, isFirefox]);
6385
}

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,8 @@ To automatically disable options depending on the environment, load the `Environ
263263

264264
If you do so, you can use two CSS classes:
265265
* You can use the CSS class `.mobile-incompatible` to mark options that are not compatible with Android/mobile devices.
266-
* You can use the CSS class `.firefox-only` to mark options that are only compatible with the Mozilla Firefox browser.
266+
* You can use the CSS class `.firefox-only` to mark options that are only compatible with the Mozilla Firefox browser. **This does _not_ include Thunderbird
267+
* You can use the CSS class `.mozilla-only` to mark options that are only compatible with the Mozilla products like Mozilla Firefox and Thunderbird.
267268

268269
## API note
269270

css/photonOptions.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ body.mobile .mobile-incompatible {
4646
body:not(.firefox) .firefox-only {
4747
display: none;
4848
}
49+
body:not(.mozilla) .mozilla-only {
50+
display: none;
51+
}
4952

5053
/* https://design.firefox.com/photon/patterns/inactive.html */
5154
[disabled],

0 commit comments

Comments
 (0)