Skip to content

Instantly share code, notes, and snippets.

@blood72
Last active September 25, 2022 16:20
Show Gist options
  • Save blood72/02fa3317a8c9198f93cff983b39bd325 to your computer and use it in GitHub Desktop.
Save blood72/02fa3317a8c9198f93cff983b39bd325 to your computer and use it in GitHub Desktop.
Open Vivaldi Browser on private mode for Choosy (applescript)
on open location this_URL
set _NOT_ACTIVATED to 0
if application "Vivaldi" is running then
# open previous browser
tell application "Vivaldi"
set totalWindows to count of window
set currentWindow to 1
set selectedWindow to _NOT_ACTIVATED
# find specified mode
repeat totalWindows times
if (mode of window currentWindow) as text = "incognito" then
set selectedWindow to currentWindow
end if
set currentWindow to currentWindow + 1
end repeat
if selectedWindow is not _NOT_ACTIVATED then
# open to previous window
tell window selectedWindow
make new tab with properties {URL:this_URL}
end tell
else
# open to new window
make tab with properties {URL:this_URL} at (make window with properties {mode:"incognito"})
close tab 1 of front window # close empty tab
end if
end tell
else
# open new browser
do shell script "open -a /Applications/Vivaldi.app --args --incognito " & this_URL
end if
# browser focus
tell application "Vivaldi"
activate
end tell
end open location
on open location this_URL
set _NOT_ACTIVATED to 0
if application "Vivaldi" is running then
# open previous browser
tell application "Vivaldi"
set totalWindows to count of window
set currentWindow to 1
set selectedWindow to _NOT_ACTIVATED
# find specified mode
repeat totalWindows times
if (mode of window currentWindow) as text ≠ "incognito" then
set selectedWindow to currentWindow
end if
set currentWindow to currentWindow + 1
end repeat
if selectedWindow is not _NOT_ACTIVATED then
# open to previous window
tell window selectedWindow
make new tab with properties {URL:this_URL}
end tell
else
# open to new window
make tab with properties {URL:this_URL} at (make window)
close tab 1 of front window # close empty tab
end if
end tell
else
# open new browser
do shell script "open -a /Applications/Vivaldi.app --args " & this_URL
end if
# browser focus
tell application "Vivaldi"
activate
end tell
end open location
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment