Keyboard shortcut to open windows in the background

Can we get a keyboard shortcut to open the story in a new window in the background? Like ‘o’ but, well, backgrounded? I’d suggest shift-o.

4 Likes

It already does try to open in the background. Here’s the relevant code:

window.open(story[‘story_permalink’], ‘_blank’);
window.focus();

What that means is that it is opening a new _blank window, then trying to focus back on NewsBlur, so effectively the window is in the background. The real answer is to change your browser settings so that new tabs open in the background. This is easy to do in Chrome, Safari, and Firefox. If you’re not on one of these, I’m not really sure how to best make this happen.

I have Firefox 7/8 set up on several different machines, with new windows set to open as tabs, and new tabs set to open in the background…

…and I can assure you that I am getting new tabs from NewsBlur opening in the foreground – both from the ‘o’ shortcut as well as when I click on links. I get switched to the new tab and watch as it loads.

Here is what I did to make Firefox open new tabs in the background:

http://lifehacker.com/263940/force-li…

“In order to force all links that open in a new window to load in a background tab, type about:config in the URL bar and change browser.tabs.loadDivertedInBackground to true.”

That’s it!! Thank you so much!

I decided I didn’t like having the “loadDivertedInBackground” functionality to be the default everywhere on the web… so I whipped up a little Greasemonkey script that accomplishes this functionality. It apparently can only be accomplished through Greasemonkey or the like; by default Firefox frowns on opening tabs/windows in the background and does its best to disable Javascript that seems to be trying to do that.

// ==UserScript==   
// @name NewsBlur BG Open   
// @namespace http://www.anent.org/newsblur/bgopen   
// @description Open links from Newsblur In Background   
// @include http://www.newsblur.com/\*   
// @include http://newsblur.com/\*   
// ==/UserScript==   
 
function linkKey(ev){   
if(/input|textarea/.test(ev.target.tagName.toLowerCase())) return;   
var k = String.fromCharCode(ev.keyCode ||ev.which);   
if(k == "O"){   
var link = document.querySelectorAll("div.story.selected a.story\_title");   
if (link.length \> 0) {   
GM\_openInTab(link[0].href);   
}   
}   
}   
 
document.addEventListener('keypress', linkKey, true);   

If you change the ‘k == “O”’ (which is a shift-o, not a number 0) line you can remap it to whatever key you want.

google reader would open links in background tabs, I wonder how they do it

By giving you a link instead of opening the link with JS. This is the one thing that really ticks me off about NewsBlur. None of the workarounds are satisfactory.

How about using code similar to this?
Source: http://stackoverflow.com/questions/10…

function openNewBackgroundTab(){
var a = document.createElement(“a”);
a.href = “http://www.google.com/”;
var evt = document.createEvent(“MouseEvents”);
//the tenth parameter of initMouseEvent sets ctrl key
evt.initMouseEvent(“click”, true, true, window, 0, 0, 0, 0, 0,
true, false, false, false, 0, null);
a.dispatchEvent(evt);
}

Just want to add a me-too to this thread. The ctrl-V open-in-background is my most used and missed feature from reader.

1 Like