sindresorhus/capture-website-cli

Set item in localStorage

fracz opened this issue · 1 comments

fracz commented

Is it possible to set an item in local storage prior to the website rendering? The --script argument seems to be executing the code after the page loads.

capture-website https://site.com --output site.png --script='localStorage.setItem("showSomething",false);'

Not currently possible, but I'm open to adding a flag (option) for it. Not sure how the flag should handle both a key and value though.

On the API side, it's just taking the given key/value pairs and running this after page.goto:

await page.evaluate(() => {
	localStorage.setItem('token', 'example-token');
});