Skip to content

How to get favicon image in SafariScripting in safari.swift file #21

Open

Description

@waquarahmad

is there a way to get the favicon image of current tab in safari browsers

Activity

  1. jis247 commented on Oct 1, 2020

    @jis247

    I have used this to get current tab name and url but how to get current tab FavIcon image.

    let safariApplication = SBApplication(bundleIdentifier: "com.apple.Safari")! as SafariApplication
            self.windows = safariApplication.windows!().reduce([String: SafariWindow](), { (dictionary, object) -> [String: SafariWindow] in
                let window = object as! SafariWindow
                let tabName = window.name
                let safariTab = window.tabs?().object(withName: "\(tabName ?? "")")
                let url = (safariTab as AnyObject).URL
                
                urlValue = url ?? ""
                tabName1 = tabName ?? ""
                print(url ?? "")
                print(tabName ?? "")
                var dictionary = dictionary
                dictionary[window.name!] = window
    
                return dictionary
            })
    
  2. tingraldi commented on May 20, 2021

    @tingraldi
    Owner

    There is no way to directly query for the favicon using the Safari scripting interface. You could conceivably retrieve the document from the Safari window and parse the link tags to find the url for the favicon. You could also use a service such as https://favicons.githubusercontent.com to retrieve the favicon for the domain associated with a given tab.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions