docs: fix example formatting in evaluateOnNewDocument (#8906)

This commit is contained in:
Alex Rudenko 2022-09-06 12:39:55 +02:00 committed by GitHub
parent 32400954c5
commit 6e7c6368d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 8 deletions

View File

@ -43,13 +43,13 @@ An example of overriding the navigator.languages property before the page loads:
// overwrite the `languages` property to use a custom getter // overwrite the `languages` property to use a custom getter
Object.defineProperty(navigator, 'languages', { Object.defineProperty(navigator, 'languages', {
get: function () { get: function () {
return ['en-US', 'en', 'bn']; return ['en-US', 'en', 'bn'];
}, },
}); });
// In your puppeteer script, assuming the preload.js file is // In your puppeteer script, assuming the preload.js file is
in same folder of our script // in same folder of our script.
const preloadFile = fs.readFileSync('./preload.js', 'utf8'); const preloadFile = fs.readFileSync('./preload.js', 'utf8');
await page.evaluateOnNewDocument(preloadFile); await page.evaluateOnNewDocument(preloadFile);
``` ```

View File

@ -2784,13 +2784,13 @@ export class Page extends EventEmitter {
* *
* // overwrite the `languages` property to use a custom getter * // overwrite the `languages` property to use a custom getter
* Object.defineProperty(navigator, 'languages', { * Object.defineProperty(navigator, 'languages', {
* get: function () { * get: function () {
* return ['en-US', 'en', 'bn']; * return ['en-US', 'en', 'bn'];
* }, * },
* }); * });
* *
* // In your puppeteer script, assuming the preload.js file is * // In your puppeteer script, assuming the preload.js file is
* in same folder of our script * // in same folder of our script.
* const preloadFile = fs.readFileSync('./preload.js', 'utf8'); * const preloadFile = fs.readFileSync('./preload.js', 'utf8');
* await page.evaluateOnNewDocument(preloadFile); * await page.evaluateOnNewDocument(preloadFile);
* ``` * ```