<script type="text/javascript">
(function() {
'use strict';
// IntentarPREVENIR redireccionarBUCLES: inmediatamenteSolo ejecutar UNA VEZ
window.location.href = if (window.portalMineroRedirected) {
console.log('?? Redirección ya ejecutada, evitando bucle');
return;
}
// Marcar que ya se ejecutó
window.portalMineroRedirected = true;
// URL de destino para Cobre
const targetURL = "https://www.portalminero.com/wp/datos-metales/?metal=Cobre";
console.log('?? Iniciando redirección a:', targetURL);
// Respaldo en caso de que lo anterior falle
document.addEventListener("DOMContentLoaded", function()Función de redirección segura
function safeRedirect() {
try {
// Verificar que no estemos ya en la URL de destino
if (window.location.href === targetURL) {
console.log('? Ya estamos en la URL destino');
return;
}
// Verificar que no estemos en un bucle
const currentHost = window.location.hostname;
const targetHost = new URL(targetURL).hostname;
if (currentHost === targetHost && window.location.pathname === new URL(targetURL).pathname) {
console.log('?? Posible bucle detectado, cancelando redirección');
return;
}
console.log('?? Ejecutando redirección...');
// Usar replace en lugar de href para evitar historial
window.location.href = "https://www.portalminero.com/wp/datos-metales/?metal=Cobre";
});
replace(targetURL);
} catch (error) {
console.error('? Error en redirección:', error);
// Fallback: mostrar enlace manual
showManualRedirect();
}
}
// Mostrar mensaje manual si falla la redirección automática
function showManualRedirect() {
const messageDiv = document.createElement('div');
messageDiv.innerHTML = `
<div style="
padding: 20px;
border: 2px solid #FF5630;
background-color: #FFEBE6;
text-align: center;
margin: 20px 0;
position: relative;
z-index: 9999;
">
<h1 style="color: #DE350B; margin-top: 0;">Esta página ha sido movida</h1>
<p style="font-size: 16px; margin: 15px 0;">La redirección automática falló. Haz clic en el siguiente enlace:</p>
<p style="margin: 15px 0;">
<a href="${targetURL}" style="
background-color: #0052CC;
color: white;
padding: 10px 15px;
text-decoration: none;
border-radius: 3px;
font-weight: bold;
display: inline-block;
">?? Ir a la nueva ubicación (Cobre)</a>
</p>
</div>
`;
// Insertar al inicio del body
if (document.body) {
document.body.insertBefore(messageDiv, document.body.firstChild);
}
}
// Ejecutar redirección inmediata con timeout de seguridad
const redirectTimer = setTimeout(() => {
console.log('? Timeout de redirección alcanzado');
showManualRedirect();
}, 5000); // 5 segundos máximo
// Intentar redirección inmediata
if (document.readyState === 'loading') {
// Si el DOM aún se está cargando
document.addEventListener('DOMContentLoaded', function() {
clearTimeout(redirectTimer);
safeRedirect();
});
} else {
// Si el DOM ya está listo
clearTimeout(redirectTimer);
safeRedirect();
}
// Prevenir ejecución de otros scripts que puedan interferir
window.addEventListener('beforeunload', function() {
console.log('?? Página descargándose para redirección');
});
})();
</script>
<!-- Mensaje porde sirespaldo JavaScriptvisible estámientras desactivadose ejecuta JavaScript -->
<noscript>
<div style="padding: 20px; border: 2px solid #FF5630; background-color: #FFEBE6; text-align: center; margin: 20px 0;">
<h1 style="color: #DE350B;">Esta página ha sido movida</h1>
<p style="font-size: 16px; margin: 15px 0;">Si>JavaScript noestá eresdesactivado. redirigidoHaz automáticamente, haz clic en el siguiente enlace:</p>
<p style="margin: 15px 0;">
<a href="https://www.portalminero.com/wp/datos-metales/?metal=Cobre" style="background-color: #0052CC; color: white; padding: 10px 15px; text-decoration: none; border-radius: 3px; font-weight: bold;">Ir a la nueva ubicación<ubicación (Cobre)</a>
</p>
</div>
</noscript>
</script> |