• js


    !function(){
      var saf;
      ;(function(){
        var $toString = Function.toString
          , cacheI = []
          , cacheS = []
          , idxI = [].indexOf.bind(cacheI)
          , pushI = [].push.bind(cacheI)
          , pushS = [].push.bind(cacheS)
        Object.defineProperty(Function.prototype, 'toString', {
          "enumerable": !1, "configurable": !0, "writable": !0,
          "value": function toString() {
            return typeof this == 'function' && cacheS[idxI(this)] || $toString.call(this);
          }
        })
        function safe_func(func, name){
          if (-1 == idxI(func)){
            pushI(func)
            pushS(`function ${name || func.name || ''}() { [native code] }`)
          }
          return func
        };
        safe_func(Function.prototype.toString, 'toString')
        saf = safe_func
      })();
      window.vilame_getter = window.vilame_getter || {}
      !function(){
        // hook ajax
        try{ var _desc = Object.getOwnPropertyDescriptors(XMLHttpRequest.prototype).open; window.vilame_getter.v_open = _desc.value }catch(e){ return }
        var _new_val = saf(function open(){
          return window.vilame_getter.v_open.apply(this, arguments)
        })
        try{ Object.defineProperty(XMLHttpRequest.prototype, 'open', { value: _new_val, enumerable: _desc['enumerable'], configurable: _desc['configurable'], writable: _desc['writable'], }) }catch(e){  }
      }();
      !function(){
        try{ var _desc = Object.getOwnPropertyDescriptors(XMLHttpRequest.prototype).send; window.vilame_getter.v_send = _desc.value }catch(e){ return }
        var _new_val = saf(function send(){
          return window.vilame_getter.v_send.apply(this, arguments)
        })
        try{ Object.defineProperty(XMLHttpRequest.prototype, 'send', { value: _new_val, enumerable: _desc['enumerable'], configurable: _desc['configurable'], writable: _desc['writable'], }) }catch(e){  }
      }();
      !function(){
        try{ var _desc = Object.getOwnPropertyDescriptors(XMLHttpRequest.prototype).setRequestHeader; window.vilame_getter.v_setRequestHeader = _desc.value }catch(e){ return }
        var _new_val = saf(function setRequestHeader(){
          return window.vilame_getter.v_setRequestHeader.apply(this, arguments)
        })
        try{ Object.defineProperty(XMLHttpRequest.prototype, 'setRequestHeader', { value: _new_val, enumerable: _desc['enumerable'], configurable: _desc['configurable'], writable: _desc['writable'], }) }catch(e){  }
      }();
      !function(){
        try{ var _desc = Object.getOwnPropertyDescriptors(HTMLFormElement.prototype).submit; window.vilame_getter.v_submit = _desc.value }catch(e){ return }
        var _new_val = saf(function submit(){
          return window.vilame_getter.v_submit.apply(this, arguments)
        })
        try{ Object.defineProperty(HTMLFormElement.prototype, 'submit', { value: _new_val, enumerable: _desc['enumerable'], configurable: _desc['configurable'], writable: _desc['writable'], }) }catch(e){  }
      }()
      !function(){
        try{ var _desc = Object.getOwnPropertyDescriptors(Element.prototype).setAttribute; window.vilame_getter.v_setAttribute = _desc.value }catch(e){ return }
        var _new_val = saf(function setAttribute(){
          return window.vilame_getter.v_setAttribute.apply(this, arguments)
        })
        try{ Object.defineProperty(Element.prototype, 'setAttribute', { value: _new_val, enumerable: _desc['enumerable'], configurable: _desc['configurable'], writable: _desc['writable'], }) }catch(e){  }
      }()
      !function(){
        // hook fetch
        window.vilame_getter.v_fetch = window.fetch
        window.fetch = saf(function fetch(){
          return window.vilame_getter.v_fetch.apply(this, arguments)
        })
        window.vilame_getter.v_Request = function(){}
        window.Request = function(_Request) {
          var bind = Function.bind;
          var unbind = bind.bind(bind);
          function instantiate(constructor, args) {
            return new (unbind(constructor, null).apply(null, args));
          }
          var names = Object.getOwnPropertyNames(_Request);
          for (var i = 0; i < names.length; i++) {
            if (names[i]in Request)
              continue;
            var desc = Object.getOwnPropertyDescriptor(_Request, names[i]);
            Object.defineProperty(Request, names[i], desc);
          }
          function Request(url, config) {
            window.vilame_getter.v_Request(arguments)
            return instantiate(_Request, arguments)
          }
          Request.prototype = _Request.prototype
          return saf(Request);
        }(Request);
      }()
    }()
  • 相关阅读:
    [转]MySQL索引类型
    [转]数据结构(全)
    [转]数据结构基础概念篇
    [转]从零开始搭建创业公司后台技术栈
    将博客搬至CSDN
    编译android源代码(aosp)
    【Android】Fresco图片加载框架(二)————Producer
    【Android】Fresco图片加载框架(一)————源码简要分析
    TSL(SSL)相关内容
    谨慎使用AsyncTask
  • 原文地址:https://www.cnblogs.com/angdh/p/16445115.html
Copyright © 2020-2023  润新知