WWDC 19
What's New in Safari Extensions
Safari app extension can now be notified when something is blocked by the content blocker
SFSafariAssociatedContentBlockerslist inInfo.plistcontentBlocker(withIdentifier: blockedResourcesWithURLs: on page:)- notifications are batched, and you will only be notified about URLs listed in the access section in the plist
You can also get notified when the user navigates to a different page:
page(_: willNavigateTo url:)
Capturing a screenshot of the visible contents of a page:
page.getScreenshotOfVisibleArea { image in … }
Resources stored in the app extension bundle can be accessed by the browser and JS:
SFSafariExtension.getBaseURI { baseURI in
tab.navigate(to: baseURI.appendingPathComponent("index.html"))
}
Listing all browser windows and tabs:
SFSafariApplication.getAllWindows { window in
window.getAllTabs { … }
}
page.getContainingTab()
tab.getContainingWindow()
Programatically showing popovers:
window.getToolbarItem { item in item?.showPopover() }
Dismissing popover: SFSafariExtensionViewController.dismissPopover