Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function switchBrowser()
- local current = hs.application.frontmostApplication()
- local bool,URL
- if (current:name() == "Google Chrome") then
- bool,URL = hs.osascript.applescript('tell application "Google Chrome" to get URL of active tab of window 0')
- if bool then
- if (string.match(URL,'chrome://')) then
- hs.alert('not a valid link')
- else
- hs.execute('open -a Safari "' .. URL .. '"')
- end
- else
- hs.alert('error getting URL')
- end
- elseif (current:name() == "Safari") then
- bool,URL = hs.osascript.applescript('tell application "Safari" to get URL of document of window 0')
- if bool then
- if (string.match(URL,'favorites://')) then
- hs.alert('not a valid link')
- else
- hs.execute('open -a "Google Chrome" "' .. URL .. '"')
- end
- else
- hs.alert('error getting URL')
- end
- else
- hs.alert('no focused browser')
- end
- end
Add Comment
Please, Sign In to add comment