chrome-ext-screen-capture

1.0.1 • Public • Published

chrome-ext-screen-capture

Capture screen from a chrome extension

Installation

In your manifest.json file, include the following:

"permissions"["tabs", "<all_urls>"],
"background"{
    "scripts": ["background.js"]
}

In your background page, put the following:

require('chrome-ext-screen-capture').backgroundPage()

In your content script, the following will return an img url:

var cesc = require('chrome-ext-screen-capture')
 
cesc.takeScreenshot(function (canvas) {
  /* You can use either a getBoundingClientRect() function or any individual jQuery object */
  var selection = document.getSelection().getRangeAt(0).getBoundingClientRect()
  var imgURL = cesc.renderPreview(selection, canvas, {padding: 20}).toDataURL('image/png')
  console.log('Check this out', imgURL)
})

Acknowledgments

Much of this code was originally sourced from Louis Li and his post.

Package Sidebar

Install

npm i chrome-ext-screen-capture

Weekly Downloads

2

Version

1.0.1

License

MIT

Last publish

Collaborators

  • richardlitt