feat: Add a new cleaner page for managing and automatically cleaning error S2A accounts, supported by new backend services for logging, authentication, and client operations.
This commit is contained in:
@@ -16,11 +16,12 @@ import (
|
||||
|
||||
// RodAuth 使用 Rod + Stealth 完成 OAuth 授权
|
||||
type RodAuth struct {
|
||||
browser *rod.Browser
|
||||
headless bool
|
||||
proxy string
|
||||
browser *rod.Browser
|
||||
headless bool
|
||||
proxy string
|
||||
proxyUser string
|
||||
proxyPass string
|
||||
profile BrowserProfile // 随机浏览器配置
|
||||
}
|
||||
|
||||
// getChromiumPath 获取 Chromium 路径
|
||||
@@ -53,6 +54,9 @@ func getChromiumPath() string {
|
||||
|
||||
// NewRodAuth 创建 Rod 授权器
|
||||
func NewRodAuth(headless bool, proxy string) (*RodAuth, error) {
|
||||
// 获取随机浏览器配置
|
||||
profile := GetRandomBrowserProfile()
|
||||
|
||||
var proxyServer string
|
||||
var proxyUser string
|
||||
var proxyPass string
|
||||
@@ -82,7 +86,15 @@ func NewRodAuth(headless bool, proxy string) (*RodAuth, error) {
|
||||
Set("disable-sync").
|
||||
Set("disable-translate").
|
||||
Set("metrics-recording-only").
|
||||
Set("no-first-run")
|
||||
Set("no-first-run").
|
||||
Set("disable-infobars").
|
||||
Set("disable-automation").
|
||||
// 使用随机语言和窗口大小
|
||||
Set("lang", strings.Split(profile.AcceptLang, ",")[0]).
|
||||
Set("window-size", fmt.Sprintf("%d,%d", profile.Width, profile.Height)).
|
||||
// 随机 User-Agent
|
||||
UserDataDir("").
|
||||
Set("user-agent", profile.UserAgent)
|
||||
|
||||
// 使用系统 Chromium(如果存在)
|
||||
if chromiumPath := getChromiumPath(); chromiumPath != "" {
|
||||
@@ -104,11 +116,12 @@ func NewRodAuth(headless bool, proxy string) (*RodAuth, error) {
|
||||
}
|
||||
|
||||
return &RodAuth{
|
||||
browser: browser,
|
||||
headless: headless,
|
||||
proxy: proxy,
|
||||
browser: browser,
|
||||
headless: headless,
|
||||
proxy: proxy,
|
||||
proxyUser: proxyUser,
|
||||
proxyPass: proxyPass,
|
||||
profile: profile,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -161,6 +174,23 @@ func (r *RodAuth) CompleteOAuth(authURL, email, password, teamID string) (string
|
||||
}
|
||||
defer page.Close()
|
||||
|
||||
// 设置随机窗口大小
|
||||
_ = page.SetViewport(&proto.EmulationSetDeviceMetricsOverride{
|
||||
Width: r.profile.Width,
|
||||
Height: r.profile.Height,
|
||||
DeviceScaleFactor: r.profile.PixelRatio,
|
||||
Mobile: false,
|
||||
})
|
||||
|
||||
// 注入额外的反检测脚本
|
||||
antiDetectionJS := GetAntiDetectionJS(r.profile)
|
||||
_, _ = page.Evaluate(&rod.EvalOptions{
|
||||
JS: antiDetectionJS,
|
||||
ByValue: true,
|
||||
AwaitPromise: false,
|
||||
ThisObj: nil,
|
||||
})
|
||||
|
||||
// 增加超时时间到 90 秒
|
||||
page = page.Timeout(90 * time.Second)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user