I'm writing a short game hacking project. As such, I need a way to retrieve a class that is wrapped in an anonymous function without any global references. The simplified class layout looks like this:
class n {
constructor() {
this.test = localStorage.getItem("test");
}
}
My approach is to proxy the localStorage.getItem function called inside the constructor.
The issue appears when I access the caller: it returns null. My code is as following:
class n {
constructor() {
this.test = localStorage.getItem("test");
}
}
localStorage.getItem = new Proxy(localStorage.getItem, {
apply: function(target, that, args) {
console.log(arguments.callee.caller);
}
})
const l = new n();