Skip to content

Instantly share code, notes, and snippets.

@alexcican
Created May 20, 2015 06:19
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 alexcican/fdc28a0a9ce627bd666a to your computer and use it in GitHub Desktop.
Save alexcican/fdc28a0a9ce627bd666a to your computer and use it in GitHub Desktop.
Adding :visited styling to visited links with JS (CSS: a[data-visited])
localStorage.setItem('visited-'+window.location.pathname,true);
var links = document.getElementsByTagName('a');
for (i=0;i<links.length;i++) {
var link = links[i];
if (link.host == window.location.host
&& localStorage.getItem('visited-' + link.pathname + '/')) {
link.dataset.visited = true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment