UOJ Comment Filter

让 UOJ 拥有像 CF 那样的评论隐藏机制

目前为 2020-04-21 提交的版本。查看 最新版本

// ==UserScript==
// @name         UOJ Comment Filter
// @namespace    n/a
// @version      0.1
// @description  让 UOJ 拥有像 CF 那样的评论隐藏机制
// @author       iotang
// @match        http://*.blog.uoj.ac/blog/*
// @match        https://*.blog.uoj.ac/blog/*
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    $(document).ready(function () {
        $(".list-group-item").on("filter-censor", function () {
            let now = $(this);
            let rating = now.find(".uoj-click-zan-block").attr("data-cnt");

            if (rating <= -7) {
                now.find(".comtbox1").css("opacity", 0.30);
                now.find(".comtposterbox").css("opacity", 0.30);
                now.find(".col-sm-6").css("opacity", 0.30);
                now.find(".bot-buffer-no").css("opacity", 0.30);
                now.find(".comtbox5").find(".bot-buffer-no").css("opacity", 1.00);
            }
            if (rating <= -15) {
                now.find(".comtbox1").hide();

                let commentHolder = document.createElement("div");
                commentHolder.className = "comment-holder";
                commentHolder.style = "min-height: 80px; white-space: pre-wrap; word-break: break-all; margin-top: 10px; margin-bottom: 10px; opacity: 0.30; font-size: 80%";
                commentHolder.innerHTML = "这个评论由于反馈太负面而被隐藏了,请点击<a class=\"comment-holder-release\" href=\"#\">这儿</a>来显示";

                now.find(".comtbox1").after(commentHolder);
                now.find(".comment-holder-release").click(function () {
                    now.find(".comment-holder").hide();
                    now.find(".comtbox1").show();
                    return false;
                });
            }
        });

        $(".list-group-item").trigger("filter-censor");
    });
})();