Skip to content

Commit

Permalink
chrome args override: custome_args can be override the default_args
Browse files Browse the repository at this point in the history
  • Loading branch information
lishimeng committed Dec 5, 2024
1 parent 36a77ca commit b8cf50a
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ func New(url, dir string, width, height int, customArgs ...string) (UI, error) {
args = append(args, customArgs...)
args = append(args, "--remote-debugging-port=0")

args = handleArgs(args)

chrome, err := newChromeWithArgs(ChromeExecutable(), args...)
done := make(chan struct{})
if err != nil {
Expand All @@ -92,6 +94,17 @@ func New(url, dir string, width, height int, customArgs ...string) (UI, error) {
return &ui{chrome: chrome, done: done, tmpDir: tmpDir}, nil
}

func handleArgs(src []string) (dest []string) {
m := make(map[string]bool)
for _, s := range src {
m[s] = true
}
for s, _ := range m {
dest = append(dest, s)
}
return
}

func (u *ui) Done() <-chan struct{} {
return u.done
}
Expand Down

0 comments on commit b8cf50a

Please sign in to comment.