4

I'm now converting my chrome extension to safari extension.

My chrome extension uses the API to open a new private window like this.

chrome.windows.create({"url": url, "incognito": true});

Does anyone know the way to implement this functionality in safari extension?

I tried looking it up, but I could only find the way to open a normal window as below. safari.application.openBrowserWindow();

sutaka
  • 41
  • 2
  • I have no experience with Safari but according to [the docs](https://developer.apple.com/reference/safariextensions/safaribrowsertab) you can set tab's `private` flag to `true`, so I guess you'll need to either alter the active tab if it exists upon window creation or add a new tab with the flag set. – wOxxOm Oct 08 '16 at 15:27
  • Thank you for giving advice, but the docs says tab's `private` is a read only attribute. So I can't change the value intensionally. – sutaka Oct 08 '16 at 19:27

1 Answers1

3

As of Safari 10.0 and macOS 10.12, there is no public API to accomplish this.

For Safari Extensions written in Javascript, the private attribute of SafariBrowserTab is read-only.

For Safari App Extensions (new in Safari 10), the usesPrivateBrowsing property of SFSafariPageProperties is also read-only.

Either of the above can only be used to query the private browsing state of a tab.

And the respective open window and open tab methods (for Safari Extensions JS and Safari App Extensions) do not currently provide any ability to configure private browsing mode either.

breakingobstacles
  • 2,815
  • 27
  • 24