From e96de94611ea677c3d78c878039ccbc87d33d023 Mon Sep 17 00:00:00 2001 From: johlanse Date: Sat, 10 Sep 2022 21:19:10 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E6=96=87=E7=AB=A0=E5=AD=A6?= =?UTF-8?q?=E4=B9=A0=E5=92=8C=E8=A7=86=E9=A2=91=E5=AD=A6=E4=B9=A0=E7=AA=97?= =?UTF-8?q?=E4=BD=93=E6=9C=80=E5=A4=A7=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/study.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/study.go b/lib/study.go index 0f17e95..6bc744b 100644 --- a/lib/study.go +++ b/lib/study.go @@ -115,13 +115,18 @@ func (c *Core) LearnArticle(user *model.User) { if score.Content["article"].CurrentScore < score.Content["article"].MaxScore { log.Infoln("开始加载文章学习模块") - context, err := c.browser.NewContext() + context, err := c.browser.NewContext(playwright.BrowserNewContextOptions{ + Viewport: &playwright.BrowserNewContextOptionsViewport{ + Width: playwright.Int(1920), + Height: playwright.Int(1080), + }}) _ = context.AddInitScript(playwright.BrowserContextAddInitScriptOptions{ Script: playwright.String("Object.defineProperties(navigator, {webdriver:{get:()=>undefined}});")}) if err != nil { log.Errorln("创建实例对象错误" + err.Error()) return } + defer func(context playwright.BrowserContext) { err := context.Close() if err != nil { @@ -228,7 +233,11 @@ func (c *Core) LearnVideo(user *model.User) { // core := Core{} // core.Init() - context, err := c.browser.NewContext() + context, err := c.browser.NewContext(playwright.BrowserNewContextOptions{ + Viewport: &playwright.BrowserNewContextOptionsViewport{ + Width: playwright.Int(1920), + Height: playwright.Int(1080), + }}) _ = context.AddInitScript(playwright.BrowserContextAddInitScriptOptions{ Script: playwright.String("Object.defineProperties(navigator, {webdriver:{get:()=>undefined}});")}) if err != nil {