Collapsit

Enables collapsing (and expanding) of comments on Removeddit.

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name               Collapsit
// @name:de            Collapsit
// @name:en            Collapsit
// @namespace          sun/userscripts
// @version            1.0.20
// @description        Enables collapsing (and expanding) of comments on Removeddit.
// @description:de     Ermöglicht das Ein- und Ausklappen von Kommentaren auf Removeddit.
// @description:en     Enables collapsing (and expanding) of comments on Removeddit.
// @compatible         chrome
// @compatible         edge
// @compatible         firefox
// @compatible         opera
// @compatible         safari
// @homepageURL        https://forgejo.sny.sh/sun/userscripts
// @supportURL         https://forgejo.sny.sh/sun/userscripts/issues
// @contributionURL    https://liberapay.com/sun
// @contributionAmount €1.00
// @author             Sunny <[email protected]>
// @include            *://*.removeddit.com/r/*/comments/*
// @match              *://*.removeddit.com/r/*/comments/*
// @run-at             document-end
// @inject-into        auto
// @grant              none
// @noframes
// @icon               https://forgejo.sny.sh/sun/userscripts/raw/branch/main/icons/Collapsit.ico
// @copyright          2020-present, Sunny (https://sny.sh/)
// @license            Hippocratic License; https://forgejo.sny.sh/sun/userscripts/src/branch/main/LICENSE.md
// ==/UserScript==

(() => {
  document.addEventListener("click", (event) => {
    if (event.target?.matches(".comment-head .author:not(.comment-author)")) {
      event.preventDefault();
      if (event.target.textContent === "[–]") {
        for (const x of Array.from(
          event.target.parentNode.parentNode.children,
        ).slice(1))
          x.style.display = "none";
        event.target.textContent = "[+]";
      } else {
        for (const x of Array.from(
          event.target.parentNode.parentNode.children,
        ).slice(1))
          x.style.display = "";
        event.target.textContent = "[–]";
      }
    }
  });
})();