Re:Ask YC: Would it make sense to build a social news site ...
by joshwa on Monday March 03, 2008 @03:41PM
(#128307)
// ==UserScript==
// @name news.yc open in new tab
// @namespace http://joshwand.com/
// @description opens links on news.yc's list pages in new tabs/windows
// @include http://news.ycombinator.com/
// @include http://news.ycombinator.com/news
// @include http://news.ycombinator.com/newest
// @include http://news.ycombinator.com/x?*
// ==/UserScript==
var a, links, thisdomain;
thisdomain = window.location.host;
links = document.getElementsByTagName('a');
for (var i = 0; i < links.length; i++) {
a = links[i];
if (a.host && (a.host != thisdomain || String(a).match(/item\?id=/))) {
a.target = "_blank";
}
}
Re:Ask YC: Would it make sense to build a social news site ...
by some on Monday March 03, 2008 @05:14PM
(#128364)
I would prefer the loop this way:
for each(a in links)
if (a.host && (a.host!=thisdomain || String(a).match(/item\?id=/)))
a.target = "_blank";
Re:Ask YC: Would it make sense to build a social news site ...
by joshwa on Tuesday March 04, 2008 @12:41AM
(#128643)
What can I say, I don't actually know JS. I just cargo-culted this from another similar script.
Re:Ask YC: Would it make sense to build a social news site ...
by bkrausz on Tuesday March 04, 2008 @12:27AM
(#128633)
Given the nature of browsers that would be counterproductive: one can easily setup browsers to open new tabs with the middle mouse button, but there's no way to stop new tabs/windows from being opened as such.
Re:Ask YC: Would it make sense to build a social news site ...
by iamwil on Monday March 03, 2008 @03:25PM
(#128293)
Given the way I surf hacker news, I'd get annoyed with that. I only open up new tabs when it takes a long time to load.
Re:Ask YC: Would it make sense to build a social news site ...
by kingnothing on Monday March 03, 2008 @07:06PM
(#128440)
You could just use your middle mouse button to click the links; that will open them in a new tab.
Feature request: Could the links to outside sites open in new tabs/windows by default, so that we don't navigate away from HN when we actually use this site?