TJournal.ru Comments Rating Hightlight

Comments Rating Hightlighter

当前为 2015-07-06 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        TJournal.ru Comments Rating Hightlight
// @namespace   none
// @description Comments Rating Hightlighter
// @include     https://tjournal.ru
// @version     1.2
// @grant       none
// @author      None
// @run-at document-start
// ==/UserScript==
$(document).ready(function(){
    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");
                } );
            }
        }
    });
});