代码拉取完成,页面将自动刷新
//+build !windows
package uzbl
import (
"os"
"path/filepath"
"gitee.com/wengo/kooky"
"gitee.com/wengo/kooky/internal"
"gitee.com/wengo/kooky/internal/netscape"
)
type uzblFinder struct{}
var _ kooky.CookieStoreFinder = (*uzblFinder)(nil)
func init() {
kooky.RegisterFinder(`uzbl`, &uzblFinder{})
}
func (s *uzblFinder) FindCookieStores() ([]kooky.CookieStore, error) {
roots, err := uzblRoots()
if err != nil {
return nil, err
}
var ret []kooky.CookieStore
for _, root := range roots {
for _, filename := range []string{`session-cookies.txt`, `cookies.txt`} {
ret = append(
ret,
&netscape.CookieStore{
DefaultCookieStore: internal.DefaultCookieStore{
BrowserStr: `uzbl`,
FileNameStr: filepath.Join(root, `uzbl`, filename),
},
},
)
}
}
if len(ret) > 0 {
if cookieStore, ok := ret[len(ret)-1].(*netscape.CookieStore); ok {
cookieStore.IsDefaultProfileBool = true
}
}
return ret, nil
}
func uzblRoots() ([]string, error) {
var ret []string
home, errHome := os.UserHomeDir()
// old location
// fallback
if errHome == nil {
ret = append(ret, filepath.Join(home, `.config`))
}
if dir, ok := os.LookupEnv(`XDG_CONFIG_HOME`); ok {
ret = append(ret, dir)
}
// new location
if errHome == nil {
ret = append(ret, filepath.Join(home, `.local`, `share`))
}
if dataDir, ok := os.LookupEnv(`XDG_DATA_HOME`); ok {
ret = append(ret, dataDir)
}
return ret, nil
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。