Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feat] Add ability to customize viewport width/height #1242

Open
mauryaratan opened this issue Feb 22, 2025 · 0 comments
Open

[Feat] Add ability to customize viewport width/height #1242

mauryaratan opened this issue Feb 22, 2025 · 0 comments

Comments

@mauryaratan
Copy link

Problem Description
Looks like the current browser viewport is 1920px, which isn't ideal in all scenarios where you need to take a screenshot. I generally take most screenshot, if any, at 1440px. Though would love a way to change the viewport size here.

Proposed Feature
Add a way to specify width/height.

Alternatives Considered
I currently have a workaround, but it won't fit all use cases.
Currently for /scrape, I take a full page screenshot which is currently 1920px, but most sites I intend to visit fit under 1440px width and generally looks better in the screenshot.
My workaround right now is:

  • Add a JS steps in /scrape endpoint with the code: window.document.documentElement.style.setProperty('width', '1440px');
  • This resizes the window and sticks the screenshot to left, leaving extra space on the right, though viewport remains the same
  • Then using Cloudflare image transformation, I'm trimming the image on the right by 480px
  • This trims the images nicely but is prone to error if future needs change + can't use transformation in each case

Implementation Suggestions
An argument to specify viewport width in either actions, or request body. Maybe introduce a new optional browserOptions parameter which can take several browser level customizations?!

Use Case
Taking a screenshot is already very handy while scraping, allowing to customize the viewport size would make it further useful in several contexts e.g. testing responsiveness, preparing consistent reports with fixed screenshot size etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant