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);
  }()
}()

 

posted @ 2022-07-05 08:44  AngDH  阅读(69)  评论(0编辑  收藏  举报