gofox

package module
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 31, 2025 License: MIT Imports: 11 Imported by: 0

README

GoFox - Golang Firefox Profile Mangaer


Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// profile folder: `{prefix}{seperator}{name}`
	// profile folder: `{group}{seperator}{id}`
	PROFILE_SEPERATOR string = "--"

	// firefox extensions file names
	EXTENSIONS = map[string]string{
		"Chameleon":         "{3579f63b-d8ee-424f-bbb6-6d0ce3285e6a}.xpi",
		"Dark Reader":       "addon@darkreader.org.xpi",
		"Simple Translate":  "simple-translate@sienori.xpi",
		"HypeStat Analyzer": "{6d930f30-aa68-421f-83b8-71322461bdaa}.xpi",
		"Vimium":            "vimium-c@gdh1995.cn.xpi",
	}
)

Functions

func GetRandomScreenSize

func GetRandomScreenSize(device_type string) (string, error)

Types

type Asset

type Asset struct {
	Kind        string // exe|profile
	DirParent   string // dir_exe|dir_profile
	DirSegments []string
	FileName    string // filename.ext
}

func DefaultAssets

func DefaultAssets(
	dir_exe string,
	dir_profile string,
) []Asset

init default assets

func (*Asset) Backup

func (a *Asset) Backup(dir_root string, today string) (bool, error)

backup Asset file into Cache dir date string, eg: `today := time.Now().Format(time.RFC3339)`

func (*Asset) Check

func (a *Asset) Check() (bool, error)

check Asset exists

func (*Asset) Copy

func (a *Asset) Copy(dir_profile string) (bool, error)

copy Asset to dst folder

func (*Asset) FullPath

func (a *Asset) FullPath() string

get Asset fullpath string

func (*Asset) Restore

func (a *Asset) Restore(dir_root string, today string) (bool, error)

restore Asset file from latest backups date string, eg: `today := time.Now().Format(time.RFC3339)`

func (*Asset) ToBackupDir

func (a *Asset) ToBackupDir(dir_root string, today string) string

find Dir for backup

type Browser

type Browser struct {
	Family string // `json:"Family"`
	Code   string // `json:"Code"`
}

func GetRandomBrowser

func GetRandomBrowser(
	family string,
	device_type string,
) (Browser, error)

get random Browser by family, eg: `Firefox`, `Edge`, etc. see package chameleon for details

type Chameleon

type Chameleon struct {
	Settings chameleon.Settings
}

func (*Chameleon) UpdateByFP

func (cs *Chameleon) UpdateByFP(fp *FingerPrint) bool

type Config

type Config struct {
	Debug bool `toml:"Debug"`

	// Root dir of this project, auto resolved, Don't change this
	DirRoot string `toml:"DirRoot"`

	// profiles folder
	DirProfiles string `toml:"DirProfiles"`

	// Firefox Exeutable, eg `D:\Portable\FirefoxPortable\App\Firefox`
	ExePath string `toml:"ExePath"`

	// profile name = prefix + seperator + id
	Seperator string `toml:"Seperator"`
}

func NewConfig

func NewConfig(
	debug bool,
	exepath string,
	dir_profiles string,
	seperator string,
) Config

create new Config

func (*Config) Check

func (c *Config) Check() (bool, error)

func (*Config) ToDirAssets

func (c *Config) ToDirAssets() string

type Device

type Device struct {
	Browser    Browser         // `json:"Browser"`
	OS         OperationSystem // `json:"OS"`
	Type       string          // `json:"Type"`
	Language   string          // `json:"Language"`
	ScreenSize string          // `json:"ScreenSize"`
}

type FPManager

type FPManager struct {
	Config       Config
	Assets       []Asset
	FingerPrints []FingerPrint
}

Firefox FingerPrint Manager

func (*FPManager) Check

func (m *FPManager) Check() (bool, error)

check

func (*FPManager) CreateFP

func (m *FPManager) CreateFP(
	group string,
	id string,
	lang string,
	proxy_url string,
	os_family string,
	br_family string,
	device_type string,
) (fp FingerPrint, err error)

create FingerPrint item, but no folders/files yet.

func (*FPManager) DeleteFP

func (m *FPManager) DeleteFP(fp *FingerPrint) (bool, error)

delete FingerPrint item, without touch folders/files yet

func (*FPManager) DirOfProfile

func (m *FPManager) DirOfProfile(fp *FingerPrint) string

get dir of Profile for FingerPrint

func (*FPManager) FillProfile

func (m *FPManager) FillProfile(fp *FingerPrint) (bool, error)

fill Profile folder from demo profile folder

func (*FPManager) GetFP

func (m *FPManager) GetFP(id string) (FingerPrint, error)

get FingerPrint by id

func (*FPManager) InitChameleon

func (m *FPManager) InitChameleon() (Chameleon, error)

init Chameleon

func (*FPManager) LoadFPs

func (m *FPManager) LoadFPs(f string) ([]FingerPrint, error)

load FingerPrint items from local file

func (*FPManager) RemoveProfile

func (m *FPManager) RemoveProfile(fp *FingerPrint) (bool, error)

remove profile folder for FingerPrint item

func (*FPManager) SaveFPs

func (m *FPManager) SaveFPs(f string, indent bool) (bool, error)

save FingerPrint items to local file

func (*FPManager) StartProfile

func (m *FPManager) StartProfile(fp *FingerPrint) (bool, error)

run shell command for FingerPrint

func (*FPManager) StartProfileByID

func (m *FPManager) StartProfileByID(id string) (bool, error)

run shell command for Profile by id

func (*FPManager) UpdateFP

func (m *FPManager) UpdateFP(fp *FingerPrint, add bool)

update FingerPrint, or add it if not exist yet

type FingerPrint

type FingerPrint struct {
	Group string // `json:"Group"`
	Id    string // `json:"Id"`

	DirProfile string // `json:"DirProfile"`

	Device   Device   // `json:"Device"`
	Location Location // `json:"Location"`

}

type GeoAddr

type GeoAddr struct {
	IPAddr   string // `json:"IPAddr"`
	Country  string // `json:"Country"`
	State    string // `json:"State"`
	City     string // `json:"City"`
	Timezone string // `json:"Timezone"`
}

type Location

type Location struct {
	GeoAddr GeoAddr     // `json:"GeoAddr"`
	Proxy   utils.Proxy // `json:"Proxy"`
}

type OperationSystem

type OperationSystem struct {
	Family string // `json:"Family"`
	Code   string // `json:"Code"`
}

func GetRandomOS

func GetRandomOS(family string) (OperationSystem, error)

get random OS by family abbr, eg: `win`, `lin`, etc. see package chameleon for details

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL