如何恢复被网站禁用的console.log()函数? [英] How do I restore console.log() function that has been disabled by a website?

查看:2110
本文介绍了如何恢复被网站禁用的console.log()函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

UPDATED:控制台不会记录的原因是网站运行此脚本:

UPDATED: The reason the console won't log is the site runs this script:

    // Production mode
    // Disable console.log
    console.log = function() {};

我猜想没有办法在网站上取回函数?

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

以前版本:

我在Chrome控制台中运行脚本,跟踪网站上的每个人。页面上有200个人,我想遍历所有的跟随按钮,并通过在控制台中运行此脚本来点击它们:

I'm running a script in my Chrome console that follows everyone on a site. There are 200 people on the page, and I want to iterate through all the follow buttons and click them all by running this script in the console:

javascript:var inputs = document.getElementsByClassName('btn-follow'); 
for(var i=0; i<inputs.length; i++) { 
inputs[i].click();
}
console.log("The btn-follow script has finished");

脚本单击按钮很好,但日志语句返回 undefined

The script clicks the buttons fine but the log statement returns undefined.

是否有从控制台登录控制台的方法?

Is there a way to log to the console from within the console?

我直接尝试console.log它看起来像这样:

When I try console.log directly it looks like this:

这里是输入console时输出的内容:

Here is what gets outputted when I type "console":

推荐答案

您可以使用 delete 消除阴影属性:

You can eliminate shadowed properties with delete:

delete console.log;

原始 log 函数 console 的原型)从来没有被覆盖 - 它只是被控制台实例的一个属性隐藏。你可以 delete 的实例函数,让原始的原型函数闪耀。

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.

这篇关于如何恢复被网站禁用的console.log()函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆