change UA to chrome 151

This commit is contained in:
kulikov0 committed 2026-09-16 14:49:26 +02:00
1 parent 76e2d8b1cf
commit 0cb812677a
6 files changed
+37 -5

No files matched your search

+32
View File
@@ -5,6 +5,9 @@ package common
import (
"fmt"
"math/rand/v2"
"strings"
"github.com/kulikov0/headless-client"
)
type DeviceProfile struct {
@@ -35,6 +38,8 @@ type browserTemplate struct {
userAgentFn func(osVersion, browserVersion string) string
}
var windowsDeviceBrands = []string{"Dell", "Lenovo", "HP", "Asus", "Acer", "MSI"}
var commonScreens = [][2]int{
{1280, 720}, {1366, 768}, {1440, 900}, {1536, 864},
{1600, 900}, {1680, 1050}, {1728, 1117}, {1920, 1080},
@@ -170,3 +175,30 @@ func RandomDeviceProfile() DeviceProfile {
ScreenHeight: screen[1],
}
}
func chromeVersionFromUserAgent(userAgent string) string {
_, rest, found := strings.Cut(userAgent, "Chrome/")
if !found {
return ""
}
version, _, _ := strings.Cut(rest, " ")
return version
}
func ChromeWindowsDeviceProfile() DeviceProfile {
userAgent := headless.ChromeWindows.UserAgent()
screen := commonScreens[rand.IntN(len(commonScreens))]
return DeviceProfile{
UserAgent: userAgent,
Platform: "web",
BrowserType: "Chrome",
BrowserVersion: chromeVersionFromUserAgent(userAgent),
DeviceBrand: windowsDeviceBrands[rand.IntN(len(windowsDeviceBrands))],
DeviceModel: "PC",
DeviceType: "pc",
OS: "Windows",
OSVersion: "10",
ScreenWidth: screen[0],
ScreenHeight: screen[1],
}
}