Settings

Theme

Show HN: Greasemonkey script to put the comment-collapse switch at the beginning

3 points by sendos 10 years ago · 0 comments · 1 min read


The new feature that was recently added to HN, which is to be able to toggle the collapse of the comment threads, has the toggle switch at the end of the comment header.

The script below puts it at the beginning of the comment header, just after the up/down vote arrows.

This has been tested in Firefox.

  // ==UserScript==
  // @name        HN: Change location of comment-collapse toggle switch
  // @namespace   HN_sendos
  // @include     https://news.ycombinator.com/item?id=*
  // @version     1
  // @run-at      document-idle
  // @grant       none
  // ==/UserScript==
 
  (function() 
   {
       var allPosts    = document.getElementsByClassName('comhead');
     
       for (var i = 0; i < allPosts.length; i++)
       {
           allPosts[i].innerHTML = allPosts[i].innerHTML.replace(RegExp("^(.+)(<a class=\"togg\" .+</a>)(.*)$","mg"), "$2 $1 $3");
       }
   })();

No comments yet.

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection