您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Remove annoying HN posts
当前为
// ==UserScript== // @name HNCleaner // @namespace LWPDWyfub // @version 0.2 // @description Remove annoying HN posts // @author LWPDWyfub // @match https://news.ycombinator.com/* // @exclude https://news.ycombinator.com/item* // @icon https://www.google.com/s2/favicons?sz=64&domain=ycombinator.com // @license MIT // ==/UserScript== (function () { 'use strict'; const annoyingTerms = [ 'ChatGPT', 'Musk', 'Elon', 'spacex', 'tesla' ]; const annoyingSites = ['twitter.com']; const annoyingTermsRegex = new RegExp('(' + annoyingTerms.join('|') + ')', 'i') const annoyingSitesRegex = new RegExp('(' + annoyingSites.join('|') + ')', 'i') const termTargets = Array.from(document.querySelectorAll('.athing')).filter(({ innerText }) => annoyingTermsRegex.test(innerText) || annoyingSitesRegex.test(innerText)) const logoutButton = document.querySelector("#logout") const hidePost = function (postIds, next) { var postId = postIds[next].id console.log("Hiding post[" + next + "] with ID " + postId) var req = XMLHttpRequest({ method: 'GET', url: "https://news.ycombinator.com/hide?id=" + postId, withCredentials: true, onerror: function (error) { console.log("Error hiding " + postId) }, onload: function (response) { var resp = response.responseText; console.log("Hiding post " + postId + " returned code " + response.status) if (resp.includes("Logged") || resp.status != 200) { console.log(resp) } else { console.log("Hid post " + postId) } } }); next = next + 1 if (next < postIds.length) { window.setTimeout(hidePost, 5000, termTargets, next) } else { console.log("Finished hiding final post") } } console.log("Found " + termTargets.length + " annoying targets") for (let target of termTargets) { console.log("Hiding post " + target.id) target.style.display = "none" } // Clean up spacers and comments Array.from(document.querySelectorAll("tr[style*='none'] + tr")).forEach(function (e) { e.style.display = "none" }) Array.from(document.querySelectorAll("tr[style*='none'] + .spacer")).forEach(function (e) { e.style.display = "none" }) // Renumber unhidden posts var allRanks = Array.from(document.querySelectorAll("span.rank")) var shownSpans = Array.from(document.querySelectorAll("span.rank")).filter( e => window.getComputedStyle(e.parentElement.parentElement).display != "none") const firstNum = parseInt(allRanks[0].innerText.replace("\.", "")) for (let i = 0; i < shownSpans.length; i++) { shownSpans[i].innerText = (firstNum + i) + "." } })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址