A similar question was asked here but without a satisfying answer.
I'm trying to do change 2 chrome settings with the extension.
- Cause the browser to open new links as tabs and not windows.
- Cause the browser to accept pop ups from a specific URL
I have looked in the documentation, but cannot find the answer.
Could anyone help me with this one?
There's no setting to open links as tabs instead of windows. You can change the popup preference through the chrome.contentSettings
API.
All of the requested features can also be enabled indirectly. Some ideas:
- New window instead of tabs.
- Detect creation of tabs through
chrome.tabs.onCreated
.
- Detect whether the window was opened from inside another window:
Use the tab.id
property from the previous event listener to get the window
object, using chrome.extension.getViews
. Then, check the window.opener
property to determine whether the link was opened from another tab.
This might not work when the link has the rel="noreferrer"
attribute set.
Create a new window using chrome.windows.create
, passing the tabId
. The tab will be detached from its previous window, and attached to the new window.
- You can rewrite the
window.open
method, which invokes chrome.tabs.create
and chrome.windows.create
to create a new popup window.
A global rewrite can be done by detecting page loads using chrome.tabs.onUpdated
, with status=="complete"
, then use chrome.extension.getViews
to change the window.open
method. Make sure that you create a cached version of the window
onject, so that the original method is still available when necessary.
These are the necessary information + documentation links which help you to create the desired functionaily. Good luck ;)