hn-blocklist

A bookmarklet for removing unwanted posts from Hacker News. Currently configured to target AI-related posts.

View the source code

Installation

Method 1: Drag and Drop

  1. Visit https://dan-lovelace.github.io/hn-blocklist/
  2. Drag this link to your bookmarks bar:
    HN 🔥
  3. Click the bookmark any time you visit Hacker News

Method 2: Manual Bookmark

  1. Copy this snippet:
    javascript:(()%20%3D%3E%20%7B%20class%20HNBlocklist%20%7B%20_removedCount%20%3D%200%3B%20removePatterns%20%3D%20%5B%20%2F%5Cbagent%5Bs%5D%3F%5Cb%2Fgi%2C%20%2F%5CbAI%5Cb%2Fg%2C%20%2Fanthropic%2Fgi%2C%20%2Fartificial%20intelligence%2Fgi%2C%20%2F%5CbChatGPT%5Cb%2Fgi%2C%20%2Fclaude%2Fgi%2C%20%2F%5Cbcopilot%5Cb%2Fgi%2C%20%2F%5CbCursor%5Cb%2Fg%2C%20%2F%5CbDALL-%3FE%5Cb%2Fgi%2C%20%2F%5Cbdeepseek%5Cb%2Fgi%2C%20%2Fdiffusion%2Fgi%2C%20%2F%5Cbembedding%5Bs%5D%3F%5Cb%2Fgi%2C%20%2F%5Cbgemini%5Cb%2Fgi%2C%20%2Fgenerative%2Fgi%2C%20%2FGPT%2Fg%2C%20%2F%5Cbfoundation%20model%2Fgi%2C%20%2F%5Cbgrok%5Cb%2Fgi%2C%20%2F%5Cbinference%5Cb%2Fgi%2C%20%2F%5Cbllama%5Cb%2Fgi%2C%20%2FLLM%5Bs%5D%3F%2Fg%2C%20%2Fmachine%20learning%2Fgi%2C%20%2F%5Cbmidjourney%5Cb%2Fgi%2C%20%2F%5Cbmistral%5Cb%2Fgi%2C%20%2F%5CbML%5Cb%2Fg%2C%20%2F%5Cbmodels%3F%5Cb%2Fgi%2C%20%2Fneural%2Fgi%2C%20%2F%5CbOpenAI%5Cb%2Fgi%2C%20%2F%5Cbperplexity%5Cb%2Fgi%2C%20%2Fprompt%5Bs%5D%3F%5Cb%2Fgi%2C%20%2F%5CbRAG%5Cb%2Fg%2C%20%2F%5Cbstable%20diffusion%5Cb%2Fgi%2C%20%2F%5Cbtokens%3F%5Cb%2Fgi%2C%20%2F%5Cbtransformer%5Bs%5D%3F%5Cb%2Fgi%2C%20%2F%5Cbvector%20database%2Fgi%2C%20%5D%3B%20showNotification%20%3D%20true%3B%20urlPatterns%20%3D%20%5B%2Fnews%5C.ycombinator%5C.com%2Fi%5D%3B%20constructor(%7B%20removePatterns%2C%20showNotification%2C%20urlPatterns%20%7D%20%3D%20%7B%7D)%20%7B%20this.remove%20%3D%20removePatterns%20%3F%3F%20this.removePatterns%3B%20this.showNotification%20%3D%20showNotification%20%3F%3F%20this.showNotification%3B%20this.urlPatterns%20%3D%20urlPatterns%20%3F%3F%20this.urlPatterns%3B%20this.run()%3B%20%7D%20run%20%3D%20()%20%3D%3E%20%7B%20const%20%7B%20location%3A%20%7B%20href%20%7D%2C%20%7D%20%3D%20window%3B%20if%20(%20!this.urlPatterns.some((pattern)%20%3D%3E%20%7B%20return%20href.match(pattern)%3B%20%7D)%20)%20%7B%20return%3B%20%7D%20const%20submissions%20%3D%20Array.from(document.querySelectorAll(%22.submission%22))%3B%20for%20(const%20submission%20of%20submissions)%20%7B%20this._testSubmission(submission)%3B%20%7D%20this._notify()%3B%20%7D%3B%20_notify%20%3D%20()%20%3D%3E%20%7B%20if%20(!this.showNotification%20%7C%7C%20this._removedCount%20%3D%3D%3D%200)%20%7B%20return%3B%20%7D%20const%20notification%20%3D%20document.createElement(%22div%22)%3B%20notification.textContent%20%3D%20%60Filtered%20%24%7Bthis._removedCount%7D%20%24%7B%20this._removedCount%20%3D%3D%3D%201%20%3F%20%22submission%22%20%3A%20%22submissions%22%20%7D%60%3B%20const%20timeout%20%3D%202500%3B%20%2F*%20how%20long%20to%20show%20the%20notification%20*%2F%20const%20transitionLength%20%3D%20300%3B%20Object.assign(notification.style%2C%20%7B%20backgroundColor%3A%20%22%232c5282%22%2C%20borderRadius%3A%20%226px%22%2C%20bottom%3A%20%2220px%22%2C%20boxShadow%3A%20%220%204px%2012px%20rgba(0%2C%200%2C%200%2C%200.15)%22%2C%20color%3A%20%22%23ffffff%22%2C%20fontFamily%3A%20%22system-ui%2C%20-apple-system%2C%20sans-serif%22%2C%20fontSize%3A%20%2215px%22%2C%20fontWeight%3A%20%22500%22%2C%20left%3A%20%2250%25%22%2C%20opacity%3A%20%220%22%2C%20padding%3A%20%2212px%2024px%22%2C%20position%3A%20%22fixed%22%2C%20transform%3A%20%22translateX(-50%25)%22%2C%20transition%3A%20%60opacity%20%24%7BtransitionLength%7D%20ease-in-out%60%2C%20zIndex%3A%20%2210000%22%2C%20%7D)%3B%20document.body.appendChild(notification)%3B%20requestAnimationFrame(()%20%3D%3E%20%7B%20notification.style.opacity%20%3D%20%221%22%3B%20%7D)%3B%20setTimeout(()%20%3D%3E%20%7B%20notification.style.opacity%20%3D%20%220%22%3B%20%7D%2C%20timeout)%3B%20setTimeout(()%20%3D%3E%20%7B%20notification.remove()%3B%20%7D%2C%20timeout%20%2B%20transitionLength)%3B%20%7D%3B%20_removeSubmission%20%3D%20(submission)%20%3D%3E%20%7B%20const%20removeElements%20%3D%20%5B%20submission%2C%20submission.nextSibling%2C%20submission.nextSibling.nextSibling%2C%20%5D%3B%20for%20(const%20element%20of%20removeElements)%20%7B%20element.remove()%3B%20%7D%20this._removedCount%2B%2B%3B%20%7D%3B%20_testSubmission%20%3D%20(submission)%20%3D%3E%20%7B%20const%20title%20%3D%20submission.querySelector(%22.titleline%20%3E%20a%22)%3F.textContent%3B%20if%20(!title)%20%7B%20return%3B%20%7D%20if%20(%20!this.removePatterns.some((pattern)%20%3D%3E%20%7B%20return%20title.match(pattern)%3B%20%7D)%20)%20%7B%20return%3B%20%7D%20this._removeSubmission(submission)%3B%20%7D%3B%20%7D%20new%20HNBlocklist()%3B%7D)()%3B
    
  2. Paste the snippet into any bookmark’s URL field and save
  3. Click the bookmark any time you visit Hacker News