javascript - 在 firefox 扩展中仅使用 js 截屏

标签 javascript firefox-addon

我正在考虑构建一个 Firefox 扩展。 此扩展需要执行屏幕截图的能力。 是否可以只使用 javascript 这样做?

最佳答案

更新:此功能已从 Firefox 中删除,除非您正在编写插件。请寻找不同的替代方案,请参阅 http://badassjs.com/post/12473322192/hack-of-the-day-rendering-html-to-a-canvashttps://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/drawWindow

过去,您可以:截取 firefox 窗口的屏幕截图,是的,这很容易造成伤害。您必须将其渲染到 Canvas 中。参见 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>

如果你指的是整个桌面的截图,我不这么认为

关于javascript - 在 firefox 扩展中仅使用 js 截屏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4742129/

相关文章:

javascript - 如何在 Strapi v3 中创建多级(嵌套)类别?

javascript - 新元素的CSS过渡

firefox-addon - 从内容脚本访问本地资源

javascript - 如何获取网络扩展图标来调用javascript

javascript - 用于切换侧边栏的 Firefox WebExtension 工具栏按钮

javascript - Javascript 'require' 是什么?

javascript - WebStorm Async Await 调试 Node.js Sails.js

javascript - 根据先前捕获的组值进行检查

javascript - 在较新的 Firefox 附加组件上使用 Blob

google-chrome-extension - 有没有办法记录所有 DOM 方法调用