diff --git a/lib/intercept.js b/lib/intercept.js index faa4d0a..2455410 100644 --- a/lib/intercept.js +++ b/lib/intercept.js @@ -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); } diff --git a/lib/modifiedWindowAPI.js b/lib/modifiedWindowAPI.js index e9d94d6..7cc6533 100644 --- a/lib/modifiedWindowAPI.js +++ b/lib/modifiedWindowAPI.js @@ -36,6 +36,12 @@ } }; return Object.getOwnPropertyDescriptor(temp, "opener").get; + }, + valueGenerator: function({original, notify}){ + if (original !== null){ + notify("fakedWindowReadout"); + } + return null; } }, {