open a new browser tab in background programmatica

2019-01-26 17:51发布

Problem

I'm using a web-based feed reader, TinyTinyRSS. When sifting through the feed lists, I'd like to open interesting articles in new tabs - but in the background, because I want to read them only after I went through all feed items.

TT-RSS has a shortcut key "o" to open the article in a new tab, but it opens the tab in the foreground (window.open).

The question is now: To fix TT-RSS, I need to know how to open a background tab from javascript. It'd be awesome if the solution worked across browsers (Firefox, Chrome, Opera, Safari).

I understand the privacy issue about that, but having it enabled for one certified webpage is ok.

Existing (bad) solutions

Firefox

In about:config, set browser.tabs.loadDivertedInBackground to true. This opens all the tabs from pages in the background, which is not what I want - I want it only for the one application/website.

Chrome

Chrome has a shytab extension. Works in chrome only and is for all pages.

2条回答
一夜七次
2楼-- · 2019-01-26 18:09

I added another "bad" solution with a TT-RSS plugin that works in Chrome and Opera, at least, but not Firefox:

It works by simulating a Ctrl-click on an "imaginary" link that is created when the hotkey is triggered.

It requires TT-RSS ≥1.7.6 (not yet released, but give it a day).

If someone knows how to get it/another JS solution work in Firefox: feel free to leave a comment.

查看更多
疯言疯语
3楼-- · 2019-01-26 18:33

Back when popup ads were a thing, this was called a "popunder" window. Popunders used to do something like this:

var popupWindow = window.open(...);
popupWindow.blur();
window.focus();

Popup blocking kind of messed around with what does and doesn't work, though- your mileage may vary.

查看更多
登录 后发表回答