I would like to automatically open download links in Safari that I remotely add to the Reading List. It is easy to add to the Reading List in iOS, and the changes are instantaneous on my computer.
My idea is to use a Folder Action Applescript to watch for new files added to /Library/Safari/ReadingListArchives/
New alphanumeric folders are added there containing "Page.webarchive" files and if possible "ReaderPage.webarchive"
My script is based of an existing Folder Action, "add - new item alert".
Please know that this is my first attempt to code; here it is:
on adding folder items to this_folder after receiving added_items
try
tell application "Finder"
--get the name of the folder
set the folder_name to the name of this_folder
end tell
tell application "Finder"
--go to the desktop
activate
--open the folder
open this_folder
--select the items
reveal the added_items
--select the items
tell application "System Events"
set item_list to POSIX path of file "Page.webarchive" of added_items
end tell
end tell
tell application "Safari" to open POSIX file item_list
end try
end adding folder items to
This code successfully opens the new alphanumeric folder containing the webarchive. Continuing, I have been trying to code a prompt for Safari to open the page. My understanding is to open the file, the POSIX path is needed. I tried to name that path and direct Safari to it. This probably makes quite evident I have no experience, so thanks to anyone who has advice.
I have also unfortunately noticed that direct download links don't show up here despite showing up in the Safari side panel, and I wonder where those exist. This code will probably also be useful to watch and open those links.
Is there a location to watch for Reading List additions which cannot be saved as a webarchive, like direct file links? And following my code, how can I command Safari to open the new file brought to focus by the Applescript?
Thanks so much, Kenny