I’m trying to override Object()
calls in JavaScript, in order to intercept and save all the parameters passed to the object constructor.
I don’t have any access to the original code since I am running from an injected code but I do run from the same scope and share the same window
of the original code.
I tried this approach:
(function (nativeObject) {
window.Object = function (value) {
if (value.magic) {
window.myMagic = value.magic;
}
return nativeObject(value);
}
})(Object);
as well as saving the original window.Object
on window.nativeObject
and calling it from within my hook, but in both ways I end up getting:
TypeError: Object.defineProperty is not a function
TypeError: Object.keys is not a function
Uncaught (in promise) TypeError: Object.isExtensible is not a function
Uncaught (in promise) TypeError: Object.create is not a function
Is it because my window.myMagic
calls the the Object
methods to set the myMagic
key in the window
object?
Is what I’m trying to do possible?