1// console.log('custom geolocation enqueued'); 2 3/** 4 * Custom geolocation implementation using the CookieYes API 5 */ 6async function getVisitorGeolocation() { 7 const apiUrl = 'https://directory.cookieyes.com/api/v1/ip'; 8 9 try { 10 const response = await fetch(apiUrl); 11 const data = await response.json(); 12 // console.log('visitor data =', data); 13 return data; 14 } catch (error) { 15 // console.error('Error fetching geolocation data:', error); 16 return null; 17 } 18} 19 20/** 21* Take action based on visitor's location 22*/ 23async function handleGeolocation() { 24 const visitorData = await getVisitorGeolocation(); 25 26 if (visitorData) { 27 const { country, in_eu, region_code } = visitorData; 28 29 if(country === 'US') { 30 const rejectButton = document.querySelector('.cookie_action_close_header_reject.cli_action_button'); 31 // console.log('reject button =', rejectButton); 32 if(rejectButton) { 33 rejectButton.style.display = 'none'; 34 } 35 } 36 } 37} 38 39handleGeolocation();
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.