Skip to content

Instantly share code, notes, and snippets.

@ryenus
Last active August 29, 2015 14:26
Show Gist options
  • Save ryenus/379fd68da7308b9efe05 to your computer and use it in GitHub Desktop.
Save ryenus/379fd68da7308b9efe05 to your computer and use it in GitHub Desktop.
HN Mod
// ==UserScript==
// @name HN Mod
// @namespace http://gitub.com/ryenus
// @version 0.1
// @description A nonintrusive Hacker News mod
// @author ryenus
// @match https://news.ycombinator.com/*
// @grant none
// ==/UserScript==
(function() {
var filters = [
'a',
'not([onclick])',
'not([target])',
'not([class*=pocket])',
'not([href^="news"])',
'not([href^="#"])',
'not([href^=mailto])',
'not([href^=logout])'
],
links = document.querySelectorAll(filters.join(':'));
for (var i=0; i<links.length; i++) {
links[i].setAttribute('target', '_blank');
}
})();
@ryenus
Copy link
Author

ryenus commented Jul 31, 2015

This script makes most HN links open in new tabs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment