Verified David
- Móvil
- 604873363
- Correo
- info@valroom.com
document.addEventListener('DOMContentLoaded', function () { var CARD_SEL = [ '.property-item', '.property-card', '.property-box', '.property-grid-card', '.listing-card', '.item-wrap', '.grid-view', '.property-item-v1', '.property-listing', '.property', '.listing-item' ].join(', '); var BADGE_SEL = '.status-labels span, .property-status span, .label-status, .status span, .labels span, .label, .badge, [class*="status"] span'; function isRealCard(card){ var hasImg = !!card.querySelector('img'); var hasContent = !!(card.querySelector('.property-title, .item-title, .property-price, a')); return hasImg && hasContent && card.offsetParent !== null; } function dedupeBadges(card, className){ var nodes = card.querySelectorAll('.' + className); if (nodes.length > 1){ nodes.forEach(function(n, i){ if (i > 0) n.remove(); }); } } function markCard(card){ if (!card || !isRealCard(card)) return; card.classList.add('valroom-card'); var hasOffer = false; var hasAvailable = false; var isReserved = false; var hasAvailableDate = false; var availableDateText = ''; card.querySelectorAll(BADGE_SEL).forEach(function(b){ var raw = (b.textContent || '').trim(); var t = raw.toUpperCase(); var c = (b.className || '').toUpperCase(); if (/(OFERTA|OFFER)/.test(t) || /(OFERTA|OFFER)/.test(c)){ hasOffer = true; } if (/DISPONIBLE A PARTIR/.test(t)){ hasAvailableDate = true; availableDateText = raw; } else if (/(DISPONIBLE|AVAILABLE)/.test(t) || /(DISPONIBLE|AVAILABLE)/.test(c)){ hasAvailable = true; } if (/(RESERVADA|RESERVED)/.test(t) || /(RESERVADA|RESERVED)/.test(c)){ isReserved = true; } if ( /(DISPONIBLE|AVAILABLE|OFERTA|OFFER|RESERVADA|RESERVED)/.test(t) || /(DISPONIBLE|AVAILABLE|OFERTA|OFFER|RESERVADA|RESERVED)/.test(c) ){ b.classList.add('valroom-hide-original'); b.style.display = 'none'; } }); var of = card.querySelector('.valroom-flag-offer'); if (hasOffer){ if (!of){ of = document.createElement('span'); of.className = 'valroom-badge valroom-flag-offer'; of.textContent = 'OFERTA'; card.appendChild(of); } } else if (of){ of.remove(); } var av = card.querySelector('.valroom-flag-available'); var rs = card.querySelector('.valroom-flag-reserved'); var ad = card.querySelector('.valroom-flag-available-date'); if (isReserved){ if (!rs){ rs = document.createElement('span'); rs.className = 'valroom-badge valroom-flag-reserved'; rs.textContent = 'RESERVADA'; card.appendChild(rs); } if (av) av.remove(); if (ad) ad.remove(); } else if (hasAvailableDate){ if (!ad){ ad = document.createElement('span'); ad.className = 'valroom-badge valroom-flag-available-date'; ad.textContent = availableDateText; card.appendChild(ad); } else { ad.textContent = availableDateText; } if (av) av.remove(); if (rs) rs.remove(); } else if (hasAvailable){ if (!av){ av = document.createElement('span'); av.className = 'valroom-badge valroom-flag-available'; av.textContent = 'DISPONIBLE'; card.appendChild(av); } if (rs) rs.remove(); if (ad) ad.remove(); } else { if (av) av.remove(); if (rs) rs.remove(); if (ad) ad.remove(); } dedupeBadges(card, 'valroom-flag-available'); dedupeBadges(card, 'valroom-flag-offer'); dedupeBadges(card, 'valroom-flag-reserved'); dedupeBadges(card, 'valroom-flag-available-date'); } function scanAll(){ document.querySelectorAll(CARD_SEL).forEach(markCard); } scanAll(); setTimeout(scanAll, 250); setTimeout(scanAll, 800); var tries = 0; var keepAlive = setInterval(function(){ scanAll(); if (++tries > 10){ clearInterval(keepAlive); } }, 800); var obs = new MutationObserver(function(muts){ muts.forEach(function(m){ m.addedNodes && m.addedNodes.forEach(function(n){ if (n.nodeType !== 1) return; if (n.matches && n.matches(CARD_SEL)){ markCard(n); } if (n.querySelectorAll){ n.querySelectorAll(CARD_SEL).forEach(markCard); } }); }); }); obs.observe(document.body, { childList: true, subtree: true }); });
Comparar listados
Comparar