MacKuba

🍎 Kuba Suder's blog on Mac & iOS development

WWDC 19

What's New in Safari Extensions

Categories: Extensions, Safari 0 comments Watch the video

Safari app extension can now be notified when something is blocked by the content blocker

  • SFSafariAssociatedContentBlockers list in Info.plist
  • contentBlocker(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



Leave a comment

*

*
This will only be used to display your Gravatar image.

*

What's the name of the base class of all AppKit and UIKit classes?

*