{"_id":"automation-extra-plugin","_rev":"4-c2c24d827999e5e20423f1dc224bf46d","name":"automation-extra-plugin","dist-tags":{"next":"4.2.2-next.616","latest":"4.2.1-next.587"},"versions":{"4.2.1-next.587":{"name":"automation-extra-plugin","version":"4.2.1-next.587","description":"Base class for automation-extra plugins (supports Playwright and Puppeteer).","main":"dist/index.cjs.js","module":"dist/index.esm.js","typings":"dist/index.d.ts","repository":{"type":"git","url":"git+https://github.com/berstend/puppeteer-extra.git"},"homepage":"https://github.com/berstend/puppeteer-extra/tree/master/packages/automation-extra-plugin","author":{"name":"berstend"},"license":"MIT","scripts":{"clean":"rimraf dist/*","prebuild":"run-s clean","build":"run-s build:tsc build:rollup","build:tsc":"tsc --module commonjs","build:rollup":"rollup -c rollup.config.ts","docs":"documentation readme --quiet --shallow --github --markdown-theme transitivebs --readme-file readme.md --section API ./src/index.ts","postdocs":"npx prettier --write readme.md","test:ts":"ava -v --config ava.config-ts.js","test:js":"ava -v --serial --concurrency 1 --fail-fast","test":"run-p test:js test:ts","pretest-ci":"run-s build","test-ci":"run-p lint test","lint:js":"eslint --no-error-on-unmatched-pattern --ext .js src/ test/","lint:ts":"tslint --project tsconfig.json","lint":"run-p lint:js lint:ts"},"engines":{"node":">=12"},"prettier":{"printWidth":80,"semi":false,"singleQuote":true},"keywords":["puppeteer","puppeteer-extra","playwright-extra","playwright","automation-extra-plugin","ua","user-agent","chrome","headless","pupeteer"],"devDependencies":{"@types/node":"^13.1.4","ava":"2.4.0","documentation-markdown-themes":"13.1.2","npm-run-all":"^4.1.5","rimraf":"^3.0.0","rollup":"^1.27.5","rollup-plugin-commonjs":"^10.1.0","rollup-plugin-node-resolve":"^5.2.0","rollup-plugin-sourcemaps":"^0.4.2","rollup-plugin-typescript2":"0.29.0","ts-node":"^8.5.4","tslint":"^5.12.1","tslint-config-prettier":"^1.18.0","tslint-config-standard":"^9.0.0","typescript":"4.1.2"},"dependencies":{"@types/debug":"^4.1.0","@types/puppeteer":"5.4.3","debug":"^4.1.1","deepmerge":"^4.2.2","is-plain-object":"^5.0.0","playwright-core":"1.8.0"},"gitHead":"03bcc0821d16e3f32190471e3e6e30b9f04d8710","bugs":{"url":"https://github.com/berstend/puppeteer-extra/issues"},"_id":"automation-extra-plugin@4.2.1-next.587","_nodeVersion":"15.3.0","_npmVersion":"lerna/3.22.1/node@v15.3.0+x64 (darwin)","_npmUser":{"name":"berstend","email":"e.ndze.it@gmail.com"},"dist":{"integrity":"sha512-1aW4DrRhd9WSkWvLrz2UXx65nDM0QtmAlH32wIMjUld+ouX2FjN3YySA2XeYzBC/yFf45keZryrmivPQDk2TiQ==","shasum":"2f487787fc3589d369d635b2442c7f5e14e5ca46","tarball":"https://registry.npmjs.org/automation-extra-plugin/-/automation-extra-plugin-4.2.1-next.587.tgz","fileCount":16,"unpackedSize":169189,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgIUv2CRA9TVsSAnZWagAAGgEP/3d7CcQoQQJBC5ZJwaHw\nIh7eKyiP4izzBhjeGqGNd5elGt9kXN296b/GxU2ECLRloV63vi8bM3emU+9d\nO0A9Z5awUIWtnxcNovuA3z4otbQbk3PiZDh4hYkW5a7dj8CawxBLTzQ6jEuw\nlZRje6g+hOKZOHFOlvHUDivug1JQPtSqqkjOcNUv95Pmvqvh0fmU5XGjlqtd\nDVltCJA51jvq0rxIJ39Za2V4au8EIl2sDnA/dfRZRDv1a4vhMHR/GHEkGcsf\nWINqFs5t/hX8BOohNcr1unBiTc95VKBwqlIQXPz2aevFR78Bvm6kbjTWOd7d\nAMr5e8Sq8LI9GkT6B13NoWltCA9QEPus58L3jZ+/gtx5JO4PCKqby1ylnKEB\n3kAcA0Ue598g9lEAZcxZgVrPiR8cz0o3WeCDi8j2MYWro1a/mEVujlkxEQ7D\nKsLogc8TcPWSn3frTaEMKWOmnl0ysupZH11Zde2E45JmmH1ll+Qvu1ZPhzo6\nwK1hvyDsjn//gDM125R5u++UNYobeuaoItNkWmBybIh4zynMIxt9kUnRha3m\nJqIIPKubYfM/x8xA/pSVVqVHKzPJIAkHNeaYbWxLf13z9oQM2OcGtcTiqi7p\n4vkEQJtA0Cjvk3qi7wn0xZuWwrZV+JEzL4pqI+b2zYrU3MD+NsssGcEkhbCQ\nqPie\r\n=lrS2\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCZb+o+rt5nLzXS6Yh2DskXSWE1CHMJtJsA37uWYV/uswIhAM0pqFUPCr2KMp41WFl7EieQRGryIEQ7RyE2iT5N5sNv"}]},"directories":{},"maintainers":[{"name":"berstend","email":"e.ndze.it@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/automation-extra-plugin_4.2.1-next.587_1612794870392_0.20748281342484942"},"_hasShrinkwrap":false},"4.2.2-next.593":{"name":"automation-extra-plugin","version":"4.2.2-next.593","description":"Base class for automation-extra plugins (supports Playwright and Puppeteer).","main":"dist/index.cjs.js","module":"dist/index.esm.js","typings":"dist/index.d.ts","repository":{"type":"git","url":"git+https://github.com/berstend/puppeteer-extra.git"},"homepage":"https://github.com/berstend/puppeteer-extra/tree/master/packages/automation-extra-plugin","author":{"name":"berstend"},"license":"MIT","scripts":{"clean":"rimraf dist/*","prebuild":"run-s clean","build":"run-s build:tsc build:rollup","build:tsc":"tsc --module commonjs","build:rollup":"rollup -c rollup.config.ts","docs":"documentation readme --quiet --shallow --github --markdown-theme transitivebs --readme-file readme.md --section API ./src/index.ts","postdocs":"npx prettier --write readme.md","test:ts":"ava -v --config ava.config-ts.js","test:js":"ava -v --serial --concurrency 1 --fail-fast","test":"run-p test:js test:ts","pretest-ci":"run-s build","test-ci":"run-p lint test","lint:js":"eslint --no-error-on-unmatched-pattern --ext .js src/ test/","lint:ts":"tslint --project tsconfig.json","lint":"run-p lint:js lint:ts"},"engines":{"node":">=12"},"prettier":{"printWidth":80,"semi":false,"singleQuote":true},"keywords":["puppeteer","puppeteer-extra","playwright-extra","playwright","automation-extra-plugin","ua","user-agent","chrome","headless","pupeteer"],"devDependencies":{"@types/node":"^13.1.4","ava":"2.4.0","documentation-markdown-themes":"13.1.2","npm-run-all":"^4.1.5","rimraf":"^3.0.0","rollup":"^1.27.5","rollup-plugin-commonjs":"^10.1.0","rollup-plugin-node-resolve":"^5.2.0","rollup-plugin-sourcemaps":"^0.4.2","rollup-plugin-typescript2":"0.29.0","ts-node":"^8.5.4","tslint":"^5.12.1","tslint-config-prettier":"^1.18.0","tslint-config-standard":"^9.0.0","typescript":"4.1.2"},"dependencies":{"@types/debug":"^4.1.0","@types/puppeteer":"5.4.3","debug":"^4.1.1","deepmerge":"^4.2.2","is-plain-object":"^5.0.0","playwright-core":"1.8.0"},"gitHead":"35c62f372672ee1a329492257766a6deaf292192","readme":"# automation-extra-plugin [![GitHub Workflow Status](https://img.shields.io/github/workflow/status/berstend/puppeteer-extra/Test/master)](https://github.com/berstend/puppeteer-extra/actions) [![Discord](https://img.shields.io/discord/737009125862408274)](http://scraping-chat.cf) [![npm](https://img.shields.io/npm/v/automation-extra-plugin.svg)](https://www.npmjs.com/package/automation-extra-plugin)\n\n> Base class to develop plugins for [automation-extra].\n\n## Installation\n\n```bash\nyarn add automation-extra-plugin\n```\n\n<details>\n <summary>Changelog</summary>\n\n- v4.1\n  - Initial public release\n\n</details>\n\n## Features\n\n- Supports [playwright-extra] as well as [puppeteer-extra]\n- Uses lifecycle events to hook into Puppeteer & Playwright execution\n- Ships with `this.env` and type guards to make multi-browser, multi-driver plugin development a breeze\n- Written in TypeScript (which means helpful auto-complete even if you're writing your plugins in JS)\n- Successor to `puppeteer-extra-plugin`, which only supports Puppeteer\n\n## Example\n\n```js\nconst { AutomationExtraPlugin } = require('automation-extra-plugin')\n\nclass DemoPlugin extends AutomationExtraPlugin {\n  constructor(opts = {}) {\n    super(opts)\n  }\n\n  static get id() {\n    return 'demo'\n  }\n\n  async beforeLaunch(options) {\n    // Modify launch options\n    options.headless = false\n  }\n\n  async onBrowser(browser) {\n    // Become aware of browser launch/connect\n    console.log('onBrowser:', {\n      driverName: this.env.driverName,\n      browserName: this.env.browserName,\n    })\n  }\n\n  async onPageCreated(page) {\n    // Hook into page events\n    console.log('Page created:', page.url())\n    page.on('load', () => {\n      console.log('Page loaded', page.url())\n    })\n    // Use a shim which unifies page.evaluateOnNewDocument and page.addInitScript\n    this.shim(page).addScript(() => {\n      navigator.alice = 'bob'\n    })\n  }\n}\n\nconst demo = new DemoPlugin()\n```\n\nUse the plugin with Puppeteer:\n\n```js\nconst puppeteer = require('puppeteer-extra')\n\npuppeteer.use(demo) // that's it :-)\npuppeteer.launch({ headless: true }).then(async (browser) => {\n  const page = await browser.newPage()\n  await page.goto('https://example.com', { waitUntil: 'load' })\n  const alice = await page.evaluate(() => navigator.alice)\n  console.log(alice) // ==> bob\n  await browser.close()\n})\n```\n\nUse the same plugin with Playwright (chromium and webkit are supported as well):\n\n```js\nconst { firefox } = require('playwright-extra')\n\nfirefox.use(demo) // that's it :-)\nfirefox.launch({ headless: true }).then(async (browser) => {\n  // ... same code as above\n})\n```\n\n## Contributing\n\nIf you're interested in releasing your plugin under the `@extra` organization please reach out to us through an issue or on our discord server. :-)\n\n## API\n\n<!--\n    Documentation is auto-generated by a custom fork of documentation.js\n    More info: https://github.com/berstend/documentation-markdown-themes/wiki#documentationjs-with-markdown-theme-support\n    Update this documentation by updating the source code.\n-->\n\n#### Table of Contents\n\n- [class: PluginLifecycleMethods](#class-pluginlifecyclemethods)\n  - [.onPluginRegistered()](#onpluginregistered)\n  - [.beforeLaunch(options)](#beforelaunchoptions)\n  - [.afterLaunch(browser, launchContext)](#afterlaunchbrowser-launchcontext)\n  - [.beforeConnect(options)](#beforeconnectoptions)\n  - [.afterConnect(browser, launchContext)](#afterconnectbrowser-launchcontext)\n  - [.onBrowser(browser, launchContext)](#onbrowserbrowser-launchcontext)\n  - [.beforeContext(options, browser)](#beforecontextoptions-browser)\n  - [.onContextCreated(context, options)](#oncontextcreatedcontext-options)\n  - [.onPageCreated(page)](#onpagecreatedpage)\n  - [.onPageClose(page)](#onpageclosepage)\n  - [.onContextClose(context)](#oncontextclosecontext)\n  - [.onDisconnected(browser)](#ondisconnectedbrowser)\n- [class: AutomationExtraPlugin](#class-automationextraplugin)\n  - [.env](#env)\n  - [.shim(page)](#shimpage)\n  - [.defaults](#defaults)\n  - [.requirements](#requirements)\n  - [.filter](#filter)\n  - [.dependencies](#dependencies)\n  - [.plugins](#plugins)\n  - [.opts](#opts)\n  - [.debug](#debug)\n  - [.id](#id)\n- [class: TypeGuards](#class-typeguards)\n  - [.isPage(obj)](#ispageobj)\n  - [.isBrowser(obj)](#isbrowserobj)\n  - [.isPuppeteerPage(obj)](#ispuppeteerpageobj)\n  - [.isPuppeteerBrowser(obj)](#ispuppeteerbrowserobj)\n  - [.isPuppeteerBrowserContext(obj)](#ispuppeteerbrowsercontextobj)\n  - [.isPlaywrightPage(obj)](#isplaywrightpageobj)\n  - [.isPlaywrightBrowser(obj)](#isplaywrightbrowserobj)\n  - [.isPlaywrightBrowserContext(obj)](#isplaywrightbrowsercontextobj)\n- [class: LauncherEnv](#class-launcherenv)\n  - [.driverName](#drivername)\n  - [.browserName](#browsername)\n  - [.isPuppeteer](#ispuppeteer)\n  - [.isPlaywright](#isplaywright)\n  - [.isChromium](#ischromium)\n  - [.isFirefox](#isfirefox)\n  - [.isWebkit](#iswebkit)\n  - [.isBrowserKnown](#isbrowserknown)\n- [class: PageShim](#class-pageshim)\n  - [.addScript(script, arg?)](#addscriptscript-arg)\n\n### class: [PluginLifecycleMethods](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L74-L241)\n\nPlugin lifecycle methods used by AutomationExtraPlugin.\n\nThese are hooking into Playwright/Puppeteer events and are meant to be overriden\non a per-need basis in your own plugin extending AutomationExtraPlugin.\n\n---\n\n#### .[onPluginRegistered()](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L78-L78)\n\nReturns: **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)&lt;void>**\n\nAfter the plugin has been registered, called early in the life-cycle (once the plugin has been added).\n\n---\n\n#### .[beforeLaunch(options)](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L97-L97)\n\n- `options` **LaunchOptions** Puppeteer/Playwright launch options\n\nReturns: **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)&lt;(LaunchOptions | void)>**\n\nBefore a new browser instance is created/launched.\n\nCan be used to modify the puppeteer/playwright launch options by modifying or returning them.\n\nPlugins using this method will be called in sequence to each\nbe able to update the launch options.\n\nExample:\n\n```javascript\nasync beforeLaunch (options) {\n  if (this.opts.flashPluginPath) {\n    options.args = options.args || []\n    options.args.push(`--ppapi-flash-path=${this.opts.flashPluginPath}`)\n  }\n}\n```\n\n---\n\n#### .[afterLaunch(browser, launchContext)](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L125-L125)\n\n- `browser` **Browser** The `puppeteer` or `playwright` browser instance.\n- `launchContext` **LaunchContext**\n\nAfter the browser has launched.\n\nNote: Don't assume that there will only be a single browser instance during the lifecycle of a plugin.\nIt's possible that `pupeeteer.launch` will be called multiple times and more than one browser created.\nIn order to make the plugins as stateless as possible don't store a reference to the browser instance\nin the plugin but rather consider alternatives.\n\nE.g. when using `onPageCreated` you can get a browser reference by using `page.browser()`.\n\nAlternatively you could expose a class method that takes a browser instance as a parameter to work with:\n\n```es6\nconst fancyPlugin = require('puppeteer-extra-plugin-fancy')()\npuppeteer.use(fancyPlugin)\nconst browser = await puppeteer.launch()\nawait fancyPlugin.killBrowser(browser)\n```\n\nExample:\n\n```javascript\nasync afterLaunch (browser, opts) {\n  this.debug('browser has been launched', opts.options)\n}\n```\n\n---\n\n#### .[beforeConnect(options)](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L137-L139)\n\n- `options` **ConnectOptions** Puppeteer/playwright connect options\n\nReturns: **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)&lt;(ConnectOptions | void)>**\n\nBefore connecting to an existing browser instance.\n\nCan be used to modify the puppeteer/playwright connect options by modifying or returning them.\n\nPlugins using this method will be called in sequence to each\nbe able to update the launch options.\n\n---\n\n#### .[afterConnect(browser, launchContext)](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L149-L149)\n\n- `browser` **Browser** The `puppeteer` or playwright browser instance.\n- `launchContext` **LaunchContext**\n\nAfter connecting to an existing browser instance.\n\n> Note: Don't assume that there will only be a single browser instance during the lifecycle of a plugin.\n\n---\n\n#### .[onBrowser(browser, launchContext)](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L163-L163)\n\n- `browser` **Browser** The `puppeteer` or `playwright` browser instance.\n- `launchContext` **LaunchContext**\n\nCalled when a browser instance is available.\n\nThis applies to both `launch` and `connect`.\n\nConvenience method created for plugins that need access to a browser instance\nand don't mind if it has been created through `launch` or `connect`.\n\n> Note: Don't assume that there will only be a single browser instance during the lifecycle of a plugin.\n\n---\n\n#### .[beforeContext(options, browser)](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L178-L181)\n\n- `options` **Playwright.BrowserContextOptions** Playwright browser context options\n- `browser` **Playwright.Browser** Playwright browser\n\nReturns: **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)&lt;(Playwright.BrowserContextOptions | void)>**\n\nBefore a new browser context is created.\n\nNote: Currently only triggered by `playwright`, as puppeteer's usage of context is very lackluster.\n\nPlugins using this method will be called in sequence to each\nbe able to update the context options.\n\n- **See: <https://github.com/microsoft/playwright/blob/master/docs/api.md#browsernewcontextoptions>**\n\n---\n\n#### .[onContextCreated(context, options)](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L191-L194)\n\n- `context` **Playwright.BrowserContext** Playwright browser context\n- `options` **Playwright.BrowserContextOptions** Playwright browser context options\n\nAfter a new browser context has been created.\n\nNote: `playwright` specific.\n\n---\n\n#### .[onPageCreated(page)](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L215-L215)\n\n- `page` **(Puppeteer.Page | Playwright.Page)**\n\nCalled when a page has been created.\n\nThe event will also fire for popup pages.\n\nExample:\n\n```javascript\nasync onPageCreated (page) {\n  let ua = await page.browser().userAgent()\n  if (this.opts.stripHeadless) {\n    ua = ua.replace('HeadlessChrome/', 'Chrome/')\n  }\n  this.debug('new ua', ua)\n  await page.setUserAgent(ua)\n}\n```\n\n- **See: <https://playwright.dev/#version=v1.3.0&path=docs%2Fapi.md&q=event-page>**\n- **See: <https://pptr.dev/#?product=Puppeteer&version=main&show=api-event-targetcreated>**\n\n---\n\n#### .[onPageClose(page)](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L221-L221)\n\n- `page` **Page**\n\nCalled when a page has been closed.\n\n---\n\n#### .[onContextClose(context)](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L229-L229)\n\n- `context` **Playwright.BrowserContext**\n\nCalled when a browser context has been closed.\n\nNote: `playwright` specific.\n\n---\n\n#### .[onDisconnected(browser)](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L240-L240)\n\n- `browser` **Browser** The `puppeteer` or `playwright` browser instance.\n\nCalled when the browser got disconnected.\n\nThis might happen because of one of the following:\n\n- The browser is closed or crashed\n- The `browser.disconnect` method was called\n\n---\n\n### class: [AutomationExtraPlugin](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L263-L487)\n\n**Extends: PluginLifecycleMethods**\n\nAutomationExtraPlugin - Meant to be used as a base class and it's methods overridden.\n\nImplements all `PluginLifecycleMethods`.\n\nExample:\n\n```javascript\nclass Plugin extends AutomationExtraPlugin {\n  static id = 'foobar'\n  constructor(opts = {}) {\n    super(opts)\n  }\n\n  async beforeLaunch(options) {\n    options.headless = false\n    return options\n  }\n}\n```\n\n---\n\n#### .[env](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L291-L291)\n\nType: **[LauncherEnv](#launcherenv)**\n\nContains info regarding the launcher environment the plugin runs in\n\n- **See: LauncherEnv**\n\n---\n\n#### .[shim(page)](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L323-L323)\n\n- `page` **Page**\n\nReturns: **[PageShim](#pageshim)**\n\nUnified Page methods for Playwright & Puppeteer\n\n---\n\n#### .[defaults](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L352-L354)\n\nType: **PluginOptions**\n\nPlugin defaults (optional).\n\nIf defined will be ([deep-](https://github.com/TehShrike/deepmerge))merged with the (optional) user supplied options (supplied during plugin instantiation).\n\nThe result of merging defaults with user supplied options can be accessed through `this.opts`.\n\nExample:\n\n```javascript\nget defaults () {\n  return {\n    stripHeadless: true,\n    makeWindows: true,\n    customFn: null\n  }\n}\n\n// Users can overwrite plugin defaults during instantiation:\npuppeteer.use(require('puppeteer-extra-plugin-foobar')({ makeWindows: false }))\n```\n\n- **See: \\[[opts]]**\n\n---\n\n#### .[requirements](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L380-L382)\n\nType: **PluginRequirements**\n\nPlugin requirements (optional).\n\nSignal certain plugin requirements to the base class and the user.\n\nCurrently supported:\n\n- `launch`\n  - If the plugin only supports locally created browser instances (no `puppeteer.connect()`),\n    will output a warning to the user.\n- `headful`\n  - If the plugin doesn't work in `headless: true` mode,\n    will output a warning to the user.\n- `runLast`\n  - In case the plugin prefers to run after the others.\n    Useful when the plugin needs data from others.\n\nExample:\n\n```javascript\nget requirements () {\n  return new Set(['runLast', 'dataFromPlugins'])\n}\n```\n\n---\n\n#### .[filter](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L399-L401)\n\nType: **(Filter | [undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined))**\n\nPlugin filter statements (optional).\n\nFilter this plugin from being called depending on the environment.\n\nExample:\n\n```javascript\nget filter() {\n  return {\n    include: ['playwright:chromium', 'puppeteer:chromium']\n  }\n}\n```\n\n---\n\n#### .[dependencies](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L423-L425)\n\nType: **PluginDependencies**\n\nPlugin dependencies (optional).\n\nMissing plugins will be required() by automation-extra.\n\nExample:\n\n```javascript\n// Will ensure the 'puppeteer-extra-plugin-user-preferences' plugin is loaded.\nget dependencies () {\n  return new Set(['user-preferences'])\n}\n\n// Will load `user-preferences` plugin and pass `{ beCool: true }` as opts\nget dependencies () {\n  return new Map([['user-preferences', { beCool: true }]])\n}\n```\n\n---\n\n#### .[plugins](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L438-L440)\n\nType: **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;AutomationExtraPluginInstance>**\n\nAdd additional plugins (optional).\n\nExpects an array of AutomationExtraPlugin instances, not classes.\nThis is intended to be used by \"meta\" plugins that use other plugins behind the scenes.\n\nThe benefit over using `dependencies` is that this doesn't use the framework for dynamic imports,\nbut requires explicit imports which bundlers like webkit handle much better.\n\nMissing plugins listed here will be added at the start of `launch` or `connect` events.\n\n---\n\n#### .[opts](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L457-L459)\n\nType: **PluginOptions**\n\nAccess the plugin options (usually the `defaults` merged with user defined options)\n\nTo skip the auto-merging of defaults with user supplied opts don't define a `defaults`\nproperty and set the `this._opts` Object in your plugin constructor directly.\n\nExample:\n\n```javascript\nget defaults () { return { foo: \"bar\" } }\n\nasync onPageCreated (page) {\n  this.debug(this.opts.foo) // => bar\n}\n```\n\n- **See: \\[[defaults]]**\n\n---\n\n#### .[debug](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L477-L479)\n\nType: **Debugger**\n\nConvenience debug logger based on the [debug] module.\nWill automatically namespace the logging output to the plugin package name.\n\n[debug]: https://www.npmjs.com/package/debug\n\n```bash\n# toggle output using environment variables\nDEBUG=automation-extra-plugin:<plugin_id> node foo.js\n# to debug all the things:\nDEBUG=automation-extra,automation-extra-plugin:* node foo.js\n```\n\nExample:\n\n```javascript\nthis.debug('hello world')\n// will output e.g. 'automation-extra-plugin:anonymize-ua hello world'\n```\n\n---\n\n#### .[id](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L285-L285)\n\nPlugin id/name (required)\n\nConvention:\n\n- Package: `automation-extra-plugin-anonymize-ua`\n- Name: `anonymize-ua`\n\nExample:\n\n```javascript\nstatic id = 'anonymize-ua';\n// or\nstatic get id() {\n  return 'anonymize-ua'\n}\n```\n\n---\n\n### class: [TypeGuards](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L501-L566)\n\nTypeGuards: They allow differentiating between different objects and types.\n\nType guards work by discriminating against properties only found in that specific type.\nThis is especially useful when used with TypeScript as it improves type safety.\n\n---\n\n#### .[isPage(obj)](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L507-L509)\n\n- `obj` **any** The object to test\n\nReturns: **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)**\n\nType guard, will make TypeScript understand which type we're working with.\n\n---\n\n#### .[isBrowser(obj)](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L515-L517)\n\n- `obj` **any** The object to test\n\nReturns: **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)**\n\nType guard, will make TypeScript understand which type we're working with.\n\n---\n\n#### .[isPuppeteerPage(obj)](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L523-L525)\n\n- `obj` **any** The object to test\n\nReturns: **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)**\n\nType guard, will make TypeScript understand which type we're working with.\n\n---\n\n#### .[isPuppeteerBrowser(obj)](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L531-L533)\n\n- `obj` **any** The object to test\n\nReturns: **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)**\n\nType guard, will make TypeScript understand which type we're working with.\n\n---\n\n#### .[isPuppeteerBrowserContext(obj)](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L539-L541)\n\n- `obj` **any** The object to test\n\nReturns: **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)**\n\nType guard, will make TypeScript understand which type we're working with.\n\n---\n\n#### .[isPlaywrightPage(obj)](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L547-L549)\n\n- `obj` **any** The object to test\n\nReturns: **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)**\n\nType guard, will make TypeScript understand which type we're working with.\n\n---\n\n#### .[isPlaywrightBrowser(obj)](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L555-L557)\n\n- `obj` **any** The object to test\n\nReturns: **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)**\n\nType guard, will make TypeScript understand which type we're working with.\n\n---\n\n#### .[isPlaywrightBrowserContext(obj)](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L563-L565)\n\n- `obj` **any** The object to test\n\nReturns: **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)**\n\nType guard, will make TypeScript understand which type we're working with.\n\n---\n\n### class: [LauncherEnv](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L575-L622)\n\n**Extends: TypeGuards**\n\nStores environment specific info, populated by the launcher.\nThis allows sane plugin development in a multi-browser, multi-driver environment.\n\n---\n\n#### .[driverName](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L579-L579)\n\nThe name of the driver currently in use: `\"playwright\" | \"puppeteer\"`.\n\n---\n\n#### .[browserName](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L587-L587)\n\nThe name of the browser engine currently in use: `\"chromium\" | \"firefox\" | \"webkit\" | \"unknown\"`.\n\nNote: With puppeteer the browser will only be known once a browser object is available (after launching or connecting),\nas they support defining the browser during `.launch()`.\n\n---\n\n#### .[isPuppeteer](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L599-L601)\n\nCheck if current driver is puppeteer\n\n---\n\n#### .[isPlaywright](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L603-L605)\n\nCheck if current driver is playwright\n\n---\n\n#### .[isChromium](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L607-L609)\n\nCheck if current browser is chrome or chromium\n\n---\n\n#### .[isFirefox](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L611-L613)\n\nCheck if current browser is firefox\n\n---\n\n#### .[isWebkit](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L615-L617)\n\nCheck if current browser is webkit\n\n---\n\n#### .[isBrowserKnown](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L619-L621)\n\nCheck if current browser is known\n\n---\n\n### class: [PageShim](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L636-L666)\n\nUnified Page methods for Playwright & Puppeteer.\nThey support common actions through a single API.\n\n---\n\n#### .[addScript(script, arg?)](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L657-L665)\n\n- `script` **([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) \\| [Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function))**\n- `arg` **Serializable?**\n\nAdds a script which would be evaluated in one of the following scenarios:\n\nWhenever the page is navigated.\nWhenever the child frame is attached or navigated. In this case, the script is evaluated in the context of the newly attached frame.\n\nThe script is evaluated after the document was created but before any of its scripts were run.\n\n- **See: **Playwright:** `addInitScript`\n  **Puppeteer:** `evaluateOnNewDocument`**\n\n---\n\n## License\n\nCopyright © 2018 - 2021, [berstend̡̲̫̹̠̖͚͓̔̄̓̐̄͛̀͘](https://github.com/berstend). Released under the MIT License.\n\n<!--\n  Reference links\n-->\n\n[automation-extra]: https://github.com/berstend/puppeteer-extra/tree/master/packages/automation-extra\n[playwright-extra]: https://github.com/berstend/puppeteer-extra/tree/master/packages/playwright-extra\n[puppeteer-extra]: https://github.com/berstend/puppeteer-extra/tree/master/packages/puppeteer-extra\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/berstend/puppeteer-extra/issues"},"_id":"automation-extra-plugin@4.2.2-next.593","_nodeVersion":"15.3.0","_npmVersion":"lerna/3.22.1/node@v15.3.0+x64 (darwin)","_npmUser":{"name":"berstend","email":"e.ndze.it@gmail.com"},"dist":{"integrity":"sha512-PjHXpAWhCQvSW/ofcezH4etvePgAbySLo6ghbz5QjxdUsStF51KSNMhsi1vRcz8V9Ov8hquRDc8eLFRz6G07LA==","shasum":"21dbd3863f678ab97db76eeb4b95e19d4965409a","tarball":"https://registry.npmjs.org/automation-extra-plugin/-/automation-extra-plugin-4.2.2-next.593.tgz","fileCount":16,"unpackedSize":169189,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgIV3MCRA9TVsSAnZWagAAsKgP/1XutceKm3SpRYiEfJyI\ncbZzcC7Fz0l0fHdmy1RDbL9Qlkk5yXPJS4ronLFrOMcSM1qz40q18ZnS3TK0\nGB8Llknq5jvVq7b7Zp3e7TWSkElQrEgo2YnEPigb0Uw4YBIHhasLjxwpY3+k\nM9+UAlQmhbXcPFTGGV14mhAHNYjI5S25uL/14vELyJda1iupq2sbX4vNI2/L\nQ8BOOdiZzvJYLIFojRu7cnfiIsotZu6u+Z46DPazHyg9CkDUSXb9Omwc1nKc\nLyTCfGdIrG5p95MHXFXeQYvnrN9uLzkIOXYNyYunnMLO9QnQi9Ql9I1Xe/1e\n3Zmdo4YYJMWMmMYpjZZvEgmF8NmFIz/fvsB5Vp+YQr94f05TzA0SJHkmoLrX\nxGYHZAAOxFROAK8zn6yEncyOva3xpb86H6vFhG0GnMYxLz/ZhFS6ViUCxJo/\nKTFyWMVC21nJdb7IQ0xm/MBT0VuIa95kN8J3dIqcvh+PjXESssk89pqhK8k/\nFTVEoTbc8NhncpdpipUjz6fGVJfD/9GXK20yZePR3DZGKqvMqMz9/Z61Sj4q\npHSInSdsbxXPEobCmBvhtVrHpvpasCsvNh9Y2/CIyZzSsBzRp1w/eEEsa6J2\n9w3JDNUC3NmwHB/g84yLYA0e+JfmwZAYqqdus64UfLfOhR+UM7X8H6DPE00U\nqDtU\r\n=+q4f\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCC6zGnS7Es4JN6/cstKdaB8577X3L0uSteUjok7gszPwIgEB5HistByhCW6klt/+NSAlFghDaISeYSiTD4vGAcmVI="}]},"directories":{},"maintainers":[{"name":"berstend","email":"e.ndze.it@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/automation-extra-plugin_4.2.2-next.593_1612799436042_0.8720904801345242"},"_hasShrinkwrap":false},"4.2.2-next.615":{"name":"automation-extra-plugin","version":"4.2.2-next.615","_rand":"a98sdf89asdf","description":"Base class for automation-extra plugins (supports Playwright and Puppeteer).","main":"dist/index.cjs.js","module":"dist/index.esm.js","typings":"dist/index.d.ts","repository":{"type":"git","url":"git+https://github.com/berstend/puppeteer-extra.git"},"homepage":"https://github.com/berstend/puppeteer-extra/tree/master/packages/automation-extra-plugin","author":{"name":"berstend"},"license":"MIT","scripts":{"clean":"rimraf dist/*","prebuild":"run-s clean","build":"run-s build:tsc build:rollup","build:tsc":"tsc --module commonjs","build:rollup":"rollup -c rollup.config.ts","docs":"documentation readme --quiet --shallow --github --markdown-theme transitivebs --readme-file readme.md --section API ./src/index.ts","postdocs":"npx prettier --write readme.md","test:ts":"ava -v --config ava.config-ts.js","test:js":"ava -v --serial --concurrency 1 --fail-fast","test":"run-p test:js test:ts","pretest-ci":"run-s build","test-ci":"run-p lint test","lint:js":"eslint --no-error-on-unmatched-pattern --ext .js src/ test/","lint:ts":"tslint --project tsconfig.json","lint":"run-p lint:js lint:ts"},"engines":{"node":">=12"},"prettier":{"printWidth":80,"semi":false,"singleQuote":true},"keywords":["puppeteer","puppeteer-extra","playwright-extra","playwright","automation-extra-plugin","ua","user-agent","chrome","headless","pupeteer"],"devDependencies":{"@types/node":"^13.1.4","ava":"2.4.0","documentation-markdown-themes":"13.1.2","npm-run-all":"^4.1.5","rimraf":"^3.0.0","rollup":"^1.27.5","rollup-plugin-commonjs":"^10.1.0","rollup-plugin-node-resolve":"^5.2.0","rollup-plugin-sourcemaps":"^0.4.2","rollup-plugin-typescript2":"0.29.0","ts-node":"^8.5.4","tslint":"^5.12.1","tslint-config-prettier":"^1.18.0","tslint-config-standard":"^9.0.0","typescript":"4.1.2"},"dependencies":{"@types/debug":"^4.1.0","@types/puppeteer":"5.4.3","debug":"^4.1.1","deepmerge":"^4.2.2","is-plain-object":"^5.0.0","playwright-core":"1.8.0"},"gitHead":"dbc1d01922a0de6703aefa3f3f32ec852b72ff44","readme":"# automation-extra-plugin [![GitHub Workflow Status](https://img.shields.io/github/workflow/status/berstend/puppeteer-extra/Test/master)](https://github.com/berstend/puppeteer-extra/actions) [![Discord](https://img.shields.io/discord/737009125862408274)](http://scraping-chat.cf) [![npm](https://img.shields.io/npm/v/automation-extra-plugin.svg)](https://www.npmjs.com/package/automation-extra-plugin)\n\n> Base class to develop plugins for [automation-extra].\n\n## Installation\n\n```bash\nyarn add automation-extra-plugin\n```\n\n<details>\n <summary>Changelog</summary>\n\n- v4.1\n  - Initial public release\n\n</details>\n\n## Features\n\n- Supports [playwright-extra] as well as [puppeteer-extra]\n- Uses lifecycle events to hook into Puppeteer & Playwright execution\n- Ships with `this.env` and type guards to make multi-browser, multi-driver plugin development a breeze\n- Written in TypeScript (which means helpful auto-complete even if you're writing your plugins in JS)\n- Successor to `puppeteer-extra-plugin`, which only supports Puppeteer\n\n## Example\n\n```js\nconst { AutomationExtraPlugin } = require('automation-extra-plugin')\n\nclass DemoPlugin extends AutomationExtraPlugin {\n  constructor(opts = {}) {\n    super(opts)\n  }\n\n  static get id() {\n    return 'demo'\n  }\n\n  async beforeLaunch(options) {\n    // Modify launch options\n    options.headless = false\n  }\n\n  async onBrowser(browser) {\n    // Become aware of browser launch/connect\n    console.log('onBrowser:', {\n      driverName: this.env.driverName,\n      browserName: this.env.browserName,\n    })\n  }\n\n  async onPageCreated(page) {\n    // Hook into page events\n    console.log('Page created:', page.url())\n    page.on('load', () => {\n      console.log('Page loaded', page.url())\n    })\n    // Use a shim which unifies page.evaluateOnNewDocument and page.addInitScript\n    this.shim(page).addScript(() => {\n      navigator.alice = 'bob'\n    })\n  }\n}\n\nconst demo = new DemoPlugin()\n```\n\nUse the plugin with Puppeteer:\n\n```js\nconst puppeteer = require('puppeteer-extra')\n\npuppeteer.use(demo) // that's it :-)\npuppeteer.launch({ headless: true }).then(async (browser) => {\n  const page = await browser.newPage()\n  await page.goto('https://example.com', { waitUntil: 'load' })\n  const alice = await page.evaluate(() => navigator.alice)\n  console.log(alice) // ==> bob\n  await browser.close()\n})\n```\n\nUse the same plugin with Playwright (chromium and webkit are supported as well):\n\n```js\nconst { firefox } = require('playwright-extra')\n\nfirefox.use(demo) // that's it :-)\nfirefox.launch({ headless: true }).then(async (browser) => {\n  // ... same code as above\n})\n```\n\n## Contributing\n\nIf you're interested in releasing your plugin under the `@extra` organization please reach out to us through an issue or on our discord server. :-)\n\n## API\n\n<!--\n    Documentation is auto-generated by a custom fork of documentation.js\n    More info: https://github.com/berstend/documentation-markdown-themes/wiki#documentationjs-with-markdown-theme-support\n    Update this documentation by updating the source code.\n-->\n\n#### Table of Contents\n\n- [class: PluginLifecycleMethods](#class-pluginlifecyclemethods)\n  - [.onPluginRegistered()](#onpluginregistered)\n  - [.beforeLaunch(options)](#beforelaunchoptions)\n  - [.afterLaunch(browser, launchContext)](#afterlaunchbrowser-launchcontext)\n  - [.beforeConnect(options)](#beforeconnectoptions)\n  - [.afterConnect(browser, launchContext)](#afterconnectbrowser-launchcontext)\n  - [.onBrowser(browser, launchContext)](#onbrowserbrowser-launchcontext)\n  - [.beforeContext(options, browser)](#beforecontextoptions-browser)\n  - [.onContextCreated(context, options)](#oncontextcreatedcontext-options)\n  - [.onPageCreated(page)](#onpagecreatedpage)\n  - [.onPageClose(page)](#onpageclosepage)\n  - [.onContextClose(context)](#oncontextclosecontext)\n  - [.onDisconnected(browser)](#ondisconnectedbrowser)\n- [class: AutomationExtraPlugin](#class-automationextraplugin)\n  - [.env](#env)\n  - [.shim(page)](#shimpage)\n  - [.defaults](#defaults)\n  - [.requirements](#requirements)\n  - [.filter](#filter)\n  - [.dependencies](#dependencies)\n  - [.plugins](#plugins)\n  - [.opts](#opts)\n  - [.debug](#debug)\n  - [.id](#id)\n- [class: TypeGuards](#class-typeguards)\n  - [.isPage(obj)](#ispageobj)\n  - [.isBrowser(obj)](#isbrowserobj)\n  - [.isPuppeteerPage(obj)](#ispuppeteerpageobj)\n  - [.isPuppeteerBrowser(obj)](#ispuppeteerbrowserobj)\n  - [.isPuppeteerBrowserContext(obj)](#ispuppeteerbrowsercontextobj)\n  - [.isPlaywrightPage(obj)](#isplaywrightpageobj)\n  - [.isPlaywrightBrowser(obj)](#isplaywrightbrowserobj)\n  - [.isPlaywrightBrowserContext(obj)](#isplaywrightbrowsercontextobj)\n- [class: LauncherEnv](#class-launcherenv)\n  - [.driverName](#drivername)\n  - [.browserName](#browsername)\n  - [.isPuppeteer](#ispuppeteer)\n  - [.isPlaywright](#isplaywright)\n  - [.isChromium](#ischromium)\n  - [.isFirefox](#isfirefox)\n  - [.isWebkit](#iswebkit)\n  - [.isBrowserKnown](#isbrowserknown)\n- [class: PageShim](#class-pageshim)\n  - [.addScript(script, arg?)](#addscriptscript-arg)\n\n### class: [PluginLifecycleMethods](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L74-L241)\n\nPlugin lifecycle methods used by AutomationExtraPlugin.\n\nThese are hooking into Playwright/Puppeteer events and are meant to be overriden\non a per-need basis in your own plugin extending AutomationExtraPlugin.\n\n---\n\n#### .[onPluginRegistered()](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L78-L78)\n\nReturns: **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)&lt;void>**\n\nAfter the plugin has been registered, called early in the life-cycle (once the plugin has been added).\n\n---\n\n#### .[beforeLaunch(options)](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L97-L97)\n\n- `options` **LaunchOptions** Puppeteer/Playwright launch options\n\nReturns: **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)&lt;(LaunchOptions | void)>**\n\nBefore a new browser instance is created/launched.\n\nCan be used to modify the puppeteer/playwright launch options by modifying or returning them.\n\nPlugins using this method will be called in sequence to each\nbe able to update the launch options.\n\nExample:\n\n```javascript\nasync beforeLaunch (options) {\n  if (this.opts.flashPluginPath) {\n    options.args = options.args || []\n    options.args.push(`--ppapi-flash-path=${this.opts.flashPluginPath}`)\n  }\n}\n```\n\n---\n\n#### .[afterLaunch(browser, launchContext)](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L125-L125)\n\n- `browser` **Browser** The `puppeteer` or `playwright` browser instance.\n- `launchContext` **LaunchContext**\n\nAfter the browser has launched.\n\nNote: Don't assume that there will only be a single browser instance during the lifecycle of a plugin.\nIt's possible that `pupeeteer.launch` will be called multiple times and more than one browser created.\nIn order to make the plugins as stateless as possible don't store a reference to the browser instance\nin the plugin but rather consider alternatives.\n\nE.g. when using `onPageCreated` you can get a browser reference by using `page.browser()`.\n\nAlternatively you could expose a class method that takes a browser instance as a parameter to work with:\n\n```es6\nconst fancyPlugin = require('puppeteer-extra-plugin-fancy')()\npuppeteer.use(fancyPlugin)\nconst browser = await puppeteer.launch()\nawait fancyPlugin.killBrowser(browser)\n```\n\nExample:\n\n```javascript\nasync afterLaunch (browser, opts) {\n  this.debug('browser has been launched', opts.options)\n}\n```\n\n---\n\n#### .[beforeConnect(options)](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L137-L139)\n\n- `options` **ConnectOptions** Puppeteer/playwright connect options\n\nReturns: **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)&lt;(ConnectOptions | void)>**\n\nBefore connecting to an existing browser instance.\n\nCan be used to modify the puppeteer/playwright connect options by modifying or returning them.\n\nPlugins using this method will be called in sequence to each\nbe able to update the launch options.\n\n---\n\n#### .[afterConnect(browser, launchContext)](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L149-L149)\n\n- `browser` **Browser** The `puppeteer` or playwright browser instance.\n- `launchContext` **LaunchContext**\n\nAfter connecting to an existing browser instance.\n\n> Note: Don't assume that there will only be a single browser instance during the lifecycle of a plugin.\n\n---\n\n#### .[onBrowser(browser, launchContext)](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L163-L163)\n\n- `browser` **Browser** The `puppeteer` or `playwright` browser instance.\n- `launchContext` **LaunchContext**\n\nCalled when a browser instance is available.\n\nThis applies to both `launch` and `connect`.\n\nConvenience method created for plugins that need access to a browser instance\nand don't mind if it has been created through `launch` or `connect`.\n\n> Note: Don't assume that there will only be a single browser instance during the lifecycle of a plugin.\n\n---\n\n#### .[beforeContext(options, browser)](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L178-L181)\n\n- `options` **Playwright.BrowserContextOptions** Playwright browser context options\n- `browser` **Playwright.Browser** Playwright browser\n\nReturns: **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)&lt;(Playwright.BrowserContextOptions | void)>**\n\nBefore a new browser context is created.\n\nNote: Currently only triggered by `playwright`, as puppeteer's usage of context is very lackluster.\n\nPlugins using this method will be called in sequence to each\nbe able to update the context options.\n\n- **See: <https://github.com/microsoft/playwright/blob/master/docs/api.md#browsernewcontextoptions>**\n\n---\n\n#### .[onContextCreated(context, options)](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L191-L194)\n\n- `context` **Playwright.BrowserContext** Playwright browser context\n- `options` **Playwright.BrowserContextOptions** Playwright browser context options\n\nAfter a new browser context has been created.\n\nNote: `playwright` specific.\n\n---\n\n#### .[onPageCreated(page)](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L215-L215)\n\n- `page` **(Puppeteer.Page | Playwright.Page)**\n\nCalled when a page has been created.\n\nThe event will also fire for popup pages.\n\nExample:\n\n```javascript\nasync onPageCreated (page) {\n  let ua = await page.browser().userAgent()\n  if (this.opts.stripHeadless) {\n    ua = ua.replace('HeadlessChrome/', 'Chrome/')\n  }\n  this.debug('new ua', ua)\n  await page.setUserAgent(ua)\n}\n```\n\n- **See: <https://playwright.dev/#version=v1.3.0&path=docs%2Fapi.md&q=event-page>**\n- **See: <https://pptr.dev/#?product=Puppeteer&version=main&show=api-event-targetcreated>**\n\n---\n\n#### .[onPageClose(page)](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L221-L221)\n\n- `page` **Page**\n\nCalled when a page has been closed.\n\n---\n\n#### .[onContextClose(context)](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L229-L229)\n\n- `context` **Playwright.BrowserContext**\n\nCalled when a browser context has been closed.\n\nNote: `playwright` specific.\n\n---\n\n#### .[onDisconnected(browser)](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L240-L240)\n\n- `browser` **Browser** The `puppeteer` or `playwright` browser instance.\n\nCalled when the browser got disconnected.\n\nThis might happen because of one of the following:\n\n- The browser is closed or crashed\n- The `browser.disconnect` method was called\n\n---\n\n### class: [AutomationExtraPlugin](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L263-L487)\n\n**Extends: PluginLifecycleMethods**\n\nAutomationExtraPlugin - Meant to be used as a base class and it's methods overridden.\n\nImplements all `PluginLifecycleMethods`.\n\nExample:\n\n```javascript\nclass Plugin extends AutomationExtraPlugin {\n  static id = 'foobar'\n  constructor(opts = {}) {\n    super(opts)\n  }\n\n  async beforeLaunch(options) {\n    options.headless = false\n    return options\n  }\n}\n```\n\n---\n\n#### .[env](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L291-L291)\n\nType: **[LauncherEnv](#launcherenv)**\n\nContains info regarding the launcher environment the plugin runs in\n\n- **See: LauncherEnv**\n\n---\n\n#### .[shim(page)](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L323-L323)\n\n- `page` **Page**\n\nReturns: **[PageShim](#pageshim)**\n\nUnified Page methods for Playwright & Puppeteer\n\n---\n\n#### .[defaults](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L352-L354)\n\nType: **PluginOptions**\n\nPlugin defaults (optional).\n\nIf defined will be ([deep-](https://github.com/TehShrike/deepmerge))merged with the (optional) user supplied options (supplied during plugin instantiation).\n\nThe result of merging defaults with user supplied options can be accessed through `this.opts`.\n\nExample:\n\n```javascript\nget defaults () {\n  return {\n    stripHeadless: true,\n    makeWindows: true,\n    customFn: null\n  }\n}\n\n// Users can overwrite plugin defaults during instantiation:\npuppeteer.use(require('puppeteer-extra-plugin-foobar')({ makeWindows: false }))\n```\n\n- **See: \\[[opts]]**\n\n---\n\n#### .[requirements](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L380-L382)\n\nType: **PluginRequirements**\n\nPlugin requirements (optional).\n\nSignal certain plugin requirements to the base class and the user.\n\nCurrently supported:\n\n- `launch`\n  - If the plugin only supports locally created browser instances (no `puppeteer.connect()`),\n    will output a warning to the user.\n- `headful`\n  - If the plugin doesn't work in `headless: true` mode,\n    will output a warning to the user.\n- `runLast`\n  - In case the plugin prefers to run after the others.\n    Useful when the plugin needs data from others.\n\nExample:\n\n```javascript\nget requirements () {\n  return new Set(['runLast', 'dataFromPlugins'])\n}\n```\n\n---\n\n#### .[filter](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L399-L401)\n\nType: **(Filter | [undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined))**\n\nPlugin filter statements (optional).\n\nFilter this plugin from being called depending on the environment.\n\nExample:\n\n```javascript\nget filter() {\n  return {\n    include: ['playwright:chromium', 'puppeteer:chromium']\n  }\n}\n```\n\n---\n\n#### .[dependencies](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L423-L425)\n\nType: **PluginDependencies**\n\nPlugin dependencies (optional).\n\nMissing plugins will be required() by automation-extra.\n\nExample:\n\n```javascript\n// Will ensure the 'puppeteer-extra-plugin-user-preferences' plugin is loaded.\nget dependencies () {\n  return new Set(['user-preferences'])\n}\n\n// Will load `user-preferences` plugin and pass `{ beCool: true }` as opts\nget dependencies () {\n  return new Map([['user-preferences', { beCool: true }]])\n}\n```\n\n---\n\n#### .[plugins](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L438-L440)\n\nType: **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;AutomationExtraPluginInstance>**\n\nAdd additional plugins (optional).\n\nExpects an array of AutomationExtraPlugin instances, not classes.\nThis is intended to be used by \"meta\" plugins that use other plugins behind the scenes.\n\nThe benefit over using `dependencies` is that this doesn't use the framework for dynamic imports,\nbut requires explicit imports which bundlers like webkit handle much better.\n\nMissing plugins listed here will be added at the start of `launch` or `connect` events.\n\n---\n\n#### .[opts](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L457-L459)\n\nType: **PluginOptions**\n\nAccess the plugin options (usually the `defaults` merged with user defined options)\n\nTo skip the auto-merging of defaults with user supplied opts don't define a `defaults`\nproperty and set the `this._opts` Object in your plugin constructor directly.\n\nExample:\n\n```javascript\nget defaults () { return { foo: \"bar\" } }\n\nasync onPageCreated (page) {\n  this.debug(this.opts.foo) // => bar\n}\n```\n\n- **See: \\[[defaults]]**\n\n---\n\n#### .[debug](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L477-L479)\n\nType: **Debugger**\n\nConvenience debug logger based on the [debug] module.\nWill automatically namespace the logging output to the plugin package name.\n\n[debug]: https://www.npmjs.com/package/debug\n\n```bash\n# toggle output using environment variables\nDEBUG=automation-extra-plugin:<plugin_id> node foo.js\n# to debug all the things:\nDEBUG=automation-extra,automation-extra-plugin:* node foo.js\n```\n\nExample:\n\n```javascript\nthis.debug('hello world')\n// will output e.g. 'automation-extra-plugin:anonymize-ua hello world'\n```\n\n---\n\n#### .[id](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L285-L285)\n\nPlugin id/name (required)\n\nConvention:\n\n- Package: `automation-extra-plugin-anonymize-ua`\n- Name: `anonymize-ua`\n\nExample:\n\n```javascript\nstatic id = 'anonymize-ua';\n// or\nstatic get id() {\n  return 'anonymize-ua'\n}\n```\n\n---\n\n### class: [TypeGuards](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L501-L566)\n\nTypeGuards: They allow differentiating between different objects and types.\n\nType guards work by discriminating against properties only found in that specific type.\nThis is especially useful when used with TypeScript as it improves type safety.\n\n---\n\n#### .[isPage(obj)](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L507-L509)\n\n- `obj` **any** The object to test\n\nReturns: **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)**\n\nType guard, will make TypeScript understand which type we're working with.\n\n---\n\n#### .[isBrowser(obj)](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L515-L517)\n\n- `obj` **any** The object to test\n\nReturns: **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)**\n\nType guard, will make TypeScript understand which type we're working with.\n\n---\n\n#### .[isPuppeteerPage(obj)](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L523-L525)\n\n- `obj` **any** The object to test\n\nReturns: **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)**\n\nType guard, will make TypeScript understand which type we're working with.\n\n---\n\n#### .[isPuppeteerBrowser(obj)](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L531-L533)\n\n- `obj` **any** The object to test\n\nReturns: **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)**\n\nType guard, will make TypeScript understand which type we're working with.\n\n---\n\n#### .[isPuppeteerBrowserContext(obj)](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L539-L541)\n\n- `obj` **any** The object to test\n\nReturns: **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)**\n\nType guard, will make TypeScript understand which type we're working with.\n\n---\n\n#### .[isPlaywrightPage(obj)](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L547-L549)\n\n- `obj` **any** The object to test\n\nReturns: **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)**\n\nType guard, will make TypeScript understand which type we're working with.\n\n---\n\n#### .[isPlaywrightBrowser(obj)](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L555-L557)\n\n- `obj` **any** The object to test\n\nReturns: **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)**\n\nType guard, will make TypeScript understand which type we're working with.\n\n---\n\n#### .[isPlaywrightBrowserContext(obj)](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L563-L565)\n\n- `obj` **any** The object to test\n\nReturns: **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)**\n\nType guard, will make TypeScript understand which type we're working with.\n\n---\n\n### class: [LauncherEnv](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L575-L622)\n\n**Extends: TypeGuards**\n\nStores environment specific info, populated by the launcher.\nThis allows sane plugin development in a multi-browser, multi-driver environment.\n\n---\n\n#### .[driverName](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L579-L579)\n\nThe name of the driver currently in use: `\"playwright\" | \"puppeteer\"`.\n\n---\n\n#### .[browserName](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L587-L587)\n\nThe name of the browser engine currently in use: `\"chromium\" | \"firefox\" | \"webkit\" | \"unknown\"`.\n\nNote: With puppeteer the browser will only be known once a browser object is available (after launching or connecting),\nas they support defining the browser during `.launch()`.\n\n---\n\n#### .[isPuppeteer](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L599-L601)\n\nCheck if current driver is puppeteer\n\n---\n\n#### .[isPlaywright](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L603-L605)\n\nCheck if current driver is playwright\n\n---\n\n#### .[isChromium](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L607-L609)\n\nCheck if current browser is chrome or chromium\n\n---\n\n#### .[isFirefox](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L611-L613)\n\nCheck if current browser is firefox\n\n---\n\n#### .[isWebkit](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L615-L617)\n\nCheck if current browser is webkit\n\n---\n\n#### .[isBrowserKnown](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L619-L621)\n\nCheck if current browser is known\n\n---\n\n### class: [PageShim](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L636-L666)\n\nUnified Page methods for Playwright & Puppeteer.\nThey support common actions through a single API.\n\n---\n\n#### .[addScript(script, arg?)](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L657-L665)\n\n- `script` **([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) \\| [Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function))**\n- `arg` **Serializable?**\n\nAdds a script which would be evaluated in one of the following scenarios:\n\nWhenever the page is navigated.\nWhenever the child frame is attached or navigated. In this case, the script is evaluated in the context of the newly attached frame.\n\nThe script is evaluated after the document was created but before any of its scripts were run.\n\n- **See: **Playwright:** `addInitScript`\n  **Puppeteer:** `evaluateOnNewDocument`**\n\n---\n\n## License\n\nCopyright © 2018 - 2021, [berstend̡̲̫̹̠̖͚͓̔̄̓̐̄͛̀͘](https://github.com/berstend). Released under the MIT License.\n\n<!--\n  Reference links\n-->\n\n[automation-extra]: https://github.com/berstend/puppeteer-extra/tree/master/packages/automation-extra\n[playwright-extra]: https://github.com/berstend/puppeteer-extra/tree/master/packages/playwright-extra\n[puppeteer-extra]: https://github.com/berstend/puppeteer-extra/tree/master/packages/puppeteer-extra\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/berstend/puppeteer-extra/issues"},"_id":"automation-extra-plugin@4.2.2-next.615","_nodeVersion":"15.3.0","_npmVersion":"lerna/3.22.1/node@v15.3.0+x64 (darwin)","_npmUser":{"name":"berstend","email":"e.ndze.it@gmail.com"},"dist":{"integrity":"sha512-54vFRcfHgU8shgSI4na34Bk5u3c7UNsim0SUR9ttdT0d6u2Psg7AG5HmvHSG9RDf2fBuHhJ+34Etb2jizSLB9g==","shasum":"ebe66085ccccbd47af6929fc5ea886d7351dbe4c","tarball":"https://registry.npmjs.org/automation-extra-plugin/-/automation-extra-plugin-4.2.2-next.615.tgz","fileCount":16,"unpackedSize":169216,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgIkeJCRA9TVsSAnZWagAAu3sP/jPDQH1l7ipLTFX06muE\ngo7Q3/Z8ZXoPUssYkCAWfaUSwdQc6OvuyJK9K3Qsk4MI9E0g766st+dEB1sN\n04EMzvqWEQV+Hc8dr9MJOaCqWe/B5ilwVNxs0rTcEUAH980iFfkEdM2n20Fn\nQbAp5D0r4hoc8+j1NOMiHSZlptYyr2g3CZFAo88JASrF6BeD7ENfAuKQ6/DF\n3/ZfXAHuS4PUHHpQ4p4vq3pFAjQ5LyDbvivYQ5m9qG6P6rwF4vLLV61YmVa+\n86sdBXtemrvYGLyNVXQnWXrVHaa01hy4lpVyCUGtrMkw2hpMzFfbXG6TFx/l\nl6ifzggE7AierWtnVGHVAVGV6lAqhXhxrekAWZOF2HhXs7W+aX4kU1IpmuJF\nLOz9ckeBINmjGkX13/En0yFSzBMTKS8qWW3/w2J8OUm8G+1n+zhSm/+kW4JD\nrC45C4wNGk728/D6xfYremBZqHeS0ateXIWyL01fw9c614SzO3WPhBF/d4QP\nPW+SZUAC1uZTolJrxo8z5O8K4nR2p+8aXyeiU7Z2SQ/8TjWbH46RNni+Y1GW\n8MEPsBfUuiTVDqgqPmVThhO/HRqPiVh2lcQbTNiCr63w/mHbyfvMQnAI9yOt\n3/Ajc8pX0JdW0QfLyYx6kpkla4nOFsoNKxycNOp35Pw7vU8xyTBEvKE23fES\nOMwS\r\n=Tykm\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCmcMqzA3r6YfcFUfIApmDhkDi9karJsCJgcP4hcDHWlAIhAJO50j2FSZwTmobnRKqyZIqfOTbxODIF3HuxFyep38Dg"}]},"directories":{},"maintainers":[{"name":"berstend","email":"e.ndze.it@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/automation-extra-plugin_4.2.2-next.615_1612859273006_0.5360961045578225"},"_hasShrinkwrap":false},"4.2.2-next.616":{"name":"automation-extra-plugin","version":"4.2.2-next.616","_rand":"a7f69a7sd","description":"Base class for automation-extra plugins (supports Playwright and Puppeteer).","main":"dist/index.cjs.js","module":"dist/index.esm.js","typings":"dist/index.d.ts","repository":{"type":"git","url":"git+https://github.com/berstend/puppeteer-extra.git"},"homepage":"https://github.com/berstend/puppeteer-extra/tree/master/packages/automation-extra-plugin","author":{"name":"berstend"},"license":"MIT","scripts":{"clean":"rimraf dist/*","prebuild":"run-s clean","build":"run-s build:tsc build:rollup","build:tsc":"tsc --module commonjs","build:rollup":"rollup -c rollup.config.ts","docs":"documentation readme --quiet --shallow --github --markdown-theme transitivebs --readme-file readme.md --section API ./src/index.ts","postdocs":"npx prettier --write readme.md","test:ts":"ava -v --config ava.config-ts.js","test:js":"ava -v --serial --concurrency 1 --fail-fast","test":"run-p test:js test:ts","pretest-ci":"run-s build","test-ci":"run-p lint test","lint:js":"eslint --no-error-on-unmatched-pattern --ext .js src/ test/","lint:ts":"tslint --project tsconfig.json","lint":"run-p lint:js lint:ts"},"engines":{"node":">=12"},"prettier":{"printWidth":80,"semi":false,"singleQuote":true},"keywords":["puppeteer","puppeteer-extra","playwright-extra","playwright","automation-extra-plugin","ua","user-agent","chrome","headless","pupeteer"],"devDependencies":{"@types/node":"^13.1.4","ava":"2.4.0","documentation-markdown-themes":"13.1.2","npm-run-all":"^4.1.5","rimraf":"^3.0.0","rollup":"^1.27.5","rollup-plugin-commonjs":"^10.1.0","rollup-plugin-node-resolve":"^5.2.0","rollup-plugin-sourcemaps":"^0.4.2","rollup-plugin-typescript2":"0.29.0","ts-node":"^8.5.4","tslint":"^5.12.1","tslint-config-prettier":"^1.18.0","tslint-config-standard":"^9.0.0","typescript":"4.1.2"},"dependencies":{"@types/debug":"^4.1.0","@types/puppeteer":"5.4.3","debug":"^4.1.1","deepmerge":"^4.2.2","is-plain-object":"^5.0.0","playwright-core":"1.8.0"},"gitHead":"846b2f283f7c0cae6dfac5a2a1761df117973e28","readme":"# automation-extra-plugin [![GitHub Workflow Status](https://img.shields.io/github/workflow/status/berstend/puppeteer-extra/Test/master)](https://github.com/berstend/puppeteer-extra/actions) [![Discord](https://img.shields.io/discord/737009125862408274)](http://scraping-chat.cf) [![npm](https://img.shields.io/npm/v/automation-extra-plugin.svg)](https://www.npmjs.com/package/automation-extra-plugin)\n\n> Base class to develop plugins for [automation-extra].\n\n## Installation\n\n```bash\nyarn add automation-extra-plugin\n```\n\n<details>\n <summary>Changelog</summary>\n\n- v4.1\n  - Initial public release\n\n</details>\n\n## Features\n\n- Supports [playwright-extra] as well as [puppeteer-extra]\n- Uses lifecycle events to hook into Puppeteer & Playwright execution\n- Ships with `this.env` and type guards to make multi-browser, multi-driver plugin development a breeze\n- Written in TypeScript (which means helpful auto-complete even if you're writing your plugins in JS)\n- Successor to `puppeteer-extra-plugin`, which only supports Puppeteer\n\n## Example\n\n```js\nconst { AutomationExtraPlugin } = require('automation-extra-plugin')\n\nclass DemoPlugin extends AutomationExtraPlugin {\n  constructor(opts = {}) {\n    super(opts)\n  }\n\n  static get id() {\n    return 'demo'\n  }\n\n  async beforeLaunch(options) {\n    // Modify launch options\n    options.headless = false\n  }\n\n  async onBrowser(browser) {\n    // Become aware of browser launch/connect\n    console.log('onBrowser:', {\n      driverName: this.env.driverName,\n      browserName: this.env.browserName,\n    })\n  }\n\n  async onPageCreated(page) {\n    // Hook into page events\n    console.log('Page created:', page.url())\n    page.on('load', () => {\n      console.log('Page loaded', page.url())\n    })\n    // Use a shim which unifies page.evaluateOnNewDocument and page.addInitScript\n    this.shim(page).addScript(() => {\n      navigator.alice = 'bob'\n    })\n  }\n}\n\nconst demo = new DemoPlugin()\n```\n\nUse the plugin with Puppeteer:\n\n```js\nconst puppeteer = require('puppeteer-extra')\n\npuppeteer.use(demo) // that's it :-)\npuppeteer.launch({ headless: true }).then(async (browser) => {\n  const page = await browser.newPage()\n  await page.goto('https://example.com', { waitUntil: 'load' })\n  const alice = await page.evaluate(() => navigator.alice)\n  console.log(alice) // ==> bob\n  await browser.close()\n})\n```\n\nUse the same plugin with Playwright (chromium and webkit are supported as well):\n\n```js\nconst { firefox } = require('playwright-extra')\n\nfirefox.use(demo) // that's it :-)\nfirefox.launch({ headless: true }).then(async (browser) => {\n  // ... same code as above\n})\n```\n\n## Contributing\n\nIf you're interested in releasing your plugin under the `@extra` organization please reach out to us through an issue or on our discord server. :-)\n\n## API\n\n<!--\n    Documentation is auto-generated by a custom fork of documentation.js\n    More info: https://github.com/berstend/documentation-markdown-themes/wiki#documentationjs-with-markdown-theme-support\n    Update this documentation by updating the source code.\n-->\n\n#### Table of Contents\n\n- [class: PluginLifecycleMethods](#class-pluginlifecyclemethods)\n  - [.onPluginRegistered()](#onpluginregistered)\n  - [.beforeLaunch(options)](#beforelaunchoptions)\n  - [.afterLaunch(browser, launchContext)](#afterlaunchbrowser-launchcontext)\n  - [.beforeConnect(options)](#beforeconnectoptions)\n  - [.afterConnect(browser, launchContext)](#afterconnectbrowser-launchcontext)\n  - [.onBrowser(browser, launchContext)](#onbrowserbrowser-launchcontext)\n  - [.beforeContext(options, browser)](#beforecontextoptions-browser)\n  - [.onContextCreated(context, options)](#oncontextcreatedcontext-options)\n  - [.onPageCreated(page)](#onpagecreatedpage)\n  - [.onPageClose(page)](#onpageclosepage)\n  - [.onContextClose(context)](#oncontextclosecontext)\n  - [.onDisconnected(browser)](#ondisconnectedbrowser)\n- [class: AutomationExtraPlugin](#class-automationextraplugin)\n  - [.env](#env)\n  - [.shim(page)](#shimpage)\n  - [.defaults](#defaults)\n  - [.requirements](#requirements)\n  - [.filter](#filter)\n  - [.dependencies](#dependencies)\n  - [.plugins](#plugins)\n  - [.opts](#opts)\n  - [.debug](#debug)\n  - [.id](#id)\n- [class: TypeGuards](#class-typeguards)\n  - [.isPage(obj)](#ispageobj)\n  - [.isBrowser(obj)](#isbrowserobj)\n  - [.isPuppeteerPage(obj)](#ispuppeteerpageobj)\n  - [.isPuppeteerBrowser(obj)](#ispuppeteerbrowserobj)\n  - [.isPuppeteerBrowserContext(obj)](#ispuppeteerbrowsercontextobj)\n  - [.isPlaywrightPage(obj)](#isplaywrightpageobj)\n  - [.isPlaywrightBrowser(obj)](#isplaywrightbrowserobj)\n  - [.isPlaywrightBrowserContext(obj)](#isplaywrightbrowsercontextobj)\n- [class: LauncherEnv](#class-launcherenv)\n  - [.driverName](#drivername)\n  - [.browserName](#browsername)\n  - [.isPuppeteer](#ispuppeteer)\n  - [.isPlaywright](#isplaywright)\n  - [.isChromium](#ischromium)\n  - [.isFirefox](#isfirefox)\n  - [.isWebkit](#iswebkit)\n  - [.isBrowserKnown](#isbrowserknown)\n- [class: PageShim](#class-pageshim)\n  - [.addScript(script, arg?)](#addscriptscript-arg)\n\n### class: [PluginLifecycleMethods](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L74-L241)\n\nPlugin lifecycle methods used by AutomationExtraPlugin.\n\nThese are hooking into Playwright/Puppeteer events and are meant to be overriden\non a per-need basis in your own plugin extending AutomationExtraPlugin.\n\n---\n\n#### .[onPluginRegistered()](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L78-L78)\n\nReturns: **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)&lt;void>**\n\nAfter the plugin has been registered, called early in the life-cycle (once the plugin has been added).\n\n---\n\n#### .[beforeLaunch(options)](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L97-L97)\n\n- `options` **LaunchOptions** Puppeteer/Playwright launch options\n\nReturns: **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)&lt;(LaunchOptions | void)>**\n\nBefore a new browser instance is created/launched.\n\nCan be used to modify the puppeteer/playwright launch options by modifying or returning them.\n\nPlugins using this method will be called in sequence to each\nbe able to update the launch options.\n\nExample:\n\n```javascript\nasync beforeLaunch (options) {\n  if (this.opts.flashPluginPath) {\n    options.args = options.args || []\n    options.args.push(`--ppapi-flash-path=${this.opts.flashPluginPath}`)\n  }\n}\n```\n\n---\n\n#### .[afterLaunch(browser, launchContext)](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L125-L125)\n\n- `browser` **Browser** The `puppeteer` or `playwright` browser instance.\n- `launchContext` **LaunchContext**\n\nAfter the browser has launched.\n\nNote: Don't assume that there will only be a single browser instance during the lifecycle of a plugin.\nIt's possible that `pupeeteer.launch` will be called multiple times and more than one browser created.\nIn order to make the plugins as stateless as possible don't store a reference to the browser instance\nin the plugin but rather consider alternatives.\n\nE.g. when using `onPageCreated` you can get a browser reference by using `page.browser()`.\n\nAlternatively you could expose a class method that takes a browser instance as a parameter to work with:\n\n```es6\nconst fancyPlugin = require('puppeteer-extra-plugin-fancy')()\npuppeteer.use(fancyPlugin)\nconst browser = await puppeteer.launch()\nawait fancyPlugin.killBrowser(browser)\n```\n\nExample:\n\n```javascript\nasync afterLaunch (browser, opts) {\n  this.debug('browser has been launched', opts.options)\n}\n```\n\n---\n\n#### .[beforeConnect(options)](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L137-L139)\n\n- `options` **ConnectOptions** Puppeteer/playwright connect options\n\nReturns: **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)&lt;(ConnectOptions | void)>**\n\nBefore connecting to an existing browser instance.\n\nCan be used to modify the puppeteer/playwright connect options by modifying or returning them.\n\nPlugins using this method will be called in sequence to each\nbe able to update the launch options.\n\n---\n\n#### .[afterConnect(browser, launchContext)](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L149-L149)\n\n- `browser` **Browser** The `puppeteer` or playwright browser instance.\n- `launchContext` **LaunchContext**\n\nAfter connecting to an existing browser instance.\n\n> Note: Don't assume that there will only be a single browser instance during the lifecycle of a plugin.\n\n---\n\n#### .[onBrowser(browser, launchContext)](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L163-L163)\n\n- `browser` **Browser** The `puppeteer` or `playwright` browser instance.\n- `launchContext` **LaunchContext**\n\nCalled when a browser instance is available.\n\nThis applies to both `launch` and `connect`.\n\nConvenience method created for plugins that need access to a browser instance\nand don't mind if it has been created through `launch` or `connect`.\n\n> Note: Don't assume that there will only be a single browser instance during the lifecycle of a plugin.\n\n---\n\n#### .[beforeContext(options, browser)](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L178-L181)\n\n- `options` **Playwright.BrowserContextOptions** Playwright browser context options\n- `browser` **Playwright.Browser** Playwright browser\n\nReturns: **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)&lt;(Playwright.BrowserContextOptions | void)>**\n\nBefore a new browser context is created.\n\nNote: Currently only triggered by `playwright`, as puppeteer's usage of context is very lackluster.\n\nPlugins using this method will be called in sequence to each\nbe able to update the context options.\n\n- **See: <https://github.com/microsoft/playwright/blob/master/docs/api.md#browsernewcontextoptions>**\n\n---\n\n#### .[onContextCreated(context, options)](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L191-L194)\n\n- `context` **Playwright.BrowserContext** Playwright browser context\n- `options` **Playwright.BrowserContextOptions** Playwright browser context options\n\nAfter a new browser context has been created.\n\nNote: `playwright` specific.\n\n---\n\n#### .[onPageCreated(page)](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L215-L215)\n\n- `page` **(Puppeteer.Page | Playwright.Page)**\n\nCalled when a page has been created.\n\nThe event will also fire for popup pages.\n\nExample:\n\n```javascript\nasync onPageCreated (page) {\n  let ua = await page.browser().userAgent()\n  if (this.opts.stripHeadless) {\n    ua = ua.replace('HeadlessChrome/', 'Chrome/')\n  }\n  this.debug('new ua', ua)\n  await page.setUserAgent(ua)\n}\n```\n\n- **See: <https://playwright.dev/#version=v1.3.0&path=docs%2Fapi.md&q=event-page>**\n- **See: <https://pptr.dev/#?product=Puppeteer&version=main&show=api-event-targetcreated>**\n\n---\n\n#### .[onPageClose(page)](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L221-L221)\n\n- `page` **Page**\n\nCalled when a page has been closed.\n\n---\n\n#### .[onContextClose(context)](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L229-L229)\n\n- `context` **Playwright.BrowserContext**\n\nCalled when a browser context has been closed.\n\nNote: `playwright` specific.\n\n---\n\n#### .[onDisconnected(browser)](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L240-L240)\n\n- `browser` **Browser** The `puppeteer` or `playwright` browser instance.\n\nCalled when the browser got disconnected.\n\nThis might happen because of one of the following:\n\n- The browser is closed or crashed\n- The `browser.disconnect` method was called\n\n---\n\n### class: [AutomationExtraPlugin](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L263-L487)\n\n**Extends: PluginLifecycleMethods**\n\nAutomationExtraPlugin - Meant to be used as a base class and it's methods overridden.\n\nImplements all `PluginLifecycleMethods`.\n\nExample:\n\n```javascript\nclass Plugin extends AutomationExtraPlugin {\n  static id = 'foobar'\n  constructor(opts = {}) {\n    super(opts)\n  }\n\n  async beforeLaunch(options) {\n    options.headless = false\n    return options\n  }\n}\n```\n\n---\n\n#### .[env](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L291-L291)\n\nType: **[LauncherEnv](#launcherenv)**\n\nContains info regarding the launcher environment the plugin runs in\n\n- **See: LauncherEnv**\n\n---\n\n#### .[shim(page)](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L323-L323)\n\n- `page` **Page**\n\nReturns: **[PageShim](#pageshim)**\n\nUnified Page methods for Playwright & Puppeteer\n\n---\n\n#### .[defaults](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L352-L354)\n\nType: **PluginOptions**\n\nPlugin defaults (optional).\n\nIf defined will be ([deep-](https://github.com/TehShrike/deepmerge))merged with the (optional) user supplied options (supplied during plugin instantiation).\n\nThe result of merging defaults with user supplied options can be accessed through `this.opts`.\n\nExample:\n\n```javascript\nget defaults () {\n  return {\n    stripHeadless: true,\n    makeWindows: true,\n    customFn: null\n  }\n}\n\n// Users can overwrite plugin defaults during instantiation:\npuppeteer.use(require('puppeteer-extra-plugin-foobar')({ makeWindows: false }))\n```\n\n- **See: \\[[opts]]**\n\n---\n\n#### .[requirements](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L380-L382)\n\nType: **PluginRequirements**\n\nPlugin requirements (optional).\n\nSignal certain plugin requirements to the base class and the user.\n\nCurrently supported:\n\n- `launch`\n  - If the plugin only supports locally created browser instances (no `puppeteer.connect()`),\n    will output a warning to the user.\n- `headful`\n  - If the plugin doesn't work in `headless: true` mode,\n    will output a warning to the user.\n- `runLast`\n  - In case the plugin prefers to run after the others.\n    Useful when the plugin needs data from others.\n\nExample:\n\n```javascript\nget requirements () {\n  return new Set(['runLast', 'dataFromPlugins'])\n}\n```\n\n---\n\n#### .[filter](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L399-L401)\n\nType: **(Filter | [undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined))**\n\nPlugin filter statements (optional).\n\nFilter this plugin from being called depending on the environment.\n\nExample:\n\n```javascript\nget filter() {\n  return {\n    include: ['playwright:chromium', 'puppeteer:chromium']\n  }\n}\n```\n\n---\n\n#### .[dependencies](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L423-L425)\n\nType: **PluginDependencies**\n\nPlugin dependencies (optional).\n\nMissing plugins will be required() by automation-extra.\n\nExample:\n\n```javascript\n// Will ensure the 'puppeteer-extra-plugin-user-preferences' plugin is loaded.\nget dependencies () {\n  return new Set(['user-preferences'])\n}\n\n// Will load `user-preferences` plugin and pass `{ beCool: true }` as opts\nget dependencies () {\n  return new Map([['user-preferences', { beCool: true }]])\n}\n```\n\n---\n\n#### .[plugins](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L438-L440)\n\nType: **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;AutomationExtraPluginInstance>**\n\nAdd additional plugins (optional).\n\nExpects an array of AutomationExtraPlugin instances, not classes.\nThis is intended to be used by \"meta\" plugins that use other plugins behind the scenes.\n\nThe benefit over using `dependencies` is that this doesn't use the framework for dynamic imports,\nbut requires explicit imports which bundlers like webkit handle much better.\n\nMissing plugins listed here will be added at the start of `launch` or `connect` events.\n\n---\n\n#### .[opts](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L457-L459)\n\nType: **PluginOptions**\n\nAccess the plugin options (usually the `defaults` merged with user defined options)\n\nTo skip the auto-merging of defaults with user supplied opts don't define a `defaults`\nproperty and set the `this._opts` Object in your plugin constructor directly.\n\nExample:\n\n```javascript\nget defaults () { return { foo: \"bar\" } }\n\nasync onPageCreated (page) {\n  this.debug(this.opts.foo) // => bar\n}\n```\n\n- **See: \\[[defaults]]**\n\n---\n\n#### .[debug](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L477-L479)\n\nType: **Debugger**\n\nConvenience debug logger based on the [debug] module.\nWill automatically namespace the logging output to the plugin package name.\n\n[debug]: https://www.npmjs.com/package/debug\n\n```bash\n# toggle output using environment variables\nDEBUG=automation-extra-plugin:<plugin_id> node foo.js\n# to debug all the things:\nDEBUG=automation-extra,automation-extra-plugin:* node foo.js\n```\n\nExample:\n\n```javascript\nthis.debug('hello world')\n// will output e.g. 'automation-extra-plugin:anonymize-ua hello world'\n```\n\n---\n\n#### .[id](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L285-L285)\n\nPlugin id/name (required)\n\nConvention:\n\n- Package: `automation-extra-plugin-anonymize-ua`\n- Name: `anonymize-ua`\n\nExample:\n\n```javascript\nstatic id = 'anonymize-ua';\n// or\nstatic get id() {\n  return 'anonymize-ua'\n}\n```\n\n---\n\n### class: [TypeGuards](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L501-L566)\n\nTypeGuards: They allow differentiating between different objects and types.\n\nType guards work by discriminating against properties only found in that specific type.\nThis is especially useful when used with TypeScript as it improves type safety.\n\n---\n\n#### .[isPage(obj)](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L507-L509)\n\n- `obj` **any** The object to test\n\nReturns: **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)**\n\nType guard, will make TypeScript understand which type we're working with.\n\n---\n\n#### .[isBrowser(obj)](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L515-L517)\n\n- `obj` **any** The object to test\n\nReturns: **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)**\n\nType guard, will make TypeScript understand which type we're working with.\n\n---\n\n#### .[isPuppeteerPage(obj)](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L523-L525)\n\n- `obj` **any** The object to test\n\nReturns: **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)**\n\nType guard, will make TypeScript understand which type we're working with.\n\n---\n\n#### .[isPuppeteerBrowser(obj)](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L531-L533)\n\n- `obj` **any** The object to test\n\nReturns: **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)**\n\nType guard, will make TypeScript understand which type we're working with.\n\n---\n\n#### .[isPuppeteerBrowserContext(obj)](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L539-L541)\n\n- `obj` **any** The object to test\n\nReturns: **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)**\n\nType guard, will make TypeScript understand which type we're working with.\n\n---\n\n#### .[isPlaywrightPage(obj)](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L547-L549)\n\n- `obj` **any** The object to test\n\nReturns: **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)**\n\nType guard, will make TypeScript understand which type we're working with.\n\n---\n\n#### .[isPlaywrightBrowser(obj)](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L555-L557)\n\n- `obj` **any** The object to test\n\nReturns: **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)**\n\nType guard, will make TypeScript understand which type we're working with.\n\n---\n\n#### .[isPlaywrightBrowserContext(obj)](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L563-L565)\n\n- `obj` **any** The object to test\n\nReturns: **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)**\n\nType guard, will make TypeScript understand which type we're working with.\n\n---\n\n### class: [LauncherEnv](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L575-L622)\n\n**Extends: TypeGuards**\n\nStores environment specific info, populated by the launcher.\nThis allows sane plugin development in a multi-browser, multi-driver environment.\n\n---\n\n#### .[driverName](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L579-L579)\n\nThe name of the driver currently in use: `\"playwright\" | \"puppeteer\"`.\n\n---\n\n#### .[browserName](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L587-L587)\n\nThe name of the browser engine currently in use: `\"chromium\" | \"firefox\" | \"webkit\" | \"unknown\"`.\n\nNote: With puppeteer the browser will only be known once a browser object is available (after launching or connecting),\nas they support defining the browser during `.launch()`.\n\n---\n\n#### .[isPuppeteer](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L599-L601)\n\nCheck if current driver is puppeteer\n\n---\n\n#### .[isPlaywright](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L603-L605)\n\nCheck if current driver is playwright\n\n---\n\n#### .[isChromium](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L607-L609)\n\nCheck if current browser is chrome or chromium\n\n---\n\n#### .[isFirefox](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L611-L613)\n\nCheck if current browser is firefox\n\n---\n\n#### .[isWebkit](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L615-L617)\n\nCheck if current browser is webkit\n\n---\n\n#### .[isBrowserKnown](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L619-L621)\n\nCheck if current browser is known\n\n---\n\n### class: [PageShim](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L636-L666)\n\nUnified Page methods for Playwright & Puppeteer.\nThey support common actions through a single API.\n\n---\n\n#### .[addScript(script, arg?)](https://github.com/berstend/puppeteer-extra/blob/9583efba78ac4cfa547f5835592edd4a0f3a5c70/packages/automation-extra-plugin/src/index.ts#L657-L665)\n\n- `script` **([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) \\| [Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function))**\n- `arg` **Serializable?**\n\nAdds a script which would be evaluated in one of the following scenarios:\n\nWhenever the page is navigated.\nWhenever the child frame is attached or navigated. In this case, the script is evaluated in the context of the newly attached frame.\n\nThe script is evaluated after the document was created but before any of its scripts were run.\n\n- **See: **Playwright:** `addInitScript`\n  **Puppeteer:** `evaluateOnNewDocument`**\n\n---\n\n## License\n\nCopyright © 2018 - 2021, [berstend̡̲̫̹̠̖͚͓̔̄̓̐̄͛̀͘](https://github.com/berstend). Released under the MIT License.\n\n<!--\n  Reference links\n-->\n\n[automation-extra]: https://github.com/berstend/puppeteer-extra/tree/master/packages/automation-extra\n[playwright-extra]: https://github.com/berstend/puppeteer-extra/tree/master/packages/playwright-extra\n[puppeteer-extra]: https://github.com/berstend/puppeteer-extra/tree/master/packages/puppeteer-extra\n","readmeFilename":"readme.md","bugs":{"url":"https://github.com/berstend/puppeteer-extra/issues"},"_id":"automation-extra-plugin@4.2.2-next.616","_nodeVersion":"15.3.0","_npmVersion":"lerna/3.22.1/node@v15.3.0+x64 (darwin)","_npmUser":{"name":"berstend","email":"e.ndze.it@gmail.com"},"dist":{"integrity":"sha512-KwEM1GxITOKqDFElnoEbgWOLNl+IITstAJ2KZGAuCmcS09fjPQ1mG7uS31Za8BgaLwqdq1pQc/RShXdJLmH3AQ==","shasum":"3964b824b1ee047cf3c85d07a5b9101625cca2e9","tarball":"https://registry.npmjs.org/automation-extra-plugin/-/automation-extra-plugin-4.2.2-next.616.tgz","fileCount":16,"unpackedSize":169213,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgIkhJCRA9TVsSAnZWagAAC3kQAJNo/Ormj3w2t99e/2uc\nJlqgLkPosb5VLjJO7nqceKOlfR6MRFkvc1r4JrR2+X0EZzvAiLcuHBSH6IDI\ne7uCwwmZLdeFUUpQIJay3zgiFaogPA1Zsrv9epFDwRueVHrQMiRmXdBZpQvp\nL6/NJDFvBLCW6CeCfIzRpqLosCLlIY1FYD7CKxE1axwoAL48pruaP70OYvC3\nl04Z9DqKkWcQsQ9+yTOOqYSKCgMVUYZK6ZsI+bJ1Tbc8wVxOU5PgX4Tni/0b\nTWYv11cjqkVJ5dcaww1sVyQsJbV3jH+1LT7tLA3WhSWRjsof8jIYTZx3Sm9u\nltYxct7rGrSFELvBtjX+oZL6gHwImEoZSfEVwlXyypOQ5ZALHJMpoflrlnb+\njlo5h2OXzL6MOSqwEr+euM7EuVZIBLzRhbjYax1YQ82eQDOcMLX/lTYhcW6K\nBTI5+V+em2dK2jnoTZxpwKjgJXWHpqiAivDOvPi10F+eEeUYWy9d6Q3rmPOu\nF6VSztoxOCSfYPlNmkWGEyPlykR8bh6xJVoq1QohDf5dVY//qxatTEuQQqbB\nygk42tlFKe+03JaH5avhsso69nk9zWFheX2OU/6UPrA6W5bydTa6oub31IUm\n7jeqkWo4FTjcmsg0hOYaY1rchn602RxwJNYdT0q8qgvmdV/xLei51K3mQR6l\nEw3R\r\n=G6KM\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHG482W5wC5P543lZslPGZj1Opjiw7dhvqfjS/KeP9vCAiAZgoUUsPfKSqDkiv019miDXKwizFRNfZrEgnXGnHkLTg=="}]},"directories":{},"maintainers":[{"name":"berstend","email":"e.ndze.it@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/automation-extra-plugin_4.2.2-next.616_1612859464744_0.9381105446763782"},"_hasShrinkwrap":false}},"time":{"created":"2021-02-08T14:34:30.391Z","4.2.1-next.587":"2021-02-08T14:34:30.564Z","modified":"2022-04-11T16:04:42.407Z","4.2.2-next.593":"2021-02-08T15:50:36.156Z","4.2.2-next.615":"2021-02-09T08:27:53.170Z","4.2.2-next.616":"2021-02-09T08:31:04.875Z"},"maintainers":[{"name":"berstend","email":"e.ndze.it@gmail.com"}],"description":"Base class for automation-extra plugins (supports Playwright and Puppeteer).","homepage":"https://github.com/berstend/puppeteer-extra/tree/master/packages/automation-extra-plugin","keywords":["puppeteer","puppeteer-extra","playwright-extra","playwright","automation-extra-plugin","ua","user-agent","chrome","headless","pupeteer"],"repository":{"type":"git","url":"git+https://github.com/berstend/puppeteer-extra.git"},"author":{"name":"berstend"},"bugs":{"url":"https://github.com/berstend/puppeteer-extra/issues"},"license":"MIT","readme":"","readmeFilename":""}