

Show HN: HN Unread Comments v1.1 released (chrome extension) - CWIZO
https://chrome.google.com/extensions/detail/fpndmkcfggkffpablcooicmihgcgalil

======
bambax
Interesting.

Looking at the source I see that you calculate and store an md5 hash for each
comment:

    
    
        var commentContentMd5 = md5($this.find('table td:eq(2) span.comment').text());
    

However each comment on HN has a unique id, that can be found on the links of
the up and down keys:

    
    
        <a id="up_1943152" href="vote?for=1943152&...
    

Wouldn't it be easier (and maybe faster) to use these ids to identify
comments?

~~~
CWIZO
That is how it was done in the v1.0, but once you vote on a comment that id is
gone. Or maybe I missed something :) Will have a look if I can use the IDs
instead.

edit: bonus "feature" of md5-ing the comments is, that if a comment changes it
is marked as unread again ...

~~~
bambax
> but once you vote on a comment that id is gone

The score is in a span that has the same id:

    
    
        <span id="score_1944875">3 points</span>
    

> if a comment changes it is marked as unread again

But identical comments in different conversations are marked as read... ;-)

~~~
CWIZO
I guess I really did miss something then :) HN's markup is really a mess ...

>But identical comments in different conversations are marked as read... ;-)

true, but that seems highly unlikely here on HN, where you don't have comments
like "lol :)" everywhere.

~~~
raganwald
If one person writes LOL and another repeats it, I consider it a feature that
the second one is also marked as read.

YMMV ;-)

------
chapel
I like the idea of this, but I find the red outline to be jarring and well
quite frankly ugly. I think a more visually pleasing way of showing new vs old
comments would be to make the text of old comments a light shade of grey, and
the new comments normal black. Similar to how a link will have a different
color once it has been visited.

~~~
CWIZO
The colour is actually the same as your HN colour that you can set in your
settings page.

Making read comments a lighter shade of grey would, unfortunately, not go well
with how HN handles comments with <= 0 score.

If you have any more ideas please share them, I know this isn't the optimal
solution right now, but I can't find anything better ...

~~~
chapel
I would just make it a lighter shade, but not as light as a <= 0 score
comment. Those happen to be hard to read.

Maybe you could give the option for the user to set their own CSS values for
read and unread.

~~~
CWIZO
Maybe I'll make it so that you can configure it, yes. So you'll be able to set
the colour of the font and select whether you wish for a box to appear around
unread comments.

------
wvl
This functionality has been available in my hckrnews extension for a while. It
works only for individual item pages, since it tracks (in localstorage) the
last comment id for each page. It uses a simple left border to highlight new
omments, which I think is a little less intrusive (yet easy to spot) than the
screenshot for this extension.

It's available here:

<http://hckrnews.com/about.html>

------
swombat
How does it work in the long run? Am I going to store the entire HN database
in Chrome, until my computer slows down to a crawl?

Otherwise, pretty cool. Installed.

~~~
CWIZO
I've got plans to address this issue in the next release. I've been using this
for more than 2 months now, and I haven't noticed any slow down, but I will do
something about this never the less.

~~~
bambax
You can store the highest comment id for each article: any comment with an (id
> stored highest id for the current article) is new.

The hash thing is interesting for detecting edits, but since comments can be
edited only for a limited amount of time (an hour maybe?) it doesn't need to
be stored for a long time.

Therefore maybe you could do:

\- hash => sessionStorage

\- article_id;highest_comment_id => localStorage

~~~
swombat
That seems like a very smart approach.

------
raganwald
Thank you!

If I haven't read any of the comments on a post, there is no need to show me
that they are new. The entire thread is new, I know that. In essence, the
extension gives comments two states: new or old. I perceive that there are
three states: new, old, and new-since-last-viewed.

I am only interested in special highlighting for the third state, new for
threads I have visited before.

------
cj
Love it... but it'd be much less intrusive if you displayed the red border
around _new_ comments the second time you visit a comment thread. So the
extensions would only change the screen if you visit a comment page more than
once.

The red border is unbearable.

