Skip to content

Instantly share code, notes, and snippets.

@nbar1
Created April 11, 2019 22:26
Show Gist options
  • Save nbar1/37b9f84f9b469ad4082f271330c5ba18 to your computer and use it in GitHub Desktop.
Save nbar1/37b9f84f9b469ad4082f271330c5ba18 to your computer and use it in GitHub Desktop.
Open HN story and comment links in a new tab
// ==UserScript==
// @name HackerNews New Tab
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Open story and comment links in a new tab
// @author Nick Barone
// @match https://news.ycombinator.com/*
// ==/UserScript==
(function() {
'use strict';
// Story links
document.querySelectorAll('.storylink').forEach(link => link.setAttribute('target', '_blank'));
// Comment links
document.querySelectorAll('.subtext > a:last-child').forEach(link => link.setAttribute('target', '_blank'));
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment