cloudwalkerfre / 煎蛋助手

// ==UserScript==
// @name         煎蛋助手
// @version      1.0
// @description  按照OO数自动排序(无聊图和妹子图),增加翻页快捷键,隐藏评论数量超过设定的用户的留言(不看吵架)
// @author       cloudwalkerfree@gmail.com
// @match        https://jandan.net/*
// @match        http://jandan.net/*
// @namespace    http://jandan.net/
// @license      MIT
// ==/UserScript==

var curserStyle = "style=\"cursor: pointer; display: inline;background-color: #DEDEDE; border-radius: 20px; bottom: 50%; color: #ffffff; display: block; float: left; font-size: 26px; margin-left: -10%; padding-bottom: 5px; position: fixed; text-align: center; width: 40px; z-index: 13;\"";

//OO和XX高亮
(function(){
    $('.comment-like').attr('style','color:red');
    $('.comment-unlike').attr('style','color:blue');
})();

//按照OO从高到低排序图片/评论
(function(){
    var sorting = new Array();
    var num = $('li[id*="comment"]').size();
    for(var i = 0; i< num; i++){
        sorting[i] = new Array();
        sorting[i][0] = $('.tucao-like-container').find('span:first').eq(i).text();
        sorting[i][1] = $('li[id*="comment"]').eq(i).attr('id');
    }

    sorting.sort(function(a,b){
        return b[0] - a[0]; 
    });

    for(var i = 0; i< num; i++){
        $('.commentlist').append($('li[id='+sorting[i][1]+']'));
    }
    
}
)();


//增加翻页快捷键,以及左右方向键翻页
(function(){ 
    $(document).keydown(function(e){
        if(['author', 'email', 'comment'].indexOf($(':focus').attr('id')) ==  -1 && ['tucao-content', 'tucao-nickname', 'tucao-email'].indexOf($(':focus').attr('class')) ==  -1){
            if(e.which == 37){
                $('.next-comment-page').get(0).click();
            }else if(e.which == 39){
                $('.previous-comment-page').get(0).click();
            }            
        }
    });
   
})();

//防止排序后图片不加载
(function(){
    window.scrollBy(0,10);
    window.scrollBy(0,-10);
})();