User:Fulmine/common.js

// select all elements with the class 'image-link' var imageLinks = document.querySelectorAll('.image-link');

imageLinks.forEach(function(imageLink) {   // select the image element within the link element    var image = imageLink.querySelector('img');

// get the href attribute of the link var href = imageLink.getAttribute('href');

// check if the link has been visited if (localStorage.getItem(href)) { // if visited, set image color to purple image.style.filter = 'hue-rotate(45deg)'; }

// when the link is clicked imageLink.addEventListener('click', function {       // set the href as visited        localStorage.setItem(href, true);    }); });