Documentation ¶
Overview ¶
Package safari provides access to Safari's windows, tabs, bookmarks etc. on the Mac.
Package-level functions call the corresponding methods on the default Parser, which reads the standard Safari bookmarks file with the default options.
The history subpackage provides access to Safari's history.
The safari command is a simple command-line program that implements some of the library's features.
Tested on Sierra and High Sierra.
Index ¶
- Constants
- Variables
- func Activate(win, tab int) error
- func ActivateTab(win, tab int) error
- func ActivateWin(win int) error
- func Close(win, tab int) error
- func CloseTab(win, tab int) error
- func CloseTabsLeft(win, tab int) error
- func CloseTabsOther(win, tab int) error
- func CloseTabsRight(win, tab int) error
- func CloseWin(win int) error
- func Configure(opts ...Option)
- type Bookmark
- type Folder
- type Item
- type Option
- type Parser
- func (p *Parser) BookmarkForUID(uid string) *Bookmark
- func (p *Parser) Configure(opts ...Option)
- func (p *Parser) FilterBookmarks(accept func(bm *Bookmark) bool) []*Bookmark
- func (p *Parser) FilterFolders(accept func(f *Folder) bool) []*Folder
- func (p *Parser) FindBookmark(accept func(bm *Bookmark) bool) *Bookmark
- func (p *Parser) FindFolder(accept func(f *Folder) bool) *Folder
- func (p *Parser) FolderForUID(uid string) *Folder
- func (p *Parser) Parse() error
- func (p *Parser) TypeForUID(uid string) string
- type Tab
- type Window
Constants ¶
const ( WebBookmarkTypeLeaf = "WebBookmarkTypeLeaf" WebBookmarkTypeList = "WebBookmarkTypeList" WebBookmarkTypeProxy = "WebBookmarkTypeProxy" )
Types of entries in Bookmarks.plist.
const ( NameBookmarksBar = "BookmarksBar" NameBookmarksMenu = "BookmarksMenu" NameReadingList = "com.apple.ReadingList" )
Names of special folders.
const ( TypeFolder = "folder" TypeBookmark = "bookmark" )
Types of objects with UIDs
Variables ¶
var ( DefaultBookmarksPath = filepath.Join(os.Getenv("HOME"), "Library/Safari/Bookmarks.plist") DefaultIgnoreBookmarklets = false )
Default options.
Functions ¶
func Activate ¶
Activate activates the specified Safari window (and tab). If tab is 0, the active tab will not be changed.
func Close ¶
Close closes the specified tab. If win is 0, the frontmost window is assumed. If tab is 0, current tab is assumed.
func CloseTab ¶
CloseTab closes the specified tab. If win is 0, frontmost window is assumed. If tab is 0, current tab is closed.
func CloseTabsLeft ¶
CloseTabsLeft closes tabs to the left of the specified one.
func CloseTabsOther ¶
CloseTabsOther closes all other tabs in win.
func CloseTabsRight ¶
CloseTabsRight closes tabs to the right of the specified one.
Types ¶
type Bookmark ¶
type Bookmark struct { URL string Ancestors []*Folder // Last element is this Bookmark's parent Preview string // contains filtered or unexported fields }
Bookmark is a Safari bookmark.
func BookmarkForUID ¶
BookmarkForUID returns Bookmark with specified UID or nil.
func BookmarksRL ¶
func BookmarksRL() []*Bookmark
BookmarksRL returns bookmarks for the user's Reading List.
func FilterBookmarks ¶
FilterBookmarks calls Bookmarks() and returns the elements for which accept(bm) returns true.
func FindBookmark ¶
FindBookmark returns the first Bookmark for which accept(bm) returns true. Returns nil if no match is found.
func (*Bookmark) InReadingList ¶
InReadingList returns true if Bookmark is from the Reading List.
func (*Bookmark) IsBookmarklet ¶
IsBookmarklet returns true if Bookmark is a bookmarklet.
type Folder ¶
type Folder struct { Ancestors []*Folder // Last element is this Folder's parent. May be empty. Bookmarks []*Bookmark // Bookmarks within this folder Folders []*Folder // Child folders // contains filtered or unexported fields }
Folder contains Bookmarks and other Folders.
func BookmarksMenu ¶
func BookmarksMenu() *Folder
BookmarksMenu returns user's Bookmarks Menu folder.
func FilterFolders ¶
FilterFolders returns all Folders for which accept(f) returns true.
func FindFolder ¶
FindFolder returns the first Folder for which accept(f) returns true. Returns nil if no match is found.
func FolderForUID ¶
FolderForUID returns Folder with UID uid or nil.
func (*Folder) IsBookmarksBar ¶
IsBookmarksBar returns true if this Folder is the users's BookmarksBar.
func (*Folder) IsBookmarksMenu ¶
IsBookmarksMenu returns true if this Folder is the users's BookmarksMenu.
func (*Folder) IsReadingList ¶
IsReadingList returns true if this Folder is the user's Reading List.
type Option ¶
type Option func(*Parser)
Option sets a Parser option.
func BookmarksPath ¶
BookmarksPath sets the path to the Safari bookmarks plist.
func IgnoreBookmarklets ¶
IgnoreBookmarklets tells parser whether to ignore bookmarklets.
type Parser ¶
type Parser struct { BookmarksPath string IgnoreBookmarklets bool // Whether to ignore bookmarklets Bookmarks []*Bookmark // Flat list of all bookmarks (excl. Reading List) BookmarksRL []*Bookmark // Flat list of all Reading List bookmarks Folders []*Folder // Flat list of all folders BookmarksBar *Folder // Folder for user's Bookmarks Bar BookmarksMenu *Folder // Folder for user's Bookmarks Menu ReadingList *Folder // Folder for user's Reading List // contains filtered or unexported fields }
Parser unmarshals a Bookmarks.plist file.
func (*Parser) BookmarkForUID ¶
BookmarkForUID returns Bookmark with given UID (or nil if no such bookmark is found).
func (*Parser) FilterBookmarks ¶
FilterBookmarks returns all Bookmarks for which accept(bm) returns true.
func (*Parser) FilterFolders ¶
FilterFolders returns all Folders for which accept(bm) returns true.
func (*Parser) FindBookmark ¶
FindBookmark returns the first Bookmark for which accept(bm) returns true.
func (*Parser) FindFolder ¶
FindFolder returns the first Folder for which accept(bm) returns true.
func (*Parser) FolderForUID ¶
FolderForUID returns Folder with given UID (or nil if no such folder is found).
func (*Parser) TypeForUID ¶
TypeForUID returns the type of item that UID refers to ("bookmark" or "folder").
type Tab ¶
Tab is a Safari tab.
Directories ¶
Path | Synopsis |
---|---|
Package cloud provides access to Safari's iCloud Tabs.
|
Package cloud provides access to Safari's iCloud Tabs. |
cmd
|
|
safari
Command safari lists Safari's bookmarks and reading list, and lists, activates and closes tabs.
|
Command safari lists Safari's bookmarks and reading list, and lists, activates and closes tabs. |
Package history provides access to Safari's history.
|
Package history provides access to Safari's history. |