Hacker News new | ask | show | jobs
Show HN: Greasemonkey script to put the comment-collapse switch at the beginning
3 points by sendos 3629 days ago
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");
       }
   })();