Intercept calls to console.log in Chrome

后端 未结 5 2779
醉梦人生
醉梦人生 2020-11-29 03:31

I have a script that I can\'t change that makes a lot of console.log calls. I want to add another layer and respond if the calls contain certain strings. This works in FF, b

5条回答
  •  情话喂你
    2020-11-29 04:07

    With ES6 new spread operator you can write it like this

    (function () {
      var log = console.log;
      console.log = function () {
        log.call(this, 'My Console!!!', ...arguments);
      };
    }());
    

提交回复
热议问题