Documentation
¶
Overview ¶
Package mozilla provides functionality for managing Mozilla-based browser profiles, such as Firefox and LibreWolf. It reads and parses the `profiles.ini` configuration file used by these applications to store profile information, and provides tools to retrieve and manage browser profiles for different flavors (e.g., Firefox, LibreWolf).
TODO: auto detect vfs lock then switch or not to watch© places
Index ¶
- Constants
- Variables
- func CheckVFSLock(bkDir string) error
- func FindPref(path string, name string) (string, error)
- func GetPrefBool(path string, name string) (bool, error)
- func HasPref(path string, name string) (bool, error)
- func SetPrefBool(path string, name string, val bool) error
- func UnlockPlaces(bkDir string) error
- type BrowserDef
- type MergedPlaceBookmark
- type MozBookmark
- type MozFolder
- type MozProfileManager
- type PlaceCopyJob
- type Sqlid
Constants ¶
const ( RootID // 1 MenuID // 2 Main bookmarks menu ToolbarID // 3 Bk tookbar that can be toggled under URL zone TagsID // 4 Hidden menu used for tags, stored as a flat one level menu OtherID // 5 Most bookmarks are automatically stored here MobileID // 6 Mobile bookmarks stored here by default )
Constants representing the meaning if IDs defined in the table moz_bookmarks.id
const ( // Name of the root node RootName = `ROOT` // Name of the `Tags` node parent to all tag nodes TagsBranchName = `TAGS` )
Names of the root node in the mozilla bookmark tree. See RootFolderNames.
const ( //TODO!: create file if it does not exist PrefsFile = "user.js" // Parses vales in prefs.js under the form: // user_pref("my.pref.option", value); REFirefoxPrefs = `user_pref\("(?P<option>%s)",\s+"*(?P<value>.*[^"])"*\)\s*;\s*(\n|$)` )
const ( MozBookmarkQueryFile = "recursive_all_bookmarks.sql" MozBookmarkQuery = "recursive-all-bookmarks" MozChangedBookmarkQueryFile = "recursive_modified_bookmarks.sql" MozChangedBookmarkQuery = "recursive-modified-bookmarks" )
const (
PlacesFile = "places.sqlite"
)
const ( // This option disables the VFS lock on firefox // Sqlite allows file locking of the database using the local file system VFS. // Previous versions of FF allowed external processes to access the file. // // Since firefox v(63) this has changed. When initializing the database FF checks // the preference option `storage.multiProcessAccess.enabled` which is not // documented officially. // // Source code: //- https://dxr.mozilla.org/mozilla-central/source/storage/TelemetryVFS.cpp#884 //- https://dxr.mozilla.org/mozilla-central/source/storage/mozStorageService.cpp#377 //- Change on github: https://github.com/mozilla/gecko-dev/commit/a543f35d4be483b19446304f52e4781d7a4a0a2f PrefMultiProcessAccess = "storage.multiProcessAccess.enabled" )
const (
ProfilesFile = "profiles.ini"
)
const (
QFolders = `` /* 131-byte string literal not displayed */
)
sql queries
Variables ¶
var ( ErrPrefNotFound = errors.New("pref not defined") ErrPrefNotBool = errors.New("pref is not bool") )
var ( ReIniProfiles = regexp.MustCompile(`(?i)profile`) ErrProfilesIni = errors.New("could not parse profiles.ini file") ErrNoDefaultProfile = errors.New("no default profile found") )
var CopyJobs []PlaceCopyJob
var ( //go:embed "recursive_all_bookmarks.sql" //go:embed "recursive_modified_bookmarks.sql" EmbeddedSQLQueries embed.FS )
var (
ErrMultiProcessAlreadyEnabled = errors.New("multiProcessAccess already enabled")
)
var RootFolderNames = map[Sqlid]string{ RootID: RootName, TagsID: TagsBranchName, MenuID: "menu", ToolbarID: "toolbar", OtherID: "other", MobileID: "mobile", }
Some root folders names in the tree
var RootFolderTitles = map[Sqlid]string{ MenuID: "Bookmarks Menu", ToolbarID: "Bookmarks Toolbar", OtherID: "Other Bookmarks", MobileID: "Mobile Bookmarks", }
Represnets the root folder names as shown on Firefox
Functions ¶
func FindPref ¶
Finds and returns a prefernce definition. Returns empty string ("") if no pref found
func SetPrefBool ¶
Set a preference in the preference file under `path`
func UnlockPlaces ¶
Types ¶
type BrowserDef ¶
type BrowserDef = browsers.BrowserDef
type MergedPlaceBookmark ¶
type MergedPlaceBookmark struct {
PlID Sqlid `db:"plId"`
PlURL string `db:"plUrl"`
PlDesc string `db:"plDescription"`
BkID Sqlid `db:"bkId"`
BkTitle string `db:"bkTitle"`
//firefox stores timestamps in milliseconds as integer
//sqlite3 strftime('%s', ...) returns seconds
//This field stores the timestamp as raw milliseconds
BkLastModified Sqlid `db:"bkLastModified"`
IsFolder bool `db:"isFolder"`
IsTag bool `db:"isTag"`
IsBk bool `db:"isBk"`
BkParent Sqlid `db:"bkParent"`
}
Type is used for scanning from `merged-places-bookmarks.sql` plId plUrl plDescription bkId bkTitle bkLastModified isFolder isTag isBk bkParent
func (*MergedPlaceBookmark) Datetime ¶
func (pb *MergedPlaceBookmark) Datetime() time.Time
type MozBookmark ¶
type MozBookmark struct {
PlID Sqlid `db:"plId"`
Title string
Tags string
Folders string
ParentID Sqlid `db:"parentFolderId"`
ParentFolder string `db:"parentFolder"`
URL string
PlDesc string `db:"plDesc"`
BkLastModified Sqlid `db:"lastModified"`
}
Columns of the table moz_bookmarks in this order:
placeId title parentFolderId folders url plDesc lastModified
This is the typed used when scanning from the query located in `recursive-all-bookmarks.sql`
type MozProfileManager ¶
type MozProfileManager struct {
PathResolver profiles.PathResolver
}
func NewMozProfileManager ¶
func NewMozProfileManager(resolver profiles.PathResolver) *MozProfileManager
func (*MozProfileManager) GetProfileByName ¶
func (*MozProfileManager) GetProfiles ¶
func (pm *MozProfileManager) GetProfiles(flavour string) ([]*profiles.Profile, error)
func (*MozProfileManager) ListFlavours ¶
func (pm *MozProfileManager) ListFlavours() []BrowserDef
type PlaceCopyJob ¶
type PlaceCopyJob struct {
ID string
}
func NewPlaceCopyJob ¶
func NewPlaceCopyJob() PlaceCopyJob
func (PlaceCopyJob) Clean ¶
func (pc PlaceCopyJob) Clean() error
func (PlaceCopyJob) Path ¶
func (pc PlaceCopyJob) Path() string