Created
November 29, 2023 12:22
-
-
Save simevidas/5f54eed1ab1e26eedc6d1c4beac49a21 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// ==UserScript== | |
// @name highlight new items | |
// @match https://news.ycombinator.com/classic | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=ycombinator.com | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
let hours = 12; | |
let now = new Date(); | |
let items = document.querySelectorAll('.athing'); | |
for (let item of items) { | |
let anchor = item.querySelector('.titleline a'); | |
let time = item.nextElementSibling.querySelector('.age'); | |
let delta = now - new Date(time.title); | |
if (delta < hours*60*60*1000) { | |
anchor.style.background = 'yellow'; | |
} | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment