JSDev93
JSDev93

Reputation: 61

Open up two tabs in a new chrome incognito window

I am looking to open up a new incognito window in chrome with two tabs. I have:

chrome.tabs.query({
                      'active': true,
                      'windowId': chrome.windows.WINDOW_ID_CURRENT
                  },
                  function(tabs) {
                      var url = tabs[0].url;
                      chrome.windows.create({"url": url,
                                             "incognito": true});
                  }
);

But I am not sure on how to add a chrome.tabs to open google.com in a new tab in the same incognito tab.

Is that possible?

Also, I cannot gain focus on an incognito window. I can gain the focus when I leave off 'incgonito': true but not when I add it like so:

chrome.tabs.query({
                  'active': true,
                  'windowId': chrome.windows.WINDOW_ID_CURRENT
                  },
                  function(tabs) {
                      var url = tabs[0].url;
                      var urlIntent = "http://google.com";
                      chrome.windows.create({
                                             "url": url,
                                             focused: true,
                                             "incognito": true
                                             },
                                             function(window){
                                                chrome.windows.update(
                                                        window.id, 
                                                        {focused: true})
                                             });
                  }
);

Upvotes: 5

Views: 1552

Answers (1)

JSDev93
JSDev93

Reputation: 61

In manifest.json you need to add:

      "incognito":"split",

As shown here https://developer.chrome.com/extensions/manifest/incognito

Upvotes: 1

Related Questions