reddit comments expand

when you've collapsed a lot of comment threads on a reddit thread and don't want to expand them all one by one

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         reddit comments expand
// @namespace    http://old.reddit.com/
// @version      1.6
// @description  when you've collapsed a lot of comment threads on a reddit thread and don't want to expand them all one by one
// @author       Antonio Lima
// @match        http://old.reddit.com/r/*/comments/*
// @match        https://old.reddit.com/r/*/comments/*
// @grant        none
// ==/UserScript==

$('#siteTable .flat-list').append('<li><a href="#" id="expander">expand all comments</a></li>');

$('#expander').click(function(e){
    if($('.comment').hasClass("collapsed")) {
        $('.comment').removeClass("collapsed");
        $('.comment').addClass("noncollapsed");
        $('.expand').html("[–]");
    }
    //hides back deleted comments and comments with score below threshold
    $('.collapsed-for-reason').removeClass("noncollapsed");
    $('.collapsed-for-reason').addClass("collapsed");
    $('.deleted').removeClass("noncollapsed");
    $('.deleted').addClass("collapsed");
    //prevents jump to the top of the page
    e.preventDefault();
});