Override Firefox Insecure Warnings with about:config

半腔热情 提交于 2020-01-02 08:41:06

问题


I am trying to write a simple batch script to take some screenshots of internal webpages on my end and came across the fact that firefox has this ability to render the window to canvas:

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"));

However, this seems to be reserved only form extensions and throws an Error: The operation is insecure.

I don't need to publish this to anyone else and I'm happy to make some internal adjustment to only my Firefox to avoid creating an extension. Is there some sort of about:config setting (or something else) I can tweak to just let this go through even if it's not in an extension?


回答1:


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!



来源:https://stackoverflow.com/questions/15961636/override-firefox-insecure-warnings-with-aboutconfig

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!