Show HN: Indicate new stories on HN frontpage (Bookmarklet/UserScript)
Tired of missing out on fresh content on Hacker News? This bookmarklet/userscript highlights new stories on the HN frontpage, making it easier to spot the latest discussions and discover exciting new things.
How it works:
Bookmarklet: A simple JavaScript snippet you can add to your browser bookmarks. Clicking it will run on the current HN page, marking new stories.
UserScript: A more powerful approach that runs automatically whenever you visit HN, permanently marking new stories.
Benefits:
Enhanced Discoverability: Quickly identify new content and avoid missing out on trending topics.
Improved Navigation: Easily scan the frontpage and find the most recent discussions.
Tailored Experience: Customize the highlighting colors and styles to match your preferences.
Code Examples:
Bookmarklet:
“`javascript
javascript:(function() {
const newStories = document.querySelectorAll(‘.athing:not(.age-ago)’);
newStories.forEach(story => story.style.backgroundColor = ‘f0f0f0’);
})();
“`
UserScript (Greasemonkey/Tampermonkey):
“`javascript
// ==UserScript==
// @name HN New Stories Highlighter
// @namespace http://tampermonkey.net/
// @version 1.0
// @description Highlights new stories on HN frontpage
// @author [Your Name]
// @match https://news.ycombinator.com/news
// @grant none
// ==/UserScript==
const newStories = document.querySelectorAll(‘.athing:not(.age-ago)’);
newStories.forEach(story => story.style.backgroundColor = ‘f0f0f0’);
Installation:
Bookmarklet: Save the JavaScript code as a bookmark in your browser.
UserScript: Install a userscript manager (Greasemonkey or Tampermonkey) and paste the code into a new script.
Customization:
Change the `backgroundColor` property in the code to your desired color.
Explore additional CSS properties to fine-tune the highlighting style.
Limitations:
The highlighting only applies to stories that have not been aged.
The code may need adjustment for future HN interface changes.
Feedback:
Let us know your thoughts and suggestions! We are always looking for ways to improve this tool and make it even more helpful.
Share this article and let your fellow HN users discover this handy feature!