Pronto uno de nuestros enecutivos se contactará contigo
Recibimos tus datos
Gracias por escribirnos. Pronto uno de nuestros comerciales se pondrá en contacto contigo para conversar sobre cómo llevar eficiencia a cada etapa de tu operación.
// ============ FUNCIÓN DE CHEQUEO ============
function checkForSuccessMessage(root) {
root = root || document;
var nodes = root.querySelectorAll
? root.querySelectorAll(TARGET_SELECTOR)
: [];
for (var i = 0; i < nodes.length; i++) {
var node = nodes[i];
// ignora el overlay propio (por si acaso) y elementos ya procesados
if (node.closest && node.closest('#kantia-popup-overlay')) continue;
var text = (node.textContent || '').trim().toLowerCase();
if (text.indexOf(TARGET_TEXT) !== -1) {
// oculta el mensaje original de Elementor
node.style.display = 'none';
showPopup();
return true;
}
}
return false;
}
// ============ OBSERVER ============
var observer = new MutationObserver(function (mutations) {
for (var i = 0; i < mutations.length; i++) {
var m = mutations[i];
// nodos añadidos
if (m.addedNodes && m.addedNodes.length) {
for (var j = 0; j < m.addedNodes.length; j++) {
var addedNode = m.addedNodes[j];
if (addedNode.nodeType !== 1) continue; // solo elementos
// el nodo añadido es el mensaje
if (addedNode.matches && addedNode.matches(TARGET_SELECTOR)) {
var t = (addedNode.textContent || '').trim().toLowerCase();
if (t.indexOf(TARGET_TEXT) !== -1) {
addedNode.style.display = 'none';
showPopup();
return;
}
}
// o lo contiene
if (checkForSuccessMessage(addedNode)) return;
}
}
// cambios en texto / atributos del propio nodo
if (m.type === 'characterData' || m.type === 'attributes') {
var tgt = m.target.nodeType === 3 ? m.target.parentElement : m.target;
if (tgt && tgt.closest) {
var hit = tgt.closest(TARGET_SELECTOR);
if (hit) {
var tx = (hit.textContent || '').trim().toLowerCase();
if (tx.indexOf(TARGET_TEXT) !== -1) {
hit.style.display = 'none';
showPopup();
return;
}
}
}
}
}
});
function startObserving() {
// chequeo inicial por si el mensaje ya existe al cargar
checkForSuccessMessage();
observer.observe(document.body, {
childList: true,
subtree: true,
characterData: true,
attributes: true,
attributeFilter: ['class']
});
// Hook adicional: el evento nativo de Elementor Forms
if (window.jQuery) {
jQuery(document).on('submit_success', function () {
setTimeout(checkForSuccessMessage, 50);
setTimeout(checkForSuccessMessage, 300);
});
}
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', startObserving);
} else {
startObserving();
}
})();