Hacker Fresh

Highlights fresh comments on HN.

12.12.2014 itibariyledir. En son verisyonu görün.

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

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.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name          Hacker Fresh
// @version       0.0.1
// @namespace     http://userscripts.psbarrett.com
// @description	  Highlights fresh comments on HN.
// @include       https://news.ycombinator.com/item*
// @grant         GM_addStyle
// ==/UserScript==
'use strict'

GM_addStyle(
`td.vote-box {
  border-radius: 5px 0px 0px 5px;
}
.fresh-item {
  background-color: #FF944D;
}`);

function get_comment_id(vote_box) {
  var item_link_ele = vote_box.parentElement.querySelector('.comhead > a:nth-child(2)');
  var link = new URL(item_link_ele.href);
  return link.searchParams.get('id');
}

var all_vote_box = document.querySelectorAll('tbody > tr > td[valign=top]');

for (var e of all_vote_box) {
  e.classList.add("vote-box");
  
  var item_id = get_comment_id(e);
  var status = localStorage.getItem(item_id)
  
  if (status === null) {
    e.classList.add("fresh-item");
    localStorage.setItem(item_id, "seen")
  }
}