Сергей Ракипов,
кликнуть по одной из ссылок, перезагрузить пример.
<!DOCTYPE html>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
<style type="text/css">
a.visited{
color: #000;
text-decoration: none;
text-decoration-line: line-through;
cursor: no-drop;
}
</style>
</head>
<body>
<a href="https://www.youtube.com/" title="https://www.youtube.com/" target="_blank">https://www.youtube.com/</a>
<a href="https://www.google.com/" title="https://www.google.com/" target="_blank">https://www.google.com/</a>
<script>
document.addEventListener("DOMContentLoaded", function() {
let link = localStorage.link ? JSON.parse(localStorage.link) : [];
document.querySelectorAll('a').forEach(a => {
let href = a.getAttribute('href');
if (link.includes(href)) a.classList.add('visited')
})
document.addEventListener("click", ({ target }) => {
if (target && target.hasAttribute('href')) {
let href = target.getAttribute('href');
if (!link.includes(href)) {
link.push(href);
localStorage.link = JSON.stringify(link)
}
target.classList.add('visited')
}
});
});
</script>
</body>
</html>