Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions browser/zen/zen.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Zen (https://zen-browser.app) is a Firefox fork that keeps its own
// profile tree, separate from Firefox's, but reuses Firefox's cookies.sqlite
// and sessionstore formats verbatim.
package zen

import (
"github.com/browserutils/kooky"
"github.com/browserutils/kooky/internal/firefox"
"github.com/browserutils/kooky/internal/firefox/find"
)

type zenFinder struct{}

var _ kooky.CookieStoreFinder = (*zenFinder)(nil)

func init() {
kooky.RegisterFinder(`zen`, &zenFinder{})
}

func (f *zenFinder) FindCookieStores() kooky.CookieStoreSeq {
return firefox.CookieStoresForProfiles(find.FindZenProfiles())
}
8 changes: 8 additions & 0 deletions internal/firefox/find/find.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ func FindFirefoxProfiles() iter.Seq2[Profile, error] {
return FindProfiles(firefoxRoots, `firefox`)
}

// FindZenProfiles returns all Zen Browser (https://zen-browser.app) profiles
// from known root directories. Zen is a Firefox fork that keeps its own
// profile tree — separate from Firefox's — but writes profiles.ini in the
// same format, so it reuses FindProfiles/FindProfilesInRoot as-is.
func FindZenProfiles() iter.Seq2[Profile, error] {
return FindProfiles(zenRoots, `zen`)
}

// FindProfilesInRoot parses a single profiles.ini from rootDir
// and returns the discovered profiles.
func FindProfilesInRoot(rootDir, browserName string) ([]Profile, error) {
Expand Down
20 changes: 20 additions & 0 deletions internal/firefox/find/zen_darwin.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//go:build darwin && !ios

package find

import (
"os"
"path/filepath"
)

func zenRoots(yield func(string, error) bool) {
// "$HOME/Library/Application Support/zen"
cfgDir, err := os.UserConfigDir()
if err != nil {
_ = yield(``, err)
return
}
if !yield(filepath.Join(cfgDir, `zen`), nil) {
return
}
}
5 changes: 5 additions & 0 deletions internal/firefox/find/zen_other.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//go:build !windows && !linux

package find

func windowsZenRoots(yield func(string, error) bool) {}
7 changes: 7 additions & 0 deletions internal/firefox/find/zen_others.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//go:build plan9 || android || ios || js || aix

package find

import "errors"

func zenRoots(yield func(string, error) bool) { yield(``, errors.New(`not implemented`)) }
45 changes: 45 additions & 0 deletions internal/firefox/find/zen_unix.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
//go:build !windows && !darwin && !plan9 && !android && !js && !aix

package find

import (
"os"
"path/filepath"

"github.com/browserutils/kooky/internal/windowsx"
)

func zenRoots(yield func(string, error) bool) {
home, err := os.UserHomeDir()
if err != nil {
_ = yield(``, err)
return
}
// tarball / AUR install, current default:
// https://docs.zen-browser.app/guides/install-linux
if !yield(filepath.Join(home, `.zen`), nil) {
return
}
// Flatpak (same doc)
if !yield(filepath.Join(home, `.var`, `app`, `app.zen_browser.zen`, `.zen`), nil) {
return
}
// Newer XDG Base Directory-following builds
// (zen-browser/desktop#12366) — gated behind the Twilight channel as of
// this writing, kept here so this doesn't need a follow-up once it
// reaches the stable channel.
if cfgDir, err := os.UserConfigDir(); err == nil {
if !yield(filepath.Join(cfgDir, `zen`), nil) {
return
}
}
// on WSL Linux add Windows paths
if !windowsx.IsWSL() {
return
}
for r, err := range windowsZenRoots {
if !yield(r, err) {
return
}
}
}
21 changes: 21 additions & 0 deletions internal/firefox/find/zen_w.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//go:build windows || linux

package find

import (
"path/filepath"

"github.com/browserutils/kooky/internal/windowsx"
)

// for Windows and WSL

func windowsZenRoots(yield func(string, error) bool) {
// "%AppData%\zen" — https://docs.zen-browser.app/faq
appData, err := windowsx.AppData()
if err != nil {
_ = yield(``, err)
return
}
_ = yield(filepath.Join(appData, `zen`), nil)
}
5 changes: 5 additions & 0 deletions internal/firefox/find/zen_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//go:build windows

package find

var zenRoots = windowsZenRoots