Forked from sillygwailo/Open in Chrome from Safari.scpt
Created
September 24, 2015 18:37
-
-
Save kevinold/729998cb3faaacabb99d to your computer and use it in GitHub Desktop.
Open in Chrome from Safari and vice versa
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- from http://www.tuaw.com/2011/03/14/use-applescript-to-open-current-safari-url-in-google-chrome/ | |
-- install FastScripts http://www.red-sweater.com/fastscripts/ and place this AppleScript in the Scripts applications folder for Google Chrome. | |
-- For me that was ~/Library/Scripts/Applications/Safari | |
-- You can then assign it a keyboard shortcut. I went with Cmd-Shift-C | |
property theURL : "" | |
tell application "Safari" | |
set theURL to URL of current tab of window 1 | |
end tell | |
tell application "Google Chrome" | |
if (count of (every window where visible is true)) is greater than 0 then | |
tell front window | |
make new tab | |
end tell | |
else | |
make new window | |
end if | |
set URL of active tab of window 1 to theURL | |
activate | |
end tell |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- from the comments of http://www.tuaw.com/2011/03/14/use-applescript-to-open-current-safari-url-in-google-chrome/ | |
-- install FastScripts http://www.red-sweater.com/fastscripts/ and place this AppleScript in the Scripts applications folder for Google Chrome. | |
-- For me that was ~/Library/Scripts/Applications/Google Chrome | |
-- You can then assign it a keyboard shortcut. I went with Cmd-Shift-S | |
set theURL to missing value | |
tell application "Google Chrome" | |
if (exists window 1) then | |
if (URL of active tab of window 1 does not start with "chrome://") then | |
set theURL to URL of active tab of window 1 | |
end if | |
end if | |
end tell | |
if theURL is not equal to missing value then | |
-- https://discussions.apple.com/thread/2770617?start=15&tstart=0 | |
tell application "Safari" | |
activate | |
try | |
tell window 1 to set current tab to make new tab | |
set URL of document 1 to theURL | |
on error | |
open location theURL | |
end try | |
end tell | |
end if |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment