Skip to content

Commit a7f7bda

Browse files
committed
First commit
0 parents  commit a7f7bda

16 files changed

+368
-0
lines changed

.bumpedrc

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
files:
2+
- package.json
3+
plugins:
4+
prerelease:
5+
Linting config files:
6+
plugin: bumped-finepack
7+
postrelease:
8+
Generating CHANGELOG file:
9+
plugin: bumped-changelog
10+
Committing new version:
11+
plugin: bumped-terminal
12+
command: 'git add CHANGELOG.md package.json && git commit -m "Release $newVersion"'
13+
Detecting problems before publish:
14+
plugin: bumped-terminal
15+
command: 'git-dirty && npm test'
16+
Publishing tag to GitHub:
17+
plugin: bumped-terminal
18+
command: 'git tag $newVersion && git push && git push --tags'
19+
Publishing to NPM:
20+
plugin: bumped-terminal
21+
command: npm publish

.editorconfig

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# http://editorconfig.org
2+
3+
root = true
4+
5+
[*]
6+
indent_style = space
7+
indent_size = 2
8+
end_of_line = lf
9+
charset = utf-8
10+
trim_trailing_whitespace = true
11+
insert_final_newline = true
12+
max_line_length = 100
13+
indent_brace_style = 1TBS
14+
spaces_around_operators = true
15+
quote_type = auto
16+
17+
[package.json]
18+
indent_style = space
19+
indent_size = 2
20+
21+
[*.md]
22+
trim_trailing_whitespace = false

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto

.gitignore

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
############################
2+
# npm
3+
############################
4+
node_modules
5+
npm-debug.log
6+
7+
############################
8+
# tmp, editor & OS files
9+
############################
10+
.tmp
11+
*.swo
12+
*.swp
13+
*.swn
14+
*.swm
15+
.DS_Store
16+
*#
17+
*~
18+
.idea
19+
*sublime*
20+
nbproject
21+
22+
############################
23+
# Tests
24+
############################
25+
testApp
26+
coverage
27+
.nyc_output
28+
29+
############################
30+
# Other
31+
############################
32+
.node_history

.npmignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
.idea
2+
.project
3+
*.sublime-*
4+
.DS_Store
5+
*.seed
6+
*.log
7+
*.csv
8+
*.dat
9+
*.out
10+
*.pid
11+
*.swp
12+
*.swo
13+
node_modules
14+
coverage
15+
*.tgz
16+
*.xml

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
unsafe-perm=true

.travis.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
language: node_js
2+
node_js:
3+
- "node"
4+
- "lts/*"
5+
after_success: npm run coveralls

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright © 2017 Kiko Beats <josefrancisco.verdu@gmail.com> (kikobeats.com)
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

README.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# frowser
2+
3+
<p align="center">
4+
<br>
5+
<img src="https://i.imgur.com/Mh13XWB.gif" alt="frowser">
6+
<br>
7+
</p>
8+
9+
![Last version](https://img.shields.io/github/tag/Kikobeats/frowser.svg?style=flat-square)
10+
[![Build Status](https://img.shields.io/travis/Kikobeats/frowser/master.svg?style=flat-square)](https://travis-ci.org/Kikobeats/frowser)
11+
[![Coverage Status](https://img.shields.io/coveralls/Kikobeats/frowser.svg?style=flat-square)](https://coveralls.io/github/Kikobeats/frowser)
12+
[![Dependency status](https://img.shields.io/david/Kikobeats/frowser.svg?style=flat-square)](https://david-dm.org/Kikobeats/frowser)
13+
[![Dev Dependencies Status](https://img.shields.io/david/dev/Kikobeats/frowser.svg?style=flat-square)](https://david-dm.org/Kikobeats/frowser#info=devDependencies)
14+
[![NPM Status](https://img.shields.io/npm/dm/frowser.svg?style=flat-square)](https://www.npmjs.org/package/frowser)
15+
[![Donate](https://img.shields.io/badge/donate-paypal-blue.svg?style=flat-square)](https://paypal.me/Kikobeats)
16+
17+
**NOTE:** more badges availables in [shields.io](https://shields.io/)
18+
19+
> Accessing to browser from the Upside Down
20+
21+
## Install
22+
23+
```bash
24+
$ npm install frowser --save
25+
```
26+
27+
## Usage
28+
29+
```js
30+
const frowser = require('frowser')
31+
32+
frowser('do something')
33+
//=> return something
34+
```
35+
36+
## API
37+
38+
### frowser(input, [options])
39+
40+
#### input
41+
42+
*Required*<br>
43+
Type: `string`
44+
45+
Lorem ipsum.
46+
47+
#### options
48+
49+
##### foo
50+
51+
Type: `boolean`<br>
52+
Default: `false`
53+
54+
Lorem ipsum.
55+
## License
56+
57+
**frowser** © [Kiko Beats](https://kikobeats.com), Released under the [MIT](https://github.com/Kikobeats/frowser/blob/master/LICENSE.md) License.<br>
58+
Authored and maintained by Kiko Beats with help from [contributors](https://github.com/Kikobeats/frowser/contributors).
59+
60+
> [kikobeats.com](https://kikobeats.com) · GitHub [Kiko Beats](https://github.com/kikobeats) · Twitter [@kikobeats](https://twitter.com/kikobeats)

index.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
'use strict'
2+
3+
const createTempFile = require('create-temp-file2')
4+
const puppeteer = require('puppeteer')
5+
6+
async function getHTML (url, opts = {}) {
7+
const browser = await puppeteer.launch()
8+
const page = await browser.newPage()
9+
await page.goto(url, opts)
10+
const bodyHTML = await page.evaluate(() => document.documentElement.innerHTML)
11+
browser.close()
12+
return bodyHTML
13+
}
14+
15+
async function takeScreenshot (url, opts = {}) {
16+
const { type = 'png' } = opts
17+
const tempFile = createTempFile({ ext: `.${type}` })
18+
const { path } = tempFile
19+
20+
const browser = await puppeteer.launch()
21+
const page = await browser.newPage()
22+
await page.goto(url)
23+
await page.screenshot(Object.assign({ path, type }, opts))
24+
browser.close()
25+
26+
return Promise.resolve(tempFile)
27+
}
28+
29+
module.exports = {
30+
getHTML,
31+
takeScreenshot
32+
}

0 commit comments

Comments
 (0)