// ==UserScript== // @name Hacker News Readability Tweaks // @namespace HackerNewsReadabilityTweaks // @homepage https://github.com/Meekelis/Hacker-News-Readability-Tweaks // @version 2 // @description Improve Hacker News Readability // @author Martin Gladdish & Kazimieras Mikelis // @downloadURL https://raw.githubusercontent.com/Meekelis/Hacker-News-Readability-Tweaks/main/HackerNewsReadabilityTweaks.user.js // @updateURL https://raw.githubusercontent.com/Meekelis/Hacker-News-Readability-Tweaks/main/HackerNewsReadabilityTweaks.user.js // @match *://news.ycombinator.com/* // @icon https://www.google.com/s2/favicons?sz=64&domain=ycombinator.com // @license MIT // ==/UserScript== const userScript = function() { 'use strict'; document.head.insertAdjacentHTML("beforeend", ``); const comments = document.querySelectorAll('.commtext'); comments.forEach(e => { if (!e.classList.contains('c00')) { e.parentElement.classList.add('downvoted'); } }); let node = null; let nodes = []; const ps = document.evaluate("//p[starts-with(., '>')]", document.body) while (node = ps.iterateNext()) { nodes.push(node); } const spans = document.evaluate("//span[starts-with(., '>')]", document.body) while (node = spans.iterateNext()) { nodes.push(node); } nodes.forEach((n) => { const textNode = Array.from(n.childNodes).find((n) => n.nodeType === Node.TEXT_NODE); if (textNode) { const p = document.createElement('p'); p.classList.add('quote'); p.innerText = textNode.data.replace(">", ""); n.firstChild.replaceWith(p); } else { n.classList.add('quote'); n.innerText = n.innerText.replace(">", ""); } }); } userScript();