Skip to content

Instantly share code, notes, and snippets.

@ireade
Last active February 27, 2020 22:26
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ireade/10fe4b3c1e1caa9751a3 to your computer and use it in GitHub Desktop.
Save ireade/10fe4b3c1e1caa9751a3 to your computer and use it in GitHub Desktop.
Detect if Opera Mini/Mobile is in Extreme or High Savings Mode
// 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);
@john-kamau01
Copy link

How do you use the code? Do you use 'if' statements to switch between the views? Please elaborate on its usage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment