Bookmarklet to highlight recent comments in a Hacker News thread
Bookmarklet to highlight recent comments in a Hacker News thread
I find myself often checking into a thread to see the latest replies, which usually means visually scanning for comments that have "minutes" in the timestamp. I decided to automate this (and a bit extra) with a bookmarklet. Create a new bookmark in your web browser and paste the following into the URL field: javascript:(function() { const cutoffStr = prompt("Highlight posts in the last:", "1 hour"); function millisForStr(s) { const [num, unit] = s.split(' '); const parsedNum = Number(num); return unit.includes('minute') ? parsedNum * 60 * 1000 : unit.includes('hour') ? parsedNum * 60 * 60 * 1000 : unit.includes('day') ? parsedNum * 24 * 60 * 60 * 1000 : NaN; } Array.from(document.querySelectorAll('.age')) .map(el => { const interval = millisForStr(el.innerText); return [el, new Date(Date.now() - interval)]; }) .forEach(([el, date]) => { const cutoff = new Date(Date.now() - millisForStr(cutoffStr)); if (date >= cutoff) { el.parentElement.parentElement.parentElement.style.background = "rgba(255, 215, 0, 0.5)"; } else { el.parentElement.parentElement.parentElement.style.background = null; } }) })(); When clicked, you'll be prompted for a string of the form "1 hour" or "23 minutes" or "2 days", and after submitting you'll see all comments on the current page that fall within that interval highlighted with a gold-colored background. Let me know what you think or if you'd like any other small features!
Share cardActual performance
Launch Intel predictions
Analyze your own launch →Incorrect prediction on native model
Similar products
Collapse Comments on Hacker News
Hacker News Comments
Collapsible comments for Hacker News
hncynic – Generate Hacker News Comments from Titles
Hacker News Live Comments Bookmarklet
Visual representation of Hacker News comments
Hacker News but it's only the comments with none of the context
Hacker News Telegraph: News generated from your comments
Automatically upvote downvoted comments on Hacker News
HNLikes – The most frequently posted links in Hacker News comments