Spaces:
No application file
No application file
File size: 857 Bytes
4c32a07 29b0879 4c32a07 29b0879 4c32a07 29b0879 4c32a07 29b0879 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | 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 }); |