Skip to content

Instantly share code, notes, and snippets.

@w3dg
Created October 26, 2025 13:14
Show Gist options
  • Select an option

  • Save w3dg/0520d38821133fb4781e5d8bf9b67e9f to your computer and use it in GitHub Desktop.

Select an option

Save w3dg/0520d38821133fb4781e5d8bf9b67e9f to your computer and use it in GitHub Desktop.
Open Links on new tab on HN and Lobste.rs
// ==UserScript==
// @name HackerNews Open Links In New Tab
// @namespace http://tampermonkey.net/
// @version 2025-10-26
// @description try to take over the world!
// @author Debopam Gupta <w3dg@duck.com>
// @match https://news.ycombinator.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=ycombinator.com
// @grant none
// ==/UserScript==
(function() {
'use strict';
const addBlankTarget = (l) => { l.target = "_blank" };
document.querySelectorAll("span.titleline a, .comment a").forEach(addBlankTarget);
})();
// ==UserScript==
// @name Lobste.rs Open in New Tab
// @namespace http://tampermonkey.net/
// @description Opens links to articles and the comment pages in a new tab
// @author Brekkjern
// @match https://www.tampermonkey.net/index.php?version=4.8.41&ext=dhdg&updated=true
// @grant none
// @include https://lobste.rs/*
// @version 0.0.1.20191112103250
// @downloadURL https://update.greasyfork.org/scripts/392307/Lobsters%20Open%20in%20New%20Tab.user.js
// @updateURL https://update.greasyfork.org/scripts/392307/Lobsters%20Open%20in%20New%20Tab.meta.js
// ==/UserScript==
(function() {
'use strict';
let links = document.querySelectorAll("a.u-url, span.comments_label > a");
links.forEach(function(element) {
element.target="_blank";
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment