mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2025-07-04 20:46:39 +02:00
parent
ab19ebd2c6
commit
77e079e5cc
7 changed files with 88 additions and 2 deletions
|
@ -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){
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue