Last active
August 25, 2024 11:15
-
-
Save linkdd/76fd57d02480c3e36a4e3f8ce39322b1 to your computer and use it in GitHub Desktop.
Add a bell emoji to unread comments on HackerNews
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Can be used with https://github.com/xcv58/Custom-JavaScript-for-Websites-2 | |
// This snippet is released under the terms of the CC0 license: https://creativecommons.org/publicdomain/zero/1.0/deed.en | |
const cache_key = 'hn_comments_views' | |
const cache = JSON.parse(localStorage.getItem(cache_key) || '{}') | |
document.querySelectorAll('.athing.comtr').forEach(comm => { | |
if (!cache[comm.id]) { | |
const span = document.createElement('span') | |
span.innerHTML = '🔔' // :bell: emoji | |
comm.querySelector('.comhead').append(span) | |
} | |
cache[comm.id] = true | |
}) | |
localStorage.setItem(cache_key, JSON.stringify(cache)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A significantly different script, with a very similar use case I wrote after seeing this script: https://gist.github.com/justjanne/e61fcc9edb7d3dc60bc1a788d0329a0e
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