[Safari] How can I quickly open the current page in Chrome?

Discussion in 'Mac Apps and Mac App Store' started by iRock1, Feb 16, 2014.

  1. iRock1 macrumors 6502a

    iRock1

    Joined:
    Apr 23, 2011
    #1
    Right now I have to go through Develop > Open Page With > Google Chrome. What I need though is to do the same using a keyboard shortcut.

    One option would be assigning a keyboard shortcut to that menu in the Keyboard Preferences Pane. However, the menu includes the app version, so I'd need to modify the keyboard shortcut every time Google Chrome updates.

    Maybe I could use the AppleScript Editor or Automator to create a new service and then use FastScripts? If so, what should I write? Because my knowledge of scripting is almost zero. :p
     
  2. Weaselboy Moderator

    Weaselboy

    Staff Member

    Joined:
    Jan 23, 2005
    Location:
    California
    #2
    This Applescript will open the front Safari window in a new Chrome tab.

    I launch it from Alfred as a "workflow", but Fastscript should do the trick also.

    Code:
    if application "Safari" is running then
    	tell application "Safari"
    		try
    			set currentSafariURL to URL of current tab of front window
    			set pageName to name of current tab of front window
    		on error
    			return "There are no pages open in Safari at the moment"
    		end try
    	end tell
    	
    	tell application "Google Chrome"
    		activate
    		
    		# If Chrome has no windows open make a new window
    		if (count of windows) is 0 then make new window
    		set currentChromeURL to URL of active tab of front window
    		
    		# Don't do anything if the page is already open in Chrome
    		if currentChromeURL is not currentSafariURL then
    			
    			# If the active tab is in use make a new tab
    			if currentChromeURL is not "chrome://newtab/" then
    				make new tab at end of tabs of front window
    			end if
    			
    			# Open the URL from Safari
    			set URL of active tab of front window to currentSafariURL
    			
    		else
    			return "The current Safari tab is already open in Chrome"
    		end if
    	end tell
    	
    	# Enable the following line to post notifications after sending URLs to Chrome
    	--return "Opening '" & pageName & "' in Chrome"
    else
    	return "Safari is not open at the moment"
    end if
    Credit to the author of the Alfred workflow here.
     
  3. iRock1 thread starter macrumors 6502a

    iRock1

    Joined:
    Apr 23, 2011
    #3
    It works wonderfully. I just saved it as a script, then assigned it a keyboard shortcut with FastScripts and voilâ!

    Thanks.
     

Share This Page