From 350ca879ffe1f2c921ec23f32e3be00a4b32b015 Mon Sep 17 00:00:00 2001 From: nv4re Date: Sat, 17 Dec 2022 15:39:30 +0700 Subject: [PATCH] Fix chrome cannot open ? --- main.go | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index def177b..30a6d55 100644 --- a/main.go +++ b/main.go @@ -42,10 +42,42 @@ func main() { output := flag.String("output", "output.json", "Output file") flag.Parse() + dir, err := os.MkdirTemp("", "chromedp-example") + if err != nil { + log.Fatal(err) + } + defer os.RemoveAll(dir) + opts := []chromedp.ExecAllocatorOption{ - chromedp.UserDataDir(""), - chromedp.Flag("new-instance", true), + chromedp.NoFirstRun, chromedp.NoDefaultBrowserCheck, + + // After Puppeteer's default behavior. + chromedp.Flag("disable-background-networking", true), + chromedp.Flag("enable-features", "NetworkService,NetworkServiceInProcess"), + chromedp.Flag("disable-background-timer-throttling", true), + chromedp.Flag("disable-backgrounding-occluded-windows", true), + chromedp.Flag("disable-breakpad", true), + chromedp.Flag("disable-client-side-phishing-detection", true), + chromedp.Flag("disable-default-apps", true), + chromedp.Flag("disable-dev-shm-usage", true), + chromedp.Flag("disable-extensions", true), + chromedp.Flag("disable-features", "site-per-process,Translate,BlinkGenPropertyTrees"), + chromedp.Flag("disable-hang-monitor", true), + chromedp.Flag("disable-ipc-flooding-protection", true), + chromedp.Flag("disable-popup-blocking", true), + chromedp.Flag("disable-prompt-on-repost", true), + chromedp.Flag("disable-renderer-backgrounding", true), + chromedp.Flag("disable-sync", true), + chromedp.Flag("force-color-profile", "srgb"), + chromedp.Flag("metrics-recording-only", true), + chromedp.Flag("safebrowsing-disable-auto-update", true), + chromedp.Flag("enable-automation", true), + chromedp.Flag("password-store", "basic"), + chromedp.Flag("use-mock-keychain", true), + + chromedp.UserDataDir(dir), + chromedp.DisableGPU, chromedp.Flag("mute-audio", true), } @@ -73,7 +105,7 @@ func main() { VideoStats: make([]VideoStat, 0), } - err := chromedp.Run(ctx, + err = chromedp.Run(ctx, chromedp.Navigate(*profileUrl), chromedp.WaitVisible(VideosItem), chromedp.Click(VideosItem, chromedp.NodeVisible),