browser

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 29, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Brave   = "brave"
	Chrome  = "chrome"
	Firefox = "firefox"
	Safari  = "safari"
)

These constants represent an individual browser as a string value. The values themselves represents the accepted value for the `-b/--browser` flag for the command line tool.

Variables

View Source
var ErrUnsupportedOS = fmt.Errorf("unsupported operating system: %q", runtime.GOOS)

ErrUnsupportedOS is returned when the current operating system is not supported.

Functions

func Default

func Default() (string, error)

Default returns the name of the default browser. The returned string is one of the constants provided by this package (`Brave`, `Chrome`, `Firefox`, `Safari`).

This is determined based on the operating system. For MacOS, the launch services plist file is queried. For Linux, the `xdg-mime` command is used to query the default handler for the HTTP protocol.

Types

type Bookmark

type Bookmark struct {
	// Name is the name of a bookmark. This name is only the final element of
	// the path (the base name), not the entire path.
	// For example, Name would be "baz" and not "foo/bar/baz".
	Name string `json:"name"`

	// Path is the full path to a bookmark. In case of nested structure, where
	// there are folders within folders, this will correspond to the entire
	// path separated by a forward slash (/).
	Path string `json:"path"`

	// Url is the URL of a bookmark.
	Url string `json:"url"`
}

Bookmark contains information regarding an individual browser bookmark.

func GetBraveBookmarks

func GetBraveBookmarks() ([]Bookmark, error)

GetBraveBookmarks returns a list of all the bookmarks collected from the Brave browser.

func GetChromeBookmarks

func GetChromeBookmarks() ([]Bookmark, error)

GetChromeBookmarks returns a list of all the bookmarks collected from the Google Chrome browser.

func GetFirefoxBookmarks

func GetFirefoxBookmarks() ([]Bookmark, error)

GetFirefoxBookmarks returns a list of all the bookmarks collected from the Firefox browser. The bookmarks are collected for the default user profile.

func GetFirefoxProfileBookmarks

func GetFirefoxProfileBookmarks(profile string) ([]Bookmark, error)

GetFirefoxProfileBookmarks is similar to GetFirefoxBookmarks, but this returns the bookmarks for the given profile name.

func GetSafariBookmarks

func GetSafariBookmarks() ([]Bookmark, error)

GetSafariBookmarks returns a list of all the bookmarks collected from the Safari browser.

type ErrUnsupportedBrowser

type ErrUnsupportedBrowser struct {
	// Name is the browser name.
	Name string
}

ErrUnsupportedBrowser is returned when user provided browser or the default browser name is not supported.

func (*ErrUnsupportedBrowser) Error

func (e *ErrUnsupportedBrowser) Error() string

Jump to

Keyboard shortcuts

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