I don’t understand why only some apps are compatible with Hook’s built in “Copy Link and Selection” but I decided to build the functionality myself for web browsers.
tell application "System Events" to set the clipboard to ""
tell application "System Events"
keystroke "c" using command down
delay 0.2
set theQuote to the clipboard as Unicode text
end tell
tell application "System Events" to set FrontAppName to name of first process where frontmost is true
if FrontAppName is "Microsoft Edge" then
tell application "Microsoft Edge"
set theName to title of active tab of front window
set theURL to URL of active tab of front window
end tell
else if FrontAppName is "Safari" then
tell application "Safari"
set theURL to URL of front document
set theName to name of front document
end tell
end if
if theQuote is "" then
set the clipboard to "[" & theName & "](" & theURL & ")"
else
set the clipboard to ">" & theQuote & "\n[" & theName & "](" & theURL & ")"
end if
display notification with title FrontAppName subtitle "Copied to clipboard"
Tweaked from this article to match Hook’s “Copy Link and Selection” style which also means that you can call up hook and paste the hook to a document. Hopefully, the Hook devs will add this functionality soon since this script is brittle (only works for the apps in the script). Also keep up the good work Hook devs!
It’s because our approach does not rely on the clipboard, but API’s if they are available; they aren’t always available. We also wanted to see what kind of traction we would get with this feature.
However, we have a goal of sharing a more general facility.
I need / want such capability. How do I use your script? I was surprised and disappointed to find that i can’t clip a selection from Safari or Chrome with a Hook link.
If you use Safari, you can use Hook share extension to get the selection and link:
(1)Select some text in Safari
(2)Click on Share button
(3)Select Hook
(4)Select “Copy Selection and link” action
(5)Click on “OK”