bookmarks

package module
v0.0.0-...-9028db7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 26, 2023 License: MIT Imports: 6 Imported by: 0

README

Safari Bookmarks plist reader

Reads Safari's Bookmarks.plist. This includes bookmarks as well as the reading list.

What, why, ...?

I wanted to be able to add stuff to the Safari reading list on iOS, then keep track of it somewhere outside iCloud, by relying on the sync to macOS, then reading it there.

Set-up

Recent macOS versions won't let you read from ~/Library/Safari (a good thing for security), you'll see this:

$ cp Library/Safari/Bookmarks.plist /tmp 
cp: Library/Safari/Bookmarks.plist: Operation not permitted

Fix it by adding the application (i.e. macOS level application, so maybe your terminal app) to "Full Disk Access" in System Preferences > Security & Privacy, like this:

iTerm added to Full Disk Access

(Yes, doing this means something running in your terminal can steal your cookies now. Be careful with your curl ... | sh commands again.)

Development notes

Use plutil -convert xml1 for a quick way to get a readable file (see also ply in go-plist).

No tests, will probably break when Apple change the format of the bookmarks file anyway.

Documentation

Index

Constants

View Source
const BookmarksPlist = "Library/Safari/Bookmarks.plist"

Variables

This section is empty.

Functions

func RequestFullDiskAccess

func RequestFullDiskAccess() error

RequestFullDiskAccess opens Settings to the Full Disk Access pane. Generally you should present something to your user suggesting how they should proceed before doing this.

Types

type Bookmark

type Bookmark struct {
	Children        []Bookmark
	WebBookmarkType string
	Title           string
	URLString       string
	// Mostly has 'title' in it...
	URIDictionary map[string]interface{}
	ReadingList   *ReadingList
}

func (Bookmark) ReadingItems

func (b Bookmark) ReadingItems() (result []Bookmark)

ReadingItems searches the tree for reading list items and returns them in a list.

func (Bookmark) String

func (b Bookmark) String() string

type Bookmarks

type Bookmarks struct {
	Bookmark
}

Bookmarks is the top level of the tree. It also is a `Bookmark`.

func Read

func Read() (*Bookmarks, error)

Read the default bookmarks plist

func Readfile

func Readfile(filename string) (*Bookmarks, error)

Readfile reads the given bookmarks plist

type ReadingList

type ReadingList struct {
	DateAdded      time.Time
	DateLastViewed time.Time
	PreviewText    string
}

Directories

Path Synopsis
cmd
safari-dump
Makes something a bit like taskpaper output for your bookmarks...
Makes something a bit like taskpaper output for your bookmarks...

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL