Created
February 2, 2014 07:44
-
-
Save zmwangx/8764383 to your computer and use it in GitHub Desktop.
AppleScript for saving URL to Safari reading list.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set theUrl to do shell script "pbpaste | grep -o -E \"\\b(https?|ftp|file)://[-A-z0-9+&@#/%?=~_|.;]*[A-z0-9+&@#/%=~_|]\" | head -1" | |
if theUrl = "" then | |
set html to do shell script "osascript -e '«class HTML» of (the clipboard as record)' | perl -ne 'print chr foreach unpack(\"C*\",pack(\"H*\",substr($_,11,-3)))'" | |
set theUrl to do shell script "echo " & quoted form of html & " | grep -o -E \"\\b(https?|ftp|file)://[-A-z0-9+&@#/%?=~_|.;]*[A-z0-9+&@#/%=~_|]\" | head -1" | |
end if | |
using terms from application "Safari" | |
tell application "Safari" | |
add reading list item theUrl as string | |
end tell | |
end using terms from | |
return theUrl |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment