const reemplazosDashboard = setInterval(() => {
const accountDashboard = document.querySelector(‘ul.account-dashboard’);
if (accountDashboard) {
accountDashboard.querySelectorAll(‘li a’).forEach(anchor => {
const title = anchor.getAttribute(‘title’)?.trim();
if (title === ‘Dashboard’ && anchor.textContent.trim() === ‘Dashboard’) {
anchor.textContent = ‘Escritorio’;
}
else if (title === ‘Orders’ && anchor.textContent.trim() === ‘Orders’) {
anchor.textContent = ‘Pedidos’;
}
else if (title === ‘Downloads’ && anchor.textContent.trim() === ‘Downloads’) {
anchor.textContent = ‘Descargas’;
}
else if (title === ‘Edit Address’ && anchor.textContent.trim() === ‘Edit Address’) {
anchor.textContent = ‘Editar perfil’;
}
else if (title === ‘Account Details’ && anchor.textContent.trim() === ‘Account Details’) {
anchor.textContent = ‘Mi cuenta’;
}
});
}
const tipsAnchor = document.querySelector(‘a.tips’);
if (tipsAnchor && tipsAnchor.textContent.trim() === ‘Log Out’) {
tipsAnchor.textContent = ‘Cerrar sesión’;
}
// Condición para detener el intervalo cuando ya estén reemplazados
const allReplaced = (
accountDashboard &&
Array.from(accountDashboard.querySelectorAll(‘li a’)).every(anchor => {
const title = anchor.getAttribute(‘title’)?.trim();
const text = anchor.textContent.trim();
if (title === ‘Dashboard’) return text === ‘Escritorio’;
if (title === ‘Orders’) return text === ‘Pedidos’;
if (title === ‘Downloads’) return text === ‘Descargas’;
if (title === ‘Edit Address’) return text === ‘Editar perfil’;
if (title === ‘Account Details’) return text === ‘Mi cuenta’;
return true; // ignore others
}) &&
tipsAnchor && tipsAnchor.textContent === ‘Cerrar sesión’
);
if (allReplaced) {
clearInterval(reemplazosDashboard);
}
}, 300);