google chrome - JavaScript - Make Proxy undetectable -


as understand, es spec says proxy (global constructor proxifying objects, functions , classes) not detectable. means if proxify function, nobody uses proxified function can detect used proxy. however, apparently misunderstood it, becuase proxifying functions detectable.

for example, new proxy(a=>a,{apply:a=>a})+'' throws error. says

uncaught typeerror: function.prototype.tostring requires 'this' function 

however, typeof new proxy(a=>a,{apply:a=>a}) indeed "function", somehow fails stringify proxy. so, obviously, here situation when proxified function doesn't behave non-proxified 1 should. function.prototype.tostring able distinguish proxified , non-proxified function.

my goal proxify function such simple become undetectable. first idea literally proxify proxy so:

proxy.tostring = (a => () => a)(proxy + ''); proxy = new proxy(proxy, {   construct: (f, args) => {     if(typeof args[0] == 'function'){       var = args[0] + '';       args[0].tostring = () => a;     }     return new f(...args);   } }); 

but, sadly, detectable. if call function.prototype.tostring binded proxified function, error occur , can therefore detect function proxy. so, tried proxify function , function.prototype , function.prototype.tostring, realized cannot proxify function because if override global property function, may access using (a=>a).constructor.

so, why asking here because ran out of ideas. how proxify function make completelly undetectable? in es spec explicitly says "proxy undetectable", side question, why proxifying function detectable?

edit

the reason i'm trying achieve because i'm working on enhanced advertisement blocking extension chrome. dealing agressive website exploits huge amount of javascript tricks detect if i'm viewing ads or not. so, basically, deleted advertisement, , script checks if there specific element, if not, cannot visit website. so, tried proxify document.getelementbyid, check if proxified , if is, cannot visit website, must make undetectable.

i don't think you're trying possible proxies. spec function.prototype.tostring defines typeerror-throwing behavior. since there's no way give proxy [[ecmascriptcode]] "internal slot", it'll throw when called on proxy.

i see no mention of "proxy undetectable" statement in spec; string 'detectable' doesn't show anywhere in document. did find claim?

maybe can overwrite functions (and .tostring properties) achieve goal? roughly:

var original_getelementbyid = document.getelementbyid; document.getelementbyid = function(id) {   if (...) {     return original_getelementbyid(id);   } else {     // special handling here   } } 

Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -