10 votes

Script to jump to unread comments in a post

Okay, so I got tired of scrolling through some of the long comment chains looking for that flash of orange that indicates a new post so I slapped together this solution. It's not pretty nor frictionless to use, but it's less annoying for me than scrolling for days just to find the new comments.

Basic usage is to open the javascript console or scratch pad (e.g., Shift+F4 in Firefox) in your browser, paste in the following line from the code block and run it. It scrolls to the first unread comment and marks it as read; on subsequent runs it will do the same thing for the next unread comment and so on. You will need to enable new comment tracking in your Tildes preferences as well if you haven't done so yet.

{var comment = document.getElementsByClassName("is-comment-new")[0]; if (comment != null) {comment.scrollIntoView(); comment.className = "comment"}}

I had hoped that I could make it into a bookmarklet but unfortunately CSP nixes that option. If anyone else knows of a better way to do this let me know.

5 comments

  1. [4]
    Deimos
    Link
    I'd like to build a native feature for something similar to this soon - what do you think of something like "show only new comments" that would collapse all comments except the new ones, and maybe...

    I'd like to build a native feature for something similar to this soon - what do you think of something like "show only new comments" that would collapse all comments except the new ones, and maybe their direct parents? Do you think just their parent would be enough context, or would it need to show the whole chain back up to a top-level one?

    6 votes
    1. [3]
      kalebo
      Link Parent
      That would be a most welcome feature! Honestly, I think the direct parent is usually than enough context as long as a user could optionally expand the posts further up the hierarchy. Out of...

      That would be a most welcome feature! Honestly, I think the direct parent is usually than enough context as long as a user could optionally expand the posts further up the hierarchy. Out of curiosity, are you thinking that this would be a client side feature dependent on js?

      2 votes
      1. [2]
        Deimos
        Link Parent
        It could be done server side initially (assuming people would want it to be the default view when visiting a thread with new comments), but if it collapses all the "old" comments and the user...

        It could be done server side initially (assuming people would want it to be the default view when visiting a thread with new comments), but if it collapses all the "old" comments and the user doesn't have js enabled, they wouldn't be able to uncollapse any of them, so that might be a bit strange.

        2 votes
        1. zowesiouff
          Link Parent
          I wonder if the whole expand / collapse comments couldn't be done entirely in CSS though. Even if the server pre-fill the right classes / styles, someone without JS could still get more context...

          I wonder if the whole expand / collapse comments couldn't be done entirely in CSS though. Even if the server pre-fill the right classes / styles, someone without JS could still get more context without having to reload ( and thus loosing all his "new" markers :/ )

          ( I'll probably try something later tonight )

          3 votes
  2. crius
    (edited )
    Link
    If you use .parentNode enough times you can target the parent comment :) I'm thinking of creating a collaborative gist to extend tildes features while it's in alpha, just give me time to get to my...

    If you use .parentNode enough times you can target the parent comment :)

    I'm thinking of creating a collaborative gist to extend tildes features while it's in alpha, just give me time to get to my desk :)

    Edit: I made a refined script that also gives you a UI to scroll between new message, check it here