Reddit New Comment Highlighting

A free Gold feature

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         Reddit New Comment Highlighting
// @description  A free Gold feature
// @version      1.0.0
// @namespace    skeeto
// @license      Public Domain
// @include      http*://*.reddit.com/*
// @grant        none
// ==/UserScript==

var HLN = HLN || {};

HLN.highlight = function(cutoff) {
    $('.entry').each(function() {
        var date = new Date($(this).find('time').attr('datetime')).getTime();
        if (date > cutoff) {
            $(this).addClass('new-comment');
        } else {
            $(this).removeClass('new-comment');
        }
    });
};

HLN.subreddit = function() {
    var match = /\/comments\/([a-z0-9]{6,})/.exec(window.location);
    return match != null ? match[1] : null;
};

HLN.lastvisit = function() {
    var subreddit = HLN.subreddit();
    if (subreddit != null) {
        var last = window.localStorage[subreddit + '-lastvisit'];
        if (last != null) {
            return parseFloat(last);
        } else {
            return null;
        }
    } else {
        return null;
    }
};

HLN.mark = function(time) {
    var subreddit = HLN.subreddit();
    if (subreddit != null) {
        return window.localStorage[subreddit + '-lastvisit']
            = time || Date.now();
    } else {
        return null;
    }
};

HLN.run = function() {
    var last = HLN.lastvisit();
    if (last) {
        HLN.highlight(last);
    }
    HLN.mark();
};

HLN.run();