您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Highlight points and comments on Hacker News with different colors based on their values
// ==UserScript== // @name Hacker News Points & Comments Highlighter // @namespace http://tampermonkey.net/ // @icon https://news.ycombinator.com/favicon.ico // @version 0.1.1 // @description Highlight points and comments on Hacker News with different colors based on their values // @author RoCry // @match https://news.ycombinator.com/* // @grant none // @license MIT // ==/UserScript== (function() { 'use strict'; // Color functions function getPointsColor(points) { if (points >= 500) return '#FF4500'; // Bright red-orange if (points >= 250) return '#FF6B21'; // Orange if (points >= 100) return '#FF8C42'; // Light orange if (points >= 50) return '#FFA563'; // Pale orange return '#FFB584'; // Very pale orange } function getCommentsColor(comments) { if (comments >= 300) return '#1E88E5'; // Bright blue if (comments >= 200) return '#42A5F5'; // Blue if (comments >= 100) return '#64B5F6'; // Light blue if (comments >= 50) return '#90CAF9'; // Pale blue return '#BBDEFB'; // Very pale blue } // Highlight points document.querySelectorAll('.score').forEach(score => { const points = parseInt(score.innerText); if (!isNaN(points)) { score.style.color = getPointsColor(points); score.style.fontWeight = 'bold'; } }); // Highlight comments document.querySelectorAll('a').forEach(link => { if (link.href.includes('item?id=') && link.innerText.includes('comment')) { const comments = parseInt(link.innerText); if (!isNaN(comments)) { link.style.color = getCommentsColor(comments); link.style.fontWeight = 'bold'; } } }); })();