Skip to content

Commit

Permalink
Add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats committed Sep 10, 2018
1 parent ec8137a commit 07fb497
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
16 changes: 16 additions & 0 deletions README.md
Expand Up @@ -84,6 +84,22 @@ https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#puppeteerlaunc

By default the library will be pass a well known list of flags, so probably you don't need any additional setup.

##### timeout

type:`number`</br>
default: `30000`

This setting will change the default maximum navigation time.

##### incognito

type:`boolean`</br>
default: `true`

Every time a new page is created, it will be an incognito page.

An incognito page will not share cookies/cache with other browser pages.

### .pool(options)

Tha main **browserless** constructor expose a singleton browser. This is enough for most scenarios, but in case you need you can intialize a **pool of instances**.
Expand Down
11 changes: 9 additions & 2 deletions src/browserless.js
Expand Up @@ -36,7 +36,11 @@ const createTempFile = opts => {
// The puppeteer launch causes many events to be emitted.
process.setMaxListeners(0)

module.exports = launchOpts => {
module.exports = ({
incognito = true,
timeout = 30000,
...launchOpts
} = {}) => {
let browser = puppeteer.launch({
ignoreHTTPSErrors: true,
args: [
Expand All @@ -59,8 +63,11 @@ module.exports = launchOpts => {

const newPage = () =>
Promise.resolve(browser).then(async browser => {
const context = await browser.createIncognitoBrowserContext()
const context = incognito
? await browser.createIncognitoBrowserContext()
: browser
const page = await context.newPage()
page.setDefaultNavigationTimeout(timeout)
return page
})

Expand Down

0 comments on commit 07fb497

Please sign in to comment.