News for hackers. Stuff that matters.

News.YC: open links in new tab

I know this is no great feat, but just wanted to post my bookmarklet, that I use to turn all the links on news.yc into `target="_blank"` links:

<a href="javascript:function%20getScript(url,%20success)%20{var%20d%20=%20document,script%20=%20d.createElement(%27script%27),head%20=%20d.getElementsByTagName(%27head%27)[0],done%20=%20false;script.src%20=%20url;script.onload%20=%20script.onreadystatechange%20=%20function(){if(%20!done%20&&%20(!this.readyState%20||%20this.readyState%20==%20%27loaded%27%20||%20this.readyState%20==%20%27complete%27)%20)%20{done%20=%20true;success();script.onload%20=%20script.onreadystatechange%20=%20null;head.removeChild(script);}};head.appendChild(script);}getScript(%22http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js%22,%20function()%20{if(%20typeof%20jQuery%20==%20%27undefined%27%20)%20{alert(%22jQuery%20could%20not%20be%20loaded%22);}$(%22td.title%20a%22).attr(%22target%22,%20%22_blank%22);});">YC - Open in new Tab</a>

( 6 comments | 9 points | on HN )
Re:News.YC: open links in new tab by mrduncan on Friday August 20, 2010 @07:51PM (#1621925)
Alternatively, nearly all browsers support middle clicking on links to open them in a new window.
Re:News.YC: open links in new tab by Timothee on Friday August 20, 2010 @08:24PM (#1621960)
Or, for laptops mostly, a combination of Ctrl, Shift, Alt + click will usually do the trick. (with the added benefit of choosing if you want to open it in the background or open it and see it right away, also true with middle-click)
Re:News.YC: open links in new tab by Ernestas on Friday August 20, 2010 @08:56PM (#1621991)
Or, Vimium, Shift + f
Re:News.YC: open links in new tab by erikpukinskis on Friday August 20, 2010 @09:31PM (#1622051)
Or, in Tekken 4, A + A + L1 + Right + Right + Start + Select
Re:News.YC: open links in new tab by swedegeek on Saturday August 21, 2010 @09:12AM (#1622764)
On my netbook, I have a multi-touch trackpad, so a 2-finger tap does the trick as well. Even with the "target=_blank" I'd probably still do a middle-click/2-finger tap to have the new tab open in the background. That way, I can quickly scan HN (or reddit or whatever else) and open up all the items I'm interested in and then read through them rapid fire.

Good exercise, though!

Re:News.YC: open links in new tab by ajbatac on Friday August 20, 2010 @09:43PM (#1622067)
+1 for the effort.