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

Add preloadFunction option #76

Merged
merged 4 commits into from Feb 16, 2021

Conversation

brandon93s
Copy link
Contributor

Updates from #66; Fixes #48.

I'll follow with corresponding additions to https://github.com/sindresorhus/capture-website-cli.

@brandon93s brandon93s mentioned this pull request Feb 7, 2021
index.d.ts Outdated
@@ -164,6 +164,11 @@ declare namespace captureWebsite {
*/
readonly isJavaScriptEnabled?: boolean;

/**
Inject a function to be executed prior to navigation; useful for [altering the JavaScript environment](https://github.com/puppeteer/puppeteer/blob/main/docs/api.md#pageevaluateonnewdocumentpagefunction-args).
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The readme and index.d.ts docs should be in sync.

readme.md Outdated
Inject a function to be executed prior to navigation.

This can be useful for [altering the JavaScript environment](https://github.com/puppeteer/puppeteer/blob/main/docs/api.md#pageevaluateonnewdocumentpagefunction-args). For example, you could define a global method on the `window`, overwrite `navigator.languages` to change the language presented by the browser, or mock `Math.random` to return a fixed value.

*This option applies only to `captureWebsite.file()`.*
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is misplaced.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤦‍♂️

This can be useful for [altering the JavaScript environment](https://github.com/puppeteer/puppeteer/blob/main/docs/api.md#pageevaluateonnewdocumentpagefunction-args). For example, you could define a global method on the `window`, overwrite `navigator.languages` to change the language presented by the browser, or mock `Math.random` to return a fixed value.
*/
readonly preloadFunction?: EvaluateFn;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

@brandon93s
Copy link
Contributor Author

Documentation has been cleaned up.

@sindresorhus sindresorhus merged commit 9f3e274 into sindresorhus:main Feb 16, 2021
@sindresorhus
Copy link
Owner

sindresorhus commented Feb 16, 2021

I'll follow with corresponding additions to sindresorhus/capture-website-cli.

https://github.com/sindresorhus/capture-website/releases/tag/v1.4.0 Can be done now :)

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

Successfully merging this pull request may close these issues.

Preload script before goto
2 participants