mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2024-12-22 12:50:36 +01:00
Used api property to display correct text in ask mode.
This commit is contained in:
parent
1abc681e3f
commit
0f44820e3d
@ -135,6 +135,18 @@
|
||||
"message": "Wollen Sie das Auslesen des rot umrandeten <canvas> erlauben?",
|
||||
"description": ""
|
||||
},
|
||||
"askForAudioPermission": {
|
||||
"message": "Wollen Sie die Audio-API erlauben?",
|
||||
"description": ""
|
||||
},
|
||||
"askForAudioInputPermission": {
|
||||
"message": "Wollen Sie das Schreiben in über die Audio-API erlauben?",
|
||||
"description": ""
|
||||
},
|
||||
"askForAudioReadoutPermission": {
|
||||
"message": "Wollen Sie das Auslesen über die Audio-API erlauben?",
|
||||
"description": ""
|
||||
},
|
||||
"askOnlyOnce_title": {
|
||||
"message": "Nur einmal nachfragen",
|
||||
"description": ""
|
||||
|
@ -135,6 +135,18 @@
|
||||
"message": "Do you want to allow the readout of the red bordered <canvas>?",
|
||||
"description": ""
|
||||
},
|
||||
"askForAudioPermission": {
|
||||
"message": "Do you want to allow the audio API?",
|
||||
"description": ""
|
||||
},
|
||||
"askForAudioInputPermission": {
|
||||
"message": "Do you want to allow audio-API input?",
|
||||
"description": ""
|
||||
},
|
||||
"askForAudioReadoutPermission": {
|
||||
"message": "Do you want to allow audio readout?",
|
||||
"description": ""
|
||||
},
|
||||
"askOnlyOnce_title": {
|
||||
"message": "Ask only once",
|
||||
"description": ""
|
||||
|
@ -15,11 +15,11 @@
|
||||
const {parseErrorStack} = require("./callingStack");
|
||||
|
||||
// Check canvas appearance
|
||||
function canvasAppearance(window, context){
|
||||
function canvasAppearance(window, api, context){
|
||||
var oldBorder = false;
|
||||
var canvas = false;
|
||||
var inDOM = null;
|
||||
if (context){
|
||||
if (api === "canvas" && context){
|
||||
var nodeName;
|
||||
try {
|
||||
nodeName = context.nodeName;
|
||||
@ -44,9 +44,9 @@
|
||||
}
|
||||
return {
|
||||
canvas: canvas,
|
||||
askCategory: canvas? (inDOM? "visible": "invisible"): "nocanvas",
|
||||
askCategory: canvas? (inDOM? "visible": "invisible"): (api === "canvas"? "nocanvas": api),
|
||||
get text(){
|
||||
var text = canvas? (this.visible? "visible": "invisible"): "nocanvas";
|
||||
var text = canvas? (this.visible? "visible": "invisible"): (api === "canvas"? "nocanvas": api);
|
||||
Object.defineProperty(this, "text", {value: text});
|
||||
return text;
|
||||
},
|
||||
@ -85,7 +85,8 @@
|
||||
askText: {
|
||||
visible: _("askForVisiblePermission"),
|
||||
invisible: _("askForInvisiblePermission"),
|
||||
nocanvas: _("askForPermission")
|
||||
nocanvas: _("askForPermission"),
|
||||
audio: _("askForAudioPermission")
|
||||
},
|
||||
askStatus: {
|
||||
alreadyAsked: {},
|
||||
@ -96,7 +97,8 @@
|
||||
askText: {
|
||||
visible: _("askForVisibleInputPermission"),
|
||||
invisible: _("askForInvisibleInputPermission"),
|
||||
nocanvas: _("askForInputPermission")
|
||||
nocanvas: _("askForInputPermission"),
|
||||
audio: _("askForAudioInputPermission")
|
||||
},
|
||||
askStatus: {
|
||||
alreadyAsked: {},
|
||||
@ -107,7 +109,8 @@
|
||||
askText: {
|
||||
visible: _("askForVisibleReadoutPermission"),
|
||||
invisible: _("askForInvisibleReadoutPermission"),
|
||||
nocanvas: _("askForReadoutPermission")
|
||||
nocanvas: _("askForReadoutPermission"),
|
||||
audio: _("askForAudioReadoutPermission")
|
||||
},
|
||||
askStatus: {
|
||||
alreadyAsked: {},
|
||||
@ -120,15 +123,16 @@
|
||||
}
|
||||
}
|
||||
|
||||
scope.ask = function({window, type, canvas, errorStack}, {_, prefs}){
|
||||
scope.ask = function({window, type, api, canvas, errorStack}, {_, prefs}){
|
||||
var answer;
|
||||
var askMode = getAskMode(window, type, _);
|
||||
var askStatus = askMode.askStatus;
|
||||
var appearance = canvasAppearance(window, canvas);
|
||||
if (prefs("askOnlyOnce") !== "no" && askStatus.alreadyAsked[appearance.askCategory]){
|
||||
var appearance = canvasAppearance(window, api, canvas);
|
||||
var category = appearance.askCategory;
|
||||
if (prefs("askOnlyOnce") !== "no" && askStatus.alreadyAsked[category]){
|
||||
// already asked
|
||||
appearance.reset();
|
||||
return askStatus.answer[appearance.askCategory];
|
||||
return askStatus.answer[category];
|
||||
}
|
||||
else {
|
||||
let imgContainer = null;
|
||||
@ -171,6 +175,9 @@
|
||||
}
|
||||
// asking
|
||||
var msg = askMode.askText[appearance.text];
|
||||
|
||||
// visible vs invisible is only calculated here correctly
|
||||
category = appearance.text;
|
||||
if (prefs("showCallingFile")){
|
||||
msg += parseErrorStack(errorStack).toString(_);
|
||||
}
|
||||
@ -183,13 +190,13 @@
|
||||
["context", "readout", "input"].forEach(function(type){
|
||||
var askMode = getAskMode(window, type, _);
|
||||
var askStatus = askMode.askStatus;
|
||||
askStatus.alreadyAsked[appearance.text] = true;
|
||||
askStatus.answer[appearance.text] = answer;
|
||||
askStatus.alreadyAsked[category] = true;
|
||||
askStatus.answer[category] = answer;
|
||||
});
|
||||
}
|
||||
else {
|
||||
askStatus.alreadyAsked[appearance.text] = true;
|
||||
askStatus.answer[appearance.text] = answer;
|
||||
askStatus.alreadyAsked[category] = true;
|
||||
askStatus.answer[category] = answer;
|
||||
}
|
||||
appearance.reset();
|
||||
return answer;
|
||||
|
@ -232,10 +232,12 @@
|
||||
funcStatus.mode = ask({
|
||||
window: window,
|
||||
type: changedFunction.type,
|
||||
api: changedFunction.api,
|
||||
canvas: this instanceof HTMLCanvasElement?
|
||||
this:
|
||||
(
|
||||
this.canvas instanceof HTMLCanvasElement?
|
||||
this &&
|
||||
(this.canvas instanceof HTMLCanvasElement)?
|
||||
this.canvas:
|
||||
false
|
||||
),
|
||||
|
Loading…
x
Reference in New Issue
Block a user