|
|
|
@ -2,6 +2,7 @@ package browser |
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
|
"os" |
|
|
|
|
"path/filepath" |
|
|
|
|
"strings" |
|
|
|
|
|
|
|
|
|
"hack-browser-data/internal/browingdata" |
|
|
|
@ -42,16 +43,15 @@ func pickChromium(name, profile string) []Browser { |
|
|
|
|
// TODO: add support for 「all」 flag and set profilePath
|
|
|
|
|
if name == "all" { |
|
|
|
|
for _, v := range chromiumList { |
|
|
|
|
if !fileutil.FolderExists(filepath.Clean(v.profilePath)) { |
|
|
|
|
log.Noticef("find browser %s failed, profile folder is not exist", v.name) |
|
|
|
|
continue |
|
|
|
|
} |
|
|
|
|
if b, err := chromium.New(v.name, v.storage, v.profilePath, v.items); err == nil { |
|
|
|
|
log.Noticef("find browser %s success", b.Name()) |
|
|
|
|
browsers = append(browsers, b) |
|
|
|
|
} else { |
|
|
|
|
if err == chromium.ErrProfilePathNotFound { |
|
|
|
|
log.Errorf("find browser %s failed, profile folder is not exist, maybe not installed", v.name) |
|
|
|
|
continue |
|
|
|
|
} else { |
|
|
|
|
log.Errorf("new chromium error: %s", err.Error()) |
|
|
|
|
} |
|
|
|
|
log.Errorf("new chromium error: %s", err.Error()) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -59,15 +59,14 @@ func pickChromium(name, profile string) []Browser { |
|
|
|
|
if profile == "" { |
|
|
|
|
profile = c.profilePath |
|
|
|
|
} |
|
|
|
|
if !fileutil.FolderExists(filepath.Clean(profile)) { |
|
|
|
|
log.Fatalf("find browser %s failed, profile folder is not exist", c.name) |
|
|
|
|
} |
|
|
|
|
b, err := chromium.New(c.name, c.storage, profile, c.items) |
|
|
|
|
if err != nil { |
|
|
|
|
if err == chromium.ErrProfilePathNotFound { |
|
|
|
|
log.Fatalf("find browser %s failed, profile folder is not exist, maybe not installed", c.name) |
|
|
|
|
} else { |
|
|
|
|
log.Fatalf("new chromium error:", err) |
|
|
|
|
return nil |
|
|
|
|
} |
|
|
|
|
log.Fatalf("new chromium error:", err) |
|
|
|
|
} |
|
|
|
|
log.Noticef("find browser %s success", b.Name()) |
|
|
|
|
browsers = append(browsers, b) |
|
|
|
|
} |
|
|
|
|
return browsers |
|
|
|
@ -83,17 +82,17 @@ func pickFirefox(name, profile string) []Browser { |
|
|
|
|
} else { |
|
|
|
|
profile = fileutil.ParentDir(profile) |
|
|
|
|
} |
|
|
|
|
if !fileutil.FolderExists(filepath.Clean(profile)) { |
|
|
|
|
log.Noticef("find browser firefox %s failed, profile folder is not exist", v.name) |
|
|
|
|
continue |
|
|
|
|
} |
|
|
|
|
if multiFirefox, err := firefox.New(v.name, v.storage, profile, v.items); err == nil { |
|
|
|
|
for _, b := range multiFirefox { |
|
|
|
|
log.Noticef("find browser firefox %s success", b.Name()) |
|
|
|
|
browsers = append(browsers, b) |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
if err == firefox.ErrProfilePathNotFound { |
|
|
|
|
log.Errorf("find browser firefox %s failed, profile folder is not exist", v.name) |
|
|
|
|
} else { |
|
|
|
|
log.Error(err) |
|
|
|
|
} |
|
|
|
|
log.Error(err) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return browsers |
|
|
|
|