Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Add a bell emoji to unread comments on HackerNews
// Can be used with
// This snippet is released under the terms of the CC0 license:
const cache_key = 'hn_comments_views'
const cache = JSON.parse(localStorage.getItem(cache_key) || '{}')
document.querySelectorAll('.athing.comtr').forEach(comm => {
if (!cache[]) {
const span = document.createElement('span')
span.innerHTML = '🔔' // :bell: emoji
cache[] = true
localStorage.setItem(cache_key, JSON.stringify(cache))
Copy link

justjanne commented Sep 20, 2021

A significantly different script, with a very similar use case I wrote after seeing this script:

It adds an orange left border to any comment that was posted after your last visit, and it stores all visits you made to a comment section so you can easily choose which comments to highlight.

In functionality 1:1 identical to what Reddit Gold offers, just for Hacker News

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment