Files changed (1) hide show
  1. content.js +18 -24
content.js CHANGED
@@ -1,31 +1,25 @@
1
- // Function to find and replace price elements
2
- function modifyPrices() {
3
- // Common selectors for price elements (adjust based on target sites)
4
- const priceSelectors = [
5
- '[class*="price"]',
6
- '[id*="price"]',
7
- '[data-price]',
8
- 'span:contains("$")',
9
- 'div:contains("USD")',
10
- 'p:contains("Buy") + *'
11
  ];
12
 
13
- priceSelectors.forEach(selector => {
14
- const elements = document.querySelectorAll(selector);
15
- elements.forEach(element => {
16
- // Crude way to detect if it looks like a price
17
- if (element.textContent.match(/[$]?\d+[\.\d{2}]?/)) {
18
- element.textContent = '$0.00';
19
- // Optionally add a data attribute to mark it as modified
20
- element.setAttribute('data-price-modified', 'true');
21
- }
22
- });
23
  });
24
  }
25
 
26
- // Run on page load
27
- window.addEventListener('load', modifyPrices);
28
 
29
- // Observe DOM changes for dynamically loaded content
30
- const observer = new MutationObserver(modifyPrices);
31
  observer.observe(document.body, { childList: true, subtree: true });
 
1
+ function scanAndModifyPrices() {
2
+ const pricePatterns = [
3
+ /\$\d+(\.\d{2})?/, // $10 or $10.99
4
+ /\d+(\.\d{2})?\s*USD/, // 10 USD or 10.99 USD
5
+ /Price:\s*\d+(\.\d{2})?/, // Price: 10.00
6
+ /\d+(\.\d{2})?\s*EUR/ // 10.99 EUR
 
 
 
 
7
  ];
8
 
9
+ const elements = document.querySelectorAll('span, div, p, h1, h2, h3, h4, h5, h6');
10
+ elements.forEach(el => {
11
+ const text = el.textContent;
12
+ if (pricePatterns.some(pattern => pattern.test(text))) {
13
+ el.textContent = '$0.00';
14
+ el.style.color = 'green'; // Visual cue for modification
15
+ el.setAttribute('data-price-zero', 'true');
16
+ }
 
 
17
  });
18
  }
19
 
20
+ // Initial scan
21
+ scanAndModifyPrices();
22
 
23
+ // Handle dynamic content
24
+ const observer = new MutationObserver(scanAndModifyPrices);
25
  observer.observe(document.body, { childList: true, subtree: true });