Breaking JavaScript execution always when cookie is set

前端 未结 4 2031
生来不讨喜
生来不讨喜 2020-12-15 10:13

Is it possible to break javascript execution in FireBug or in some other web developer tool always when cookie is set (without setting JS breakpoints explicitly)?

<         


        
4条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-15 10:46

    This should work (run it in a console):

    origDescriptor = Object.getOwnPropertyDescriptor(HTMLDocument.prototype, 'cookie');
    Object.defineProperty(document, 'cookie', {
      get() {
        return origDescriptor.get.call(this);
      },
      set(value) {
        debugger;
        return origDescriptor.set.call(this, value);
      },
      enumerable: true,
      configurable: true
    });
    

提交回复
热议问题