1function getUserCountry(callback) { 2 fetch('https://ipinfo.io/json') 3 .then(response => response.json()) 4 .then(data => callback(data.country)) 5 .catch(() => callback('UNKNOWN')); 6} 7 8function updateLinks(countryCode) { 9 // an array to convert the country code into a name, because our names do not match 10 const countryMappings = { 11 'CA': 'canada', 12 'NL': 'nederland', 13 'DE': 'deutschland', 14 'AU': 'australia', 15 'IE': 'ireland', 16 'AT': 'oesterreich', 17 'ES': 'espana', 18 'CH': 'schweiz', 19 'IT': 'italia', 20 'EL': 'greece', 21 'CL': 'chile', 22 'FR': 'francaise', 23 'LV': 'latvija', 24 'PT': 'portuguesa', 25 'TR': 'turkiye', 26 'FI': 'suomi', 27 'UK': 'uk', 28 'SE': 'sverige', 29 'DK': 'danmark' 30 }; 31 32 const links = document.querySelectorAll('.popular-slots__link'); 33 links.forEach(link => { 34 const href = link.getAttribute('href'); 35 36 // If the country code is in the dictionary, add localization 37 if (countryMappings[countryCode]) { 38 link.setAttribute('href', `${href}/${countryMappings[countryCode]}`); 39 } else { 40 // If the country code is not defined, we leave only the site root 41 link.setAttribute('href', href); 42 } 43 }); 44} 45 46getUserCountry(updateLinks);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.