(function () {
  var ua = window.navigator.userAgent.toLowerCase();
  if (
    !/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
      navigator.userAgent
    )
  ) {
    return;
  } else if (ua.indexOf('iphone') > 0 || ua.indexOf('android') > 0) {
    try {
      let url = window.location.href;
      let curpath = url.indexOf('//');
      if (curpath !== -1 && url.indexOf('m.') === -1) {
        let pathValue = curpath + 1;
        if (url.indexOf('https') !== -1) {
          url = url.replace('https', 'http');
          window.location.href =
            url.slice(0, pathValue) + 'm.' + url.slice(pathValue);
        } else {
          window.location.href =
            url.slice(0, pathValue + 1) + 'm.' + url.slice(pathValue + 1);
        }
      }
    } catch (e) {
      window.location.href = 'http://m.dexfilter.com';
    }
  }
})();
