Hi everyone. Can anyone out there help me create a Shortcut or some other functionality that will take all open Safari Tabs and save them in Instapaper?
I mostly have a lot of tabs open in Safari on MacOS so I don’t know how a Siri Shortcut would help there. But maybe someone knows of another way to save all open tabs in Instapaper?
I don’t think you can loop through open Safari tabs on iOS, because of sandboxing. But for the Mac here’s a simple AppleScript to save everything to Instapaper. Instapaper has a fairly simple API, so just a cURL request with the URL, username and password should be enough. (You can get more fancy of course, might be a fun exercise.)
-- might be just your email address
set instapaper_username to ""
-- only if you have one, not all Instapaper accounts have passwords
set instapaper_password to ""
tell application "Safari"
activate
set safari_windows to the front window
repeat with one_window in safari_windows
repeat with one_tab in (tabs of one_window)
set instapaper_save_url to quoted form of ("https://www.instapaper.com/api/add?url=" & (URL of one_tab) & "&username=" & instapaper_username & "&password=" & instapaper_password)
do shell script "curl " & instapaper_save_url
end repeat
end repeat
end tell
You can run this AppleScript from all sorts of places by the way. I often run an AppleScript to save the open Chrome tabs of the current window to a Markdown file, via Alfred.
If you open Alfred and press cmd (⌘) + , you can go to “Workflows” and add a new workflow using the Plus button.
Add a “Run Applescript” action by right-clicking in empty space. Paste the code between the two existing lines. (Full code at the end of my post here)
Choose an input, like a keyword, that you want to use to trigger the script. In this case no argument would be required, but in some cases you do want to give input. (For example: when I use it with my “Save Chrome tabs to file” I have an optional argument for the filename.)
This is one reason why I would recommend this method over @lbutlr suggestion to save it as an application, although he is correct and that would be a quick way to do it.
Now just start Alfred, type your keyword, and watch the magic.
I’ve put the complete action on one of my websites, so you can just import that and use it with the keyword “safpaper”. But I would highly recommend actually following the steps yourself and creating it, because you’ll learn some new things!
And the full script to copy/paste for the more manual route (it’s just the previous script between the on alfred_script lines)
on alfred_script(q)
-- might be just your email address
set instapaper_username to ""
-- only if you have one, not all Instapaper accounts have passwords
set instapaper_password to ""
tell application "Safari"
activate
set safari_windows to the front window
repeat with one_window in safari_windows
repeat with one_tab in (tabs of one_window)
set instapaper_save_url to quoted form of ("https://www.instapaper.com/api/add?url=" & (URL of one_tab) & "&username=" & instapaper_username & "&password=" & instapaper_password)
do shell script "curl " & instapaper_save_url
end repeat
end repeat
end tell
end alfred_script