Created
November 29, 2023 12:11
-
-
Save simevidas/d59ac7f370266dd341638751ae1e6a1d 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
// ==UserScript== | |
// @name highlight new items | |
// @match https://www.reddit.com/r/*/ | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=reddit.com | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
let hours = 12; | |
let now = new Date(); | |
let items = document.querySelectorAll('.thing:not(.promoted)'); | |
for (let item of items) { | |
let anchor = item.querySelector('.title a'); | |
let time = item.querySelector('time'); | |
let delta = now - new Date(time.dateTime); | |
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