1
0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2024-12-22 12:50:36 +01:00

Added ability to use objectGetters on faked functions.

This commit is contained in:
kkapsner 2019-11-07 17:38:54 +01:00
parent 73657852d3
commit 5d6c2d9a47

View File

@ -79,10 +79,23 @@
Array.isArray(changedFunction.object)? Array.isArray(changedFunction.object)?
changedFunction.object: changedFunction.object:
[changedFunction.object] [changedFunction.object]
).map(function(name){
if (name){
const constructor = getWrapped(window)[name];
if (constructor){
return constructor.prototype;
}
}
return false;
}).concat(
changedFunction.objectGetters?
changedFunction.objectGetters.map(function(objectGetter){
return objectGetter(getWrapped(window));
}):
[]
).forEach(function(object){ ).forEach(function(object){
const constructor = getWrapped(window)[object]; if (object){
if (constructor){ callback({name, object: object});
callback({name, object: constructor.prototype});
} }
}); });
}); });
@ -295,12 +308,25 @@
Array.isArray(changedFunction.object)? Array.isArray(changedFunction.object)?
changedFunction.object: changedFunction.object:
[changedFunction.object] [changedFunction.object]
).map(function(name){
if (name){
const constructor = getWrapped(window)[name];
if (constructor){
return constructor.prototype;
}
}
return false;
}).concat(
changedFunction.objectGetters?
changedFunction.objectGetters.map(function(objectGetter){
return objectGetter(getWrapped(window));
}):
[]
).forEach(function(object){ ).forEach(function(object){
const constructor = getWrapped(window)[object]; if (object){
if (constructor){ const original = object[name];
const original = constructor.prototype[name];
const checker = generateChecker(name, changedFunction, siteStatus, original); const checker = generateChecker(name, changedFunction, siteStatus, original);
const descriptor = Object.getOwnPropertyDescriptor(constructor.prototype, name); const descriptor = Object.getOwnPropertyDescriptor(object, name);
if (descriptor){ if (descriptor){
if (descriptor.hasOwnProperty("value")){ if (descriptor.hasOwnProperty("value")){
if (changedFunction.fakeGenerator){ if (changedFunction.fakeGenerator){
@ -321,7 +347,7 @@
); );
}, window); }, window);
} }
Object.defineProperty(constructor.prototype, name, descriptor); Object.defineProperty(object, name, descriptor);
} }
} }
}); });