mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2024-12-22 12:50:36 +01:00
Added protection from undefined properties.
DOMRect has some new properties that are only in nightly at the moment.
This commit is contained in:
parent
350fdd3278
commit
1d5953e8c7
@ -100,7 +100,13 @@
|
||||
forEachFunction(function({name, object}){
|
||||
var map = originalPropertyDescriptors[name] || new WeakMap();
|
||||
originalPropertyDescriptors[name] = map;
|
||||
map.set(object, Object.getOwnPropertyDescriptor(object, name));
|
||||
|
||||
const originalPropertyDescriptor = Object.getOwnPropertyDescriptor(object, name);
|
||||
if (!originalPropertyDescriptor){
|
||||
return;
|
||||
}
|
||||
|
||||
map.set(object, originalPropertyDescriptor);
|
||||
Object.defineProperty(
|
||||
object,
|
||||
name,
|
||||
@ -145,11 +151,14 @@
|
||||
if (preIntercepted){
|
||||
preIntercepted = false;
|
||||
forEachFunction(function({name, object}){
|
||||
Object.defineProperty(
|
||||
object,
|
||||
name,
|
||||
originalPropertyDescriptors[name].get(object)
|
||||
);
|
||||
const originalPropertyDescriptor = originalPropertyDescriptors[name].get(object);
|
||||
if (originalPropertyDescriptor){
|
||||
Object.defineProperty(
|
||||
object,
|
||||
name,
|
||||
originalPropertyDescriptor
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
@ -286,26 +295,28 @@
|
||||
var original = constructor.prototype[name];
|
||||
const checker = generateChecker(name, changedFunction, siteStatus, original);
|
||||
var descriptor = Object.getOwnPropertyDescriptor(constructor.prototype, name);
|
||||
if (descriptor.hasOwnProperty("value")){
|
||||
if (changedFunction.fakeGenerator){
|
||||
descriptor.value = exportFunction(
|
||||
changedFunction.fakeGenerator(checker),
|
||||
window
|
||||
);
|
||||
if (descriptor){
|
||||
if (descriptor.hasOwnProperty("value")){
|
||||
if (changedFunction.fakeGenerator){
|
||||
descriptor.value = exportFunction(
|
||||
changedFunction.fakeGenerator(checker),
|
||||
window
|
||||
);
|
||||
}
|
||||
else {
|
||||
descriptor.value = null;
|
||||
}
|
||||
}
|
||||
else {
|
||||
descriptor.value = null;
|
||||
descriptor.get = exportFunction(function(){
|
||||
return exportFunction(
|
||||
changedFunction.fakeGenerator(checker),
|
||||
window
|
||||
);
|
||||
}, window);
|
||||
}
|
||||
Object.defineProperty(constructor.prototype, name, descriptor);
|
||||
}
|
||||
else {
|
||||
descriptor.get = exportFunction(function(){
|
||||
return exportFunction(
|
||||
changedFunction.fakeGenerator(checker),
|
||||
window
|
||||
);
|
||||
}, window);
|
||||
}
|
||||
Object.defineProperty(constructor.prototype, name, descriptor);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -319,7 +330,7 @@
|
||||
const object = objectGetter(getWrapped(window));
|
||||
if (object){
|
||||
const descriptor = Object.getOwnPropertyDescriptor(object, name);
|
||||
if (descriptor.hasOwnProperty("get")){
|
||||
if (descriptor && descriptor.hasOwnProperty("get")){
|
||||
var original = descriptor.get;
|
||||
const checker = generateChecker(name, changedGetter, siteStatus, original);
|
||||
const getter = changedGetter.getterGenerator(checker);
|
||||
|
Loading…
x
Reference in New Issue
Block a user