(function() { // 1. Ocultar contenido inicialmente const style = document.createElement('style'); style.id = 'geo-filter-style'; style.innerHTML = 'html { display: none !important; }'; document.head.appendChild(style); const ALLOWED_COUNTRIES = ['ES', 'FR']; async function validateUser() { try { // Usamos ip-api.com que es gratuito y no requiere key const response = await fetch('http://ip-api.com/json/'); const data = await response.json(); if (data && data.countryCode) { if (ALLOWED_COUNTRIES.includes(data.countryCode.toUpperCase())) { // Permitido const s = document.getElementById('geo-filter-style'); if (s) s.remove(); } else { // No permitido window.location.replace('https://www.google.com'); } } else { // Si falla, mostramos por si acaso const s = document.getElementById('geo-filter-style'); if (s) s.remove(); } } catch (error) { console.error('Geo-filter Error:', error); const s = document.getElementById('geo-filter-style'); if (s) s.remove(); } } validateUser(); })();