如果原始浏览器对象已更改,如何获取原始浏览器对象? [英] How to get the original native browser objects, if they have changed?

查看:67
本文介绍了如果原始浏览器对象已更改,如何获取原始浏览器对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

其实整个问题。一种反猴子补丁。如果原始对象(对象,数组,函数,字符串等)及其原型已更改\ expanded \ deleted,如何获取它们?



我现在看到的唯一选项 - 它是动态创建框架 - 拉出他的原生物体 - 动态移除框架。也许可以通过帮助Web Workers完成相同的工作。但是它们> 9,其中没有类DOM,并且它本身与动态帧相同。



框架示例

  delete Object.prototype.constructor; 
delete Object;

console.log(window .__ proto __.__ proto __.__ proto __。constructor); // undefined
// console.log(Object); // undefined

var frame = document.createElement('frame');
document.all [0] .appendChild(frame);

var Object = frames [0] .Object;
document.all [0] .removeChild(frame);
console.log(Object);

这个理论问题。
例如,我们正在开发一个嵌入式库,并且无法知道它何时被调用,所以当它被调用时,可以更改本机浏览器对象。我们需要获得原始对象,初始环境。



也许有其他方法可以解决?



提前致谢。

解决方案

在发布答案之前,我必须告诉你我不会说英语,所以请原谅我拼写法,我没有解决你的问题,但也许这对你有所帮助。



我在寻找几个星期如何获得 toString 内置函数,即使它被重新定义并且没有找到任何东西(除了创建一个新框架,但这个解决方案对我不起作用,因为我使用的是节点js / node webkit)。 / p>

我开始在窗口对象内搜索,对于不可配置的对象,所以没有人可以重新定义它们,我发现了这个:

  Object.getOwnPropertyDescriptor(window,top); 
// Object {value:Window,writable:true,enumerable:true,configurable:false}
Object.getOwnPropertyDescriptor(top .__ proto __,toString);
//对象{值:函数,可写:真,可枚举:false,可配置:false}

因此,如果我访问 top .__ proto __。toString 总是得到真正的内置函数,因为它是不可配置的(到目前为止我找不到替换它的方法)。这对我在webkit客户端上工作,所以我必须继续搜索nodejs的解决方案。



顺便说一句,我删除对象构造函数和你做的一样在顶部找不到对象,但我认为它必须存储在某个地方。我会继续搜索,如果我找到解决方案,我会编辑这篇文章。



我希望我有所帮助。


Actually the whole issue. Kind of anti-monkey patching. How to get the original objects (Object, Array, Function, String, etc) and their prototypes, if they have changed \ expanded \ deleted?

The only option that I see now - it is the dynamic creation of the frame - pulling out of his native objects - Remove the frame on the fly. Perhaps the same can be done with the help Web Workers. But they ie> 9, in which there are no classes DOM, and by itself the same way as the dynamic frame.

Example with frame

delete Object.prototype.constructor;
delete Object;

console.log(window.__proto__.__proto__.__proto__.constructor); // undefined
// console.log(Object); // undefined

var frame = document.createElement('frame');
document.all[0].appendChild(frame);

var Object = frames[0].Object;
document.all[0].removeChild(frame);
console.log(Object);

This theoretical question. For example, we are developing an embedded library, and can not know when it will be called, so by the time it is invoked with the native browser objects can be changed. What we need to get the original objects, the initial environment.

Maybe there are other ways to solve?

Thanks in advance.

解决方案

Before posting my answer, I have to tell you that I do not speak english so excuse me for the orthography, and I do not have a solution for your problem but but maybe this helps you.

I was searching for weeks how to get the toString built-in function even if it was redefined and do not found anything (except for creating a new frame, but this solution do not work for me because I am using node js/node webkit).

I start to search inside the window object, for objects that are not configurable so nobody can redefine them and I found this:

Object.getOwnPropertyDescriptor(window, "top");
//Object {value: Window, writable: true, enumerable: true, configurable: false}
Object.getOwnPropertyDescriptor(top.__proto__, "toString");
//Object {value: function, writable: true, enumerable: false, configurable: false}

So if I access top.__proto__.toString always get the real built-in function because is not configurable (and so far I found no way to replace it). This work for me on a webkit client, so I have to keep searching a solution for nodejs.

By the way, I delete the object constructor same as you did and I can not find Object inside the top, but I think it must be stored somewhere. I will keep searching, if I find a solution I will edit this post.

I hope I have helped.

这篇关于如果原始浏览器对象已更改,如何获取原始浏览器对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆