# foo

## API

<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

#### Table of Contents

-   [PuppeteerExtra](#puppeteerextra)
    -   [Examples](#examples)
    -   [use](#use)
    -   [launch](#launch)
    -   [connect](#connect)
    -   [defaultArgs](#defaultargs)
    -   [executablePath](#executablepath)
    -   [createBrowserFetcher](#createbrowserfetcher)
    -   [plugins](#plugins)
    -   [getPluginData](#getplugindata)
-   [defaultExport](#defaultexport)
-   [addExtra](#addextra)
    -   [Parameters](#parameters-6)

### PuppeteerExtra

[\_testing/index.ts:67-463](https://github.com/berstend/documentation-markdown-themes/blob/e0eefde467bc13d45b2a7295d5d69cfbf3d7780e/_testing/index.ts#L67-L463 "Source code on GitHub")

Modular plugin framework to teach `puppeteer` new tricks.

This module acts as a drop-in replacement for `puppeteer`.

Allows PuppeteerExtraPlugin's to register themselves and
to extend puppeteer with additional functionality.

#### Examples

```javascript
const puppeteer = require('puppeteer-extra')
puppeteer.use(require('puppeteer-extra-plugin-anonymize-ua')())
puppeteer.use(require('puppeteer-extra-plugin-font-size')({defaultFontSize: 18}))

;(async () => {
  const browser = await puppeteer.launch({headless: false})
  const page = await browser.newPage()
  await page.goto('http://example.com', {waitUntil: 'domcontentloaded'})
  await browser.close()
})()
```

#### use

[\_testing/index.ts:80-102](https://github.com/berstend/documentation-markdown-themes/blob/e0eefde467bc13d45b2a7295d5d69cfbf3d7780e/_testing/index.ts#L80-L102 "Source code on GitHub")

The **main interface** to register `puppeteer-extra` plugins.

##### Parameters

-   `plugin` **PuppeteerExtraPlugin** 

Returns **this** The same `PuppeteerExtra` instance (for optional chaining)

#### launch

[\_testing/index.ts:142-166](https://github.com/berstend/documentation-markdown-themes/blob/e0eefde467bc13d45b2a7295d5d69cfbf3d7780e/_testing/index.ts#L142-L166 "Source code on GitHub")

The method launches a browser instance with given arguments. The browser will be closed when the parent node.js process is closed.

Augments the original `puppeteer.launch` method with plugin lifecycle methods.

All registered plugins that have a `beforeLaunch` method will be called
in sequence to potentially update the `options` Object before launching the browser.

##### Parameters

-   `options` **Puppeteer.LaunchOptions?** See [puppeteer docs](https://github.com/puppeteer/puppeteer/blob/master/docs/api.md#puppeteerlaunchoptions).

Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)&lt;Puppeteer.Browser>** 

#### connect

[\_testing/index.ts:178-197](https://github.com/berstend/documentation-markdown-themes/blob/e0eefde467bc13d45b2a7295d5d69cfbf3d7780e/_testing/index.ts#L178-L197 "Source code on GitHub")

Attach Puppeteer to an existing Chromium instance.

Augments the original `puppeteer.connect` method with plugin lifecycle methods.

All registered plugins that have a `beforeConnect` method will be called
in sequence to potentially update the `options` Object before launching the browser.

##### Parameters

-   `options` **Puppeteer.ConnectOptions?** See [puppeteer docs](https://github.com/puppeteer/puppeteer/blob/master/docs/api.md#puppeteerconnectoptions).

Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)&lt;Puppeteer.Browser>** 

#### defaultArgs

[\_testing/index.ts:204-206](https://github.com/berstend/documentation-markdown-themes/blob/e0eefde467bc13d45b2a7295d5d69cfbf3d7780e/_testing/index.ts#L204-L206 "Source code on GitHub")

The default flags that Chromium will be launched with.

##### Parameters

-   `options` **Puppeteer.ChromeArgOptions?** See [puppeteer docs](https://github.com/puppeteer/puppeteer/blob/master/docs/api.md#puppeteerdefaultargsoptions).

Returns **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>** 

#### executablePath

[\_testing/index.ts:209-211](https://github.com/berstend/documentation-markdown-themes/blob/e0eefde467bc13d45b2a7295d5d69cfbf3d7780e/_testing/index.ts#L209-L211 "Source code on GitHub")

Path where Puppeteer expects to find bundled Chromium.

Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** 

#### createBrowserFetcher

[\_testing/index.ts:218-222](https://github.com/berstend/documentation-markdown-themes/blob/e0eefde467bc13d45b2a7295d5d69cfbf3d7780e/_testing/index.ts#L218-L222 "Source code on GitHub")

This methods attaches Puppeteer to an existing Chromium instance.

##### Parameters

-   `options` **Puppeteer.FetcherOptions?** See [puppeteer docs](https://github.com/puppeteer/puppeteer/blob/master/docs/api.md#puppeteercreatebrowserfetcheroptions).

Returns **Puppeteer.BrowserFetcher** 

#### plugins

[\_testing/index.ts:272-274](https://github.com/berstend/documentation-markdown-themes/blob/e0eefde467bc13d45b2a7295d5d69cfbf3d7780e/_testing/index.ts#L272-L274 "Source code on GitHub")

Get all registered plugins.

Type: [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;PuppeteerExtraPlugin>

#### getPluginData

[\_testing/index.ts:299-304](https://github.com/berstend/documentation-markdown-themes/blob/e0eefde467bc13d45b2a7295d5d69cfbf3d7780e/_testing/index.ts#L299-L304 "Source code on GitHub")

-   **See: puppeteer-extra-plugin/data**

Collects the exposed `data` property of all registered plugins.
Will be reduced/flattened to a single array.

Can be accessed by plugins that listed the `dataFromPlugins` requirement.

Implemented mainly for plugins that need data from other plugins (e.g. `user-preferences`).

##### Parameters

-   `name` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Filter data by optional plugin name

### defaultExport

[\_testing/index.ts:484-486](https://github.com/berstend/documentation-markdown-themes/blob/e0eefde467bc13d45b2a7295d5d69cfbf3d7780e/_testing/index.ts#L484-L486 "Source code on GitHub")

The **default export** will behave exactly the same as the regular puppeteer
(just with extra plugin functionality) and can be used as a drop-in replacement.

Behind the scenes it will try to require either `puppeteer`
or [`puppeteer-core`](https://github.com/puppeteer/puppeteer/blob/master/docs/api.md#puppeteer-vs-puppeteer-core)
from the installed dependencies.

```js
// javascript import
const puppeteer = require('puppeteer-extra')

// typescript/es6 module import
import puppeteer from 'puppeteer-extra'

// Add plugins
puppeteer.use(...)
```

Type: [PuppeteerExtra](#puppeteerextra)

### addExtra

[\_testing/index.ts:508-509](https://github.com/berstend/documentation-markdown-themes/blob/e0eefde467bc13d45b2a7295d5d69cfbf3d7780e/_testing/index.ts#L508-L509 "Source code on GitHub")

An **alternative way** to use `puppeteer-extra`: Augments the provided puppeteer with extra plugin functionality.

This is useful in case you need multiple puppeteer instances with different plugins or to add plugins to a non-standard puppeteer package.

```js
// js import
const { addExtra } = require('puppeteer-extra')

// ts/es6 import
import { addExtra } from 'puppeteer-extra'

// Patch e.g. puppeteer-firefox and add plugins
const puppeteer = addExtra(require('puppeteer-firefox'))
puppeteer.use(...)
```

#### Parameters

-   `puppeteer` **VanillaPuppeteer** Any puppeteer API-compatible puppeteer implementation or version.
