Reddit - Comments Tab

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

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==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);
})();