// Function to add the alt attribute to images with the specified src
function addAltToImages() {
const images = document.querySelectorAll('img');
images.forEach(img => {
if (img.src.includes("https://ad.ipredictive.com/d/track/event")) {
img.setAttribute('alt', '');
}
});
}
// Create a MutationObserver to watch for changes in the DOM
const observer = new MutationObserver(mutations => {
mutations.forEach(mutation => {
mutation.addedNodes.forEach(node => {
// Check if the added node is an img element
if (node.tagName === 'IMG') {
addAltToImages(); // Call the function to add alt attribute
} else if (node.querySelectorAll) {
// If it's not an img, check for any img elements inside it
const imgs = node.querySelectorAll('img');
imgs.forEach(img => addAltToImages());
}
});
});
});
// Start observing the document body for child node additions
observer.observe(document.body, {
childList: true,
subtree: true
});
// Initial call to handle any existing images
addAltToImages();