9 ms·
This is a sweet and simple implementation, however I don't think the title "[...] you haven't read yet" is correct. The code caches every comment ID which exist
by tfsh 5y ago
This is a sweet and simple implementation, however I don't think the title "[...] you haven't read yet" is correct. The code caches every comment ID which exists in the page, even ones outside of the viewport. A more accurate title would be "Display a bell emoji on new HN comments".
- Using the JavaScript Intersection Observer may be an interesting addition, as this would explicitly differentiate comments on the thread which you may not have scrolled down to.
- deleted 5y ago[deleted]
- legrande 5y ago> This is a sweet and simple implementation I love one-thing-well items of code instead of large (and thus non-secure) abstractions built upon other abstractions. Big fan of the K.I.S.S principle https://en.wikipedia.org/wiki/KISS_principle https://en.wikipedia.org/wiki/KISS_principle
- obventio56 5y agoI will point out that that reason this can be so concise is because of a set of large foundational abstractions.
- legrande 5y agoGood point. I never thought of it that way. The modern PC is a marvel. On one hand it's a complex mess, on the other we can write poetry like that JS snippet, and it all works seamlessly (unless you're doing something weird).
- sillysaurusx 5y agoI changed the script so that the bells stay till you mouseover each HN comment: https://news.ycombinator.com/item?id=28540049 https://news.ycombinator.com/item?id=28540049
- myfonj 5y agoI've made userscript that locally stores hashes of titles and comments that stays in viewport for some time period and adds some marker to those displayed for the first time (i.e. guaranteed to be "unread" for the browser profile, provided there was no edit). https://greasyfork.org/en/scripts/423969-hn-style-unread-content/code https://greasyfork.org/en/scripts/423969-hn-style-unread-con... It uses IntersectionObserver for "exposition watch" and "crypto.subtle.digest" for SHA-1 hashes - I was pleasantly surprised those native APIs are enough to get this magic working. It's very POC-ey (absolutely no checks for storage capacity etc) but works quite well for me. E: Actual markers are just light green right borders on "unread" items that slightly fades out after "exposition timeout". I'm using dark userstyle for HN (https://uso.kkx.one/style/71155 https://uso.kkx.one/style/71155 ); in default theme they are probably too light to be visible.
- deleted 5y ago[deleted]