Skip to content

Instantly share code, notes, and snippets.

@mikker
Created May 13, 2020 20:59
Show Gist options
  • Save mikker/9304b2c2f14e500c4cc9063e6d8bc9af to your computer and use it in GitHub Desktop.
Save mikker/9304b2c2f14e500c4cc9063e6d8bc9af to your computer and use it in GitHub Desktop.

Revisions

  1. mikker created this gist May 13, 2020.
    5 changes: 5 additions & 0 deletions 00 README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    # Open Reading List in tabs

    1. Make a new Automator document of type "App"
    1. Add these three steps in order
    1. Remember to replace `mikker` with your own username in the AppleScript scripts
    5 changes: 5 additions & 0 deletions 01 Run Applescript.applescript
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    -- Copy the file to $HOME because of some permissions issue

    tell application "Finder"
    copy file "Macintosh HD:Users:mikker:Library:Safari:Bookmarks.plist" to folder "Macintosh HD:Users:mikker"
    end tell
    25 changes: 25 additions & 0 deletions 02 Run Shell Script
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@
    #!/usr/bin/env ruby

    # Note! Set Shell to "/usr/bin/ruby" and install a gem:
    # $ gem install CFPropertyList

    require 'cfpropertylist'
    require 'fileutils'

    path = File.expand_path '~/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|
    `open "#{url}"`
    end
    5 changes: 5 additions & 0 deletions 03 Run Applescript.applescript
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    -- Cleanup

    tell application "Finder"
    move file "Macintosh HD:Users:mikker:Bookmarks.plist" to trash
    end tell