How do I restore console.log() function that has been disabled by a website? [duplicate]

倖福魔咒の 提交于 2019-12-08 18:37:26

You can eliminate shadowed properties with delete:

delete console.log;

The original log function (which exists on console's prototype) was never overwritten -- it has merely been shadowed by a property on the console instance. You can delete the instance function and let the original prototype function shine through.

This works for me:

The log statement I submit (in blue) is followed by it's effect (the message, in black) and the return type of the log expression (in grey).

EDIT

Verify that you haven't replaced the console somehow. You can try the following:

I'm guessing there isn't a way to get the function back on the site?

Since you are using Chrome and can use Object.getPrototypeOf, you can do:

var original_log = Object.getPrototypeOf(console).log;

The log method is defined on the prototype.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!