From cf4ffeca514a10438d3ecdd1ca6fdebef0191468 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=B4=8D=E1=B4=8F=E1=B4=8F=C9=B4D4=CA=80=E1=B4=8B?= Date: Tue, 16 Aug 2022 19:30:53 +0800 Subject: [PATCH] fix: find cookies file failed --- internal/browser/browser_windows.go | 2 +- internal/browser/chromium/chromium.go | 13 ++++++++----- internal/decrypter/decrypter_darwin.go | 2 ++ internal/decrypter/decrypter_linux.go | 2 ++ internal/decrypter/decrypter_windows.go | 2 ++ 5 files changed, 15 insertions(+), 6 deletions(-) diff --git a/internal/browser/browser_windows.go b/internal/browser/browser_windows.go index 17fa899..b4c964d 100644 --- a/internal/browser/browser_windows.go +++ b/internal/browser/browser_windows.go @@ -96,7 +96,7 @@ var ( braveProfilePath = homeDir + "/AppData/Local/BraveSoftware/Brave-Browser/User Data/Default/" speed360ProfilePath = homeDir + "/AppData/Local/360chrome/Chrome/User Data/Default/" qqBrowserProfilePath = homeDir + "/AppData/Local/Tencent/QQBrowser/User Data/Default/" - operaProfilePath = homeDir + "/AppData/Roaming/Opera Software/Opera Stable/Default/" + operaProfilePath = homeDir + "/AppData/Roaming/Opera Software/Opera Stable/" operaGXProfilePath = homeDir + "/AppData/Roaming/Opera Software/Opera GX Stable/" vivaldiProfilePath = homeDir + "/AppData/Local/Vivaldi/User Data/Default/" coccocProfilePath = homeDir + "/AppData/Local/CocCoc/Browser/User Data/Default/" diff --git a/internal/browser/chromium/chromium.go b/internal/browser/chromium/chromium.go index 7f716e6..9a7319e 100644 --- a/internal/browser/chromium/chromium.go +++ b/internal/browser/chromium/chromium.go @@ -124,14 +124,17 @@ func chromiumWalkFunc(items []item.Item, multiItemPaths map[string]map[item.Item return func(path string, info fs.FileInfo, err error) error { for _, v := range items { if info.Name() == v.FileName() { - parentBaseDir := fileutil.ParentBaseDir(path) - if parentBaseDir == "System Profile" { + if strings.Contains(path, "System Profile") { continue } - if _, exist := multiItemPaths[parentBaseDir]; exist { - multiItemPaths[parentBaseDir][v] = path + profileFolder := fileutil.ParentBaseDir(path) + if strings.Contains(filepath.ToSlash(path), "/Network/Cookies") { + profileFolder = fileutil.BaseDir(strings.ReplaceAll(filepath.ToSlash(path), "/Network/Cookies", "")) + } + if _, exist := multiItemPaths[profileFolder]; exist { + multiItemPaths[profileFolder][v] = path } else { - multiItemPaths[parentBaseDir] = map[item.Item]string{v: path} + multiItemPaths[profileFolder] = map[item.Item]string{v: path} } } } diff --git a/internal/decrypter/decrypter_darwin.go b/internal/decrypter/decrypter_darwin.go index 62ef35e..35645bc 100644 --- a/internal/decrypter/decrypter_darwin.go +++ b/internal/decrypter/decrypter_darwin.go @@ -1,3 +1,5 @@ +//go:build darwin + package decrypter func Chromium(key, encryptPass []byte) ([]byte, error) { diff --git a/internal/decrypter/decrypter_linux.go b/internal/decrypter/decrypter_linux.go index 715f610..6f8e2d5 100644 --- a/internal/decrypter/decrypter_linux.go +++ b/internal/decrypter/decrypter_linux.go @@ -1,3 +1,5 @@ +//go:build linux + package decrypter func Chromium(key, encryptPass []byte) ([]byte, error) { diff --git a/internal/decrypter/decrypter_windows.go b/internal/decrypter/decrypter_windows.go index 277d222..794d870 100644 --- a/internal/decrypter/decrypter_windows.go +++ b/internal/decrypter/decrypter_windows.go @@ -1,3 +1,5 @@ +//go:build windows + package decrypter import (