代码拉取完成,页面将自动刷新
package find
import (
"encoding/json"
"errors"
"io/ioutil"
"path/filepath"
"runtime"
)
type chromeCookieStoreFile struct {
Path string
Browser string
Profile string
OS string
IsDefaultProfile bool
}
func FindChromeCookieStoreFiles() ([]*chromeCookieStoreFile, error) {
return FindCookieStoreFiles(chromeRoots, `chrome`)
}
func FindChromiumCookieStoreFiles() ([]*chromeCookieStoreFile, error) {
return FindCookieStoreFiles(chromiumRoots, `chromium`)
}
func FindCookieStoreFiles(rootsFunc func() ([]string, error), browserName string) ([]*chromeCookieStoreFile, error) {
if rootsFunc == nil {
return nil, errors.New(`passed roots function is nil`)
}
var files []*chromeCookieStoreFile
roots, err := rootsFunc()
if err != nil {
return nil, err
}
for _, root := range roots {
localStateBytes, err := ioutil.ReadFile(filepath.Join(root, `Local State`))
if err != nil {
continue
}
var localState struct {
Profile struct {
InfoCache map[string]struct {
IsUsingDefaultName bool `json:"is_using_default_name"`
Name string
} `json:"info_cache"`
}
}
if err := json.Unmarshal(localStateBytes, &localState); err != nil {
// fallback - json file exists, json structure unknown
files = append(
files,
&chromeCookieStoreFile{
Browser: browserName,
Profile: `Profile 1`,
IsDefaultProfile: true,
Path: filepath.Join(root, `Default`, `Cookies`),
OS: runtime.GOOS,
},
)
continue
}
for profDir, profStr := range localState.Profile.InfoCache {
files = append(
files,
&chromeCookieStoreFile{
Browser: browserName,
Profile: profStr.Name,
IsDefaultProfile: profStr.IsUsingDefaultName,
Path: filepath.Join(root, profDir, `Cookies`),
OS: runtime.GOOS,
},
)
}
}
return files, nil
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。