mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2024-12-22 21:00:23 +01:00
Future proof: getters my be values in other browsers
Example: window.opener is a value property in Chrome.
This commit is contained in:
parent
d666d68812
commit
a95fae3de8
@ -349,6 +349,39 @@
|
|||||||
|
|
||||||
Object.defineProperty(object, name, descriptor);
|
Object.defineProperty(object, name, descriptor);
|
||||||
}
|
}
|
||||||
|
else if (
|
||||||
|
changedGetter.valueGenerator &&
|
||||||
|
descriptor && descriptor.hasOwnProperty("value")
|
||||||
|
){
|
||||||
|
const protectedAPIFeatures = prefs("protectedAPIFeatures");
|
||||||
|
if (
|
||||||
|
functionStatus.active &&
|
||||||
|
(
|
||||||
|
!protectedAPIFeatures.hasOwnProperty(name) ||
|
||||||
|
protectedAPIFeatures[name]
|
||||||
|
)
|
||||||
|
){
|
||||||
|
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(window),
|
||||||
|
errorStack: (new Error()).stack,
|
||||||
|
messageId,
|
||||||
|
timestamp: new Date(),
|
||||||
|
functionName: name,
|
||||||
|
api: changedGetter.api
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
Object.defineProperty(object, name, descriptor);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
logging.error("Try to fake non getter property:", changedGetter);
|
logging.error("Try to fake non getter property:", changedGetter);
|
||||||
}
|
}
|
||||||
|
@ -36,6 +36,12 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
return Object.getOwnPropertyDescriptor(temp, "opener").get;
|
return Object.getOwnPropertyDescriptor(temp, "opener").get;
|
||||||
|
},
|
||||||
|
valueGenerator: function({original, notify}){
|
||||||
|
if (original !== null){
|
||||||
|
notify("fakedWindowReadout");
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user