js hook dom

 

 

 

var _appendChild = Node.prototype.appendChild;
Node.prototype.appendChild = function(){
    console.log("Hook appendChild");
    return _appendChild();
};

 

Node.prototype.appendChild = new Proxy(
    Node.prototype.appendChild,{
        apply:function(){
            var retval = Reflect.apply(trapTarget.thisArg,argumentList);
            console.log("appendChild retval:",retval);
            return retval;
         }
​
   }
);

 

posted @ 2022-01-09 13:38  AngDH  阅读(115)  评论(0编辑  收藏  举报