造成异常种族状况的猴子修补阑尾

时间:2018-07-12 12:01:10

标签: javascript hook appendchild monkeypatching

我正在尝试像这样在iframe中修补本机的appendchild:

IframeContentWindow.Node.prototype.__appendChild__ = IframeContentWindow.Node.prototype.appendChild;
Node.prototype.appendChild = function(e){
                               console.log("some Manipulations....");
                               this.__appendChild__(e);

                           };

在我修补iframe appendchild猴子之后,我注入了一些使用document.getelementbyid("some div id").appendchild(somechild);的第三方js代码 现在,如果当我在chrome dev-tools中标记iframe元素并在控制台$0.contentDocument.appendchild中执行($ 0表示我正在标记的iframe元素)时,我正在获取功能,但是如果我正在执行document.getelementbyid("some div id").appendchild时,我得到了本机的appendchild,首先我认为我需要钩住元素实例appendchild,但是经过一些刷新后,有时它确实起作用了,所以我不需要钩住需要标识的特定元素appendchild。比赛条件在哪里发生。想法?

0 个答案:

没有答案