Question: Google's "Report a Bug" or "Feedback Tool" lets you select an area of your browser window to create a screenshot that is submitted with your feedback about a bug.

![Google Feedback Tool Screenshot](https://i.stack.imgur.com/CDhEi.png)
*Screenshot by Jason Small, posted in a [duplicate question](https://stackoverflow.com/questions/6608327/google-style-send-feedback).* 

How are they doing this? Google's JavaScript feedback API is loaded from [here](https://ssl.gstatic.com/feedback/api.js) and [their overview of the feedback module](http://www.google.com/tools/feedback/intl/en/learnmore.html) will demonstrate the screenshot capability.

Answer: 
Here is a complete screenshot example that works with chrome in 2021. The end result is a blob ready to be transmitted. Flow is: request media > grab frame > draw to canvas > transfer to blob. If you want to do it more memory efficient explore [OffscreenCanvas](https://developer.mozilla.org/en-US/docs/Web/API/OffscreenCanvas) or possibly [ImageBitmapRenderingContext](https://developer.mozilla.org/en-US/docs/Web/API/ImageBitmapRenderingContext)

<https://jsfiddle.net/v24hyd3q/1/>

```
// Request media
navigator.mediaDevices.getDisplayMedia().then(stream => 
{
  // Grab frame from stream
  let track = stream.getVideoTracks()[0];
  let capture = new ImageCapture(track);
  capture.grabFrame().then(bitmap => 
  {
    // Stop sharing
    track.stop();

    // Draw the bitmap to canvas
    canvas.width = bitmap.width;
    canvas.height = bitmap.height;
    canvas.getContext('2d').drawImage(bitmap, 0, 0);

    // Grab blob from canvas
    canvas.toBlob(blob => {
        // Do things with blob here
        console.log('output blob:', blob);
    });
  });
})
.catch(e => console.log(e));

```
You can try my new JS library: [screenshot.js](https://github.com/amiad/screenshot.js).

It's enable to take real screenshot.

You load the script:

```html
<script src="https://raw.githubusercontent.com/amiad/screenshot.js/master/screenshot.js"></script>

```

and take screenshot:

```js
new Screenshot({success: img => {
        // callback function
        myimage = img;
    }});

```

You can read more options in project page.