var dbObjCollection = [{appNameId:'1',country:'de,at',url:'https://theayurvedaexperience.de/',append_url:'YES',original_url:'',redirect_url:''},{appNameId:'1',country:'it',url:'https://theayurvedaexperience.it',append_url:'YES',original_url:'',redirect_url:''},{appNameId:'1',country:'es',url:'https://theayurvedaexperience.es',append_url:'YES',original_url:'',redirect_url:''},{appNameId:'1',country:'nl,gb,ie,lu,be',url:'https://theayurvedaexperience.co.uk',append_url:'YES',original_url:'',redirect_url:''},{appNameId:'1',country:'sg,my,ae,sa,qa,kw,bh',url:'https://sg.theayurvedaexperience.com',append_url:'YES',original_url:'',redirect_url:''},{appNameId:'1',country:'jp',url:'https://jp.ayurvedaexperience.com',append_url:'YES',original_url:'',redirect_url:''},{appNameId:'1',country:'ca',url:'https://holisco.com',append_url:'YES',original_url:'',redirect_url:''},{appNameId:'2',country:'gb,nl,be,fr,it,lu,de,at,es',url:'',append_url:'YES',original_url:'https://theayurvedaexperience.com/pages/manjish-glow-elixir',redirect_url:'https://iyura.co.uk/pages/manjish-glow-night-time-elixir?utm_source=GEORedirect&utm_medium=URL&utm_campaign=manjish'},{appNameId:'2',country:'gb,nl,be,fr,it,lu,de,at,es',url:'',append_url:'YES',original_url:'https://theayurvedaexperience.com/products/iyura-manjish-glow-elixir',redirect_url:'https://iyura.co.uk/products/manjish-glow-elixir?utm_source=GEORedirect&utm_medium=URL&utm_campaign=manjish'},{appNameId:'2',country:'gb,nl,be,fr,it,lu,de,at,es',url:'',append_url:'YES',original_url:'https://theayurvedaexperience.com/products/iyura-manjish-glow-elixir-pack-of-2',redirect_url:'https://iyura.co.uk/products/manjish-glow-night-time-elixir-pack-of-2?utm_source=GEORedirect&utm_medium=URL&utm_campaign=manjish'},{appNameId:'2',country:'gb,nl,be,fr,it,lu,de,at,es',url:'',append_url:'YES',original_url:'https://theayurvedaexperience.com/products/iyura-manjish-glow-elixir-pack-of-5',redirect_url:'https://iyura.co.uk/products/manjish-glow-elixir-pack-of-5?utm_source=GEORedirect&utm_medium=URL&utm_campaign=manjish'},{appNameId:'2',country:'gb,nl,be,fr,it,lu,de,at,es',url:'',append_url:'YES',original_url:'https://theayurvedaexperience.com/pages/kesaradi-oil-by-iyura',redirect_url:'https://iyura.co.uk/pages/kesaradi-oil?utm_source=GEORedirect&utm_medium=URL&utm_campaign=kesaradi'},{appNameId:'2',country:'gb,nl,be,fr,it,lu,de,at,es',url:'',append_url:'YES',original_url:'https://theayurvedaexperience.com/pages/kesaradi-oil-np',redirect_url:'https://iyura.co.uk/pages/kesaradi-oil?utm_source=GEORedirect&utm_medium=URL&utm_campaign=kesaradi'},{appNameId:'2',country:'gb,nl,be,fr,it,lu,de,at,es',url:'',append_url:'YES',original_url:'https://theayurvedaexperience.com/products/iyura-kesaradi-oil',redirect_url:'https://iyura.co.uk/products/kesaradi-oil?utm_source=GEORedirect&utm_medium=URL&utm_campaign=kesaradi'},{appNameId:'2',country:'gb,nl,be,fr,it,lu,de,at,es',url:'',append_url:'YES',original_url:'https://theayurvedaexperience.com/products/iyura-kesaradi-oil-pack-of-2',redirect_url:'https://iyura.co.uk/products/kesaradi-oil-pack-of-2?utm_source=GEORedirect&utm_medium=URL&utm_campaign=kesaradi'},{appNameId:'2',country:'gb,nl,be,fr,it,es,de,at,lu',url:'',append_url:'YES',original_url:'https://theayurvedaexperience.com/products/iyura-kesaradi-oil-pack-of-5',redirect_url:'https://iyura.co.uk/products/kesaradi-oil-pack-of-5?utm_source=GEORedirect&utm_medium=URL&utm_campaign=kesaradi'},{appNameId:'2',country:'gb,nl,be,fr,it,lu,de,at,es',url:'',append_url:'YES',original_url:'https://theayurvedaexperience.com/products/iyura-day-night',redirect_url:'https://iyura.co.uk/pages/iyura-day-and-night-duo?utm_source=GEORedirect&utm_medium=URL&utm_campaign=DAN'},{appNameId:'2',country:'gb,nl,be,fr,it,lu,de,at,es',url:'',append_url:'YES',original_url:'https://theayurvedaexperience.com/products/iyura-day-night',redirect_url:'https://iyura.co.uk/products/day-night-face-oil-duo?utm_source=GEORedirect&utm_medium=URL&utm_campaign=DAN'},{appNameId:'2',country:'gb,nl,be,fr,it,lu,de,at,es',url:'',append_url:'YES',original_url:'https://theayurvedaexperience.com/products/kansa-wand-for-face-body-with-iyura-manjish-glow-elixir',redirect_url:'https://iyura.co.uk/pages/layuna-massager?utm_source=GEORedirect&utm_medium=URL&utm_campaign=Layuna'},{appNameId:'2',country:'gb,nl,be,fr,it,lu,de,at,es',url:'',append_url:'YES',original_url:'https://theayurvedaexperience.com/products/kansa-face-and-body-wand',redirect_url:'https://iyura.co.uk/pages/layuna-massager?utm_source=GEORedirect&utm_medium=URL&utm_campaign=Layuna'},{appNameId:'2',country:'gb,nl,be,fr,it,lu,de,at,es',url:'',append_url:'YES',original_url:'https://theayurvedaexperience.com/products/kansa-face-and-body-wand-with-free-maintenance-kit',redirect_url:'https://iyura.co.uk/pages/layuna-massager?utm_source=GEORedirect&utm_medium=URL&utm_campaign=Layuna'},{appNameId:'2',country:'gb,nl,be,fr,it,lu,de,at,es',url:'',append_url:'YES',original_url:'https://theayurvedaexperience.com/products/personal-kansa-face-wand',redirect_url:'https://iyura.co.uk/products/layuna-massager-personal-face-massager?utm_source=GEORedirect&utm_medium=URL&utm_campaign=Layuna'},{appNameId:'2',country:'gb,nl,be,fr,it,lu,de,at,es',url:'',append_url:'YES',original_url:'https://theayurvedaexperience.com/products/iyura-kansa-face-wand-with-free-maintenance-kit',redirect_url:'https://iyura.co.uk/products/layuna-massager-personal-face-massager?utm_source=GEORedirect&utm_medium=URL&utm_campaign=Layuna'},{appNameId:'2',country:'gb,nl,be,fr,it,lu,de,at,es',url:'',append_url:'YES',original_url:'https://theayurvedaexperience.com/products/marma-tool',redirect_url:'https://iyura.co.uk/products/layuna-massager-personal-face-massager?utm_source=GEORedirect&utm_medium=URL&utm_campaign=Layuna'},{appNameId:'2',country:'gb,nl,be,fr,it,lu,de,at,es',url:'',append_url:'YES',original_url:'https://theayurvedaexperience.com/products/kansa-vataki-foot-wand',redirect_url:'https://iyura.co.uk/products/layuna-massager-foot-massager?utm_source=GEORedirect&utm_medium=URL&utm_campaign=Layuna'},{appNameId:'2',country:'gb,nl,be,fr,it,lu,de,at,es',url:'',append_url:'YES',original_url:'https://theayurvedaexperience.com/products/super-saver-kansa-wands-pack',redirect_url:'https://iyura.co.uk/products/super-saver-layuna-massager-pack?utm_source=GEORedirect&utm_medium=URL&utm_campaign=Layuna'},{appNameId:'2',country:'gb,nl,be,fr,it,lu,de,at,es',url:'',append_url:'YES',original_url:'https://theayurvedaexperience.com/products/complete-kansa-tool-set',redirect_url:'https://iyura.co.uk/products/super-saver-layuna-massager-pack?utm_source=GEORedirect&utm_medium=URL&utm_campaign=Layuna'},{appNameId:'2',country:'gb,nl,be,fr,it,lu,de,at,es',url:'',append_url:'YES',original_url:'https://theayurvedaexperience.com/products/all-things-kansa-set-4-original-kansa-wands-free-iyura-kesaradi-face-oil-free-iyura-kansa-oil-for-face-body-free-kansa-course',redirect_url:'https://iyura.co.uk/products/super-saver-layuna-massager-pack?utm_source=GEORedirect&utm_medium=URL&utm_campaign=Layuna'},{appNameId:'2',country:'gb,nl,be,fr,it,lu,de,at,es',url:'',append_url:'YES',original_url:'https://theayurvedaexperience.com/products/your-complete-kansa-wands-kit',redirect_url:'https://iyura.co.uk/products/super-saver-layuna-massager-pack?utm_source=GEORedirect&utm_medium=URL&utm_campaign=Layuna'},{appNameId:'2',country:'gb,nl,be,fr,it,lu,de,at,es',url:'',append_url:'YES',original_url:'https://theayurvedaexperience.com/',redirect_url:'https://iyura.co.uk/'},]; /* console.log(temp8Check); */ function RemoveLastCharFrmStringWC(dString, rchar){ if(dString != null && rchar != null){ if(dString.length > 0 && rchar.length > 0) { var lastChar = dString.substr(dString.length - 1); if(lastChar == rchar) { dString = dString.slice(0,-1); } } } return dString; } function GetLocation(href) { var l = document.createElement("a"); l.href = href; return l; } var urlString = window.top.location.href; urlParams = parseURLParams(urlString); if(urlParams){ if(urlParams['geo']=="false"){ Cookies.set('geo',"false",{ path: '/' }); } } var actual_url= window.location.href; if(actual_url != Cookies.get("same_domain")){ if(!Cookies.get('geo')){ var rand="1363858305"; /*if(Cookies.get("data"+rand)){ window.top.location.href =Cookies.get("data"+rand); } */ if(!Cookies.get("mod_cc")){ modBarjquery.ajax({ url: '//pro.ip-api.com/json/?key=MQXSLbxUAhwAwzB', type: 'POST', dataType: 'jsonp' }).success (function (data1) { console.log ("IP API"); Cookies.set("mod_cc"+rand,data1['countryCode']); Cookies.set("mod_cn"+rand,data1['country']); auto_url_bar(); auto_bar(); }); } setTimeout(function(){ if(!Cookies.get("mod_cc"+rand)){ modBarjquery.ajax({ url: "http://api.ipapi.com/api/check?access_key=3b026537ce9f3956700c31bee96daa53", dataType: "jsonp", type: "POST", }).success(function(data4){ var data5 = data4['country_code']; console.log ("Geo IP Nekudo") Cookies.set("mod_cc"+rand,data5['country_code']); Cookies.set("mod_cn"+rand,data5['country_name']); auto_url_bar(); auto_bar(); }); } }, 2000); /*Backed up on 3 sep 2019 due to shutdown of geoip api. setTimeout(function(){ if(!Cookies.get("mod_cc"+rand)){ modBarjquery.ajax({ url: "//geoip.nekudo.com/api", dataType: "jsonp", type: "POST", }).success(function(data4){ var data5 = data4['country']; console.log ("Geo IP Nekudo") Cookies.set("mod_cc"+rand,data5['code']); Cookies.set("mod_cn"+rand,data5['name']); auto_url_bar(); auto_bar(); }); } }, 2000); */ setTimeout(function(){ if(!Cookies.get("mod_cc"+rand)){ modBarjquery.ajax({ url: "//modapps.com.au/geolocationredirect/index.php/redirect/geo/", dataType: "json", type: "POST", data: { data: "U2FsdGVkX1+1yqBolOAjPPlD4DsNNOEnuBfqGbjQQEQ="} }).success(function(data2){ Cookies.set("mod_cc"+rand,data2['country_code']); Cookies.set("mod_cn"+rand,data2['country_name']); auto_url_bar(); auto_bar(); }); } }, 2000); } function auto_url_bar(){ if(Cookies.get("mod_cc"+rand)){ var searchAppId = "2"; var searchCountry = Cookies.get("mod_cc"+rand); console.log(searchCountry); if(searchCountry != null){ searchCountry = searchCountry.replace(/\"/g, ""); } var searchUrl = RemoveLastCharFrmStringWC(window.top.location.href,'/').replace('www.',''); console.log(searchUrl); var resultObj = ''; resultObj = modBarjquery.grep(dbObjCollection, function(e){ return (e.appNameId == searchAppId && (e.country.toUpperCase().indexOf(searchCountry) >= 0)) && RemoveLastCharFrmStringWC(e.original_url,'/').replace('www.','') == searchUrl}); console.log(resultObj); if(resultObj != null){ if (resultObj.length == 0) { // not found console.log("Not found - auto_url_bar - searchId 2"); } else { // access the foo property using result[0].foo window.top.location.href=resultObj[0].redirect_url; } } } } function auto_bar(){ if(Cookies.get("mod_cc"+rand)){ var checkUrlPath = ''; var searchAppId = "1"; var searchCountry = Cookies.get("mod_cc"+rand); if(searchCountry != null){ searchCountry = searchCountry.replace(/\"/g, ""); } var searchUrl = window.top.location.href; var resultObj = ''; resultObj = modBarjquery.grep(dbObjCollection, function(e){ return (e.appNameId == searchAppId && (e.country.toUpperCase().indexOf(searchCountry) >= 0)); }); if(resultObj != null){ if (resultObj.length == 0) { // not found console.log("Not found - auto bar function - searchAppId 1"); } else { // access the foo property using result[0].foo var rdpURL = GetLocation(resultObj[0].url); if(resultObj[0].append_url.toUpperCase() == "YES") { checkUrlPath = RemoveLastCharFrmStringWC(rdpURL.href,'/') + window.location.pathname + window.location.search ; } else { checkUrlPath = rdpURL.href; } if(checkUrlPath.length > 0){ Cookies.set("data"+rand,checkUrlPath); Cookies.set("same_domain",resultObj[0].url); window.top.location.href = Cookies.get("data"+rand); } } } } } } function parseURLParams(url) { var queryStart = url.indexOf("?") + 1, queryEnd = url.indexOf("#") + 1 || url.length + 1, query = url.slice(queryStart, queryEnd - 1), pairs = query.replace(/\+/g, " ").split("&"), parms = {}, i, n, v, nv; if (query === url || query === "") { return; } for (i = 0; i < pairs.length; i++) { nv = pairs[i].split("="); n = decodeURIComponent(nv[0]); v = decodeURIComponent(nv[1]); if (!parms.hasOwnProperty(n)) { parms[n] = []; } parms[n].push(nv.length === 2 ? v : null); } return parms; }