mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
docs: fix example formatting in evaluateOnNewDocument (#8906)
This commit is contained in:
parent
32400954c5
commit
6e7c6368d3
@ -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);
|
||||||
```
|
```
|
||||||
|
@ -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);
|
||||||
* ```
|
* ```
|
||||||
|
Loading…
Reference in New Issue
Block a user