当我遵循 Apple 示例时,我总是得到nil
activeTab
:
override func toolbarItemClicked(in window: SFSafariWindow) {
// This method will be called when your toolbar item is clicked.
window.getActiveTab(completionHandler: { (activeTab) in
print(activeTab)
activeTab?.getActivePage(completionHandler: { (activePage) in
print(activePage)
activePage?.getPropertiesWithCompletionHandler( { (properties) in
print(properties)
if properties?.url != nil {
let urlString = properties!.url.absoluteString
print("URL!", urlString)
let videoURL = self.youtubeDl(urlString: urlString)
if videoURL != nil {
window.openTab(with: videoURL!, makeActiveIfPossible: true, completionHandler: nil)
}
}
})
})
})
}