Skip to content

Commit

Permalink
Fix the way device profiles are read from puppeteer-core
Browse files Browse the repository at this point in the history
    TypeError: Cannot read properties of undefined (reading 'Galaxy S5')

$ DEBUG=phantomas:extensions:devices ./bin/phantomas.js https://elecena.pl --tablet
  phantomas:extensions:devices Devices: tablet provided - using "Kindle Fire HDX" profile: {"name":"Kindle Fire HDX","userAgent":"Mozilla/5.0 (Linux; U; en-us; KFAPWI Build/JDQ39) AppleWebKit/535.19 (KHTML, like Gecko) Silk/3.13 Safari/535.19 Silk-Accelerated=true","viewport":{"width":800,"height":1280,"deviceScaleFactor":2,"isMobile":true,"hasTouch":true,"isLandscape":false}} +0ms
  phantomas:extensions:devices page.emulate() called +100ms
  • Loading branch information
macbre committed Mar 10, 2024
1 parent 56deb32 commit a74cc03
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions extensions/devices/devices.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@

module.exports = function (phantomas) {
const puppeteer = require("puppeteer"),
devices = puppeteer.devices,
// @see https://github.com/GoogleChrome/puppeteer/blob/master/DeviceDescriptors.js
devices = puppeteer.KnownDevices,
// @see https://github.com/puppeteer/puppeteer/blob/main/packages/puppeteer-core/src/common/Device.ts
availableDevices = {
phone: "Galaxy S5", // 360x640
"phone-landscape": "Galaxy S5 landscape", // 640x360
tablet: "Kindle Fire HDX", // 800x1200
"tablet-landscape": "Kindle Fire HDX landscape", // 1280x800
};

var device;
let device;

// check if --phone or --tablet option was passed
Object.keys(availableDevices).forEach(function (item) {
Expand Down

0 comments on commit a74cc03

Please sign in to comment.