public
Last active

TextExpander Snippet (using AppleScript) to open the currently visible page in Safari in Chrome

  • Download Gist
gistfile1.applescript
AppleScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
property theURL : ""
tell application "Safari"
set theURL to URL of current tab of window 1
end tell
if appIsRunning("Google Chrome") then
tell application "Google Chrome"
make new window
set URL of active tab of window 0 to theURL
activate
end tell
else
tell application "Google Chrome"
do shell script "open -a \"Google Chrome\""
set URL of active tab of window 0 to theURL
activate
end tell
end if
 
on appIsRunning(appName)
tell application "System Events" to (name of processes) contains appName
end appIsRunning

This is an awesome snippet! Now here is your dumb question. Where exactly do you expand this snippet in order to activate it?

It doesn't actually expand any text. You just type your abbreviation while you're browsing (no need to have an active text field or anything), and the AppleScript in the snippet executes. No text is inserted upon completion.

slightly tweaked to open in new tab rather than new window
and added comment to use it as a launchbar action
https://gist.github.com/3153606

Great addition, prenagha!

If anyone is looking for a way to do exactly the opposite (open currently active Chrome tab with Safari), here's an adapted version of the script to do that: https://gist.github.com/4401082

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.