Take a screenshot using only js in Firefox extension

I am going to create a firefox extension. This extension requires the ability to take screenshots. Is it possible to do this only with javascript?

+3
source share
1 answer

UPDATE: This feature has been removed from Firefox if you are not writing a plugin. Please find various alternatives, see http://badassjs.com/post/12473322192/hack-of-the-day-rendering-html-to-a-canvas and https://developer.mozilla.org/en- US / docs / Web / API / CanvasRenderingContext2D / drawWindow

In those days, you could: take a screenshot of the firefox window, yes, and it was so easy that it hurt. You should have done it on canvas. See https://developer.mozilla.org/en/drawing_graphics_with_canvas#Rendering_Web_Content_Into_A_Canvas

<canvas id='my-canvas'></canvas>
<script> 
var canvas = document.getElementById('my-canvas');
var ctx = canvas.getContext("2d");
// Draw the window at the top left of canvas, width=100, height=200, white background
// drawWindow has been removed :(
ctx.drawWindow(window, 0,0, 100, 200, "rgb(255,255,255)");
// Open another window with the thumbnail as an image
open(canvas.toDataURL("image/png"));
</script>

If you mean a screenshot of the entire desktop, I don’t think that

+6
source

Source: https://habr.com/ru/post/1786542/


All Articles