diff --git a/browser/browser.go b/browser/browser.go index c8bc7b7c..e433c578 100644 --- a/browser/browser.go +++ b/browser/browser.go @@ -65,13 +65,13 @@ func pickChromium(name, profile string) []Browser { if !fileutil.IsDirExists(filepath.Clean(profile)) { slog.Error("find browser failed, profile folder does not exist", "browser", c.name) } - chromiumList, err := chromium.New(c.name, c.storage, profile, c.dataTypes) + chromes, err := chromium.New(c.name, c.storage, profile, c.dataTypes) if err != nil { slog.Error("new chromium error", "err", err) } - for _, b := range chromiumList { - slog.Warn("find browser success", "browser", b.Name()) - browsers = append(browsers, b) + for _, chrome := range chromes { + slog.Warn("find browser success", "browser", chrome.Name()) + browsers = append(browsers, chrome) } } return browsers diff --git a/browser/chromium/chromium.go b/browser/chromium/chromium.go index 748cd0b2..c66c5b7b 100644 --- a/browser/chromium/chromium.go +++ b/browser/chromium/chromium.go @@ -4,6 +4,7 @@ import ( "io/fs" "log/slog" "path/filepath" + "slices" "strings" "github.com/moond4rk/hackbrowserdata/browserdata" @@ -50,12 +51,16 @@ func (c *Chromium) Name() string { } func (c *Chromium) BrowsingData(isFullExport bool) (*browserdata.BrowserData, error) { - items := c.dataTypes + // delete chromiumKey from dataTypes, doesn't need to export key + dataTypes := slices.DeleteFunc(c.dataTypes, func(i types.DataType) bool { + return i == types.ChromiumKey + }) + if !isFullExport { - items = types.FilterSensitiveItems(c.dataTypes) + dataTypes = types.FilterSensitiveItems(c.dataTypes) } - data := browserdata.New(items) + data := browserdata.New(dataTypes) if err := c.copyItemToLocal(); err != nil { return nil, err @@ -107,10 +112,10 @@ func (c *Chromium) userDataTypePaths(profilePath string, items []types.DataType) } var keyPath string var dir string - for userDir, v := range multiItemPaths { - for _, p := range v { - if strings.HasSuffix(p, types.ChromiumKey.Filename()) { - keyPath = p + for userDir, profiles := range multiItemPaths { + for _, profile := range profiles { + if strings.HasSuffix(profile, types.ChromiumKey.Filename()) { + keyPath = profile dir = userDir break } @@ -138,6 +143,9 @@ func chromiumWalkFunc(items []types.DataType, multiItemPaths map[string]map[type if strings.Contains(path, "System Profile") { continue } + if strings.Contains(path, "Snapshot") { + continue + } profileFolder := fileutil.ParentBaseDir(path) if strings.Contains(filepath.ToSlash(path), "/Network/Cookies") { profileFolder = fileutil.BaseDir(strings.ReplaceAll(filepath.ToSlash(path), "/Network/Cookies", "")) diff --git a/browser/firefox/firefox.go b/browser/firefox/firefox.go index 974d39b5..78a2aa28 100644 --- a/browser/firefox/firefox.go +++ b/browser/firefox/firefox.go @@ -160,12 +160,12 @@ func (f *Firefox) Name() string { } func (f *Firefox) BrowsingData(isFullExport bool) (*browserdata.BrowserData, error) { - items := f.items + dataTypes := f.items if !isFullExport { - items = types.FilterSensitiveItems(f.items) + dataTypes = types.FilterSensitiveItems(f.items) } - b := browserdata.New(items) + data := browserdata.New(dataTypes) if err := f.copyItemToLocal(); err != nil { return nil, err @@ -177,8 +177,8 @@ func (f *Firefox) BrowsingData(isFullExport bool) (*browserdata.BrowserData, err } f.masterKey = masterKey - if err := b.Recovery(f.masterKey); err != nil { + if err := data.Recovery(f.masterKey); err != nil { return nil, err } - return b, nil + return data, nil }