Hacker News new | ask | show | jobs
by seanalltogether 3748 days ago
If we ever make it around to a second piece of javascript on here, can I request that it be a collapse comment function? I promise i won't ask for anything else.
11 comments

https://chrome.google.com/webstore/detail/hacker-news-collap...

I don't know about other browsers, but this works OK on Chrome.

I use this plugin, I don't think I'd visit as often if I didn't have it: https://chrome.google.com/webstore/detail/hacker-news-enhanc...
Thanks for the recommendation!
I use this userscript: https://greasyfork.org/en/scripts/18066-hn-comment-trees

It also highlights new comments and collapses threads without new comments on repeat visits. HN now feels unusable without it in scenarios where I can't use a userscript :-/

What's the rationale behind not making this feature available for everyone?
Quality—don't want to make it too easy to ignore entire chunks of the conversation, and don't want to encourage adding chunks to the conversation that are worth ignoring.

As I understand it.

This bookmarklet http://pastebin.com/raw/Rur0Lrza works if you have less than 500 karma. I haven't figured out how to make it work for over 500 karma.
Is there anything like Reddit Enhancement Suite for HN? Any recommendations out there?
Yes, aptly named "Hacker News Enhancement Suite". I use it and think it does fine, mainly just for collapsing comments.

https://chrome.google.com/webstore/detail/hacker-news-enhanc...

If you want the state of your collapsed comments to be remembered between session you're adding a lot of data to the backend of HN. I can see not implementing it, because threads are short lived and rarely get more comments that can be reasonably browser or searched.

I don't see that collapsing comments would really add much value, especially if the state is to kept per user per comment in the backend.

If you don't care about state, I feel reasonably sure that you could Greasemonkey your way out of not having that feature.

Alternatively, I'd appreciate if comments had a link to their siblings and not just their parents. It wouldn't require any JavaScript, but would (for me) have the same utility.
https://greasyfork.org/en/scripts/12493-hacker-news-folding-...

I wrote this a while ago, which seems to work. I reused the vote arrow with 1/4-turn rotation, placed on the other side of the comment header line to avoid confusion.

I use this bookmarklet:

  javascript:(function()%7Bfunction%20getScript(url,success)%7Bvar%20script=document.createElement('script');script.src=url;var%20head=document.getElementsByTagName('head')%5B0%5D,done=false;script.onload=script.onreadystatechange=function()%7Bif(!done&&(!this.readyState%7C%7Cthis.readyState=='loaded'%7C%7Cthis.readyState=='complete'))%7Bdone=true;success();script.onload=script.onreadystatechange=null;head.removeChild(script)%7D%7D;head.appendChild(script)%7DgetScript('//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js',function()%7Bif(typeof%20jQuery!=='undefined')%7Bif(!$('body').hasClass('collapsible-comments'))%7B$('body').addClass('collapsible-comments');var%20span_html='%3Cspan%20style=%5C'cursor:pointer;margin-right:10px;%5C'%20class=%5C'expand-handle%5C'%3E%5B-%5D%3C/span%3E';if(window.location.href.indexOf('item?id=')!=-1)%7B$('center%20%3E%20table%20%3E%20tbody%20%3E%20tr:eq(2)%20%3E%20td%20%3E%20table:eq(1)%20span.comhead').prepend(span_html)%7Delse%20if(window.location.href.indexOf('threads?id=')!=-1)%7B$('center%20%3E%20table%20%3E%20tbody%20%3E%20tr%20%3E%20td%20%3E%20table%20span.comhead').prepend(span_html)%7D$('.expand-handle').live('click',function()%7Bcurrent_level_width=parseInt($(this).closest('tr').find('td:eq(0)%20%3E%20img').attr('width'),10);$(this).closest('table').closest('tr').nextAll().each(function(index,el)%7Bvar%20elWidth=parseInt($('tbody%20%3E%20tr%20%3E%20td%20%3E%20img',this).attr('width'),10);if(elWidth%3Ecurrent_level_width)%7Bif(elWidth%3C=inner_level_width)%7Binner_level_width=1000;$(this).hide()%7Dif(inner_level_width==1000&&$('.comment',this).css('display')=='none')%7Binner_level_width=elWidth%7D%7Delse%7Breturn%20false%7D%7D);inner_level_width=1000;$(this).text('%5B+%5D').addClass('expand-handle-collapsed').removeClass('expand-handle');$(this).closest('div').nextAll().hide();$(this).closest('div').parent().prev().hide();$(this).closest('div').css(%7B'margin-left':'18px','margin-bottom':'5px'%7D)%7D);$('.expand-handle-collapsed').live('click',function()%7Bcurrent_level_width=parseInt($(this).closest('tr').find('td%20%3E%20img').attr('width'),10);$(this).closest('table').closest('tr').nextAll().each(function(index,el)%7Bvar%20elWidth=parseInt($('tbody%20%3E%20tr%20%3E%20td%20%3E%20img',this).attr('width'),10);if(elWidth%3Ecurrent_level_width)%7Bif(elWidth%3C=inner_level_width)%7Binner_level_width=1000;$(this).show()%7Dif(inner_level_width==1000&&$('.comment',this).css('display')=='none')%7Binner_level_width=elWidth%7D%7Delse%7Breturn%20false%7D%7D);inner_level_width=1000;$(this).text('%5B-%5D').addClass('expand-handle').removeClass('expand-handle-collapsed');$(this).closest('div').nextAll().show();$(this).closest('div').parent().prev().show();$(this).closest('div').css(%7B'margin-left':'0','margin-bottom':'-10px'%7D)%7D)%7D%7D%7D);var%20current_level_width=0;var%20inner_level_width=1000%7D)();
I can't remember who wrote it, but it works.
Thanks, se anal together!