Skip to content

Instantly share code, notes, and snippets.

@coderofsalvation
Last active June 12, 2022 10:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coderofsalvation/5c1eb5de2e1955206b7986939ed180d7 to your computer and use it in GitHub Desktop.
Save coderofsalvation/5c1eb5de2e1955206b7986939ed180d7 to your computer and use it in GitHub Desktop.
bookmarketlet to mark clicked images as seen
<a href="javascript:(function()%7BsetInterval(%20()%20%3D%3E%20%7B%0A%20%20%20%20let%20imgs%20%3D%20%5B...document.querySelectorAll(%22img%22)%5D%0A%20%20%20%20imgs.map(%20(i)%20%3D%3E%20%7B%0A%20%20%20%20%20%20let%20rec%20%3D%20localStorage.getItem(i.src)%3B%0A%20%20%20%20%20%20if(%20rec%20)%7B%0A%20%20%20%20%20%20%20%20i.style.opacity%20%3D%200.15%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20i.addEventListener('click'%2C%20((i)%20%3D%3E%20()%20%3D%3E%20localStorage.setItem(i.src%2C'%7B%7D'))(i)%20)%0A%20%20%20%20%7D)%0A%7D%2C2000)%7D)()%3B">marketplace_seenmarker</a>
javascript:(function()%7BsetInterval(%20()%20%3D%3E%20%7B%0A%20%20%20%20let%20imgs%20%3D%20%5B...document.querySelectorAll(%22img%22)%5D%0A%20%20%20%20imgs.map(%20(i)%20%3D%3E%20%7B%0A%20%20%20%20%20%20let%20rec%20%3D%20localStorage.getItem(i.src)%3B%0A%20%20%20%20%20%20if(%20rec%20)%7B%0A%20%20%20%20%20%20%20%20i.style.opacity%20%3D%200.15%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20i.addEventListener('click'%2C%20((i)%20%3D%3E%20()%20%3D%3E%20localStorage.setItem(i.src%2C'%7B%7D'))(i)%20)%0A%20%20%20%20%7D)%0A%7D%2C2000)%7D)()%3B
setInterval( () => {
let imgs = [...document.querySelectorAll("img")]
imgs.map( (i) => {
let rec = localStorage.getItem(i.src);
if( rec ){
i.style.opacity = 0.15
}
i.addEventListener('click', ((i) => () => localStorage.setItem(i.src,'{}'))(i) )
})
},2000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment