Last Updated: February 25, 2016
·
1.913K
· skeep

Take screenshot in chrome extension

If you are working on a Chrome extension and want to take a screenshot if the background webpage use the following code.

chrome.tabs.captureVisibleTab(null, {}, function (image) {
   console.log(image); //the image variable is a base64 encoded image which you should be able to load in either canvas or src attribute of an image.
});

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Did you know?

JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.

Security insights from Cside