TJournal.ru Comments Rating Hightlight

Comments Rating Hightlighter

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        TJournal.ru Comments Rating Hightlight
// @namespace   none
// @description Comments Rating Hightlighter
// @include     https://tjournal.ru/*
// @include     http://tjournal.ru/*
// @version     1.31
// @grant       none
// @author      None
// @run-at document-end
// ==/UserScript==
var UsetToHide = [//По имени фильтруем,
        //'Фёдор Хан'
    ];

    var UserIDToHide = [ // По ID фильтруем, чтоб наверняка
        //'66666'
    ];

    var ratingToMegaHide = -5; // после какого рейтинга делаем подсветку и минимальную прозрачность
    var ratingToHide = 0; // после какого рейтинга делаем комментарий полу-прозрачным
    var ratinSuperPost = 10; // после какого рейтинга делаем комментарий зеленым

    $("div.comment").each(function( index ) {
        var comment = $( this );
        var username = comment.find("a.b-comment__user").find("span").text();
        var user_id = comment.find("a.b-comment__user").attr("href");
        comment.find("div.rating").each(function( index ) {
            count = parseInt($( this ).find("div.rating-count").text().trim().replace("–","-"));
            if(count < ratingToMegaHide){
                $(comment).css("opacity","0.1").css('color','#c12216').css("background-color",'#ffd9d9').mouseover(function(){
                    $(this).css("opacity","1");
                }).mouseout(function(){
                    $(this).css("opacity","0.1");
                });
            }else if(count < ratingToHide){
                $(comment).css("opacity","0.3").mouseover(function(){
                    $(this).css("opacity","1");
                }).mouseout( function(){
                    $(this).css("opacity","0.3");
                } );
            }else if(count > ratinSuperPost){
                $(comment)
                    .css("opacity","1")
                    .css("color",'#2a7815')
                    .css('background-color','#c9f4b4');
            }
        });
        for(var i=0;i<UserIDToHide.length;i++){
            var patt = new RegExp('/'+UserIDToHide[i],"i");
            if(patt.test(user_id)){
                $(comment).css("opacity","0.1").css('color','#c12216').css("background-color",'#c9f4b4').mouseover( function(){
                    $(this).css("opacity","1");
                }).mouseout( function(){
                    $(this).css("opacity","0.1");
                } );
            }
        }
        for(i=0;i<UsetToHide.length;i++){
            patt = new RegExp(UsetToHide[i],"i");
            if(patt.test(username)){
                $(comment).css("opacity","0.1").css('color','#c12216').css("background-color",'#c9f4b4').mouseover( function(){
                    $(this).css("opacity","1");
                }).mouseout( function(){
                    $(this).css("opacity","0.1");
                } );
            }
        }
    });