1
0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2024-11-11 23:58:52 +01:00

Show caller when asking for readout permission

Get stack and show the caller when asking for readout API permission.

Related to enhancement request to show source where canvas is nested.
https://github.com/kkapsner/CanvasBlocker/issues/8
This commit is contained in:
Jay Satiro 2014-12-06 22:38:07 -05:00
parent a8ff41bd95
commit 74dd775f98

View File

@ -101,10 +101,27 @@
status = askStatus.answer;
}
else {
// console.log("asking");
status = window.confirm(_(changedFunction.mode.askText))? "allow": "block";
//unsafeWindow.console.log("asking");
var callers = new Error().stack.split('\n');
var findme = callers.shift(); // Remove us from the stack
findme = findme.replace(/(:[0-9]+){1,2}$/, ""); // rm line & column
// Eliminate squashed stack. stack may contain 2+ stacks, but why...
for (var i = 0; callers[i]; i++){
if (callers[i].search(findme) == 0){
callers.splice(i, callers.length - i);
break;
}
}
var msg = _(changedFunction.mode.askText);
if (changedFunction.mode.askText === "askForReadoutPermission"){
msg += "\n\nCaller: " + callers[0];
// maybe show full stack here if some pref
//msg += "\n\nFull stack: \n" + callers.join('\n');
}
status = window.confirm(msg) ? "allow": "block";
askStatus.alreadyAsked = true;
askStatus.answer = status;
//unsafeWindow.console.log("asking (done)");
}
}
switch (status){