Created
February 25, 2021 19:22
-
-
Save bduggan/0f7c75aa52a06818057e49efb4cf2b78 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let as = document.getElementsByTagName('a') | |
let now = Date.now(); | |
for (let item of as) { | |
let href = item.getAttribute('href'); | |
let last = localStorage.getItem(href); | |
let days_ago = (now - last)/1000/60/60/24; | |
let h = 190; | |
// if (days_ago > 20) { h = 90; } | |
let s = days_ago > 1 ? 20 : 20 + 60 * (1 - days_ago); | |
let l = days_ago > 1 ? 20 : 20 + 60 * (1 - days_ago); | |
item.style.backgroundColor = `hsl(${h},${s}%,${l}%)` | |
if (days_ago < 1) { | |
item.style.color = `black` | |
} | |
item.addEventListener("click", function() { | |
localStorage.setItem(href,Date.now()); | |
} ); | |
console.log(` added ${href} (${days_ago})`); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment