Y Combinator Hacker News Job Posts Adblock

Removes ads on https://news.ycombinator.com/

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name        Y Combinator Hacker News Job Posts Adblock
// @version     1.4
// @match       https://news.ycombinator.com/*
// @exclude     https://news.ycombinator.com/user*
// @author      Dave121
// @description Removes ads on https://news.ycombinator.com/
// @license     GPLv3
// @icon         https://www.google.com/s2/favicons?sz=64&domain=ycombinator.com
// @namespace   https://greasyfork.org/en/users/102920-dave121
// ==/UserScript==

// do you wish to re-number the posts after the removed ads?
const FIX_NUMBERING = false;

// Select all "athing" rows
const rows = document.querySelectorAll('tr.thing, tr.athing');

// Filter rows that do NOT contain a vote arrow (i.e., job posts)
const filteredRows = [...rows].filter(row => !row.querySelector('td.votelinks'));

// Remove both the "athing" and its subtext row
filteredRows.forEach(row => {
  // remove the main row
  const next = row.nextElementSibling;
  row.remove();

  // remove its detail row (age | hide | comments)
  if (next && !next.classList.contains('athing')) {
    next.remove();
  }
});


if (FIX_NUMBERING) {
  document
    .querySelectorAll('span.rank')
    .forEach?.((s, i) => s.textContent && (s.textContent = `${i + 1}.`));
}