mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2025-07-04 12:36:37 +02:00
parent
e2efb727b9
commit
f3f6df229f
5 changed files with 122 additions and 58 deletions
|
@ -331,21 +331,22 @@
|
|||
});
|
||||
const descriptor = Object.getOwnPropertyDescriptor(object, name);
|
||||
if (!descriptor) return;
|
||||
|
||||
if (descriptor.hasOwnProperty("value")){
|
||||
const type = descriptor.hasOwnProperty("value")? "value": "get";
|
||||
let changed;
|
||||
if (type ==="value"){
|
||||
if (changedFunction.fakeGenerator){
|
||||
descriptor.value = extension.exportFunctionWithName(
|
||||
changed = extension.exportFunctionWithName(
|
||||
changedFunction.fakeGenerator(checker, original, windowToProcess),
|
||||
windowToProcess,
|
||||
original.name
|
||||
);
|
||||
}
|
||||
else {
|
||||
descriptor.value = null;
|
||||
changed = null;
|
||||
}
|
||||
}
|
||||
else {
|
||||
descriptor.get = extension.exportFunctionWithName(function(){
|
||||
changed = extension.exportFunctionWithName(function(){
|
||||
return extension.exportFunctionWithName(
|
||||
changedFunction.fakeGenerator(checker),
|
||||
windowToProcess,
|
||||
|
@ -353,7 +354,9 @@
|
|||
);
|
||||
}, windowToProcess, descriptor.get.name);
|
||||
}
|
||||
Object.defineProperty(object, name, descriptor);
|
||||
extension.changeProperty(windowToProcess, changedFunction.api, {
|
||||
object, name, type, changed
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -378,7 +381,12 @@
|
|||
window: windowToProcess, prefs, checkStack, ask, notify
|
||||
});
|
||||
const getter = changedGetter.getterGenerator(checker, original, windowToProcess);
|
||||
descriptor.get = extension.exportFunctionWithName(getter, windowToProcess, original.name);
|
||||
extension.changeProperty(windowToProcess, changedGetter.api,
|
||||
{
|
||||
object, name, type: "get",
|
||||
changed: extension.exportFunctionWithName(getter, windowToProcess, original.name)
|
||||
}
|
||||
);
|
||||
|
||||
if (descriptor.hasOwnProperty("set") && descriptor.set && changedGetter.setterGenerator){
|
||||
const original = descriptor.set;
|
||||
|
@ -387,10 +395,14 @@
|
|||
original,
|
||||
prefs
|
||||
);
|
||||
descriptor.set = extension.exportFunctionWithName(setter, windowToProcess, original.name);
|
||||
extension.changeProperty(windowToProcess, changedGetter.api,
|
||||
{
|
||||
object, name, type: "set",
|
||||
changed: extension.exportFunctionWithName(setter, windowToProcess, original.name)
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
Object.defineProperty(object, name, descriptor);
|
||||
}
|
||||
else if (
|
||||
changedGetter.valueGenerator &&
|
||||
|
@ -405,21 +417,23 @@
|
|||
}
|
||||
switch (functionStatus.mode){
|
||||
case "ask": case "block": case "fake":
|
||||
descriptor.value = changedGetter.valueGenerator({
|
||||
mode: functionStatus.mode,
|
||||
original: descriptor.value,
|
||||
notify: function notifyCallback(messageId){
|
||||
notify({
|
||||
url: getURL(windowToProcess),
|
||||
errorStack: (new Error()).stack,
|
||||
messageId,
|
||||
timestamp: new Date(),
|
||||
functionName: name,
|
||||
api: changedGetter.api
|
||||
});
|
||||
}
|
||||
extension.changeProperty(windowToProcess, changedGetter.api, {
|
||||
object, name, type: "value",
|
||||
changed: changedGetter.valueGenerator({
|
||||
mode: functionStatus.mode,
|
||||
original: descriptor.value,
|
||||
notify: function notifyCallback(messageId){
|
||||
notify({
|
||||
url: getURL(windowToProcess),
|
||||
errorStack: (new Error()).stack,
|
||||
messageId,
|
||||
timestamp: new Date(),
|
||||
functionName: name,
|
||||
api: changedGetter.api
|
||||
});
|
||||
}
|
||||
})
|
||||
});
|
||||
Object.defineProperty(object, name, descriptor);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue