Spaces:
No application file
No application file
| function scanAndModifyPrices() { | |
| const pricePatterns = [ | |
| /\$\d+(\.\d{2})?/, // $10 or $10.99 | |
| /\d+(\.\d{2})?\s*USD/, // 10 USD or 10.99 USD | |
| /Price:\s*\d+(\.\d{2})?/, // Price: 10.00 | |
| /\d+(\.\d{2})?\s*EUR/ // 10.99 EUR | |
| ]; | |
| const elements = document.querySelectorAll('span, div, p, h1, h2, h3, h4, h5, h6'); | |
| elements.forEach(el => { | |
| const text = el.textContent; | |
| if (pricePatterns.some(pattern => pattern.test(text))) { | |
| el.textContent = '$0.00'; | |
| el.style.color = 'green'; // Visual cue for modification | |
| el.setAttribute('data-price-zero', 'true'); | |
| } | |
| }); | |
| } | |
| // Initial scan | |
| scanAndModifyPrices(); | |
| // Handle dynamic content | |
| const observer = new MutationObserver(scanAndModifyPrices); | |
| observer.observe(document.body, { childList: true, subtree: true }); |