mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2024-12-22 21:00:23 +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}){
|
forEachFunction(function({name, object}){
|
||||||
var map = originalPropertyDescriptors[name] || new WeakMap();
|
var map = originalPropertyDescriptors[name] || new WeakMap();
|
||||||
originalPropertyDescriptors[name] = map;
|
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.defineProperty(
|
||||||
object,
|
object,
|
||||||
name,
|
name,
|
||||||
@ -145,11 +151,14 @@
|
|||||||
if (preIntercepted){
|
if (preIntercepted){
|
||||||
preIntercepted = false;
|
preIntercepted = false;
|
||||||
forEachFunction(function({name, object}){
|
forEachFunction(function({name, object}){
|
||||||
|
const originalPropertyDescriptor = originalPropertyDescriptors[name].get(object);
|
||||||
|
if (originalPropertyDescriptor){
|
||||||
Object.defineProperty(
|
Object.defineProperty(
|
||||||
object,
|
object,
|
||||||
name,
|
name,
|
||||||
originalPropertyDescriptors[name].get(object)
|
originalPropertyDescriptor
|
||||||
);
|
);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -286,6 +295,7 @@
|
|||||||
var original = constructor.prototype[name];
|
var original = constructor.prototype[name];
|
||||||
const checker = generateChecker(name, changedFunction, siteStatus, original);
|
const checker = generateChecker(name, changedFunction, siteStatus, original);
|
||||||
var descriptor = Object.getOwnPropertyDescriptor(constructor.prototype, name);
|
var descriptor = Object.getOwnPropertyDescriptor(constructor.prototype, name);
|
||||||
|
if (descriptor){
|
||||||
if (descriptor.hasOwnProperty("value")){
|
if (descriptor.hasOwnProperty("value")){
|
||||||
if (changedFunction.fakeGenerator){
|
if (changedFunction.fakeGenerator){
|
||||||
descriptor.value = exportFunction(
|
descriptor.value = exportFunction(
|
||||||
@ -307,6 +317,7 @@
|
|||||||
}
|
}
|
||||||
Object.defineProperty(constructor.prototype, name, descriptor);
|
Object.defineProperty(constructor.prototype, name, descriptor);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -319,7 +330,7 @@
|
|||||||
const object = objectGetter(getWrapped(window));
|
const object = objectGetter(getWrapped(window));
|
||||||
if (object){
|
if (object){
|
||||||
const descriptor = Object.getOwnPropertyDescriptor(object, name);
|
const descriptor = Object.getOwnPropertyDescriptor(object, name);
|
||||||
if (descriptor.hasOwnProperty("get")){
|
if (descriptor && descriptor.hasOwnProperty("get")){
|
||||||
var original = descriptor.get;
|
var original = descriptor.get;
|
||||||
const checker = generateChecker(name, changedGetter, siteStatus, original);
|
const checker = generateChecker(name, changedGetter, siteStatus, original);
|
||||||
const getter = changedGetter.getterGenerator(checker);
|
const getter = changedGetter.getterGenerator(checker);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user