Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
* develop:
  Trying to fix issues in Catalina
  more :retab for AppleScript
  :retab get-current-url.applescript
  Set username as env. variable.
  minor typo
  Add basic support for qutebrowser
  • Loading branch information
spamwax committed Mar 12, 2020
2 parents ce0055e + fbbe1d5 commit d432142
Show file tree
Hide file tree
Showing 9 changed files with 303 additions and 274 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]
### Changed
- Don't use 'sed' hack to pass username to URL on pinboard (which will be overwritten on new updates).

## [0.15.8] - 2019-08-29
### Changed
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ After initial [setup](#installation--setup):
- Opera
- Vivaldi
- Brave
- qutebrowser (See [known issues](#known_issues) )
- Firefox Dev. Edition
- Safari Tech. Preview
- Chrome
Expand Down
273 changes: 158 additions & 115 deletions res/workflow/get-current-url.applescript
Original file line number Diff line number Diff line change
@@ -1,162 +1,205 @@
on appIsRunning(appName)
tell application "System Events" to (name of processes) contains appName
set osver to system version of (system info)
considering numeric strings
set catalina to (osver >= "10.15" and osver < "10.16")
end considering
if catalina then
return true
end if
tell application "System Events" to (name of processes) contains appName
-- set processName to run script "tell application \"System Events\" to (name of processes)"
-- set ret to processName contains appName
-- return ret
end appIsRunning


on run
set theApplication to (name of (info for (path to frontmost application)))
set theText to ""
set theURL to ""

if theApplication is "Google Chrome.app" and appIsRunning("Google Chrome") then
set theResult to run script "tell application id \"com.google.chrome\"
set theApplication to (name of (info for (path to frontmost application)))
set theText to ""
set theURL to ""

if theApplication is "Google Chrome.app" and appIsRunning("Google Chrome") then
set theResult to run script "tell application id \"com.google.chrome\"
set theText to title of active tab of first window
set theURL to get URL of active tab of first window
return {theURL, theText}
end tell"
set theURL to item 1 of theResult
set theText to item 2 of theResult

else if theApplication is "Opera.app" and appIsRunning("Opera") then
set theResult to run script "tell application id \"com.operasoftware.Opera\"
set theText to title of active tab of first window
set theURL to get URL of active tab of first window
return {theURL, theText}
end tell"
set theURL to item 1 of theResult
set theText to item 2 of theResult

else if theApplication is "Opera Developer.app" and appIsRunning("Opera") then
set theResult to run script "tell application id \"com.operasoftware.OperaDeveloper\"
set theText to title of active tab of first window
set theURL to get URL of active tab of first window
return {theURL, theText}
end tell"
set theURL to item 1 of theResult
set theText to item 2 of theResult
else if theApplication is "Opera.app" and appIsRunning("Opera") then
set theResult to run script "tell application id \"com.operasoftware.Opera\"
set theURL to item 1 of theResult
set theText to item 2 of theResult

else if theApplication is "Opera Beta.pp" and appIsRunning("Opera") then
set theResult to run script "tell application id \"com.operasoftware.OperaNext\"
set theText to title of active tab of first window
set theURL to get URL of active tab of first window
return {theURL, theText}
end tell"
set theURL to item 1 of theResult
set theText to item 2 of theResult

else if theApplication is "Opera Developer.app" and appIsRunning("Opera") then
set theResult to run script "tell application id \"com.operasoftware.OperaDeveloper\"
set theText to title of active tab of first window
set theURL to get URL of active tab of first window
return {theURL, theText}
end tell"
set theURL to item 1 of theResult
set theText to item 2 of theResult

else if theApplication is "Opera Beta.pp" and appIsRunning("Opera") then
set theResult to run script "tell application id \"com.operasoftware.OperaNext\"
set theText to title of active tab of first window
set theURL to get URL of active tab of first window
return {theURL, theText}
end tell"
set theURL to item 1 of theResult
set theText to item 2 of theResult

else if theApplication is "Vivaldi.app" and appIsRunning("Vivaldi") then
set theResult to run script "tell application id \"com.vivaldi.Vivaldi\"
set theURL to item 1 of theResult
set theText to item 2 of theResult

else if theApplication is "Vivaldi.app" and appIsRunning("Vivaldi") then
set theResult to run script "tell application id \"com.vivaldi.Vivaldi\"
set theText to title of active tab of first window
set theURL to get URL of active tab of first window
return {theURL, theText}
end tell"
set theURL to item 1 of theResult
set theText to item 2 of theResult

else if theApplication is "Brave Browser.app" and appIsRunning("Brave Browser") then
set theResult to run script "tell application id \"com.brave.Browser\"
set theText to title of active tab of first window
set theURL to get URL of active tab of first window
return {theURL, theText}
end tell"
set theURL to item 1 of theResult
set theText to item 2 of theResult
else if theApplication is "Brave Browser.app" and appIsRunning("Brave Browser") then
set theResult to run script "tell application id \"com.brave.Browser\"
set theURL to item 1 of theResult
set theText to item 2 of theResult

else if theApplication is "Brave Browser Beta.app" and appIsRunning("Brave Browser Beta") then
set theResult to run script "tell application id \"com.brave.Browser.beta\"
set theText to title of active tab of first window
set theURL to get URL of active tab of first window
return {theURL, theText}
end tell"
set theURL to item 1 of theResult
set theText to item 2 of theResult

else if theApplication is "Brave Browser Beta.app" and appIsRunning("Brave Browser Beta") then
set theResult to run script "tell application id \"com.brave.Browser.beta\"
set theText to title of active tab of first window
set theURL to get URL of active tab of first window
return {theURL, theText}
end tell"
set theURL to item 1 of theResult
set theText to item 2 of theResult

else if theApplication is "Safari.app" and appIsRunning("Safari") then
set theResult to run script "tell application id \"com.apple.safari\"
set theURL to item 1 of theResult
set theText to item 2 of theResult

else if theApplication is "Safari.app" and appIsRunning("Safari") then
set theResult to run script "tell application id \"com.apple.safari\"
set theTab to front document
set theText to name of theTab
set theURL to URL of theTab
return {theURL, theText}
end tell"
set theURL to item 1 of theResult
set theText to item 2 of theResult
else if {"Safari Technology Preview.app", "SafariTechnologyPreview.app"} contains theApplication and appIsRunning("Safari Technology Preview") then
set theResult to run script "tell application id \"com.apple.SafariTechnologyPreview\"
set theURL to item 1 of theResult
set theText to item 2 of theResult

else if {"Safari Technology Preview.app", "SafariTechnologyPreview.app"} contains theApplication and appIsRunning("Safari Technology Preview") then
set theResult to run script "tell application id \"com.apple.SafariTechnologyPreview\"
set theTab to front document
set theText to name of theTab
set theURL to URL of theTab
return {theURL, theText}
end tell"
set theURL to item 1 of theResult
set theText to item 2 of theResult
else if theApplication is "Chromium.app" and appIsRunning("Chromium") then
set theResult to run script "tell application \"Chromium\"
set theURL to item 1 of theResult
set theText to item 2 of theResult

else if theApplication is "Chromium.app" and appIsRunning("Chromium") then
set theResult to run script "tell application \"Chromium\"
set theURL to URL of active tab of first window
set theText to title of active tab of first window
return {theURL, theText}
end tell"
set theURL to item 1 of theResult
set theText to item 2 of theResult
set theURL to item 1 of theResult
set theText to item 2 of theResult

else if theApplication is "Microsoft Edge.app" and appIsRunning("Microsoft Edge") then
set theResult to run script "tell application id \"com.microsoft.edgemac\"
else if theApplication is "Microsoft Edge.app" and appIsRunning("Microsoft Edge") then
set theResult to run script "tell application id \"com.microsoft.edgemac\"
set theText to title of active tab of first window
set theURL to get URL of active tab of first window
return {theURL, theText}
end tell"
set theURL to item 1 of theResult
set theText to item 2 of theResult

else if theApplication is "Firefox.app" and appIsRunning("Firefox") then
set theResult to run script "tell application id \"org.mozilla.firefox\"
activate
set w to item 1 of window 1
set theText to name of w
end tell
tell application \"System Events\"
set myApp to name of first application process whose frontmost is true
if myApp is \"Firefox\" then
set theURL to item 1 of theResult
set theText to item 2 of theResult

else if theApplication is "qutebrowser.app" and appIsRunning("qutebrowser") then
set theResult to run script "tell application id \"org.qt-project.Qt.QtWebEngineCore\"
activate
end tell
tell application \"System Events\"
set myApp to name of first application process whose frontmost is true
end tell
if myApp is \"qutebrowser\" then
tell application \"System Events\"
key code 53 -- ESC
delay 0.5
end tell
tell application \"System Events\" -- yank url
keystroke \"y\"
delay 0.4
keystroke \"y\"
end tell
delay 0.5
set theURL to (get the clipboard as Unicode text)
tell application \"System Events\" -- yank title
keystroke \"y\"
delay 0.4
keystroke \"t\"
end tell
delay 0.5
set theTitle to (the clipboard as Unicode text)
end if
do shell script \"pbcopy < /dev/null\"
return {theURL, theTitle}"
set theURL to item 1 of theResult
set theText to item 2 of theResult

else if theApplication is "Firefox.app" and appIsRunning("Firefox") then
set theResult to run script "tell application id \"org.mozilla.firefox\"
activate
set w to item 1 of window 1
set theText to name of w
end tell
tell application \"System Events\"
key code 97
set myApp to name of first application process whose frontmost is true
if myApp is \"Firefox\" then
tell application \"System Events\"
key code 97
delay 0.5
keystroke \"c\" using command down
end tell
delay 0.5
end if
delay 0.5
keystroke \"c\" using command down
end tell
delay 0.5
end if
delay 0.5
end tell
set theURL to get the clipboard
return {theURL, theText}"
set theURL to item 1 of theResult
set theText to item 2 of theResult

else if {"Firefox Developer Edition.app", "FirefoxDeveloperEdition.app"} contains theApplication and appIsRunning("Firefox") then
set theResult to run script "tell application id \"org.mozilla.firefoxdeveloperedition\"
activate
set w to item 1 of window 1
set theText to name of w
end tell
tell application \"System Events\"
set myApp to name of first application process whose frontmost is true
if myApp is \"Firefox\" then
set theURL to get the clipboard
return {theURL, theText}"
set theURL to item 1 of theResult
set theText to item 2 of theResult

else if {"Firefox Developer Edition.app", "FirefoxDeveloperEdition.app"} contains theApplication and appIsRunning("Firefox") then
set theResult to run script "tell application id \"org.mozilla.firefoxdeveloperedition\"
activate
set w to item 1 of window 1
set theText to name of w
end tell
tell application \"System Events\"
keystroke \"l\" using command down
set myApp to name of first application process whose frontmost is true
if myApp is \"Firefox\" then
tell application \"System Events\"
keystroke \"l\" using command down
delay 0.5
keystroke \"c\" using command down
end tell
delay 0.5
end if
delay 0.5
keystroke \"c\" using command down
end tell
delay 0.5
end if
delay 0.5
end tell
set theURL to get the clipboard
return {theURL, theText}"
set theURL to item 1 of theResult
set theText to item 2 of theResult

end if

return {theURL & " fd850fc2e63511e79f720023dfdf24ec " & theText}

set theURL to get the clipboard
return {theURL, theText}"
set theURL to item 1 of theResult
set theText to item 2 of theResult

end if

return {theURL & " fd850fc2e63511e79f720023dfdf24ec " & theText}

end run
Loading

0 comments on commit d432142

Please sign in to comment.