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 यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला 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);