Instantly share code, notes, and snippets.

Embed
What would you like to do?
Chuck's excellent script to deal with tracker images without alt tag - the ones that mess up a11y scans!
document.addEventListener('DOMContentLoaded', function () {
const targetNode = document.body;
const callback = function (mutationsList) {
for (let mutation of mutationsList) {
if (mutation.type == 'childList') {
mutation.addedNodes.forEach((node) => {
if (node && node.src && node.src.match(/.*pages02.net.*/).length >
0) {
observer.disconnect();
node.setAttribute("aria-hidden", true);
node.setAttribute("alt", "");
}
});
}
}
};
const observer = new MutationObserver(callback);
observer.observe(targetNode, {
childList: true
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment