feat: add High DPI and Low DPI Desktop device descriptors (#7531)

This commit is contained in:
Max Schmitt 2021-07-15 22:16:27 +02:00 committed by GitHub
parent cf0fb33540
commit 86b21d5299
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 116 additions and 1 deletions

View File

@ -1140,5 +1140,110 @@
"isMobile": true,
"hasTouch": true,
"defaultBrowserType": "chromium"
},
"Desktop Chrome HiDPI": {
"userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4543.0 Safari/537.36",
"screen": {
"width": 1792,
"height": 1120
},
"viewport": {
"width": 1280,
"height": 720
},
"deviceScaleFactor": 2,
"isMobile": false,
"hasTouch": false,
"defaultBrowserType": "chromium"
},
"Desktop Edge HiDPI": {
"userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4543.0 Safari/537.36 Edg/93.0.4543.0",
"screen": {
"width": 1792,
"height": 1120
},
"viewport": {
"width": 1280,
"height": 720
},
"deviceScaleFactor": 2,
"isMobile": false,
"hasTouch": false,
"defaultBrowserType": "chromium"
},
"Desktop Firefox HiDPI": {
"userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:90.0 Gecko/20100101 Firefox/90.0",
"screen": {
"width": 1792,
"height": 1120
},
"viewport": {
"width": 1280,
"height": 720
},
"deviceScaleFactor": 2,
"isMobile": false,
"hasTouch": false,
"defaultBrowserType": "firefox"
},
"Desktop Safari": {
"userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.2 Safari/605.1.15",
"screen": {
"width": 1792,
"height": 1120
},
"viewport": {
"width": 1280,
"height": 720
},
"deviceScaleFactor": 2,
"isMobile": false,
"hasTouch": false,
"defaultBrowserType": "webkit"
},
"Desktop Chrome": {
"userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4543.0 Safari/537.36",
"screen": {
"width": 1920,
"height": 1080
},
"viewport": {
"width": 1280,
"height": 720
},
"deviceScaleFactor": 1,
"isMobile": false,
"hasTouch": false,
"defaultBrowserType": "chromium"
},
"Dekstop Edge": {
"userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4543.0 Safari/537.36 Edg/93.0.4543.0",
"screen": {
"width": 1920,
"height": 1080
},
"viewport": {
"width": 1280,
"height": 720
},
"deviceScaleFactor": 1,
"isMobile": false,
"hasTouch": false,
"defaultBrowserType": "chromium"
},
"Desktop Firefox": {
"userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:90.0 Gecko/20100101 Firefox/90.0",
"screen": {
"width": 1920,
"height": 1080
},
"viewport": {
"width": 1280,
"height": 720
},
"deviceScaleFactor": 1,
"isMobile": false,
"hasTouch": false,
"defaultBrowserType": "firefox"
}
}

7
types/types.d.ts vendored
View File

@ -11425,6 +11425,13 @@ type Devices = {
"Pixel 5 landscape": DeviceDescriptor;
"Moto G4": DeviceDescriptor;
"Moto G4 landscape": DeviceDescriptor;
"Desktop Chrome HiDPI": DeviceDescriptor;
"Desktop Edge HiDPI": DeviceDescriptor;
"Desktop Firefox HiDPI": DeviceDescriptor;
"Desktop Safari": DeviceDescriptor;
"Desktop Chrome": DeviceDescriptor;
"Dekstop Edge": DeviceDescriptor;
"Desktop Firefox": DeviceDescriptor;
[key: string]: DeviceDescriptor;
}

View File

@ -75,11 +75,14 @@ async function run() {
devicesDescriptors[deviceName].userAgent = devicesDescriptors[deviceName].userAgent.replace(
/(.*Chrome\/)(.*?)( .*)/,
`$1${versions.chromium}$3`
).replace(
/(.*Edg\/)(.*?)$/,
`$1${versions.chromium}`
)
break;
case 'firefox':
devicesDescriptors[deviceName].userAgent = devicesDescriptors[deviceName].userAgent.replace(
/(.*Firefox\/)(.*?)( .*)/,
/^(.*Firefox\/)(.*?)( .*?)?$/,
`$1${versions.firefox}$3`
).replace(/(.*rv:)(.*)\)(.*?)/, `$1${versions.firefox}$3`)
break;