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

Set item in localStorage #22

Open
fracz opened this issue Feb 19, 2020 · 1 comment
Open

Set item in localStorage #22

fracz opened this issue Feb 19, 2020 · 1 comment
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@fracz
Copy link

fracz commented Feb 19, 2020

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);'
@sindresorhus
Copy link
Owner

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');
});

@sindresorhus sindresorhus added enhancement New feature or request help wanted Extra attention is needed labels Feb 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants