Override Firefox Insecure Warnings with about:conf

2019-05-11 14:10发布

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条回答
Rolldiameter
2楼-- · 2019-05-11 14:56

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!

查看更多
登录 后发表回答