Last active
February 27, 2020 22:26
-
-
Save ireade/10fe4b3c1e1caa9751a3 to your computer and use it in GitHub Desktop.
Detect if Opera Mini/Mobile is in Extreme or High Savings Mode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Check if current browser is Opera | |
var isOpera = window.opera | window.opr | ( navigator.userAgent.indexOf(' OPR/') > -1 ) | ( navigator.userAgent.indexOf(' Coast/') > -1 ) | ( navigator.userAgent.indexOf(' OPiOS/') > -1 ); | |
// Check if the Opera browser is Opera Mini or Opera Mobile in regular mode (called High Savings Mode) | |
var isOperaHigh = (navigator.userAgent.indexOf('OPR/') > -1) && (navigator.userAgent.indexOf('Mobile') > -1) && (navigator.userAgent.indexOf('Presto/') < 0); | |
// Check if the Opera browser is Opera Mini in Extreme Savings Mode | |
var isOperaExtreme = (navigator.userAgent.indexOf('Opera Mini/') > -1) && (navigator.userAgent.indexOf('Presto/') > -1); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How do you use the code? Do you use 'if' statements to switch between the views? Please elaborate on its usage.