top of page

All Posts

bottom of page
function storeYBValue() { const urlParams = new URLSearchParams(window.location.search); const useYB = urlParams.get('useYB'); if (useYB) { sessionStorage.setItem('useYB', useYB); } } function findOriginalNumber() { const useYB = sessionStorage.getItem('useYB'); if (!useYB) { const defaultMappings = [ { pattern: /1?[-s]?(?786)?[-s]?558[-s]?4015/g, newNumber: "(321) 200-1096" } ]; const walker = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT, null, false); let node; while ((node = walker.nextNode())) { defaultMappings.forEach(rep => { if (rep.pattern.test(node.nodeValue)) { node.nodeValue = node.nodeValue.replace(rep.pattern, rep.newNumber); } }); } try { const links = document.querySelectorAll('a[href^="tel:"]'); links.forEach(link => { let href = link.getAttribute('href'); defaultMappings.forEach(rep => { if (rep.pattern.test(href)) { href = href.replace(rep.pattern, rep.newNumber.replace(/[^d]/g, '')); } }); link.setAttribute('href', href); }); } catch (error) { console.error("Error processing 'tel:' links:", error); } } else { const indexedMappings = [ { condition: (useYB === '1'), pattern: /1?[-s]?(?786)?[-s]?558[-s]?4015/g, newNumber: "(321) 207-6675" }, { condition: (useYB === '2'), pattern: /1?[-s]?(?786)?[-s]?558[-s]?4015/g, newNumber: "(321) 218-2091" }, { condition: (useYB === '3'), pattern: /1?[-s]?(?786)?[-s]?558[-s]?4015/g, newNumber: "(321) 218-2229" } ]; const walker = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT, null, false); let node; while ((node = walker.nextNode())) { indexedMappings.forEach(rep => { if (rep.condition && rep.pattern.test(node.nodeValue)) { node.nodeValue = node.nodeValue.replace(rep.pattern, rep.newNumber); } }); } try { const links = document.querySelectorAll('a[href^="tel:"]'); links.forEach(link => { let href = link.getAttribute('href'); indexedMappings.forEach(rep => { if (rep.condition && rep.pattern.test(href)) { href = href.replace(rep.pattern, rep.newNumber.replace(/[^d]/g, '')); } }); link.setAttribute('href', href); }); } catch (error) { console.error("Error processing 'tel:' links:", error); } } } window.onload = function() { storeYBValue(); findOriginalNumber(); }