diff --git a/_locales/de/messages.json b/_locales/de/messages.json index e622196..e0f4c05 100644 --- a/_locales/de/messages.json +++ b/_locales/de/messages.json @@ -135,6 +135,18 @@ "message": "Wollen Sie das Auslesen des rot umrandeten 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": "" diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 5231541..3ed4e6c 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -135,6 +135,18 @@ "message": "Do you want to allow the readout of the red bordered ?", "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": "" diff --git a/lib/askForPermission.js b/lib/askForPermission.js index 34f01ec..1769134 100644 --- a/lib/askForPermission.js +++ b/lib/askForPermission.js @@ -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; diff --git a/lib/intercept.js b/lib/intercept.js index 4ccc60b..7cd0688 100644 --- a/lib/intercept.js +++ b/lib/intercept.js @@ -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 ),