Last active
August 31, 2019 09:00
-
-
Save mikker/eb21cb9940d7d0d1c06c to your computer and use it in GitHub Desktop.
Open all links in Safari's Reading List in tabs.
This file contains hidden or 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
#!/usr/bin/env ruby | |
# $ gem install CFPropertyList | |
require 'cfpropertylist' | |
path = File.expand_path '~/Library/Safari/Bookmarks.plist' | |
plist = CFPropertyList::List.new file: path | |
list = plist.value.value["Children"].value.select do |item| | |
if title = item.value["Title"] | |
title.value == 'com.apple.ReadingList' | |
end | |
end.first.value["Children"].value | |
bookmarks = list.map do |item| | |
item.value["URLString"].value | |
end.reverse | |
puts "Opening #{bookmarks.count} tabs " | |
bookmarks.each do |url| | |
`osascript -e 'tell application "Safari" to tell window 1 to make new tab with properties {URL:"#{url}"}'` | |
print '.' | |
end | |
puts '' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you for writing this up!

I tried to execute the code like this:
Unfortunately I get following error:

Anything I'm doing wrong or is the script broken?
Best regards