1
0
Fork 0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2025-07-04 20:46:39 +02:00

First proxy attempt

This commit is contained in:
kkapsner 2021-01-26 13:47:59 +01:00
parent 42b19a4ba5
commit 211d6710f6
4 changed files with 46 additions and 17 deletions

View file

@ -240,7 +240,7 @@
name, changedFunction, siteStatus, original,
window: windowToProcess, prefs, notify, checkStack, ask
}){
return function checker(callingDepth = 2){
return function checker(callingDepth = 3){
const errorStack = (new Error()).stack;
try {
@ -344,24 +344,39 @@
let changed;
if (type ==="value"){
if (changedFunction.fakeGenerator){
changed = extension.exportFunctionWithName(
changedFunction.fakeGenerator(checker, original, windowToProcess),
windowToProcess,
original.name
);
// const proxy = new windowToProcess.Proxy(original, {apply: function(target, thisArgs, args){
// console.log(target, thisArgs, args, generated);
// return generated.apply(thisArgs, args);
// }});
if ((changedFunction.exportOptions || {}).allowCallbacks){
changed = extension.exportFunctionWithName(
changedFunction.fakeGenerator(checker, original, windowToProcess),
windowToProcess,
original.name
);
}
else {
const generated = changedFunction.fakeGenerator(checker, original, windowToProcess);
changed = extension.createProxyFunction(windowToProcess, original, generated);
}
}
else {
changed = null;
}
}
else {
changed = extension.exportFunctionWithName(function(){
return extension.exportFunctionWithName(
changedFunction.fakeGenerator(checker),
windowToProcess,
original.name
);
}, windowToProcess, descriptor.get.name);
// changed = extension.exportFunctionWithName(function(){
// return extension.exportFunctionWithName(
// changedFunction.fakeGenerator(checker),
// windowToProcess,
// original.name
// );
// }, windowToProcess, descriptor.get.name);
changed = extension.createProxyFunction(windowToProcess, original, extension.exportFunctionWithName(
changedFunction.fakeGenerator(checker),
windowToProcess,
original.name
));
}
extension.changeProperty(windowToProcess, changedFunction.api, {
object, name, type, changed
@ -393,7 +408,8 @@
extension.changeProperty(windowToProcess, changedGetter.api,
{
object, name, type: "get",
changed: extension.exportFunctionWithName(getter, windowToProcess, original.name)
// changed: extension.exportFunctionWithName(getter, windowToProcess, original.name)
changed: extension.createProxyFunction(windowToProcess, original, getter)
}
);
@ -407,7 +423,8 @@
extension.changeProperty(windowToProcess, changedGetter.api,
{
object, name, type: "set",
changed: extension.exportFunctionWithName(setter, windowToProcess, original.name)
// changed: extension.exportFunctionWithName(setter, windowToProcess, original.name)
changed: extension.createProxyFunction(windowToProcess, original, setter)
}
);
}