Reddit - Comments Tab

Adds a 'comments' tab to the tab-bar in every subreddit and mutireddit

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Reddit - Comments Tab
// @namespace    https://github.com/Dr-Turner
// @version      0.3
// @description  Adds a 'comments' tab to the tab-bar in every subreddit and mutireddit
// @author       Dave Turner
// @match        https://www.reddit.com/r/*
// @match        https://www.reddit.com/me/m/*
// ==/UserScript==

(function() {
    'use strict';
    // find subreddit link
    var sub = document.getElementsByClassName('pagename')[0];
    var a_tag = sub.children[0];
    var current_sub = a_tag.href;

    // create comments tab
    var li = document.createElement('li');
    var a = document.createElement('a');
    var tab_text = document.createTextNode('comments');
    var new_href = current_sub += 'comments';
    // build
    a.href = new_href;
    a.classList = ['choice'];
    a.appendChild(tab_text);
    li.appendChild(a);

    // get tab bar node
    var ul = document.getElementsByClassName('tabmenu')[0];
    //attach
    ul.appendChild(li);
})();