1
0
Fork 0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2025-07-04 12:36:37 +02:00

Added showCanvasWhileAsking

Fixes #175
This commit is contained in:
kkapsner 2018-01-04 13:36:18 +01:00
parent ab19ebd2c6
commit 77e079e5cc
7 changed files with 88 additions and 2 deletions

View file

@ -131,12 +131,53 @@
return askStatus.answer[appearance.askCategory];
}
else {
let imgContainer = null;
if (type === "readout" && prefs("showCanvasWhileAsking") && canvas){
try {
let content = canvas.toDataURL();
let document = window.top.document;
imgContainer = document.createElement("div");
imgContainer.style.cssText = `
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.7);
color: white;
text-align: center;
z-index: 100000000000000;
padding: 1em;`;
let heading = document.createElement("h1");
heading.textContent = "CanvasBlocker";
imgContainer.appendChild(heading);
let text = document.createElement("div");
text.style.margin = "0.5em auto";
text.textContent = browser.i18n.getMessage("showCanvasWhileAsking_message");
imgContainer.appendChild(text);
let img = document.createElement("img");
img.style.backgroundColor = "white";
img.style.border = "2px solid lightgray";
img.src = HTMLCanvasElement.prototype.toDataURL.call(canvas);
imgContainer.appendChild(img);
document.body.appendChild(imgContainer);
}
catch (e){
// unable to read the canvas
}
}
// asking
var msg = askMode.askText[appearance.text];
if (prefs("showCallingFile")){
msg += parseErrorStack(errorStack).toString(_);
}
answer = window.top.confirm(msg)? "allow": prefs("askDenyMode");
if (imgContainer && imgContainer.parentNode){
imgContainer.parentNode.removeChild(imgContainer);
}
if (prefs("askOnlyOnce") === "combined"){
["context", "readout", "input"].forEach(function(type){

View file

@ -232,7 +232,13 @@
funcStatus.mode = ask({
window: window,
type: changedFunction.type,
canvas: this,
canvas: this instanceof HTMLCanvasElement?
this:
(
this.canvas instanceof HTMLCanvasElement?
this.canvas:
false
),
errorStack: error.stack
});
}

View file

@ -106,6 +106,10 @@
defaultValue: "block",
options: ["block", "fake"]
},
{
name: "showCanvasWhileAsking",
defaultValue: true
},
{
name: "showNotifications",
defaultValue: true,