forked from sebarmeli/JS-Redirection-Mobile-Site
-
Notifications
You must be signed in to change notification settings - Fork 0
/
redirection_mobile_self.min.js
executable file
·9 lines (9 loc) · 1.31 KB
/
redirection_mobile_self.min.js
1
2
3
4
5
6
7
8
9
/*
* JS Redirection Mobile
*
* Copyright (c) 2011 Sebastiano Armeli-Battana (http://sebarmeli.com)
* Dual licensed under the MIT or GPL Version 3 licenses.
* @link http://github.com/sebarmeli/JS-Redirection-Mobile-Site/
* @version 0.9.5
*/
(function(f,m,b){var d=function(t){var s=new Date();s.setTime(s.getTime()+t);return s;};var n=function(x){if(!x){return;}var s=m.location.search,y=s&&s.substring(1).split("&"),u=0,w=y.length;for(;u<w;u++){var t=y[u],v=t&&t.substring(0,t.indexOf("="));if(v===x){return t.substring(t.indexOf("=")+1,t.length);}}};var a=b.userAgent.toLowerCase(),p="false",o="mobile_redirect",q="m",k="",e=m.location.protocol,l=m.location.host,g=n(o),h=k||(q+"."+(!!l.match(/^www\./i)?l.substring(4):l)),i=1,c=!!(a.match(/(iPhone|iPod|blackberry|android 0.5|htc|lg|midp|mmp|mobile|nokia|opera mini|palm|pocket|psp|sgh|smartphone|symbian|treo mini|Playstation Portable|SonyEricsson|Samsung|MobileExplorer|PalmSource|Benq|Windows Phone|Windows Mobile|IEMobile|Windows CE|Nintendo Wii)/i));if(m.referrer.indexOf(h)>=0||g===p){if(f.sessionStorage){f.sessionStorage.setItem(o,p);}else{m.cookie=o+"="+p+";expires="+d(3600*1000*i).toUTCString();}}var r=(f.sessionStorage)?(f.sessionStorage.getItem(o)===p):false,j=m.cookie?(m.cookie.indexOf(o)>=0):false;if(c&&!(j||r)){m.location.href=e+"//"+h;}}(window,document,navigator));