Reddit - Comments Tab

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

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

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