Intercept calls to console.log in Chrome

后端 未结 5 2679
醉梦人生
醉梦人生 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 03:59

    You can also use the same logic, but call it off the console object so the context is the same.

    if(window.console){
      console.yo = console.log;
      console.log = function(str){
        console.yo('MY CONSOLE!!');
        console.yo(str);
      }
    }
    

提交回复
热议问题