Skip to content

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
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.