E-Hentai Comment Collapser

Hidden comment score < 0.

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

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

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name         E-Hentai Comment Collapser
// @namespace    https://greasyfork.org/users/1069880-l-l
// @version      1.0
// @description  Hidden comment score < 0.
// @author       Li
// @match        https://e-hentai.org/*
// @match        https://exhentai.org/*
// @icon         https://www.google.com/s2/favicons?domain=e-hentai.org
// @grant        GM_addStyle
// @run-at       document-end
// @license      MIT
// ==/UserScript==

// thanks:
// https://greasyfork.org/scripts/450620 (MIT)(greasyfork.org/users/316903-fmnijk)

/* main function */
(function() {
    'use strict';

    if (window.location.href === 'https://e-hentai.org/'){
        return false;
    }

    // 获取所有带有 class="c1" 的元素
    var c1Elements = document.getElementsByClassName("c1");

    // 遍历所有 c1Elements 元素
    for (var i = 0; i < c1Elements.length; i++) {
        var c1Element = c1Elements[i];

        // 查找每个 c1 元素内部的 score 元素
        var scoreElement = c1Element.querySelector(".c5 span");

        if (scoreElement) {
            // 获取 score 的文本内容并转换为整数
            var score = parseInt(scoreElement.innerText.trim(), 10);

            if (score < 0) {
                // 1. 获取评论内容区域 (.c6)
                var contentElement = c1Element.querySelector(".c6");
                if (contentElement) {
                    // 默认隐藏评论内容
                    contentElement.style.display = "none";
                }

                // 2. 略微降低整体的透明度
                c1Element.style.opacity = "0.6";

                // 3. 添加按钮
                var c3Element = c1Element.querySelector(".c3");
                if (c3Element) {
                    var toggleBtn = document.createElement("a");
                    toggleBtn.href = "javascript:void(0);";
                    toggleBtn.innerText = " [Show comment]";
                    toggleBtn.style.color = "#888";
                    toggleBtn.style.cursor = "pointer";
                    toggleBtn.style.marginLeft = "12px";
                    toggleBtn.style.fontWeight = "bold";

                    // 点击事件切换显示状态
                    toggleBtn.onclick = (function(content, container, btn) {
                        return function() {
                            if (content.style.display === "none") {
                                content.style.display = "block";
                                container.style.opacity = "1.0";
                                btn.innerText = " [Hide comment]";
                            } else {
                                content.style.display = "none";
                                container.style.opacity = "0.6";
                                btn.innerText = " [Show comment]";
                            }
                        };
                    })(contentElement, c1Element, toggleBtn);

                    c3Element.appendChild(toggleBtn);
                }
            }
        }
    }
})();