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