Skip to content

Instantly share code, notes, and snippets.

@alexcican
alexcican / :visited.js
Created May 20, 2015 06:19
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;
}
}