Skip to content

Instantly share code, notes, and snippets.

@simevidas
Created November 29, 2023 12:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simevidas/5f54eed1ab1e26eedc6d1c4beac49a21 to your computer and use it in GitHub Desktop.
Save simevidas/5f54eed1ab1e26eedc6d1c4beac49a21 to your computer and use it in GitHub Desktop.
// ==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