我正在尝试编写一个简单的批处理脚本来截取内部网页的一些屏幕截图,并发现 Firefox 具有将窗口渲染到画布的能力:
var canvas = document.createElement('canvas');
var ctx = canvas.getContext("2d");
ctx.drawWindow(window, 0,0, 100, 200, "rgb(255,255,255)");
console.log(canvas.toDataURL("image/png"));
然而,这似乎只保留形式扩展并抛出错误:操作不安全。
我不需要将其发布给其他任何人,并且我很乐意仅对我的 Firefox 进行一些内部调整以避免创建扩展。是否有某种 about:config 设置(或其他设置)我可以调整以让它通过,即使它不在扩展中?
Go to about:config
and set devtools.chrome.enabled
to true
Restart
Go to the tab you want to take screenshot
Press Shift+F4
Switch environment to Browser
Paste the following snippet
var canvas = gBrowser.contentDocument.createElement('canvas');
var ctx = canvas.getContext("2d");
ctx.drawWindow(window, 0,0, 100, 200, "rgb(255,255,255)");
canvas.toDataURL("image/png");
Place the cursor at the end of the last line
Press Control+L
Mission accomplished!
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)