Skip to content

Instantly share code, notes, and snippets.

@paulirish
Created April 4, 2016 00:24
Show Gist options
  • Star 70 You must be signed in to star a gist
  • Fork 10 You must be signed in to fork a gist
  • Save paulirish/d7df1a5ff5d269b9884a9d22461af613 to your computer and use it in GitHub Desktop.
Save paulirish/d7df1a5ff5d269b9884a9d22461af613 to your computer and use it in GitHub Desktop.
open chrome tabs in safari
tell application "Google Chrome"
set tab_list to every tab in the front window
repeat with the_tab in tab_list
set the_url to the URL of the_tab
tell application "Safari" to open location the_url
end repeat
end tell
@Dudemullet
Copy link

@JCDC85 @zhanggang807 It might just be that Safari does not expose the same api as Chrome ? I don't really know how applescript works

@ldeck
Copy link

ldeck commented Dec 21, 2020

Here's a variant to only open the current tab in safari with an optional line to close the tab

tell application "Google Chrome"
	
	set current_tab to active tab in the front window
	set the_url to the URL of current_tab
	tell application "Safari" to open location the_url
	
	# Uncomment the next line to close tab after opening in Safari
	# tell current_tab to close
end tell

That's great @Dudemullet. Here's a slight improvement to activate safari.

tell application "Google Chrome"
	set current_tab to active tab in the front window
	set the_url to the URL of current_tab
end tell
	
tell application "Safari"
	open location the_url
	activate
end tell

@timbitzen
Copy link

Found this, then realized you can right-click the URL in Chrome and choose Services (see pic). There's Open option which by default (Ventura) opens in Safari. If it's not in your menu, you can enable it under Settings > Keyboard > Shortcuts > Services. Check the box for Open.

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