# foo

## API

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

#### Table of Contents

-   [class: PuppeteerExtra](#class-puppeteerextra)
    -   [.use(plugin)](#useplugin)
    -   [.launch(options?)](#launchoptions)
    -   [.connect(options?)](#connectoptions)
    -   [.defaultArgs(options?)](#defaultargsoptions)
    -   [.executablePath()](#executablepath)
    -   [.createBrowserFetcher(options?)](#createbrowserfetcheroptions)
    -   [.plugins](#plugins)
    -   [.getPluginData(name?)](#getplugindataname)
-   [defaultExport()](#defaultexport)
-   [addExtra(puppeteer)](#addextrapuppeteer)

### class: [PuppeteerExtra](https://github.com/berstend/documentation-markdown-themes/blob/e0eefde467bc13d45b2a7295d5d69cfbf3d7780e/_testing/index.ts#L67-L465)

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.

Example:

```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(plugin)](https://github.com/berstend/documentation-markdown-themes/blob/e0eefde467bc13d45b2a7295d5d69cfbf3d7780e/_testing/index.ts#L80-L102)

-   `plugin` **PuppeteerExtraPlugin** 

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

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

* * *

#### .[launch(options?)](https://github.com/berstend/documentation-markdown-themes/blob/e0eefde467bc13d45b2a7295d5d69cfbf3d7780e/_testing/index.ts#L142-L166)

-   `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>** 

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.

* * *

#### .[connect(options?)](https://github.com/berstend/documentation-markdown-themes/blob/e0eefde467bc13d45b2a7295d5d69cfbf3d7780e/_testing/index.ts#L178-L197)

-   `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>** 

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.

* * *

#### .[defaultArgs(options?)](https://github.com/berstend/documentation-markdown-themes/blob/e0eefde467bc13d45b2a7295d5d69cfbf3d7780e/_testing/index.ts#L204-L206)

-   `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)>** 

The default flags that Chromium will be launched with.

* * *

#### .[executablePath()](https://github.com/berstend/documentation-markdown-themes/blob/e0eefde467bc13d45b2a7295d5d69cfbf3d7780e/_testing/index.ts#L209-L211)

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

Path where Puppeteer expects to find bundled Chromium.

* * *

#### .[createBrowserFetcher(options?)](https://github.com/berstend/documentation-markdown-themes/blob/e0eefde467bc13d45b2a7295d5d69cfbf3d7780e/_testing/index.ts#L218-L222)

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

Returns: **Puppeteer.BrowserFetcher** 

This methods attaches Puppeteer to an existing Chromium instance.

* * *

#### .[plugins](https://github.com/berstend/documentation-markdown-themes/blob/e0eefde467bc13d45b2a7295d5d69cfbf3d7780e/_testing/index.ts#L272-L274)

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

Get all registered plugins.

* * *

#### .[getPluginData(name?)](https://github.com/berstend/documentation-markdown-themes/blob/e0eefde467bc13d45b2a7295d5d69cfbf3d7780e/_testing/index.ts#L299-L304)

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

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`).

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

* * *

### [defaultExport()](https://github.com/berstend/documentation-markdown-themes/blob/e0eefde467bc13d45b2a7295d5d69cfbf3d7780e/_testing/index.ts#L486-L488)

Type: **[PuppeteerExtra](#puppeteerextra)**

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(...)
```

* * *

### [addExtra(puppeteer)](https://github.com/berstend/documentation-markdown-themes/blob/e0eefde467bc13d45b2a7295d5d69cfbf3d7780e/_testing/index.ts#L511-L512)

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

Returns: **[PuppeteerExtra](#puppeteerextra)** A fresh PuppeteerExtra instance using the provided puppeteer

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(...)
```

* * *
