0
votes

I'm building a Chrome extension that takes a screenshot of the user's active tab. I want to take both desktop and mobile screenshots.

For Desktop screenshot, I use the the chrome.tabCapture API functions and capture the content of the currently active tab.

How can I take a screenshot for mobile or custom dimensions?

1
Are you saying you want this to work on a mobile device, or that you want the user's screen to be adjusted to mobile dimensions and then another screenshot taken?zero298
I want to adjust the user screen to mobile dimensions and then take another screenshot. And if this process will be visible to the end-user or can be hidden as well.dmraptis

1 Answers

1
votes

You can use chrome.windows.update to force a resize. The received updateInfo object should have the width and height you wish to use. (there is no standard 'mobile' size).

You'd probably want to also -

  1. Store the pre-resize dimensions and restore to it later. You can do it with chrome.windows.getCurrent, and inspect the returned Window for width and height.

  2. Take care to account for toolbars and window margins, to get as close as you can to emulating true mobile experience.