-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
38 lines (31 loc) · 698 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
'use strict'
const { PuppeteerExtraPlugin } = require('puppeteer-extra-plugin')
const utils = require('./util')
/**
* Minimize/Maximize puppeteer pages in real time
*
* @example
* await page.minimize()
* await page.maximize()
*/
class Plugin extends PuppeteerExtraPlugin {
constructor(opts = {}) {
super(opts)
}
get name() {
return 'minmax'
}
async minimize() {
return utils.minimize(this)
}
async maximize() {
return utils.maximize(this)
}
async onPageCreated(page) {
page.minimize = this.minimize.bind(page)
page.maximize = this.maximize.bind(page)
}
}
module.exports = function(pluginConfig) {
return new Plugin(pluginConfig)
}