Skip to content

Instantly share code, notes, and snippets.

@jsn
Created February 8, 2017 13:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jsn/3ba6e08cbeadb9f8937db0802aa4660a to your computer and use it in GitHub Desktop.
Save jsn/3ba6e08cbeadb9f8937db0802aa4660a to your computer and use it in GitHub Desktop.
(function () {
var mobileElem = document.getElementById('mobile-link'),
mobileUrl;
if (mobileElem !== undefined && mobileElem !== null) {
mobileUrl = mobileElem.getAttribute('href');
}
if (getCookie('noRedirect') !== 'enabled' && mobileUrl !== undefined) {
(function(a,b){if(/mobile|ip(hone|od|ad)|android|blackberry|iemobile|kindle|netfront|silk-accelerated|(hpw|web)os|fennec|minimo|opera m(obi|ini)|blazer|dolfin|dolphin|skyfire|zune/i.test(a.substr(0,4)))window.location.href=b})(navigator.userAgent||navigator.vendor||window.opera,mobileUrl);
}
function getCookie(name) {
var value = "; " + document.cookie;
var parts = value.split("; " + name + "=");
if (parts.length == 2) return parts.pop().split(";").shift();
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment