
Show HN: Two Column HN Frontpage for Firefox/Chrome - brudgers
A GreaseMonkey [Firefox] or TamperMonkey [Chrome&#x2F;Chromium] script to create a two column layout on the Hacker News front page. Useful to avoid scrolling. Probably not useful for much else.<p><pre><code>    &#x2F;&#x2F; ==UserScript==
    &#x2F;&#x2F; @name        hmMainPage
    &#x2F;&#x2F; @namespace   com.kludgecode.hn.demo
    &#x2F;&#x2F; @include     https:&#x2F;&#x2F;news.ycombinator.com&#x2F;news
    &#x2F;&#x2F; @version     1
    &#x2F;&#x2F; @grant       none
    &#x2F;&#x2F; ==&#x2F;UserScript==

    (function () {
      &#x2F;&#x2F; itemList[0] is the target document element
      var itemList = document.getElementsByClassName(&#x27;itemlist&#x27;)[0];
      &#x2F;&#x2F; r is the container for the content we build
      var r = document.createElement(&#x27;tr&#x27;);
      &#x2F;&#x2F; it will display two columns
      var left = document.createElement(&#x27;td&#x27;);
      var right = document.createElement(&#x27;td&#x27;);
      &#x2F;&#x2F; An array of the first row of each item
      var row1 = Array.prototype.slice.call(document.getElementsByClassName(&#x27;athing&#x27;), 0);
      &#x2F;&#x2F; the second row of each item; a table body that wraps both rows; a table that wraps the table body
      var row2 = []; tb = []; t = [];
      &#x2F;&#x2F; control the loops
      var len = row1.length;

      for (var i = 0; i &lt; len; i++) {
        row2.push(row1[i].nextElementSibling);
        tb.push(document.createElement(&#x27;tb&#x27;));
        t.push(document.createElement(&#x27;table&#x27;));
      };
      
      for (var i = 0; i &lt; len; i++) {
        tb[i].appendChild(row1[i]);
      };
 
      for (var i = 0; i &lt; len; i++) {
        tb[i].appendChild(row2[i]);
      };
 
      for (var i = 0; i &lt; len; i++) {
        t[i].appendChild(tb[i]);
      };
 
      for (var i = 0; i &lt; len &#x2F; 2; i++) {
        left.appendChild(t[i])
      };
 
      for (var i = len &#x2F; 2; i &lt; len; i++) {
        right.appendChild(t[i])
      };
 
      r.appendChild(left);
      r.appendChild(right);
 
      itemList.innerHTML = &quot;&quot;;
 
      itemList.append(r)
    })();</code></pre>
======
brudgers
I wrote too much, imagine that, and had to remove some comments to comply with
2000 character limit. Nothing magical, just a kludge.

