Skip to content

Instantly share code, notes, and snippets.

@simevidas
Created November 29, 2023 12:11
Show Gist options
  • Save simevidas/d59ac7f370266dd341638751ae1e6a1d to your computer and use it in GitHub Desktop.
Save simevidas/d59ac7f370266dd341638751ae1e6a1d to your computer and use it in GitHub Desktop.
// ==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