Skip to content

Instantly share code, notes, and snippets.

@seanlilmateus
Created July 27, 2012 23:18
Show Gist options
  • Save seanlilmateus/3190992 to your computer and use it in GitHub Desktop.
Save seanlilmateus/3190992 to your computer and use it in GitHub Desktop.
Safari tabs with macruby
framework "ScriptingBridge"
safari=SBApplication.applicationWithBundleIdentifier("com.apple.Safari")
new_window = SafariDocument.alloc.init # create a new window
safari.windows << new_window # make the window visible
safari.windows.first.currentTab.URL = "https://mail.google.com"
sites = ["https://twitter.com", "http://news.ycombinator.com"].map do |site|
new_tab = SafariTab.alloc.initWithProperties({"URL" => site}) # create a new tab
safari.windows.first.tabs << new_tab # add the tab to the window
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment