crb

package module
v0.0.0-...-b6c3f2b Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2024 License: MIT Imports: 14 Imported by: 0

README

crb

PkgGoDev

Library and tools for parsing and exporting Chrome bookmarks.

Written against Chromium main@{2022-08-28} (Chrome 106). Should work at least as far back as 2014 (Chrome 40).

Usage: crb [options] bookmarks_file

Options:
  -E, --export stringArray   export bookmarks HTML to the specified file (- for stdout)
  -h, --help                 show this help text
  -q, --quiet                don't write info about the bookmarks file to stderr
  -t, --tree                 write the bookmarks tree to stdout (use --verbose to show dates)
  -v, --verbose              show additional information
Usage: crb-carve [options] file[:[start_offset][:[end_offset]|+length]]...

Options:
  -h, --help                   show this help text
  -j, --json                   show information about the recovered files as JSON
  -o, --output string          write the recovered files to the specified directory
  -O, --output-format string   output file format (default "bookmarks.{input.basename}-{match.offset}.{bookmarks.checksum}.json")
  -q, --quiet                  don't show information about the recovered files

Output Fields (--output-format, --json):
  input.path                 input file path
  input.basename             input file basename
  match.offset               match offset
  match.length               match length
  bookmarks.barguid          chrome bookmarks bar folder guid
  bookmarks.checksum         chrome bookmarks checksum
  bookmarks.date.unix        most recent date (unix timestamp)
  bookmarks.date.unixmicro   most recent date (unix microscond timestamp)
  bookmarks.date.yyyymmdd    most recent data (yyyymmdd)
  bookmarks.count.folders    number of folders
  bookmarks.count.urls       number of bookmarks
  output                     output file basename (not for --output-format)

Documentation

Overview

Package crb manipulates Chrome bookmarks.

Written against Chromium aabc28688acc0ba19b42ac3795febddc11a43ede (Chrome 106, 2022-08-22). Should work at least as far back as 2014 (Chrome 40).

See:

Index

Constants

This section is empty.

Variables

View Source
var ErrBreak = errors.New("break")

Functions

func Carve

func Carve(f io.ReaderAt, fn CarveMatchFunc) error

Carve attempts to recover valid Chrome bookmarks from r, which could be a disk image or something similar. It stops if ErrBreak or another error is returned.

func Encode

func Encode(w io.Writer, b *Bookmarks) error

Encode re-encodes a Chrome bookmarks file. It should be more or less the same as Chrome itself, but the formatting is slightly different.

func Export

func Export(w io.Writer, b *Bookmarks, f FaviconFunc) error

Export writes a HTML bookmark export of b to w, getting favicons from f.

Types

type BookmarkNode

type BookmarkNode struct {
	Children         *[]BookmarkNode   `json:"children,omitempty"` // Type == NodeTypeFolder
	DateAdded        Time              `json:"date_added"`
	DateLastUsed     Time              `json:"date_last_used,omitempty"`
	DateModified     Time              `json:"date_modified,omitempty"`
	GUID             GUID              `json:"guid"`
	ID               int               `json:"id,string"`
	Name             string            `json:"name"`
	ShowIcon         bool              `json:"show_icon,omitempty"` // used by MSEdge
	Source           Source            `json:"source,omitempty"`    // used by MSEdge
	Type             NodeType          `json:"type"`
	URL              string            `json:"url,omitempty"`
	MetaInfo         map[string]string `json:"meta_info,omitempty"`
	UnsyncedMetaInfo map[string]string `json:"unsynced_meta_info,omitempty"`
}

func (BookmarkNode) Walk

func (n BookmarkNode) Walk(fn WalkFunc) error

Walk iterates over folders and bookmarks in b depth-first, stopping if ErrBreak or another error is returned.

type Bookmarks

type Bookmarks struct {
	Checksum string `json:"checksum"`
	Roots    struct {
		BookmarkBar    BookmarkNode `json:"bookmark_bar"`
		Other          BookmarkNode `json:"other"`
		MobileBookmark BookmarkNode `json:"synced"`
	} `json:"roots"`
	SyncMetadata     Bytes             `json:"sync_metadata,omitempty"`
	Version          Version           `json:"version"`
	MetaInfo         map[string]string `json:"meta_info,omitempty"`
	UnsyncedMetaInfo map[string]string `json:"unsynced_meta_info,omitempty"`
}

func Decode

func Decode(r io.Reader) (*Bookmarks, bool, error)

Decode strictly decodes a Chrome bookmarks file.

func (Bookmarks) CalculateChecksum

func (b Bookmarks) CalculateChecksum() string

Calculate calculates the expected checksum for b.

func (Bookmarks) Walk

func (b Bookmarks) Walk(fn WalkFunc) error

Walk iterates over folders and bookmarks in b depth-first, stopping if ErrBreak or another error is returned.

type Bytes

type Bytes []byte

func (Bytes) MarshalJSON

func (c Bytes) MarshalJSON() ([]byte, error)

func (*Bytes) UnmarshalJSON

func (c *Bytes) UnmarshalJSON(b []byte) error

type CarveMatchFunc

type CarveMatchFunc func(off int64, buf []byte, obj *Bookmarks) error

type FaviconFunc

type FaviconFunc func(url string) (dataURL string)

FaviconFunc gets the data URL of the favicon for url, returning an empty string if one isn't available.

type GUID

type GUID string

func (GUID) Bytes

func (s GUID) Bytes() ([16]byte, error)

func (GUID) Canonical

func (s GUID) Canonical() (string, error)

func (GUID) MarshalJSON

func (s GUID) MarshalJSON() ([]byte, error)

func (GUID) String

func (s GUID) String() string

func (*GUID) UnmarshalJSON

func (s *GUID) UnmarshalJSON(b []byte) error

func (GUID) Valid

func (s GUID) Valid() error

type NodeType

type NodeType string
const (
	NodeTypeURL    NodeType = "url"
	NodeTypeFolder NodeType = "folder"
)

func (NodeType) MarshalJSON

func (t NodeType) MarshalJSON() ([]byte, error)

func (*NodeType) UnmarshalJSON

func (t *NodeType) UnmarshalJSON(b []byte) error

func (NodeType) Valid

func (t NodeType) Valid() error

type Source

type Source string
const (
	SourceUserAdd   Source = "user_add"
	SourceImportFre Source = "import_fre"
	SourceUnknown   Source = "unknown"
)

func (Source) MarshalJSON

func (s Source) MarshalJSON() ([]byte, error)

func (*Source) UnmarshalJSON

func (s *Source) UnmarshalJSON(b []byte) error

func (Source) Valid

func (s Source) Valid() error

type Time

type Time int64

func (Time) IsZero

func (t Time) IsZero() bool

func (Time) MarshalJSON

func (t Time) MarshalJSON() ([]byte, error)

func (*Time) SetTime

func (t *Time) SetTime(x time.Time)

func (Time) String

func (t Time) String() string

func (Time) Time

func (t Time) Time() time.Time

func (Time) Unix

func (t Time) Unix() int64

func (Time) UnixMicro

func (t Time) UnixMicro() int64

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(b []byte) error

type Version

type Version int
const CurrentVersion Version = 1

func (Version) MarshalJSON

func (v Version) MarshalJSON() ([]byte, error)

func (*Version) UnmarshalJSON

func (v *Version) UnmarshalJSON(b []byte) error

func (Version) Valid

func (v Version) Valid() error

type WalkFunc

type WalkFunc func(n BookmarkNode, parents ...string) error

Directories

Path Synopsis
cmd
crb
Command crb parses, validates, and exports Chrome bookmark files.
Command crb parses, validates, and exports Chrome bookmark files.
crb-carve
Command crb-carve attempts to recover Chrome bookmark files from a file.
Command crb-carve attempts to recover Chrome bookmark files from a file.

Jump to

Keyboard shortcuts

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