mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2025-07-04 04:26:35 +02: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
2 changed files with 39 additions and 0 deletions
|
@ -349,6 +349,39 @@
|
|||
|
||||
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 {
|
||||
logging.error("Try to fake non getter property:", changedGetter);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue