<commit_before># Chromy

Chromy is a library for operating headless chrome.

Chromy is similar to Nightmare.js but has some differences:

 - Controlling Chrome via Chrome DevTools Protocol.
 - Supports mobile emulation.
 - No need to prepare a screen such as xvfb.

## Requirements

 - Node 6 or later
 - Install Chrome59 or later to your machine before use Chromy.

headless mode is supported by Chrome59 or later.

## Installation

```bash
npm i chromy
```

## Usage

```js
const Chromy = require('chromy')

// not headless
// let chromy = new Chromy({visible:true})
let chromy = new Chromy()
chromy.chain()
      .goto('http://example.com/')
      .evaluate(() => {
        return document.querySelectorAll('*').length
      })
      .result((r) => console.log(r))
      .end()
      .then(() => chromy.close())
```

You can also use async/await interfaces like this:

```js
const Chromy = require('chromy')

async function main () {
  let chromy = new Chromy()
  await chromy.goto('http://example.com/')
  const result = await chromy.evaluate(() => {
          return document.querySelectorAll('*').length
        })
  console.log(result)
  await chromy.close()
}

main()
```

### Mobile Emulation

Chromy provides mobile emulation.  
The emulation changes a screen resolution, density, userAgent and provides touch emulation.

```js
const Chromy = require('chromy')

let chromy = new Chromy()
chromy.chain()
      .emulate('iPhone6')
      .goto('http://example.com/')
      .tap(100, 100) // emulate tap action by synthesizing touch events.
      .evaluate(() => {
        return navigator.userAgent
      })
      .result(console.log)
      .end()
      .then(() => chromy.close())
```

## FAQ

[FAQ](https://github.com/OnetapInc/chromy/wiki/FAQ)

## API

##### Chromy(options)<commit_msg>Add API index to README<commit_after># Chromy

Chromy is a library for operating headless chrome.

Chromy is similar to Nightmare.js but has some differences:

 - Controlling Chrome via Chrome DevTools Protocol.
 - Supports mobile emulation.
 - No need to prepare a screen such as xvfb.

## Requirements

 - Node 6 or later
 - Install Chrome59 or later to your machine before use Chromy.

headless mode is supported by Chrome59 or later.

## Installation

```bash
npm i chromy
```

## Usage

```js
const Chromy = require('chromy')

// not headless
// let chromy = new Chromy({visible:true})
let chromy = new Chromy()
chromy.chain()
      .goto('http://example.com/')
      .evaluate(() => {
        return document.querySelectorAll('*').length
      })
      .result((r) => console.log(r))
      .end()
      .then(() => chromy.close())
```

You can also use async/await interfaces like this:

```js
const Chromy = require('chromy')

async function main () {
  let chromy = new Chromy()
  await chromy.goto('http://example.com/')
  const result = await chromy.evaluate(() => {
          return document.querySelectorAll('*').length
        })
  console.log(result)
  await chromy.close()
}

main()
```

### Mobile Emulation

Chromy provides mobile emulation.  
The emulation changes a screen resolution, density, userAgent and provides touch emulation.

```js
const Chromy = require('chromy')

let chromy = new Chromy()
chromy.chain()
      .emulate('iPhone6')
      .goto('http://example.com/')
      .tap(100, 100) // emulate tap action by synthesizing touch events.
      .evaluate(() => {
        return navigator.userAgent
      })
      .result(console.log)
      .end()
      .then(() => chromy.close())
```

## FAQ

[FAQ](https://github.com/OnetapInc/chromy/wiki/FAQ)

## API

* [Chromy(options)](#chromyoptions)
* [.start(startingUrl = null)](#startstartingurl--null)
* [.goto(url, options = {})](#gotourl-options--)
* [.waitLoadEvent()](#waitloadevent)
* []()
* []()

##### Chromy(options)
{'fraction_non_alphanumeric': 0.14940711462450593, 'fraction_numerical': 0.006324110671936759, 'mean_word_length': 3.194475138121547, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2157801', 'n_tokens_mistral': 1286, 'n_tokens_neox': 1184, 'n_words': 350}