Hacker News Threshold

Allows you to highlight threads on Hacker News which have a number of points greater than a specified threshold

2014-09-17 기준 버전입니다. 최신 버전을 확인하세요.

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

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

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==UserScript==
// @name            Hacker News Threshold
// @namespace       HackerNewsThreshold
// @description     Allows you to highlight threads on Hacker News which have a number of points greater than a specified threshold
// @include         *://news.ycombinator.com/*
// @version         0.1
// ==/UserScript==
var init = function() {
    function addThreshold() {
        $("head").append("<style>.hnth{background: #FFFB93 !important;}.hnterr{background:#FF0000;color:#fff;}</style>");

        function highlightThreads(threshold) {
            var $hnfti = $("#hnfti");
            if (!isNaN(threshold)) {
                $hnfti.removeClass("hnterr");
                $(".hnth").removeClass("hnth");
                $("span[id^='score_']").filter(function() {
                    var m = $(this).html().match(/[0-9]+/g);

                    if (m) {
                        return parseInt(threshold) <= parseInt(m[0]);
                    } else {
                        return false;
                    }
                }).closest("tr").prev().addClass("hnth");
            } else {
                $(".hnth").removeClass("hnth");
                $hnfti.addClass("hnterr");
            }
        }

        $("#hnfti").live("keyup",
                function() {
                    highlightThreads($(this).val());
                });

        var startthreshold = 100;

        $($(".pagetop")[0]).append(" | Threshold: <input type='text' id='hnfti' value='" + startthreshold + "'  />");

        highlightThreads(startthreshold);
    }

    (function(fn) {
        var script = document.createElement('script');
        script.src = 'https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js';
        script.addEventListener('load',
                function() {
                    var script = document.createElement('script');
                    script.textContent = 'jQuery.noConflict();(function($){(' + fn.toString() + ')();})(jQuery);';
                    document.body.appendChild(script);
                },
                false);
        document.body.appendChild(script);
    })(init);