Spaces:
No application file
No application file
Create content.js
#2
by
hotboxxgenn
- opened
- content.js +31 -0
content.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 });
|